CurveRouterSwapper

Git Source

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

NameTypeDescription
curveRouter_addressThe address of the Curve Router.

_approveTokenForSwap

Approves the Curve Router to spend the specified token.

function _approveTokenForSwap(address token) internal;

Parameters

NameTypeDescription
tokenaddressThe 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

NameTypeDescription
curveSwapParamsCurveSwapParamsThe parameters for the swap.
amountuint256The amount of the input token to swap.
expecteduint256The minimum amount of the output token expected to receive.
receiveraddressThe address that will receive the output tokens.

Returns

NameTypeDescription
<none>uint256The 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

NameTypeDescription
curveSwapParamsCurveSwapParamsThe parameters for the swap.
fromTokenaddressThe address of the input token.
toTokenaddressThe 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;
}