cove-contracts-boosties

cove

codecov CI Discord X (formerly Twitter) Follow

This repository contains the core smart contracts for the Cove Protocol. It includes Boosties (a liquid locker and staking platform for Yearn), a governance token, and auxiliary contracts.

The testing suite includes unit, integration, fork, and invariant tests.

For more detailed information, visit the documentation.

[!IMPORTANT] You acknowledge that there are potential uses of the [Licensed Work] that could be deemed illegal or noncompliant under U.S. law. You agree that you will not use the [Licensed Work] for any activities that are or may reasonably be expected to be deemed illegal or noncompliant under U.S. law. You also agree that you, and not [Storm Labs], are responsible for any illegal or noncompliant uses of the [Licensed Work] that you facilitate, enable, engage in, support, promote, or are otherwise involved with.

Prerequisites

Ensure you have the following installed:

Installation

Install rust using rustup:

rustup update

Setup pyenv and install the python dependencies:

pyenv install 3.9.17
pyenv virtualenv 3.9.17 cove-contracts-boosties
pyenv local cove-contracts-boosties
pip install -r requirements.txt

Install the forge libraries as submodules:

forge install

Install node and build dependencies:

pnpm install

Usage

Build forge-deploy if not already built:

pnpm forge-deploy:build

Build the contracts:

pnpm build

Run the tests:

pnpm test

Run invariant tests (echidna)

Install echidna and run the test for each Echidna test contract:

Echidna may fail if the contracts are not built cleanly. If you encounter issues, try running pnpm clean && pnpm build before running the tests.

pnpm invariant-test ERC20RewardsGauge_EchidnaTest

Run slither static analysis

Install slither and run the tool:

pnpm slither

To run the upgradeability checks with slither-check-upgradeability:

pnpm slither-upgradeability

Run semgrep static analysis

Install semgrep and run the tool:

pnpm semgrep

Deploying contracts to a live network

DEPLOYER_ADDRESS in the .env file will be used as sender for the script. Ensure this is defined before deploying.

Local mainnet fork

Fork mainnet on the local network using anvil with the provided script:

pnpm fork:mainnet

Keep this terminal session going to keep the fork network alive.

Then in another terminal session, deploy the contracts to the local network:

pnpm deploy:local
  • Deployments will be in deployments/<chainId>-fork.
  • Make sure to not commit broadcast/.
  • If trying to deploy new contract either use the default deployer functions or generate them with$./forge-deploy gen-deployer.

Mainnet

First ensure the .env file is set up with the correct addresses for the mainnet deployment.

Add the deployer account to the cast wallet management:

cast wallet import deployer --interactive

This will prompt you to enter the private key and the password for the deployer account. Then deploy the contracts to the mainnet:

pnpm deploy:prod
  • Deployments will be in deployments/<chainId>.
  • Ensure DEPLOYER_ADDRESS is set to the same public address as the deployer wallet account.

Once the script finishes running, commit the new deployments to the repository.

Contract Architecture

Boosties

boosties

Audits

Smart contract audits of the Cove Protocol are available here.

Contents

Contents

IGasliteDrop

Git Source

Functions

airdropERC20

function airdropERC20(
    address _token,
    address[] calldata _addresses,
    uint256[] calldata _amounts,
    uint256 _totalAmount
)
    external
    payable;

Contents

Contents

Contents

SelfPermit

Git Source

Inherits: ISelfPermit

Functionality to call permit on any EIP-2612-compliant token for use in the route

These functions are expected to be embedded in multicalls to allow EOAs to approve a contract and call a function that requires an approval in a single transaction.

Functions

selfPermit

Permits this contract to spend a given token from msg.sender

The owner is always msg.sender and the spender is always address(this).

function selfPermit(
    address token,
    uint256 value,
    uint256 deadline,
    uint8 v,
    bytes32 r,
    bytes32 s
)
    public
    payable
    override;

Parameters

NameTypeDescription
tokenaddressThe address of the token spent
valueuint256The amount that can be spent of token
deadlineuint256A timestamp, the current blocktime must be less than or equal to this timestamp
vuint8Must produce valid secp256k1 signature from the holder along with r and s
rbytes32Must produce valid secp256k1 signature from the holder along with v and s
sbytes32Must produce valid secp256k1 signature from the holder along with r and v

selfPermitIfNecessary

Permits this contract to spend a given token from msg.sender

The owner is always msg.sender and the spender is always address(this). Can be used instead of #selfPermit to prevent calls from failing due to a frontrun of a call to #selfPermit

function selfPermitIfNecessary(
    address token,
    uint256 value,
    uint256 deadline,
    uint8 v,
    bytes32 r,
    bytes32 s
)
    external
    payable
    override;

Parameters

NameTypeDescription
tokenaddressThe address of the token spent
valueuint256The amount that can be spent of token
deadlineuint256A timestamp, the current blocktime must be less than or equal to this timestamp
vuint8Must produce valid secp256k1 signature from the holder along with r and s
rbytes32Must produce valid secp256k1 signature from the holder along with v and s
sbytes32Must produce valid secp256k1 signature from the holder along with r and v

selfPermitAllowed

Permits this contract to spend the sender's tokens for permit signatures that have the allowed parameter

The owner is always msg.sender and the spender is always address(this)

function selfPermitAllowed(
    address token,
    uint256 nonce,
    uint256 expiry,
    uint8 v,
    bytes32 r,
    bytes32 s
)
    public
    payable
    override;

Parameters

NameTypeDescription
tokenaddressThe address of the token spent
nonceuint256The current nonce of the owner
expiryuint256The timestamp at which the permit is no longer valid
vuint8Must produce valid secp256k1 signature from the holder along with r and s
rbytes32Must produce valid secp256k1 signature from the holder along with v and s
sbytes32Must produce valid secp256k1 signature from the holder along with r and v

selfPermitAllowedIfNecessary

Permits this contract to spend the sender's tokens for permit signatures that have the allowed parameter

The owner is always msg.sender and the spender is always address(this) Can be used instead of #selfPermitAllowed to prevent calls from failing due to a frontrun of a call to #selfPermitAllowed.

function selfPermitAllowedIfNecessary(
    address token,
    uint256 nonce,
    uint256 expiry,
    uint8 v,
    bytes32 r,
    bytes32 s
)
    external
    payable
    override;

Parameters

NameTypeDescription
tokenaddressThe address of the token spent
nonceuint256The current nonce of the owner
expiryuint256The timestamp at which the permit is no longer valid
vuint8Must produce valid secp256k1 signature from the holder along with r and s
rbytes32Must produce valid secp256k1 signature from the holder along with v and s
sbytes32Must produce valid secp256k1 signature from the holder along with r and v

Contents

Contents

GaugeFactory

Git Source

Inherits: IGaugeFactory

Creates Gauge and ExtraReward

Uses clone to create new contracts

State Variables

deployedGauge

address public immutable deployedGauge;

Functions

constructor

constructor(address _deployedGauge);

createGauge

Create a new reward Gauge clone

function createGauge(address _vault, address _owner) external override returns (address);

Parameters

NameTypeDescription
_vaultaddressthe vault address.
_owneraddressowner

Returns

NameTypeDescription
<none>addressgauge address

_clone

function _clone(address _source) internal returns (address result);

Events

GaugeCreated

event GaugeCreated(address indexed gauge);

ExtraRewardCreated

event ExtraRewardCreated(address indexed extraReward);

VeRegistry

Git Source

Inherits: Ownable

veYFI holders will vote for gauge allocation to vault tokens.

State Variables

veToken

address public veToken;

yfi

address public immutable yfi;

veYfiRewardPool

address public immutable veYfiRewardPool;

gaugefactory

address public immutable gaugefactory;

_vaults

EnumerableSet.AddressSet private _vaults;

gauges

mapping(address => address) public gauges;

vaultForGauge

mapping(address => address) public vaultForGauge;

isGauge

mapping(address => bool) public isGauge;

Functions

constructor

constructor(address _ve, address _yfi, address _gaugefactory, address _veYfiRewardPool) Ownable();

setVe

Set the veYFI token address.

function setVe(address _veToken) external onlyOwner;

Parameters

NameTypeDescription
_veTokenaddressthe new address of the veYFI token

getVaults

function getVaults() external view returns (address[] memory);

Returns

NameTypeDescription
<none>address[]address[] list of vaults with gauge that are possible to vote for.

addVaultToRewards

Add a vault to the list of vaults that receives rewards.

function addVaultToRewards(address _vault, address _owner) external onlyOwner returns (address);

Parameters

NameTypeDescription
_vaultaddressvault address
_owneraddressowner.

removeVaultFromRewards

Remove a vault from the list of vaults receiving rewards.

function removeVaultFromRewards(address _vault) external onlyOwner;

Parameters

NameTypeDescription
_vaultaddressvault address

Events

VaultAdded

event VaultAdded(address indexed vault);

VaultRemoved

event VaultRemoved(address indexed vault);

UpdatedVeToken

event UpdatedVeToken(address indexed ve);

WETH

Git Source

State Variables

name

string public name = "Wrapped Ether";

symbol

string public symbol = "WETH";

decimals

uint8 public decimals = 18;

balanceOf

mapping(address => uint256) public balanceOf;

allowance

mapping(address => mapping(address => uint256)) public allowance;

Functions

constructor

constructor() payable;

deposit

function deposit() public payable;

withdraw

function withdraw(uint256 wad) public;

totalSupply

function totalSupply() public view returns (uint256);

approve

function approve(address guy, uint256 wad) public returns (bool);

transfer

function transfer(address dst, uint256 wad) public returns (bool);

transferFrom

function transferFrom(address src, address dst, uint256 wad) public returns (bool);

Events

Approval

event Approval(address indexed src, address indexed guy, uint256 wad);

Transfer

event Transfer(address indexed src, address indexed dst, uint256 wad);

Deposit

event Deposit(address indexed dst, uint256 wad);

Withdrawal

event Withdrawal(address indexed src, uint256 wad);

Contents

CoveToken

Git Source

Inherits: IERC6372, ERC20Votes, AccessControlEnumerable, Pausable, Multicall

ERC20 token with governance features including roles, pausability, and permit functionality.

*This token includes roles for minting and pausing, as well as the ability to set transfer allowances via signatures. It also includes an allowlisting mechanism for:

  • Senders: Vesting contracts, treasury multisig, or rewards contracts so CoveToken can be claimed.
  • Receivers: For non-tokenized staking contracts like MiniChefV3 to enable staking while it is non-transferrable. It inherits from OpenZeppelin's IERC6372, ERC20Votes, AccessControlEnumerable, Pausable, and Multicall contracts.*

State Variables

_INITIAL_INFLATION_DELAY

Initial delay before inflation starts.

uint256 private constant _INITIAL_INFLATION_DELAY = 3 * 52 weeks;

_INITIAL_SUPPLY

Initial supply of tokens.

uint256 private constant _INITIAL_SUPPLY = 1_000_000_000 ether;

_MIN_MINT_INTERVAL

Minimum time interval between mints.

uint256 private constant _MIN_MINT_INTERVAL = 52 weeks;

_MINT_CAP_NUMERATOR

Numerator for calculating mint cap.

uint256 private constant _MINT_CAP_NUMERATOR = 600;

_MINT_CAP_DENOMINATOR

Denominator for calculating mint cap.

uint256 private constant _MINT_CAP_DENOMINATOR = 10_000;

_MAX_PAUSE_PERIOD

Maximum period the contract can be paused.

uint256 private constant _MAX_PAUSE_PERIOD = 18 * 4 weeks;

_OWNER_PAUSE_PERIOD

Period after which the owner can unpause the contract.

uint256 private constant _OWNER_PAUSE_PERIOD = 6 * 4 weeks;

MINTER_ROLE

Role identifier for minters.

bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");

TIMELOCK_ROLE

Role identifier for the timelock.

bytes32 public constant TIMELOCK_ROLE = keccak256("TIMELOCK_ROLE");

mintingAllowedAfter

Timestamp after which minting is allowed.

uint256 public mintingAllowedAfter;

OWNER_CAN_UNPAUSE_AFTER

Timestamp after which the owner can unpause the contract.

uint256 public immutable OWNER_CAN_UNPAUSE_AFTER;

ANYONE_CAN_UNPAUSE_AFTER

Timestamp after which anyone can unpause the contract.

uint256 public immutable ANYONE_CAN_UNPAUSE_AFTER;

allowedReceiver

Mapping to track addresses allowed to receive transfers.

mapping(address => bool) public allowedReceiver;

allowedSender

Mapping to track addresses allowed to initiate transfers.

mapping(address => bool) public allowedSender;

_eventId

State variable to make the events orderable for external observers if they are called in the same block.

uint256 private _eventId;

Functions

constructor

Deploys this contract with the initial owner and minting allowed after a specified time.

The contract is paused upon deployment and the initial supply is minted to the owner.

constructor(address owner_) payable ERC20Permit("Cove DAO") ERC20("Cove DAO", "COVE");

Parameters

NameTypeDescription
owner_addressThe address of the initial owner.

mint

Mints tokens to a specified address.

function mint(address to, uint256 amount) external onlyRole(MINTER_ROLE);

Parameters

NameTypeDescription
toaddressThe address to mint tokens to.
amountuint256The amount of tokens to mint.

unpause

Unpauses the contract.

function unpause() external whenPaused;

addAllowedReceiver

Adds an address to the list of allowed transferees.

function addAllowedReceiver(address target) external onlyRole(TIMELOCK_ROLE);

Parameters

NameTypeDescription
targetaddressThe address to allow.

removeAllowedReceiver

Removes an address from the list of allowed transferees.

function removeAllowedReceiver(address target) external onlyRole(TIMELOCK_ROLE);

Parameters

NameTypeDescription
targetaddressThe address to disallow.

addAllowedSender

Adds an address to the list of allowed transferrers.

function addAllowedSender(address target) external onlyRole(TIMELOCK_ROLE);

Parameters

NameTypeDescription
targetaddressThe address to allow.

removeAllowedSender

Removes an address from the list of allowed transferrers.

function removeAllowedSender(address target) external onlyRole(TIMELOCK_ROLE);

Parameters

NameTypeDescription
targetaddressThe address to disallow.

availableSupplyToMint

Calculates the available supply that can be minted.

function availableSupplyToMint() public view returns (uint256);

Returns

NameTypeDescription
<none>uint256uint256 The amount of supply available for minting.

_addToAllowedReceiver

function _addToAllowedReceiver(address target) internal;

_removeFromAllowedReceiver

function _removeFromAllowedReceiver(address target) internal;

_addToAllowedSender

function _addToAllowedSender(address target) internal;

_removeFromAllowedSender

function _removeFromAllowedSender(address target) internal;

_beforeTokenTransfer

*Hook that is called before any transfer of tokens. This includes minting and burning. It checks if the contract is paused and if so, only allows transfers from allowed transferrers or to allowed transferees (only one inclusion is required). This is meant to support:

  • Allowed senders: Vesting, treasury multisig, and rewards contracts so CoveToken can be distributed.
  • Allowed receivers: For non-tokenized staking contracts like MiniChefV3 so any address can stake CoveToken while it's non-transferrable.*
function _beforeTokenTransfer(address from, address to, uint256 amount) internal override;

Parameters

NameTypeDescription
fromaddressThe address which is transferring tokens.
toaddressThe address which is receiving tokens.
amountuint256The amount of tokens being transferred.

clock

Overrides IERC6372 functions to make the token & governor timestamp-based

function clock() public view override(IERC6372, ERC20Votes) returns (uint48);

CLOCK_MODE

function CLOCK_MODE() public pure override(IERC6372, ERC20Votes) returns (string memory);

Events

SenderAllowed

Emitted when an address is granted permission to initiate transfers.

event SenderAllowed(address indexed target, uint256 eventId);

Parameters

NameTypeDescription
targetaddressThe address that is being allowed to send tokens.
eventIduint256An identifier for the event to order events within the same block.

SenderDisallowed

Emitted when an address has its permission to initiate transfers revoked.

event SenderDisallowed(address indexed target, uint256 eventId);

Parameters

NameTypeDescription
targetaddressThe address that is being disallowed from sending tokens.
eventIduint256An identifier for the event to order events within the same block.

ReceiverAllowed

Emitted when an address is granted permission to receive transfers.

event ReceiverAllowed(address indexed target, uint256 eventId);

Parameters

NameTypeDescription
targetaddressThe address that is being allowed to receive tokens.
eventIduint256An identifier for the event to order events within the same block.

ReceiverDisallowed

Emitted when an address has its permission to receive transfers revoked.

event ReceiverDisallowed(address indexed target, uint256 eventId);

Parameters

NameTypeDescription
targetaddressThe address that is being disallowed from receiving tokens.
eventIduint256An identifier for the event to order events within the same block.

Contents

Contents

Contents

IFlashLoanProvider

Git Source

Functions

flashLoan

Performs a 'flash loan', sending tokens to recipient, executing the receiveFlashLoan hook on it, and then reverting unless the tokens plus a proportional protocol fee have been returned. The tokens and amounts arrays must have the same length, and each entry in these indicates the loan amount for each token contract. tokens must be sorted in ascending order. The 'userData' field is ignored by the Vault, and forwarded as-is to recipient as part of the receiveFlashLoan call. Emits FlashLoan events.

function flashLoan(
    IFlashLoanRecipient recipient,
    IERC20[] memory tokens,
    uint256[] memory amounts,
    bytes memory userData
)
    external;

IFlashLoanRecipient

Git Source

Functions

receiveFlashLoan

When flashLoan is called on the Vault, it invokes the receiveFlashLoan hook on the recipient. At the time of the call, the Vault will have transferred amounts for tokens to the recipient. Before this call returns, the recipient must have transferred amounts plus feeAmounts for each token back to the Vault, or else the entire flash loan will revert. userData is the same value passed in the IVault.flashLoan call.

function receiveFlashLoan(
    IERC20[] memory tokens,
    uint256[] memory amounts,
    uint256[] memory feeAmounts,
    bytes memory userData
)
    external;

Contents

AggregatorV3Interface

Git Source

Functions

latestRoundData

function latestRoundData()
    external
    view
    returns (uint80 roundID, int256 price, uint256 startedAt, uint256 timeStamp, uint80 answeredInRound);

decimals

function decimals() external view returns (uint256);

Contents

ICurveBasePool

Git Source

Functions

get_dy

function get_dy(int128 i, int128 j, uint256 dx) external view returns (uint256 dy);

exchange

function exchange(int128 i, int128 j, uint256 dx, uint256 min_dy) external;

coins

function coins(uint256 arg0) external view returns (address);

ICurveFactory

Git Source

Functions

deploy_pool

function deploy_pool(
    string calldata name,
    string calldata symbol,
    address[2] calldata coins,
    uint256 a,
    uint256 gamma,
    uint256 midFee,
    uint256 outFee,
    uint256 allowedExtraProfit,
    uint256 feeGamma,
    uint256 adjustmentStep,
    uint256 adminFee,
    uint256 maHalfTime,
    uint256 initialPrice
)
    external
    returns (address);

ICurveRouter

Git Source

Functions

exchange

Performs an exchange operation.

route and swapParams should be determined off chain.

function exchange(
    address[11] calldata route,
    uint256[5][5] calldata swapParams,
    uint256 amount,
    uint256 expected
)
    external
    payable
    returns (uint256);

Parameters

