CrustRouter01
Mantle0x2c2954cf16f974033e1e2345fce1ca434dc14497
Solidity v0.8.13+commit.abaa5c0e
概覽
讀取函式
Returns the address of the factory contract used by this router.✨ AI
回傳值
| 名稱 | 類型 | 描述 |
|---|---|---|
| — | address | The factory contract address that the router uses to create and manage liquidity pairs.✨ AI |
Calculate the output token amount and indicate whether the swap will use a stable pool.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| amountIn | uint256 | Input token amount to swap.✨ AI |
| tokenIn | address | Address of the token being sold.✨ AI |
| tokenOut | address | Address of the token being bought.✨ AI |
回傳值
| 名稱 | 類型 | 描述 |
|---|---|---|
| amount | uint256 | Estimated amount of tokenOut received for the given amountIn and route.✨ AI |
| stable | bool | Boolean indicating whether the selected pair is a stable (low-slippage) pool.✨ AI |
Calculate the expected output amounts for a multi-hop swap given an input amount and routes.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| amountIn | uint256 | Amount of input tokens to start the swap.✨ AI |
| routes | tuple[] | Array of route tuples defining each hop in the swap path and its pool parameters.✨ AI |
回傳值
| 名稱 | 類型 | 描述 |
|---|---|---|
| amounts | uint256[] | Array of amounts for each step of the path: amounts[0] == amountIn, later entries are expected outputs after each hop.✨ AI |
Calculate the exact amount of tokenOut you will receive for a given tokenIn amount.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| amountIn | uint256 | Amount of input tokens to swap (in tokenIn's smallest unit).✨ AI |
| tokenIn | address | Address of the token being sold.✨ AI |
| tokenOut | address | Address of the token being bought.✨ AI |
| stable | bool | True to use the stable pool formula, false for the volatile pool.✨ AI |
回傳值
| 名稱 | 類型 | 描述 |
|---|---|---|
| — | uint256 | Exact amount of tokenOut (in tokenOut's smallest unit) that the swap will produce.✨ AI |
Return the current reserves for a token pair from the selected stable or volatile pool.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| tokenA | address | Address of the first token in the pair.✨ AI |
| tokenB | address | Address of the second token in the pair.✨ AI |
| stable | bool | True to select the stable-pair pool variant; false for the regular pool.✨ AI |
回傳值
| 名稱 | 類型 | 描述 |
|---|---|---|
| reserveA | uint256 | reserveA: Reserve amount for tokenA in the chosen pool.✨ AI |
| reserveB | uint256 | reserveB: Reserve amount for tokenB in the chosen pool.✨ AI |
Return whether the given address is a registered liquidity pair.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| pair | address | Address to check if it is a registered liquidity pair.✨ AI |
回傳值
| 名稱 | 類型 | 描述 |
|---|---|---|
| — | bool | True if the address is a registered liquidity pair, otherwise false.✨ AI |
Return the pair contract address for the specified token pair and stability flag.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| tokenA | address | Address of the first token in the pair.✨ AI |
| tokenB | address | Address of the second token in the pair.✨ AI |
| stable | bool | Whether to select the stable-pair variant (true) or the volatile variant (false).✨ AI |
回傳值
| 名稱 | 類型 | 描述 |
|---|---|---|
| pair | address | pair: The address of the liquidity pair contract for the given tokens and stable flag.✨ AI |
Calculate optimal token amounts and the estimated liquidity tokens returned when adding liquidity to the pair.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| tokenA | address | Address of the first token in the pair.✨ AI |
| tokenB | address | Address of the second token in the pair.✨ AI |
| stable | bool | True to use the stable pool formula, false to use the volatile pool formula.✨ AI |
| amountADesired | uint256 | Desired amount of tokenA the caller intends to deposit.✨ AI |
| amountBDesired | uint256 | Desired amount of tokenB the caller intends to deposit.✨ AI |
回傳值
| 名稱 | 類型 | 描述 |
|---|---|---|
| amountA | uint256 | Adjusted amount of tokenA that should be deposited given the pool ratio.✨ AI |
| amountB | uint256 | Adjusted amount of tokenB that should be deposited given the pool ratio.✨ AI |
| liquidity | uint256 | Estimated number of liquidity tokens that would be minted for the deposit.✨ AI |
Calculates the equivalent amount of token B for a given amountA using reserveA and reserveB to preserve the pool ratio.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| amountA | uint256 | Amount of token A to quote.✨ AI |
| reserveA | uint256 | Current reserve of token A in the pair.✨ AI |
| reserveB | uint256 | Current reserve of token B in the pair.✨ AI |
回傳值
| 名稱 | 類型 | 描述 |
|---|---|---|
| amountB | uint256 | Equivalent amount of token B for amountA, computed as amountA * reserveB / reserveA.✨ AI |
Calculate token amounts returned when removing a specific amount of liquidity from a token pair.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| tokenA | address | Address of the first token in the pair.✨ AI |
| tokenB | address | Address of the second token in the pair.✨ AI |
| stable | bool | True if the pair is a stable pool, false if the pool is volatile.✨ AI |
| liquidity | uint256 | Amount of LP tokens to burn to withdraw underlying tokens.✨ AI |
回傳值
| 名稱 | 類型 | 描述 |
|---|---|---|
| amountA | uint256 | Amount of tokenA that will be returned when burning the specified liquidity.✨ AI |
| amountB | uint256 | Amount of tokenB that will be returned when burning the specified liquidity.✨ AI |
Return the two token addresses in ascending order to produce a canonical pair ordering.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| tokenA | address | First token address to compare.✨ AI |
| tokenB | address | Second token address to compare.✨ AI |
回傳值
| 名稱 | 類型 | 描述 |
|---|---|---|
| token0 | address | token0: the smaller token address (by numeric value).✨ AI |
| token1 | address | token1: the larger token address (by numeric value).✨ AI |
Returns the address of the wrapped native token (WMNT) used by the router.✨ AI
回傳值
| 名稱 | 類型 | 描述 |
|---|---|---|
| — | address | The wrapped native token contract address (WMNT).✨ AI |
寫入函式
Swap an exact amount of input tokens through specified routes and send the output to the recipient before the deadline.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| amounts | uint256[] | Array of token amounts per step; the first element is the exact input amount.✨ AI |
| routes | tuple[] | Array of route tuples defining each swap leg (token path and pool identifiers).✨ AI |
| to | address | Recipient address that will receive the final output tokens.✨ AI |
| deadline | uint256 | Unix timestamp after which the swap transaction will revert.✨ AI |
回傳值
| 名稱 | 類型 | 描述 |
|---|---|---|
| — | uint256[] | Array of output amounts for each token in the swap sequence, ordered from input to final output.✨ AI |
Add liquidity to a token pair and receive liquidity tokens in return.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| tokenA | address | Address of the first token in the pair.✨ AI |
| tokenB | address | Address of the second token in the pair.✨ AI |
| stable | bool | If true, use the pair's stable swap logic; otherwise use volatile logic.✨ AI |
| amountADesired | uint256 | Desired amount of tokenA to deposit.✨ AI |
| amountBDesired | uint256 | Desired amount of tokenB to deposit.✨ AI |
| amountAMin | uint256 | Minimum amount of tokenA to accept (slippage protection).✨ AI |
| amountBMin | uint256 | Minimum amount of tokenB to accept (slippage protection).✨ AI |
| to | address | Recipient address that will receive the minted liquidity tokens.✨ AI |
| deadline | uint256 | Unix timestamp after which the transaction will revert.✨ AI |
回傳值
| 名稱 | 類型 | 描述 |
|---|---|---|
| amountA | uint256 | Amount of tokenA actually deposited into the pair.✨ AI |
| amountB | uint256 | Amount of tokenB actually deposited into the pair.✨ AI |
| liquidity | uint256 | Amount of liquidity tokens minted and sent to the recipient.✨ AI |
Adds liquidity to a token–MNT pool and returns the deposited token and MNT amounts plus minted LP tokens.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| token | address | Address of the ERC20 token paired with MNT.✨ AI |
| stable | bool | True to use a stable swap pool calculation, false for a volatile pool.✨ AI |
| amountTokenDesired | uint256 | Desired amount of token to add as liquidity.✨ AI |
| amountTokenMin | uint256 | Minimum accepted token amount; transaction reverts if lower.✨ AI |
| amountMNTMin | uint256 | Minimum accepted MNT amount; transaction reverts if lower.✨ AI |
| to | address | Recipient address that will receive the minted liquidity tokens.✨ AI |
| deadline | uint256 | Unix timestamp after which the transaction becomes invalid.✨ AI |
回傳值
| 名稱 | 類型 | 描述 |
|---|---|---|
| amountToken | uint256 | amountToken: Actual amount of the ERC20 token deposited into the pool.✨ AI |
| amountMNT | uint256 | amountMNT: Actual amount of MNT deposited into the pool.✨ AI |
| liquidity | uint256 | liquidity: Amount of LP tokens minted and sent to the recipient.✨ AI |
Removes liquidity from a token pair and transfers the underlying tokens to the recipient.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| tokenA | address | First token of the pair.✨ AI |
| tokenB | address | Second token of the pair.✨ AI |
| stable | bool | Whether the pair is a stable (true) or volatile (false) pool.✨ AI |
| liquidity | uint256 | Amount of liquidity tokens to burn.✨ AI |
| amountAMin | uint256 | Minimum acceptable amount of tokenA to receive (slippage protection).✨ AI |
| amountBMin | uint256 | Minimum acceptable amount of tokenB to receive (slippage protection).✨ AI |
| to | address | Address that will receive the withdrawn tokens.✨ AI |
| deadline | uint256 | Unix timestamp after which the transaction will revert if not executed.✨ AI |
回傳值
| 名稱 | 類型 | 描述 |
|---|---|---|
| amountA | uint256 | Amount of tokenA returned to the recipient.✨ AI |
| amountB | uint256 | Amount of tokenB returned to the recipient.✨ AI |
Remove liquidity from a token–MNT pair and transfer the resulting token and MNT amounts to the recipient.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| token | address | Address of the ERC20 token paired with MNT.✨ AI |
| stable | bool | True if the pair uses the stable curve variant, false for the volatile curve.✨ AI |
| liquidity | uint256 | Amount of LP tokens to burn to withdraw underlying assets.✨ AI |
| amountTokenMin | uint256 | Minimum acceptable amount of the ERC20 token to receive, otherwise revert.✨ AI |
| amountMNTMin | uint256 | Minimum acceptable amount of MNT to receive, otherwise revert.✨ AI |
| to | address | Recipient address that will receive the withdrawn token and MNT.✨ AI |
| deadline | uint256 | Unix timestamp after which the transaction will revert if not executed.✨ AI |
回傳值
| 名稱 | 類型 | 描述 |
|---|---|---|
| amountToken | uint256 | amountToken: Amount of ERC20 token received and transferred to the recipient.✨ AI |
| amountMNT | uint256 | amountMNT: Amount of MNT received and transferred to the recipient.✨ AI |
Removes liquidity from a token-MNT pair and transfers the withdrawn tokens to the recipient, supporting fee-on-transfer tokens.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| token | address | ERC20 token address paired with MNT.✨ AI |
| stable | bool | True if the pair is a stable pool, false otherwise.✨ AI |
| liquidity | uint256 | Amount of LP tokens to burn.✨ AI |
| amountTokenMin | uint256 | Minimum acceptable amount of the ERC20 token to receive.✨ AI |
| amountMNTMin | uint256 | Minimum acceptable amount of MNT (native token) to receive.✨ AI |
| to | address | Recipient address that will receive the withdrawn tokens.✨ AI |
| deadline | uint256 | Unix timestamp after which the transaction will revert.✨ AI |
回傳值
| 名稱 | 類型 | 描述 |
|---|---|---|
| amountToken | uint256 | Amount of the ERC20 token received after removing liquidity.✨ AI |
| amountFTM | uint256 | Amount of native chain token (MNT/FTM) received after removing liquidity.✨ AI |
Remove liquidity from a token–MNT pair using an off-chain permit signature.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| token | address | Address of the non-MNT token in the liquidity pair.✨ AI |
| stable | bool | True for the stable-pair variant, false for the volatile-pair variant.✨ AI |
| liquidity | uint256 | Amount of LP tokens to burn (amount of liquidity to remove).✨ AI |
| amountTokenMin | uint256 | Minimum acceptable amount of the non-MNT token to receive, else revert.✨ AI |
| amountMNTMin | uint256 | Minimum acceptable amount of MNT to receive, else revert.✨ AI |
| to | address | Recipient address to receive the withdrawn tokens.✨ AI |
| deadline | uint256 | Unix timestamp after which the transaction will revert if not executed.✨ AI |
| approveMax | bool | If true, permit approves max uint256 allowance; otherwise approves 'liquidity'.✨ AI |
| v | uint8 | Signature v value for the permit.✨ AI |
| r | bytes32 | Signature r value for the permit.✨ AI |
| s | bytes32 | Signature s value for the permit.✨ AI |
回傳值
| 名稱 | 類型 | 描述 |
|---|---|---|
| amountToken | uint256 | amountToken: Actual amount of the non-MNT token sent to the recipient.✨ AI |
| amountMNT | uint256 | amountMNT: Actual amount of MNT tokens sent to the recipient.✨ AI |
Remove liquidity from a token–MNT pair using an off-chain permit and support fee-on-transfer tokens.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| token | address | Address of the ERC20 token in the liquidity pair.✨ AI |
| stable | bool | If true, use the stable-swap variant of the pair.✨ AI |
| liquidity | uint256 | Amount of pair LP tokens to burn/remove.✨ AI |
| amountTokenMin | uint256 | Minimum acceptable amount of the ERC20 token to receive.✨ AI |
| amountMNTMin | uint256 | Minimum acceptable amount of MNT (native token) to receive.✨ AI |
| to | address | Recipient address for the withdrawn assets.✨ AI |
| deadline | uint256 | Unix timestamp after which the transaction reverts.✨ AI |
| approveMax | bool | If true, the permit approves max uint256 instead of the exact liquidity amount.✨ AI |
| v | uint8 | Signature recovery byte for the permit.✨ AI |
| r | bytes32 | First 32 bytes of the permit signature.✨ AI |
| s | bytes32 | Second 32 bytes of the permit signature.✨ AI |
回傳值
| 名稱 | 類型 | 描述 |
|---|---|---|
| amountToken | uint256 | Amount of ERC20 token actually sent to `to` after removal.✨ AI |
| amountFTM | uint256 | Amount of native MNT (FTM) actually sent to `to` after removal.✨ AI |
Remove liquidity from a token pair using an off-chain permit signature and send the resulting tokens to the recipient.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| tokenA | address | Address of the first token in the pair.✨ AI |
| tokenB | address | Address of the second token in the pair.✨ AI |
| stable | bool | True if removing from a stable pair variant, false for volatile pair.✨ AI |
| liquidity | uint256 | Amount of LP tokens to burn/remove.✨ AI |
| amountAMin | uint256 | Minimum amount of tokenA to accept (slippage protection).✨ AI |
| amountBMin | uint256 | Minimum amount of tokenB to accept (slippage protection).✨ AI |
| to | address | Recipient address that will receive the withdrawn tokens.✨ AI |
| deadline | uint256 | Unix timestamp after which the transaction will revert.✨ AI |
| approveMax | bool | If true, interpret the permit as approval for max uint256 allowance.✨ AI |
| v | uint8 | Recovery identifier (v) of the ECDSA permit signature.✨ AI |
| r | bytes32 | R component of the ECDSA permit signature.✨ AI |
| s | bytes32 | S component of the ECDSA permit signature.✨ AI |
回傳值
| 名稱 | 類型 | 描述 |
|---|---|---|
| amountA | uint256 | amountA: Actual amount of tokenA transferred to the recipient.✨ AI |
| amountB | uint256 | amountB: Actual amount of tokenB transferred to the recipient.✨ AI |
Swap an exact amount of MNT (sent with the call) for tokens following the given routes and deliver output to the recipient.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| amountOutMin | uint256 | Minimum total amount of output tokens required for the swap to succeed, otherwise it reverts.✨ AI |
| routes | tuple[] | Array of route tuples that define each swap hop, intermediate pools and token path for the MNT swap.✨ AI |
| to | address | Recipient address that will receive the output tokens.✨ AI |
| deadline | uint256 | Unix timestamp after which the transaction will revert if not executed.✨ AI |
回傳值
| 名稱 | 類型 | 描述 |
|---|---|---|
| amounts | uint256[] | amounts: Array of token amounts for each hop in the route; the last element is the final output amount delivered to 'to'.✨ AI |
Swap the exact MNT sent for tokens along the given routes; supports fee-on-transfer tokens.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| amountOutMin | uint256 | Minimum amount of output tokens to accept.✨ AI |
| routes | tuple[] | Array of route tuples defining each swap hop and associated pair info.✨ AI |
| to | address | Recipient address for the final output tokens.✨ AI |
| deadline | uint256 | Unix timestamp after which the transaction will revert.✨ AI |
Swap an exact amount of input tokens for MNT through the specified routes and send the result to the recipient.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| amountIn | uint256 | Exact amount of input tokens to swap.✨ AI |
| amountOutMin | uint256 | Minimum acceptable amount of MNT; transaction reverts if output is lower.✨ AI |
| routes | tuple[] | Array of route tuples defining swap paths, pools, and intermediate tokens.✨ AI |
| to | address | Recipient address that will receive the output MNT tokens.✨ AI |
| deadline | uint256 | Unix timestamp after which the transaction will revert if not executed.✨ AI |
回傳值
| 名稱 | 類型 | 描述 |
|---|---|---|
| amounts | uint256[] | Amounts of tokens for each step of the swap, starting with amountIn and ending with the final MNT amount.✨ AI |
Swap an exact amount of input tokens for MNT and send the resulting MNT to the recipient, supporting fee-on-transfer tokens.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| amountIn | uint256 | Exact amount of input tokens to swap.✨ AI |
| amountOutMin | uint256 | Minimum acceptable amount of MNT to receive; reverts if the output is lower.✨ AI |
| routes | tuple[] | Array of route tuples describing each swap hop and pool to use.✨ AI |
| to | address | Recipient address that will receive the output MNT tokens.✨ AI |
| deadline | uint256 | Unix timestamp after which the transaction becomes invalid.✨ AI |
Swap an exact amount of input tokens for output tokens along the specified routes, subject to slippage and deadline.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| amountIn | uint256 | Exact amount of input tokens to send into the first pool.✨ AI |
| amountOutMin | uint256 | Minimum acceptable final output amount; transaction reverts if received < this.✨ AI |
| routes | tuple[] | Array of route tuples describing each hop: pool addresses, token path, and swap direction.✨ AI |
| to | address | Address that will receive the final output tokens.✨ AI |
| deadline | uint256 | Unix timestamp after which the transaction is invalid and will revert.✨ AI |
回傳值
| 名稱 | 類型 | 描述 |
|---|---|---|
| amounts | uint256[] | amounts: Array of uint256 amounts for each hop (input amount and successive output amounts); final element is amount received.✨ AI |
Swaps an exact amount of tokenFrom for tokenTo through a single pool (stable or volatile) and sends output to the recipient.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| amountIn | uint256 | Exact amount of input tokens to swap.✨ AI |
| amountOutMin | uint256 | Minimum acceptable amount of output tokens; reverts if the result is lower.✨ AI |
| tokenFrom | address | Address of the input ERC20 token.✨ AI |
| tokenTo | address | Address of the output ERC20 token.✨ AI |
| stable | bool | True to route through the stable pool variant, false to use the volatile pool.✨ AI |
| to | address | Recipient address that will receive the output tokens.✨ AI |
| deadline | uint256 | Unix timestamp after which the transaction will revert if not processed.✨ AI |
回傳值
| 名稱 | 類型 | 描述 |
|---|---|---|
| amounts | uint256[] | Array of token amounts for each hop in the swap path, typically [amountIn, amountOut].✨ AI |
Swap an exact amount of input tokens for output tokens along specified routes, supporting fee-on-transfer tokens.✨ AI
參數
| 名稱 | 類型 | 描述 |
|---|---|---|
| amountIn | uint256 | Exact amount of input tokens to swap.✨ AI |
| amountOutMin | uint256 | Minimum acceptable amount of output tokens to receive; reverts if less.✨ AI |
| routes | tuple[] | Array of route tuples that define each hop and pool information for the swap.✨ AI |
| to | address | Recipient address that will receive the output tokens.✨ AI |
| deadline | uint256 | Unix timestamp after which the transaction will revert.✨ AI |