Getting a Quote
To place such an order that would be reasonably profitable to incentivize a taker to fulfill it, a quote must not only reflect the current market exchange rate but also include relevant fees: the affiliate fee (in case you are going to collect an affiliate fee), the DLN protocol fee, the taker's margin fee; additionally, a quote must cover all implicit operating expenses incurred by a taker during and after order fulfillment (that includes Taker's gas costs for fulfillment and unlock of liquidity in the source chain).
/v1.0/dln/order/quoteendpoint performs all necessary calculations to provide the best reasonable quote for the given input.
Let's get a quote for our use-case by calling the
/v1.0/dln/order/quoteendpoint with the following parameter values:
Calling the endpoint:
gives a response with the recommended amount of input token, and several details describing how it has been calculated. The recommended amount of the output token (USDT in our case) available in the
estimation.dstChainTokenOut.recommendedAmountproperty — this is the amount that can be suggested to a user for explicit approval before placing an order.
At the time of writing, the response contains the following values:
"name": "USD Coin",
This response states that executing an order to swap 100 USDC on BNB Chain to USDT on Avalanche requires approximately 0.722632 USDC, so this has been added to the input amount, resulting 100.722632 USDC to be charged from the user upon order creation.
Additionally, 0.100722632 USDC is accrued as an affiliate fee upon order creation.
The affiliate fee is paid only after the order gets fulfilled, and after the taker has unlocked the order in the source chain.
The most important part is the recommended amount of the output token: the API endpoint assumes that takers would be incentivized to fulfill an order with the given input at the time of the request if taking 99.623050 USDT. Not bad for a cross-chain swap!
If a user is comfortable with the quote, a transaction to create a limit order with the given quote can be requested.