FraxswapRouter
Fraxtal0x7ae2a0f3d9ef911a0a3f726fa9fbfca25dc18f7a
Solidity v0.8.30+commit.73712a01
概览
读取函数
Returns the init code hash used to compute deterministic pair contract addresses.✨ AI
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
| hash | bytes | hash: bytes - keccak256 hash of the pair contract init code used for CREATE2 address derivation.✨ AI |
Returns the address of the Wrapped Ether (WETH) token used by the router.✨ AI
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
| — | address | The address of the WETH token contract used for wrapped ETH operations.✨ AI |
Returns the address of the Fraxswap factory contract.✨ AI
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
| — | address | The factory contract address used by this router.✨ AI |
Calculate the minimum input token amount required to obtain a specified output from a liquidity pair.✨ AI
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| amountOut | uint256 | Desired amount of output token to receive.✨ AI |
| reserveIn | uint256 | Reserve amount of the input token in the pair.✨ AI |
| reserveOut | uint256 | Reserve amount of the output token in the pair.✨ AI |
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
| amountIn | uint256 | amountIn: Minimum input token amount to supply to receive amountOut, derived from the pair reserves and fee.✨ AI |
Return the amount of output tokens for a given input amount and pool reserves.✨ AI
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| amountIn | uint256 | Amount of input tokens provided for the swap.✨ AI |
| reserveIn | uint256 | Current reserve amount of the input token in the pool.✨ AI |
| reserveOut | uint256 | Current reserve amount of the output token in the pool.✨ AI |
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
| amountOut | uint256 | amountOut: Calculated output token amount obtainable from the swap using the pool's constant-product formula.✨ AI |
Compute the input token amounts required for each hop to receive a specified output amount.✨ AI
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| amountOut | uint256 | Desired final token amount to receive.✨ AI |
| path | address[] | Ordered list of token addresses representing the swap route.✨ AI |
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
| amounts | uint256[] | Array of token amounts required at each step of path; last equals amountOut and first is the required input amount.✨ AI |
Compute the output amounts for each hop in a multi-hop swap given an input amount and path.✨ AI
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| amountIn | uint256 | Amount of the input token to start the swap (in token smallest units).✨ AI |
| path | address[] | Ordered list of token addresses defining the swap sequence from input to output.✨ AI |
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
| amounts | uint256[] | Array of token amounts corresponding to each token in path; amounts[0] == amountIn and last is the final output amount.✨ AI |
Return the equivalent amountB for a given amountA using the reserves' ratio.✨ AI
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| amountA | uint256 | Input token A amount.✨ AI |
| reserveA | uint256 | Reserve of token A in the pair.✨ AI |
| reserveB | uint256 | Reserve of token B in the pair.✨ AI |
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
| amountB | uint256 | amountB: Equivalent output amount of token B computed as amountA * reserveB / reserveA.✨ AI |
Get the router contract version string.✨ AI
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
| — | string | Router version string identifying the deployed implementation.✨ AI |
写入函数
Add liquidity to a token pair and mint LP 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 |
| amountADesired | uint256 | Desired amount of tokenA to add.✨ AI |
| amountBDesired | uint256 | Desired amount of tokenB to add.✨ AI |
| amountAMin | uint256 | Minimum amount of tokenA to accept (revert otherwise).✨ AI |
| amountBMin | uint256 | Minimum amount of tokenB to accept (revert otherwise).✨ AI |
| to | address | Recipient address that receives the minted liquidity tokens.✨ AI |
| deadline | uint256 | Unix timestamp after which the transaction will revert if not processed.✨ AI |
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
| amountA | uint256 | amountA: Actual amount of tokenA that was added to the pool.✨ AI |
| amountB | uint256 | amountB: Actual amount of tokenB that was added to the pool.✨ AI |
| liquidity | uint256 | liquidity: Amount of liquidity (LP) tokens minted to the recipient.✨ AI |
Adds liquidity to a token–ETH pair by depositing the specified token and ETH, and returns the amounts used and liquidity tokens minted.✨ AI
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| token | address | Address of the ERC20 token to pair with ETH.✨ AI |
| amountTokenDesired | uint256 | Desired amount of token to add to the pair.✨ AI |
| amountTokenMin | uint256 | Minimum acceptable amount of token to add (slippage protection).✨ AI |
| amountETHMin | uint256 | Minimum acceptable amount of ETH to add (slippage protection).✨ AI |
| to | address | Address that will receive the minted liquidity tokens.✨ AI |
| deadline | uint256 | Timestamp after which the transaction will revert if not executed.✨ AI |
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
| amountToken | uint256 | amountToken: Actual amount of token deposited into the pair.✨ AI |
| amountETH | uint256 | amountETH: Actual amount of ETH deposited into the pair.✨ AI |
| liquidity | uint256 | liquidity: Amount of liquidity tokens minted and sent to `to`.✨ AI |
Compute the input token amounts required to receive a specified output along a swap path using TWAMM.✨ AI
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| amountOut | uint256 | Desired output token amount for the final token in the path.✨ AI |
| path | address[] | Array of token addresses defining the swap route from the input to the output token.✨ AI |
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
| amounts | uint256[] | amounts: uint256[] of required input amounts for each token in the path; amounts[0] is the initial input required.✨ AI |
Compute token output amounts for a given swap path using TWAMM logic.✨ AI
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| amountIn | uint256 | Input token amount for the first token in path.✨ AI |
| path | address[] | Sequence of token addresses representing the swap route (length must be >= 2).✨ AI |
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
| amounts | uint256[] | Array of amounts for each token in the path; amounts[0] equals amountIn and last element is the final output amount.✨ AI |
Removes liquidity for the token pair and transfers the underlying 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 |
| liquidity | uint256 | Amount of liquidity tokens to burn from the pair.✨ AI |
| amountAMin | uint256 | Minimum acceptable amount of tokenA to receive, or the call reverts.✨ AI |
| amountBMin | uint256 | Minimum acceptable amount of tokenB to receive, or the call reverts.✨ AI |
| to | address | Recipient address that will receive the withdrawn tokens.✨ AI |
| deadline | uint256 | Timestamp after which the transaction will revert if not processed.✨ AI |
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
| amountA | uint256 | Amount of tokenA returned to the recipient.✨ AI |
| amountB | uint256 | Amount of tokenB returned to the recipient.✨ AI |
Remove liquidity from the token–ETH pair, burn LP tokens, and return the underlying token and ETH to the recipient.✨ AI
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| token | address | Address of the ERC20 token in the pair.✨ AI |
| liquidity | uint256 | Amount of LP tokens to burn and remove from the pool.✨ AI |
| amountTokenMin | uint256 | Minimum amount of token expected to receive (revert if less).✨ AI |
| amountETHMin | uint256 | Minimum amount of ETH expected to receive (revert if less).✨ AI |
| to | address | Recipient address that will receive the token and ETH.✨ AI |
| deadline | uint256 | Unix timestamp after which the transaction will revert.✨ AI |
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
| amountToken | uint256 | Actual amount of token transferred to the recipient.✨ AI |
| amountETH | uint256 | Actual amount of ETH transferred to the recipient.✨ AI |
Remove liquidity from a token-ETH pair and send ETH while supporting fee-on-transfer tokens.✨ AI
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| token | address | Address of the ERC-20 token in the token-ETH pair.✨ AI |
| liquidity | uint256 | Amount of liquidity tokens to remove.✨ AI |
| amountTokenMin | uint256 | Minimum amount of tokens to accept; revert if received less.✨ AI |
| amountETHMin | uint256 | Minimum amount of ETH to accept; revert if received less.✨ AI |
| to | address | Recipient address that will receive the ETH.✨ AI |
| deadline | uint256 | Unix timestamp after which the transaction will revert if not processed.✨ AI |
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
| amountETH | uint256 | amountETH: Amount of ETH (in wei) returned to the recipient.✨ AI |
Remove liquidity from a token-ETH pair, burn LP tokens, and send token and ETH to the recipient using an EIP-2612 permit.✨ AI
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| token | address | Address of the ERC20 token paired with ETH.✨ AI |
| liquidity | uint256 | Amount of LP tokens to remove (in LP token units).✨ AI |
| amountTokenMin | uint256 | Minimum accepted amount of token to receive, else revert.✨ AI |
| amountETHMin | uint256 | Minimum accepted amount of ETH to receive, else revert.✨ AI |
| to | address | Recipient address that will receive the token and ETH.✨ AI |
| deadline | uint256 | Unix timestamp after which the permit and transaction are invalid.✨ AI |
| approveMax | bool | If true, permit approves max uint256 allowance; otherwise approves 'liquidity'.✨ AI |
| v | uint8 | Signature 'v' value for the permit (EIP-2612).✨ AI |
| r | bytes32 | Signature 'r' value for the permit (EIP-2612).✨ AI |
| s | bytes32 | Signature 's' value for the permit (EIP-2612).✨ AI |
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
| amountToken | uint256 | amountToken: Actual amount of ERC20 token transferred to the recipient.✨ AI |
| amountETH | uint256 | amountETH: Actual amount of ETH transferred to the recipient.✨ AI |
Remove liquidity from a token–ETH pair using an off-chain permit, supporting fee-on-transfer tokens and send assets to a recipient.✨ AI
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| token | address | Address of the ERC20 token in the token–ETH pair.✨ AI |
| liquidity | uint256 | Amount of LP tokens to remove.✨ AI |
| amountTokenMin | uint256 | Minimum amount of token to accept (slippage protection).✨ AI |
| amountETHMin | uint256 | Minimum amount of ETH to accept (slippage protection).✨ AI |
| to | address | Recipient address for returned tokens and ETH.✨ AI |
| deadline | uint256 | Unix timestamp after which the transaction will revert.✨ AI |
| approveMax | bool | If true, set permit allowance to uint256.max; otherwise use liquidity.✨ AI |
| v | uint8 | Signature parameter v for the permit.✨ AI |
| r | bytes32 | Signature parameter r for the permit.✨ AI |
| s | bytes32 | Signature parameter s for the permit.✨ AI |
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
| amountETH | uint256 | amountETH: Amount of ETH (in wei) returned to the recipient.✨ AI |
Remove liquidity from a token pair using an EIP-2612 permit and transfer the underlying 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 |
| liquidity | uint256 | Amount of LP 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 | Recipient address for the withdrawn tokens.✨ AI |
| deadline | uint256 | Unix timestamp after which the transaction will revert.✨ AI |
| approveMax | bool | If true, use max uint256 allowance in the permit; otherwise use 'liquidity'.✨ AI |
| v | uint8 | Recovery byte of the permit signature.✨ AI |
| r | bytes32 | First 32 bytes of the permit signature.✨ AI |
| s | bytes32 | Second 32 bytes of the permit signature.✨ AI |
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
| amountA | uint256 | amountA: Actual amount of tokenA sent to the recipient.✨ AI |
| amountB | uint256 | amountB: Actual amount of tokenB sent to the recipient.✨ AI |
Swap ETH for an exact amount of tokens and send those tokens to the recipient.✨ AI
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| amountOut | uint256 | Exact amount of output tokens the caller wants to receive.✨ AI |
| path | address[] | Array of token addresses to trade through; first element must be WETH and last the output token.✨ AI |
| to | address | Address that will receive the output tokens.✨ AI |
| deadline | uint256 | Unix timestamp after which the transaction will revert if not executed.✨ AI |
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
| amounts | uint256[] | Array of token amounts for each address in path; first is the wrapped ETH input amount and last equals amountOut.✨ AI |
Swap an exact amount of ETH for tokens along the given path and send the output tokens to the recipient.✨ AI
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| amountOutMin | uint256 | Minimum acceptable amount of output tokens; revert if received amount is lower.✨ AI |
| path | address[] | Array of token addresses representing the swap route; first should be WETH, last is desired output token.✨ AI |
| to | address | Recipient address that will receive the output tokens.✨ AI |
| deadline | uint256 | Unix timestamp after which the transaction is invalid and will revert.✨ AI |
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
| amounts | uint256[] | Amounts for each token in the path: amounts[0] is input ETH (as WETH) and amounts[last] is the output token amount sent to 'to'.✨ AI |
Swap exact ETH for tokens and send the tokens to the recipient while supporting fee-on-transfer tokens.✨ AI
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| amountOutMin | uint256 | Minimum amount of output tokens that must be received for the transaction not to revert.✨ AI |
| path | address[] | Array of token addresses defining the swap route; first address is WETH wrapper, last is desired token.✨ 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 |
Swap an exact amount of input tokens for ETH, require at least amountOutMin, and send ETH to the recipient before deadline.✨ AI
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| amountIn | uint256 | Exact amount of input tokens to swap.✨ AI |
| amountOutMin | uint256 | Minimum amount of ETH to accept; revert if the output is below this.✨ AI |
| path | address[] | Array of token addresses representing the swap route; last address should be WETH.✨ AI |
| to | address | Recipient address that will receive the output ETH.✨ AI |
| deadline | uint256 | Unix timestamp after which the transaction will revert if not executed.✨ AI |
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
| amounts | uint256[] | Array of token amounts for each hop (uint256[]), starting with amountIn and ending with ETH amount received.✨ AI |
Swap an exact amount of input tokens for ETH while supporting tokens that charge transfer fees.✨ AI
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| amountIn | uint256 | Exact amount of input tokens to send.✨ AI |
| amountOutMin | uint256 | Minimum acceptable amount of ETH to receive, or revert.✨ AI |
| path | address[] | Array of token addresses to route the swap; last address is WETH.✨ AI |
| to | address | Recipient address that will receive the output ETH.✨ AI |
| deadline | uint256 | Unix timestamp after which the transaction will revert.✨ AI |
Swap an exact amount of input tokens for output tokens along a path, sending the results to the recipient.✨ AI
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| amountIn | uint256 | Amount of input tokens to swap.✨ AI |
| amountOutMin | uint256 | Minimum acceptable amount of output tokens; transaction reverts if output is lower.✨ AI |
| path | address[] | Array of token addresses defining the swap route; path[0] is input token, last is output token.✨ 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[] | Array of token amounts for each hop in the path; amounts[0] == amountIn and the last element is the output received.✨ AI |
Swap an exact amount of input tokens for output tokens along a path while supporting fee-on-transfer tokens.✨ AI
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| amountIn | uint256 | Exact amount of input tokens to send.✨ AI |
| amountOutMin | uint256 | Minimum amount of output tokens required for the caller to accept the swap.✨ AI |
| path | address[] | Array of token addresses representing the swap route (input to output).✨ AI |
| to | address | Recipient address that will receive the output tokens.✨ AI |
| deadline | uint256 | Unix timestamp after which the transaction will revert if not yet executed.✨ AI |
Swap input tokens to receive an exact amount of ETH, spending no more than amountInMax.✨ AI
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| amountOut | uint256 | Exact amount of ETH to receive (in wei).✨ AI |
| amountInMax | uint256 | Maximum amount of input tokens to spend (in token smallest units).✨ AI |
| path | address[] | Array of token addresses for the swap; path[0] is input token, last must be WETH.✨ AI |
| to | address | Recipient address that will receive the resulting ETH.✨ 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; amounts[0] is input used and last equals amountOut (ETH).✨ AI |
Swaps the minimum required input tokens to obtain an exact amount of output tokens.✨ AI
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| amountOut | uint256 | Exact amount of output tokens desired.✨ AI |
| amountInMax | uint256 | Maximum amount of input tokens willing to spend.✨ AI |
| path | address[] | Array of token addresses representing the swap route (input to output).✨ AI |
| to | address | Recipient address that receives 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; amounts[0] is actual input spent and the last equals the requested amountOut.✨ AI |