Skip to main content

Yearn4626Router.sol

Git Source

Router that is meant to be used with Yearn V3 vaults and strategies for deposits, withdraws and migrations. The router was developed from the original router by FEI protocol https://github.com/fei-protocol/ERC4626 The router is designed to be used with permit and multicall for the optimal experience. NOTE: It is important to never leave tokens in the router at the end of a call, otherwise they can be swept by anyone.

State Variables

_name

bytes32 private immutable _name;

Functions

constructor

constructor(string memory _name_, IWETH9 weth) PeripheryPayments(weth);

name

function name() external view returns (string memory);

depositToVault

deposit amount to an ERC4626 vault.

throws "!minShares" Error.

function depositToVault(IYearn4626 vault, uint256 amount, address to, uint256 minSharesOut)
public
payable
override
returns (uint256);

Parameters

NameTypeDescription
vaultIYearn4626The ERC4626 vault to deposit assets to.
amountuint256The amount of assets to deposit to vault.
toaddressThe destination of ownership shares.
minSharesOutuint256The min amount of vault shares received by to.

Returns

NameTypeDescription
<none>uint256. the amount of shares received by to.

depositToVault

See depositToVault in IYearn4626Router.

Uses msg.sender as the default for to.

function depositToVault(IYearn4626 vault, uint256 amount, uint256 minSharesOut) external payable returns (uint256);

depositToVault

See depositToVault in IYearn4626Router.

Uses msg.sender as the default for to and their full balance of msg.sender as amount.

function depositToVault(IYearn4626 vault, uint256 minSharesOut) external payable returns (uint256);

depositToVault

See depositToVault in IYearn4626Router.

Uses msg.sender as the default for to, their full balance of msg.sender as amount and 1 Basis point for maxLoss. NOTE: The slippage tollerance is only useful if previewDeposit cannot be manipulated for the vault.

function depositToVault(IYearn4626 vault) external payable returns (uint256);

redeem

See redeem in IYearn4626RouterBase.

Uses msg.sender as receiver.

function redeem(IYearn4626 vault, uint256 shares, uint256 maxLoss) external payable returns (uint256);

redeem

See redeem in IYearn4626RouterBase.

Uses msg.sender as receiver and their full balance as shares.

function redeem(IYearn4626 vault, uint256 maxLoss) external payable returns (uint256);

redeem

See redeem in IYearn4626RouterBase.

Uses msg.sender as receiver, their full balance as shares and 1 Basis Point for maxLoss.

function redeem(IYearn4626 vault) external payable returns (uint256);

migrate

will redeem shares from one vault and deposit amountOut to a different ERC4626 vault.

throws "!minAmount", "!minShares" Errors.

function migrate(IYearn4626 fromVault, IYearn4626 toVault, uint256 shares, address to, uint256 minSharesOut)
public
payable
override
returns (uint256);

Parameters

NameTypeDescription
fromVaultIYearn4626The ERC4626 vault to redeem shares from.
toVaultIYearn4626The ERC4626 vault to deposit assets to.
sharesuint256The amount of shares to redeem from fromVault.
toaddressThe destination of ownership shares.
minSharesOutuint256The min amount of toVault shares received by to.

Returns

NameTypeDescription
<none>uint256. the amount of shares received by to.

migrate

See migrate in IYearn4626Router.

Uses msg.sender as to.

function migrate(IYearn4626 fromVault, IYearn4626 toVault, uint256 shares, uint256 minSharesOut)
external
payable
returns (uint256);

migrate

See migrate in IYearn4626Router.

Uses msg.sender as to and their full balance for shares.

function migrate(IYearn4626 fromVault, IYearn4626 toVault, uint256 minSharesOut) external payable returns (uint256);

migrate

See migrate in IYearn4626Router.

Uses msg.sender as to, their full balance for shares and no minamountOut. NOTE: Using this will enforce no slippage checks and should be used with care.

function migrate(IYearn4626 fromVault, IYearn4626 toVault) external payable returns (uint256);

migrateFromV2

migrate from Yearn V2 vault to a V3 vault'.

throws "!minAmount", "!minShares" Errors.

function migrateFromV2(IYearnV2 fromVault, IYearn4626 toVault, uint256 shares, address to, uint256 minSharesOut)
public
payable
override
returns (uint256);

Parameters

NameTypeDescription
fromVaultIYearnV2The Yearn V2 vault to withdraw from.
toVaultIYearn4626The Yearn V3 vault to deposit assets to.
sharesuint256The amount of V2 shares to redeem form 'fromVault'.
toaddressThe destination of ownership shares
minSharesOutuint256The min amount of 'toVault' shares to be received by 'to'.

Returns

NameTypeDescription
<none>uint256. The actual amount of 'toVault' shares received by 'to'.

migrateFromV2

See migrateFromV2 in IYearn4626Router.

Uses msg.sender as to.

function migrateFromV2(IYearnV2 fromVault, IYearn4626 toVault, uint256 shares, uint256 minSharesOut)
external
payable
returns (uint256);

migrateFromV2

See migrateFromV2 in IYearn4626Router.

Uses msg.sender as to and their full balance as shares.

function migrateFromV2(IYearnV2 fromVault, IYearn4626 toVault, uint256 minSharesOut)
external
payable
returns (uint256);

migrateFromV2

See migrate in IYearn4626Router.

Uses msg.sender as to, their full balance for shares and no minamountOut. NOTE: Using this will enforce no slippage checks and should be used with care.

function migrateFromV2(IYearnV2 fromVault, IYearn4626 toVault) external payable returns (uint256 sharesOut);