Skip to main content

slipe

"amountUSD": "500.9777",

tracking down the request on our side this is the payload passed

"path": "/v1/quote/",
"type": "Request",
"query": {
"fromChain": "56",
"toChain": "56",
"fromToken": "BNB",
"toToken": "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",
"fromAddress": "0x709b6d9Bc8EC95e3F451fE992684B1c9a1Ff5aCE",
"fromAmount": "741424837428597200",
"slippage": 0.03,
"order": "CHEAPEST",
"maxPriceImpact": 0.1,
"allowDestinationCall": true
},

for which sushiswap quote was return with

toAmount "516575012030983962624"
toAmountMin "501077761670054443745"
toAmountUSD "516.4717"

so you have received 501 usdc - the guaranteed minimum value that the transfer will yield including slippage https://apidocs.li.fi/reference/get_v1-quote which was also returned in the response of the API in the toAmountMin field

怎么计算这个值在滑点区间

To calculate the value within the slippage range, you can follow these steps:

  1. Understand the Terms:

    • toAmount: The expected amount you will receive.
    • toAmountMin: The minimum amount you will receive after considering slippage.
    • slippage: The percentage of price movement you are willing to tolerate.
  2. Calculate Slippage:

    • The slippage percentage here is 3% (0.03).
    • The toAmountMin is the guaranteed minimum amount, which accounts for this slippage.
  3. Verify the Slippage Calculation:

    • Start with the toAmount: 516.5750 (converted from 516575012030983962624 assuming a decimal point for USDC).

    • Calculate the minimum expected amount considering slippage:

      toAmountMin=toAmount×(1slippage)\text{toAmountMin} = \text{toAmount} \times (1 - \text{slippage})

    • Plug in the numbers:

      toAmountMin=516.5750×(10.03)=501.07775\text{toAmountMin} = 516.5750 \times (1 - 0.03) = 501.07775

  4. Compare with toAmountMin from API:

    • The API returned toAmountMin as 501.0777, which matches our calculation.

This confirms that the slippage calculation aligns with the expected minimum amount you could receive.