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:
-
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.
-
Calculate Slippage:
- The slippage percentage here is 3% (0.03).
- The
toAmountMinis the guaranteed minimum amount, which accounts for this slippage.
-
Verify the Slippage Calculation:
-
Start with the
toAmount: 516.5750 (converted from516575012030983962624assuming a decimal point for USDC). -
Calculate the minimum expected amount considering slippage:
-
Plug in the numbers:
-
-
Compare with
toAmountMinfrom API:- The API returned
toAmountMinas 501.0777, which matches our calculation.
- The API returned
This confirms that the slippage calculation aligns with the expected minimum amount you could receive.