Quotes

Once you've established the tokens you want to trade, and the amount you want to trade, you may want to get a price quote from Dexible to determine current market pricing and fees. The SDK instance has a "quote" property that allows you to get quotes quickly.

let quote = sdk.quote.getQuote({
    tokenIn, //WETH
    tokenOut, //MATIC,
    amountIn: ethers.utils.parseUnits("20", tokenIn.decimals),
    slippagePercent: .5,
    //optionally set max rounds for the quote
    //maxRounds: 10, 
    //optionall set a max fixed gas price to apply to the quote fees
    //maxFixedGas: ethers.utils.parseUnits("10", 9)
});

Dexible will return an array with two quotes: immediate and recommended, in that order. The immediate quote is for a single round so that you can compare the price impact of your full order on the market. Sometimes, the immediate and recommended quotes will match if Dexible determines it's the best outcome. Both quotes have the following structure:

{
    id: 13,
    tokenIn: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
    tokenOut: '0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0',
    amountInPerRound: '20000000000000000000',
    amountOutPerRound: '41162692560851345024700',
    maxNetOutput: '41162576735049726266880',
    minNetOutput: '40956418895145987335127',
    networkId: 1,
    rounds: 1,
    costPercentage: 0.0016816710779981633,
    minTotalFees: 68914601737519830000,
    maxTotalFees: 69120759577423570000,
    expires: '2021-07-12T22:06:54.687Z'
 }

Most of the fields are self-explanatory. The amounts in/out per round shows what Dexible will send to DEX's as input and what it expects you to receive per round (before fees). Then it deducts fees, including gas costs, and gives you the min/max NET outputs. This is what you can expect to receive after fees are taken from the output side. There is also a cost percentage showing what portion of the proceeds are going towards gas and fees. Finally, the min/max fees are provided to give you an idea of the best/worst case scenarios on cost. Note that in most cases, actual fees will be slightly less than the estimate. This is because we have to use a high gas usage amount when estimating actual transaction costs. This results in estimates with higher gas costs than what will actually be used.

Quotes provide min/max amounts due to the slippage applied to the round. In some cases, full slippage may be realized in the market while other times, no slippage will occur. This gives a best/worst case scenario or min/max.

Last updated