CurveRouterSwapper
Contains helper methods for interacting with Curve Router.
*Curve router is deployed on these networks at 0xF0d4c12A5768D806021F80a262B4d39d26C58b8D
- Ethereum
- Optimism
- Gnosis
- Polygon
- Fantom
- Kava
- Arbitrum
- Avalanche
- Base at 0xd6681e74eEA20d196c15038C580f721EF2aB6320 https://github.com/curvefi/curve-router-ng/tree/master*
State Variables
_CURVE_ROUTER
The address of the Curve Router contract
address private immutable _CURVE_ROUTER;
Functions
constructor
Sets the Curve Router address on contract deployment.
constructor(address curveRouter_) payable;
Parameters
Name | Type | Description |
---|---|---|
curveRouter_ | address | The address of the Curve Router. |
_approveTokenForSwap
Approves the Curve Router to spend the specified token.
function _approveTokenForSwap(address token) internal;
Parameters
Name | Type | Description |
---|---|---|
token | address | The ERC20 token address to approve. |
_swap
Executes a token swap via the Curve Router.
function _swap(
CurveSwapParams memory curveSwapParams,
uint256 amount,
uint256 expected,
address receiver
)
internal
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
curveSwapParams | CurveSwapParams | The parameters for the swap. |
amount | uint256 | The amount of the input token to swap. |
expected | uint256 | The minimum amount of the output token expected to receive. |
receiver | address | The address that will receive the output tokens. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The amount of the output token received from the swap. |
_validateSwapParams
Validates the swap parameters against the provided route and tokens.
function _validateSwapParams(
CurveSwapParams memory curveSwapParams,
address fromToken,
address toToken
)
internal
view;
Parameters
Name | Type | Description |
---|---|---|
curveSwapParams | CurveSwapParams | The parameters for the swap. |
fromToken | address | The address of the input token. |
toToken | address | The address of the output token. |
Structs
CurveSwapParams
Struct to store parameters for a Curve swap
struct CurveSwapParams {
address[11] route;
uint256[5][5] swapParams;
address[5] pools;
}