Quotes
There are two types of token-swap quotes you can get from Dexible: spot and execution. Spot quotes are just the market average exchange rate between two tokens. Execution quotes will generate an execution plan and split an order into multiple rounds to minimize price impact on the market. Both of these are done through Dexible's 'exchange' property.
TokenExchange
Dexible continues to evolve in automating DeFi interactions. In the future, it will support more than simple token swaps. As such, Dexible V2.0 is a step towards separating the types of automations that can be done on Dexible. The 'exchange' property is an instance of a TokenExchange which handles all things token-swap related, including getting quotes.
Spot Quote
To get a spot quote, you just have supply the two tokens being exchanged and a current market price is provided.
The price above is a decimal number representing the price expressed in quoteToken units. In this case, it would be expressed in USDC.
Execution Quote
To generate an execution plan, Dexible needs to know what type of order you want to execute. There are 7 order types supported (see Algos section). In most cases, a MarketSwap type is all that's needed to get an idea of Dexible's execution plan. Here is an example that also includes some customizations for a quote using a TWAP swap. It includes DexFilters that will limit the DEXs included in Dexible's execution plan. We will discuss those more later.
Dexible will return a quote that represents a recommended execution plan based on specified details. It includes a min/max amount out, which represents before/after slippage but always AFTER fees have been deducted. Note that gas fees are estimates at the time of the quote. The value may vary if the gas market is volatile. Here is an example that uses a fixed gas price so that Dexible will only execute the swap when gas prices are at or below a specified rate:
Swap Customizations
Here is the expected output from a quote request:
Most of the fields are self-explanatory. Note the min/max amount out. Both of these are after the bps and estimated gas fees are applied. The feeToken represents the token used to capture fees. Rounds is the number of segments an order will be split into. The total estimated gas is an estimate of all gas fees for all rounds in the order. It's based on current gas prices or the fixed gas price you provided.
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