Skip to content

[API] Swap Quote Endpoint Improvements

Eridanus (9R) requested to merge eridanus/quote_endpoint into develop

This PR changes a few things about the Swap Quote Endpoint:

  • No longer errors out if the quote is for a synth asset and the from_address doesn't have sufficient synth asset balance
  • Adds a recommended_min_amount_in value (explanation below)
  • If the source chain is THORChain, don't return an inbound_address and fix the "Notes". There is no inbound address for THORChain inbounds, a MsgDeposit is just broadcasted to the network

recommended_min_amount_in is: MAX(outbound_fee(src_chain), outbound_fee(dest_chain)) * 4

The motivation for returning this value is right now front-ends need to reason themselves about what the minimum swap amount should be for a pair. Functionally, the minimum swap amount needs to be AT VERY LEAST the MAX of the fees on the source & destination chain. This is because if the swap is refunded the input amount needs to cover the outbound fees of the source chain. A 4x buffer is applied on top of this because outbound fees can spike quickly, and inbounds can take awhile to confirm (BTC mostly). We've seen many cases where the original inbound takes a long time to confirm and in that time the outbound fees spike, meaning when the swap is refunded due to limit not being met the original input can no longer cover the outbound fee of the source chain, and the entire swap is eaten. Returning this value handles this logic for the front-ends, simplifying their integration.

Edited by Eridanus (9R)

Merge request reports