Getting a Quote

/quote endpoint of DNL API should be used only to display outcomes of the trades when the address of the user is unknown (e.g. to let the user see prices of cross-chain trades before he connects the wallet to the Dapp).

Whenever an address is known, make sure to call /create-tx directly.

To place 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).

The /v1.0/dln/order/quote endpoint 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/quote endpoint with the following parameter values:




specifies the ID of the BNB Chain as the chain where an order would be placed



sets the input token (the user is willing to give) to the USDC token address on the BNB Chain



specifies the desired input amount: since the USDC token contract uses 18 decimals (the number of digits that come after the decimal place when displaying token values on-screen), the simple math: 100*10^18 leads to 100000000000000000000 as the value representing 100 USDC tokens



specified the Avalanche network chain ID as the destination chain where an order should be fulfilled



sets the output token (the user is willing to take) to the USDT token address on Avalanche



asks the API to add the approximate amount of operating expenses to the amount of input token before making a quote



asks the order to accrue the given share of input amount, which would be paid after an order gets fulfilled and unlocked

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.recommendedAmount property — 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:

    "estimation": {
            "srcChainTokenIn": {
                    "address": "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
                    "decimals": 18,
                    "name": "USD Coin",
                    "symbol": "USDC",
                    "chainId": 56,
                    "approximateOperatingExpense": "722632000000000000",
            "dstChainTokenOut": {
                    "address": "0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7",
                    "decimals": 6,
                    "name": "TetherToken",
                    "symbol": "USDt",
                    "chainId": 43114,
                    "amount": "99623050",
    "tx": {
        "allowanceTarget": "0xeF4fB24aD0916217251F553c0596F8Edc630EB66",
        "allowanceValue": "100722632000000000000"

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.

Last updated