NameTypeDescription
routeaddress[11]An array of [initial token, pool or zap, token, pool or zap, token, ...]. The iteration continues until a pool address of 0x00, then the last given token is transferred to _receiver
swapParamsuint256[5][5]A multidimensional array of [i, j, swap type, pool_type, n_coins] where: i is the index of the input token, j is the index of the output token, swap type should be: - 1 for exchange, - 2 for exchange_underlying, - 3 for underlying exchange via zap: factory stable metapools with lending base pool exchange_underlying and factory crypto-metapools underlying exchange (exchange method in zap); - 4 for coin -> LP token "exchange" (actually add_liquidity), - 5 for lending pool underlying coin -> LP token "exchange" (actually add_liquidity), - 6 for LP token -> coin "exchange" (actually remove_liquidity_one_coin), - 7 for LP token -> lending or fake pool underlying coin "exchange" (actually remove_liquidity_one_coin), - 8 for ETH <-> WETH, ETH -> stETH or ETH -> frxETH, stETH <-> wstETH, frxETH <-> sfrxETH, ETH -> wBETH, - 9 for SNX swaps (sUSD, sEUR, sETH, sBTC) Pool type: - 1 - stable, 2 - crypto, 3 - tricrypto, 4 - llama n_coins indicates the number of coins in the pool
amountuint256The amount of route[0] to be sent.
expecteduint256The minimum amount received after the final swap.

Returns

NameTypeDescription
<none>uint256The received amount of the final output token.

exchange

Performs up to 5 swaps in a single transaction.

Routing and swap params must be determined off-chain. This functionality is designed for gas efficiency over ease-of-use.

function exchange(
    address[11] calldata route,
    uint256[5][5] calldata swapParams,
    uint256 amount,
    uint256 expected,
    address[5] calldata pools,
    address receiver
)
    external
    payable
    returns (uint256);

Parameters

NameTypeDescription
routeaddress[11]Array of the route.
swapParamsuint256[5][5]Parameters for the swap operation.
amountuint256The amount of route[0] to be sent.
expecteduint256The minimum amount expected after all the swaps.
poolsaddress[5]Array of pool addresses for swaps via zap contracts. Needed only for swap type = 3.
receiveraddressThe address to transfer the final output token to.

Returns

NameTypeDescription
<none>uint256The received amount of the final output token.

exchange

Executes an exchange operation.

function exchange(
    address[11] calldata route,
    uint256[5][5] calldata swapParams,
    uint256 amount,
    uint256 expected,
    address[5] calldata pools
)
    external
    payable
    returns (uint256);

Parameters

NameTypeDescription
routeaddress[11]Array containing the route for exchange.
swapParamsuint256[5][5]Parameters for the swap operation.
amountuint256The amount of input token to be sent.
expecteduint256The minimum amount expected after the exchange.
poolsaddress[5]Array of pool addresses for swaps via zap contracts.

Returns

NameTypeDescription
<none>uint256The received amount of the final output token.

get_dy

function get_dy(
    address[11] calldata route,
    uint256[5][5] calldata swapParams,
    uint256 amount,
    address[5] calldata pools
)
    external
    view
    returns (uint256);

ICurveTwoAssetPool

Git Source

Functions

add_liquidity

function add_liquidity(
    uint256[2] calldata amounts,
    uint256 minMintAmount,
    bool useEth,
    address receiver
)
    external
    returns (uint256);

add_liquidity

function add_liquidity(uint256[2] calldata amounts, uint256 minMintAmount) external returns (uint256);

get_dy

function get_dy(uint256 i, uint256 j, uint256 dx) external view returns (uint256 dy);

exchange

function exchange(uint256 i, uint256 j, uint256 dx, uint256 min_dy) external payable returns (uint256 dy);

exchange

function exchange(
    uint256 i,
    uint256 j,
    uint256 dx,
    uint256 min_dy,
    bool useEth
)
    external
    payable
    returns (uint256 dy);

coins

function coins(uint256 arg0) external view returns (address);

price_oracle

function price_oracle() external view returns (uint256);

Contents

Broker

Git Source

Struct encapsulating the broker parameters passed to the create functions. Both can be set to zero.

struct Broker {
    address account;
    uint256 fee;
}

Properties

NameTypeDescription
accountaddressThe address receiving the broker's fee.
feeuint256The broker's percentage fee from the total amount, denoted as a fixed-point number where 1e18 is 100%.

Lockup

Git Source

Namespace for the structs used in both {SablierV2LockupLinear} and {SablierV2LockupDynamic}.

Structs

Amounts

Struct encapsulating the deposit, withdrawn, and refunded amounts, all denoted in units of the asset's decimals.

Because the deposited and the withdrawn amount are often read together, declaring them in the same slot saves gas.

struct Amounts {
    uint128 deposited;
    uint128 withdrawn;
    uint128 refunded;
}

Properties

NameTypeDescription
depositeduint128The initial amount deposited in the stream, net of fees.
withdrawnuint128The cumulative amount withdrawn from the stream.
refundeduint128The amount refunded to the sender. Unless the stream was canceled, this is always zero.

LockupLinear

Git Source

Structs

Durations

Struct encapsulating the cliff duration and the total duration.

struct Durations {
    uint40 cliff;
    uint40 total;
}

Properties

NameTypeDescription
cliffuint40The cliff duration in seconds.
totaluint40The total duration in seconds.

Stream

Lockup Linear stream.

The fields are arranged like this to save gas via tight variable packing.

struct Stream {
    address sender;
    uint40 startTime;
    uint40 cliffTime;
    bool isCancelable;
    bool wasCanceled;
    IERC20 asset;
    uint40 endTime;
    bool isDepleted;
    bool isStream;
    bool isTransferable;
    Lockup.Amounts amounts;
}

Properties

NameTypeDescription
senderaddressThe address streaming the assets, with the ability to cancel the stream.
startTimeuint40The Unix timestamp indicating the stream's start.
cliffTimeuint40The Unix timestamp indicating the cliff period's end.
isCancelableboolBoolean indicating if the stream is cancelable.
wasCanceledboolBoolean indicating if the stream was canceled.
assetIERC20The contract address of the ERC-20 asset used for streaming.
endTimeuint40The Unix timestamp indicating the stream's end.
isDepletedboolBoolean indicating if the stream is depleted.
isStreamboolBoolean indicating if the struct entity exists.
isTransferableboolBoolean indicating if the stream NFT is transferable.
amountsLockup.AmountsStruct containing the deposit, withdrawn, and refunded amounts, all denoted in units of the asset's decimals.

Batch

Git Source

Structs

CreateWithDurations

Struct encapsulating the parameters for the {ISablierV2Batch.createWithDurations} function. The function takes an array of these structs to create multiple streams in a single transaction.

struct CreateWithDurations {
    address sender;
    address recipient;
    uint128 totalAmount;
    bool cancelable;
    bool transferable;
    LockupLinear.Durations durations;
    Broker broker;
}

Properties

NameTypeDescription
senderaddressThe address streaming the assets, with the ability to cancel the stream. It doesn't have to be the same as msg.sender.
recipientaddressThe address receiving the assets.
totalAmountuint128The total amount of ERC-20 assets to be paid, including the stream deposit and any potential fees, all denoted in units of the asset's decimals.
cancelableboolIndicates if the stream is cancelable.
transferableboolIndicates if the stream NFT is transferable.
durationsLockupLinear.DurationsStruct containing (i) cliff period duration and (ii) total stream duration, both in seconds.
brokerBrokerStruct containing (i) the address of the broker assisting in creating the stream, and (ii) the percentage fee paid to the broker from totalAmount, denoted as a fixed-point number. Both can be set to zero.

ISablierV2Batch

Git Source

Functions

createWithDurations

Creates a batch of Lockup Linear streams using createWithDurations.

*Requirements:

  • There must be at least one element in batch.
  • All requirements from {ISablierV2LockupLinear.createWithDurations} must be met for each stream.*
function createWithDurations(
    address lockupLinear,
    IERC20 asset,
    Batch.CreateWithDurations[] calldata batch
)
    external
    returns (uint256[] memory streamIds);

Parameters

NameTypeDescription
lockupLinearaddressThe address of the {SablierV2LockupLinear} contract.
assetIERC20The contract address of the ERC-20 asset used for streaming.
batchBatch.CreateWithDurations[]An array of structs, each encapsulating a subset of the parameters of {SablierV2LockupLinear.createWithDurations}.

Returns

NameTypeDescription
streamIdsuint256[]The ids of the newly created streams.

ISablierV2LockupLinear

Git Source

Functions

getStream

function getStream(uint256 streamId) external view returns (LockupLinear.Stream memory stream);

Contents

ISnapshotDelegateRegistry

Git Source

Functions

setDelegate

function setDelegate(bytes32 id, address delegate) external;

delegation

function delegation(address account, bytes32 id) external view returns (address);

Contents

IStakeDaoGauge

Git Source

Functions

staking_token

function staking_token() external view returns (address);

IStakeDaoVault

Git Source

Functions

withdraw

function withdraw(uint256 shares) external;

token

function token() external view returns (address);

Contents

Contents

Contents

IERC20PermitAllowed

Git Source

Interface used by DAI/CHAI for permit

Functions

permit

Approve the spender to spend some tokens via the holder signature

This is the permit interface used by DAI and CHAI

function permit(
    address holder,
    address spender,
    uint256 nonce,
    uint256 expiry,
    bool allowed,
    uint8 v,
    bytes32 r,
    bytes32 s
)
    external;

Parameters

NameTypeDescription
holderaddressThe address of the token holder, the token owner
spenderaddressThe address of the token spender
nonceuint256The holder's nonce, increases at each call to permit
expiryuint256The timestamp at which the permit is no longer valid
allowedboolBoolean that sets approval amount, true for type(uint256).max and false for 0
vuint8Must produce valid secp256k1 signature from the holder along with r and s
rbytes32Must produce valid secp256k1 signature from the holder along with v and s
sbytes32Must produce valid secp256k1 signature from the holder along with r and v

ISelfPermit

Git Source

Functionality to call permit on any EIP-2612-compliant token for use in the route

Functions

selfPermit

Permits this contract to spend a given token from msg.sender

The owner is always msg.sender and the spender is always address(this).

