/fungible/route
and /fungible/msgs_direct
endpoints return a ton of useful information.
In addition to showing estimated amount in and out (the obvious ones), we recommend showing:
response.usd_amount_in
)response.usd_amount_out
)response.swap_price_impact_percent
) — This measures how much the user’s expected execution price differs from the current on-chain spot price at time of execution. A high price impact means the user’s swap size is large relative to the available on chain liquidity that they’re swapping against, which makes a bad price very likely.swap_venue
field of the swap
operation in response.operations
) - This tells the user what DEX they’re actually performing the underlying swap on, which helps avoid confusion about prices. This can be useful information in the event the API returns an usual route and routes the user to a DEX they’re unfamiliar with / don’t want to use or to a DEX where there’s not much liquidity of the token they’re swapping (e.g. SEI liquidity on Osmosis is sparse at the time of this writing)transfer
and axelar_transfer
entries in response.operations
under fee_asset
and fee_amount
) — These represent the fees that bridges take from the user along the route, denominated in the token(s) they’re taking. It’s important to show because sometimes bridges take fees unexpectedly (e.g. Noble used to take 0.10% fee on IBC transfers), and sometimes they take large fees (e.g. During periods of high gas prices, Axelar fees can be as high as $200)transfer
and axelar_transfer
entries in response.operations
under usd_fee_amount
) — This gives the user a sense of the actual cost of their fee amounts. In cases of more complex swaps and transfers, the user might have a hard time making sense of the underlying fee tokens because the fees are being charged at an intermediate point in the route/route
and displayed the quote to the user, a call to /msgs
is the only way to generate the correct message. (DO NOT call /msgs_direct
after calling /route
since this will regenerate the quote)
Alternatively you can call /msgs_direct
to both generate the quote information and the transaction that needs to be signed with 1 request. Remember that these endpoints are not deterministic and calling either again will generate a different output and your user will not execute the transaction they think they are executing.
swap_price_impact > PRICE_IMPACT_THRESHOLD
) : This indicates the user’s swap is executing at a considerably worse price than the on-chain spot price — meaning they’re probably getting a worse price than they think they should. It also indicates the size of their trade is large relative to the available on chain liquidity. We recommend usingPRICE_IMPACT_THRESHOLD = 2.5
in your calculations(usd_amount_in - usd_amount_out)/usd_amount_in)*100 > USD_REL_VALUE_THRESHOLD
): This estimates the underlying value the user will lose instantly as a result of swapping, represented as a percentage of the value of their input. A high value for this figure indicates the user is instantly losing a large percentage of the value of their starting tokens. For example, a value of 50 indicates the user loses 50% of the estimated value of their input. We recommend using USD_REL_VALUE_THRESHOLD=2.5
usd_fee_amount / usd_amount_in > FEE_THRESHOLD
) : This indicates that the value of fees charged by bridges used in the route amount to a large percentage of the underlying amount being transferred. If this value is high, user might want to wait until bridging more funds to execute (since bridge fees rarely scale with volume). We recommend setting FEE_THRESHOLD=.25
PRICE_IMPACT_THRESHOLD
on go.skip.build, we auto-open the drop-down that normally hides price impact and highlight the whole field in red.
(usd_amount_in - usd_amount_out)/usd_amount_in)*100 > 10
swap_price_impact > 10
)(usd_amount_in - usd_amount_out)/usd_amount_in)*100 > 5
swap_price_impact > 5
)swap_price_impact
, usd_amount_out
, and/or usd_amount_in
are missing)