CrustRouter01

Mantle

0x2c2954cf16f974033e1e2345fce1ca434dc14497

Solidity v0.8.13+commit.abaa5c0e

🤖
通过你的 AI 查询此合约
引用: 0x2c2954cf16f974033e1e2345fce1ca434dc14497
示例提示词: "Tell me the current state of mantle/0x2c2954cf16f974033e1e2345fce1ca434dc14497"
还没有接入 AI?→ mcp.smarts.md
Mantle 在 Smarts 上是仅文档链:源代码和 ABI 已索引,但当前不提供实时链上数据(状态、最新事件、管理员画像)。AI 代理仍可通过 MCP 调用 get_contract_info 和 get_contract_source。

概览

读取函数
12
写入函数
16
事件
0

读取函数

factory() view

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
getAmountOut(amountIn: uint256, tokenIn: address, tokenOut: address) view

Calculate the output token amount and indicate whether the swap will use a stable pool.✨ AI

开发者: Performs chained getAmountOut calculations on any number of pairs.

参数

名称 类型 描述
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
getAmountsOut(amountIn: uint256, routes: tuple[]) view

Calculate the expected output amounts for a multi-hop swap given an input amount and routes.✨ AI

开发者: Performs chained getAmountOut calculations on any number of pairs.

参数

名称 类型 描述
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
getExactAmountOut(amountIn: uint256, tokenIn: address, tokenOut: address, stable: bool) view

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
getReserves(tokenA: address, tokenB: address, stable: bool) view

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
isPair(pair: address) view

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
pairFor(tokenA: address, tokenB: address, stable: bool) view

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
quoteAddLiquidity(tokenA: address, tokenB: address, stable: bool, amountADesired: uint256, amountBDesired: uint256) view

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
quoteLiquidity(amountA: uint256, reserveA: uint256, reserveB: uint256) pure

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
quoteRemoveLiquidity(tokenA: address, tokenB: address, stable: bool, liquidity: uint256) view

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
sortTokens(tokenA: address, tokenB: address) pure

Return the two token addresses in ascending order to produce a canonical pair ordering.✨ AI

开发者: Reverts if tokenA == tokenB or if the computed token0 is the zero address (ensures distinct non-zero tokens).✨ 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
wmnt() view

Returns the address of the wrapped native token (WMNT) used by the router.✨ AI

返回值

名称 类型 描述
address The wrapped native token contract address (WMNT).✨ AI

写入函数

UNSAFE_swapExactTokensForTokens(amounts: uint256[], routes: tuple[], to: address, deadline: uint256) nonpayable

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
addLiquidity(tokenA: address, tokenB: address, stable: bool, amountADesired: uint256, amountBDesired: uint256, amountAMin: uint256, amountBMin: uint256, to: address, deadline: uint256) nonpayable

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
addLiquidityMNT(token: address, stable: bool, amountTokenDesired: uint256, amountTokenMin: uint256, amountMNTMin: uint256, to: address, deadline: uint256) payable

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
removeLiquidity(tokenA: address, tokenB: address, stable: bool, liquidity: uint256, amountAMin: uint256, amountBMin: uint256, to: address, deadline: uint256) nonpayable

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
removeLiquidityMNT(token: address, stable: bool, liquidity: uint256, amountTokenMin: uint256, amountMNTMin: uint256, to: address, deadline: uint256) nonpayable

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
removeLiquidityMNTSupportingFeeOnTransferTokens(token: address, stable: bool, liquidity: uint256, amountTokenMin: uint256, amountMNTMin: uint256, to: address, deadline: uint256) nonpayable

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
removeLiquidityMNTWithPermit(token: address, stable: bool, liquidity: uint256, amountTokenMin: uint256, amountMNTMin: uint256, to: address, deadline: uint256, approveMax: bool, v: uint8, r: bytes32, s: bytes32) nonpayable

Remove liquidity from a token–MNT pair using an off-chain permit signature.✨ AI

开发者: Uses an ERC-2612-style permit to approve LP token transfer; signature must be valid and deadline not passed.✨ 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
removeLiquidityMNTWithPermitSupportingFeeOnTransferTokens(token: address, stable: bool, liquidity: uint256, amountTokenMin: uint256, amountMNTMin: uint256, to: address, deadline: uint256, approveMax: bool, v: uint8, r: bytes32, s: bytes32) nonpayable

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
removeLiquidityWithPermit(tokenA: address, tokenB: address, stable: bool, liquidity: uint256, amountAMin: uint256, amountBMin: uint256, to: address, deadline: uint256, approveMax: bool, v: uint8, r: bytes32, s: bytes32) nonpayable

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
swapExactMNTForTokens(amountOutMin: uint256, routes: tuple[], to: address, deadline: uint256) payable

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
swapExactMNTForTokensSupportingFeeOnTransferTokens(amountOutMin: uint256, routes: tuple[], to: address, deadline: uint256) payable

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
swapExactTokensForMNT(amountIn: uint256, amountOutMin: uint256, routes: tuple[], to: address, deadline: uint256) nonpayable

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
swapExactTokensForMNTSupportingFeeOnTransferTokens(amountIn: uint256, amountOutMin: uint256, routes: tuple[], to: address, deadline: uint256) nonpayable

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
swapExactTokensForTokens(amountIn: uint256, amountOutMin: uint256, routes: tuple[], to: address, deadline: uint256) nonpayable

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
swapExactTokensForTokensSimple(amountIn: uint256, amountOutMin: uint256, tokenFrom: address, tokenTo: address, stable: bool, to: address, deadline: uint256) nonpayable

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
swapExactTokensForTokensSupportingFeeOnTransferTokens(amountIn: uint256, amountOutMin: uint256, routes: tuple[], to: address, deadline: uint256) nonpayable

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