function selfPermit(address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external payable;

Parameters

NameTypeDescription
tokenaddressThe address of the token spent
valueuint256The amount that can be spent of token
deadlineuint256A timestamp, the current blocktime must be less than or equal to this timestamp
vuint8Must produce valid secp256k1 signature from the holder along with r and s
rbytes32Must produce valid secp256k1 signature from the holder along with v and s
sbytes32Must produce valid secp256k1 signature from the holder along with r and v

selfPermitIfNecessary

Permits this contract to spend a given token from msg.sender

The owner is always msg.sender and the spender is always address(this). Can be used instead of #selfPermit to prevent calls from failing due to a frontrun of a call to #selfPermit

function selfPermitIfNecessary(
    address token,
    uint256 value,
    uint256 deadline,
    uint8 v,
    bytes32 r,
    bytes32 s
)
    external
    payable;

Parameters

NameTypeDescription
tokenaddressThe address of the token spent
valueuint256The amount that can be spent of token
deadlineuint256A timestamp, the current blocktime must be less than or equal to this timestamp
vuint8Must produce valid secp256k1 signature from the holder along with r and s
rbytes32Must produce valid secp256k1 signature from the holder along with v and s
sbytes32Must produce valid secp256k1 signature from the holder along with r and v

selfPermitAllowed

Permits this contract to spend the sender's tokens for permit signatures that have the allowed parameter

The owner is always msg.sender and the spender is always address(this)

function selfPermitAllowed(
    address token,
    uint256 nonce,
    uint256 expiry,
    uint8 v,
    bytes32 r,
    bytes32 s
)
    external
    payable;

Parameters

NameTypeDescription
tokenaddressThe address of the token spent
nonceuint256The current nonce of the owner
expiryuint256The timestamp at which the permit is no longer valid
vuint8Must produce valid secp256k1 signature from the holder along with r and s
rbytes32Must produce valid secp256k1 signature from the holder along with v and s
sbytes32Must produce valid secp256k1 signature from the holder along with r and v

selfPermitAllowedIfNecessary

Permits this contract to spend the sender's tokens for permit signatures that have the allowed parameter

The owner is always msg.sender and the spender is always address(this) Can be used instead of #selfPermitAllowed to prevent calls from failing due to a frontrun of a call to #selfPermitAllowed.

function selfPermitAllowedIfNecessary(
    address token,
    uint256 nonce,
    uint256 expiry,
    uint8 v,
    bytes32 r,
    bytes32 s
)
    external
    payable;

Parameters

NameTypeDescription
tokenaddressThe address of the token spent
nonceuint256The current nonce of the owner
expiryuint256The timestamp at which the permit is no longer valid
vuint8Must produce valid secp256k1 signature from the holder along with r and s
rbytes32Must produce valid secp256k1 signature from the holder along with v and s
sbytes32Must produce valid secp256k1 signature from the holder along with r and v

Contents

Contents

IBaseGauge

Git Source

Functions

queueNewRewards

function queueNewRewards(uint256 _amount) external returns (bool);

earned

function earned(address _account) external view returns (uint256);

IDYfiRewardPool

Git Source

Functions

claim

function claim() external returns (uint256);

IGauge

Git Source

Inherits: IBaseGauge, IERC4626

Functions

initialize

function initialize(address _stakingToken, address _owner) external;

boostedBalanceOf

function boostedBalanceOf(address _account) external view returns (uint256);

getReward

function getReward(address _account) external returns (bool);

setRecipient

function setRecipient(address _recipient) external;

IGaugeFactory

Git Source

Functions

createGauge

function createGauge(address, address) external returns (address);

IRedemption

Git Source

Functions

redeem

function redeem(uint256 dYfiAmount) external payable returns (uint256);

eth_required

function eth_required(uint256 dYfiAmount) external view returns (uint256);

IVotingYFI

Git Source

Inherits: IERC20

Functions

totalSupply

function totalSupply() external view returns (uint256);

locked

function locked(address _user) external view returns (LockedBalance memory);

modify_lock

function modify_lock(uint256 _amount, uint256 _unlock_time, address _user) external returns (LockedBalance memory);

withdraw

function withdraw() external returns (Withdrawn memory);

point_history

function point_history(address user, uint256 epoch) external view returns (Point memory);

Events

ModifyLock

event ModifyLock(address indexed sender, address indexed user, uint256 amount, uint256 locktime, uint256 ts);

Withdraw

event Withdraw(address indexed user, uint256 amount, uint256 ts);

Penalty

event Penalty(address indexed user, uint256 amount, uint256 ts);

Supply

event Supply(uint256 oldSupply, uint256 newSupply, uint256 ts);

Structs

LockedBalance

struct LockedBalance {
    uint256 amount;
    uint256 end;
}

Withdrawn

struct Withdrawn {
    uint256 amount;
    uint256 penalty;
}

Point

struct Point {
    int128 bias;
    int128 slope;
    uint256 ts;
    uint256 blk;
}

IYearnVaultV2

Git Source

Functions

token

function token() external view returns (address);

deposit

function deposit(uint256 amount, address recipient) external returns (uint256 shares);

deposit

function deposit(uint256 amount) external returns (uint256 shares);

withdraw

function withdraw(uint256 shares, address recipient) external returns (uint256 amount);

pricePerShare

function pricePerShare() external view returns (uint256);

totalSupply

function totalSupply() external view returns (uint256);

totalAssets

function totalAssets() external view returns (uint256);

lastReport

function lastReport() external view returns (uint256);

lockedProfitDegradation

function lockedProfitDegradation() external view returns (uint256);

lockedProfit

function lockedProfit() external view returns (uint256);

IYfiRewardPool

Git Source

Functions

claim

function claim() external returns (uint256);

checkpoint_token

function checkpoint_token() external;

checkpoint_total_supply

function checkpoint_total_supply() external;

Events

CheckpointToken

event CheckpointToken(uint256 time, uint256 tokens);

IWETH

Git Source

Functions

deposit

function deposit() external payable;

withdraw

function withdraw(uint256) external;

approve

function approve(address, uint256) external returns (bool);

transfer

function transfer(address, uint256) external returns (bool);

transferFrom

function transferFrom(address, address, uint256) external returns (bool);

balanceOf

function balanceOf(address) external view returns (uint256);

Contents

IBaseRewardsGauge

Git Source

Functions

depositRewardToken

function depositRewardToken(address rewardToken, uint256 amount) external;

IMiniChefV3Rewarder

Git Source

Functions

onReward

function onReward(uint256 pid, address user, address recipient, uint256 rewardAmount, uint256 newLpAmount) external;

pendingTokens

function pendingTokens(
    uint256 pid,
    address user,
    uint256 rewardAmount
)
    external
    view
    returns (IERC20[] memory, uint256[] memory);

IDYFIRedeemer

Git Source

Inherits: IFlashLoanRecipient, IAccessControlEnumerable

Functions

slippage

function slippage() external view returns (uint256);

getLatestPrice

function getLatestPrice() external view returns (uint256);

minYfiRedeem

function minYfiRedeem(uint256 dYfiAmount) external view returns (uint256);

currentYfiRedeem

function currentYfiRedeem(uint256 dYfiAmount) external view returns (uint256);

expectedMassRedeemReward

function expectedMassRedeemReward(uint256 dYfiAmount) external view returns (uint256);

massRedeem

function massRedeem(address[] calldata accounts, uint256[] calldata dYfiAmounts) external;

setSlippage

function setSlippage(uint256 slippage_) external;

IMasterRegistry

Git Source

Functions

addRegistry

Add a new registry entry to the master list. Reverts if an entry is already found with the given name.

function addRegistry(bytes32 registryName, address registryAddress) external;

Parameters

NameTypeDescription
registryNamebytes32name for the registry
registryAddressaddressaddress of the new registry

updateRegistry

Update an existing registry entry to the master list. Reverts if no match is found.

function updateRegistry(bytes32 registryName, address registryAddress) external;

Parameters

NameTypeDescription
registryNamebytes32name for the registry
registryAddressaddressaddress of the new registry

resolveNameToLatestAddress

Resolves a name to the latest registry address. Reverts if no match is found.

function resolveNameToLatestAddress(bytes32 registryName) external view returns (address);

Parameters

NameTypeDescription
registryNamebytes32name for the registry

Returns

NameTypeDescription
<none>addressaddress address of the latest registry with the matching name

resolveNameAndVersionToAddress

Resolves a name and version to an address. Reverts if there is no registry with given name and version.

function resolveNameAndVersionToAddress(bytes32 registryName, uint256 version) external view returns (address);

Parameters

NameTypeDescription
registryNamebytes32address of the registry you want to resolve to
versionuint256version of the registry you want to resolve to

resolveNameToAllAddresses

Resolves a name to an array of all addresses. Reverts if no match is found.

function resolveNameToAllAddresses(bytes32 registryName) external view returns (address[] memory);

Parameters

NameTypeDescription
registryNamebytes32name for the registry

Returns

NameTypeDescription
<none>address[]address address of the latest registry with the matching name

resolveAddressToRegistryData

Resolves an address to registry entry data.

function resolveAddressToRegistryData(address registryAddress)
    external
    view
    returns (bytes32 registryName, uint256 version, bool isLatest);

Parameters

NameTypeDescription
registryAddressaddressaddress of a registry you want to resolve

Returns

NameTypeDescription
registryNamebytes32name of the resolved registry
versionuint256version of the resolved registry
isLatestboolboolean flag of whether the given address is the latest version of the given registries with matching name

Structs

ReverseRegistryData

struct ReverseRegistryData {
    bytes32 registryName;
    uint256 version;
}

IStakingDelegateRewards

Git Source

Inherits: IAccessControlEnumerable

Functions

getReward

function getReward(address stakingToken) external;

setRewardReceiver

function setRewardReceiver(address receiver) external;

ISwapAndLock

Git Source

Inherits: IAccessControlEnumerable

Functions

convertToCoveYfi

function convertToCoveYfi() external returns (uint256);

setDYfiRedeemer

function setDYfiRedeemer(address newDYfiRedeemer) external;

dYfiRedeemer

function dYfiRedeemer() external view returns (address);

IYearn4626RouterExt

Git Source

Inherits: IYearn4626Router

Functions

redeemVaultV2

function redeemVaultV2(
    IYearnVaultV2 vault,
    uint256 shares,
    address to,
    uint256 minAmountOut
)
    external
    payable
    returns (uint256 amountOut);

redeemFromRouter

function redeemFromRouter(
    IERC4626 vault,
    uint256 shares,
    address to,
    uint256 minAmountOut
)
    external
    payable
    returns (uint256 amountOut);

withdrawFromRouter

function withdrawFromRouter(
    IERC4626 vault,
    uint256 assets,
    address to,
    uint256 maxSharesIn
)
    external
    payable
    returns (uint256 sharesIn);

redeemStakeDaoGauge

function redeemStakeDaoGauge(
    IStakeDaoGauge gauge,
    uint256 shares,
    address to
)
    external
    payable
    returns (uint256 amountOut);

previewDeposits

function previewDeposits(
    address[] calldata path,
    uint256 assetsIn
)
    external
    view
    returns (uint256[] memory sharesOut);

previewMints

function previewMints(address[] calldata path, uint256 sharesOut) external view returns (uint256[] memory assetsIn);

previewWithdraws

function previewWithdraws(
    address[] calldata path,
    uint256 assetsOut
)
    external
    view
    returns (uint256[] memory sharesIn);

previewRedeems

function previewRedeems(address[] calldata path, uint256 sharesIn) external view returns (uint256[] memory assetsOut);

pullTokenWithPermit2

function pullTokenWithPermit2(
    ISignatureTransfer.PermitTransferFrom memory permit,
    ISignatureTransfer.SignatureTransferDetails calldata transferDetails,
    bytes calldata signature
)
    external
    payable;

IYearnGaugeStrategy

Git Source

Inherits: IStrategy

Functions

vault

function vault() external view returns (address);

vaultAsset

function vaultAsset() external view returns (address);

yearnStakingDelegate

function yearnStakingDelegate() external view returns (address);

dYfiRedeemer

function dYfiRedeemer() external view returns (address);

setHarvestSwapParams

function setHarvestSwapParams(CurveRouterSwapper.CurveSwapParams calldata curveSwapParams_) external;

setDYfiRedeemer

function setDYfiRedeemer(address newDYfiRedeemer) external;

maxTotalAssets

function maxTotalAssets() external view returns (uint256);

depositedInYSD

function depositedInYSD(address asset) external view returns (uint256);

IYearnStakingDelegate

Git Source

Functions

deposit

function deposit(address gauge, uint256 amount) external;

withdraw

function withdraw(address gauge, uint256 amount) external;

withdraw

function withdraw(address gauge, uint256 amount, address receiver) external;

lockYfi

function lockYfi(uint256 amount) external returns (IVotingYFI.LockedBalance memory);

harvest

function harvest(address vault) external returns (uint256);

setCoveYfiRewardForwarder

function setCoveYfiRewardForwarder(address forwarder) external;

setGaugeRewardSplit

function setGaugeRewardSplit(
    address gauge,
    uint64 treasuryPct,
    uint64 coveYfiPct,
    uint64 userPct,
    uint64 veYfiPct
)
    external;

setBoostRewardSplit

function setBoostRewardSplit(uint128 treasuryPct, uint128 coveYfiPct) external;

setExitRewardSplit

function setExitRewardSplit(uint128 treasuryPct, uint128 coveYfiPct) external;

setSwapAndLock

function setSwapAndLock(address swapAndLock) external;

balanceOf

function balanceOf(address user, address gauge) external view returns (uint256);

totalDeposited

function totalDeposited(address gauge) external view returns (uint256);

depositLimit

function depositLimit(address gauge) external view returns (uint256);

availableDepositLimit

function availableDepositLimit(address gauge) external view returns (uint256);

gaugeStakingRewards

function gaugeStakingRewards(address gauge) external view returns (address);

gaugeRewardReceivers

function gaugeRewardReceivers(address gauge) external view returns (address);

getGaugeRewardSplit

function getGaugeRewardSplit(address gauge) external view returns (RewardSplit memory);

getBoostRewardSplit

function getBoostRewardSplit() external view returns (BoostRewardSplit memory);

getExitRewardSplit

function getExitRewardSplit() external view returns (ExitRewardSplit memory);

treasury

function treasury() external view returns (address);

Structs

RewardSplit

struct RewardSplit {
    uint64 treasury;
    uint64 coveYfi;
    uint64 user;
    uint64 lock;
}

ExitRewardSplit

struct ExitRewardSplit {
    uint128 treasury;
    uint128 coveYfi;
}

BoostRewardSplit

struct BoostRewardSplit {
    uint128 treasury;
    uint128 coveYfi;
}

Contents

Errors

Git Source

Library containing all custom errors the protocol may revert with.

Errors

NameEmpty

Thrown when the registry name given is empty.

error NameEmpty();

AddressEmpty

Thrown when the registry address given is empty.

error AddressEmpty();

RegistryNameFound

Thrown when the registry name is found when calling addRegistry().

error RegistryNameFound(bytes32 name);

RegistryNameNotFound

Thrown when the registry name is not found but is expected to be.

error RegistryNameNotFound(bytes32 name);

RegistryAddressNotFound

Thrown when the registry address is not found but is expected to be.

error RegistryAddressNotFound(address registryAddress);

RegistryNameVersionNotFound

Thrown when the registry name and version is not found but is expected to be.

error RegistryNameVersionNotFound(bytes32 name, uint256 version);

DuplicateRegistryAddress

Thrown when a duplicate registry address is found.

error DuplicateRegistryAddress(address registryAddress);

ZeroAddress

Error for when an address is zero which is not allowed.

error ZeroAddress();

ZeroAmount

Error for when an amount is zero which is not allowed.

error ZeroAmount();

InvalidRewardSplit

Error for when a reward split is invalid.

error InvalidRewardSplit();

TreasuryPctTooHigh

Error for when the treasury percentage is too high.

error TreasuryPctTooHigh();

PerpetualLockEnabled

Error for when perpetual lock is enabled and an action cannot be taken.

error PerpetualLockEnabled();

PerpetualLockDisabled

Error for when perpetual lock is disabled and an action cannot be taken.

error PerpetualLockDisabled();

SwapAndLockNotSet

Error for when swap and lock settings are not set.

error SwapAndLockNotSet();

GaugeRewardsAlreadyAdded

Error for when gauge rewards have already been added.

error GaugeRewardsAlreadyAdded();

GaugeRewardsNotYetAdded

Error for when gauge rewards have not yet been added.

error GaugeRewardsNotYetAdded();

ExecutionNotAllowed

Error for when execution of an action is not allowed.

error ExecutionNotAllowed();

ExecutionFailed

Error for when execution of an action has failed.

error ExecutionFailed();

CoveYfiRewardForwarderNotSet

Error for when Cove YFI reward forwarder is not set.

error CoveYfiRewardForwarderNotSet();

RescueNotAllowed

Error for when a rescue operation is not allowed.

error RescueNotAllowed();

PreviousRewardsPeriodNotCompleted

Error for when the previous rewards period has not been completed.

error PreviousRewardsPeriodNotCompleted();

OnlyStakingDelegateCanUpdateUserBalance

Error for when only the staking delegate can update a user's balance.

error OnlyStakingDelegateCanUpdateUserBalance();

OnlyStakingDelegateCanAddStakingToken

Error for when only the staking delegate can add a staking token.

error OnlyStakingDelegateCanAddStakingToken();

OnlyRewardDistributorCanNotifyRewardAmount

Error for when only the reward distributor can notify the reward amount.

error OnlyRewardDistributorCanNotifyRewardAmount();

StakingTokenAlreadyAdded

Error for when a staking token has already been added.

error StakingTokenAlreadyAdded();

StakingTokenNotAdded

Error for when a staking token has not been added.

error StakingTokenNotAdded();

RewardRateTooLow

Error for when the reward rate is too low.

error RewardRateTooLow();

RewardDurationCannotBeZero

Error for when the reward duration cannot be zero.

error RewardDurationCannotBeZero();

SlippageTooHigh

Error for when slippage is too high.

error SlippageTooHigh();

InvalidTokensReceived

Error for when invalid tokens are received.

error InvalidTokensReceived();

InvalidFromToken

CURVE ROUTER SWAPPER ///

error InvalidFromToken(address intendedFromToken, address actualFromToken);

InvalidToToken

error InvalidToToken(address intendedToToken, address actualToToken);

ExpectedAmountZero

Error for when the expected amount is zero.

error ExpectedAmountZero();

InvalidSwapParams

Error for when swap parameters are invalid.

error InvalidSwapParams();

SameAddress

SWAP AND LOCK ///

Error for when the same address is used in a context where it is not allowed.

error SameAddress();

OnlyMintingEnabled

Error for when only minting is enabled.

error OnlyMintingEnabled();

ZeroEthTransfer

RESCUABLE ///

Error for when an ETH transfer of zero is attempted.

error ZeroEthTransfer();

EthTransferFailed

Error for when an ETH transfer fails.

error EthTransferFailed();

ZeroTokenTransfer

Error for when a token transfer of zero is attempted.

error ZeroTokenTransfer();

NotAuthorized

GAUGE REWARD RECEIVER ///

Error for when an action is not authorized.

error NotAuthorized();

CannotRescueRewardToken

Error for when rescuing a reward token is not allowed.

error CannotRescueRewardToken();

InvalidArrayLength

DYFI REDEEMER ///

Error for when an array length is invalid.

error InvalidArrayLength();

PriceFeedOutdated

Error for when a price feed is outdated.

error PriceFeedOutdated();

PriceFeedIncorrectRound

Error for when a price feed round is incorrect.

error PriceFeedIncorrectRound();

PriceFeedReturnedZeroPrice

Error for when a price feed returns a zero price.

error PriceFeedReturnedZeroPrice();

NoDYfiToRedeem

Error for when there is no DYFI to redeem.

error NoDYfiToRedeem();

CallerRewardEthTransferFailed

Error for when an ETH transfer for caller reward fails.

error CallerRewardEthTransferFailed();

GaugeAlreadyDeployed

COVE YEARN GAUGE FACTORY ///

Error for when a gauge has already been deployed.

error GaugeAlreadyDeployed();

GaugeNotDeployed

Error for when a gauge has not been deployed.

error GaugeNotDeployed();

InvalidLPToken

MINICHEF V3 ////

Error for when an LP token is invalid.

error InvalidLPToken();

LPTokenNotAdded

Error for when an LP token has not been added.

error LPTokenNotAdded();

LPTokenDoesNotMatchPoolId

Error for when an LP token does not match the pool ID.

error LPTokenDoesNotMatchPoolId();

InsufficientBalance

Error for when there is an insufficient balance.

error InsufficientBalance();

LPTokenAlreadyAdded

Error for when an LP token has already been added.

error LPTokenAlreadyAdded();

RewardRateTooHigh

Error for when the reward rate is too high.

error RewardRateTooHigh();

InsufficientShares

Yearn4626RouterExt ///

Error for when there are insufficient shares.

error InsufficientShares();

InvalidTo

Error for when the 'to' address is invalid.

error InvalidTo();

InsufficientGas

Error esure the has enough remaining gas.

error InsufficientGas();

TakeAwayNotEnoughBalance

TESTING ///

Error for when there is not enough balance to take away.

error TakeAwayNotEnoughBalance();

StrategyNotAddedToVault

Error for when a strategy has not been added to a vault.

error StrategyNotAddedToVault();

TransferNotAllowedYet

COVE TOKEN ///

Error for when a transfer is attempted before it is allowed.

error TransferNotAllowedYet();

CannotBeBothSenderAndReceiver

Error for when an address is being added as both a sender and a receiver.

error CannotBeBothSenderAndReceiver();

UnpauseTooEarly

Error for when an unpause is attempted too early.

error UnpauseTooEarly();

PausePeriodTooLong

Error for when the pause period is too long.

error PausePeriodTooLong();

MintingAllowedTooEarly

Error for when minting is attempted too early.

error MintingAllowedTooEarly();

InflationTooLarge

Error for when the mint amount exceeds the cap.

error InflationTooLarge();

AccessControlEnumerableUnauthorizedAccount

error AccessControlEnumerableUnauthorizedAccount(address account, bytes32 neededRole);

Unauthorized

Error for when an action is unauthorized.

error Unauthorized();

ExpectedPause

Error for when a pause is expected but not enacted.

error ExpectedPause();

AddressNotContract

COVE YEARN GAUGE FACTORY ///

Error for when an address is not a contract.

error AddressNotContract();

YearnVaultV2Helper

Git Source

Helper functions for Yearn Vault V2 contracts. Since Yearn Vault V2 contracts are not ERC-4626 compliant, they do not provide previewDeposit, previewMint, previewRedeem, and previewWithdraw functions. This library provides these functions for previewing share based deposit/mint/redeem/withdraw estimations.

These functions are only to be used off-chain for previewing. Due to how Yearn Vault V2 contracts work, share based withdraw/redeem estimations may not be accurate if the vault incurs a loss, thus share price changes. Coverage is currently disabled for this library due to forge limitations. TODO: Once the fix PR is merged, https://github.com/foundry-rs/foundry/pull/7510 coverage should be re-enabled.

Functions

freeFunds

Calculates the currently free funds in a Yearn Vault V2 contract.

This is based on Yearn Vault V2 contract's free funds calculation logic. https://github.com/yearn/yearn-vaults/blob/97ca1b2e4fcf20f4be0ff456dabd020bfeb6697b/contracts/Vault.vy#L844-L847

function freeFunds(IYearnVaultV2 vault) internal view returns (uint256);

Parameters

NameTypeDescription
vaultIYearnVaultV2The Yearn Vault V2 contract.

Returns

NameTypeDescription
<none>uint256The free funds in the vault.

previewDeposit

Preview the amount of shares to be issued for a given deposit amount.

function previewDeposit(IYearnVaultV2 vault, uint256 assetsIn) internal view returns (uint256);

Parameters

NameTypeDescription
vaultIYearnVaultV2The Yearn Vault V2 contract.
assetsInuint256The amount of assets to be deposited.

Returns

NameTypeDescription
<none>uint256The number of shares that would be issued for the deposited assets.

previewMint

Preview the amount of assets required to mint a given amount of shares.

function previewMint(IYearnVaultV2 vault, uint256 sharesOut) internal view returns (uint256);

Parameters

NameTypeDescription
vaultIYearnVaultV2The Yearn Vault V2 contract.
sharesOutuint256The number of shares to be minted.

Returns

NameTypeDescription
<none>uint256The amount of assets required to mint the specified number of shares.

previewRedeem

Preview the amount of assets to be received for redeeming a given amount of shares.

function previewRedeem(IYearnVaultV2 vault, uint256 sharesIn) internal view returns (uint256);

Parameters

NameTypeDescription
vaultIYearnVaultV2The Yearn Vault V2 contract.
sharesInuint256The number of shares to be redeemed.

Returns

NameTypeDescription
<none>uint256The amount of assets that would be received for the redeemed shares.

previewWithdraw

Preview the number of shares to be redeemed for a given withdrawal amount of assets.

function previewWithdraw(IYearnVaultV2 vault, uint256 assetsOut) internal view returns (uint256);

Parameters

NameTypeDescription
vaultIYearnVaultV2The Yearn Vault V2 contract.
assetsOutuint256The amount of assets to be withdrawn.

Returns

NameTypeDescription
<none>uint256The number of shares that would be redeemed for the withdrawn assets.

Contents

CoveYearnGaugeFactory

Git Source

Inherits: AccessControlEnumerable, Multicall

Factory contract to deploy and manage Yearn gauge-related contracts for Cove protocol.

This contract allows for the creation of Yearn gauge strategies, auto-compounding gauges, and non-auto-compounding gauges. It also manages the reward forwarder implementations and various administrative roles.

State Variables

MANAGER_ROLE

Role identifier for the manager role, used for privileged functions.

bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");

PAUSER_ROLE

Role identifier for the pauser role, used to pause certain contract functionalities.

bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");

_DYFI

Address of the DYFI token, used within the contract for various functionalities.

address private constant _DYFI = 0x41252E8691e964f7DE35156B68493bAb6797a275;

YEARN_STAKING_DELEGATE

Address of the Yearn Staking Delegate, immutable for the lifetime of the contract.

address public immutable YEARN_STAKING_DELEGATE;

COVE

Address of the COVE token, immutable for the lifetime of the contract.

address public immutable COVE;

rewardForwarderImpl

Address of the current Reward Forwarder implementation.

address public rewardForwarderImpl;

erc20RewardsGaugeImpl

Address of the current ERC20 Rewards Gauge implementation.

address public erc20RewardsGaugeImpl;

ysdRewardsGaugeImpl

Address of the current YSD Rewards Gauge implementation.

address public ysdRewardsGaugeImpl;

gaugeAdmin

Address of the account with gauge admin privileges.

address public gaugeAdmin;

gaugeManager

Address of the account with gauge management privileges.

address public gaugeManager;

gaugePauser

Address of the account with gauge pausing privileges.

address public gaugePauser;

supportedYearnGauges

Array of addresses for supported Yearn Gauges.

address[] public supportedYearnGauges;

yearnGaugeInfoStored

Mapping of Yearn Gauge addresses to their stored information.

mapping(address => GaugeInfoStored) public yearnGaugeInfoStored;

Functions

constructor

Initializes the factory with the necessary contract implementations and administrative roles.

constructor(
    address factoryAdmin,
    address ysd,
    address cove,
    address rewardForwarderImpl_,
    address erc20RewardsGaugeImpl_,
    address ysdRewardsGaugeImpl_,
    address gaugeAdmin_,
    address gaugeManager_,
    address gaugePauser_
)
    payable;

Parameters

NameTypeDescription
factoryAdminaddressThe address that will be granted the factory admin role.
ysdaddressThe address of the Yearn staking delegate.
coveaddressThe address of the Cove token.
rewardForwarderImpl_addressThe implementation address of the RewardForwarder contract.
erc20RewardsGaugeImpl_addressThe implementation address of the ERC20RewardsGauge contract.
ysdRewardsGaugeImpl_addressThe implementation address of the YSDRewardsGauge contract.
gaugeAdmin_addressThe address that will be granted the gauge admin role.
gaugeManager_address
gaugePauser_address

numOfSupportedYearnGauges

Returns the number of supported Yearn gauges.

function numOfSupportedYearnGauges() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The count of supported Yearn gauges.

getAllGaugeInfo

Retrieves information for all supported Yearn gauges.

The usage of the limit and offset parameters matches the same pattern found in pagination/SQL queries.

function getAllGaugeInfo(uint256 limit, uint256 offset) external view returns (GaugeInfo[] memory);

Parameters

NameTypeDescription
limituint256The maximum number of gauges to fetch information for.
offsetuint256The starting gauge index to retrieve data from.

Returns

NameTypeDescription
<none>GaugeInfo[]An array of GaugeInfo structs containing details for each supported Yearn gauge.

getGaugeInfo

Retrieves information for a specific Yearn gauge.

The unchecked block is used here because the loop index i is simply incremented in each iteration, ensuring that i will not exceed the length of the array and cause an overflow. Underflow is not a concern as i is initialized to 0 and only incremented.

Fetches gauge information from storage and attempts to determine the vault asset and version.

function getGaugeInfo(address yearnGauge) public view returns (GaugeInfo memory);

Parameters

NameTypeDescription
yearnGaugeaddressThe address of the Yearn gauge to retrieve information for.

Returns

NameTypeDescription
<none>GaugeInfoA GaugeInfo struct containing details for the specified Yearn gauge.

deployCoveGauges

Deploys Cove gauges for a given Yearn strategy.

Creates new instances of auto-compounding and non-auto-compounding gauges, initializes them, and sets up reward forwarders.

function deployCoveGauges(address coveYearnStrategy) external onlyRole(MANAGER_ROLE);

Parameters

NameTypeDescription
coveYearnStrategyaddressThe address of the Cove Yearn strategy for which to deploy gauges.

setRewardForwarderImplementation

Sets the implementation address for the RewardForwarder contract.

Can only be called by the admin role. Reverts if the new implementation address is the zero address.

function setRewardForwarderImplementation(address impl) external onlyRole(DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
impladdressThe new implementation address for the RewardForwarder contract.

setYsdRewardsGaugeImplementation

Sets the implementation address for the YSDRewardsGauge contract.

Can only be called by the admin role. Reverts if the new implementation address is the zero address.

function setYsdRewardsGaugeImplementation(address impl) external onlyRole(DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
impladdressThe new implementation address for the YSDRewardsGauge contract.

setERC20RewardsGaugeImplementation

Sets the implementation address for the ERC20RewardsGauge contract.

Can only be called by the admin role. Reverts if the new implementation address is the zero address.

function setERC20RewardsGaugeImplementation(address impl) external onlyRole(DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
impladdressThe new implementation address for the ERC20RewardsGauge contract.

setGaugeAdmin

Sets the gauge admin address.

Can only be called by the admin role. Reverts if the new gauge admin address is the zero address.

function setGaugeAdmin(address admin) external onlyRole(DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
adminaddressThe new gauge admin address.

setGaugeManager

Sets the gauge manager address.

Can only be called by the admin role. Reverts if the new gauge manager address is the zero address.

function setGaugeManager(address manager) external onlyRole(DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
manageraddressThe new gauge manager address.

setGaugePauser

Sets the gauge pauser address.

Can only be called by the admin role. Reverts if the new gauge pauser address is the zero address.

function setGaugePauser(address pauser) external onlyRole(DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
pauseraddressThe new gauge pauser address.

_setRewardForwarderImplementation

function _setRewardForwarderImplementation(address impl) internal;

_setERC20RewardsGaugeImplementation

function _setERC20RewardsGaugeImplementation(address impl) internal;

_setYsdRewardsGaugeImplementation

function _setYsdRewardsGaugeImplementation(address impl) internal;

_setGaugeAdmin

function _setGaugeAdmin(address admin) internal;

_setGaugeManager

function _setGaugeManager(address manager) internal;

_setGaugePauser

function _setGaugePauser(address pauser) internal;

Events

CoveGaugesDeployed

Event emitted when Cove gauges are deployed.

event CoveGaugesDeployed(
    address yearnGauge, address coveYearnStrategy, address autoCompoundingGauge, address nonAutoCompoundingGauge
);

Parameters

NameTypeDescription
yearnGaugeaddressAddress of the Yearn Gauge.
coveYearnStrategyaddressAddress of the Cove Yearn Strategy.
autoCompoundingGaugeaddressAddress of the auto-compounding gauge.
nonAutoCompoundingGaugeaddressAddress of the non-auto-compounding gauge.

Structs

GaugeInfoStored

struct GaugeInfoStored {
    address coveYearnStrategy;
    address autoCompoundingGauge;
    address nonAutoCompoundingGauge;
}

GaugeInfo

struct GaugeInfo {
    address yearnVaultAsset;
    address yearnVault;
    bool isVaultV2;
    address yearnGauge;
    address coveYearnStrategy;
    address autoCompoundingGauge;
    address nonAutoCompoundingGauge;
}

Contents

BaseRewardsGauge

Git Source

Inherits: IBaseRewardsGauge, ERC4626Upgradeable, ERC20PermitUpgradeable, AccessControlEnumerableUpgradeable, ReentrancyGuardUpgradeable, PausableUpgradeable

Gauge contract for managing and distributing reward tokens to stakers.

This contract handles the accounting of reward tokens, allowing users to claim their accrued rewards. It supports multiple reward tokens and allows for the addition of new rewards by authorized distributors. It does not support rebasing or fee on transfer tokens, or tokens with a max supply greater than type(uint128).max. The total supply of the gauge will always be equal to the total assets held by the gauge.

State Variables

MANAGER_ROLE

Role identifier for the manager role.

bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");

PAUSER_ROLE

Role identifier for the pauser role.

bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");

MAX_REWARDS

Maximum number of rewards that can be managed by the gauge.

uint256 public constant MAX_REWARDS = 8;

_WEEK

Constant representing one week in seconds.

uint256 internal constant _WEEK = 1 weeks;

_PRECISION

Precision used for reward calculations.

uint256 internal constant _PRECISION = 1e18;

rewardTokens

Array of reward token addresses.

address[] public rewardTokens;

_rewardData

Mapping from reward token address to its associated reward data.

mapping(address => Reward) internal _rewardData;

rewardsReceiver

Mapping from claimant address to their default reward receiver address.

mapping(address => address) public rewardsReceiver;

rewardIntegralFor

Mapping from reward token address to claimant address to their integral reward amount.

mapping(address => mapping(address => uint256)) public rewardIntegralFor;

claimData

Mapping from user address to reward token address to their claim data (claimable and claimed amounts).

mapping(address => mapping(address => uint256)) public claimData;

Functions

constructor

Constructor that disables initializers to prevent further initialization.

constructor() payable;

__BaseRewardsGauge_init

function __BaseRewardsGauge_init(address asset_) internal onlyInitializing;

decimals

Get the number of decimals for this token.

function decimals() public view override(ERC20Upgradeable, ERC4626Upgradeable) returns (uint8);

Returns

NameTypeDescription
<none>uint8uint8 Number of decimals

claimedReward

Get the number of already-claimed reward tokens for a user

function claimedReward(address addr, address token) external view returns (uint256);

Parameters

NameTypeDescription
addraddressAccount to get reward amount for
tokenaddressToken to get reward amount for

Returns

NameTypeDescription
<none>uint256uint256 Total amount of _token already claimed by _addr

claimableReward

Get the number of claimable reward tokens for a user

function claimableReward(address user, address rewardToken) external view returns (uint256);

Parameters

NameTypeDescription
useraddressAccount to get reward amount for
rewardTokenaddressToken to get reward amount for

Returns

NameTypeDescription
<none>uint256uint256 Claimable reward token amount

getRewardData

Get the reward data for a reward token

function getRewardData(address rewardToken) external view returns (Reward memory);

Parameters

NameTypeDescription
rewardTokenaddresstoken address to get reward data for

Returns

NameTypeDescription
<none>RewardReward struct for the reward token

setRewardsReceiver

Set the default reward receiver for the caller.

When set to address(0), rewards are sent to the caller

function setRewardsReceiver(address receiver) external;

Parameters

NameTypeDescription
receiveraddressReceiver address for any rewards claimed via claimRewards

claimRewards

Claim available reward tokens for addr

function claimRewards(address addr, address receiver) external nonReentrant;

Parameters

NameTypeDescription
addraddressAddress to claim for
receiveraddressAddress to transfer rewards to - if set to address(0), uses the default reward receiver for the caller

addReward

Adds a new reward token to be distributed by this contract.

Adds a new reward token to the contract, enabling it to be claimed by users. Can only be called by an address with the manager role.

function addReward(address rewardToken, address distributor) external onlyRole(MANAGER_ROLE);

Parameters

NameTypeDescription
rewardTokenaddressThe address of the reward token to add.
distributoraddressThe address of the distributor for the reward token.

setRewardDistributor

Set the reward distributor for a reward token. Only the current distributor or an address with the manager role can call this.

function setRewardDistributor(address rewardToken, address distributor) external;

Parameters

NameTypeDescription
rewardTokenaddressaddress of the reward token
distributoraddressaddress of the distributor contract

depositRewardToken

Deposit reward tokens into the gauge. Only the distributor or an address with the manager role can call this.

function depositRewardToken(address rewardToken, uint256 amount) external nonReentrant;

Parameters

NameTypeDescription
rewardTokenaddressaddress of the reward token
amountuint256amount of reward tokens to deposit

pause

Pauses the contract. Only callable by PAUSER_ROLE or DEFAULT_ADMIN_ROLE.

function pause() external;

unpause

Unpauses the contract. Only callable by DEFAULT_ADMIN_ROLE.

function unpause() external onlyRole(DEFAULT_ADMIN_ROLE);

totalAssets

Returns the total amount of the underlying asset that the gauge has.

Provides the total assets managed by the gauge, which is the same as the total supply of the gauge's shares. This is used to calculate the value of each share.

function totalAssets() public view virtual override(ERC4626Upgradeable) returns (uint256);

Returns

NameTypeDescription
<none>uint256The total assets held by the gauge.

_checkpointRewards

Internal function to claim pending rewards and update reward accounting for a user. This function is called during any claim operation and when rewards are deposited. It iterates through all reward tokens to update user rewards and optionally claims them.

function _checkpointRewards(address user, uint256 totalSupply_, bool claim, address receiver) internal;

Parameters

NameTypeDescription
useraddressThe user address to checkpoint rewards for. If set to address(0), only updates the global state.
totalSupply_uint256The current total supply of the staking token.
claimboolIf true, rewards will be transferred to the user or their designated receiver.
receiveraddressThe address to send claimed rewards to. If set to address(0), sends to the user or their default receiver.

_updateReward

The unchecked block is used here because the loop index i is simply incremented in each iteration, ensuring that i will not exceed the length of the array and cause an overflow. Underflow is not a concern as i is initialized to 0 and only incremented.

Internal function to update the reward accounting for a given token. This updates the accumulated reward per token and the timestamp of the last reward update. It is called by _checkpointRewards to ensure the reward state is up to date before any interactions.

function _updateReward(address token, uint256 totalSupply_) internal;

Parameters

NameTypeDescription
tokenaddressThe address of the reward token to update accounting for.
totalSupply_uint256The current total supply of the staking token, used to calculate the rewards per token.

_processUserReward

Internal function to process user rewards, updating the claimable and claimed amounts.

function _processUserReward(address token, address user, uint256 userBalance, bool claim, address receiver) internal;

Parameters

NameTypeDescription
tokenaddressThe address of the reward token to process.
useraddressThe user address to process rewards for.
userBalanceuint256The current balance of the user.
claimboolWhether to claim the rewards (transfer them to the user).
receiveraddressThe address to send claimed rewards to.

maxMint

Returns the maximum amount of shares that can be minted. Returns 0 if the contract is paused.

It is possible for totalClaimed + totalClaimable to overflow if using reward tokens with a max supply greater than type(uint128).max. An overflow in the claimed amount of reward tokens could allow a user to withdraw more tokens than allocated, leading to a potential drain of the contract. This can technically happen even if the supply is lower than 2**128 since tokens can be eventually recycled into the rewards, but should be a extremely rare scenario.

Assumes the total supply is equal to the total assets held by the gauge.

function maxMint(address) public view virtual override(ERC4626Upgradeable) returns (uint256);

Returns

NameTypeDescription
<none>uint256The maximum amount of shares that can be minted.

maxDeposit

Returns the maximum amount of assets that can be deposited. Returns 0 if the contract is paused.

Assumes the total supply is equal to the total assets held by the gauge.

function maxDeposit(address) public view virtual override(ERC4626Upgradeable) returns (uint256);

Returns

NameTypeDescription
<none>uint256The maximum amount of assets that can be deposited.

_beforeTokenTransfer

Hook that is called before any transfer of tokens. This includes minting and burning.

function _beforeTokenTransfer(address from, address to, uint256 amount) internal override(ERC20Upgradeable);

Parameters

NameTypeDescription
fromaddressThe address which is transferring tokens.
toaddressThe address which is receiving tokens.
amountuint256The amount of tokens being transferred.

Events

RewardTokenAdded

Event emitted when a reward token is added to the gauge.

event RewardTokenAdded(address indexed rewardToken, address distributor);

Parameters

NameTypeDescription
rewardTokenaddressThe address of the reward token that was added.
distributoraddressThe address of the distributor for the added reward token.

RewardTokenDeposited

Event emitted when a reward token is deposited into the gauge.

event RewardTokenDeposited(address indexed rewardToken, uint256 amount, uint256 newRate, uint256 timestamp);

Parameters

NameTypeDescription
rewardTokenaddressThe address of the reward token that was deposited.
amountuint256The amount of the reward token that was deposited.
newRateuint256The new rate of distribution per second for the deposited reward token.
timestampuint256The timestamp when the deposit occurred.

RewardDistributorSet

Event emitted when a reward distributor is set for a reward token.

event RewardDistributorSet(address indexed rewardToken, address distributor);

Parameters

NameTypeDescription
rewardTokenaddressThe address of the reward token for which the distributor is set.
distributoraddressThe address of the distributor set for the reward token.

Errors

CannotRedirectForAnotherUser

Error indicating an attempt to redirect rewards for another user.

error CannotRedirectForAnotherUser();

MaxRewardsReached

Error indicating that the maximum number of rewards has been reached.

error MaxRewardsReached();

RewardTokenAlreadyAdded

Error indicating that the reward token has already been added.

error RewardTokenAlreadyAdded();

Unauthorized

Error indicating an unauthorized action was attempted.

error Unauthorized();

InvalidDistributorAddress

Error indicating that an invalid distributor address was provided.

error InvalidDistributorAddress();

RewardAmountTooLow

Error indicating that the reward amount is too low.

error RewardAmountTooLow();

ZeroAddress

Error indicating that a zero address was provided where it is not allowed.

error ZeroAddress();

RewardCannotBeAsset

Error indicating that the reward token cannot be the same as the asset token.

error RewardCannotBeAsset();

RewardTokenNotAdded

Error indication that the reward token has not been added.

error RewardTokenNotAdded();

Structs

Reward

struct Reward {
    address distributor;
    uint256 periodFinish;
    uint256 rate;
    uint256 lastUpdate;
    uint256 integral;
    uint256 leftOver;
}

ERC20RewardsGauge

Git Source

Inherits: BaseRewardsGauge

A RewardsGauge contract for staking ERC20 tokens and earning rewards.

Functions

initialize

Initialize the contract

function initialize(address asset_) external virtual initializer;

Parameters

NameTypeDescription
asset_addressAddress of the asset token that will be deposited

MiniChefV3

Git Source

Inherits: Multicall, AccessControlEnumerable, Rescuable, SelfPermit, Pausable

A contract for managing staking, rewards, and pool information for liquidity providers.

This contract handles the logic for staking LP tokens, distributing rewards, and managing pool information. It supports multiple reward tokens through external rewarder contracts and includes emergency withdrawal functionality. It does not support rebasing or fee on transfer tokens.

State Variables

REWARD_TOKEN

Address of REWARD_TOKEN contract.

IERC20 public immutable REWARD_TOKEN;

_poolInfo

Info of each MCV3 pool.

PoolInfo[] private _poolInfo;

lpToken

Address of the LP token for each MCV3 pool.

IERC20[] public lpToken;

lpSupply

Total amount of LP token staked in each MCV3 pool.

uint256[] public lpSupply;

rewarder

Address of each IRewarder contract in MCV3.

IMiniChefV3Rewarder[] public rewarder;

_userInfo

Info of each user that stakes LP tokens.

mapping(uint256 => mapping(address => UserInfo)) private _userInfo;

_pidPlusOne

PID of the LP token plus one.

mapping(address => uint256) private _pidPlusOne;

totalAllocPoint

Total allocation points. Must be the sum of all allocation points in all pools.

uint256 public totalAllocPoint;

rewardPerSecond

The amount of REWARD_TOKEN distributed per second.

uint256 public rewardPerSecond;

availableReward

The amount of REWARD_TOKEN available in this contract for distribution.

uint256 public availableReward;

MAX_REWARD_TOKEN_PER_SECOND

The maximum amount of REWARD_TOKEN that can be distributed per second.

uint256 public constant MAX_REWARD_TOKEN_PER_SECOND = 100_000_000 ether / uint256(1 weeks);

_ACC_REWARD_TOKEN_PRECISION

Precision factor to calculate accumulated reward tokens per share.

uint256 private constant _ACC_REWARD_TOKEN_PRECISION = 1e12;

TIMELOCK_ROLE

The timelock role for the contract.

bytes32 public constant TIMELOCK_ROLE = keccak256("TIMELOCK_ROLE");

PAUSER_ROLE

The pauser role for the contract.

bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");

Functions

constructor

Constructs the MiniChefV3 contract with a specified reward token and admin address.

constructor(IERC20 rewardToken_, address admin, address pauser) payable;

Parameters

NameTypeDescription
rewardToken_IERC20The ERC20 token to be used as the reward token.
adminaddressThe address that will be granted the default admin role.
pauseraddress

poolLength

Returns the number of MCV3 pools.

function poolLength() public view returns (uint256 pools);

pidOfLPToken

Retrieves the pool ID of a given LP token.

Returns the pool ID by looking up the LP token address in the _pidPlusOne mapping.

function pidOfLPToken(IERC20 lpToken_) external view returns (uint256 pid);

Parameters

NameTypeDescription
lpToken_IERC20The LP token to query the pool ID for.

Returns

NameTypeDescription
piduint256The pool ID of the given LP token.

isLPTokenAdded

Checks if an LP token has been added to any pool.

The unchecked block is used here because the subtraction is safe from underflow. The condition above ensures that pidPlusOne is greater than zero, so subtracting one will not underflow.

Returns true if the LP token exists in the _pidPlusOne mapping.

function isLPTokenAdded(IERC20 lpToken_) external view returns (bool added);

Parameters

NameTypeDescription
lpToken_IERC20The LP token to check.

Returns

NameTypeDescription
addedboolTrue if the LP token has been added to a pool.

getUserInfo

Retrieves user information for a specific pool.

Returns the user's staked amount, reward debt, and unpaid rewards for a given pool.

function getUserInfo(uint256 pid, address user) external view returns (UserInfo memory info);

Parameters

NameTypeDescription
piduint256The pool ID to retrieve user information for.
useraddressThe user address to retrieve information for.

Returns

NameTypeDescription
infoUserInfoThe user's information for the specified pool.

getPoolInfo

Retrieves pool information for a specific pool ID.

Returns the pool's accumulated reward per share, last reward time, and allocation points.

function getPoolInfo(uint256 pid) external view returns (PoolInfo memory info);

Parameters

NameTypeDescription
piduint256The pool ID to retrieve information for.

Returns

NameTypeDescription
infoPoolInfoThe pool's information.

add

Add a new LP to the pool. Can only be called by the owner. DO NOT add the same LP token more than once. Rewards will be messed up if you do.

function add(uint32 allocPoint, IERC20 lpToken_, IMiniChefV3Rewarder rewarder_) public onlyRole(TIMELOCK_ROLE);

Parameters

NameTypeDescription
allocPointuint32AP of the new pool.
lpToken_IERC20Address of the LP ERC-20 token.
rewarder_IMiniChefV3RewarderAddress of the rewarder delegate.

set

Update the given pool's REWARD_TOKEN allocation point and IRewarder contract. Can only be called by the owner.

function set(
    uint256 pid,
    uint32 allocPoint,
    IERC20 lpToken_,
    IMiniChefV3Rewarder rewarder_,
    bool overwrite
)
    public
    onlyRole(TIMELOCK_ROLE);

Parameters

NameTypeDescription
piduint256The index of the pool. See _poolInfo.
allocPointuint32New AP of the pool.
lpToken_IERC20Address of the LP ERC-20 token.
rewarder_IMiniChefV3RewarderAddress of the rewarder delegate.
overwriteboolTrue if rewarder_ should be set. Otherwise rewarder_ is ignored.

rescue

function rescue(IERC20 token, address to, uint256 amount) external onlyRole(DEFAULT_ADMIN_ROLE);

setRewardPerSecond

Sets the reward per second to be distributed. Can only be called by the owner.

function setRewardPerSecond(uint256 rewardPerSecond_) public onlyRole(TIMELOCK_ROLE);

Parameters

NameTypeDescription
rewardPerSecond_uint256The amount of reward token to be distributed per second.

commitReward

Commits REWARD_TOKEN to the contract for distribution.

function commitReward(uint256 amount) external;

Parameters

NameTypeDescription
amountuint256The amount of REWARD_TOKEN to commit.

pendingReward

View function to see pending REWARD_TOKEN on frontend.

function pendingReward(uint256 pid, address user_) external view returns (uint256 pending);

Parameters

NameTypeDescription
piduint256The index of the pool. See _poolInfo.
user_addressAddress of user.

Returns

NameTypeDescription
pendinguint256REWARD_TOKEN reward for a given user.

updatePool

Update reward variables of the given pool.

function updatePool(uint256 pid) public returns (PoolInfo memory pool);

Parameters

NameTypeDescription
piduint256The index of the pool. See _poolInfo.

Returns

NameTypeDescription
poolPoolInfoReturns the pool that was updated.

deposit

Deposit LP tokens to MCV3 for REWARD_TOKEN allocation.

Deposits can be paused in case of emergencies by the admin or pauser roles.

function deposit(uint256 pid, uint256 amount, address to) public whenNotPaused;

Parameters

NameTypeDescription
piduint256The index of the pool. See _poolInfo.
amountuint256LP token amount to deposit.
toaddressThe receiver of amount deposit benefit.

harvestAndWithdraw

Withdraw LP tokens from MCV3.

+= is slightly more gas efficient (5300) than the alternative (5365) using solidity 0.8.18. The rule only applies to non-mapping storage variables.

function harvestAndWithdraw(uint256 pid, uint256 amount, address to) public;

Parameters

NameTypeDescription
piduint256The index of the pool. See _poolInfo.
amountuint256LP token amount to withdraw.
toaddressReceiver of the LP tokens.

harvest

Harvest proceeds for transaction sender to to.

unchecked is used as the subtraction is guaranteed to not underflow because rewardAmount is always less than or equal to availableReward_.

function harvest(uint256 pid, address to) public;

Parameters

NameTypeDescription
piduint256The index of the pool. See _poolInfo.
toaddressReceiver of REWARD_TOKEN rewards.

emergencyWithdraw

Withdraw without caring about rewards. EMERGENCY ONLY.

unchecked is used as the subtraction is guaranteed to not underflow because rewardAmount is always less than or equal to availableReward_.

function emergencyWithdraw(uint256 pid, address to) public;

Parameters

NameTypeDescription
piduint256The index of the pool. See _poolInfo.
toaddressReceiver of the LP tokens.

pause

Pauses the contract. Only callable by PAUSER_ROLE or DEFAULT_ADMIN_ROLE.

function pause() external;

unpause

Unpauses the contract. Only callable by DEFAULT_ADMIN_ROLE.

function unpause() external onlyRole(DEFAULT_ADMIN_ROLE);

Events

Deposit

Emitted when a user deposits LP tokens into a pool.

event Deposit(address indexed user, uint256 indexed pid, uint256 amount, address indexed to);

Parameters

NameTypeDescription
useraddressThe address of the user making the deposit.
piduint256The pool ID into which the deposit is made.
amountuint256The amount of LP tokens deposited.
toaddressThe address receiving the deposit.

Withdraw

Emitted when a user withdraws LP tokens from a pool.

event Withdraw(address indexed user, uint256 indexed pid, uint256 amount, address indexed to);

Parameters

NameTypeDescription
useraddressThe address of the user making the withdrawal.
piduint256The pool ID from which the withdrawal is made.
amountuint256The amount of LP tokens withdrawn.
toaddressThe address receiving the withdrawn LP tokens.

EmergencyWithdraw

Emitted when a user performs an emergency withdrawal of LP tokens from a pool.

event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount, address indexed to);

Parameters

NameTypeDescription
useraddressThe address of the user making the emergency withdrawal.
piduint256The pool ID from which the emergency withdrawal is made.
amountuint256The amount of LP tokens emergency withdrawn.
toaddressThe address receiving the emergency withdrawn LP tokens.

Harvest

Emitted when a user harvests reward tokens from a pool.

event Harvest(address indexed user, uint256 indexed pid, uint256 amount);

Parameters

NameTypeDescription
useraddressThe address of the user performing the harvest.
piduint256The pool ID from which the harvest is performed.
amountuint256The amount of reward tokens harvested.

LogPoolAddition

Emitted when a new pool is added to the MiniChef contract.

event LogPoolAddition(
    uint256 indexed pid, uint256 allocPoint, IERC20 indexed lpToken, IMiniChefV3Rewarder indexed rewarder
);

Parameters

NameTypeDescription
piduint256The pool ID of the newly added pool.
allocPointuint256The number of allocation points assigned to the new pool.
lpTokenIERC20The address of the LP token for the new pool.
rewarderIMiniChefV3RewarderThe address of the rewarder contract for the new pool.

LogSetPool

Emitted when a pool's configuration is updated.

event LogSetPool(uint256 indexed pid, uint256 allocPoint, IMiniChefV3Rewarder indexed rewarder, bool overwrite);

Parameters

NameTypeDescription
piduint256The pool ID of the updated pool.
allocPointuint256The new number of allocation points assigned to the pool.
rewarderIMiniChefV3RewarderThe address of the rewarder contract for the pool.
overwriteboolIndicates whether the update overwrites the existing rewarder contract.

LogUpdatePool

Emitted when a pool's rewards are updated.

event LogUpdatePool(uint256 indexed pid, uint64 lastRewardTime, uint256 lpSupply, uint256 accRewardPerShare);

Parameters

NameTypeDescription
piduint256The pool ID of the updated pool.
lastRewardTimeuint64The last timestamp when the pool's rewards were calculated.
lpSupplyuint256The total amount of LP tokens staked in the pool.
accRewardPerShareuint256The accumulated reward tokens per share, scaled to precision.

LogRewardPerSecond

Emitted when the reward per second is updated.

event LogRewardPerSecond(uint256 rewardPerSecond);

Parameters

NameTypeDescription
rewardPerSeconduint256The new amount of reward tokens distributed per second.

LogRewardCommitted

Emitted when a reward amount is committed for distribution.

event LogRewardCommitted(uint256 amount);

Parameters

NameTypeDescription
amountuint256The amount of reward tokens committed.

LogRewarderEmergencyWithdrawFaulty

Emitted when an emergency withdrawal from a rewarder contract is faulty.

event LogRewarderEmergencyWithdrawFaulty(address indexed user, uint256 indexed pid, uint256 amount, address indexed to);

Parameters

NameTypeDescription
useraddressThe address of the user performing the emergency withdrawal.
piduint256The pool ID from which the emergency withdrawal is made.
amountuint256The amount of tokens emergency withdrawn.
toaddressThe address receiving the emergency withdrawn tokens.

Structs

UserInfo

struct UserInfo {
    uint256 amount;
    uint256 rewardDebt;
    uint256 unpaidRewards;
}

PoolInfo

struct PoolInfo {
    uint160 accRewardPerShare;
    uint64 lastRewardTime;
    uint32 allocPoint;
}

RewardForwarder

Git Source

Inherits: Initializable, AccessControlUpgradeable

This contract is responsible for forwarding rewards from various sources to a specified destination. It allows for the approval and forwarding of reward tokens to a designated address, which can be a contract that further distributes or processes the rewards. The contract is initialized with the address of the reward destination and includes functionality to approve reward tokens for spending and to forward them.

The contract uses the OpenZeppelin SafeERC20 library to interact with ERC20 tokens safely. It inherits from OpenZeppelin's Initializable contract to ensure that initialization logic is executed only once.

State Variables

MANAGER_ROLE

Constant role for the manager of the contract, who can forward rewards.

bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");

rewardDestination

Address where the majority of rewards will be forwarded.

address public rewardDestination;

Functions

constructor

Constructor that disables initializers to prevent further initialization.

constructor() payable;

initialize

Initializes the contract with the specified reward destination.

function initialize(address destination_, address admin, address manager) external initializer;

Parameters

NameTypeDescription
destination_addressThe destination address where the rewards will be forwarded.
adminaddress
manageraddress

approveRewardToken

Approves the reward destination to spend the specified reward token.

Grants unlimited approval to the reward destination for the specified reward token.

function approveRewardToken(address rewardToken) external;

Parameters

NameTypeDescription
rewardTokenaddressThe address of the reward token to approve.

forwardRewardToken

Forwards the specified reward token to the reward destination.

Forwards all balance of the specified reward token to the reward destination

function forwardRewardToken(address rewardToken) public onlyRole(MANAGER_ROLE);

Parameters

NameTypeDescription
rewardTokenaddressThe address of the reward token to forward.

YSDRewardsGauge

Git Source

Inherits: BaseRewardsGauge

Gauge contract for managing and distributing YSD rewards to stakers within the Yearn ecosystem.

Extends from BaseRewardsGauge, adding specific logic for Yearn staking and strategy interactions. It includes functionality to set reward receivers and handle deposits and withdrawals in coordination with Yearn contracts.

State Variables

yearnStakingDelegate

Address of the Yearn staking delegate contract.

address public yearnStakingDelegate;

coveYearnStrategy

Address of the Cove Yearn strategy contract.

address public coveYearnStrategy;

Functions

initialize

Initializes the YSDRewardsGauge with the asset, Yearn staking delegate, and strategy addresses.

function initialize(address asset_, address ysd_, address strategy) external virtual initializer;

Parameters

NameTypeDescription
asset_addressThe asset token that will be used for deposits.
ysd_addressThe address of the Yearn staking delegate.
strategyaddressThe address of the Yearn strategy.

setStakingDelegateRewardsReceiver

Sets the receiver of staking delegate rewards.

Sets the address that will receive rewards from the Yearn staking delegate.

function setStakingDelegateRewardsReceiver(address receiver) external onlyRole(DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
receiveraddressThe address to receive the staking rewards.

maxDeposit

Returns the maximum amount of assets that can be deposited into the gauge.

Overrides the BaseRewardsGauge-maxDeposit function to include interaction with the YearnStakingDelegate.

function maxDeposit(address) public view virtual override(BaseRewardsGauge) returns (uint256);

Returns

NameTypeDescription
<none>uint256The maximum amount of assets that can be deposited.

maxMint

Returns the maximum amount of shares that can be minted from the gauge

Overrides the BaseRewardsGauge-maxMint function to include interaction with the YearnStakingDelegate.

function maxMint(address) public view virtual override(BaseRewardsGauge) returns (uint256);

Returns

NameTypeDescription
<none>uint256The maximum amount of shares that can be minted.

_availableDepositLimit

function _availableDepositLimit() internal view returns (uint256);

_deposit

Internal function to handle deposits into the gauge. Overrides the ERC4626Upgradeable-_deposit function to include interaction with the Yearn staking delegate.

function _deposit(
    address caller,
    address receiver,
    uint256 assets,
    uint256 shares
)
    internal
    virtual
    override(ERC4626Upgradeable);

Parameters

NameTypeDescription
calleraddressThe address initiating the deposit.
receiveraddressThe address that will receive the shares.
assetsuint256The amount of assets to deposit.
sharesuint256The amount of shares to mint.

_withdraw

Internal function to handle withdrawals from the gauge. Overrides the ERC4626Upgradeable-_withdraw function to include interaction with the Yearn staking delegate.

function _withdraw(
    address caller,
    address receiver,
    address owner,
    uint256 assets,
    uint256 shares
)
    internal
    virtual
    override(ERC4626Upgradeable);

Parameters

NameTypeDescription
calleraddressThe address initiating the withdrawal.
receiveraddressThe address that will receive the assets.
owneraddressThe address that owns the shares being withdrawn.
assetsuint256The amount of assets to withdraw.
sharesuint256The amount of shares to burn.

Errors

MaxTotalAssetsExceeded

Error thrown when the total assets exceed the maximum allowed.

error MaxTotalAssetsExceeded();

InvalidInitialization

Error thrown when the contract is not initialized properly.

error InvalidInitialization();

Contents

YearnGaugeStrategy

Git Source

Inherits: BaseStrategy, CurveRouterSwapper, YearnGaugeStrategyBase

Strategy for interacting with Yearn Gauge

State Variables

_harvestSwapParams

Parameters for Curve swap used during harvest

CurveSwapParams internal _harvestSwapParams;

_dYfiRedeemer

Address of the contract that will be redeeming dYFI for YFI for this strategy

address private _dYfiRedeemer;

Functions

constructor

Initializes the YearnGaugeStrategy

constructor(
    address asset_,
    address yearnStakingDelegate_,
    address curveRouter_
)
    payable
    BaseStrategy(asset_, "Wrapped YearnV3 Strategy")
    CurveRouterSwapper(curveRouter_)
    YearnGaugeStrategyBase(asset_, yearnStakingDelegate_);

Parameters

NameTypeDescription
asset_addressThe address of the asset (gauge token)
yearnStakingDelegate_addressThe address of the YearnStakingDelegate
curveRouter_addressThe address of the Curve router

setHarvestSwapParams

Sets the parameters for the Curve swap used in the harvest function

function setHarvestSwapParams(CurveSwapParams calldata curveSwapParams) external onlyManagement;

Parameters

NameTypeDescription
curveSwapParamsCurveSwapParamsThe parameters for the Curve swap

setDYfiRedeemer

Sets the address of the contract that will be redeeming dYFI

function setDYfiRedeemer(address newDYfiRedeemer) external onlyManagement;

Parameters

NameTypeDescription
newDYfiRedeemeraddressThe address of the new dYFI redeemer contract

dYfiRedeemer

Get the address of the contract that will be redeeming dYFI from this strategy

function dYfiRedeemer() external view returns (address);

Returns

NameTypeDescription
<none>addressThe address of the dYFI redeemer contract

availableDepositLimit

Calculates the available deposit limit for the strategy

function availableDepositLimit(address) public view override returns (uint256);

Returns

NameTypeDescription
<none>uint256The strategy's available deposit limit

_deployFunds

Deploys funds into the YearnStakingDelegate by depositing the asset.

function _deployFunds(uint256 _amount) internal override;

Parameters

NameTypeDescription
_amountuint256The amount of the asset to deposit.

_freeFunds

Withdraws funds from the YearnStakingDelegate by withdrawing the asset.

function _freeFunds(uint256 _amount) internal override;

Parameters

NameTypeDescription
_amountuint256The amount of the asset to withdraw.

_emergencyWithdraw

Performs an emergency withdrawal from the YearnStakingDelegate, withdrawing the asset to the strategy.

function _emergencyWithdraw(uint256 amount) internal override;

Parameters

NameTypeDescription
amountuint256The amount to withdraw in case of an emergency.

_harvestAndReport

Harvests dYfi rewards, swaps YFI for the vault asset, and re-deposits or adds to idle balance

function _harvestAndReport() internal override returns (uint256 _totalAssets);

Returns

NameTypeDescription
_totalAssetsuint256The total assets after harvest and redeposit/idle balance update

Events

DYfiRedeemerSet

event DYfiRedeemerSet(address oldDYfiRedeemer, address newDYfiRedeemer);

YearnGaugeStrategyBase

Git Source

Abstract base contract for Yearn gauge strategies, handling deposits and withdrawals to the YearnStakingDelegate.

State Variables

_DYFI

Address of the dYFI token

address internal constant _DYFI = 0x41252E8691e964f7DE35156B68493bAb6797a275;

_YFI

Address of the YFI token

address internal constant _YFI = 0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e;

_YEARN_STAKING_DELEGATE

Address of the YearnStakingDelegate contract

address internal immutable _YEARN_STAKING_DELEGATE;

_VAULT_ASSET

Address of the vault's underlying asset

address internal immutable _VAULT_ASSET;

_VAULT

Address of the Yearn vault

address internal immutable _VAULT;

Functions

constructor

Sets the initial configuration of the strategy and approves the maximum amount of tokens to the YearnStakingDelegate.

constructor(address asset_, address yearnStakingDelegate_);

Parameters

NameTypeDescription
asset_addressThe address of the asset (gauge token).
yearnStakingDelegate_addressThe address of the Yearn Staking Delegate.

yearnStakingDelegate

Get the address of the YearnStakingDelegate.

function yearnStakingDelegate() external view returns (address);

Returns

NameTypeDescription
<none>addressThe address of the YearnStakingDelegate.

vaultAsset

Get the address of the vault's underlying asset. This is the asset that is deposited into the vault which then is deposited into the gauge.

function vaultAsset() external view returns (address);

Returns

NameTypeDescription
<none>addressThe address of the vault's underlying asset.

vault

Get the address of the vault. This is the Yearn vault that the gauge is for.

function vault() external view returns (address);

Returns

NameTypeDescription
<none>addressThe address of the vault.

_depositToYSD

Internal function to deposit assets into the YearnStakingDelegate.

function _depositToYSD(address asset, uint256 amount) internal virtual;

Parameters

NameTypeDescription
assetaddressThe address of the asset to deposit.
amountuint256The amount of the asset to deposit.

_withdrawFromYSD

Internal function to withdraw assets from the YearnStakingDelegate.

function _withdrawFromYSD(address asset, uint256 amount) internal virtual;

Parameters

NameTypeDescription
assetaddressThe address of the asset to withdraw.
amountuint256The amount of the asset to withdraw.

depositedInYSD

Return the amount of the asset deposited by this contract in the YearnStakingDelegate.

function depositedInYSD(address asset) public view returns (uint256);

Parameters

NameTypeDescription
assetaddressThe address of the asset to check.

Returns

NameTypeDescription
<none>uint256The amount of the asset deposited in the YearnStakingDelegate.

Contents

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;
}

CoveYFI

Git Source

Inherits: ERC20Permit, Rescuable, AccessControlEnumerable

CoveYFI is a tokenized version of veYFI, commonly referred to as a liquid locker.

Extends the ERC-20 standard with permit, pausable, ownable, and rescuable functionality.

State Variables

_YFI

Address of the mainnet Yearn YFI token.

address private constant _YFI = 0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e;

_YEARN_STAKING_DELEGATE

Address of the YearnStakingDelegate contract, set at deployment and immutable thereafter.

address private immutable _YEARN_STAKING_DELEGATE;

Functions

constructor

constructor(
    address _yearnStakingDelegate,
    address admin
)
    payable
    ERC20("Cove YFI", "coveYFI")
    ERC20Permit("Cove YFI");

Parameters

NameTypeDescription
_yearnStakingDelegateaddressThe address of the YearnStakingDelegate contract.
adminaddressThe address of the contract admin for rescuing tokens.

deposit

Deposits YFI tokens into the YearnStakingDelegate contract and mints coveYFI tokens to the sender.

Mints coveYFI tokens equivalent to the amount of YFI deposited. The deposited YFI is then staked. Reverts with Errors.ZeroAmount if the deposit amount is zero. Emits a Transfer event from the zero address to the sender, indicating minting of coveYFI tokens.

function deposit(uint256 balance) external returns (uint256);

Parameters

NameTypeDescription
balanceuint256The amount of YFI tokens to deposit and stake. Must be greater than zero to succeed.

Returns

NameTypeDescription
<none>uint256The amount of coveYFI tokens minted to the sender.

deposit

Deposits YFI tokens into the YearnStakingDelegate contract and mints coveYFI tokens to the receiver.

function deposit(uint256 balance, address receiver) external returns (uint256);

Parameters

NameTypeDescription
balanceuint256The amount of YFI tokens to deposit and stake.
receiveraddressThe address to mint the coveYFI tokens to.

Returns

NameTypeDescription
<none>uint256The amount of coveYFI tokens minted to the receiver.

rescue

Allows the owner to rescue tokens mistakenly sent to the contract.

Can only be called by the contract owner. This function is intended for use in case of accidental token transfers into the contract.

function rescue(IERC20 token, address to, uint256 balance) external onlyRole(DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
tokenIERC20The ERC20 token to rescue, or 0x0 for ETH.
toaddressThe recipient address of the rescued tokens.
balanceuint256The amount of tokens to rescue.

yearnStakingDelegate

Returns the address of the YearnStakingDelegate contract.

Provides a way to access the YearnStakingDelegate address used by the contract.

function yearnStakingDelegate() external view returns (address);

Returns

NameTypeDescription
<none>addressThe address of the YearnStakingDelegate contract.

yfi

Returns the address of the YFI token contract.

Provides a way to access the YFI token address used by the contract.

function yfi() external pure returns (address);

Returns

NameTypeDescription
<none>addressThe address of the YFI token contract.

asset

Returns the address of asset required to deposit into this contract, which is YFI.

This is provided for the compatibility with the 4626 Router.

function asset() external pure returns (address);

Returns

NameTypeDescription
<none>addressThe address of the YFI token contract.

_deposit

function _deposit(uint256 balance, address receiver) internal returns (uint256);

DYFIRedeemer

Git Source

Inherits: IDYFIRedeemer, AccessControlEnumerable, ReentrancyGuard, Pausable

This contract can be used to redeem dYFI for YFI for multiple dYFI holders in a single transaction. Any address that holds dYFI can approve this contract to spend their dYFI. Then the caller of massRedeem will provide a list of dYFI holders and their dYFI amounts. By utilizing low-fee flash loans from Balancer, this contract can redeem all dYFI for YFI, and sell the excess YFI for ETH to pay back the flash loan and to reward the caller. The users who approve this contract to spend their dYFI must acknowledge that they will not receive more than the minimum amount of YFI that should be redeemed for their dYFI. The minimum amount of YFI at a given time can be calculated using the minYfiRedeem(uint256 dYfiAmount) function.

State Variables

_REDEMPTION

Address of the redemption contract for dYFI tokens.

address private constant _REDEMPTION = 0x7dC3A74F0684fc026f9163C6D5c3C99fda2cf60a;

_YFI_ETH_PRICE_FEED

Address of the Chainlink YFI/ETH price feed contract.

address private constant _YFI_ETH_PRICE_FEED = 0x3EbEACa272Ce4f60E800f6C5EE678f50D2882fd4;

_FLASH_LOAN_PROVIDER

Address of the Balancer flash loan provider contract.

address private constant _FLASH_LOAN_PROVIDER = 0xBA12222222228d8Ba445958a75a0704d566BF2C8;

_DYFI

Address of the dYFI token contract.

address private constant _DYFI = 0x41252E8691e964f7DE35156B68493bAb6797a275;

_YFI

Address of the YFI token contract.

address private constant _YFI = 0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e;

_WETH

Address of the WETH token contract.

address private constant _WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;

_ETH_YFI_CURVE_POOL

Address of the Curve ETH/YFI liquidity pool contract.

address private constant _ETH_YFI_CURVE_POOL = 0xC26b89A667578ec7b3f11b2F98d6Fd15C07C54ba;

_MAX_SLIPPAGE

Maximum slippage allowed during redemption, represented as a fraction of 1e18.

uint256 private constant _MAX_SLIPPAGE = 0.05e18;

_DEFAULT_SLIPPAGE

Default slippage used during redemption if no specific slippage is set, represented as a fraction of 1e18.

uint256 private constant _DEFAULT_SLIPPAGE = 0.01e18;

_slippage

The slippage that should be applied to the redemption process

uint256 private _slippage;

Functions

constructor

constructor(address admin) payable;

receive

Allows this contract to receive ETH

receive() external payable;

massRedeem

Redeems dYFI for YFI for multiple dYFI holders in a single transaction. Any extra ETH will be sent to the caller.

This function utilizes flash loans from Balancer to acquire ETH needed to redeem dYFI for YFI. The amount of YFI to distribute is calculated as follows: YFI to distribute = dYFI amount - ETH required for redemption * YFI/ETH price * (1 + slippage) The extra YFI is swapped for ETH and sent to the caller as an extra reward.

function massRedeem(
    address[] calldata dYfiHolders,
    uint256[] calldata dYfiAmounts
)
    external
    nonReentrant
    whenNotPaused;

Parameters

NameTypeDescription
dYfiHoldersaddress[]list of addresses that hold dYFI and have approved this contract to spend their dYFI
dYfiAmountsuint256[]list of dYFI amounts that should be redeemed for YFI from the corresponding dYFI holder

receiveFlashLoan

Called by the flash loan provider to execute a flash loan of WETH.

The unchecked block is used here because overflow is not possible as the loop index i is simply incremented in each iteration. The loop is bounded by dYfiHolders.length, ensuring that i will not exceed the length of the array and overflow. Underflow is not a concern as i is initialized to 0 and only incremented.

The unchecked block is used here because overflow is not possible as the loop index i is simply incremented in each iteration. The loop is bounded by dYfiHolders.length, ensuring that i will not exceed the length of the array and overflow. Underflow is not a concern as i is initialized to 0 and only incremented.

function receiveFlashLoan(
    IERC20[] calldata tokens,
    uint256[] calldata amounts,
    uint256[] calldata feeAmounts,
    bytes calldata userData
)
    external;

Parameters

NameTypeDescription
tokensIERC20[]list of token addresses flash loaned.
amountsuint256[]list of amounts flash loaned.
feeAmountsuint256[]list of fee amounts that must be paid back.
userDatabytesadditional data with no specified format.

setSlippage

Sets the slippage that should be applied to DYFI -> YFI redeems.

The slippage is applied to the YFI/ETH price. For example, if the slippage is 0.01e18, then the YFI/ETH price will be multiplied by 1.01.

function setSlippage(uint256 slippage_) external onlyRole(DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
slippage_uint256The new slippage to use for YFI swaps.

kill

Kills the contract. Only the admin can call this function.

function kill() external onlyRole(DEFAULT_ADMIN_ROLE);

minYfiRedeem

Returns the minimum amount of YFI that should be redeemed for a given amount of dYFI

function minYfiRedeem(uint256 dYfiAmount) external view returns (uint256);

Parameters

NameTypeDescription
dYfiAmountuint256The amount of dYFI to redeem

Returns

NameTypeDescription
<none>uint256The minimum amount of YFI that should be redeemed for a given amount of dYFI

currentYfiRedeem

Returns the expected amount of YFI that should be redeemed for a given amount of dYFI

function currentYfiRedeem(uint256 dYfiAmount) external view returns (uint256);

Parameters

NameTypeDescription
dYfiAmountuint256The amount of dYFI to redeem

Returns

NameTypeDescription
<none>uint256The expected amount of YFI that should be redeemed for a given amount of dYFI

expectedMassRedeemReward

Calculates the expected amount of ETH the caller will receive for redeeming dYFI for YFI for the given users and amounts.

This assumes flash loan fee of 0.

function expectedMassRedeemReward(uint256 dYfiAmount) external view returns (uint256);

Parameters

NameTypeDescription
dYfiAmountuint256total dYFI amount that should be redeemed for YFI.

Returns

NameTypeDescription
<none>uint256The expected amount of ETH the caller will receive for redeeming dYFI for YFI.

getLatestPrice

Returns the latest YFI/ETH from the Chainlink price feed.

function getLatestPrice() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The latest ETH per 1 YFI from the Chainlink price feed.

slippage

Get the slippage that should be applied to DYFI -> YFI redeems.

function slippage() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The slippage in 1e18 precision.

_setSlippage

Internal function to set the slippage that should be applied to DYFI -> YFI redeems.

function _setSlippage(uint256 slippage_) internal;

Parameters

NameTypeDescription
slippage_uint256The new slippage to use for YFI swaps.

_getLatestPrice

Returns ETH per 1 YFI in 1e18 precision

function _getLatestPrice() internal view returns (uint256);

_getEthRequired

Returns the minimum ETH required for redemption in 1e18 precision

function _getEthRequired(uint256 dYfiAmount) internal view returns (uint256);

Events

SlippageSet

Emitted when the slippage is set.

event SlippageSet(uint256 slippage);

Parameters

NameTypeDescription
slippageuint256The new slippage value set for the redemption process.

DYfiRedeemed

Emitted when dYFI is redeemed for YFI.

event DYfiRedeemed(address indexed dYfiHolder, uint256 dYfiAmount, uint256 yfiAmount);

Parameters

NameTypeDescription
dYfiHolderaddressThe address of the dYFI holder whose tokens were redeemed.
dYfiAmountuint256The amount of dYFI that was redeemed.
yfiAmountuint256The amount of YFI received from redeeming the dYFI.

CallerReward

Emitted when a reward is given to the caller of the massRedeem function.

event CallerReward(address indexed caller, uint256 amount);

Parameters

NameTypeDescription
calleraddressThe address of the caller who received the reward.
amountuint256The amount of the reward received.

GaugeRewardReceiver

Git Source

Inherits: Clone, Rescuable, ReentrancyGuardUpgradeable, AccessControlEnumerableUpgradeable

Contract to receive rewards from a Yearn gauge and distribute them according to specified splits.

Inherits from Clone and ReentrancyGuardUpgradeable for creating clones acts and preventing reentrancy attacks.

Functions

constructor

Initializes the contract by disabling initializers from the Clone pattern.

constructor() payable;

initialize

Initializes the GaugeRewardReceiver contract.

function initialize(address admin_) external initializer;

Parameters

NameTypeDescription
admin_addressThe address of the owner of the contract.

harvest

Harvest rewards from the gauge and distribute to treasury, compound, and veYFI

function harvest(
    address swapAndLock,
    address treasury,
    address coveYfiRewardForwarder,
    IYearnStakingDelegate.RewardSplit calldata rewardSplit
)
    external
    nonReentrant
    returns (uint256);

Parameters

NameTypeDescription
swapAndLockaddressAddress of the SwapAndLock contract.
treasuryaddressAddress of the treasury to receive a portion of the rewards.
coveYfiRewardForwarderaddressAddress of the CoveYfiRewardForwarder contract.
rewardSplitIYearnStakingDelegate.RewardSplitStruct containing the split percentages for lock, treasury, and user rewards.

Returns

NameTypeDescription
<none>uint256userRewardsAmount The amount of rewards harvested for the user.

rescue

Rescue tokens from the contract. May only be called by the owner. Token cannot be the reward token.

function rescue(IERC20 token, address to, uint256 amount) external onlyRole(DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
tokenIERC20address of the token to rescue.
toaddressaddress to send the rescued tokens to.
amountuint256amount of tokens to rescue.

stakingDelegate

Get the address of the staking delegate from the contract's immutable arguments.

function stakingDelegate() public pure returns (address);

Returns

NameTypeDescription
<none>addressThe address of the staking delegate.

gauge

Get the address of the gauge from the contract's immutable arguments.

function gauge() public pure returns (address);

Returns

NameTypeDescription
<none>addressThe address of the gauge.

rewardToken

Get the address of the reward token from the contract's immutable arguments.

function rewardToken() public pure returns (address);

Returns

NameTypeDescription
<none>addressThe address of the reward token.

stakingDelegateRewards

Get the address of the staking delegate rewards contract from the contract's immutable arguments.

function stakingDelegateRewards() public pure returns (address);

Returns

NameTypeDescription
<none>addressThe address of the staking delegate rewards contract.

MasterRegistry

Git Source

Inherits: IMasterRegistry, AccessControlEnumerable, Multicall

This contract holds list of other registries or contracts and its historical versions.

State Variables

MANAGER_ROLE

Role responsible for adding registries.

bytes32 private constant MANAGER_ROLE = keccak256("MANAGER_ROLE");

_registryMap

mapping(bytes32 => address[]) private _registryMap;

_reverseRegistry

mapping(address => ReverseRegistryData) private _reverseRegistry;

Functions

constructor

constructor(address admin, address manager) payable;

addRegistry

Add a new registry entry to the master list. Reverts if an entry is already found with the given name.

function addRegistry(bytes32 registryName, address registryAddress) external override onlyRole(MANAGER_ROLE);

Parameters

NameTypeDescription
registryNamebytes32name for the registry
registryAddressaddressaddress of the new registry

updateRegistry

Update an existing registry entry to the master list. Reverts if no match is found.

function updateRegistry(bytes32 registryName, address registryAddress) external override onlyRole(MANAGER_ROLE);

Parameters

NameTypeDescription
registryNamebytes32name for the registry
registryAddressaddressaddress of the new registry

resolveNameToLatestAddress

Resolves a name to the latest registry address. Reverts if no match is found.

function resolveNameToLatestAddress(bytes32 registryName) external view override returns (address);

Parameters

NameTypeDescription
registryNamebytes32name for the registry

Returns

NameTypeDescription
<none>addressaddress address of the latest registry with the matching name

resolveNameAndVersionToAddress

Resolves a name and version to an address. Reverts if there is no registry with given name and version.

function resolveNameAndVersionToAddress(
    bytes32 registryName,
    uint256 version
)
    external
    view
    override
    returns (address);

Parameters

NameTypeDescription
registryNamebytes32address of the registry you want to resolve to
versionuint256version of the registry you want to resolve to

resolveNameToAllAddresses

Resolves a name to an array of all addresses. Reverts if no match is found.

function resolveNameToAllAddresses(bytes32 registryName) external view override returns (address[] memory);

Parameters

NameTypeDescription
registryNamebytes32name for the registry

Returns

NameTypeDescription
<none>address[]address address of the latest registry with the matching name

resolveAddressToRegistryData

Resolves an address to registry entry data.

function resolveAddressToRegistryData(address registryAddress)
    external
    view
    override
    returns (bytes32 registryName, uint256 version, bool isLatest);

Parameters

NameTypeDescription
registryAddressaddressaddress of a registry you want to resolve

Returns

NameTypeDescription
registryNamebytes32name of the resolved registry
versionuint256version of the resolved registry
isLatestboolboolean flag of whether the given address is the latest version of the given registries with matching name

Events

AddRegistry

Add a new registry entry to the master list.

event AddRegistry(bytes32 indexed name, address registryAddress, uint256 version);

Parameters

NameTypeDescription
namebytes32address of the added pool
registryAddressaddressaddress of the registry
versionuint256version of the registry

UpdateRegistry

Update a current registry entry to the master list.

event UpdateRegistry(bytes32 indexed name, address registryAddress, uint256 version);

Parameters

NameTypeDescription
namebytes32address of the added pool
registryAddressaddressaddress of the registry
versionuint256version of the registry

Rescuable

Git Source

Allows the inheriting contract to rescue ERC20 tokens that are sent to it by mistake.

Functions

_rescue

Rescue any ERC20 tokens that are stuck in this contract. The inheriting contract that calls this function should specify required access controls

function _rescue(IERC20 token, address to, uint256 balance) internal;

Parameters

NameTypeDescription
tokenIERC20address of the ERC20 token to rescue. Use zero address for ETH
toaddressaddress to send the tokens to
balanceuint256amount of tokens to rescue. Use zero to rescue all

StakingDelegateRewards

Git Source

Inherits: IStakingDelegateRewards, AccessControlEnumerable

Contract for managing staking rewards with functionality to update balances, notify new rewards, and recover tokens.

Inherits from IStakingDelegateRewards and AccessControlEnumerable.

State Variables

_DEFAULT_DURATION

Default duration of rewards period in seconds (7 days).

uint256 private constant _DEFAULT_DURATION = 7 days;

TIMELOCK_ROLE

Role identifier used for protecting functions with timelock access.

bytes32 public constant TIMELOCK_ROLE = keccak256("TIMELOCK_ROLE");

_REWARDS_TOKEN

Address of the token used for rewards, immutable.

address private immutable _REWARDS_TOKEN;

_STAKING_DELEGATE

Address of the staking delegate, immutable.

address private immutable _STAKING_DELEGATE;

periodFinish

Mapping of staking tokens to the period end timestamp.

mapping(address => uint256) public periodFinish;

rewardRate

Mapping of staking tokens to their respective reward rate.

mapping(address => uint256) public rewardRate;

rewardsDuration

Mapping of staking tokens to their rewards duration.

mapping(address => uint256) public rewardsDuration;

lastUpdateTime

Mapping of staking tokens to the last update time for rewards.

mapping(address => uint256) public lastUpdateTime;

rewardPerTokenStored

Mapping of staking tokens to the accumulated reward per token.

mapping(address => uint256) public rewardPerTokenStored;

leftOver

Mapping of staking tokens to the leftover rewards.

mapping(address => uint256) public leftOver;

userRewardPerTokenPaid

Mapping of staking tokens and users to the paid-out reward per token.

mapping(address => mapping(address => uint256)) public userRewardPerTokenPaid;

rewards

Mapping of staking tokens and users to their respective rewards.

mapping(address => mapping(address => uint256)) public rewards;

rewardDistributors

Mapping of staking tokens to their reward distributors.

mapping(address => address) public rewardDistributors;

rewardReceiver

Mapping of users to their designated reward receivers.

mapping(address => address) public rewardReceiver;

Functions

constructor

Constructor that sets the rewards token and staking delegate addresses.

constructor(address rewardsToken_, address stakingDelegate_, address admin, address timeLock) payable;

Parameters

NameTypeDescription
rewardsToken_addressThe ERC20 token to be used as the rewards token.
stakingDelegate_addressThe address of the staking delegate contract.
adminaddress
timeLockaddress

getReward

Claims reward for a given staking token.

function getReward(address stakingToken) external;

Parameters

NameTypeDescription
stakingTokenaddressThe address of the staking token.

getReward

Claims reward for a given user and staking token.

function getReward(address user, address stakingToken) external;

Parameters

NameTypeDescription
useraddressThe address of the user to claim rewards for.
stakingTokenaddressThe address of the staking token.

setRewardReceiver

Sets the reward receiver who will receive your rewards instead.

This can be set to the zero address to receive rewards directly.

function setRewardReceiver(address receiver) external;

Parameters

NameTypeDescription
receiveraddressThe address of the reward receiver.

notifyRewardAmount

Notifies a new reward amount for a given staking token.

function notifyRewardAmount(address stakingToken, uint256 reward) external;

Parameters

NameTypeDescription
stakingTokenaddressThe address of the staking token to notify the reward for.
rewarduint256The amount of the new reward.

updateUserBalance

Updates the balance of a user for a given staking token.

function updateUserBalance(
    address user,
    address stakingToken,
    uint256 currentUserBalance,
    uint256 currentTotalDeposited
)
    external;

Parameters

NameTypeDescription
useraddressThe address of the user to update the balance for.
stakingTokenaddressThe address of the staking token.
currentUserBalanceuint256The current balance of staking token of the user.
currentTotalDepositeduint256The current total deposited amount of the staking token.

addStakingToken

Adds a new staking token to the contract.

function addStakingToken(address stakingToken, address rewardDistributioner) external;

Parameters

NameTypeDescription
stakingTokenaddressThe address of the staking token to add.
rewardDistributioneraddressThe address allowed to notify new rewards for the staking token.

setRewardsDuration

Sets the duration of the rewards period for a given staking token.

function setRewardsDuration(address stakingToken, uint256 rewardsDuration_) external onlyRole(TIMELOCK_ROLE);

Parameters

NameTypeDescription
stakingTokenaddressThe address of the staking token to set the rewards duration for.
rewardsDuration_uint256The new duration of the rewards period.

recoverERC20

Allows recovery of ERC20 tokens other than the staking and rewards tokens.

Added to support recovering LP Rewards from other systems such as BAL to be distributed to holders

function recoverERC20(address tokenAddress, address to, uint256 tokenAmount) external onlyRole(DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
tokenAddressaddressThe address of the token to recover.
toaddressThe address to send the recovered tokens to.
tokenAmountuint256The amount of tokens to recover.

getRewardForDuration

Calculates the total reward for a given duration for a staking token.

function getRewardForDuration(address stakingToken) external view returns (uint256);

Parameters

NameTypeDescription
stakingTokenaddressThe address of the staking token.

Returns

NameTypeDescription
<none>uint256The total reward for the given duration.

rewardToken

Returns the address of the rewards token.

function rewardToken() external view returns (address);

Returns

NameTypeDescription
<none>addressThe address of the rewards token.

stakingDelegate

Returns the address of the staking delegate.

function stakingDelegate() external view returns (address);

Returns

NameTypeDescription
<none>addressThe address of the staking delegate.

lastTimeRewardApplicable

Calculates the last time a reward was applicable for the given staking token.

function lastTimeRewardApplicable(address stakingToken) public view returns (uint256);

Parameters

NameTypeDescription
stakingTokenaddressThe address of the staking token.

Returns

NameTypeDescription
<none>uint256The last applicable timestamp for rewards.

rewardPerToken

Calculates the accumulated reward per token stored.

function rewardPerToken(address stakingToken) external view returns (uint256);

Parameters

NameTypeDescription
stakingTokenaddressThe address of the staking token.

Returns

NameTypeDescription
<none>uint256The accumulated reward per token.

_rewardPerToken

function _rewardPerToken(address stakingToken, uint256 currentTotalDeposited) internal view returns (uint256);

earned

Calculates the amount of reward earned by an account for a given staking token.

function earned(address account, address stakingToken) external view returns (uint256);

Parameters

NameTypeDescription
accountaddressThe address of the user's account.
stakingTokenaddressThe address of the staking token.

Returns

NameTypeDescription
<none>uint256The amount of reward earned.

_earned

function _earned(
    address account,
    address stakingToken,
    uint256 userBalance,
    uint256 rewardPerToken_
)
    internal
    view
    returns (uint256);

_getReward

Updates the reward state for a given user and staking token. If there are any rewards to be paid out, they are sent to the receiver that was set by the user. (Defaults to the user's address if not set)

function _getReward(address user, address stakingToken) internal;

Parameters

NameTypeDescription
useraddressThe address of the user to update rewards for.
stakingTokenaddressThe address of the staking token.

_updateReward

function _updateReward(address account, address stakingToken) internal;

_updateReward

Updates reward state for a given user and staking token.

function _updateReward(
    address account,
    address stakingToken,
    uint256 currentUserBalance,
    uint256 currentTotalDeposited
)
    internal;

Parameters

NameTypeDescription
accountaddressThe address of the user to update rewards for.
stakingTokenaddressThe address of the staking token.
currentUserBalanceuint256
currentTotalDepositeduint256

Events

RewardAdded

Emitted when rewards are added for a staking token.

event RewardAdded(address indexed stakingToken, uint256 rewardAmount, uint256 rewardRate, uint256 start, uint256 end);

Parameters

NameTypeDescription
stakingTokenaddressThe staking token for which rewards are added.
rewardAmountuint256The amount of rewards added.
rewardRateuint256The rate at which rewards will be distributed.
startuint256The start time of the reward period.
enduint256The end time of the reward period.

StakingTokenAdded

Emitted when a staking token is added to the rewards program.

event StakingTokenAdded(address indexed stakingToken, address rewardDistributioner);

Parameters

NameTypeDescription
stakingTokenaddressThe staking token that was added.
rewardDistributioneraddressThe address authorized to distribute rewards for the staking token.

UserBalanceUpdated

Emitted when a user's balance is updated for a staking token.

event UserBalanceUpdated(address indexed user, address indexed stakingToken);

Parameters

NameTypeDescription
useraddressThe user whose balance was updated.
stakingTokenaddressThe staking token for which the balance was updated.

RewardPaid

Emitted when rewards are paid out to a user for a staking token.

event RewardPaid(address indexed user, address indexed stakingToken, uint256 reward, address receiver);

Parameters

NameTypeDescription
useraddressThe user who received the rewards.
stakingTokenaddressThe staking token for which the rewards were paid.
rewarduint256The amount of rewards paid.
receiveraddressThe address that received the rewards.

RewardsDurationUpdated

Emitted when the rewards duration is updated for a staking token.

event RewardsDurationUpdated(address indexed stakingToken, uint256 newDuration);

Parameters

NameTypeDescription
stakingTokenaddressThe staking token for which the duration was updated.
newDurationuint256The new duration for rewards.

Recovered

Emitted when tokens are recovered from the contract.

event Recovered(address token, uint256 amount);

Parameters

NameTypeDescription
tokenaddressThe address of the token that was recovered.
amountuint256The amount of the token that was recovered.

RewardReceiverSet

Emitted when a user sets a reward receiver address.

event RewardReceiverSet(address indexed user, address receiver);

Parameters

NameTypeDescription
useraddressThe user who set the reward receiver.
receiveraddressThe address set as the reward receiver.

SwapAndLock

Git Source

Inherits: ISwapAndLock, AccessControlEnumerable

This contract is designed to swap dYFI tokens to YFI and lock them in the YearnStakingDelegate. It inherits from ISwapAndLock and AccessControlEnumerable to leverage swapping functionality and role-based access control.

State Variables

_YFI

Address of the mainnet Yearn YFI token.

address private constant _YFI = 0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e;

_D_YFI

Address of the mainnet Yearn D_YFI token.

address private constant _D_YFI = 0x41252E8691e964f7DE35156B68493bAb6797a275;

_YEARN_STAKING_DELEGATE

Address of the YearnStakingDelegate contract, set at deployment and immutable thereafter.

address private immutable _YEARN_STAKING_DELEGATE;

_COVE_YFI

Address of the CoveYFI contract, set at deployment and immutable thereafter.

address private immutable _COVE_YFI;

_dYfiRedeemer

Address of the DYfiRedeemer contract.

address private _dYfiRedeemer;

Functions

constructor

Constructs the SwapAndLock contract.

constructor(address yearnStakingDelegate_, address coveYfi_, address admin) payable;

Parameters

NameTypeDescription
yearnStakingDelegate_addressAddress of the YearnStakingDelegate contract.
coveYfi_addressAddress of the CoveYFI contract.
adminaddressAddress of the contract admin for rescuing tokens.

convertToCoveYfi

Converts any YFI held by this contract to CoveYFI, minting CoveYFI to the treasury. YFI will be locked as veYFI under YearnStakingDelegate's ownership.

function convertToCoveYfi() external returns (uint256);

Returns

NameTypeDescription
<none>uint256The amount of coveYFI minted.

setDYfiRedeemer

Sets the address of the DYfiRedeemer contract and approves it to spend dYFI. If the redeemer was already set, the approval is removed from the old redeemer.

function setDYfiRedeemer(address newDYfiRedeemer) external onlyRole(DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
newDYfiRedeemeraddressAddress of the new DYFIRedeemer contract.

dYfiRedeemer

Get the address of the dYFI redeemer contract.

function dYfiRedeemer() external view returns (address);

Returns

NameTypeDescription
<none>addressThe address of the dYFI redeemer contract.

Events

DYfiRedeemerSet

Emitted when the address of the DYfiRedeemer contract is updated.

event DYfiRedeemerSet(address oldRedeemer, address newRedeemer);

Parameters

NameTypeDescription
oldRedeemeraddressThe address of the previous DYfiRedeemer contract.
newRedeemeraddressThe address of the new DYfiRedeemer contract.

Yearn4626RouterExt

Git Source

Inherits: IYearn4626RouterExt, Yearn4626Router

Extends the Yearn4626Router with additional functionality for depositing to Yearn Vault V2 and pulling tokens with Permit2.

This contract introduces two key functions: depositing to Yearn Vault V2 and pulling tokens with a signature via Permit2. The contract holds an immutable reference to a Permit2 contract to facilitate token transfers with permits.

State Variables

_PERMIT2

IPermit2 private immutable _PERMIT2;

Functions

constructor

Constructs the Yearn4626RouterExt contract.

Sets up the router with the name for the vault, WETH address, and Permit2 contract address.

constructor(string memory name_, address weth_, address permit2_) payable Yearn4626Router(name_, IWETH9(weth_));

Parameters

NameTypeDescription
name_stringThe name of the vault.
weth_addressThe address of the WETH contract.
permit2_addressThe address of the Permit2 contract.

serializedDeposits

Deposits the specified amount of assets into series of ERC4626 vaults or Yearn Vault V2.

function serializedDeposits(
    address[] calldata path,
    uint256 assetsIn,
    address to,
    uint256 minSharesOut
)
    external
    payable
    returns (uint256 sharesOut);

Parameters

NameTypeDescription
pathaddress[]The array of addresses that represents the vaults to deposit into.
assetsInuint256The amount of assets to deposit into the first vault.
toaddressThe address to which the shares will be transferred.
minSharesOutuint256The minimum amount of shares expected to be received.

Returns

NameTypeDescription
sharesOutuint256The actual amount of shares received by the to address.

serializedRedeems

Redeems the specified shares from a series of ERC4626 vaults or Yearn Vault V2.

function serializedRedeems(
    address[] calldata path,
    bool[] calldata isYearnVaultV2,
    uint256 sharesIn,
    address to,
    uint256 minAssetsOut
)
    external
    payable
    returns (uint256 assetsOut);

Parameters

NameTypeDescription
pathaddress[]The array of addresses that represents the vaults to redeem from.
isYearnVaultV2bool[]The array of boolean values that represent whether the vault is a Yearn Vault V2.
sharesInuint256The amount of shares to redeem from the first vault.
toaddressThe address to which the assets will be transferred.
minAssetsOutuint256The minimum amount of assets expected to be received.

Returns

NameTypeDescription
assetsOutuint256The actual amount of assets received by the to address.

redeemVaultV2

Redeems the specified shares from the Yearn Vault V2.

The shares must exist in this router before calling this function.

function redeemVaultV2(
    IYearnVaultV2 vault,
    uint256 shares,
    address to,
    uint256 minAssetsOut
)
    public
    payable
    returns (uint256 amountOut);

Parameters

NameTypeDescription
vaultIYearnVaultV2The Yearn Vault V2 contract instance.
sharesuint256The amount of shares to redeem.
toaddressThe address to which the assets will be transferred.
minAssetsOutuint256The minimum amount of assets expected to be received.

Returns

NameTypeDescription
amountOutuint256The actual amount of assets received by the to address.

redeemFromRouter

Redeems the specified IERC4626 vault shares that this router is holding.

function redeemFromRouter(
    IERC4626 vault,
    uint256 shares,
    address to,
    uint256 minAmountOut
)
    public
    payable
    virtual
    returns (uint256 amountOut);

Parameters

NameTypeDescription
vaultIERC4626The IERC4626 vault contract instance.
sharesuint256The amount of shares to redeem.
toaddressThe address to which the assets will be transferred.
minAmountOutuint256The minimum amount of assets expected to be received.

Returns

NameTypeDescription
amountOutuint256The actual amount of assets received by the to address.

withdrawFromRouter

Withdraws the specified assets from the IERC4626 vault.

function withdrawFromRouter(
    IERC4626 vault,
    uint256 assets,
    address to,
    uint256 maxSharesIn
)
    public
    payable
    virtual
    returns (uint256 sharesOut);

Parameters

NameTypeDescription
vaultIERC4626The IERC4626 vault contract instance.
assetsuint256The amount of assets to withdraw.
toaddressThe address to which the assets will be transferred.
maxSharesInuint256The maximum amount of vault shares expected to be burned.

Returns

NameTypeDescription
sharesOutuint256The actual amount of shares burned from the vault.

redeemStakeDaoGauge

Redeems the specified shares of the StakeDAO Gauge.

Assumes the assets withdrawn will be the the yearn vault tokens and will always be the same amount as the shares of the burned StakeDAO gauge tokens.

function redeemStakeDaoGauge(IStakeDaoGauge gauge, uint256 shares, address to) public payable returns (uint256);

Parameters

NameTypeDescription
gaugeIStakeDaoGaugeThe StakeDAO Gauge contract instance.
sharesuint256The amount of StakeDAO gauge tokens to burn.
toaddress

pullTokenWithPermit2

Pulls tokens to the contract using a signature via Permit2.

Verifies that the to address in transferDetails is the contract itself and then calls permitTransferFrom on the Permit2 contract. Reverts with InvalidTo if the to address is not the contract itself.

function pullTokenWithPermit2(
    ISignatureTransfer.PermitTransferFrom calldata permit,
    ISignatureTransfer.SignatureTransferDetails calldata transferDetails,
    bytes calldata signature
)
    public
    payable;

Parameters

NameTypeDescription
permitISignatureTransfer.PermitTransferFromThe PermitTransferFrom struct containing the permit details.
transferDetailsISignatureTransfer.SignatureTransferDetailsThe details of the transfer, including the to address.
signaturebytesThe signature to authorize the token transfer.

previewDeposits

Calculate the amount of shares to be received from a series of deposits to ERC4626 vaults or Yearn Vault V2.

function previewDeposits(
    address[] calldata path,
    uint256 assetsIn
)
    external
    view
    returns (uint256[] memory sharesOut);

Parameters

NameTypeDescription
pathaddress[]The array of addresses that represents the path from input token to output token
assetsInuint256The amount of assets to deposit into the first vault.

Returns

NameTypeDescription
sharesOutuint256[]The amount of shares to be received from each deposit. The length of the array is path.length - 1.

previewMints

Calculate the amount of assets required to mint a given amount of shares from a series of deposits to ERC4626 vaults or Yearn Vault V2.

Increment the loop index i without checking for overflow. This is safe because the loop's termination condition ensures that i will not exceed the bounds of the sharesOut array, which would be the only case where an overflow could occur.

sharesOut is the expected result at the last vault, and the path = [tokenIn, vault0, vault1, ..., vaultN]. First calculate the amount of assets in to get the desired sharesOut from the last vault, then using that amount as the next sharesOut to get the amount of assets in for the penultimate vault.

function previewMints(address[] calldata path, uint256 sharesOut) external view returns (uint256[] memory assetsIn);

Parameters

NameTypeDescription
pathaddress[]The array of addresses that represents the path from input to output.
sharesOutuint256The amount of shares to mint from the last vault.

Returns

NameTypeDescription
assetsInuint256[]The amount of assets required at each step. The length of the array is path.length - 1.

previewWithdraws

Calculate the amount of shares required to withdraw a given amount of assets from a series of withdraws from ERC4626 vaults or Yearn Vault V2.

Decrement the loop counter within an unchecked block to avoid redundant gas cost associated with underflow checking. This is safe because the loop's initialization and exit condition ensure that i will not underflow.

assetsOut is the desired result of the output token, and the path = [vault0, vault1, ..., vaultN, tokenOut]. First calculate the amount of shares in to get the desired assetsOut from the last vault, then using that amount as the next assetsOut to get the amount of shares in for the penultimate vault.

function previewWithdraws(
    address[] calldata path,
    uint256 assetsOut
)
    external
    view
    returns (uint256[] memory sharesIn);

Parameters

NameTypeDescription
pathaddress[]The array of addresses that represents the path from input to output.
assetsOutuint256The amount of assets to withdraw from the last vault.

Returns

NameTypeDescription
sharesInuint256[]The amount of shares required at each step. The length of the array is path.length - 1.

previewRedeems

Calculate the amount of assets to be received from a series of withdraws from ERC4626 vaults or Yearn Vault V2.

Decrement the loop counter without checking for overflow. This is safe because the for loop naturally ensures that i will not underflow as it is bounded by i == 0 check.

function previewRedeems(address[] calldata path, uint256 sharesIn) external view returns (uint256[] memory assetsOut);

Parameters

NameTypeDescription
pathaddress[]The array of addresses that represents the path from input to output.
sharesInuint256The amount of shares to withdraw from the first vault.

Returns

NameTypeDescription
assetsOutuint256[]The amount of assets to be received at each step. The length of the array is path.length - 1.

Errors

InsufficientShares

Error for when the number of shares received is less than the minimum expected.

error InsufficientShares();

InsufficientAssets

Error for when the amount of assets received is less than the minimum expected.

error InsufficientAssets();

RequiresMoreThanMaxShares

Error for when the amount of shares burned is more than the maximum expected.

error RequiresMoreThanMaxShares();

InvalidPermit2TransferTo

Error for when the to address in the Permit2 transfer is not the router contract.

error InvalidPermit2TransferTo();

InvalidPermit2TransferAmount

Error for when the amount in the Permit2 transfer is not the same as the requested amount.

error InvalidPermit2TransferAmount();

InvalidPathLength

Error for when the serialized deposit path is too short.

error InvalidPathLength();

PreviewPathIsTooShort

Error for when the path is too short to preview the deposits/mints/withdraws/redeems.

error PreviewPathIsTooShort();

PreviewNonVaultAddressInPath

Error for when the address in the path is not a vault.

error PreviewNonVaultAddressInPath(address invalidVault);

PreviewVaultMismatch

Error for when an address in the path does not match previous or next vault's asset.

error PreviewVaultMismatch();

YearnStakingDelegate

Git Source

Inherits: IYearnStakingDelegate, AccessControlEnumerable, ReentrancyGuard, Rescuable, Pausable

Contract for staking yearn gauge tokens, managing rewards, and delegating voting power.

Inherits from IYearnStakingDelegate, AccessControlEnumerable, ReentrancyGuard, Rescuable, and Pausable.

State Variables

PAUSER_ROLE

Role identifier for pausers, capable of pausing contract functions.

bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");

TIMELOCK_ROLE

Role identifier for timelock, capable of performing time-sensitive administrative functions.

bytes32 public constant TIMELOCK_ROLE = keccak256("TIMELOCK_ROLE");

DEPOSITOR_ROLE

Role identifier for depositors, capable of depositing gauge tokens.

bytes32 public constant DEPOSITOR_ROLE = keccak256("DEPOSITOR_ROLE");

_YFI_REWARD_POOL

Address of the Yearn Finance YFI reward pool.

address private constant _YFI_REWARD_POOL = 0xb287a1964AEE422911c7b8409f5E5A273c1412fA;

_DYFI_REWARD_POOL

Address of the Yearn Finance D_YFI reward pool.

address private constant _DYFI_REWARD_POOL = 0x2391Fc8f5E417526338F5aa3968b1851C16D894E;

_YFI

Address of the Yearn Finance YFI token.

address private constant _YFI = 0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e;

_D_YFI

Address of the Yearn Finance D_YFI token.

address private constant _D_YFI = 0x41252E8691e964f7DE35156B68493bAb6797a275;

_VE_YFI

Address of the Yearn Finance veYFI token.

address private constant _VE_YFI = 0x90c1f9220d90d3966FbeE24045EDd73E1d588aD5;

_SNAPSHOT_DELEGATE_REGISTRY

Address of the Snapshot delegate registry.

address private constant _SNAPSHOT_DELEGATE_REGISTRY = 0x469788fE6E9E9681C6ebF3bF78e7Fd26Fc015446;

_MAX_TREASURY_PCT

Maximum percentage of the treasury in basis points.

uint256 private constant _MAX_TREASURY_PCT = 0.2e18;

_GAUGE_REWARD_RECEIVER_IMPL

Address of the GaugeRewardReceiver implementation, set at contract deployment and immutable thereafter.

address private immutable _GAUGE_REWARD_RECEIVER_IMPL;

gaugeStakingRewards

Mapping of gauge addresses to their corresponding staking rewards contract addresses.

mapping(address => address) public gaugeStakingRewards;

gaugeRewardReceivers

Mapping of gauge addresses to their corresponding GaugeRewardReceiver contract addresses.

mapping(address => address) public gaugeRewardReceivers;

balanceOf

Mapping of user addresses to a nested mapping of token addresses to the user's balance of that token.

mapping(address => mapping(address => uint256)) public balanceOf;

totalDeposited

Mapping of gauge token address to the total amount deposited in this contract.

mapping(address => uint256) public totalDeposited;

depositLimit

Mapping of gauge token addresses to their corresponding deposit limits. Note that this is the ideal limit, which should be enforced by the depositing contracts

mapping(address => uint256) public depositLimit;

blockedTargets

Mapping of target addresses to a boolean indicating whether the target is blocked.

mapping(address => bool) public blockedTargets;

_gaugeRewardSplit

Mapping of vault addresses to their corresponding RewardSplit configuration.

mapping(address => RewardSplit) private _gaugeRewardSplit;

_treasury

Address of the treasury where funds are managed.

address private _treasury;

_shouldPerpetuallyLock

Flag indicating whether to lock rewards perpetually.

bool private _shouldPerpetuallyLock;

_swapAndLock

Address of the contract that swaps and locks tokens.

address private _swapAndLock;

_coveYfiRewardForwarder

Address of the contract that forwards YFI rewards to CoveYFI.

address private _coveYfiRewardForwarder;

_boostRewardSplit

Configuration for how rewards are split in the boost phase.

BoostRewardSplit private _boostRewardSplit;

_exitRewardSplit

Configuration for how rewards are split upon exit.

ExitRewardSplit private _exitRewardSplit;

Functions

constructor

Initializes the contract by setting up roles and initializing state variables.

constructor(
    address gaugeRewardReceiverImpl,
    address treasury_,
    address admin,
    address pauser,
    address timelock
)
    payable;

Parameters

NameTypeDescription
gaugeRewardReceiverImpladdressAddress of the GaugeRewardReceiver implementation.
treasury_addressAddress of the treasury.
adminaddressAddress of the admin.
pauseraddressAddress of the pauser.
timelockaddressAddress of the timelock.

deposit

Deposits a specified amount of gauge tokens into this staking delegate.

Deposits can be paused in case of emergencies by the admin or pauser roles.

function deposit(address gauge, uint256 amount) external onlyRole(DEPOSITOR_ROLE) whenNotPaused;

Parameters

NameTypeDescription
gaugeaddressThe address of the gauge token to deposit.
amountuint256The amount of tokens to deposit.

withdraw

Withdraws a specified amount of gauge tokens from this staking delegate.

function withdraw(address gauge, uint256 amount, address receiver) external;

Parameters

NameTypeDescription
gaugeaddressThe address of the gauge token to withdraw.
amountuint256The amount of tokens to withdraw.
receiveraddress

withdraw

Withdraws a specified amount of gauge tokens from this staking delegate.

function withdraw(address gauge, uint256 amount) external;

Parameters

NameTypeDescription
gaugeaddressThe address of the gauge token to withdraw.
amountuint256The amount of tokens to withdraw.

_withdraw

function _withdraw(address gauge, uint256 amount, address receiver) internal;

harvest

Harvests rewards from a gauge and distributes them.

function harvest(address gauge) external returns (uint256);

Parameters

NameTypeDescription
gaugeaddressAddress of the gauge to harvest from.

Returns

NameTypeDescription
<none>uint256The amount of rewards harvested.

claimBoostRewards

Claim dYFI rewards from the reward pool and transfer them to the CoveYFI Reward Forwarder

function claimBoostRewards() external;

claimExitRewards

Claim YFI rewards from the reward pool and transfer them to the CoveYFI Reward Forwarder

function claimExitRewards() external;

lockYfi

Locks YFI tokens in the veYFI contract.

Locking YFI can be paused in case of emergencies by the admin or pauser roles.

function lockYfi(uint256 amount) external whenNotPaused returns (IVotingYFI.LockedBalance memory);

Parameters

NameTypeDescription
amountuint256Amount of YFI tokens to lock.

Returns

NameTypeDescription
<none>IVotingYFI.LockedBalanceThe locked balance information.

setCoveYfiRewardForwarder

Sets the address for the CoveYFI Reward Forwarder.

Can only be called by an address with the TIMELOCK_ROLE. Emits CoveYfiRewardForwarderSet event.

function setCoveYfiRewardForwarder(address forwarder) external onlyRole(TIMELOCK_ROLE);

Parameters

NameTypeDescription
forwarderaddressThe address of the new CoveYFI Reward Forwarder.

setTreasury

Set treasury address. This address will receive a portion of the rewards

function setTreasury(address treasury_) external onlyRole(TIMELOCK_ROLE);

Parameters

NameTypeDescription
treasury_addressaddress to receive rewards

setSwapAndLock

Sets the address for the SwapAndLock contract.

function setSwapAndLock(address newSwapAndLock) external onlyRole(TIMELOCK_ROLE);

Parameters

NameTypeDescription
newSwapAndLockaddressAddress of the SwapAndLock contract.

setGaugeRewardSplit

Set the reward split percentages

Sum of percentages must equal to 1e18

function setGaugeRewardSplit(
    address gauge,
    uint64 treasuryPct,
    uint64 coveYfiPct,
    uint64 userPct,
    uint64 veYfiPct
)
    external
    onlyRole(TIMELOCK_ROLE);

Parameters

NameTypeDescription
gaugeaddressaddress of the gauge token
treasuryPctuint64percentage of rewards to treasury
coveYfiPctuint64percentage of rewards to coveYFI Reward Forwarder
userPctuint64percentage of rewards to user
veYfiPctuint64percentage of rewards to veYFI

setBoostRewardSplit

Set the reward split percentages for dYFI boost rewards

Sum of percentages must equal to 1e18

function setBoostRewardSplit(uint128 treasuryPct, uint128 coveYfiPct) external onlyRole(TIMELOCK_ROLE);

Parameters

NameTypeDescription
treasuryPctuint128percentage of rewards to treasury
coveYfiPctuint128percentage of rewards to CoveYFI Reward Forwarder

setExitRewardSplit

Set the reward split percentages for YFI exit rewards

Sum of percentages must equal to 1e18

function setExitRewardSplit(uint128 treasuryPct, uint128 coveYfiPct) external onlyRole(TIMELOCK_ROLE);

Parameters

NameTypeDescription
treasuryPctuint128percentage of rewards to treasury
coveYfiPctuint128percentage of rewards to CoveYFI Reward Forwarder

setDepositLimit

Set the deposit limit for a gauge token. This is the ideal limit, which should be enforced by the depositing contracts.

function setDepositLimit(address gaugeToken, uint256 limit) external onlyRole(TIMELOCK_ROLE);

Parameters

NameTypeDescription
gaugeTokenaddressaddress of the gauge token
limituint256maximum amount of tokens that can be deposited

setSnapshotDelegate

Delegates voting power to a given address

function setSnapshotDelegate(bytes32 id, address delegate) external onlyRole(TIMELOCK_ROLE);

Parameters

NameTypeDescription
idbytes32name of the space in snapshot to apply delegation. For yearn it is "veyfi.eth"
delegateaddressaddress to delegate voting power to

addGaugeRewards

Adds gauge rewards configuration.

function addGaugeRewards(
    address gauge,
    address stakingDelegateRewards
)
    external
    nonReentrant
    onlyRole(DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
gaugeaddressAddress of the gauge.
stakingDelegateRewardsaddressAddress of the StakingDelegateRewards contract.

updateGaugeRewards

Updates gauge rewards configuration.

function updateGaugeRewards(
    address gauge,
    address stakingDelegateRewards
)
    external
    nonReentrant
    onlyRole(TIMELOCK_ROLE);

Parameters

NameTypeDescription
gaugeaddressAddress of the gauge.
stakingDelegateRewardsaddressAddress of the new StakingDelegateRewards contract.

setPerpetualLock

Set perpetual lock status

function setPerpetualLock(bool lock) external onlyRole(TIMELOCK_ROLE);

Parameters

NameTypeDescription
lockboolif true, lock YFI for 4 years after each harvest

earlyUnlock

early unlock veYFI and send YFI to treasury

function earlyUnlock() external onlyRole(TIMELOCK_ROLE);

pause

Pauses the contract. Only callable by PAUSER_ROLE or DEFAULT_ADMIN_ROLE.

function pause() external;

unpause

Unpauses the contract. Only callable by DEFAULT_ADMIN_ROLE.

function unpause() external onlyRole(DEFAULT_ADMIN_ROLE);

execute

Execute arbitrary calls from the staking delegate. This function is callable by the admin role for future proofing. Target must not be YFI, dYFI, veYFI, or a known gauge token.

function execute(
    address target,
    bytes calldata data,
    uint256 value
)
    external
    payable
    onlyRole(TIMELOCK_ROLE)
    returns (bytes memory);

Parameters

NameTypeDescription
targetaddresscontract to call
databytescalldata to execute the call with
valueuint256call value

Returns

NameTypeDescription
<none>bytesresult of the call

availableDepositLimit

Get the available deposit limit for a gauge token

function availableDepositLimit(address gaugeToken) external view returns (uint256);

Parameters

NameTypeDescription
gaugeTokenaddressThe address of the gauge token

Returns

NameTypeDescription
<none>uint256Available deposit limit

getBoostRewardSplit

Get the dYFI boost reward split

function getBoostRewardSplit() external view returns (BoostRewardSplit memory);

Returns

NameTypeDescription
<none>BoostRewardSplitBoostRewardSplit struct containing the treasury and coveYFI split.

getExitRewardSplit

Get the YFI exit reward split

function getExitRewardSplit() external view returns (ExitRewardSplit memory);

Returns

NameTypeDescription
<none>ExitRewardSplitExitRewardSplit struct containing the treasury and coveYFI split.

getGaugeRewardSplit

Get the dYFI reward split for a gauge

function getGaugeRewardSplit(address gauge) external view returns (RewardSplit memory);

Parameters

NameTypeDescription
gaugeaddressAddress of the gauge

Returns

NameTypeDescription
<none>RewardSplitRewardSplit struct containing the treasury, coveYFI, user, and lock splits for the gauge

treasury

Get the address of the treasury

function treasury() external view returns (address);

Returns

NameTypeDescription
<none>addressThe address of the treasury

coveYfiRewardForwarder

Get the address of the stored CoveYFI Reward Forwarder

function coveYfiRewardForwarder() external view returns (address);

Returns

NameTypeDescription
<none>addressThe address of the CoveYFI Reward Forwarder

swapAndLock

Get the address of the SwapAndLock contract

function swapAndLock() external view returns (address);

Returns

NameTypeDescription
<none>addressThe address of the SwapAndLock contract

shouldPerpetuallyLock

Get the perpetual lock status

function shouldPerpetuallyLock() external view returns (bool);

Returns

NameTypeDescription
<none>boolTrue if perpetual lock is enabled

yfi

Get the address of the YFI token

function yfi() external pure returns (address);

Returns

NameTypeDescription
<none>addressThe address of the YFI token

dYfi

Get the address of the dYFI token

function dYfi() external pure returns (address);

Returns

NameTypeDescription
<none>addressThe address of the dYFI token

veYfi

Get the address of the veYFI token

function veYfi() external pure returns (address);

Returns

NameTypeDescription
<none>addressThe address of the veYFI token

_setTreasury

Internal function to set the treasury address.

function _setTreasury(address treasury_) internal;

Parameters

NameTypeDescription
treasury_addressThe address of the new treasury.

_setCoveYfiRewardForwarder

Internal function to set the CoveYFI Reward Forwarder address.

function _setCoveYfiRewardForwarder(address forwarder) internal;

Parameters

NameTypeDescription
forwarderaddressThe address of the CoveYFI Reward Forwarder.

_setGaugeRewards

Internal function to set gauge rewards and reward receiver.

function _setGaugeRewards(address gauge, address stakingDelegateRewards) internal;

Parameters

NameTypeDescription
gaugeaddressAddress of the gauge.
stakingDelegateRewardsaddressAddress of the StakingDelegateRewards contract.

_setPerpetualLock

Internal function to set the perpetual lock status.

function _setPerpetualLock(bool lock) internal;

Parameters

NameTypeDescription
lockboolTrue for max lock.

_setGaugeRewardSplit

Internal function to set the reward split for a gauge.

function _setGaugeRewardSplit(
    address gauge,
    uint64 treasuryPct,
    uint64 coveYfiPct,
    uint64 userPct,
    uint64 lockPct
)
    internal;

Parameters

NameTypeDescription
gaugeaddressAddress of the gauge.
treasuryPctuint64Percentage of rewards to the treasury.
coveYfiPctuint64
userPctuint64Percentage of rewards to the user.
lockPctuint64Percentage of rewards to lock in veYFI.

_setBoostRewardSplit

Internal function to set the reward split for the dYFI boost rewards

function _setBoostRewardSplit(uint128 treasuryPct, uint128 coveYfiPct) internal;

Parameters

NameTypeDescription
treasuryPctuint128Percentage of rewards to the treasury.
coveYfiPctuint128Percentage of rewards to the CoveYFI Reward Forwarder.

_setExitRewardSplit

Internal function to set the reward split for the YFI exit rewards (when veYFI holders early unlock their YFI, a portion of their YFI is distributed to other veYFI holders).

function _setExitRewardSplit(uint128 treasuryPct, uint128 coveYfiPct) internal;

Parameters

NameTypeDescription
treasuryPctuint128Percentage of rewards to the treasury.
coveYfiPctuint128Percentage of rewards to the CoveYFI Reward Forwarder.

_checkpointUserBalance

Internal function to checkpoint a user's balance for a gauge.

function _checkpointUserBalance(
    address stakingDelegateReward,
    address gauge,
    address user,
    uint256 userBalance,
    uint256 currentTotalDeposited
)
    internal;

Parameters

NameTypeDescription
stakingDelegateRewardaddressAddress of the StakingDelegateRewards contract.
gaugeaddressAddress of the gauge.
useraddressAddress of the user.
userBalanceuint256New balance of the user for the gauge.
currentTotalDepositeduint256

Events

LockYfi

Emitted when YFI tokens are locked.

event LockYfi(address indexed sender, uint256 amount);

Parameters

NameTypeDescription
senderaddressThe address of the sender who locked YFI tokens.
amountuint256The amount of YFI tokens locked.

GaugeRewardsSet

Emitted when gauge rewards are set.

event GaugeRewardsSet(address indexed gauge, address stakingRewardsContract, address receiver);

Parameters

NameTypeDescription
gaugeaddressThe address of the gauge for which rewards are set.
stakingRewardsContractaddressThe address of the staking rewards contract.
receiveraddressThe address of the rewards receiver.

PerpetualLockSet

Emitted when the perpetual lock setting is updated.

event PerpetualLockSet(bool shouldLock);

Parameters

NameTypeDescription
shouldLockboolThe status of the perpetual lock setting.

GaugeRewardSplitSet

Emitted when the reward split configuration for a gauge is set.

event GaugeRewardSplitSet(address indexed gauge, RewardSplit split);

Parameters

NameTypeDescription
gaugeaddressThe address of the gauge for which the reward split is set.
splitRewardSplitThe reward split configuration.

BoostRewardSplitSet

Emitted when the boost reward split configuration is set.

event BoostRewardSplitSet(uint128 treasuryPct, uint128 coveYfiPct);

Parameters

NameTypeDescription
treasuryPctuint128The percentage of the boost reward allocated to the treasury.
coveYfiPctuint128The percentage of the boost reward allocated to CoveYFI.

ExitRewardSplitSet

Emitted when the exit reward split configuration is set.

event ExitRewardSplitSet(uint128 treasuryPct, uint128 coveYfiPct);

Parameters

NameTypeDescription
treasuryPctuint128The percentage of the exit reward allocated to the treasury.
coveYfiPctuint128The percentage of the exit reward allocated to CoveYFI.

DepositLimitSet

Emitted when a deposit limit is set.

event DepositLimitSet(address indexed gaugeToken, uint256 limit);

Parameters

NameTypeDescription
gaugeTokenaddressThe address of the gauge token for which the deposit limit is set.
limituint256The deposit limit.

SwapAndLockSet

Emitted when the swap and lock contract address is set.

event SwapAndLockSet(address swapAndLockContract);

Parameters

NameTypeDescription
swapAndLockContractaddressThe address of the swap and lock contract.

TreasurySet

Emitted when the treasury address is updated.

event TreasurySet(address newTreasury);

Parameters

NameTypeDescription
newTreasuryaddressThe new address of the treasury.

CoveYfiRewardForwarderSet

Emitted when the CoveYFI reward forwarder address is set.

event CoveYfiRewardForwarderSet(address forwarder);

Parameters

NameTypeDescription
forwarderaddressThe address of the CoveYFI reward forwarder.

Deposit

Emitted when a gauge token is deposited

event Deposit(address indexed sender, address indexed gauge, uint256 amount, uint256 newTotalDeposited);

Parameters

NameTypeDescription
senderaddressThe address of the sender who made the deposit.
gaugeaddressThe address of the gauge token deposited.
amountuint256The amount of tokens deposited.
newTotalDepositeduint256The new total amount of the gauge tokens deposited across all users.

Withdraw

Emitted when a gauge token is withdrawn

event Withdraw(address indexed sender, address indexed gauge, uint256 amount, uint256 newTotalDeposited);

Parameters

NameTypeDescription
senderaddressThe address of the sender who made the withdrawal.
gaugeaddressThe address of the gauge token withdrawn.
amountuint256The amount of tokens withdrawn.
newTotalDepositeduint256The new total amount of the gauge tokens deposited across all users.

StakingDelegateRewardsFaulty

Emitted when the checkpointing of a user's balance fails

event StakingDelegateRewardsFaulty(
    address stakingDelegateRewards,
    address user,
    address gauge,
    uint256 currentUserBalance,
    uint256 currentTotalDeposited
);

Parameters

NameTypeDescription
stakingDelegateRewardsaddressThe address of the StakingDelegateRewards contract.
useraddressThe address of the user whose balance failed to checkpoint.
gaugeaddressThe address of the gauge token.
currentUserBalanceuint256The current balance of gauge tokens deposited by the user.
currentTotalDepositeduint256The current total amount of the gauge tokens deposited across all users.