Skip to content

Latest commit

 

History

History
132 lines (99 loc) · 2.69 KB

fetch-request.md

File metadata and controls

132 lines (99 loc) · 2.69 KB

Fetch Request

Obtaining

dexter.newFetchRequest()
    ...

FetchRequest API

Omitting the forTokens() & forTokenPairs() when constructing your request will result in all possible pools.

Omitting the forDexs() & forAllDexs() when constructing your request will result in all available DEXs to be used when fetching pools.

onDexs(string | string[]): FetchRequest Set which DEXs to grab information for.
Using
dexter.newFetchRequest()
    .onDexs(WingRiders.identifier)
    ...

or

dexter.newFetchRequest()
    .onDexs([WingRiders.identifier, SundaeSwap.identifier])
    ...

onAllDexs(): FetchRequest Grab information from all available DEXs.
Using
dexter.newFetchRequest()
    .onAllDexs()
    ...

setDataProviderForDex(string, BaseDataProvider): FetchRequest Force a data provider for a DEX.
Using
dexter.newFetchRequest()
    .onAllDexs()
    ...

forTokens(Token[]): FetchRequest Set filtering tokens when fetching liquidity pools
Using
const indyAsset: Asset = new Asset('533bb94a8850ee3ccbe483106489399112b74c905342cb1792a797a0', '494e4459', 6);

// Will only fetch pools containing the INDY token
dexter.newFetchRequest()
    .forTokens([indyAsset])
    ...

forTokenPairs(Token[][]): FetchRequest Set filtering token pairs when fetching liquidity pools
Using
const indyAsset: Asset = new Asset('533bb94a8850ee3ccbe483106489399112b74c905342cb1792a797a0', '494e4459', 6);

// Will only fetch pools containing ADA & INDY assets
dexter.newFetchRequest()
    .forTokenPairs([
        ['lovelace', indyAsset],
    ])
    ...

getLiquidityPools(): Promise<LiquidityPool[]> Fetch liquidity pools from your set DEXs

Providing the first or first & second parameters will filter the returned pools by the assets you provide.

Using
dexter.newFetchRequest()
    .onAllDexs()
    .getLiquidityPools()
    .then((pools: LiquidityPool[]) => {
        console.log(pools);
    });

getLiquidityPoolState(LiquidityPool): Promise<LiquidityPool> Fetch latest state for a liquidity pool
Using
dexter.newFetchRequest()
    .getLiquidityPoolState(liquidityPool)
    .then((pool: LiquidityPool) => {
        console.log(pool);
    });