Sidechain Contracts
Last updated
Last updated
Aura Finance is expanding to become a cross-chain protocol. Deploying to chains beyond Ethereum, with the intent to deploy to wherever the balancer is deployed and emitting rewards. As part of this expansion, a new set of contracts had been deployed.
AuraBalProxyOFT.sol : L1 Aura BAL proxy OFT
AuraBalOFT.sol : L2 Aura BAL OFT
AuraProxyOFT.sol : L1 Aura proxy OFT
AuraOFT.sol : L2 Aura OFT
Create2Factory.sol : A create2 factory to deploy the sidechain contracts to constant addresses
CrossChainConfig.sol : Abstract contract to handle setting LZ configs
CrossChainMessages.sol : Shared LZ messaging library
L1Coordinator.sol : L1 Coordinator handles sending messages to canonical chain
L2Coordinator.sol : L2 Coordinator handles sending messages to canonical chain
PausableOFT.sol : OFT extension that allows a guardian
address to perform an emergency pause
PausableProxyOFT.sol : Proxy OFT extension that allows a guardian
address to perform an emergency pause
PauseGuardian.sol : Allows to implement pauses triggered by a guardian
address
L1PoolManagerProxy.sol : Allows to permissionless add pools on any supported sidechain
L2PoolManagerProxy.sol : Given a root gauge on L1PoolManagerProxy it adds a gauge recipient on PoolManagerLite
Sidechain auraBAL
constructor(string _name, string _symbol) public
Constructs the AuraBalOFT contract.
Parameters
_name
string
The oft token name
_symbol
string
The oft token symbol
function initialize(address _lzEndpoint, address _guardian) external
Initialize the contract.
Parameters
_lzEndpoint
address
LayerZero endpoint contract
_guardian
address
Pause guardian
Send and receive auraBAL to and from all the sidechains. all auraBAL sat in this bridge will be staked in the auraBAL compounder and rewards distributed to the L2 staking contracts
struct HarvestToken {
address token;
uint256 rewards;
}
address vault
auraBAL compounder vault contract address
uint256 internalTotalSupply
Internally tracking of total auraBAL supply bridged
uint16[] harvestSrcChainIds
Harvest src chain IDs array
mapping(address => uint256) totalClaimable
token address mapped to amount
mapping(address => mapping(uint16 => uint256)) claimable
token address mapped srcChainId mapped to amount claimable
mapping(uint16 => address) rewardReceiver
srcChainId mapped to reward receiver
mapping(address => bool) authorizedHarvesters
Authorized harvesters
mapping(address => address) ofts
Token to OFT
event Harvest(address caller, uint256 totalUnderlyingSum)
Emitted when harvest rewards.
Parameters
caller
address
The caller
totalUnderlyingSum
uint256
The total amount of auraBal staked on all sidechains.
constructor(address _lzEndpoint, address _token, address _vault, address _guardian, address _sudo, uint256 _inflowLimit) public
Constructs the AuraBalProxyOFT contract
Parameters
_lzEndpoint
address
LayerZero endpoint contract
_token
address
The proxied token (auraBAL)
_vault
address
The AuraBal compounder vault
_guardian
address
The pause guardian address
_sudo
address
The super user address
_inflowLimit
uint256
Initial inflow limit per epoch
function setAdapterParams(uint16 _srcChainId, bytes32 _selector, bytes _adapterParams) external
Sets the configuration for a given source chain ID and selector.
Parameters
_srcChainId
uint16
The source chain ID.
_selector
bytes32
The selector.
_adapterParams
bytes
The adapter params.
function setRewardReceiver(uint16 _srcChainId, address _receiver) external
Set reward receiver for src chain
Parameters
_srcChainId
uint16
The source chain ID
_receiver
address
The receiver address
function updateAuthorizedHarvesters(address _harvester, bool _authorized) external
Adds or remove an address from the harvesters' whitelist
Parameters
_harvester
address
address of the authorized harvester
_authorized
bool
Whether to add or remove harvester
function setOFT(address _token, address _oft) external
Set OFT for token
Parameters
_token
address
Token contract address
_oft
address
OFT contract address
function setHarvestSrcChainIds(uint16[] _srcChainIds) external
Set srcChainIds to loop through for harvest
Parameters
_srcChainIds
uint16[]
Source chain IDs
function circulatingSupply() public view returns (uint256)
returns the circulating amount of tokens on current chain
function harvest(uint256[] _totalUnderlying, uint256 _totalUnderlyingSum) external
_Harvest rewards from the compounder and distribute them to the source chains
Collect the amount of auraBAL that is staked on each source chain (L2). Then
trigger a harvest on the vault which calculates the amount of auraBAL that has
been earned since the last claim and the amount of extra rewards. These rewards
are then lazily distributed to the src chains proportionally.
Lazily meaning the claimable values are just added to a claimable mapping for
processing latest via processClaimable_
Parameters
_totalUnderlying
uint256[]
Array of totalUnderlying auraBAL staked on the source chain
_totalUnderlyingSum
uint256
Sum of values in _totalUnderlying array
function processClaimable(address _token, uint16 _srcChainId, address _zroPaymentAddress) external payable
Process claimable rewards
Parameters
_token
address
The token to process
_srcChainId
uint16
The source chain ID
_zroPaymentAddress
address
The LayerZero ZRO payment address
function vaultExecute(uint256 _value, bytes _data) external returns (bool, bytes)
Execute a function on the vault
In order to account for the withdrawalPenalty this contract needs To be the owner of the auraBAL vault. Therefore it needs to be able to call vault owner functions. Rather than wrapping each function we can just use an execute pointing at the vault
function rescue(address _token, address _to, uint256 _amount) external
Rescues the specified amount of tokens from the bridge and transfers them to the specified address.
This function is only callable by the sudo address.
Parameters
_token
address
The address of the token to be rescued.
_to
address
The address to which the tokens should be transferred.
_amount
uint256
The amount of tokens to be rescued.
Sidechain AURA
uint16 canonicalChainId
canonical chain ID
event Locked(address caller, uint256 amount)
Emitted when locked cvx on the L1 chain
Parameters
caller
address
The msg.sender
amount
uint256
The amount of cvx locked.
constructor(string _name, string _symbol, uint16 _canonicalChainId) public
Constructs the AuraOFT contract.
Parameters
_name
string
The oft token name
_symbol
string
The oft token symbol
_canonicalChainId
uint16
The canonical chain id
function initialize(address _lzEndpoint, address _guardian) external
Initialize the contract.
Parameters
_lzEndpoint
address
LayerZero endpoint contract
_guardian
address
The pause guardian
function setAdapterParams(uint16 _srcChainId, bytes32 _selector, bytes _adapterParams) external
Sets the configuration for a given source chain ID and selector.
Parameters
_srcChainId
uint16
The source chain ID.
_selector
bytes32
The selector.
_adapterParams
bytes
The adapter params.
function lock(address _receiver, uint256 _cvxAmount, address _zroPaymentAddress) external payable
Lock CVX on the L1 chain
Parameters
_receiver
address
address that will be receiving the refund and vlaura lock
_cvxAmount
uint256
Amount of CVX to lock for vlCVX on L1
_zroPaymentAddress
address
The LayerZero ZRO payment address
Send and receive AURA to and from all the Sidechains and receives lock requests from the sidechains
address locker
Aura Locker contract address
constructor(address _lzEndpoint, address _token, address _locker, address _guardian, address _sudo, uint256 _inflowLimit) public
Constructs the AuraProxyOFT contract
Parameters
_lzEndpoint
address
LayerZero endpoint contract
_token
address
The proxied token (auraBAL)
_locker
address
The Aura Locker contract address
_guardian
address
The pause guardian address
_sudo
address
The super user address
_inflowLimit
uint256
Initial inflow limit per epoch
Deploy contracts using CREATE2 opcode.
A factory contract that uses the CREATE2 opcode to deploy contracts with a deterministic address.
event Deployed(bytes32 salt, address deployed)
Event emitted when a contract is successfully deployed.
Parameters
salt
bytes32
A unique value used as part of the computation to determine the contract's address.
deployed
address
The address where the contract has been deployed.
mapping(address => bool) deployer
function updateDeployer(address _deployer, bool _authorized) external
Adds or remove an address from the deployers' whitelist
Parameters
_deployer
address
address of the authorized deployer
_authorized
bool
Whether to add or remove deployer
function deploy(uint256 amount, bytes32 salt, bytes bytecode, bytes[] callbacks) external returns (address)
Deploys a contract using the CREATE2 opcode.
Parameters
amount
uint256
The amount of Ether to be sent with the transaction deploying the contract.
salt
bytes32
A unique value used as part of the computation to determine the contract's address.
bytecode
bytes
The bytecode that will be used to create the contract.
callbacks
bytes[]
Callbacks to execute after contract is created.
Return Values
[0]
address
The address where the contract has been deployed.
function computeAddress(bytes32 salt, bytes32 codeHash) external view returns (address)
receive() external payable
Fallback function that accepts Ether.
Setter/Getter logic for cross chain layer zero config
mapping(uint16 => mapping(bytes32 => bytes)) getAdapterParams
srcChainId mapped to selector and configuration
event SetAdapterParams(uint16 srcChainId, bytes32 selector, bytes adapterParams)
Emitted a configuration is set for a given source chain id.
Parameters
srcChainId
uint16
The source chain ID.
selector
bytes32
The selector.
adapterParams
bytes
The configuration.
function setAdapterParams(uint16 _srcChainId, bytes32 _selector, bytes _adapterParams) external virtual
Sets the configuration for a given source chain ID and selector.
Parameters
_srcChainId
uint16
The source chain ID.
_selector
bytes32
The selector.
_adapterParams
bytes
The adapter params.
Share types for cross chain messages
bytes4 MAGIC_BYTES
_Magic Bytes to pad the custom message with bytes4(keccak256("isCustomMessage(bytes)"))
enum MessageType {
LOCK,
FEES,
FEES_CALLBACK
}
Tracks the amount of fee debt accrued by each sidechain and sends AURA back to each sidechain for rewards
uint256 REWARD_MULTIPLIER_DENOMINATOR
address balToken
BAL token contract
address auraToken
AURA token contract
address auraOFT
AURA OFT token contract
address treasury
AURA treasury address
address booster
Booster contract address
uint256 rewardMultiplier
Reward multiplier
mapping(uint16 => uint256) feeDebtOf
src chain ID mapped to total feeDebt
mapping(uint16 => uint256) settledFeeDebtOf
src chain ID mapped to total settled feeDebt
mapping(uint16 => uint256) distributedFeeDebtOf
src chain ID mapped to total distributed feeDebt
mapping(uint16 => address) bridgeDelegates
src chain ID to bridgeDelegate
mapping(uint16 => address) l2Coordinators
src chain ID to L2Coordinator address
mapping(address => bool) distributors
sender to isDistributor
event BridgeDelegateUpdated(uint16 srcChainId, address bridgeDelegate)
Parameters
srcChainId
uint16
Source chain ID
bridgeDelegate
address
The bridge delegate contract
event L2CoordinatorUpated(uint16 srcChainId, address l2Coordinator)
Parameters
srcChainId
uint16
Source chain ID
l2Coordinator
address
The l2Coordinator contract
event DisributorUpdated(address distributor, bool active)
Parameters
distributor
address
Distributor address
active
bool
If they are an active distributor
event FeeDebtNotified(uint16 srcChainId, uint256 amount)
Parameters
srcChainId
uint16
Source chain ID
amount
uint256
Amount of fee that was notified
event AuraDistributed(uint16 srcChainId, uint256 amount)
Parameters
srcChainId
uint16
Source chain ID
amount
uint256
Amount of AURA that was distributed
event FeeDebtSettled(uint16 srcChainId, uint256 amount)
Parameters
srcChainId
uint16
Source chain ID
amount
uint256
Amount of fee debt that was settled
event RewardMultiplierUpdated(uint256 multiplier)
Parameters
multiplier
uint256
The reward multiplier
event BoosterUpdated(address booster)
Parameters
booster
address
The booster contract
constructor(address _lzEndpoint, address _booster, address _balToken, address _auraToken, address _auraOFT, address _treasury) public
function setAdapterParams(uint16 _srcChainId, bytes32 _selector, bytes _adapterParams) external
Sets the configuration for a given source chain ID and selector.
Parameters
_srcChainId
uint16
The source chain ID.
_selector
bytes32
The selector.
_adapterParams
bytes
The adapter params.
function setBridgeDelegate(uint16 _srcChainId, address _bridgeDelegate) external
Set bridge delegate for given srcChainId
Parameters
_srcChainId
uint16
ID of the source chain
_bridgeDelegate
address
Address of the bridge delegate
function setL2Coordinator(uint16 _srcChainId, address _l2Coordinator) external
Set L2 Coordinator for given srcChainId
Parameters
_srcChainId
uint16
ID of the source chain
_l2Coordinator
address
Address of l2Coordinator
function setDistributor(address _distributor, bool _active) external
Set distributor as valid or invalid so the can call harvest
Parameters
_distributor
address
Distributor address
_active
bool
Is the distributor active
function setRewardMultiplier(uint256 _multiplier) external
Set the reward multiplier
Parameters
_multiplier
uint256
The new multiplier
function setBooster(address _booster) external
Set the booster address
Parameters
_booster
address
The booster contract address
function distributeAura(uint16 _srcChainId, address _zroPaymentAddress, address _sendFromZroPaymentAddress, bytes _sendFromAdapterParams) external payable
Distribute AURA to the src chain using the BAL float in this contract mint AURA by calling distributeL2Fees on the Booster and then send those AURA tokens to the src chain
function settleFeeDebt(uint16 _srcChainId, uint256 _amount) external
Receive CRV from the L2 via some thirdpart bridge to settle the feeDebt for the remote chain
receive() external payable
Coordinates LZ messages and actions from the L1 on the L2
uint16 canonicalChainId
canonical chain ID
address auraOFT
AuraOFT contract
address booster
Booster contract
address balToken
The BAL token contract
address bridgeDelegate
The bridge delegate contract
uint256 accBalRewards
Accumulated BAL rewards
uint256 accAuraRewards
Accumulated AURA rewards
event BridgeDelegateUpdated(address bridgeDelegate)
Emitted when the bridge delegate address is updated.
Parameters
bridgeDelegate
address
The new bridge delegate address.
event RewardAdded(address token, uint256 reward)
Emmitted when rewards are added
Parameters
token
address
The reward token
reward
uint256
The reward amount
constructor(address _auraOFT, uint16 _canonicalChainId) public
function mintRate() public view returns (uint256)
Get mint rate based on accumulated BAL and AURA
Dev mint rate is aura per bal rewards
function initialize(address _booster, address _balToken, address _lzEndpoint) external
Initializes the booster and balToken addresses
This function should only be called by the owner of the contract
Parameters
_booster
address
Address of the booster
_balToken
address
Address of the balToken
_lzEndpoint
address
LayerZero endpoint contract
function setBridgeDelegate(address _bridgeDelegate) external
function setAdapterParams(uint16 _srcChainId, bytes32 _selector, bytes _adapterParams) external
Sets the configuration for a given source chain ID and selector.
Parameters
_srcChainId
uint16
The source chain ID.
_selector
bytes32
The selector.
_adapterParams
bytes
The adapter params.
function mint(address _to, uint256 _amount) external
Mint function called by Booster.rewardClaimed. uses the CVX (L2) balance of this contract to transfer tokens
Parameters
_to
address
Address to send CVX (L2) to
_amount
uint256
Amount of CRV rewardClaimed was called with
function queueNewRewards(address _originalSender, uint256 _fees, uint256 _rewards, address _zroPaymentAddress) external payable
Called by the booster.earmarkRewards to register feeDebt with the L1 and receive CVX tokens in return
Parameters
_originalSender
address
Sender that initiated the Booster call
_fees
uint256
Amount of CRV that was received as fees
_rewards
uint256
Amount of CRV that was received by the reward contract
_zroPaymentAddress
address
The LayerZero ZRO payment address
Extension to the OFT standard that allows a guardian
address to perform an emergency pause on the sendFrom
function.
constructor(string _name, string _symbol) public
Constructs the PausableOFT contract
Parameters
_name
string
The oft token name
_symbol
string
The oft token symbol
function sendFrom(address _from, uint16 _dstChainId, bytes _toAddress, uint256 _amount, address payable _refundAddress, address _zroPaymentAddress, bytes _adapterParams) public payable
Override sendFrom to add pause modifier
Extension to the ProxyOFT standard that allows a guardian
address to perform an emergency pause.
When paused all messages received are added to a queue to be processed after queueDelay
time has passed.
When paused no messages can be sent via sendFrom
.
uint256 epochDuration
Duration of each inflow epoch
address sudo
Addres of super user
uint256 inflowLimit
Transfer inflow limit per epoch
uint256 queueDelay
Queue delay
mapping(uint256 => uint256) outflow
Epoch mapped to transfer outflow
mapping(uint256 => uint256) inflow
Epoch mapped to transfer inflow
mapping(bytes32 => bool) queue
Transfer queue
event QueuedFromChain(uint256 epoch, uint16 srcChainId, address to, uint256 amount, uint256 timestamp)
Parameters
epoch
uint256
The epoch
srcChainId
uint16
The source chain
to
address
Address to transfer to
amount
uint256
Amount to transfer
timestamp
uint256
Time the transfer was queued
event Rescue(address token, address to, uint256 amount)
Parameters
token
address
Token address
to
address
Send to address
amount
uint256
Amount to send
constructor(address _token, address _sudo, uint256 _inflowLimit) public
Parameters
_token
address
Proxy token (eg AURA or auraBAL)
_sudo
address
The super user address
_inflowLimit
uint256
Initial inflow limit per epoch
function setQueueDelay(uint256 _delay) external
Amount of time that a transfer has to sit in the queue until it can be processed
Parameters
_delay
uint256
Queue delay
function setInflowLimit(uint256 _limit) external
Set the inflow limit per epoch
Parameters
_limit
uint256
Inflow limit per epoch
function getCurrentEpoch() external view returns (uint256)
Get current epoch
function sendFrom(address _from, uint16 _dstChainId, bytes _toAddress, uint256 _amount, address payable _refundAddress, address _zroPaymentAddress, bytes _adapterParams) public payable
Override sendFrom to add pause modifier
function processQueued(uint256 _epoch, uint16 _srcChainId, address _to, uint256 _amount, uint256 _timestamp) external
Process a queued transfer Transfer has to be a valid root and the queue delay has to have passed
Parameters
_epoch
uint256
Epoch
_srcChainId
uint16
Source chain ID
_to
address
Address to transfer to
_amount
uint256
Amount to transfer
_timestamp
uint256
Time when this transfer was queued
function rescue(address _token, address _to, uint256 _amount) external virtual
In a doomsday bridge scenario there may be a case where funds need to be rescued.
Parameters
_token
address
Token address
_to
address
Send to address
_amount
uint256
Amount to send
Contract module which allows children to implement an emergency stop mechanism that can be triggered by an authorized immutable guardian address.
address guardian
The guardian address
function pause() external
This function pauses the contract.
This function can only be called by the 'guardian'.
function unpause() external
This function is used to unpause the contract.
This function can only be called by the 'guardian' of the contract.
function outboundTransfer(address _l1Token, address _to, uint256 _amount, bytes _data) external payable returns (bytes)
address gatewayRouter
The Gnosis bridge address
address l1Crv
Mainnet CRV token address
constructor(address _gatewayRouter, address _crv, address _l1Crv) public
Constructs the GnosisBridgeSender contract.
Parameters
_gatewayRouter
address
The arbitrum gatewayRouter address.
_crv
address
The L2 token address.
_l1Crv
address
The L1 token address.
function send(uint256 _amount) external
_Function to send a specified amount of tokens. Requirements:
The caller must be the owner of the contract._
Parameters
_amount
uint256
The amount of CRV tokens to be sent
Receive bridged tokens from the L2 on L1
address l1Coordinator
The L1Coordinator address
uint16 srcChainId
The source chain id
event SettleFeeDebt(uint256 amount)
Emitted when tokens are sent to a recipient.
Parameters
amount
uint256
The amount of fee debt settled.
constructor(address _l1Coordinator, uint16 _srcChainId) public
Constructs the BridgeDelegateReceiver contract.
Parameters
_l1Coordinator
address
The address of the L1 Coordinator.
_srcChainId
uint16
The source chain id.
function settleFeeDebt(uint256 _amount) external
Settle fee debt on the L1 Coordinator.
Parameters
_amount
uint256
The amount debt to settle Requirements: - The caller must be the owner of the contract.
Sends tokens to L1 via a bridge
address crv
The crv token address
address l1Receiver
The L1Receiver address
event Send(address to, uint256 amount)
Emitted when tokens are sent to a recipient.
Parameters
to
address
The address of the recipient.
amount
uint256
The amount of tokens sent.
event L1ReceiverUpated(address l1Receiver)
Emitted when the l1 receiver address is updated.
Parameters
l1Receiver
address
The new l1 receiver address.
function setL1Receiver(address _l1Receiver) external
Allows the owner of the contract to set the L1 receiver address.
This function requires the owner of the contract to call it and pass in a valid address. If the address is valid, the l1Receiver variable is updated and an event is emitted.
Parameters
_l1Receiver
address
The new l1 receiver address.
function send(uint256 _amount) external virtual
Function to send a specified amount of tokens
Parameters
_amount
uint256
The amount of tokens to be sent
Only used as an example and for tests Sends tokens to "L1" via a simple transfer
address token
The ERC20 bridged token address.
constructor(address _token) public
Constructs the SimpleBridgeDelegateSender contract.
Parameters
_token
address
The address of the ERC20 token to be sent.
function send(uint256 _amount) external
Sends tokens to a l1Receiver.
Parameters
_amount
uint256
The amount of tokens to send. Requirements: - The caller must be the owner of the contract.
Claim zap to bundle various reward claims
Claims from all pools, Bridges/Locks to L1 if Wanted and compounds if needed.
receive() external payable
address cvx
address cvxCrv
address compounder
address owner
uint16 canonicalChainID
struct ClaimRewardsAmounts {
uint256 lockCvxMaxAmount;
uint256 depositCvxCrvMaxAmount;
uint256 bridgeCvxMaxAmount;
}
struct Options {
bool useAllWalletFunds;
bool sendCvxToL1;
bool lockCvxL1;
bool useCompounder;
bool refundEth;
bool overrideL1Receiver;
address l1Receiever;
address zro;
bytes adapterParams;
}
function initialize(address _owner, address _cvx, address _cvxCrv, address _compounder) external
function getName() external pure returns (string)
Returns meta data of contract
function setApprovals() external
Approve spending of: cvxCrv -> Compounder
function claimRewards(address zroPaymentAddress, address[] rewardContracts, address[] extraRewardContracts, address[] tokenRewardContracts, address[] tokenRewardTokens, struct SidechainClaimZap.ClaimRewardsAmounts amounts, struct SidechainClaimZap.Options options) external payable
Claim all the rewards
Parameters
zroPaymentAddress
address
rewardContracts
address[]
Array of addresses for LP token rewards
extraRewardContracts
address[]
Array of addresses for extra rewards
tokenRewardContracts
address[]
Array of addresses for token rewards e.g vlCvxExtraRewardDistribution
tokenRewardTokens
address[]
Array of token reward addresses to use with tokenRewardContracts
amounts
struct SidechainClaimZap.ClaimRewardsAmounts
Claim rewards amounts.
options
struct SidechainClaimZap.Options
Claim options
Simple strategy to harvest all vault's extra rewards and queue them.
address auraBalToken
The $AURABAL token address
address vault
The AuraBal compounder vault address
constructor(address _auraBalToken, address _vault) public
Simple constructor
Parameters
_auraBalToken
address
The $AURABAL token address
_vault
address
The AuraBal compounder vault
function harvest() external returns (uint256)
function setApprovals() external
function stake(uint256 _amount) external
function totalUnderlying() external view returns (uint256)
function withdraw(uint256 _amount) external
Allows the Vault to withdraw a given amount of auraBal.
Only callable by the vault.
Parameters
_amount
uint256
The amount of auraBal to withdraw.
function harvest(uint256) public returns (uint256 harvested)
This function is used to process extra rewards for the vault.
This function will loop through the extra rewards and transfer the balance of the reward token to the rewards address. It will then queue the new rewards with the balance.
struct PoolInfo {
address lptoken;
address token;
address gauge;
address crvRewards;
address stash;
bool shutdown;
}
function earmarkRewards(uint256 _pid, address _zroPaymentAddress) external payable returns (bool)
function poolLength() external view returns (uint256)
function lockRewards() external view returns (address)
function poolInfo(uint256 _pid) external view returns (struct IBoosterLite.PoolInfo poolInfo)
function lockIncentive() external view returns (uint256)
function stakerIncentive() external view returns (uint256)
function earmarkIncentive() external view returns (uint256)
function platformFee() external view returns (uint256)
function FEE_DENOMINATOR() external view returns (uint256)
Claim zap to bundle various reward claims
Claims from all pools, and stakes cvxCrv and CVX if wanted. v2: - change exchange to use curve pool - add getReward(address,token) type - add option to lock cvx - add option use all funds in wallet v3: - add option to deposit to compounder - reduce calls to cvxcrv rewards/compounder - removed enum and option bitshifting - introduced options struct - gas optimisation on use all funds balances - helper functions to reduce code repetition
address crv
address cvx
address cvxCrv
address crvDepositWrapper
address cvxCrvRewards
address locker
address owner
address compounder
struct ClaimRewardsAmounts {
uint256 depositCrvMaxAmount;
uint256 minAmountOut;
uint256 depositCvxMaxAmount;
uint256 depositCvxCrvMaxAmount;
}
struct Options {
bool claimCvxCrv;
bool claimLockedCvx;
bool lockCvxCrv;
bool lockCrvDeposit;
bool useAllWalletFunds;
bool useCompounder;
bool lockCvx;
}
constructor(address _crv, address _cvx, address _cvxCrv, address _crvDepositWrapper, address _cvxCrvRewards, address _locker, address _compounder) public
Parameters
_crv
address
CRV token (0xD533a949740bb3306d119CC777fa900bA034cd52);
_cvx
address
CVX token (0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B);
_cvxCrv
address
cvxCRV token (0x62B9c7356A2Dc64a1969e19C23e4f579F9810Aa7);
_crvDepositWrapper
address
crvDepositWrapper (0x8014595F2AB54cD7c604B00E9fb932176fDc86Ae);
_cvxCrvRewards
address
cvxCrvRewards (0x3Fe65692bfCD0e6CF84cB1E7d24108E434A7587e);
_locker
address
vlCVX (0xD18140b4B819b895A3dba5442F959fA44994AF50);
_compounder
address
cvxCrv autocompounder vault
function getName() external pure returns (string)
Returns meta data of contract.
function setApprovals() external
Approve spending of: crv -> crvDepositor cvxCrv -> cvxCrvRewards cvxCrv -> Compounder cvx -> Locker
function claimRewards(address[] rewardContracts, address[] extraRewardContracts, address[] tokenRewardContracts, address[] tokenRewardTokens, struct AuraClaimZapV3.ClaimRewardsAmounts amounts, struct AuraClaimZapV3.Options options) external
Claim all the rewards
Parameters
rewardContracts
address[]
Array of addresses for LP token rewards
extraRewardContracts
address[]
Array of addresses for extra rewards
tokenRewardContracts
address[]
Array of addresses for token rewards e.g vlCvxExtraRewardDistribution
tokenRewardTokens
address[]
Array of token reward addresses to use with tokenRewardContracts
amounts
struct AuraClaimZapV3.ClaimRewardsAmounts
Claim rewards amounts.
options
struct AuraClaimZapV3.Options
Claim options
View-only contract to combine calls
IMPORTANT: These functions are extremely gas-intensive and should not be called from within a transaction.
contract IBalancerVault balancerVault
struct Token {
address addr;
uint8 decimals;
string symbol;
string name;
}
struct Pool {
uint256 pid;
address lptoken;
address token;
address gauge;
address crvRewards;
address stash;
bool shutdown;
address rewardToken;
bytes32 poolId;
uint256[] normalizedWeights;
address[] poolTokens;
uint256[] underlying;
uint256 totalSupply;
struct AuraViewHelpers.RewardsData rewardsData;
struct AuraViewHelpers.ExtraRewards[] extraRewards;
}
struct Vault {
address addr;
address underlying;
uint256 totalUnderlying;
uint256 totalSupply;
uint256 withdrawalPenalty;
struct AuraViewHelpers.ExtraRewards[] extraRewards;
}
struct VaultAccount {
address addr;
uint256 balance;
uint256 balanceOfUnderlying;
uint256[] extraRewardsEarned;
}
struct Locker {
uint256 epoch;
uint256 totalSupply;
uint256 lockedSupply;
struct AuraViewHelpers.RewardsData rewardsData;
}
struct LockerAccount {
address addr;
uint256 total;
uint256 unlockable;
uint256 locked;
uint256 nextUnlockIndex;
uint128 rewardPerTokenPaid;
uint128 rewards;
address delegate;
uint256 votes;
struct AuraLocker.LockedBalance[] lockData;
struct AuraLocker.EarnedData[] claimableRewards;
}
struct RewardsData {
uint256 periodFinish;
uint256 lastUpdateTime;
uint256 rewardRate;
uint256 rewardPerTokenStored;
uint256 queuedRewards;
}
struct ExtraRewards {
address addr;
address rewardsToken;
struct AuraViewHelpers.RewardsData rewardsData;
}
struct PoolBalances {
uint256 pid;
uint256 earned;
uint256[] extraRewardsEarned;
uint256 staked;
}
function getVault(address _vault) external view returns (struct AuraViewHelpers.Vault vault)
function getVaultAccount(address _vault, address _account) external view returns (struct AuraViewHelpers.VaultAccount vaultAccount)
function getLocker(address _locker) external view returns (struct AuraViewHelpers.Locker locker)
function getLockerAccount(address _locker, address _account) external view returns (struct AuraViewHelpers.LockerAccount lockerAccount)
function getPools(address _booster) external view returns (struct AuraViewHelpers.Pool[])
function getCvxCrvRewards(address _cvxCrvRewards) public view returns (struct AuraViewHelpers.Pool)
function getPool(struct IBooster.PoolInfo poolInfo, uint256 _pid) public view returns (struct AuraViewHelpers.Pool)
function getPoolsBalances(address _booster, address _account) external view returns (struct AuraViewHelpers.PoolBalances[])
function getPoolBalances(address _rewardPool, uint256 _pid, address _account) public view returns (struct AuraViewHelpers.PoolBalances)
function getTokens(address[] _addresses) public view returns (struct AuraViewHelpers.Token[])
function getEarmarkingReward(uint256 pool, address booster, address token) public returns (uint256 pending)
function getMultipleEarmarkingRewards(uint256[] pools, address booster, address token) external returns (uint256[] pendings)
Invokes booster.earmarkRewards for multiple pools on BoosterLite
Allows anyone to call earmarkRewards
via the booster.
contract IBoosterLite booster
address crv
constructor(address _booster, address _crv) public
Parameters
_booster
address
Booster.sol
_crv
address
Crv e.g. 0xba100000625a3754423978a60c9317c58a424e3D
function earmarkRewards(uint256[] _pids, address _zroPaymentAddress) external payable returns (uint256)
function processIdleRewards(uint256[] _pids) external
Invoke processIdleRewards for each pool id.
Parameters
_pids
uint256[]
Array of pool ids
The convex platform contracts developed for the sidechain are ‘lite’ variations of those used on Ethereum. In practice this means that contracts have functionality changed or removed, multiple contracts are merged together or contracts are not utilised on the sidechain.
BaseRewardPool4626
BoosterOwnerLite
BoosterLite
PoolManagerLite
VoterProxyLite
Simply wraps the BaseRewardPool with the new IERC4626 Vault standard functions.
See https://github.com/fei-protocol/ERC4626/blob/main/src/interfaces/IERC4626.sol#L58 This is not so much a vault as a Reward Pool, therefore asset:share ratio is always 1:1. To create most utility for this RewardPool, the "asset" has been made to be the crvLP token, as opposed to the cvxLP token. Therefore, users can easily deposit crvLP, and it will first go to the Booster and mint the cvxLP before performing the normal staking function.
address asset
The address of the underlying ERC20 token used for the Vault for accounting, depositing, and withdrawing.
constructor(uint256 pid_, address stakingToken_, address rewardToken_, address operator_, address rewardManager_, address lptoken_) public
See BaseRewardPool.sol
function totalAssets() external view virtual returns (uint256)
Total amount of the underlying asset that is "managed" by Vault.
function deposit(uint256 assets, address receiver) public virtual returns (uint256)
Mints shares
Vault shares to receiver
.
Because asset
is not actually what is collected here, first wrap to required token in the booster.
function mint(uint256 shares, address receiver) external virtual returns (uint256)
Mints exactly shares
Vault shares to receiver
by depositing assets
of underlying tokens.
function withdraw(uint256 assets, address receiver, address owner) public virtual returns (uint256)
Redeems shares
from owner
and sends assets
of underlying tokens to receiver
.
function redeem(uint256 shares, address receiver, address owner) external virtual returns (uint256)
Redeems shares
from owner
and sends assets
of underlying tokens to receiver
.
function convertToShares(uint256 assets) public view virtual returns (uint256)
The amount of shares that the vault would exchange for the amount of assets provided, in an ideal scenario where all the conditions are met.
function convertToAssets(uint256 shares) public view virtual returns (uint256)
The amount of assets that the vault would exchange for the amount of shares provided, in an ideal scenario where all the conditions are met.
function maxDeposit(address) public view virtual returns (uint256)
Total number of underlying assets that can be deposited by owner
into the Vault, where owner
corresponds to the input parameter receiver
of a deposit
call.
function previewDeposit(uint256 assets) external view virtual returns (uint256)
Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given current on-chain conditions.
function maxMint(address owner) external view virtual returns (uint256)
Total number of underlying shares that can be minted for owner
, where owner
corresponds to the input parameter receiver
of a mint
call.
function previewMint(uint256 shares) external view virtual returns (uint256)
Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given current on-chain conditions.
function maxWithdraw(address owner) public view virtual returns (uint256)
Total number of underlying assets that can be withdrawn from the Vault by owner
, where owner
corresponds to the input parameter of a withdraw
call.
function previewWithdraw(uint256 assets) public view virtual returns (uint256 shares)
Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block, given current on-chain conditions.
function maxRedeem(address owner) external view virtual returns (uint256)
Total number of underlying shares that can be redeemed from the Vault by owner
, where owner
corresponds to the input parameter of a redeem
call.
function previewRedeem(uint256 shares) external view virtual returns (uint256)
Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block, given current on-chain conditions.
function name() external view returns (string)
Returns the name of the token.
function symbol() external view returns (string)
Returns the symbol of the token.
function decimals() external view returns (uint8)
Returns the decimals places of the token.
function totalSupply() public view returns (uint256)
Returns the amount of tokens in existence.
function balanceOf(address account) public view returns (uint256)
Returns the amount of tokens owned by account
.
function transfer(address recipient, uint256 amount) external returns (bool)
_Moves amount
tokens from the caller's account to recipient
.
Returns a boolean value indicating whether the operation succeeded.
Emits a {Transfer} event._
function allowance(address owner, address spender) public view virtual returns (uint256)
See {IERC20-allowance}.
function approve(address spender, uint256 amount) public virtual returns (bool)
_See {IERC20-approve}.
Requirements:
spender
cannot be the zero address._
function transferFrom(address owner, address recipient, uint256 amount) external returns (bool)
Moves amount
tokens from sender
to recipient
using the allowance mechanism. amount
is then deducted from the caller's allowance.
Immutable booster owner that requires all pools to be shutdown before shutting down the entire convex system
A timelock is required if forcing a shutdown if there is a bugged pool that can not be withdrawn from. Allow arbitrary calls to other contracts, but limit how calls are made to Booster. A lite version of the original Booster for use on sidechains
address poolManager
address booster
address stashFactory
address rescueStash
address owner
address pendingowner
bool isSealed
uint256 FORCE_DELAY
bool isForceTimerStarted
uint256 forceTimestamp
event ShutdownStarted(uint256 executableTimestamp)
event ShutdownExecuted()
event TransferOwnership(address pendingOwner)
event AcceptedOwnership(address newOwner)
event OwnershipSealed()
constructor(address _owner, address _poolManager, address _booster, address _stashFactory, address _rescueStash, bool _seal) public
Parameters
_owner
address
Owner (e.g. CVX multisig)
_poolManager
address
PoolManager (e.g. PoolManagerSecondaryProxy or 0xD20904e5916113D11414F083229e9C8C6F91D1e1)
_booster
address
The booster (e.g. 0xF403C135812408BFbE8713b5A23a04b3D48AAE31)
_stashFactory
address
Creates stashes (e.g. 0x884da067B66677e72530df91eabb6e3CE69c2bE4)
_rescueStash
address
Rescues tokens for subsequent vlCVX redistribution (e.g. 0x01140351069af98416cC08b16424b9E765436531)
_seal
bool
function transferOwnership(address _owner) external
function acceptOwnership() external
function sealOwnership() external
function setBoosterOwner() external
function setFactories(address _rfactory, address _sfactory, address _tfactory) external
function setFeeManager(address _feeM) external
function shutdownSystem() external
function queueForceShutdown() external
function forceShutdownSystem() external
function execute(address _to, uint256 _value, bytes _data) external returns (bool, bytes)
function setRescueTokenDistribution(address _distributor, address _rewardDeposit, address _treasury) external
function setRescueTokenReward(address _token, uint256 _option) external
function setStashExtraReward(address _stash, address _token) external
function setStashRewardHook(address _stash, address _hook) external
function setStashFactoryImplementation(address _v1, address _v2, address _v3) external
A lite version of the original Booster for use on sidechains
address crv
uint256 lockIncentive
uint256 stakerIncentive
uint256 earmarkIncentive
uint256 platformFee
uint256 MaxFees
uint256 FEE_DENOMINATOR
address owner
address feeManager
address poolManager
address staker
address minter
address rewardFactory
address stashFactory
address tokenFactory
address treasury
address rewards
bool isShutdown
struct PoolInfo {
address lptoken;
address token;
address gauge;
address crvRewards;
address stash;
bool shutdown;
}
struct BoosterLite.PoolInfo[] poolInfo
mapping(address => bool) gaugeMap
event Deposited(address user, uint256 poolid, uint256 amount)
event Withdrawn(address user, uint256 poolid, uint256 amount)
event PoolAdded(address lpToken, address gauge, address token, address rewardPool, address stash, uint256 pid)
event PoolShutdown(uint256 poolId)
event OwnerUpdated(address newOwner)
event FeeManagerUpdated(address newFeeManager)
event PoolManagerUpdated(address newPoolManager)
event FactoriesUpdated(address rewardFactory, address stashFactory, address tokenFactory)
event RewardContractsUpdated(address rewards)
event FeesUpdated(uint256 lockIncentive, uint256 stakerIncentive, uint256 earmarkIncentive, uint256 platformFee)
event TreasuryUpdated(address newTreasury)
constructor(address _staker) public
Constructor doing what constructors do. It is noteworthy that a lot of basic config is set to 0 - expecting subsequent calls setFeeManager etc.
Parameters
_staker
address
VoterProxyLite (locks the crv and adds to all gauges)
function initialize(address _minter, address _crv, address _owner) external
Initialize the contract.
Parameters
_minter
address
CVX token, or the thing that mints it
_crv
address
CRV Token address
_owner
address
Owner address
function setOwner(address _owner) external
Owner is responsible for setting initial config, updating vote delegate and shutting system
function setFeeManager(address _feeM) external
Fee Manager can update the fees (lockIncentive, stakeIncentive, earmarkIncentive, platformFee)
function setPoolManager(address _poolM) external
Pool manager is responsible for adding new pools
function setFactories(address _rfactory, address _sfactory, address _tfactory) external
Factories are used when deploying new pools. Only the stash factory is mutable after init
function setRewardContracts(address _rewards) external
Only called once, to set the addresses of cvxCrv (rewards)
function setFees(uint256 _lockFees, uint256 _stakerFees, uint256 _callerFees, uint256 _platform) external
Fee manager can set all the relevant fees
Parameters
_lockFees
uint256
% for cvxCrv stakers where 1% == 100
_stakerFees
uint256
% for CVX stakers where 1% == 100
_callerFees
uint256
% for whoever calls the claim where 1% == 100
_platform
uint256
% for "treasury" or vlCVX where 1% == 100
function setTreasury(address _treasury) external
Set the address of the treasury (i.e. vlCVX)
function poolLength() external view returns (uint256)
END SETTER SECTION ///
function addPool(address _lptoken, address _gauge, uint256 _stashVersion) external returns (bool)
Called by the PoolManager (i.e. PoolManagerProxy) to add a new pool - creates all the required contracts (DepositToken, RewardPool, Stash) and then adds to the list!
function shutdownPool(uint256 _pid) external returns (bool)
Shuts down the pool by withdrawing everything from the gauge to here (can later be claimed from depositors by using the withdraw fn) and marking it as shut down
function shutdownSystem() external
Shuts down the WHOLE SYSTEM by withdrawing all the LP tokens to here and then allowing for subsequent withdrawal by any depositors.
function deposit(uint256 _pid, uint256 _amount, bool _stake) public returns (bool)
Deposits an "_amount" to a given gauge (specified by _pid), mints a DepositToken
and subsequently stakes that on Convex BaseRewardPool
function depositAll(uint256 _pid, bool _stake) external returns (bool)
Deposits all a senders balance to a given gauge (specified by _pid), mints a DepositToken
and subsequently stakes that on Convex BaseRewardPool
function withdraw(uint256 _pid, uint256 _amount) public returns (bool)
Withdraw a given amount from a pool (must already been unstaked from the Convex Reward Pool - BaseRewardPool uses withdrawAndUnwrap to get around this)
function withdrawAll(uint256 _pid) public returns (bool)
Withdraw all the senders LP tokens from a given gauge
function withdrawTo(uint256 _pid, uint256 _amount, address _to) external returns (bool)
Allows the actual BaseRewardPool to withdraw and send directly to the user
function claimRewards(uint256 _pid, address _gauge) external returns (bool)
Allows a stash to claim secondary rewards from a gauge
function setGaugeRedirect(uint256 _pid) external returns (bool)
Tells the Curve gauge to redirect any accrued rewards to the given stash via the VoterProxy
function earmarkRewards(uint256 _pid, address _zroPaymentAddress) external payable returns (bool)
Basically a hugely pivotal function. Responsible for collecting the crv from gauge, and then redistributing to the correct place. Pays the caller a fee to process this.
function rewardClaimed(uint256 _pid, address _address, uint256 _amount) external returns (bool)
Callback from reward contract when crv is received.
Goes off and mints a relative amount of CVX
based on the distribution schedule.
Pool Manager Lite
Add pools to the Booster contract
address booster
address operator
bool protectAddPool
bool isShutdown
constructor(address _booster) public
function setOperator(address _operator) external
function setProtectPool(bool _protectAddPool) external
function addPool(address _gauge) external returns (bool)
function addPool(address _gauge, uint256 _stashVersion) external returns (bool)
function shutdownPool(uint256 _pid) external returns (bool)
function shutdownSystem() external
A lite version of the original VoterProxy for use on sidechains
address mintr
address crv
address rewardDeposit
address withdrawer
address owner
address operator
constructor() public
function initialize(address _mintr, address _crv, address _owner) external
Initialize the contract.
Parameters
_mintr
address
CRV minter
_crv
address
CRV Token address
_owner
address
The owner
function getName() external pure returns (string)
function setOwner(address _owner) external
function setRewardDeposit(address _withdrawer, address _rewardDeposit) external
Allows dao to set the reward withdrawal address
Parameters
_withdrawer
address
Whitelisted withdrawer
_rewardDeposit
address
Distributor address
function setSystemConfig(address _mintr) external returns (bool)
Allows dao to set the external system config, should it change in the future
Parameters
_mintr
address
Token minter address for claiming rewards
function setOperator(address _operator) external
Set the operator of the VoterProxy
Parameters
_operator
address
Address of the operator (Booster)
function setStashAccess(address _stash, bool _status) external returns (bool)
function deposit(address _token, address _gauge) external returns (bool)
Deposit tokens into the Curve Gauge
Only can be called by the operator (Booster) once this contract has been whitelisted by the Curve DAO
Parameters
_token
address
Deposit LP token address
_gauge
address
Gauge contract to deposit to
function withdraw(contract IERC20 _asset) external returns (uint256 balance)
Withdraw ERC20 tokens that have been distributed as extra rewards
Tokens shouldn't end up here if they can help it. However, dao can set a withdrawer that can process these to some ExtraRewardDistribution.
function withdraw(address _token, address _gauge, uint256 _amount) public returns (bool)
Withdraw LP tokens from a gauge
Only callable by the operator
Parameters
_token
address
LP token address
_gauge
address
Gauge for this LP token
_amount
uint256
Amount of LP token to withdraw
function withdrawAll(address _token, address _gauge) external returns (bool)
Withdraw all LP tokens from a gauge
Only callable by the operator
Parameters
_token
address
LP token address
_gauge
address
Gauge for this LP token
function claimCrv(address _gauge) external returns (uint256)
Claim CRV from Curve
Claim CRV for LP token staking from the CRV minter contract
function claimRewards(address _gauge) external returns (bool)
Claim extra rewards from gauge
Called by operator (Booster) to claim extra rewards
function balanceOfPool(address _gauge) public view returns (uint256)
function execute(address _to, uint256 _value, bytes _data) external returns (bool, bytes)
Allows to permissionless add pools on any supported sidechain. 1. Owner must configure gaugeTypes mapping (lzChainId => balancer gauge type) 2. User most provide a root gauge address and the layer zero chain id, with enought native fee to be able to add a pool on the destination chain.
uint256 NO_EXTRA_GAS
uint16 PT_SEND
uint16 lzChainId
LayerZero chain ID for this chain
address gaugeController
Gauge controller address
address gaugeCheckpointer
Gauge controller address
mapping(uint16 => string) gaugeTypes
lzChainId => gauge type
event AddSidechainPool(uint16 dstChainId, address rootGauge, address dstGauge)
constructor(uint16 _lzChainId, address _lzEndpoint, address _gaugeController, address _gaugeCheckpointer) public
Parameters
_lzChainId
uint16
LayerZero chain ID
_lzEndpoint
address
LayerZero endpoint
_gaugeController
address
Gauge controller address
_gaugeCheckpointer
address
Guage checkpointer address
receive() external payable
function setGaugeType(uint16 _lzChainId, string gaugeType) external
Maps layer zero chain id with balancer gauge type.
Parameters
_lzChainId
uint16
Layer zero chain id.
gaugeType
string
Balancer gaugeType.
function addPools(address[] _gauges, uint16 _dstChainId, address _zroPaymentAddress, bytes _adapterParams) external payable returns (bool)
Send a message to add a pool on a sidechain.
Set adapterParams correctly per dstChainId to provide enough gas to add a pool on the destination chain.
Parameters
_gauges
address[]
The root gauge addresses.
_dstChainId
uint16
The LayerZero destination chain ID eg optimism is 111
_zroPaymentAddress
address
The LayerZero ZRO payment address
_adapterParams
bytes
The adapter params, very important as default gas limit is not enough to add a pool on any sidechain.
Given a root gauge on L1PoolManagerProxy it adds a gauge recipient on PoolManagerLite
address poolManager
The poolManager address
mapping(address => bool) isValidGauge
Mapping of valid gauges sent from L1
event PoolManagerUpdated(address poolManager)
constructor() public
function initialize(address _lzEndpoint, address _poolManager) external
Initialize the contract.
Parameters
_lzEndpoint
address
LayerZero endpoint contract
_poolManager
address
Pool Manager address
function isShutdown() external view returns (bool)
function setPoolManager(address _poolManager) external
function setPoolManagerOperator(address _operator) external
sets the poolManager operator.
Usefull to reset pool manager operator value.
function ownerAddPool(address _gauge) external returns (bool)
Adds new pool directly on L2.
Parameters
_gauge
address
The gauge address.
function addPool(address _gauge) external returns (bool)
Adds new pool directly on L2 checking for a valid gauge
Parameters
_gauge
address
The gauge address.
function shutdownPool(uint256 _pid) external returns (bool)
Shutdowns a given pool.
Parameters
_pid
uint256
The pool id.
function shutdownSystem() external
Shutdows the system, it is not reversible.