Infrared Protocol
The Infrared Protocol revolutionizes the way users engage with the Berachain ecosystem, particularly in how they stake consensus assets and receive the Proof-of-Liquidity inflation. It enables users to stake their assets effortlessly and receive IBGT, a liquid staked representation of BGT, significantly enhancing BGT's utility. Additionally, Infrared democratizes access to Validator staking through the IBERA contract suite, a liquid staking token tightly integrated with Proof-of-Liquidity (POL) and the Infrared ecosystem.
Learn More
Contract Architecture
https://link.excalidraw.com/l/1Tuu8vTTCh1/1f3jMvwGuuS
Core Contracts
-
IBERA.sol
: Main liquid staking token contract. Handles minting/burning of iBERA, facilitates POL rewards and manages validators. -
InfraredVault.sol
: Manages staking pools and reward distribution. Integrates with Berachain's POL system. -
InfraredDistributor.sol
: Handles distribution of validator rewards and commission management. -
BribeCollector.sol
: Collects and auctions bribes from Berachain reward vaults.
Staking Contracts
-
IBERADepositor.sol
: Handles deposits to CL through Berachain beacon deposit contract. -
IBERAWithdrawor.sol
: Manages withdrawals from CL through Berachain precompiles. -
IBERAClaimor.sol
: Processes user claims for withdrawn funds. -
IBERAFeeReceivor.sol
: Receives and processes validator rewards from EL.
Voting Contracts
-
VotingEscrow.sol
: Implementation of vote-escrowed NFTs (veNFTs) for protocol governance. -
Voter.sol
: Manages voting logic for POL cutting board allocation. -
MultiRewards.sol
: Base contract for reward distribution across multiple tokens.
Getting Started
Prerequisites
# Install Foundry
curl -L https://foundry.paradigm.xyz | bash
foundryup
Quick Start
# Clone the repository
git clone https://github.com/infrared-dao/infrared-contracts.git
cd infrared-protocol
# Install dependencies
forge install
# Build contracts
forge build
# Run tests
forge test
Integration Guide
Developers who want to integrate with InfraredVault
and IBGTVault
can do so by following these steps:
Installation
Add the infrared-contracts
to your Foundry project:
forge install infrared-dao/infrared-contracts
Update your foundry.toml
with the following remapping:
@infrared/=lib/infrared-contracts/contracts
Example Usage
import {IInfrared} from '@infrared/interfaces/IInfrared.sol';
import {IInfraredVault} from '@infrared/interfaces/IInfraredVault.sol';
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
// Query InfraredVault
IInfraredVault infraredVault = IInfrared(infrared).vaultRegistry(asset);
// Stake into InfraredVault
IERC20(asset).approve(address(infraredVault), amount);
infraredVault.stake(amount);
// Check earned rewards
IInfraredVault.RewardData[] memory rTs = infraredVault.getUserRewardsEarned(user);
// Harvest rewards
infraredVault.getReward();
// Withdraw assets and harvest remaining rewards
infraredVault.exit();
Contents
- libraries
- BribeCollector
- Infrared
- InfraredBGT
- InfraredDistributor
- InfraredUpgradeable
- InfraredVault
- MultiRewards
- RED
- WrappedVault
Contents
ConfigTypes
Enums
FeeType
Fee type enum for determining rates to charge on reward distribution.
enum FeeType {
HarvestOperatorFeeRate,
HarvestOperatorProtocolRate,
HarvestVaultFeeRate,
HarvestVaultProtocolRate,
HarvestBribesFeeRate,
HarvestBribesProtocolRate,
HarvestBoostFeeRate,
HarvestBoostProtocolRate
}
RewardsLib
State Variables
RATE_UNIT
RED mint rate in hundredths of 1 bip
Used as the denominator when calculating IRED minting (1e6)
uint256 internal constant RATE_UNIT = 1e6;
WEIGHT_UNIT
Weight units when partitioning reward amounts in hundredths of 1 bip
Used as the denominator when calculating weighted distributions (1e6)
uint256 internal constant WEIGHT_UNIT = 1e6;
FEE_UNIT
Protocol fee rate in hundredths of 1 bip
Used as the denominator when calculating protocol fees (1e6)
uint256 internal constant FEE_UNIT = 1e6;
Functions
chargedFeesOnRewards
Calculates how fees are split between protocol, voters, and the recipient.
function chargedFeesOnRewards(
RewardsStorage storage,
uint256 _amt,
uint256 _feeTotal,
uint256 _feeProtocol
)
external
pure
returns (uint256 amtRecipient, uint256 amtVoter, uint256 amtProtocol);
_chargedFeesOnRewards
function _chargedFeesOnRewards(
uint256 _amt,
uint256 _feeTotal,
uint256 _feeProtocol
)
internal
pure
returns (uint256 amtRecipient, uint256 amtVoter, uint256 amtProtocol);
_distributeFeesOnRewards
function _distributeFeesOnRewards(
mapping(address => uint256) storage protocolFeeAmounts,
address _voter,
address _token,
uint256 _amtVoter,
uint256 _amtProtocol
) internal;
harvestBase
function harvestBase(address bgt, address ibgt, address ibera)
external
returns (uint256 bgtAmt);
harvestVault
function harvestVault(
RewardsStorage storage $,
IInfraredVault vault,
address bgt,
address ibgt,
address voter,
address red,
uint256 rewardsDuration
) external returns (uint256 bgtAmt);
harvestBribes
function harvestBribes(
RewardsStorage storage $,
address wbera,
address collector,
address[] memory _tokens,
bool[] memory whitelisted
) external returns (address[] memory tokens, uint256[] memory _amounts);
collectBribesInWBERA
function collectBribesInWBERA(
RewardsStorage storage $,
uint256 _amount,
address wbera,
address ibera,
address ibgtVault,
address voter,
uint256 rewardsDuration
) external returns (uint256 amtInfraredBERA, uint256 amtIbgtVault);
harvestBoostRewards
function harvestBoostRewards(
RewardsStorage storage $,
address bgt,
address ibgtVault,
address voter,
uint256 rewardsDuration
) external returns (address _vault, address _token, uint256 _amount);
harvestOperatorRewards
function harvestOperatorRewards(
RewardsStorage storage $,
address ibera,
address voter,
address distributor
) external returns (uint256 _amt);
_handleTokenRewardsForVault
Handles non-InfraredBGT token rewards to the vault.
function _handleTokenRewardsForVault(
RewardsStorage storage $,
IInfraredVault _vault,
address _token,
address voter,
uint256 _amount,
uint256 _feeTotal,
uint256 _feeProtocol,
uint256 rewardsDuration
) internal;
Parameters
Name | Type | Description |
---|---|---|
$ | RewardsStorage | |
_vault | IInfraredVault | IInfraredVault The address of the vault. |
_token | address | address The reward token. |
voter | address | |
_amount | uint256 | uint256 The amount of reward token to send to vault. |
_feeTotal | uint256 | uint256 The rate to charge for total fees on _amount . |
_feeProtocol | uint256 | uint256 The rate to charge for protocol treasury on total fees. |
rewardsDuration | uint256 |
_handleTokenBribesForReceiver
Handles non-InfraredBGT token bribe rewards to a non-vault receiver address.
Does not take protocol fee on bribe coin, as taken on bribe collector payout token in eventual callback.
function _handleTokenBribesForReceiver(
RewardsStorage storage,
address _recipient,
address _token,
uint256 _amount
) internal;
Parameters
Name | Type | Description |
---|---|---|
<none> | RewardsStorage | |
_recipient | address | address The address of the recipient. |
_token | address | address The address of the token to forward to recipient. |
_amount | uint256 |
_handleRewardsForOperators
Handles BGT base rewards supplied to validator distributor.
function _handleRewardsForOperators(
RewardsStorage storage $,
address ibera,
address voter,
address distributor,
uint256 _iBERAShares,
uint256 _feeTotal,
uint256 _feeProtocol
) internal returns (uint256 _amt);
Parameters
Name | Type | Description |
---|---|---|
$ | RewardsStorage | |
ibera | address | |
voter | address | |
distributor | address | |
_iBERAShares | uint256 | uint256 The BGT reward amount. |
_feeTotal | uint256 | uint256 The rate to charge for total fees on _iBERAShares . |
_feeProtocol | uint256 | uint256 The rate to charge for protocol treasury on total fees. |
delegateBGT
function delegateBGT(RewardsStorage storage, address _delegatee, address bgt)
external;
updateInfraredBERABribesWeight
function updateInfraredBERABribesWeight(
RewardsStorage storage $,
uint256 _weight
) external;
updateFee
function updateFee(
RewardsStorage storage $,
ConfigTypes.FeeType _t,
uint256 _fee
) external;
claimProtocolFees
function claimProtocolFees(
RewardsStorage storage $,
address _to,
address _token,
uint256 _amount
) external;
getBGTBalance
function getBGTBalance(RewardsStorage storage, address bgt)
external
view
returns (uint256);
_getBGTBalance
function _getBGTBalance(address bgt) internal view returns (uint256);
updateRedMintRate
function updateRedMintRate(RewardsStorage storage $, uint256 _iredMintRate)
external;
Events
RedNotMinted
Emitted when Red cannot be minted during a harvest because of pause
event RedNotMinted(uint256 amount);
Structs
RewardsStorage
struct RewardsStorage {
mapping(address => uint256) protocolFeeAmounts;
uint256 redMintRate;
uint256 collectBribesWeight;
mapping(uint256 => uint256) fees;
}
ValidatorManagerLib
Functions
isValidator
function isValidator(ValidatorStorage storage $, bytes memory pubkey)
external
view
returns (bool);
_getValidatorId
Gets the validator ID for associated CL pubkey
function _getValidatorId(bytes memory pubkey) internal pure returns (bytes32);
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | The CL pubkey of validator |
addValidators
function addValidators(
ValidatorStorage storage $,
address distributor,
ValidatorTypes.Validator[] memory _validators
) external;
removeValidators
function removeValidators(
ValidatorStorage storage $,
address distributor,
bytes[] memory _pubkeys
) external;
replaceValidator
function replaceValidator(
ValidatorStorage storage $,
address distributor,
bytes calldata _current,
bytes calldata _new
) external;
queueBoosts
function queueBoosts(
ValidatorStorage storage $,
address bgt,
address ibgt,
bytes[] memory _pubkeys,
uint128[] memory _amts
) external;
cancelBoosts
function cancelBoosts(
ValidatorStorage storage $,
address bgt,
bytes[] memory _pubkeys,
uint128[] memory _amts
) external;
activateBoosts
function activateBoosts(
ValidatorStorage storage $,
address bgt,
bytes[] memory _pubkeys
) external;
queueDropBoosts
function queueDropBoosts(
ValidatorStorage storage $,
address bgt,
bytes[] memory _pubkeys,
uint128[] memory _amts
) external;
cancelDropBoosts
function cancelDropBoosts(
ValidatorStorage storage $,
address bgt,
bytes[] memory _pubkeys,
uint128[] memory _amts
) external;
dropBoosts
function dropBoosts(
ValidatorStorage storage $,
address bgt,
bytes[] memory _pubkeys
) external;
infraredValidators
function infraredValidators(ValidatorStorage storage $, address distributor)
external
view
returns (ValidatorTypes.Validator[] memory validators);
numInfraredValidators
function numInfraredValidators(ValidatorStorage storage $)
external
view
returns (uint256);
_getValidatorAddress
function _getValidatorAddress(
ValidatorStorage storage,
address distributor,
bytes memory pubkey
) internal view returns (address);
Structs
ValidatorStorage
struct ValidatorStorage {
EnumerableSet.Bytes32Set validatorIds;
mapping(bytes32 => bytes) validatorPubkeys;
}
ValidatorTypes
Structs
Validator
Validator information for validator set
struct Validator {
bytes pubkey;
address addr;
}
VaultManagerLib
Functions
notPaused
Ensures that new vaults can only be registered while the register vaults are not paused
modifier notPaused(VaultStorage storage $);
registerVault
Registers a new vault for a specific asset.
function registerVault(VaultStorage storage $, address asset)
external
notPaused($)
returns (address);
setVaultRegistrationPauseStatus
Sets new vault registration paused or not
function setVaultRegistrationPauseStatus(VaultStorage storage $, bool pause)
external;
Parameters
Name | Type | Description |
---|---|---|
$ | VaultStorage | |
pause | bool | True to pause, False to un pause |
toggleVault
Toggles the pause status of a specific vault.
function toggleVault(VaultStorage storage $, address asset) external;
updateWhitelistedRewardTokens
Updates the whitelist status of a reward token.
function updateWhitelistedRewardTokens(
VaultStorage storage $,
address token,
bool whitelisted
) external;
addReward
function addReward(
VaultStorage storage $,
address _stakingToken,
address _rewardsToken,
uint256 _rewardsDuration
) external;
addIncentives
function addIncentives(
VaultStorage storage $,
address _stakingToken,
address _rewardsToken,
uint256 _amount
) external;
updateRewardsDuration
Updates the global rewards duration for new vaults.
function updateRewardsDuration(VaultStorage storage $, uint256 newDuration)
external;
isWhitelisted
Checks if a token is whitelisted as a reward token.
function isWhitelisted(VaultStorage storage $, address token)
public
view
returns (bool);
recoverERC20FromVault
function recoverERC20FromVault(
VaultStorage storage $,
address _asset,
address _to,
address _token,
uint256 _amount
) external;
updateRewardsDurationForVault
function updateRewardsDurationForVault(
VaultStorage storage $,
address _stakingToken,
address _rewardsToken,
uint256 _rewardsDuration
) external;
claimLostRewardsOnVault
function claimLostRewardsOnVault(VaultStorage storage $, address _asset)
external;
Structs
VaultStorage
struct VaultStorage {
bool pausedVaultRegistration;
mapping(address => IInfraredVault) vaultRegistry;
EnumerableSet.AddressSet whitelistedRewardTokens;
uint256 rewardsDuration;
}
BribeCollector
Inherits: InfraredUpgradeable, IBribeCollector
The Bribe Collector contract is responsible for collecting bribes from Berachain rewards vaults and auctioning them for a Payout token which then is distributed among Infrared validators.
This contract is forked from Berachain POL which is forked from Uniswap V3 Factory Owner contract. https://github.com/uniswapfoundation/UniStaker/blob/main/src/V3FactoryOwner.sol
State Variables
payoutToken
Token used for fee payments when claiming bribes
address public payoutToken;
payoutAmount
The amount of payout token that is required to claim POL bribes for all tokens
This works as first come first serve basis. whoever pays this much amount of the payout amount first will get the fees
uint256 public payoutAmount;
Functions
constructor
constructor(address _infrared) InfraredUpgradeable(_infrared);
initialize
function initialize(address _gov, address _payoutToken, uint256 _payoutAmount)
external
initializer;
setPayoutAmount
Update the payout amount to a new value. Must be called by governor
function setPayoutAmount(uint256 _newPayoutAmount) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_newPayoutAmount | uint256 | The value that will be the new payout amount |
claimFees
Claims accumulated bribes in exchange for payout token
Caller must approve payoutAmount of payout token to this contract.
function claimFees(
address _recipient,
address[] calldata _feeTokens,
uint256[] calldata _feeAmounts
) external;
Parameters
Name | Type | Description |
---|---|---|
_recipient | address | The Address to receive claimed tokens |
_feeTokens | address[] | Array of token addresses to claim |
_feeAmounts | uint256[] | Array of amounts to claim for each fee token |
Infrared
Inherits: InfraredUpgradeable, IInfrared
Provides core functionalities for managing validators, vaults, and reward distribution in the Infrared protocol.
Serves as the main entry point for interacting with the Infrared protocol
The contract is upgradeable, ensuring flexibility for governance-led upgrades and chain compatibility.
State Variables
_bgt
The BGT token contract reference
Immutable IBerachainBGT instance of the BGT token
IBerachainBGT internal _bgt;
ibgt
The InfraredBGT liquid staked token
InfraredBGT public ibgt;
rewardsFactory
The Berachain rewards vault factory address
IBerachainRewardsVaultFactory public rewardsFactory;
chef
The Berachain chef contract for distributing validator rewards
IBeraChef public chef;
wbera
Wrapped bera
IWBERA public wbera;
honey
Honey ERC20 token
ERC20 public honey;
collector
bribe collector contract
IBribeCollector public collector;
distributor
Infrared distributor for BGT rewards to validators
IInfraredDistributor public distributor;
voter
IRED voter
IVoter public voter;
ibera
collects all iBERA realted fees and revenue
IInfraredBERA public ibera;
red
The RED token
IRED public red;
ibgtVault
The InfraredBGT vault
IInfraredVault public ibgtVault;
VALIDATOR_STORAGE_LOCATION
Upgradeable ERC-7201 storage for Validator lib
keccak256(abi.encode(uint256(keccak256(bytes("infrared.validatorStorage"))) - 1)) & ~bytes32(uint256(0xff));
bytes32 public constant VALIDATOR_STORAGE_LOCATION =
0x8ea5a3cc3b9a6be40b16189aeb1b6e6e61492e06efbfbe10619870b5bc1cc500;
VAULT_STORAGE_LOCATION
Upgradeable ERC-7201 storage for Vault lib
keccak256(abi.encode(uint256(keccak256(bytes("infrared.vaultStorage"))) - 1)) & ~bytes32(uint256(0xff));
bytes32 public constant VAULT_STORAGE_LOCATION =
0x1bb2f1339407e6d63b93b8b490a9d43c5651f6fc4327c66addd5939450742a00;
REWARDS_STORAGE_LOCATION
Upgradeable ERC-7201 storage for Rewards lib
keccak256(abi.encode(uint256(keccak256(bytes("infrared.rewardsStorage"))) - 1)) & ~bytes32(uint256(0xff));
bytes32 public constant REWARDS_STORAGE_LOCATION =
0xad12e6d08cc0150709acd6eed0bf697c60a83227922ab1d254d1ca4d3072ca00;
Functions
_validatorStorage
function _validatorStorage()
internal
pure
returns (ValidatorManagerLib.ValidatorStorage storage vs);
_vaultStorage
function _vaultStorage()
internal
pure
returns (VaultManagerLib.VaultStorage storage vs);
_rewardsStorage
function _rewardsStorage()
internal
pure
returns (RewardsLib.RewardsStorage storage rs);
onlyCollector
Ensures that only the collector contract can call the function Reverts if the caller is not the collector
modifier onlyCollector();
constructor
constructor() InfraredUpgradeable(address(0));
initialize
function initialize(InitializationData calldata data) external initializer;
_validateInitializationData
function _validateInitializationData(InitializationData memory data)
internal
pure;
_initializeCoreContracts
function _initializeCoreContracts(InitializationData memory data) internal;
registerVault
Registers a new vault for a given asset
Infrared.sol must be admin over MINTER_ROLE on InfraredBGT to grant minter role to deployed vault
Note: emits: NewVault with the caller, asset address, and new vault address.
function registerVault(address _asset)
external
returns (IInfraredVault vault);
Parameters
Name | Type | Description |
---|---|---|
_asset | address | The address of the asset, such as a specific LP token |
Returns
Name | Type | Description |
---|---|---|
vault | IInfraredVault | The address of the newly created InfraredVault contract |
addReward
Adds a new reward token to a specific staking vault
Only callable by governance when contract is initialized
Note: error: ZeroAmount if _rewardsDuration is 0
function addReward(
address _stakingToken,
address _rewardsToken,
uint256 _rewardsDuration
) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_stakingToken | address | The address of the staking token associated with the vault |
_rewardsToken | address | The address of the token to be added as a reward |
_rewardsDuration | uint256 | The duration period for the rewards distribution, in seconds |
addIncentives
Adds reward incentives to a specific staking vault
Transfers reward tokens from caller to this contract, then notifies vault of new rewards
Notes:
-
error: ZeroAmount if _amount is 0
-
access: Callable when contract is initialized
-
security: Requires caller to have approved this contract to spend _rewardsToken
function addIncentives(
address _stakingToken,
address _rewardsToken,
uint256 _amount
) external;
Parameters
Name | Type | Description |
---|---|---|
_stakingToken | address | The address of the staking token associated with the vault |
_rewardsToken | address | The address of the token being added as incentives |
_amount | uint256 | The amount of reward tokens to add as incentives |
updateWhiteListedRewardTokens
Updates the whitelist status of a reward token
function updateWhiteListedRewardTokens(address _token, bool _whitelisted)
external
onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_token | address | The address of the token to whitelist or remove from whitelist |
_whitelisted | bool | A boolean indicating if the token should be whitelisted |
updateRewardsDuration
Sets the new duration for reward distributions in InfraredVaults
Only callable by governance
function updateRewardsDuration(uint256 _rewardsDuration)
external
onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_rewardsDuration | uint256 | The new reward duration period, in seconds |
updateRewardsDurationForVault
Updates the rewards duration for a specific reward token on a specific vault
Only callable by governance
function updateRewardsDurationForVault(
address _stakingToken,
address _rewardsToken,
uint256 _rewardsDuration
) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_stakingToken | address | The address of the staking asset associated with the vault |
_rewardsToken | address | The address of the reward token to update the duration for |
_rewardsDuration | uint256 | The new reward duration period, in seconds |
toggleVault
Pauses staking functionality on a specific vault
Only callable by governance, will revert if vault doesn't exist
function toggleVault(address _asset) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_asset | address | The address of the staking asset associated with the vault to pause |
claimLostRewardsOnVault
Claims lost rewards on a specific vault
Only callable by governance, will revert if vault doesn't exist
function claimLostRewardsOnVault(address _asset) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_asset | address | The address of the staking asset associated with the vault to claim lost rewards on |
recoverERC20
Recovers ERC20 tokens sent accidentally to the contract
function recoverERC20(address _to, address _token, uint256 _amount)
external
onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_to | address | The address to receive the recovered tokens |
_token | address | The address of the token to recover |
_amount | uint256 | The amount of the token to recover |
recoverERC20FromVault
Recover ERC20 tokens from a vault.
function recoverERC20FromVault(
address _asset,
address _to,
address _token,
uint256 _amount
) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_asset | address | address The address of the staking asset that the vault is for. |
_to | address | address The address to send the tokens to. |
_token | address | address The address of the token to recover. |
_amount | uint256 | uint256 The amount of the token to recover. |
delegateBGT
Delegates BGT votes to _delegatee
address.
function delegateBGT(address _delegatee) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_delegatee | address | address The address to delegate votes to |
updateInfraredBERABribesWeight
Updates the weight for iBERA bribes
function updateInfraredBERABribesWeight(uint256 _weight)
external
onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_weight | uint256 | uint256 The weight value |
updateFee
Updates the fee rate charged on different harvest functions
Fee rate in units of 1e6 or hundredths of 1 bip
function updateFee(ConfigTypes.FeeType _t, uint256 _fee)
external
onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_t | ConfigTypes.FeeType | FeeType The fee type |
_fee | uint256 | uint256 The fee rate to update to |
claimProtocolFees
Claims accumulated protocol fees in contract
function claimProtocolFees(address _to, address _token, uint256 _amount)
external
onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_to | address | address The recipient of the fees |
_token | address | address The token to claim fees in |
_amount | uint256 | uint256 The amount of accumulated fees to claim |
setIBGT
Sets the address of the iBGT contract
Infrared must be granted MINTER_ROLE on IBGT to set the address
function setIBGT(address _ibgt) external;
Parameters
Name | Type | Description |
---|---|---|
_ibgt | address | The address of the iBGT contract |
setRed
Sets the address of the RED contract
Infrared must be granted MINTER_ROLE on RED to set the address
function setRed(address _red) external;
Parameters
Name | Type | Description |
---|---|---|
_red | address | The address of the RED contract |
updateRedMintRate
Updates the mint rate for RED
function updateRedMintRate(uint256 _redMintRate) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_redMintRate | uint256 | The new mint rate for RED |
chargedFeesOnRewards
function chargedFeesOnRewards(
uint256 _amt,
uint256 _feeTotal,
uint256 _feeProtocol
)
public
view
returns (uint256 amtRecipient, uint256 amtVoter, uint256 amtProtocol);
harvestBase
Claims all the BGT base and commission rewards minted to this contract for validators.
function harvestBase() public;
harvestVault
Claims all the BGT rewards for the vault associated with the given staking token.
function harvestVault(address _asset) external;
Parameters
Name | Type | Description |
---|---|---|
_asset | address | address The address of the staking asset that the vault is for. |
harvestBribes
Claims all the bribes rewards in the contract forwarded from Berachain POL.
function harvestBribes(address[] calldata _tokens) external;
Parameters
Name | Type | Description |
---|---|---|
_tokens | address[] | address[] memory The addresses of the tokens to harvest in the contract. |
collectBribes
Collects bribes from bribe collector and distributes to wiBERA and iBGT Infrared vaults.
function collectBribes(address _token, uint256 _amount)
external
onlyCollector;
harvestOperatorRewards
Credits all accumulated rewards to the operator
function harvestOperatorRewards() public;
harvestBoostRewards
Claims all the BGT staker rewards from boosting validators.
Sends rewards to iBGT vault.
function harvestBoostRewards() external;
addValidators
Adds validators to the set of InfraredValidators
.
function addValidators(ValidatorTypes.Validator[] calldata _validators)
external
onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_validators | ValidatorTypes.Validator[] | Validator[] memory The validators to add. |
removeValidators
Removes validators from the set of InfraredValidators
.
function removeValidators(bytes[] calldata _pubkeys) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_pubkeys | bytes[] | bytes[] memory The pubkeys of the validators to remove. |
replaceValidator
Replaces a validator in the set of InfraredValidators
.
function replaceValidator(bytes calldata _current, bytes calldata _new)
external
onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_current | bytes | bytes The pubkey of the validator to replace. |
_new | bytes | bytes The new validator pubkey. |
queueNewCuttingBoard
Queues a new cutting board on BeraChef for reward weight distribution for validator
function queueNewCuttingBoard(
bytes calldata _pubkey,
uint64 _startBlock,
IBeraChef.Weight[] calldata _weights
) external onlyKeeper;
Parameters
Name | Type | Description |
---|---|---|
_pubkey | bytes | bytes The pubkey of the validator to queue the cutting board for |
_startBlock | uint64 | uint64 The start block for reward weightings |
_weights | IBeraChef.Weight[] | IBeraChef.Weight[] calldata The weightings used when distributor calls chef to distribute validator rewards |
queueBoosts
Queue _amts
of tokens to _validators
for boosts.
function queueBoosts(bytes[] calldata _pubkeys, uint128[] calldata _amts)
external
onlyKeeper;
Parameters
Name | Type | Description |
---|---|---|
_pubkeys | bytes[] | bytes[] memory The pubkeys of the validators to queue boosts for. |
_amts | uint128[] | uint128[] memory The amount of BGT to boost with. |
cancelBoosts
Removes _amts
from previously queued boosts to _validators
.
_pubkeys
need not be in the current validator set in case just removed but need to cancel.
function cancelBoosts(bytes[] calldata _pubkeys, uint128[] calldata _amts)
external
onlyKeeper;
Parameters
Name | Type | Description |
---|---|---|
_pubkeys | bytes[] | bytes[] memory The pubkeys of the validators to remove boosts for. |
_amts | uint128[] | uint128[] memory The amounts of BGT to remove from the queued boosts. |
activateBoosts
Activates queued boosts for _pubkeys
.
function activateBoosts(bytes[] calldata _pubkeys) external;
Parameters
Name | Type | Description |
---|---|---|
_pubkeys | bytes[] | bytes[] memory The pubkeys of the validators to activate boosts for. |
queueDropBoosts
Queues a drop boost of the validators removing an amount of BGT for sender.
Reverts if user
does not have enough boosted balance to cover amount.
function queueDropBoosts(bytes[] calldata _pubkeys, uint128[] calldata _amts)
external
onlyKeeper;
Parameters
Name | Type | Description |
---|---|---|
_pubkeys | bytes[] | |
_amts | uint128[] |
cancelDropBoosts
Cancels a queued drop boost of the validator removing an amount of BGT for sender.
function cancelDropBoosts(bytes[] calldata _pubkeys, uint128[] calldata _amts)
external
onlyKeeper;
Parameters
Name | Type | Description |
---|---|---|
_pubkeys | bytes[] | |
_amts | uint128[] |
dropBoosts
Drops an amount of BGT from an existing boost of validators by user.
function dropBoosts(bytes[] calldata _pubkeys) external;
Parameters
Name | Type | Description |
---|---|---|
_pubkeys | bytes[] |
infraredValidators
Gets the set of infrared validator pubkeys.
function infraredValidators()
public
view
virtual
returns (ValidatorTypes.Validator[] memory validators);
Returns
Name | Type | Description |
---|---|---|
validators | ValidatorTypes.Validator[] | Validator[] memory The set of infrared validators. |
numInfraredValidators
Gets the number of infrared validators in validator set.
function numInfraredValidators() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | num uint256 The number of infrared validators in validator set. |
isInfraredValidator
Checks if a validator is an infrared validator.
function isInfraredValidator(bytes calldata _validator)
public
view
returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_validator | bytes |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | _isValidator bool Whether the validator is an infrared validator. |
getBGTBalance
Gets the BGT balance for this contract
function getBGTBalance() public view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | bgtBalance The BGT balance held by this address |
whitelistedRewardTokens
Mapping of tokens that are whitelisted to be used as rewards or accepted as bribes
serves as central source of truth for whitelisted reward tokens for all Infrared contracts
function whitelistedRewardTokens(address token) public view returns (bool);
vaultRegistry
Mapping of staking token addresses to their corresponding InfraredVault
Each staking token can only have one vault
function vaultRegistry(address _stakingToken)
public
view
returns (IInfraredVault vault);
setVaultRegistrationPauseStatus
Sets new vault registration paused or not
function setVaultRegistrationPauseStatus(bool pause) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
pause | bool | True to pause, False to un pause |
rewardsDuration
The rewards duration
Used as gloabl variabel to set the rewards duration for all new reward tokens on InfraredVaults
function rewardsDuration() public view returns (uint256 duration);
Returns
Name | Type | Description |
---|---|---|
duration | uint256 | uint256 The reward duration period, in seconds |
fees
Protocol fee rates to charge for various harvest function distributions
function fees(uint256 t) public view override returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
t | uint256 |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint256 The fee rate |
protocolFeeAmounts
The unclaimed Infrared protocol fees of token accumulated by contract
function protocolFeeAmounts(address _token) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_token | address |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint256 The amount of accumulated fees |
receive
receive() external payable;
Structs
InitializationData
struct InitializationData {
address _gov;
address _keeper;
address __bgt;
address _rewardsFactory;
address _chef;
address payable _wbera;
address _honey;
address _collector;
address _distributor;
address _voter;
address _iBERA;
uint256 _rewardsDuration;
}
InfraredBGT
Inherits: ERC20PresetMinterPauser
This contract is the InfraredBGT token.
State Variables
bgt
address public immutable bgt;
Functions
constructor
constructor(address _bgt, address _admin, address _minter, address _pauser)
ERC20PresetMinterPauser("Infrared BGT", "iBGT", _admin, _minter, _pauser);
Errors
ZeroAddress
error ZeroAddress();
InfraredDistributor
Inherits: InfraredUpgradeable, IInfraredDistributor
A contract for distributing rewards in a single ERC20 token (iBERA) to validators
State Variables
token
Token used for reward distributions
ERC20 public token;
amountsCumulative
Tracks reward amount accumulation per validator
uint256 public amountsCumulative;
_snapshots
mapping(bytes32 pubkeyHash => Snapshot) internal _snapshots;
_validators
mapping(bytes32 pubkeyHash => address) internal _validators;
Functions
constructor
constructor(address _infrared) InfraredUpgradeable(_infrared);
initialize
function initialize(address _gov, address _token) external initializer;
add
Register new validator for rewards
Only callable by Infrared contract
Notes:
-
access-control: Requires INFRARED_ROLE
-
error: ValidatorAlreadyExists if validator already registered
function add(bytes calldata pubkey, address validator) external onlyInfrared;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | Validator's public key |
validator | address | Address authorized to claim rewards |
remove
Removes validator from reward-eligible set
Only callable by Infrared contract
Note: access-control: Requires INFRARED_ROLE
function remove(bytes calldata pubkey) external onlyInfrared;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | Validator's public key |
purge
Purges validator from registry completely
Only possible after all rewards are claimed
Note: error: ClaimableRewardsExist if unclaimed rewards remain
function purge(bytes calldata pubkey) external;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | Validator's public key |
notifyRewardAmount
Distributes new commission rewards to validator set
Note: error: ZeroAmount if amount is 0
function notifyRewardAmount(uint256 amount) external;
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | Amount to distribute equally among validators |
claim
Claims outstanding commission rewards
Note: error: InvalidValidator if caller not authorized
function claim(bytes calldata pubkey, address recipient) external;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | Validator's public key |
recipient | address | Address to receive the claimed rewards |
getSnapshot
Get validator's reward snapshots
Returns (0,0) if validator doesn't exist
function getSnapshot(bytes calldata pubkey)
external
view
returns (uint256 amountCumulativeLast, uint256 amountCumulativeFinal);
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | Validator's public key |
Returns
Name | Type | Description |
---|---|---|
amountCumulativeLast | uint256 | Last claimed accumulator value |
amountCumulativeFinal | uint256 | Final accumulator value if removed |
getValidator
Get validator's registered claim address
function getValidator(bytes calldata pubkey) external view returns (address);
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | Validator's public key |
Returns
Name | Type | Description |
---|---|---|
<none> | address | Address authorized to claim validator rewards |
InfraredUpgradeable
Inherits: Upgradeable
This contract provides base upgradeability functionality for Infrared.
State Variables
infrared
Infrared coordinator contract
IInfrared public immutable infrared;
Functions
onlyInfrared
modifier onlyInfrared();
constructor
constructor(address _infrared);
__InfraredUpgradeable_init
function __InfraredUpgradeable_init() internal onlyInitializing;
InfraredVault
Inherits: MultiRewards, IInfraredVault
This contract is the vault for staking tokens, and receiving rewards from the Proof of Liquidity protocol.
This contract uses the MultiRewards contract to distribute rewards to vault stakers, this is taken from curve.fi. (inspired by Synthetix).
Does not support staking tokens with non-standard ERC20 transfer tax behavior.
State Variables
MAX_NUM_REWARD_TOKENS
Maximum number of reward tokens that can be supported
Limited to prevent gas issues with reward calculations
uint256 public constant MAX_NUM_REWARD_TOKENS = 10;
infrared
The infrared contract address acts a vault factory and coordinator
address public immutable infrared;
rewardsVault
IBerachainRewardsVault public immutable rewardsVault;
Functions
onlyInfrared
Modifier to check that the caller is infrared contract
modifier onlyInfrared();
constructor
constructor(address _stakingToken, uint256 _rewardsDuration)
MultiRewards(_stakingToken);
_createRewardsVaultIfNecessary
Gets or creates the berachain rewards vault for given staking token
function _createRewardsVaultIfNecessary(
address _infrared,
address _stakingToken
) private returns (IBerachainRewardsVault);
Parameters
Name | Type | Description |
---|---|---|
_infrared | address | The address of Infrared |
_stakingToken | address | The address of the staking token for this vault |
Returns
Name | Type | Description |
---|---|---|
<none> | IBerachainRewardsVault | The address of the berachain rewards vault |
onStake
Transfers to berachain low level module on staking of LP tokens with the vault after transferring tokens in
function onStake(uint256 amount) internal override;
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | The amount of staking token transferred in to the contract |
onWithdraw
Redeems from berachain low level module on withdraw of LP tokens from the vault before transferring tokens out
function onWithdraw(uint256 amount) internal override;
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | The amount of staking token transferred out of the contract |
onReward
hook called after the reward is claimed to harvest the rewards from the berachain rewards vault
function onReward() internal override;
updateRewardsDuration
Updates reward duration for a specific reward token
Only callable by Infrared contract
Note: access-control: Requires INFRARED_ROLE
function updateRewardsDuration(address _rewardsToken, uint256 _rewardsDuration)
external
onlyInfrared;
Parameters
Name | Type | Description |
---|---|---|
_rewardsToken | address | The address of the reward token |
_rewardsDuration | uint256 | The new duration in seconds |
togglePause
Toggles pause state of the vault
Affects all vault operations when paused
Note: access-control: Requires INFRARED_ROLE
function togglePause() external onlyInfrared;
addReward
Adds a new reward token to the vault
Cannot exceed maximum number of reward tokens
Note: access-control: Requires INFRARED_ROLE
function addReward(address _rewardsToken, uint256 _rewardsDuration)
external
onlyInfrared;
Parameters
Name | Type | Description |
---|---|---|
_rewardsToken | address | The reward token to add |
_rewardsDuration | uint256 | The reward period duration |
notifyRewardAmount
Notifies the vault of newly added rewards
Updates internal reward rate calculations
function notifyRewardAmount(address _rewardToken, uint256 _reward)
external
onlyInfrared;
Parameters
Name | Type | Description |
---|---|---|
_rewardToken | address | The reward token address |
_reward | uint256 | The amount of new rewards |
recoverERC20
Recovers accidentally sent tokens
Cannot recover staking token or active reward tokens
function recoverERC20(address _to, address _token, uint256 _amount)
external
onlyInfrared;
Parameters
Name | Type | Description |
---|---|---|
_to | address | The address to receive the recovered tokens |
_token | address | The token to recover |
_amount | uint256 | The amount to recover |
getAllRewardTokens
Returns all reward tokens
function getAllRewardTokens() external view returns (address[] memory);
Returns
Name | Type | Description |
---|---|---|
<none> | address[] | An array of reward token addresses |
getAllRewardsForUser
Returns all rewards for a user
function getAllRewardsForUser(address _user)
external
view
returns (UserReward[] memory);
Parameters
Name | Type | Description |
---|---|---|
_user | address | The address of the user |
Returns
Name | Type | Description |
---|---|---|
<none> | UserReward[] | An array of UserReward structs |
MultiRewards
Inherits: ReentrancyGuard, Pausable, IMultiRewards
Fork of https://github.com/curvefi/multi-rewards with hooks on stake/withdraw of LP tokens
State Variables
stakingToken
The token that users stake to earn rewards
This is the base token that users deposit into the contract
ERC20 public immutable stakingToken;
rewardData
Stores reward-related data for each reward token
Maps reward token addresses to their Reward struct containing distribution parameters
mapping(address => Reward) public override rewardData;
rewardTokens
Array of all reward token addresses
Used to iterate through all reward tokens when updating or claiming rewards
address[] public rewardTokens;
userRewardPerTokenPaid
Tracks the reward per token paid to each user for each reward token
Maps user address to reward token address to amount already paid Used to calculate new rewards since last claim
mapping(address => mapping(address => uint256)) public userRewardPerTokenPaid;
rewards
Tracks the unclaimed rewards for each user for each reward token
Maps user address to reward token address to unclaimed amount
mapping(address => mapping(address => uint256)) public rewards;
_totalSupply
The total amount of staking tokens in the contract
Used to calculate rewards per token
uint256 internal _totalSupply;
_balances
Maps user addresses to their staked token balance
Internal mapping used to track individual stake amounts
mapping(address => uint256) internal _balances;
Functions
updateReward
Updates the reward for the given account before executing the function body.
modifier updateReward(address account);
Parameters
Name | Type | Description |
---|---|---|
account | address | address The account to update the reward for. |
constructor
Constructs the MultiRewards contract.
constructor(address _stakingToken);
Parameters
Name | Type | Description |
---|---|---|
_stakingToken | address | address The token that users stake to earn rewards. |
totalSupply
Returns the total amount of staked tokens in the contract
function totalSupply() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint256 The total supply of staked tokens |
balanceOf
Returns the balance of staked tokens for the given account
function balanceOf(address account) external view returns (uint256 _balance);
Parameters
Name | Type | Description |
---|---|---|
account | address | The account to get the balance for |
Returns
Name | Type | Description |
---|---|---|
_balance | uint256 | The balance of staked tokens |
lastTimeRewardApplicable
Calculates the last time reward is applicable for a given rewards token
function lastTimeRewardApplicable(address _rewardsToken)
public
view
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_rewardsToken | address | The address of the rewards token |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The timestamp when the reward was last applicable |
rewardPerToken
Calculates the reward per token for a given rewards token
function rewardPerToken(address _rewardsToken) public view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_rewardsToken | address | The address of the rewards token |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The reward amount per token |
earned
Calculates the earned rewards for a given account and rewards token
function earned(address account, address _rewardsToken)
public
view
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
account | address | The address of the account |
_rewardsToken | address | The address of the rewards token |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The amount of rewards earned |
getRewardForDuration
Calculates the total reward for the duration of a given rewards token
function getRewardForDuration(address _rewardsToken)
external
view
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_rewardsToken | address | The address of the rewards token |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The total reward amount for the duration of a given rewards token |
stake
Stakes tokens into the contract
Transfers amount
of staking tokens from the user to this contract
function stake(uint256 amount)
external
nonReentrant
whenNotPaused
updateReward(msg.sender);
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | The amount of tokens to stake |
onStake
Hook called in the stake function after transfering staking token in
function onStake(uint256 amount) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | The amount of staking token transferred in to the contract |
withdraw
Withdraws staked tokens from the contract
Transfers amount
of staking tokens back to the user
function withdraw(uint256 amount)
public
nonReentrant
updateReward(msg.sender);
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | The amount of tokens to withdraw |
onWithdraw
Hook called in withdraw function before transferring staking token out
function onWithdraw(uint256 amount) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | The amount of staking token to be transferred out of the contract |
getRewardForUser
Claims all pending rewards for a specified user
Iterates through all reward tokens and transfers any accrued rewards to the user
function getRewardForUser(address _user)
public
nonReentrant
updateReward(_user);
Parameters
Name | Type | Description |
---|---|---|
_user | address | The address of the user to claim rewards for |
onReward
Hook called in getRewardForUser function
function onReward() internal virtual;
getReward
Claims all pending rewards for the caller
Transfers all accrued rewards to the caller
function getReward() public;
exit
Withdraws all staked tokens and claims pending rewards
Combines withdraw and getReward operations
function exit() external;
_addReward
Adds a reward token to the contract.
function _addReward(
address _rewardsToken,
address _rewardsDistributor,
uint256 _rewardsDuration
) internal;
Parameters
Name | Type | Description |
---|---|---|
_rewardsToken | address | address The address of the reward token. |
_rewardsDistributor | address | address The address of the rewards distributor. |
_rewardsDuration | uint256 | uint256 The duration of the rewards period. |
_notifyRewardAmount
Notifies the contract that reward tokens is being sent to the contract.
function _notifyRewardAmount(address _rewardsToken, uint256 reward)
internal
whenNotPaused
updateReward(address(0));
Parameters
Name | Type | Description |
---|---|---|
_rewardsToken | address | address The address of the reward token. |
reward | uint256 | uint256 The amount of reward tokens is being sent to the contract. |
_recoverERC20
Recovers ERC20 tokens sent to the contract.
Added to support recovering LP Rewards from other systems such as BAL to be distributed to holders
function _recoverERC20(address to, address tokenAddress, uint256 tokenAmount)
internal;
Parameters
Name | Type | Description |
---|---|---|
to | address | address The address to send the tokens to. |
tokenAddress | address | address The address of the token to withdraw. |
tokenAmount | uint256 | uint256 The amount of tokens to withdraw. |
_setRewardsDuration
Updates the reward duration for a reward token.
function _setRewardsDuration(address _rewardsToken, uint256 _rewardsDuration)
internal;
Parameters
Name | Type | Description |
---|---|---|
_rewardsToken | address | address The address of the reward token. |
_rewardsDuration | uint256 | uint256 The new duration of the rewards period. |
RED
Inherits: ERC20PresetMinterPauser
This contract is the RED token.
State Variables
ibgt
address public immutable ibgt;
infrared
address public immutable infrared;
Functions
constructor
constructor(
address _ibgt,
address _infrared,
address _admin,
address _minter,
address _pauser
)
ERC20PresetMinterPauser(
"Infared Governance Token",
"RED",
_admin,
_minter,
_pauser
);
Errors
ZeroAddress
error ZeroAddress();
WrappedVault
Inherits: ERC4626
A wrapper vault built on ERC4626 to facilitate staking operations and reward distribution through the Infrared protocol. Each staking token has a corresponding wrapped vault.
deploy 1 wrapped vault per staking token
State Variables
rewardDistributor
Address of the reward distributor, typically a multisig.
address public immutable rewardDistributor;
iVault
Instance of the associated InfraredVault for staking.
InfraredVault public immutable iVault;
deadShares
Inflation attack prevention
uint256 internal constant deadShares = 1e3;
Functions
constructor
Initializes a new WrappedVault contract for a specific staking token.
constructor(
address _rewardDistributor,
address _infrared,
address _stakingToken,
string memory _name,
string memory _symbol
) ERC4626(ERC20(_stakingToken), _name, _symbol);
Parameters
Name | Type | Description |
---|---|---|
_rewardDistributor | address | Address of the reward distributor (e.g., multisig). |
_infrared | address | Address of the Infrared protocol. |
_stakingToken | address | Address of the ERC20 staking token. |
_name | string | Name of the wrapped vault token (ERC4626). |
_symbol | string | Symbol of the wrapped vault token (ERC4626). |
totalAssets
Returns the total assets managed by the wrapped vault.
Overrides the ERC4626 totalAssets
function to integrate with the InfraredVault balance.
function totalAssets() public view virtual override returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The total amount of staking tokens held by the InfraredVault. |
beforeWithdraw
Hook called before withdrawal operations.
This function ensures that the requested amount of staking tokens is withdrawn from the InfraredVault before being transferred to the user.
function beforeWithdraw(uint256 assets, uint256) internal virtual override;
Parameters
Name | Type | Description |
---|---|---|
assets | uint256 | The amount of assets to withdraw. |
<none> | uint256 |
afterDeposit
Hook called after deposit operations.
This function stakes the deposited tokens into the InfraredVault.
function afterDeposit(uint256 assets, uint256) internal virtual override;
Parameters
Name | Type | Description |
---|---|---|
assets | uint256 | The amount of assets being deposited. |
<none> | uint256 |
claimRewards
Claims rewards from the InfraredVault and transfers them to the reward distributor.
Only rewards other than the staking token itself are transferred.
function claimRewards() external;
Events
RewardClaimed
Event emitted when reward tokens claimed
event RewardClaimed(address indexed token, uint256 amount);
Contents
- IBerachainBGT
- IBerachainBGTStaker
- IBribeCollector
- IERC20Mintable
- IInfrared
- IInfraredBERA
- IInfraredBERAClaimor
- IInfraredBERADepositor
- IInfraredBERAFeeReceivor
- IInfraredBERAWithdrawor
- IInfraredBGT
- IInfraredDistributor
- IInfraredUpgradeable
- IInfraredVault
- IMultiRewards
- IRED
- IWBERA
IBerachainBGT
Inherits: IBGT
IBerachainBGTStaker
Inherits: IBGTStaker
Functions
rewardToken
Temp override of interface to include left out reward token
function rewardToken() external view returns (address);
IBribeCollector
Inherits: IPOLErrors
Functions
payoutToken
Token used for fee payments when claiming bribes
function payoutToken() external view returns (address);
Returns
Name | Type | Description |
---|---|---|
<none> | address | Address of the payout token |
payoutAmount
The amount of payout token that is required to claim POL bribes for all tokens
This works as first come first serve basis. whoever pays this much amount of the payout amount first will get the fees
function payoutAmount() external view returns (uint256);
setPayoutAmount
Update the payout amount to a new value. Must be called by governor
function setPayoutAmount(uint256 _newPayoutAmount) external;
Parameters
Name | Type | Description |
---|---|---|
_newPayoutAmount | uint256 | The value that will be the new payout amount |
claimFees
Claims accumulated bribes in exchange for payout token
Caller must approve payoutAmount of payout token to this contract.
function claimFees(
address _recipient,
address[] calldata _feeTokens,
uint256[] calldata _feeAmounts
) external;
Parameters
Name | Type | Description |
---|---|---|
_recipient | address | The Address to receive claimed tokens |
_feeTokens | address[] | Array of token addresses to claim |
_feeAmounts | uint256[] | Array of amounts to claim for each fee token |
Events
PayoutAmountSet
Emitted when the payout amount is updated by the governor
event PayoutAmountSet(
uint256 indexed oldPayoutAmount, uint256 indexed newPayoutAmount
);
Parameters
Name | Type | Description |
---|---|---|
oldPayoutAmount | uint256 | Previous payout amount |
newPayoutAmount | uint256 | New payout amount set |
FeesClaimed
Emitted when the fees are claimed
event FeesClaimed(
address indexed caller,
address indexed recipient,
address indexed feeToken,
uint256 amount
);
Parameters
Name | Type | Description |
---|---|---|
caller | address | Caller of the claimFees function |
recipient | address | The address to which collected POL bribes will be transferred |
feeToken | address | The address of the fee token to collect |
amount | uint256 | The amount of fee token to transfer |
IERC20Mintable
Inherits: IERC20
Functions
MINTER_ROLE
function MINTER_ROLE() external view returns (bytes32);
mint
function mint(address to, uint256 amount) external;
IInfrared
Functions
whitelistedRewardTokens
Checks if a token is a whitelisted reward token
function whitelistedRewardTokens(address _token) external view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_token | address | The address of the token to check |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool True if the token is whitelisted, false otherwise |
vaultRegistry
Returns the infrared vault address for a given staking token
function vaultRegistry(address _asset) external view returns (IInfraredVault);
Parameters
Name | Type | Description |
---|---|---|
_asset | address | The address of the staking asset |
Returns
Name | Type | Description |
---|---|---|
<none> | IInfraredVault | IInfraredVault The vault associated with the asset |
ibgt
The InfraredBGT liquid staked token
function ibgt() external view returns (InfraredBGT);
Returns
Name | Type | Description |
---|---|---|
<none> | InfraredBGT | IInfraredBGT The InfraredBGT token contract address |
rewardsFactory
The Berachain rewards vault factory address
function rewardsFactory()
external
view
returns (IBerachainRewardsVaultFactory);
Returns
Name | Type | Description |
---|---|---|
<none> | IBerachainRewardsVaultFactory | IBerachainRewardsVaultFactory instance of the rewards factory contract address |
chef
The Berachain chef contract for distributing validator rewards
function chef() external view returns (IBeraChef);
Returns
Name | Type | Description |
---|---|---|
<none> | IBeraChef | IBeraChef instance of the BeraChef contract address |
ibgtVault
The InfraredBGT vault
function ibgtVault() external view returns (IInfraredVault);
Returns
Name | Type | Description |
---|---|---|
<none> | IInfraredVault | IInfraredVault instance of the iBGT vault contract address |
protocolFeeAmounts
The unclaimed Infrared protocol fees of token accumulated by contract
function protocolFeeAmounts(address token) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
token | address | address The token address for the accumulated fees |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint256 The amount of accumulated fees |
fees
Protocol fee rates to charge for various harvest function distributions
function fees(uint256 i) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
i | uint256 | The index of the fee rate |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint256 The fee rate |
wbera
Wrapped bera
function wbera() external view returns (IWBERA);
Returns
Name | Type | Description |
---|---|---|
<none> | IWBERA | IWBERA The wbera token contract address |
honey
Honey ERC20 token
function honey() external view returns (ERC20);
Returns
Name | Type | Description |
---|---|---|
<none> | ERC20 | ERC20 The honey token contract address |
collector
bribe collector contract
function collector() external view returns (IBribeCollector);
Returns
Name | Type | Description |
---|---|---|
<none> | IBribeCollector | IBribeCollector The bribe collector contract address |
distributor
Infrared distributor for BGT rewards to validators
function distributor() external view returns (IInfraredDistributor);
Returns
Name | Type | Description |
---|---|---|
<none> | IInfraredDistributor | IInfraredDistributor instance of the distributor contract address |
voter
IRED voter
function voter() external view returns (IVoter);
Returns
Name | Type | Description |
---|---|---|
<none> | IVoter | IVoter instance of the voter contract address |
ibera
collects all iBERA realted fees and revenue
function ibera() external view returns (IInfraredBERA);
Returns
Name | Type | Description |
---|---|---|
<none> | IInfraredBERA | returns IInfraredBERAFeeReceivor instanace of iBeraFeeReceivor |
red
The RED token
function red() external view returns (IRED);
Returns
Name | Type | Description |
---|---|---|
<none> | IRED | IRED instance of the RED token contract address |
rewardsDuration
The rewards duration
Used as gloabl variabel to set the rewards duration for all new reward tokens on InfraredVaults
function rewardsDuration() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint256 The reward duration period, in seconds |
registerVault
Registers a new vault for a given asset
Infrared.sol must be admin over MINTER_ROLE on InfraredBGT to grant minter role to deployed vault
Note: emits: NewVault with the caller, asset address, and new vault address.
function registerVault(address _asset)
external
returns (IInfraredVault vault);
Parameters
Name | Type | Description |
---|---|---|
_asset | address | The address of the asset, such as a specific LP token |
Returns
Name | Type | Description |
---|---|---|
vault | IInfraredVault | The address of the newly created InfraredVault contract |
addReward
Adds a new reward token to a specific staking vault
Only callable by governance when contract is initialized
Notes:
-
error: ZeroAmount if _rewardsDuration is 0
-
error: RewardTokenNotWhitelisted if _rewardsToken is not whitelisted
-
error: NoRewardsVault if vault doesn't exist for _stakingToken
function addReward(
address _stakingToken,
address _rewardsToken,
uint256 _rewardsDuration
) external;
Parameters
Name | Type | Description |
---|---|---|
_stakingToken | address | The address of the staking token associated with the vault |
_rewardsToken | address | The address of the token to be added as a reward |
_rewardsDuration | uint256 | The duration period for the rewards distribution, in seconds |
addIncentives
Adds reward incentives to a specific staking vault
Transfers reward tokens from caller to this contract, then notifies vault of new rewards
Notes:
-
error: ZeroAmount if _amount is 0
-
error: NoRewardsVault if vault doesn't exist for _stakingToken
-
error: RewardTokenNotWhitelisted if reward token hasn't been configured for the vault
-
access: Callable when contract is initialized
-
security: Requires caller to have approved this contract to spend _rewardsToken
function addIncentives(
address _stakingToken,
address _rewardsToken,
uint256 _amount
) external;
Parameters
Name | Type | Description |
---|---|---|
_stakingToken | address | The address of the staking token associated with the vault |
_rewardsToken | address | The address of the token being added as incentives |
_amount | uint256 | The amount of reward tokens to add as incentives |
updateWhiteListedRewardTokens
Updates the whitelist status of a reward token
function updateWhiteListedRewardTokens(address _token, bool _whitelisted)
external;
Parameters
Name | Type | Description |
---|---|---|
_token | address | The address of the token to whitelist or remove from whitelist |
_whitelisted | bool | A boolean indicating if the token should be whitelisted |
updateRewardsDuration
Sets the new duration for reward distributions in InfraredVaults
Only callable by governance
function updateRewardsDuration(uint256 _rewardsDuration) external;
Parameters
Name | Type | Description |
---|---|---|
_rewardsDuration | uint256 | The new reward duration period, in seconds |
updateRewardsDurationForVault
Updates the rewards duration for a specific reward token on a specific vault
Only callable by governance
function updateRewardsDurationForVault(
address _stakingToken,
address _rewardsToken,
uint256 _rewardsDuration
) external;
Parameters
Name | Type | Description |
---|---|---|
_stakingToken | address | The address of the staking asset associated with the vault |
_rewardsToken | address | The address of the reward token to update the duration for |
_rewardsDuration | uint256 | The new reward duration period, in seconds |
toggleVault
Pauses staking functionality on a specific vault
Only callable by governance, will revert if vault doesn't exist
function toggleVault(address _asset) external;
Parameters
Name | Type | Description |
---|---|---|
_asset | address | The address of the staking asset associated with the vault to pause |
claimLostRewardsOnVault
Claims lost rewards on a specific vault
Only callable by governance, will revert if vault doesn't exist
function claimLostRewardsOnVault(address _asset) external;
Parameters
Name | Type | Description |
---|---|---|
_asset | address | The address of the staking asset associated with the vault to claim lost rewards on |
recoverERC20
Recovers ERC20 tokens sent accidentally to the contract
function recoverERC20(address _to, address _token, uint256 _amount) external;
Parameters
Name | Type | Description |
---|---|---|
_to | address | The address to receive the recovered tokens |
_token | address | The address of the token to recover |
_amount | uint256 | The amount of the token to recover |
recoverERC20FromVault
Recover ERC20 tokens from a vault.
function recoverERC20FromVault(
address _asset,
address _to,
address _token,
uint256 _amount
) external;
Parameters
Name | Type | Description |
---|---|---|
_asset | address | address The address of the staking asset that the vault is for. |
_to | address | address The address to send the tokens to. |
_token | address | address The address of the token to recover. |
_amount | uint256 | uint256 The amount of the token to recover. |
delegateBGT
Delegates BGT votes to _delegatee
address.
function delegateBGT(address _delegatee) external;
Parameters
Name | Type | Description |
---|---|---|
_delegatee | address | address The address to delegate votes to |
updateInfraredBERABribesWeight
Updates the weight for iBERA bribes
function updateInfraredBERABribesWeight(uint256 _weight) external;
Parameters
Name | Type | Description |
---|---|---|
_weight | uint256 | uint256 The weight value |
updateFee
Updates the fee rate charged on different harvest functions
Please harvest all assosiated rewards for a given type before updating
Fee rate in units of 1e6 or hundredths of 1 bip
function updateFee(ConfigTypes.FeeType _t, uint256 _fee) external;
Parameters
Name | Type | Description |
---|---|---|
_t | ConfigTypes.FeeType | FeeType The fee type |
_fee | uint256 | uint256 The fee rate to update to |
setRed
Sets the address of the RED contract
Infrared must be granted MINTER_ROLE on RED to set the address
function setRed(address _red) external;
Parameters
Name | Type | Description |
---|---|---|
_red | address | The address of the RED contract |
setIBGT
Sets the address of the iBGT contract
Infrared must be granted MINTER_ROLE on IBGT to set the address
function setIBGT(address _ibgt) external;
Parameters
Name | Type | Description |
---|---|---|
_ibgt | address | The address of the iBGT contract |
updateRedMintRate
Updates the mint rate for RED
function updateRedMintRate(uint256 _redMintRate) external;
Parameters
Name | Type | Description |
---|---|---|
_redMintRate | uint256 | The new mint rate for RED |
claimProtocolFees
Claims accumulated protocol fees in contract
function claimProtocolFees(address _to, address _token, uint256 _amount)
external;
Parameters
Name | Type | Description |
---|---|---|
_to | address | address The recipient of the fees |
_token | address | address The token to claim fees in |
_amount | uint256 | uint256 The amount of accumulated fees to claim |
harvestBase
Claims all the BGT base and commission rewards minted to this contract for validators.
function harvestBase() external;
harvestOperatorRewards
Credits all accumulated rewards to the operator
function harvestOperatorRewards() external;
harvestVault
Claims all the BGT rewards for the vault associated with the given staking token.
function harvestVault(address _asset) external;
Parameters
Name | Type | Description |
---|---|---|
_asset | address | address The address of the staking asset that the vault is for. |
harvestBribes
Claims all the bribes rewards in the contract forwarded from Berachain POL.
function harvestBribes(address[] memory _tokens) external;
Parameters
Name | Type | Description |
---|---|---|
_tokens | address[] | address[] memory The addresses of the tokens to harvest in the contract. |
collectBribes
Collects bribes from bribe collector and distributes to wiBERA and iBGT Infrared vaults.
_token The payout token for the bribe collector.
_amount The amount of payout received from bribe collector.
function collectBribes(address _token, uint256 _amount) external;
harvestBoostRewards
Claims all the BGT staker rewards from boosting validators.
Sends rewards to iBGT vault.
function harvestBoostRewards() external;
addValidators
Adds validators to the set of InfraredValidators
.
function addValidators(ValidatorTypes.Validator[] memory _validators)
external;
Parameters
Name | Type | Description |
---|---|---|
_validators | ValidatorTypes.Validator[] | Validator[] memory The validators to add. |
removeValidators
Removes validators from the set of InfraredValidators
.
function removeValidators(bytes[] memory _pubkeys) external;
Parameters
Name | Type | Description |
---|---|---|
_pubkeys | bytes[] | bytes[] memory The pubkeys of the validators to remove. |
replaceValidator
Replaces a validator in the set of InfraredValidators
.
function replaceValidator(bytes calldata _current, bytes calldata _new)
external;
Parameters
Name | Type | Description |
---|---|---|
_current | bytes | bytes The pubkey of the validator to replace. |
_new | bytes | bytes The new validator pubkey. |
queueBoosts
Queue _amts
of tokens to _validators
for boosts.
function queueBoosts(bytes[] memory _pubkeys, uint128[] memory _amts)
external;
Parameters
Name | Type | Description |
---|---|---|
_pubkeys | bytes[] | bytes[] memory The pubkeys of the validators to queue boosts for. |
_amts | uint128[] | uint128[] memory The amount of BGT to boost with. |
cancelBoosts
Removes _amts
from previously queued boosts to _validators
.
_pubkeys
need not be in the current validator set in case just removed but need to cancel.
function cancelBoosts(bytes[] memory _pubkeys, uint128[] memory _amts)
external;
Parameters
Name | Type | Description |
---|---|---|
_pubkeys | bytes[] | bytes[] memory The pubkeys of the validators to remove boosts for. |
_amts | uint128[] | uint128[] memory The amounts of BGT to remove from the queued boosts. |
activateBoosts
Activates queued boosts for _pubkeys
.
function activateBoosts(bytes[] memory _pubkeys) external;
Parameters
Name | Type | Description |
---|---|---|
_pubkeys | bytes[] | bytes[] memory The pubkeys of the validators to activate boosts for. |
queueDropBoosts
Queues a drop boost of the validators removing an amount of BGT for sender.
Reverts if user
does not have enough boosted balance to cover amount.
function queueDropBoosts(bytes[] calldata pubkeys, uint128[] calldata amounts)
external;
Parameters
Name | Type | Description |
---|---|---|
pubkeys | bytes[] | bytes[] memory The pubkeys of the validators to remove boost from. |
amounts | uint128[] | Amounts of BGT to remove from the queued drop boosts. |
cancelDropBoosts
Cancels a queued drop boost of the validator removing an amount of BGT for sender.
function cancelDropBoosts(bytes[] calldata pubkeys, uint128[] calldata amounts)
external;
Parameters
Name | Type | Description |
---|---|---|
pubkeys | bytes[] | bytes[] memory The pubkeys of the validators to remove boost from. |
amounts | uint128[] | Amounts of BGT to remove from the queued drop boosts. |
dropBoosts
Drops an amount of BGT from an existing boost of validators by user.
function dropBoosts(bytes[] calldata pubkeys) external;
Parameters
Name | Type | Description |
---|---|---|
pubkeys | bytes[] | bytes[] memory The pubkeys of the validators to remove boost from. |
queueNewCuttingBoard
Queues a new cutting board on BeraChef for reward weight distribution for validator
function queueNewCuttingBoard(
bytes calldata _pubkey,
uint64 _startBlock,
IBeraChef.Weight[] calldata _weights
) external;
Parameters
Name | Type | Description |
---|---|---|
_pubkey | bytes | bytes The pubkey of the validator to queue the cutting board for |
_startBlock | uint64 | uint64 The start block for reward weightings |
_weights | IBeraChef.Weight[] | IBeraChef.Weight[] calldata The weightings used when distributor calls chef to distribute validator rewards |
infraredValidators
Gets the set of infrared validator pubkeys.
function infraredValidators()
external
view
returns (ValidatorTypes.Validator[] memory validators);
Returns
Name | Type | Description |
---|---|---|
validators | ValidatorTypes.Validator[] | Validator[] memory The set of infrared validators. |
numInfraredValidators
Gets the number of infrared validators in validator set.
function numInfraredValidators() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | num uint256 The number of infrared validators in validator set. |
isInfraredValidator
Checks if a validator is an infrared validator.
function isInfraredValidator(bytes memory _pubkey)
external
view
returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_pubkey | bytes | bytes The pubkey of the validator to check. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | _isValidator bool Whether the validator is an infrared validator. |
getBGTBalance
Gets the BGT balance for this contract
function getBGTBalance() external view returns (uint256 bgtBalance);
Returns
Name | Type | Description |
---|---|---|
bgtBalance | uint256 | The BGT balance held by this address |
Events
NewVault
Emitted when a new vault is registered
event NewVault(address _sender, address indexed _asset, address indexed _vault);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The address that initiated the vault registration |
_asset | address | The address of the asset for which the vault is registered |
_vault | address | The address of the newly created vault |
VaultRegistrationPauseStatus
Emitted when pause status for new vault registration has changed
event VaultRegistrationPauseStatus(bool pause);
Parameters
Name | Type | Description |
---|---|---|
pause | bool | True if new vault creation is paused |
OperatorRewardsDistributed
Emitted when InfraredBGT tokens are supplied to distributor.
event OperatorRewardsDistributed(
address indexed _ibera, address indexed _distributor, uint256 _amt
);
Parameters
Name | Type | Description |
---|---|---|
_ibera | address | token the rewards are denominated in |
_distributor | address | The address of the distributor receiving the InfraredBGT tokens. |
_amt | uint256 | The amount of WBERA tokens supplied to distributor. |
InfraredBGTSupplied
Emitted when InfraredBGT tokens are supplied to a vault.
event InfraredBGTSupplied(
address indexed _vault, uint256 _ibgtAmt, uint256 _iredAmt
);
Parameters
Name | Type | Description |
---|---|---|
_vault | address | The address of the vault receiving the InfraredBGT and IRED tokens. |
_ibgtAmt | uint256 | The amount of InfraredBGT tokens supplied to vault. |
_iredAmt | uint256 | The amount of IRED tokens supplied to vault as additional reward from protocol. |
RewardSupplied
Emitted when rewards are supplied to a vault.
event RewardSupplied(
address indexed _vault, address indexed _token, uint256 _amt
);
Parameters
Name | Type | Description |
---|---|---|
_vault | address | The address of the vault receiving the reward. |
_token | address | The address of the token being supplied as a reward. |
_amt | uint256 | The amount of the reward token supplied. |
BribeSupplied
Emitted when rewards are supplied to a vault.
event BribeSupplied(
address indexed _recipient, address indexed _token, uint256 _amt
);
Parameters
Name | Type | Description |
---|---|---|
_recipient | address | The address receiving the bribe. |
_token | address | The address of the token being supplied as a bribe reward. |
_amt | uint256 | The amount of the bribe reward token supplied. |
Recovered
Emitted when tokens are recovered from the contract.
event Recovered(address _sender, address indexed _token, uint256 _amount);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The address that initiated the recovery. |
_token | address | The address of the token being recovered. |
_amount | uint256 | The amount of the token recovered. |
RewardTokenNotSupported
Emitted when a reward token is marked as unsupported.
event RewardTokenNotSupported(address _token);
Parameters
Name | Type | Description |
---|---|---|
_token | address | The address of the reward token. |
InfraredBGTUpdated
Emitted when the InfraredBGT token address is updated.
event InfraredBGTUpdated(address _sender, address _oldIbgt, address _newIbgt);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The address that initiated the update. |
_oldIbgt | address | The previous address of the InfraredBGT token. |
_newIbgt | address | The new address of the InfraredBGT token. |
InfraredBGTVaultUpdated
Emitted when the InfraredBGT vault address is updated.
event InfraredBGTVaultUpdated(
address _sender, address _oldIbgtVault, address _newIbgtVault
);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The address that initiated the update. |
_oldIbgtVault | address | The previous address of the InfraredBGT vault. |
_newIbgtVault | address | The new address of the InfraredBGT vault. |
WhiteListedRewardTokensUpdated
Emitted when reward tokens are whitelisted or unwhitelisted.
event WhiteListedRewardTokensUpdated(
address _sender,
address indexed _token,
bool _wasWhitelisted,
bool _isWhitelisted
);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The address that initiated the update. |
_token | address | The address of the token being updated. |
_wasWhitelisted | bool | The previous whitelist status of the token. |
_isWhitelisted | bool | The new whitelist status of the token. |
RewardsDurationUpdated
Emitted when the rewards duration is updated
event RewardsDurationUpdated(
address _sender, uint256 _oldDuration, uint256 _newDuration
);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The address that initiated the update |
_oldDuration | uint256 | The previous rewards duration |
_newDuration | uint256 | The new rewards duration |
IredMintRateUpdated
Emitted when the IRED mint rate per unit InfraredBGT is updated.
event IredMintRateUpdated(
address _sender, uint256 _oldMintRate, uint256 _newMintRate
);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The address that initiated the update. |
_oldMintRate | uint256 | The previous IRED mint rate. |
_newMintRate | uint256 | The new IRED mint rate. |
InfraredBERABribesWeightUpdated
Emitted when a weight is updated.
event InfraredBERABribesWeightUpdated(
address _sender, uint256 _oldWeight, uint256 _newWeight
);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The address that initiated the update. |
_oldWeight | uint256 | The old value of the weight. |
_newWeight | uint256 | The new value of the weight. |
FeeUpdated
Emitted when protocol fee rate is updated.
event FeeUpdated(
address _sender,
ConfigTypes.FeeType _feeType,
uint256 _oldFeeRate,
uint256 _newFeeRate
);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The address that initiated the update. |
_feeType | ConfigTypes.FeeType | The fee type updated. |
_oldFeeRate | uint256 | The old protocol fee rate. |
_newFeeRate | uint256 | The new protocol fee rate. |
ProtocolFeesClaimed
Emitted when protocol fees claimed.
event ProtocolFeesClaimed(
address _sender, address _to, address _token, uint256 _amount
);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The address that initiated the claim. |
_to | address | The address to send protocol fees to. |
_token | address | The address of the token protocol fees in. |
_amount | uint256 | The amount of protocol fees claimed. |
ProtocolFees
Emitted when protocol fees are received.
event ProtocolFees(address indexed _token, uint256 _amt, uint256 _voterAmt);
Parameters
Name | Type | Description |
---|---|---|
_token | address | The address of the token protocol fees in. |
_amt | uint256 | The amount of protocol fees received. |
_voterAmt | uint256 | The amount of protocol fees received by the voter. |
BaseHarvested
Emitted when base + commission rewards are harvested.
event BaseHarvested(address _sender, uint256 _bgtAmt);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The address that initiated the harvest. |
_bgtAmt | uint256 | The amount of BGT harvested. |
VaultHarvested
Emitted when a vault harvests its rewards.
event VaultHarvested(
address _sender,
address indexed _asset,
address indexed _vault,
uint256 _bgtAmt
);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The address that initiated the harvest. |
_asset | address | The asset associated with the vault being harvested. |
_vault | address | The address of the vault being harvested. |
_bgtAmt | uint256 | The amount of BGT harvested. |
BribesCollected
Emitted when bribes are harvested then collected by collector.
event BribesCollected(
address _sender,
address _token,
uint256 _amtWiberaVault,
uint256 _amtIbgtVault
);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The address that initiated the bribe collection. |
_token | address | The payout token from bribe collection. |
_amtWiberaVault | uint256 | The amount of collected bribe sent to the wrapped iBERA vault. |
_amtIbgtVault | uint256 | The amount of collected bribe sent to the iBGT vault. |
ValidatorHarvested
Emitted when a validator harvests its rewards.
event ValidatorHarvested(
address _sender,
bytes indexed _validator,
DataTypes.Token[] _rewards,
uint256 _bgtAmt
);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The address that initiated the harvest. |
_validator | bytes | The public key of the validator. |
_rewards | DataTypes.Token[] | An array of tokens and amounts harvested. |
_bgtAmt | uint256 | The amount of BGT included in the rewards. |
ValidatorsAdded
Emitted when validators are added.
event ValidatorsAdded(address _sender, ValidatorTypes.Validator[] _validators);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The address that initiated the addition. |
_validators | ValidatorTypes.Validator[] | An array of validators that were added. |
ValidatorsRemoved
Emitted when validators are removed from validator set.
event ValidatorsRemoved(address _sender, bytes[] _pubkeys);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The address that initiated the removal. |
_pubkeys | bytes[] | An array of validators' pubkeys that were removed. |
ValidatorReplaced
Emitted when a validator is replaced with a new validator.
event ValidatorReplaced(address _sender, bytes _current, bytes _new);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The address that initiated the replacement. |
_current | bytes | The pubkey of the current validator being replaced. |
_new | bytes | The pubkey of the new validator. |
QueuedBoosts
Emitted when BGT tokens are queued for boosts to validators.
event QueuedBoosts(address _sender, bytes[] _pubkeys, uint128[] _amts);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The address that initiated the boost. |
_pubkeys | bytes[] | The addresses of the validators to which tokens are queued for boosts. |
_amts | uint128[] | The amounts of tokens that were queued. |
CancelledBoosts
Emitted when existing queued boosts to validators are cancelled.
event CancelledBoosts(address _sender, bytes[] _pubkeys, uint128[] _amts);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The address that initiated the cancellation. |
_pubkeys | bytes[] | The pubkeys of the validators to which tokens were queued for boosts. |
_amts | uint128[] | The amounts of tokens to remove from boosts. |
ActivatedBoosts
Emitted when an existing boost to a validator is activated.
event ActivatedBoosts(address _sender, bytes[] _pubkeys);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The address that initiated the activation. |
_pubkeys | bytes[] | The addresses of the validators which were boosted. |
QueueDropBoosts
Emitted when an user queues a drop boost for a validator.
event QueueDropBoosts(
address indexed user, bytes[] indexed pubkeys, uint128[] amounts
);
Parameters
Name | Type | Description |
---|---|---|
user | address | The address of the user. |
pubkeys | bytes[] | The addresses of the validators to which tokens were queued for boosts. |
amounts | uint128[] | The amounts of tokens to remove from boosts. |
CancelDropBoosts
Emitted when an user cancels a queued drop boost for a validator.
event CancelDropBoosts(
address indexed user, bytes[] indexed pubkeys, uint128[] amounts
);
Parameters
Name | Type | Description |
---|---|---|
user | address | The address of the user. |
pubkeys | bytes[] | The addresses of the validators to which tokens were queued for boosts. |
amounts | uint128[] | The amounts of tokens to remove from boosts. |
DroppedBoosts
Emitted when sender removes an amount of BGT boost from a validator
event DroppedBoosts(address indexed _sender, bytes[] _pubkeys);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The address that initiated the cancellation. |
_pubkeys | bytes[] | The addresses of the validators to which tokens were queued for boosts. |
Undelegated
Emitted when tokens are undelegated from a validator.
event Undelegated(address _sender, bytes _pubkey, uint256 _amt);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The address that initiated the undelegation. |
_pubkey | bytes | The pubkey of the validator from which tokens are undelegated. |
_amt | uint256 | The amount of tokens that were undelegated. |
Redelegated
Emitted when tokens are redelegated from one validator to another.
event Redelegated(address _sender, bytes _from, bytes _to, uint256 _amt);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The address that initiated the redelegation. |
_from | bytes | The public key of the validator from which tokens are redelegated. |
_to | bytes | The public key of the validator to which tokens are redelegated. |
_amt | uint256 | The amount of tokens that were redelegated. |
RedSet
Emitted when the RED token is set.
event RedSet(address _sender, address _red);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The address that initiated the update. |
_red | address | The address of the RED token. |
UpdatedRedMintRate
event UpdatedRedMintRate(
uint256 oldMintRate, uint256 newMintRate, address sender
);
Parameters
Name | Type | Description |
---|---|---|
oldMintRate | uint256 | The old mint rate for RED |
newMintRate | uint256 | The new mint rate for RED |
sender | address | The address that initiated the update |
IBGTSet
Emitted when the iBGT token is set.
event IBGTSet(address _sender, address _ibgt);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The address that initiated the update. |
_ibgt | address | The address of the iBGT token. |
IInfraredBERA
Inherits: IERC20, IAccessControl
Functions
infrared
Address of the Infrared operator contract
function infrared() external view returns (address);
depositor
Address of the depositor that interacts with chain deposit precompile
function depositor() external view returns (address);
withdrawor
Address of the withdrawor that interacts with chain withdraw precompile
function withdrawor() external view returns (address);
receivor
Address of the fee receivor contract that receives tx priority fees + MEV on EL
function receivor() external view returns (address);
deposits
Deposits of BERA backing InfraredBERA intended for use in CL by validators
function deposits() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The amount of BERA for deposits to CL |
stakes
Returns the amount of BERA staked in validator with given pubkey
function stakes(bytes calldata pubkey) external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The amount of BERA staked in validator |
staked
Returns whether initial deposit has been staked to validator with given pubkey
function staked(bytes calldata pubkey) external view returns (bool);
Returns
Name | Type | Description |
---|---|---|
<none> | bool | Whethere initial deposit has been staked to validator |
hasExited
Checks if a validator has been force exited from the Consensus Layer
exited validators can no longer be deposited in.
function hasExited(bytes calldata pubkey) external view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | The public key of the validator to check |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool True if the validator has been force exited, false otherwise |
signatures
Returns the deposit signature to use for given pubkey
function signatures(bytes calldata pubkey)
external
view
returns (bytes memory);
Returns
Name | Type | Description |
---|---|---|
<none> | bytes | The deposit signature for pubkey |
feeDivisorShareholders
Fee taken by the shareholders on yield from EL coinbase priority fees + MEV, represented as an integer denominator (1/x)%
additional fees include POL base rewards, POL comission, POL bribes
function feeDivisorShareholders() external view returns (uint16);
Returns
Name | Type | Description |
---|---|---|
<none> | uint16 | The fee taken by shareholders as an integer denominator (1/x)%, (25% = 4), (50% = 2), (100% = 1) |
pending
Pending deposits yet to be forwarded to CL
function pending() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The amount of BERA yet to be deposited to CL |
confirmed
Confirmed deposits sent to CL
function confirmed() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The amount of BERA confirmed to be deposited to CL |
keeper
Returns whether given account is an InfraredBERA keeper
function keeper(address account) external view returns (bool);
Returns
Name | Type | Description |
---|---|---|
<none> | bool | Whether account is a keeper |
governor
Returns whether given account is an InfraredBERA governor
function governor(address account) external view returns (bool);
Returns
Name | Type | Description |
---|---|---|
<none> | bool | Whether account is a governor |
validator
Returns whether given pubkey is in Infrared validator set
function validator(bytes calldata pubkey) external view returns (bool);
Returns
Name | Type | Description |
---|---|---|
<none> | bool | Whether pubkey in Infrared validator set |
previewMint
Previews the amount of InfraredBERA shares that would be minted for a given BERA amount
function previewMint(uint256 beraAmount)
external
view
returns (uint256 shares, uint256 fee);
Parameters
Name | Type | Description |
---|---|---|
beraAmount | uint256 | The amount of BERA to simulate depositing |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The amount of InfraredBERA shares that would be minted, returns 0 if the operation would fail |
fee | uint256 | The fee that would be charged for the mint operation |
previewBurn
Previews the amount of BERA that would be received for burning InfraredBERA shares
function previewBurn(uint256 shares)
external
view
returns (uint256 beraAmount, uint256 fee);
Parameters
Name | Type | Description |
---|---|---|
shares | uint256 | The amount of InfraredBERA shares to simulate burning |
Returns
Name | Type | Description |
---|---|---|
beraAmount | uint256 | The amount of BERA that would be received, returns 0 if the operation would fail |
fee | uint256 | The fee that would be charged for the burn operation |
initialize
Initializes InfraredBERA to allow for future mints and burns
Must be called before InfraredBERA can offer deposits and withdraws
function initialize(
address _gov,
address _keeper,
address _infrared,
address _depositor,
address _withdrawor,
address _receivor
) external payable;
compound
Compounds accumulated EL yield in fee receivor into deposits
Called internally at bof whenever InfraredBERA minted or burned
Only sweeps if amount transferred from fee receivor would exceed min deposit thresholds
function compound() external;
sweep
Sweeps received funds in msg.value
as yield into deposits
Fee receivor must call this function in its sweep function for autocompounding
function sweep() external payable;
collect
Collects yield from fee receivor and mints ibera shares to Infrared
Only Infrared can call this function
function collect() external returns (uint256 sharesMinted);
Returns
Name | Type | Description |
---|---|---|
sharesMinted | uint256 | The amount of ibera shares minted |
mint
Mints ibera shares to receiver for bera paid in by sender
function mint(address receiver)
external
payable
returns (uint256 nonce, uint256 shares);
Parameters
Name | Type | Description |
---|---|---|
receiver | address | Address of the receiver of ibera |
Returns
Name | Type | Description |
---|---|---|
nonce | uint256 | The nonce issued to identify the credited bera funds for deposit |
shares | uint256 | The amount of shares of ibera minted |
burn
Burns ibera shares from sender for bera to ultimately be transferred to receiver on subsequent call to claim
Sender must pay withdraw precompile fee upfront
function burn(address receiver, uint256 shares)
external
payable
returns (uint256 nonce, uint256 amount);
Parameters
Name | Type | Description |
---|---|---|
receiver | address | Address of the receiver of future bera |
shares | uint256 | The amount of shares of ibera burned |
Returns
Name | Type | Description |
---|---|---|
nonce | uint256 | The nonce issued to identify the owed bera funds for claim |
amount | uint256 | The amount of bera funds that will be available for claim |
register
Registers update to BERA staked in validator with given pubkey at CL
Reverts if not called by depositor or withdrawor
function register(bytes calldata pubkey, int256 delta) external;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | The pubkey of the validator to update BERA stake for at CL |
delta | int256 | The change in the amount of BERA staked/unstaked (+/-) at CL |
setFeeDivisorShareholders
Sets the fee shareholders taken on yield from EL coinbase priority fees + MEV
function setFeeDivisorShareholders(uint16 to) external;
Parameters
Name | Type | Description |
---|---|---|
to | uint16 | The new fee shareholders represented as an integer denominator (1/x)% |
setDepositSignature
Sets the deposit signature to be used when depositing to pubkey
function setDepositSignature(bytes calldata pubkey, bytes calldata signature)
external;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | The pubkey of the validator receiving the deposit |
signature | bytes | The deposit signature to use for pubkey |
withdrawalsEnabled
Flag to show whether withdrawals are currently enabled
function withdrawalsEnabled() external view returns (bool);
Returns
Name | Type | Description |
---|---|---|
<none> | bool | True if withdrawals are enabled |
Events
Mint
event Mint(
address indexed receiver,
uint256 nonce,
uint256 amount,
uint256 shares,
uint256 fee
);
Burn
event Burn(
address indexed receiver,
uint256 nonce,
uint256 amount,
uint256 shares,
uint256 fee
);
Sweep
event Sweep(uint256 amount);
Register
event Register(bytes pubkey, int256 delta, uint256 stake);
SetFeeShareholders
event SetFeeShareholders(uint16 from, uint16 to);
SetDepositSignature
event SetDepositSignature(bytes pubkey, bytes from, bytes to);
WithdrawalFlagSet
event WithdrawalFlagSet(bool flag);
IInfraredBERAClaimor
Functions
claims
Outstanding BERA claims for a receiver
function claims(address receiver) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
receiver | address | The address of the claims receiver |
queue
Queues a new BERA claim for a receiver
Only callable by the InfraredBERAWithdrawor contract
function queue(address receiver) external payable;
Parameters
Name | Type | Description |
---|---|---|
receiver | address | The address of the claims receiver |
sweep
Sweeps oustanding BERA claims for a receiver to their address
function sweep(address receiver) external;
Parameters
Name | Type | Description |
---|---|---|
receiver | address | The address of the claims receiver |
Events
Queue
event Queue(address indexed receiver, uint256 amount, uint256 claim);
Sweep
event Sweep(address indexed receiver, uint256 amount);
IInfraredBERADepositor
Functions
InfraredBERA
The address of InfraredBERA
function InfraredBERA() external view returns (address);
slips
Outstanding slips for deposits on previously minted ibera
function slips(uint256 nonce)
external
view
returns (uint96 timestamp, uint256 fee, uint256 amount);
Parameters
Name | Type | Description |
---|---|---|
nonce | uint256 | The nonce associated with the slip |
Returns
Name | Type | Description |
---|---|---|
timestamp | uint96 | The block.timestamp at which deposit slip was issued |
fee | uint256 | The fee escrow amount set aside for deposit contract request |
amount | uint256 | The amount of bera left to be submitted for deposit slip |
fees
Amount of BERA internally set aside for deposit contract request fees
function fees() external view returns (uint256);
reserves
Amount of BERA internally set aside to execute deposit contract requests
function reserves() external view returns (uint256);
nonceSlip
The next nonce to issue deposit slip for
function nonceSlip() external view returns (uint256);
nonceSubmit
The next nonce to submit deposit slip for
function nonceSubmit() external view returns (uint256);
queue
Queues a deposit from InfraredBERA for chain deposit precompile escrowing msg.value in contract
function queue(uint256 amount) external payable returns (uint256 nonce);
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | The amount of funds to deposit |
Returns
Name | Type | Description |
---|---|---|
nonce | uint256 | The nonce created when queueing the deposit |
execute
Executes a deposit to deposit precompile using escrowed funds
function execute(bytes calldata pubkey, uint256 amount) external;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | The pubkey to deposit validator funds to |
amount | uint256 | The amount of funds to use from escrow to deposit to validator |
Events
Queue
event Queue(uint256 nonce, uint256 amount);
Execute
event Execute(bytes pubkey, uint256 start, uint256 end, uint256 amount);
IInfraredBERAFeeReceivor
Functions
InfraredBERA
The address of InfraredBERA
function InfraredBERA() external view returns (address);
shareholderFees
Accumulated protocol fees in contract to be claimed by governor
function shareholderFees() external view returns (uint256);
distribution
Amount of BERA swept to InfraredBERA and fees taken for protool on next call to sweep
function distribution() external view returns (uint256 amount, uint256 fees);
Returns
Name | Type | Description |
---|---|---|
amount | uint256 | THe amount of BERA forwarded to InfraredBERA on next sweep |
fees | uint256 | The protocol fees taken on next sweep |
sweep
Sweeps accumulated coinbase priority fees + MEV to InfraredBERA to autocompound principal
function sweep() external returns (uint256 amount, uint256 fees);
collect
Collects accumulated shareholder fees
Reverts if msg.sender is not iBERA contract
function collect() external returns (uint256 sharesMinted);
Returns
Name | Type | Description |
---|---|---|
sharesMinted | uint256 | The amount of iBERA shares minted and sent to infrared |
Events
Sweep
event Sweep(address indexed receiver, uint256 amount, uint256 fees);
Collect
event Collect(address indexed receiver, uint256 amount, uint256 sharesMinted);
IInfraredBERAWithdrawor
Functions
InfraredBERA
The address of InfraredBERA
function InfraredBERA() external view returns (address);
sweep
Sweeps forced withdrawals to InfraredBERA to re-stake principal
function sweep(bytes calldata pubkey) external;
requests
Outstanding requests for claims on previously burnt ibera
function requests(uint256 nonce)
external
view
returns (
address receiver,
uint96 timestamp,
uint256 fee,
uint256 amountSubmit,
uint256 amountProcess
);
Parameters
Name | Type | Description |
---|---|---|
nonce | uint256 | The nonce associated with the claim |
Returns
Name | Type | Description |
---|---|---|
receiver | address | The address of the receiver of bera funds to be claimed |
timestamp | uint96 | The block.timestamp at which withdraw request was issued |
fee | uint256 | The fee escrow amount set aside for withdraw precompile request |
amountSubmit | uint256 | The amount of bera left to be submitted for withdraw request |
amountProcess | uint256 | The amount of bera left to be processed for withdraw request |
fees
Amount of BERA internally set aside for withdraw precompile request fees
function fees() external view returns (uint256);
reserves
Amount of BERA internally set aside to process withdraw compile requests from funds received on successful requests
function reserves() external view returns (uint256);
rebalancing
Amount of BERA internally rebalancing amongst Infrared validators
function rebalancing() external view returns (uint256);
nonceRequest
The next nonce to issue withdraw request for
function nonceRequest() external view returns (uint256);
nonceSubmit
The next nonce to submit withdraw request for
function nonceSubmit() external view returns (uint256);
nonceProcess
The next nonce in queue to process claims for
function nonceProcess() external view returns (uint256);
queue
Queues a withdraw from InfraredBERA for chain withdraw precompile escrowing minimum fees for request to withdraw precompile
function queue(address receiver, uint256 amount)
external
payable
returns (uint256 nonce);
Parameters
Name | Type | Description |
---|---|---|
receiver | address | The address to receive withdrawn funds |
amount | uint256 | The amount of funds to withdraw |
Returns
Name | Type | Description |
---|---|---|
nonce | uint256 | The nonce created when queueing the withdraw |
execute
Executes a withdraw request to withdraw precompile
Payable in case excess bera required to satisfy withdraw precompile fee
function execute(bytes calldata pubkey, uint256 amount) external payable;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | The pubkey to withdraw validator funds from |
amount | uint256 | The amount of funds to withdraw from validator |
process
Processes the funds received from withdraw precompile to next-to-process request receiver
Reverts if balance has not increased by full amount of request for next-to-process request nonce
function process() external;
Events
Queue
event Queue(address indexed receiver, uint256 nonce, uint256 amount);
Execute
event Execute(bytes pubkey, uint256 start, uint256 end, uint256 amount);
Process
event Process(address indexed receiver, uint256 nonce, uint256 amount);
Sweep
event Sweep(address indexed receiver, uint256 amount);
IInfraredBGT
Inherits: IERC20Mintable, IAccessControl
Functions
bgt
The address of the BGT non-transferrable ERC20 token
function bgt() external view returns (address);
IInfraredDistributor
Interface for distributing validator commissions and rewards
Handles reward distribution snapshots and claiming logic for validators
Functions
token
Token used for reward distributions
function token() external view returns (ERC20);
Returns
Name | Type | Description |
---|---|---|
<none> | ERC20 | The ERC20 token interface of the reward token |
amountsCumulative
Tracks reward amount accumulation per validator
function amountsCumulative() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Current cumulative amount of rewards |
getSnapshot
Get validator's reward snapshots
Returns (0,0) if validator doesn't exist
function getSnapshot(bytes calldata pubkey)
external
view
returns (uint256 amountCumulativeLast, uint256 amountCumulativeFinal);
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | Validator's public key |
Returns
Name | Type | Description |
---|---|---|
amountCumulativeLast | uint256 | Last claimed accumulator value |
amountCumulativeFinal | uint256 | Final accumulator value if removed |
getValidator
Get validator's registered claim address
function getValidator(bytes calldata pubkey) external view returns (address);
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | Validator's public key |
Returns
Name | Type | Description |
---|---|---|
<none> | address | Address authorized to claim validator rewards |
add
Register new validator for rewards
Only callable by Infrared contract
Notes:
-
access-control: Requires INFRARED_ROLE
-
error: ValidatorAlreadyExists if validator already registered
function add(bytes calldata pubkey, address validator) external;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | Validator's public key |
validator | address | Address authorized to claim rewards |
remove
Removes validator from reward-eligible set
Only callable by Infrared contract
Note: access-control: Requires INFRARED_ROLE
function remove(bytes calldata pubkey) external;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | Validator's public key |
purge
Purges validator from registry completely
Only possible after all rewards are claimed
Note: error: ClaimableRewardsExist if unclaimed rewards remain
function purge(bytes calldata pubkey) external;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | Validator's public key |
notifyRewardAmount
Distributes new commission rewards to validator set
Notes:
-
error: ZeroAmount if amount is 0
-
error: InvalidValidator if no validators exist
function notifyRewardAmount(uint256 amount) external;
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | Amount to distribute equally among validators |
claim
Claims outstanding commission rewards
Notes:
-
error: InvalidValidator if caller not authorized
-
error: ZeroAmount if no rewards to claim
function claim(bytes calldata pubkey, address recipient) external;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | Validator's public key |
recipient | address | Address to receive the claimed rewards |
Events
Added
Emitted when validator is added to commission-eligible set
event Added(bytes pubkey, address operator, uint256 amountCumulative);
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | Validator's public key |
operator | address | Address authorized to claim rewards |
amountCumulative | uint256 | Starting point for commission stream |
Removed
Emitted when validator is removed from commission-eligible set
event Removed(bytes pubkey, address operator, uint256 amountCumulative);
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | Validator's public key |
operator | address | Address previously authorized for claims |
amountCumulative | uint256 | Final point for commission stream |
Purged
Emitted when validator is fully purged from registry
event Purged(bytes pubkey, address validator);
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | Validator's public key |
validator | address | Address being purged |
Notified
Emitted when new commission rewards are added
event Notified(uint256 amount, uint256 num);
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | New rewards being distributed |
num | uint256 | Current number of eligible validators |
Claimed
Emitted when validator claims their commission
event Claimed(
bytes pubkey, address validator, address recipient, uint256 amount
);
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | Claiming validator's public key |
validator | address | Address authorized for claims |
recipient | address | Address receiving the commission |
amount | uint256 | Amount of commission claimed |
Structs
Snapshot
Reward accumulation checkpoints for validators
Used to calculate claimable rewards between snapshots
struct Snapshot {
uint256 amountCumulativeLast;
uint256 amountCumulativeFinal;
}
IInfraredUpgradeable
Inherits: IAccessControl
Functions
KEEPER_ROLE
Access control for keeper role
function KEEPER_ROLE() external view returns (bytes32);
GOVERNANCE_ROLE
Access control for governance role
function GOVERNANCE_ROLE() external view returns (bytes32);
infrared
Infrared coordinator contract
function infrared() external view returns (address);
IInfraredVault
Inherits: IMultiRewards
Functions
getAllRewardTokens
Returns all reward tokens
function getAllRewardTokens() external view returns (address[] memory);
Returns
Name | Type | Description |
---|---|---|
<none> | address[] | An array of reward token addresses |
getAllRewardsForUser
Returns all rewards for a user
Only up to date since the lastUpdateTime
function getAllRewardsForUser(address _user)
external
view
returns (UserReward[] memory);
Parameters
Name | Type | Description |
---|---|---|
_user | address | The address of the user |
Returns
Name | Type | Description |
---|---|---|
<none> | UserReward[] | An array of UserReward structs |
infrared
Returns the Infrared protocol coordinator
function infrared() external view returns (address);
Returns
Name | Type | Description |
---|---|---|
<none> | address | The address of the Infrared contract |
rewardsVault
Returns the associated Berachain rewards vault
function rewardsVault() external view returns (IBerachainRewardsVault);
Returns
Name | Type | Description |
---|---|---|
<none> | IBerachainRewardsVault | The rewards vault contract instance |
updateRewardsDuration
Updates reward duration for a specific reward token
Only callable by Infrared contract
Note: access-control: Requires INFRARED_ROLE
function updateRewardsDuration(address _rewardsToken, uint256 _rewardsDuration)
external;
Parameters
Name | Type | Description |
---|---|---|
_rewardsToken | address | The address of the reward token |
_rewardsDuration | uint256 | The new duration in seconds |
togglePause
Toggles pause state of the vault
Affects all vault operations when paused
Note: access-control: Requires INFRARED_ROLE
function togglePause() external;
addReward
Adds a new reward token to the vault
Cannot exceed maximum number of reward tokens
Note: access-control: Requires INFRARED_ROLE
function addReward(address _rewardsToken, uint256 _rewardsDuration) external;
Parameters
Name | Type | Description |
---|---|---|
_rewardsToken | address | The reward token to add |
_rewardsDuration | uint256 | The reward period duration |
notifyRewardAmount
Notifies the vault of newly added rewards
Updates internal reward rate calculations
function notifyRewardAmount(address _rewardToken, uint256 _reward) external;
Parameters
Name | Type | Description |
---|---|---|
_rewardToken | address | The reward token address |
_reward | uint256 | The amount of new rewards |
recoverERC20
Recovers accidentally sent tokens
Cannot recover staking token or active reward tokens
function recoverERC20(address _to, address _token, uint256 _amount) external;
Parameters
Name | Type | Description |
---|---|---|
_to | address | The address to receive the recovered tokens |
_token | address | The token to recover |
_amount | uint256 | The amount to recover |
Structs
UserReward
A struct to hold a user's reward information
struct UserReward {
address token;
uint256 amount;
}
Properties
Name | Type | Description |
---|---|---|
token | address | The address of the reward token |
amount | uint256 | The amount of reward tokens |
IMultiRewards
Functions
totalSupply
Returns the total amount of staked tokens in the contract
function totalSupply() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint256 The total supply of staked tokens |
stake
Stakes tokens into the contract
Transfers amount
of staking tokens from the user to this contract
function stake(uint256 amount) external;
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | The amount of tokens to stake |
withdraw
Withdraws staked tokens from the contract
Transfers amount
of staking tokens back to the user
function withdraw(uint256 amount) external;
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | The amount of tokens to withdraw |
getReward
Claims all pending rewards for the caller
Transfers all accrued rewards to the caller
function getReward() external;
exit
Withdraws all staked tokens and claims pending rewards
Combines withdraw and getReward operations
function exit() external;
balanceOf
Returns the balance of staked tokens for the given account
function balanceOf(address account) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
account | address | The account to get the balance for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The balance of staked tokens |
lastTimeRewardApplicable
Calculates the last time reward is applicable for a given rewards token
function lastTimeRewardApplicable(address _rewardsToken)
external
view
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_rewardsToken | address | The address of the rewards token |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The timestamp when the reward was last applicable |
rewardPerToken
Calculates the reward per token for a given rewards token
function rewardPerToken(address _rewardsToken)
external
view
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_rewardsToken | address | The address of the rewards token |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The reward amount per token |
earned
Calculates the earned rewards for a given account and rewards token
function earned(address account, address _rewardsToken)
external
view
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
account | address | The address of the account |
_rewardsToken | address | The address of the rewards token |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The amount of rewards earned |
getRewardForDuration
Calculates the total reward for the duration of a given rewards token
function getRewardForDuration(address _rewardsToken)
external
view
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_rewardsToken | address | The address of the rewards token |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The total reward amount for the duration of a given rewards token |
rewardData
Gets the reward data for a given rewards token
function rewardData(address _rewardsToken)
external
view
returns (
address rewardsDistributor,
uint256 rewardsDuration,
uint256 periodFinish,
uint256 rewardRate,
uint256 lastUpdateTime,
uint256 rewardPerTokenStored,
uint256 rewardResidual
);
Parameters
Name | Type | Description |
---|---|---|
_rewardsToken | address | The address of the rewards token |
Returns
Name | Type | Description |
---|---|---|
rewardsDistributor | address | The address authorized to distribute rewards |
rewardsDuration | uint256 | The duration of the reward period |
periodFinish | uint256 | The timestamp when rewards finish |
rewardRate | uint256 | The rate of rewards distributed per second |
lastUpdateTime | uint256 | The last time rewards were updated |
rewardPerTokenStored | uint256 | The last calculated reward per token |
rewardResidual | uint256 |
rewardTokens
Returns the reward token address at a specific index
function rewardTokens(uint256 index) external view returns (address);
Parameters
Name | Type | Description |
---|---|---|
index | uint256 | The index in the reward tokens array |
Returns
Name | Type | Description |
---|---|---|
<none> | address | The address of the reward token at the given index |
getRewardForUser
Claims all pending rewards for a specified user
Iterates through all reward tokens and transfers any accrued rewards to the user
function getRewardForUser(address _user) external;
Parameters
Name | Type | Description |
---|---|---|
_user | address | The address of the user to claim rewards for |
Events
Staked
Emitted when tokens are staked
event Staked(address indexed user, uint256 amount);
Parameters
Name | Type | Description |
---|---|---|
user | address | The address of the user who staked |
amount | uint256 | The amount of tokens staked |
Withdrawn
Emitted when tokens are withdrawn
event Withdrawn(address indexed user, uint256 amount);
Parameters
Name | Type | Description |
---|---|---|
user | address | The address of the user who withdrew |
amount | uint256 | The amount of tokens withdrawn |
RewardPaid
Emitted when rewards are claimed
event RewardPaid(
address indexed user, address indexed rewardsToken, uint256 reward
);
Parameters
Name | Type | Description |
---|---|---|
user | address | The address of the user claiming the reward |
rewardsToken | address | The address of the reward token |
reward | uint256 | The amount of rewards claimed |
RewardAdded
Emitted when rewards are added to the contract
event RewardAdded(address indexed rewardsToken, uint256 reward);
Parameters
Name | Type | Description |
---|---|---|
rewardsToken | address | The address of the reward token |
reward | uint256 | The amount of rewards added |
RewardsDistributorUpdated
Emitted when a rewards distributor is updaRewardAddedd
event RewardsDistributorUpdated(
address indexed rewardsToken, address indexed newDistributor
);
Parameters
Name | Type | Description |
---|---|---|
rewardsToken | address | The address of the reward token |
newDistributor | address | The address of the new distributor |
RewardsDurationUpdated
Emitted when the rewards duration for a token is updated
event RewardsDurationUpdated(address token, uint256 newDuration);
Parameters
Name | Type | Description |
---|---|---|
token | address | The reward token address whose duration was updated |
newDuration | uint256 | The new duration set for the rewards period |
Recovered
Emitted when tokens are recovered from the contract
event Recovered(address token, uint256 amount);
Parameters
Name | Type | Description |
---|---|---|
token | address | The address of the token that was recovered |
amount | uint256 | The amount of tokens that were recovered |
RewardStored
Emitted when new reward data is stored
event RewardStored(address rewardsToken, uint256 rewardsDuration);
Parameters
Name | Type | Description |
---|---|---|
rewardsToken | address | The address of the reward token |
rewardsDuration | uint256 | The duration set for the reward period |
Structs
Reward
Reward data for a particular reward token
Struct containing all relevant information for reward distribution
struct Reward {
address rewardsDistributor;
uint256 rewardsDuration;
uint256 periodFinish;
uint256 rewardRate;
uint256 lastUpdateTime;
uint256 rewardPerTokenStored;
uint256 rewardResidual;
}
IRED
Inherits: IERC20Mintable, IAccessControl
Functions
ibgt
The address of the InfraredBGT token
function ibgt() external view returns (address);
infrared
The address of the Infrared contract
function infrared() external view returns (address);
IWBERA
Inherits: IERC20
The deposit function allows users to deposit EVM balance (BERA) into the contract. It mints an equivalent amount of WBERA tokens and assigns them to the sender.
Functions
deposit
function deposit() external payable;
withdraw
function withdraw(uint256 amount) external;
Contents
- InfraredBERA
- InfraredBERAClaimor
- InfraredBERAConstants
- InfraredBERADepositor
- InfraredBERAFeeReceivor
- InfraredBERAWithdrawor
- InfraredBERAWithdraworLite
InfraredBERA
Inherits: ERC20Upgradeable, Upgradeable, IInfraredBERA
Infrared liquid staking token for BERA
Assumes BERA balances do not change at the CL
State Variables
withdrawalsEnabled
Flag to show whether withdrawals are currently enabled
bool public withdrawalsEnabled;
_initialized
Whether initial mint to address(this) has happened
bool private _initialized;
feeDivisorShareholders
Fee taken by the shareholders on yield from EL coinbase priority fees + MEV, represented as an integer denominator (1/x)%
uint16 public feeDivisorShareholders;
infrared
Address of the Infrared operator contract
address public infrared;
depositor
Address of the depositor that interacts with chain deposit precompile
address public depositor;
withdrawor
Address of the withdrawor that interacts with chain withdraw precompile
address public withdrawor;
receivor
Address of the fee receivor contract that receives tx priority fees + MEV on EL
address public receivor;
deposits
Deposits of BERA backing InfraredBERA intended for use in CL by validators
uint256 public deposits;
_stakes
mapping(bytes32 pubkeyHash => uint256 stake) internal _stakes;
_staked
mapping(bytes32 pubkeyHash => bool isStaked) internal _staked;
_exited
mapping(bytes32 pubkeyHash => bool hasExited) internal _exited;
_signatures
mapping(bytes32 pubkeyHash => bytes) internal _signatures;
Functions
initialize
Initializes InfraredBERA to allow for future mints and burns
Must be called before InfraredBERA can offer deposits and withdraws
function initialize(
address _gov,
address _keeper,
address _infrared,
address _depositor,
address _withdrawor,
address _receivor
) external payable initializer;
setWithdrawalsEnabled
function setWithdrawalsEnabled(bool flag) external onlyGovernor;
_deposit
function _deposit(uint256 value)
private
returns (uint256 nonce, uint256 amount, uint256 fee);
_withdraw
function _withdraw(address receiver, uint256 amount, uint256 fee)
private
returns (uint256 nonce);
pending
Pending deposits yet to be forwarded to CL
function pending() public view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The amount of BERA yet to be deposited to CL |
confirmed
Confirmed deposits sent to CL
function confirmed() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The amount of BERA confirmed to be deposited to CL |
keeper
Returns whether given account is an InfraredBERA keeper
function keeper(address account) public view returns (bool);
Returns
Name | Type | Description |
---|---|---|
<none> | bool | Whether account is a keeper |
governor
Returns whether given account is an InfraredBERA governor
function governor(address account) public view returns (bool);
Returns
Name | Type | Description |
---|---|---|
<none> | bool | Whether account is a governor |
validator
Returns whether given pubkey is in Infrared validator set
function validator(bytes calldata pubkey) external view returns (bool);
Returns
Name | Type | Description |
---|---|---|
<none> | bool | Whether pubkey in Infrared validator set |
compound
Compounds accumulated EL yield in fee receivor into deposits
Called internally at bof whenever InfraredBERA minted or burned
function compound() public;
sweep
Sweeps received funds in msg.value
as yield into deposits
Fee receivor must call this function in its sweep function for autocompounding
function sweep() external payable;
mint
Mints ibera shares to receiver for bera paid in by sender
function mint(address receiver)
public
payable
returns (uint256 nonce, uint256 shares);
Parameters
Name | Type | Description |
---|---|---|
receiver | address | Address of the receiver of ibera |
Returns
Name | Type | Description |
---|---|---|
nonce | uint256 | The nonce issued to identify the credited bera funds for deposit |
shares | uint256 | The amount of shares of ibera minted |
burn
Burns ibera shares from sender for bera to ultimately be transferred to receiver on subsequent call to claim
Sender must pay withdraw precompile fee upfront
function burn(address receiver, uint256 shares)
external
payable
returns (uint256 nonce, uint256 amount);
Parameters
Name | Type | Description |
---|---|---|
receiver | address | Address of the receiver of future bera |
shares | uint256 | The amount of shares of ibera burned |
Returns
Name | Type | Description |
---|---|---|
nonce | uint256 | The nonce issued to identify the owed bera funds for claim |
amount | uint256 | The amount of bera funds that will be available for claim |
register
Registers update to BERA staked in validator with given pubkey at CL
Reverts if not called by depositor or withdrawor
function register(bytes calldata pubkey, int256 delta) external;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | The pubkey of the validator to update BERA stake for at CL |
delta | int256 | The change in the amount of BERA staked/unstaked (+/-) at CL |
setFeeDivisorShareholders
Sets the fee shareholders taken on yield from EL coinbase priority fees + MEV
function setFeeDivisorShareholders(uint16 to) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
to | uint16 | The new fee shareholders represented as an integer denominator (1/x)% |
setDepositSignature
Sets the deposit signature to be used when depositing to pubkey
function setDepositSignature(bytes calldata pubkey, bytes calldata signature)
external
onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | The pubkey of the validator receiving the deposit |
signature | bytes | The deposit signature to use for pubkey |
collect
Collects yield from fee receivor and mints ibera shares to Infrared
Only Infrared can call this function
function collect() external returns (uint256 sharesMinted);
Returns
Name | Type | Description |
---|---|---|
sharesMinted | uint256 | The amount of ibera shares minted |
previewMint
Previews the amount of InfraredBERA shares that would be minted for a given BERA amount
function previewMint(uint256 beraAmount)
public
view
returns (uint256 shares, uint256 fee);
Parameters
Name | Type | Description |
---|---|---|
beraAmount | uint256 | The amount of BERA to simulate depositing |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The amount of InfraredBERA shares that would be minted, returns 0 if the operation would fail |
fee | uint256 | The fee that would be charged for the mint operation |
previewBurn
Previews the amount of BERA that would be received for burning InfraredBERA shares
function previewBurn(uint256 shareAmount)
public
view
returns (uint256 beraAmount, uint256 fee);
Parameters
Name | Type | Description |
---|---|---|
shareAmount | uint256 |
Returns
Name | Type | Description |
---|---|---|
beraAmount | uint256 | The amount of BERA that would be received, returns 0 if the operation would fail |
fee | uint256 | The fee that would be charged for the burn operation |
stakes
Returns the amount of BERA staked in validator with given pubkey
function stakes(bytes calldata pubkey) external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The amount of BERA staked in validator |
staked
Returns whether initial deposit has been staked to validator with given pubkey
function staked(bytes calldata pubkey) external view returns (bool);
Returns
Name | Type | Description |
---|---|---|
<none> | bool | Whethere initial deposit has been staked to validator |
hasExited
Checks if a validator has been force exited from the Consensus Layer
exited validators can no longer be deposited in.
function hasExited(bytes calldata pubkey) external view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | The public key of the validator to check |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool True if the validator has been force exited, false otherwise |
signatures
Returns the deposit signature to use for given pubkey
function signatures(bytes calldata pubkey)
external
view
returns (bytes memory);
Returns
Name | Type | Description |
---|---|---|
<none> | bytes | The deposit signature for pubkey |
InfraredBERAClaimor
Inherits: Upgradeable, IInfraredBERAClaimor
Claimor to claim BERA withdrawn from CL for Infrared liquid staking token
Separate contract so withdrawor process has trusted contract to forward funds to so no issue with naked bera transfer and receive function
State Variables
claims
Outstanding BERA claims for a receiver
mapping(address => uint256) public claims;
ibera
IInfraredBERA public ibera;
Functions
initialize
Initializer function (replaces constructor)
function initialize(address _gov, address _keeper, address _ibera)
external
initializer;
Parameters
Name | Type | Description |
---|---|---|
_gov | address | Address of the initial admin / gov |
_keeper | address | Address of the initial keeper |
_ibera | address | Address of InfraredBera proxy contract |
queue
Queues a new BERA claim for a receiver
Only callable by the InfraredBERAWithdrawor contract
function queue(address receiver) external payable;
Parameters
Name | Type | Description |
---|---|---|
receiver | address | The address of the claims receiver |
sweep
Sweeps oustanding BERA claims for a receiver to their address
function sweep(address receiver) external;
Parameters
Name | Type | Description |
---|---|---|
receiver | address | The address of the claims receiver |
InfraredBERAConstants
State Variables
INITIAL_DEPOSIT
uint256 public constant INITIAL_DEPOSIT = 10000 ether;
MINIMUM_DEPOSIT
uint256 public constant MINIMUM_DEPOSIT = 10 ether;
MINIMUM_DEPOSIT_FEE
uint256 public constant MINIMUM_DEPOSIT_FEE = 1 ether;
MINIMUM_WITHDRAW_FEE
uint256 public constant MINIMUM_WITHDRAW_FEE = 1 ether;
FORCED_MIN_DELAY
uint256 public constant FORCED_MIN_DELAY = 7 days;
InfraredBERADepositor
Inherits: Upgradeable, IInfraredBERADepositor
Depositor to deposit BERA to CL for Infrared liquid staking token
State Variables
ETH1_ADDRESS_WITHDRAWAL_PREFIX
uint8 public constant ETH1_ADDRESS_WITHDRAWAL_PREFIX = 0x01;
DEPOSIT_CONTRACT
address public DEPOSIT_CONTRACT;
InfraredBERA
The address of InfraredBERA
address public InfraredBERA;
slips
Outstanding slips for deposits on previously minted ibera
mapping(uint256 => Slip) public slips;
fees
Amount of BERA internally set aside for deposit contract request fees
uint256 public fees;
nonceSlip
The next nonce to issue deposit slip for
uint256 public nonceSlip;
nonceSubmit
The next nonce to submit deposit slip for
uint256 public nonceSubmit;
Functions
initialize
Initialize the contract (replaces the constructor)
function initialize(
address _gov,
address _keeper,
address ibera,
address _depositContract
) public initializer;
Parameters
Name | Type | Description |
---|---|---|
_gov | address | Address for admin / gov to upgrade |
_keeper | address | Address for keeper |
ibera | address | The initial IBERA address |
_depositContract | address | The ETH2 (Berachain) Deposit Contract Address |
_enoughtime
Checks whether enough time has passed beyond min delay
function _enoughtime(uint96 then, uint96 current)
private
pure
returns (bool has);
Parameters
Name | Type | Description |
---|---|---|
then | uint96 | The block timestamp in past |
current | uint96 | The current block timestamp now |
Returns
Name | Type | Description |
---|---|---|
has | bool | Whether time between then and now exceeds forced min delay |
reserves
Amount of BERA internally set aside to execute deposit contract requests
function reserves() public view returns (uint256);
queue
Queues a deposit from InfraredBERA for chain deposit precompile escrowing msg.value in contract
function queue(uint256 amount) external payable returns (uint256 nonce);
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | The amount of funds to deposit |
Returns
Name | Type | Description |
---|---|---|
nonce | uint256 | The nonce created when queueing the deposit |
execute
Executes a deposit to deposit precompile using escrowed funds
function execute(bytes calldata pubkey, uint256 amount) external;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | The pubkey to deposit validator funds to |
amount | uint256 | The amount of funds to use from escrow to deposit to validator |
Structs
Slip
struct Slip {
uint96 timestamp;
uint256 fee;
uint256 amount;
}
InfraredBERAFeeReceivor
Inherits: Upgradeable, IInfraredBERAFeeReceivor
Fee receivor receives coinbase priority fees + MEV credited to contract on EL upon block validation also receives collected validator bribe share.
CL validators should set fee_recipient to the address of this contract
State Variables
InfraredBERA
The address of InfraredBERA
address public InfraredBERA;
infrared
IInfrared public infrared;
shareholderFees
Accumulated protocol fees in contract to be claimed by governor
uint256 public shareholderFees;
Functions
initialize
Initializer function (replaces constructor)
function initialize(
address _gov,
address _keeper,
address ibera,
address _infrared
) external initializer;
Parameters
Name | Type | Description |
---|---|---|
_gov | address | Address for admin / gov to upgrade |
_keeper | address | Address for keeper |
ibera | address | Address for InfraredBERA |
_infrared | address | Address for Infrared |
distribution
Amount of BERA swept to InfraredBERA and fees taken for protool on next call to sweep
function distribution() public view returns (uint256 amount, uint256 fees);
Returns
Name | Type | Description |
---|---|---|
amount | uint256 | THe amount of BERA forwarded to InfraredBERA on next sweep |
fees | uint256 | The protocol fees taken on next sweep |
sweep
Sweeps accumulated coinbase priority fees + MEV to InfraredBERA to autocompound principal
function sweep() external returns (uint256 amount, uint256 fees);
collect
Collects accumulated shareholder fees
Reverts if msg.sender is not iBERA contract
function collect() external returns (uint256 sharesMinted);
Returns
Name | Type | Description |
---|---|---|
sharesMinted | uint256 | The amount of iBERA shares minted and sent to infrared |
receive
receive() external payable;
InfraredBERAWithdrawor
Inherits: Upgradeable, IInfraredBERAWithdrawor
Withdrawor to withdraw BERA from CL for Infrared liquid staking token
Assumes ETH returned via withdraw precompile credited to contract so receive unnecessary
State Variables
WITHDRAW_REQUEST_TYPE
uint8 public constant WITHDRAW_REQUEST_TYPE = 0x01;
WITHDRAW_PRECOMPILE
address public WITHDRAW_PRECOMPILE;
InfraredBERA
The address of InfraredBERA
address public InfraredBERA;
claimor
address public claimor;
requests
Outstanding requests for claims on previously burnt ibera
mapping(uint256 => Request) public requests;
fees
Amount of BERA internally set aside for withdraw precompile request fees
uint256 public fees;
rebalancing
Amount of BERA internally rebalancing amongst Infrared validators
uint256 public rebalancing;
nonceRequest
The next nonce to issue withdraw request for
uint256 public nonceRequest;
nonceSubmit
The next nonce to submit withdraw request for
uint256 public nonceSubmit;
nonceProcess
The next nonce in queue to process claims for
uint256 public nonceProcess;
Functions
initializeV2
function initializeV2(address _claimor, address _withdraw_precompile)
external
onlyGovernor;
_enoughtime
Checks whether enough time has passed beyond min delay
function _enoughtime(uint96 then, uint96 current)
private
pure
returns (bool has);
Parameters
Name | Type | Description |
---|---|---|
then | uint96 | The block timestamp in past |
current | uint96 | The current block timestamp now |
Returns
Name | Type | Description |
---|---|---|
has | bool | Whether time between then and now exceeds forced min delay |
reserves
Amount of BERA internally set aside to process withdraw compile requests from funds received on successful requests
function reserves() public view returns (uint256);
queue
Queues a withdraw from InfraredBERA for chain withdraw precompile escrowing minimum fees for request to withdraw precompile
function queue(address receiver, uint256 amount)
external
payable
returns (uint256 nonce);
Parameters
Name | Type | Description |
---|---|---|
receiver | address | The address to receive withdrawn funds |
amount | uint256 | The amount of funds to withdraw |
Returns
Name | Type | Description |
---|---|---|
nonce | uint256 | The nonce created when queueing the withdraw |
execute
Executes a withdraw request to withdraw precompile
Payable in case excess bera required to satisfy withdraw precompile fee
function execute(bytes calldata pubkey, uint256 amount) external payable;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | The pubkey to withdraw validator funds from |
amount | uint256 | The amount of funds to withdraw from validator |
process
Processes the funds received from withdraw precompile to next-to-process request receiver
Reverts if balance has not increased by full amount of request for next-to-process request nonce
function process() external;
sweep
Sweeps forced withdrawals to InfraredBERA to re-stake principal
function sweep(bytes calldata pubkey) external;
receive
receive() external payable;
Structs
Request
struct Request {
address receiver;
uint96 timestamp;
uint256 fee;
uint256 amountSubmit;
uint256 amountProcess;
}
InfraredBERAWithdraworLite
Inherits: Upgradeable, IInfraredBERAWithdrawor
Withdrawor Lite to be upgraded when voluntary exits are enabled
State Variables
WITHDRAW_REQUEST_TYPE
uint8 public constant WITHDRAW_REQUEST_TYPE = 0x01;
WITHDRAW_PRECOMPILE
address public WITHDRAW_PRECOMPILE;
InfraredBERA
The address of InfraredBERA
address public InfraredBERA;
claimor
address public claimor;
requests
Outstanding requests for claims on previously burnt ibera
mapping(uint256 => Request) public requests;
fees
Amount of BERA internally set aside for withdraw precompile request fees
uint256 public fees;
rebalancing
Amount of BERA internally rebalancing amongst Infrared validators
uint256 public rebalancing;
nonceRequest
The next nonce to issue withdraw request for
uint256 public nonceRequest;
nonceSubmit
The next nonce to submit withdraw request for
uint256 public nonceSubmit;
nonceProcess
The next nonce in queue to process claims for
uint256 public nonceProcess;
Functions
initialize
Initialize the contract (replaces the constructor)
function initialize(address _gov, address _keeper, address ibera)
public
initializer;
Parameters
Name | Type | Description |
---|---|---|
_gov | address | Address for admin / gov to upgrade |
_keeper | address | Address for keeper |
ibera | address | The initial InfraredBERA address |
_enoughtime
Checks whether enough time has passed beyond min delay
function _enoughtime(uint96 then, uint96 current)
private
pure
returns (bool has);
Parameters
Name | Type | Description |
---|---|---|
then | uint96 | The block timestamp in past |
current | uint96 | The current block timestamp now |
Returns
Name | Type | Description |
---|---|---|
has | bool | Whether time between then and now exceeds forced min delay |
reserves
Amount of BERA internally set aside to process withdraw compile requests from funds received on successful requests
function reserves() public view returns (uint256);
queue
Queues a withdraw from InfraredBERA for chain withdraw precompile escrowing minimum fees for request to withdraw precompile
function queue(address receiver, uint256 amount)
external
payable
returns (uint256 nonce);
Parameters
Name | Type | Description |
---|---|---|
receiver | address | The address to receive withdrawn funds |
amount | uint256 | The amount of funds to withdraw |
Returns
Name | Type | Description |
---|---|---|
nonce | uint256 | The nonce created when queueing the withdraw |
execute
Executes a withdraw request to withdraw precompile
Payable in case excess bera required to satisfy withdraw precompile fee
function execute(bytes calldata pubkey, uint256 amount) external payable;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | The pubkey to withdraw validator funds from |
amount | uint256 | The amount of funds to withdraw from validator |
process
Processes the funds received from withdraw precompile to next-to-process request receiver
Reverts if balance has not increased by full amount of request for next-to-process request nonce
function process() external;
sweep
Sweeps forced withdrawals to InfraredBERA to re-stake principal
function sweep(bytes calldata pubkey) external;
receive
receive() external payable;
Structs
Request
struct Request {
address receiver;
uint96 timestamp;
uint256 fee;
uint256 amountSubmit;
uint256 amountProcess;
}
Contents
DataTypes
State Variables
NATIVE_ASSET
The address of the native asset as of EIP-7528.
address public constant NATIVE_ASSET =
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
Structs
Token
struct Token {
address tokenAddress;
uint256 amount;
}
Errors
Errors
ZeroAddress
error ZeroAddress();
ZeroAmount
error ZeroAmount();
UnderFlow
error UnderFlow();
InvalidArrayLength
error InvalidArrayLength();
AlreadySet
error AlreadySet();
ValidatorAlreadyExists
error ValidatorAlreadyExists();
FailedToAddValidator
error FailedToAddValidator();
ValidatorDoesNotExist
error ValidatorDoesNotExist();
MaxNumberOfRewards
error MaxNumberOfRewards();
Unauthorized
error Unauthorized(address sender);
IBGTNotRewardToken
error IBGTNotRewardToken();
IREDNotRewardToken
error IREDNotRewardToken();
IBGTNotStakingToken
error IBGTNotStakingToken();
StakedInRewardsVault
error StakedInRewardsVault();
NoRewardsVault
error NoRewardsVault();
RegistrationPaused
error RegistrationPaused();
RewardTokenNotWhitelisted
error RewardTokenNotWhitelisted();
InvalidValidator
error InvalidValidator();
InvalidOperator
error InvalidOperator();
InvalidDepositAmount
error InvalidDepositAmount();
ValidatorAlreadyRemoved
error ValidatorAlreadyRemoved();
VaultNotSupported
error VaultNotSupported();
InvalidNonce
error InvalidNonce();
VaultNotStaked
error VaultNotStaked();
ClaimDistrRewardsFailed
error ClaimDistrRewardsFailed();
ClaimableRewardsExist
error ClaimableRewardsExist();
DuplicateAssetAddress
error DuplicateAssetAddress();
VaultDeploymentFailed
error VaultDeploymentFailed();
RewardTokenNotSupported
error RewardTokenNotSupported();
BGTBalanceMismatch
error BGTBalanceMismatch();
NotInfrared
error NotInfrared();
NotInitialized
error NotInitialized();
InvalidFee
error InvalidFee();
InvalidCommissionRate
error InvalidCommissionRate();
InvalidDelegatee
error InvalidDelegatee();
InvalidWeight
error InvalidWeight();
MaxProtocolFeeAmount
error MaxProtocolFeeAmount();
BoostExceedsSupply
error BoostExceedsSupply();
ETHTransferFailed
error ETHTransferFailed();
TokensReservedForProtocolFees
error TokensReservedForProtocolFees();
NoRewardsToClaim
error NoRewardsToClaim();
InvalidAmount
error InvalidAmount();
InvalidShares
error InvalidShares();
WithdrawalsNotEnabled
error WithdrawalsNotEnabled();
InvalidSignature
error InvalidSignature();
InvalidReceiver
error InvalidReceiver();
CallFailed
error CallFailed();
InvalidReserves
error InvalidReserves();
UnauthorizedOperator
error UnauthorizedOperator();
ValidatorForceExited
error ValidatorForceExited();
InfraredVaultDeployer
Functions
deploy
Deploys a new InfraredVault
or InfraredBGTVault
contract.
If _stakingToken == InfraredBGT, then deploys InfraredBGTVault
.
function deploy(address _stakingToken, uint256 _rewardsDuration)
public
returns (address _new);
Parameters
Name | Type | Description |
---|---|---|
_stakingToken | address | address The address of the staking token. |
_rewardsDuration | uint256 | The duration of the rewards for the vault. |
Returns
Name | Type | Description |
---|---|---|
_new | address | address The address of the new InfraredVault contract. |
Upgradeable
Inherits: UUPSUpgradeable, AccessControlUpgradeable
Provides base upgradeability functionality using UUPS and access control.
State Variables
KEEPER_ROLE
bytes32 public constant KEEPER_ROLE = keccak256("KEEPER_ROLE");
GOVERNANCE_ROLE
bytes32 public constant GOVERNANCE_ROLE = keccak256("GOVERNANCE_ROLE");
Functions
onlyKeeper
Modifier to restrict access to KEEPER_ROLE.
modifier onlyKeeper();
onlyGovernor
Modifier to restrict access to GOVERNANCE_ROLE.
modifier onlyGovernor();
whenInitialized
modifier whenInitialized();
constructor
Note: oz-upgrades-unsafe-allow: constructor
constructor();
__Upgradeable_init
Initialize the upgradeable contract.
function __Upgradeable_init() internal onlyInitializing;
_authorizeUpgrade
Restrict upgrades to only the governor.
function _authorizeUpgrade(address newImplementation)
internal
override
onlyGovernor;
currentImplementation
Returns the current implementation address.
function currentImplementation() external view returns (address);
implementation
Alias for currentImplementation
for clarity.
function implementation() external view returns (address);
Contents
ERC20PresetMinterPauser
Inherits: Context, AccessControlEnumerable, ERC20Burnable, ERC20Pausable
*{ERC20} token, including:
- ability for holders to burn (destroy) their tokens
- a minter role that allows for token minting (creation)
- a pauser role that allows to stop all token transfers This contract uses {AccessControl} to lock permissioned functions using the different roles - head to its documentation for details. The account that deploys the contract will be granted the minter and pauser roles, as well as the default admin role, which will let it grant both minter and pauser roles to other accounts. Deprecated in favor of https://wizard.openzeppelin.com/[Contracts Wizard].*
State Variables
MINTER_ROLE
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
PAUSER_ROLE
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
Functions
constructor
Grants DEFAULT_ADMIN_ROLE
, MINTER_ROLE
and PAUSER_ROLE
to the
account that deploys the contract.
See ERC20-constructor.
constructor(
string memory name,
string memory symbol,
address _admin,
address _minter,
address _pauser
) ERC20(name, symbol);
mint
*Creates amount
new tokens for to
.
See ERC20-_mint.
Requirements:
- the caller must have the
MINTER_ROLE
.*
function mint(address to, uint256 amount) public virtual;
pause
*Pauses all token transfers. See {ERC20Pausable} and {Pausable-_pause}. Requirements:
- the caller must have the
PAUSER_ROLE
.*
function pause() public virtual;
unpause
*Unpauses all token transfers. See {ERC20Pausable} and {Pausable-_unpause}. Requirements:
- the caller must have the
PAUSER_ROLE
.*
function unpause() public virtual;
_update
function _update(address from, address to, uint256 value)
internal
virtual
override(ERC20, ERC20Pausable)
whenNotPaused;
Contents
Contents
IReward
Interface for rewards distribution contracts in the Infrared Voter
Base interface implemented by all reward-type contracts
Functions
DURATION
Duration of each reward epoch in seconds
function DURATION() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Fixed duration of 7 days |
voter
Address of the Voter contract that manages rewards
function voter() external view returns (address);
Returns
Name | Type | Description |
---|---|---|
<none> | address | Voter contract address |
ve
Address of the VotingEscrow contract that manages veNFTs
function ve() external view returns (address);
Returns
Name | Type | Description |
---|---|---|
<none> | address | VotingEscrow contract address |
authorized
Address permitted to call privileged state-changing functions
function authorized() external view returns (address);
Returns
Name | Type | Description |
---|---|---|
<none> | address | Authorized caller address |
totalSupply
Total amount of staking tokens locked in contract
function totalSupply() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Current total supply of staked tokens |
balanceOf
Retrieves current staked balance for a veNFT
function balanceOf(uint256 tokenId) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | ID of the veNFT to query |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Current staked token balance |
tokenRewardsPerEpoch
Gets reward amount allocated for a specific epoch
function tokenRewardsPerEpoch(address token, uint256 epochStart)
external
view
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
token | address | Address of reward token |
epochStart | uint256 | Starting timestamp of epoch |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Amount of token allocated as rewards for the epoch |
lastEarn
Retrieves timestamp of last reward claim for a veNFT
function lastEarn(address token, uint256 tokenId)
external
view
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
token | address | Address of reward token |
tokenId | uint256 | ID of veNFT that claimed |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Timestamp of last claim for this token/veNFT pair |
isReward
Checks if a token is configured as a reward token
function isReward(address token) external view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
token | address | Address of token to check |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | True if token is active for rewards |
numCheckpoints
Number of balance checkpoints for a veNFT
function numCheckpoints(uint256 tokenId) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | ID of veNFT to query |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Number of checkpoints recorded |
supplyNumCheckpoints
Total number of supply checkpoints recorded
function supplyNumCheckpoints() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Count of global supply checkpoints |
checkpoints
Gets balance checkpoint data for a veNFT at specific index
function checkpoints(uint256 tokenId, uint256 index)
external
view
returns (uint256 timestamp, uint256 balanceOf);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | ID of veNFT to query |
index | uint256 | Checkpoint index to read |
Returns
Name | Type | Description |
---|---|---|
timestamp | uint256 | Time checkpoint was created |
balanceOf | uint256 | Balance recorded at checkpoint |
supplyCheckpoints
Gets total supply checkpoint data at specific index
function supplyCheckpoints(uint256 index)
external
view
returns (uint256 timestamp, uint256 supply);
Parameters
Name | Type | Description |
---|---|---|
index | uint256 | Checkpoint index to read |
Returns
Name | Type | Description |
---|---|---|
timestamp | uint256 | Time checkpoint was created |
supply | uint256 | Total supply recorded at checkpoint |
getPriorBalanceIndex
Gets historical balance index for a veNFT at timestamp
Uses binary search to find checkpoint index
function getPriorBalanceIndex(uint256 tokenId, uint256 timestamp)
external
view
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | ID of veNFT to query |
timestamp | uint256 | Time to query balance at |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Index of nearest checkpoint before timestamp |
getPriorSupplyIndex
Gets historical supply index at timestamp
Uses binary search to find checkpoint index
function getPriorSupplyIndex(uint256 timestamp)
external
view
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
timestamp | uint256 | Time to query supply at |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Index of nearest checkpoint before timestamp |
rewardsListLength
Number of tokens configured for rewards
function rewardsListLength() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Length of rewards token list |
earned
Calculates unclaimed rewards for a veNFT
function earned(address token, uint256 tokenId)
external
view
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
token | address | Address of reward token to calculate |
tokenId | uint256 | ID of veNFT to calculate for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Amount of unclaimed rewards |
_deposit
Records a token deposit and updates checkpoints
Can only be called by authorized address
function _deposit(uint256 amount, uint256 tokenId) external;
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | Amount of tokens being deposited |
tokenId | uint256 | ID of veNFT receiving deposit |
_withdraw
Records a token withdrawal and updates checkpoints
Can only be called by authorized address
function _withdraw(uint256 amount, uint256 tokenId) external;
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | Amount of tokens being withdrawn |
tokenId | uint256 | ID of veNFT withdrawing from |
getReward
Claims accumulated rewards for a veNFT
function getReward(uint256 tokenId, address[] memory tokens) external;
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | ID of veNFT claiming rewards |
tokens | address[] | Array of reward token addresses to claim |
notifyRewardAmount
Adds new reward tokens for distribution
Transfers tokens from caller and updates reward accounting
function notifyRewardAmount(address token, uint256 amount) external;
Parameters
Name | Type | Description |
---|---|---|
token | address | Address of token to add as reward |
amount | uint256 | Amount of token to add to rewards |
renotifyRewardAmount
in case rewards where distributed during a epoch with no deposits, redistribute the rewards
function renotifyRewardAmount(uint256 timestamp, address token) external;
Parameters
Name | Type | Description |
---|---|---|
timestamp | uint256 | Timestamp of the start of the epoch to renotify |
token | address | Address of token to renotify |
Events
Deposit
Emitted when tokens are deposited for rewards
event Deposit(address indexed from, uint256 indexed tokenId, uint256 amount);
Parameters
Name | Type | Description |
---|---|---|
from | address | Address depositing tokens |
tokenId | uint256 | ID of the veNFT receiving deposit |
amount | uint256 | Amount of tokens deposited |
Withdraw
Emitted when tokens are withdrawn from rewards
event Withdraw(address indexed from, uint256 indexed tokenId, uint256 amount);
Parameters
Name | Type | Description |
---|---|---|
from | address | Address withdrawing tokens |
tokenId | uint256 | ID of the veNFT withdrawing from |
amount | uint256 | Amount of tokens withdrawn |
NotifyReward
Emitted when new rewards are added
event NotifyReward(
address indexed from,
address indexed reward,
uint256 indexed epoch,
uint256 amount
);
Parameters
Name | Type | Description |
---|---|---|
from | address | Address supplying the reward tokens |
reward | address | Token being added as reward |
epoch | uint256 | Epoch timestamp for reward distribution |
amount | uint256 | Amount of reward tokens added |
ClaimRewards
Emitted when rewards are claimed
event ClaimRewards(
address indexed from, address indexed reward, uint256 amount
);
Parameters
Name | Type | Description |
---|---|---|
from | address | Address claiming the rewards |
reward | address | Token being claimed |
amount | uint256 | Amount of tokens claimed |
Errors
InvalidReward
Thrown when attempting to interact with an invalid reward token
error InvalidReward();
NotAuthorized
Thrown when caller is not authorized to perform operation
error NotAuthorized();
NotWhitelisted
Thrown when token is not in whitelist
error NotWhitelisted();
ZeroAmount
Thrown when attempting operation with zero amount
error ZeroAmount();
NonZeroSupply
Thrown when supply is not zero
error NonZeroSupply();
ActiveEpoch
Thrown when epoch is active
error ActiveEpoch();
Structs
Checkpoint
Balance checkpoint for tracking historical balances
struct Checkpoint {
uint256 timestamp;
uint256 balanceOf;
}
Properties
Name | Type | Description |
---|---|---|
timestamp | uint256 | Time of checkpoint |
balanceOf | uint256 | Balance at checkpoint |
SupplyCheckpoint
Supply checkpoint for tracking total supply
struct SupplyCheckpoint {
uint256 timestamp;
uint256 supply;
}
Properties
Name | Type | Description |
---|---|---|
timestamp | uint256 | Time of checkpoint |
supply | uint256 | Total supply at checkpoint |
IVeArtProxy
Functions
tokenURI
Generate a SVG based on veNFT metadata
function tokenURI(uint256 _tokenId)
external
view
returns (string memory output);
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | Unique veNFT identifier |
Returns
Name | Type | Description |
---|---|---|
output | string | SVG metadata as HTML tag |
lineArtPathsOnly
Generate only the foreground
function lineArtPathsOnly(uint256 _tokenId)
external
view
returns (bytes memory output);
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | Unique veNFT identifier |
Returns
Name | Type | Description |
---|---|---|
output | bytes | Encoded output of generateShape() |
generateConfig
Generate the master art config metadata for a veNFT
function generateConfig(uint256 _tokenId)
external
view
returns (Config memory cfg);
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | Unique veNFT identifier |
Returns
Name | Type | Description |
---|---|---|
cfg | Config | Config struct |
twoStripes
Generate the points for two stripe lines based on the config generated for a veNFT
function twoStripes(Config memory cfg, int256 l)
external
pure
returns (Point[100] memory Line);
Parameters
Name | Type | Description |
---|---|---|
cfg | Config | Master art config metadata of a veNFT |
l | int256 | Number of line drawn |
Returns
Name | Type | Description |
---|---|---|
Line | Point[100] | (x, y) coordinates of the drawn stripes |
circles
Generate the points for circles based on the config generated for a veNFT
function circles(Config memory cfg, int256 l)
external
pure
returns (Point[100] memory Line);
Parameters
Name | Type | Description |
---|---|---|
cfg | Config | Master art config metadata of a veNFT |
l | int256 | Number of circles drawn |
Returns
Name | Type | Description |
---|---|---|
Line | Point[100] | (x, y) coordinates of the drawn circles |
interlockingCircles
Generate the points for interlocking circles based on the config generated for a veNFT
function interlockingCircles(Config memory cfg, int256 l)
external
pure
returns (Point[100] memory Line);
Parameters
Name | Type | Description |
---|---|---|
cfg | Config | Master art config metadata of a veNFT |
l | int256 | Number of interlocking circles drawn |
Returns
Name | Type | Description |
---|---|---|
Line | Point[100] | (x, y) coordinates of the drawn interlocking circles |
corners
Generate the points for corners based on the config generated for a veNFT
function corners(Config memory cfg, int256 l)
external
pure
returns (Point[100] memory Line);
Parameters
Name | Type | Description |
---|---|---|
cfg | Config | Master art config metadata of a veNFT |
l | int256 | Number of corners drawn |
Returns
Name | Type | Description |
---|---|---|
Line | Point[100] | (x, y) coordinates of the drawn corners |
curves
Generate the points for a curve based on the config generated for a veNFT
function curves(Config memory cfg, int256 l)
external
pure
returns (Point[100] memory Line);
Parameters
Name | Type | Description |
---|---|---|
cfg | Config | Master art config metadata of a veNFT |
l | int256 | Number of curve drawn |
Returns
Name | Type | Description |
---|---|---|
Line | Point[100] | (x, y) coordinates of the drawn curve |
spiral
Generate the points for a spiral based on the config generated for a veNFT
function spiral(Config memory cfg, int256 l)
external
pure
returns (Point[100] memory Line);
Parameters
Name | Type | Description |
---|---|---|
cfg | Config | Master art config metadata of a veNFT |
l | int256 | Number of spiral drawn |
Returns
Name | Type | Description |
---|---|---|
Line | Point[100] | (x, y) coordinates of the drawn spiral |
explosion
Generate the points for an explosion based on the config generated for a veNFT
function explosion(Config memory cfg, int256 l)
external
pure
returns (Point[100] memory Line);
Parameters
Name | Type | Description |
---|---|---|
cfg | Config | Master art config metadata of a veNFT |
l | int256 | Number of explosion drawn |
Returns
Name | Type | Description |
---|---|---|
Line | Point[100] | (x, y) coordinates of the drawn explosion |
wormhole
Generate the points for a wormhole based on the config generated for a veNFT
function wormhole(Config memory cfg, int256 l)
external
pure
returns (Point[100] memory Line);
Parameters
Name | Type | Description |
---|---|---|
cfg | Config | Master art config metadata of a veNFT |
l | int256 | Number of wormhole drawn |
Returns
Name | Type | Description |
---|---|---|
Line | Point[100] | (x, y) coordinates of the drawn wormhole |
Structs
Config
Art configuration
struct Config {
int256 _tokenId;
int256 _balanceOf;
int256 _lockedEnd;
int256 _lockedAmount;
int256 shape;
uint256 palette;
int256 maxLines;
int256 dash;
int256 seed1;
int256 seed2;
int256 seed3;
}
lineConfig
Individual line art path variables.
struct lineConfig {
bytes8 color;
uint256 stroke;
uint256 offset;
uint256 offsetHalf;
uint256 offsetDashSum;
uint256 pathLength;
}
Point
Represents an (x,y) coordinate in a line.
struct Point {
int256 x;
int256 y;
}
IVoter
Interface for Infrared's voting system that manages votes for POL CuttingBoard allocation and bribe vault creation
Handles voting power allocation, managed veNFT deposits, and bribe distribution
Functions
ve
Returns the VotingEscrow contract address
function ve() external view returns (address);
Returns
Name | Type | Description |
---|---|---|
<none> | address | Address of the VE token that governs these contracts |
totalWeight
Returns total voting weight across all votes
function totalWeight() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Total weight sum of all active votes |
maxVotingNum
Returns maximum number of staking tokens one voter can vote for
function maxVotingNum() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Maximum number of allowed votes per voter |
feeVault
Returns global fee distribution vault address
function feeVault() external view returns (address);
Returns
Name | Type | Description |
---|---|---|
<none> | address | Address of the fee vault |
bribeVaults
Returns bribe vault address for a given staking token
function bribeVaults(address stakingToken) external view returns (address);
Parameters
Name | Type | Description |
---|---|---|
stakingToken | address | Address of staking token |
Returns
Name | Type | Description |
---|---|---|
<none> | address | Address of associated bribe vault |
weights
Returns total weight allocated to a staking token
function weights(address stakingToken) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
stakingToken | address | Address of staking token |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Total voting weight for the token |
votes
Returns vote weight allocated by token ID for specific staking token
function votes(uint256 tokenId, address stakingToken)
external
view
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | NFT token ID |
stakingToken | address | Address of staking token |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Vote weight allocated |
usedWeights
Returns total vote weight used by specific token ID
function usedWeights(uint256 tokenId) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | NFT token ID |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Total used voting weight |
lastVoted
Returns timestamp of last vote for a token ID
function lastVoted(uint256 tokenId) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | NFT token ID |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Timestamp of last vote |
isWhitelistedToken
Checks if a token is whitelisted for rewards
function isWhitelistedToken(address token) external view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
token | address | Address of token to check |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | True if token is whitelisted |
isWhitelistedNFT
Checks if NFT is whitelisted for special voting
function isWhitelistedNFT(uint256 tokenId) external view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | NFT token ID to check |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | True if NFT is whitelisted |
isAlive
Checks if bribe vault is active
function isAlive(address bribeVault) external view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
bribeVault | address | Address of bribe vault to check |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | True if vault is active |
length
Returns number of staking tokens with active bribe vaults
function length() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Count of staking tokens with bribe vaults |
epochStart
Calculates start of epoch containing timestamp
function epochStart(uint256 _timestamp) external pure returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_timestamp | uint256 | Input timestamp |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Start of epoch time |
epochNext
Calculates start of next epoch after timestamp
function epochNext(uint256 _timestamp) external pure returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_timestamp | uint256 | Input timestamp |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Start of next epoch time |
epochVoteStart
Calculates start of voting window for epoch containing timestamp
function epochVoteStart(uint256 _timestamp) external pure returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_timestamp | uint256 | Input timestamp |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Vote window start time |
epochVoteEnd
Calculates end of voting window for epoch containing timestamp
function epochVoteEnd(uint256 _timestamp) external pure returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_timestamp | uint256 | Input timestamp |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Vote window end time |
poke
Updates voting balances in rewards contracts for a token ID
Should be called after any action that affects vote weight
function poke(uint256 _tokenId) external;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | veNFT token ID to update |
vote
Distributes voting weight to multiple staking tokens
Weight is allocated proportionally based on provided weights
function vote(
uint256 _tokenId,
address[] calldata _stakingTokenVote,
uint256[] calldata _weights
) external;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | veNFT token ID voting with |
_stakingTokenVote | address[] | Array of staking token addresses receiving votes |
_weights | uint256[] | Array of weights to allocate to each token |
reset
Resets voting state for a token ID
Required before making changes to veNFT state
function reset(uint256 _tokenId) external;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | veNFT token ID to reset |
depositManaged
Deposits veNFT into a managed NFT
NFT will be re-locked to max time on withdrawal
function depositManaged(uint256 _tokenId, uint256 _mTokenId) external;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | veNFT token ID to deposit |
_mTokenId | uint256 | Managed NFT token ID to deposit into |
withdrawManaged
Withdraws veNFT from a managed NFT
Withdrawing locks NFT to max lock time
function withdrawManaged(uint256 _tokenId) external;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | veNFT token ID to withdraw |
claimBribes
Claims bribes from multiple sources for a veNFT
function claimBribes(
address[] memory _bribes,
address[][] memory _tokens,
uint256 _tokenId
) external;
Parameters
Name | Type | Description |
---|---|---|
_bribes | address[] | Array of bribe vault addresses to claim from |
_tokens | address[][] | Array of reward tokens to claim for each vault |
_tokenId | uint256 | veNFT token ID to claim for |
claimFees
Claims fee rewards for a veNFT
function claimFees(address[] memory _tokens, uint256 _tokenId) external;
Parameters
Name | Type | Description |
---|---|---|
_tokens | address[] | Array of fee tokens to claim |
_tokenId | uint256 | veNFT token ID to claim for |
setMaxVotingNum
Updates maximum allowed votes per voter
function setMaxVotingNum(uint256 _maxVotingNum) external;
Parameters
Name | Type | Description |
---|---|---|
_maxVotingNum | uint256 | New maximum number of allowed votes |
whitelistNFT
Updates whitelist status for veNFT for privileged voting
function whitelistNFT(uint256 _tokenId, bool _bool) external;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | veNFT token ID to update |
_bool | bool | New whitelist status |
createBribeVault
Creates new bribe vault for staking token
function createBribeVault(
address _stakingToken,
address[] calldata _rewardTokens
) external returns (address);
Parameters
Name | Type | Description |
---|---|---|
_stakingToken | address | Address of staking token |
_rewardTokens | address[] | Array of reward token addresses |
Returns
Name | Type | Description |
---|---|---|
<none> | address | Address of created bribe vault |
killBribeVault
Disables a bribe vault
function killBribeVault(address _stakingToken) external;
Parameters
Name | Type | Description |
---|---|---|
_stakingToken | address | Address of staking token for vault to disable |
reviveBribeVault
Re-enables a disabled bribe vault
function reviveBribeVault(address _stakingToken) external;
Parameters
Name | Type | Description |
---|---|---|
_stakingToken | address | Address of staking token for vault to re-enable |
Events
BribeVaultCreated
Emitted when a new bribe vault is created
event BribeVaultCreated(
address stakingToken, address bribeVault, address creator
);
Parameters
Name | Type | Description |
---|---|---|
stakingToken | address | The staking token address for which the vault was created |
bribeVault | address | The address of the newly created bribe vault |
creator | address | The address that created the bribe vault |
BribeVaultKilled
Emitted when a bribe vault is killed (disabled)
event BribeVaultKilled(address indexed bribeVault);
Parameters
Name | Type | Description |
---|---|---|
bribeVault | address | The address of the killed bribe vault |
BribeVaultRevived
Emitted when a killed bribe vault is revived (re-enabled)
event BribeVaultRevived(address indexed bribeVault);
Parameters
Name | Type | Description |
---|---|---|
bribeVault | address | The address of the revived bribe vault |
Voted
Emitted when votes are cast for a staking token
event Voted(
address indexed voter,
address indexed stakingToken,
uint256 indexed tokenId,
uint256 weight,
uint256 totalWeight,
uint256 timestamp
);
Parameters
Name | Type | Description |
---|---|---|
voter | address | Address of the account casting the vote |
stakingToken | address | The staking token being voted for |
tokenId | uint256 | ID of the veNFT used to vote |
weight | uint256 | Vote weight allocated |
totalWeight | uint256 | New total vote weight for the staking token |
timestamp | uint256 | Block timestamp when vote was cast |
Abstained
Emitted when votes are withdrawn/reset
event Abstained(
address indexed voter,
address indexed stakingToken,
uint256 indexed tokenId,
uint256 weight,
uint256 totalWeight,
uint256 timestamp
);
Parameters
Name | Type | Description |
---|---|---|
voter | address | Address of the account withdrawing votes |
stakingToken | address | The staking token votes are withdrawn from |
tokenId | uint256 | ID of the veNFT used to vote |
weight | uint256 | Vote weight withdrawn |
totalWeight | uint256 | New total vote weight for the staking token |
timestamp | uint256 | Block timestamp when votes were withdrawn |
WhitelistNFT
Emitted when an NFT's whitelist status changes
event WhitelistNFT(
address indexed whitelister, uint256 indexed tokenId, bool indexed _bool
);
Parameters
Name | Type | Description |
---|---|---|
whitelister | address | Address making the whitelist change |
tokenId | uint256 | ID of the NFT being whitelisted/unwhitelisted |
_bool | bool | New whitelist status |
SkipKilledBribeVault
Emitted when a killed bribe vault is skipped
event SkipKilledBribeVault(
address indexed stakingToken, uint256 indexed tokenId
);
Parameters
Name | Type | Description |
---|---|---|
stakingToken | address | Address of staking token for vault to skip |
tokenId | uint256 | ID of the veNFT used to vote |
MaxVotingNumSet
Emitted when maximum voting number is set
event MaxVotingNumSet(uint256 indexed maxVotingNum);
Parameters
Name | Type | Description |
---|---|---|
maxVotingNum | uint256 | New maximum number of allowed votes |
Errors
AlreadyVotedOrDeposited
error AlreadyVotedOrDeposited();
BribeVaultAlreadyKilled
error BribeVaultAlreadyKilled();
BribeVaultAlreadyRevived
error BribeVaultAlreadyRevived();
BribeVaultExists
error BribeVaultExists();
BribeVaultDoesNotExist
error BribeVaultDoesNotExist(address _stakingToken);
BribeVaultNotAlive
error BribeVaultNotAlive(address _stakingToken);
InactiveManagedNFT
error InactiveManagedNFT();
MaximumVotingNumberTooLow
error MaximumVotingNumberTooLow();
NonZeroVotes
error NonZeroVotes();
NotAStakingToken
error NotAStakingToken();
NotApprovedOrOwner
error NotApprovedOrOwner();
NotWhitelistedNFT
error NotWhitelistedNFT();
NotWhitelistedToken
error NotWhitelistedToken();
SameValue
error SameValue();
SpecialVotingWindow
error SpecialVotingWindow();
TooManyStakingTokens
error TooManyStakingTokens();
UnequalLengths
error UnequalLengths();
ZeroBalance
error ZeroBalance();
ZeroAddress
error ZeroAddress();
VaultNotRegistered
error VaultNotRegistered();
NotGovernor
error NotGovernor();
DistributeWindow
error DistributeWindow();
IVotes
Modified IVotes interface for tokenId based voting
Functions
getPastVotes
Returns the amount of votes that tokenId
had at a specific moment in the past.
If the account passed in is not the owner, returns 0.
function getPastVotes(address account, uint256 tokenId, uint256 timepoint)
external
view
returns (uint256);
getPastTotalSupply
Returns the total supply of votes available at a specific moment in the past. If the clock()
is
configured to use block numbers, this will return the value the end of the corresponding block.
NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.
Votes that have not been delegated are still part of total supply, even though they would not participate in a
vote.
function getPastTotalSupply(uint256 timepoint)
external
view
returns (uint256);
delegates
Returns the delegate that tokenId
has chosen. Can never be equal to the delegator's tokenId
.
Returns 0 if not delegated.
function delegates(uint256 tokenId) external view returns (uint256);
delegate
Delegates votes from the sender to delegatee
.
function delegate(uint256 delegator, uint256 delegatee) external;
delegateBySig
Delegates votes from delegator
to delegatee
. Signer must own delegator
.
function delegateBySig(
uint256 delegator,
uint256 delegatee,
uint256 nonce,
uint256 expiry,
uint8 v,
bytes32 r,
bytes32 s
) external;
Events
DelegateChanged
Emitted when an account changes their delegate.
event DelegateChanged(
address indexed delegator,
uint256 indexed fromDelegate,
uint256 indexed toDelegate
);
DelegateVotesChanged
Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.
event DelegateVotesChanged(
address indexed delegate, uint256 previousBalance, uint256 newBalance
);
IVotingEscrow
Inherits: IVotes, IERC4906, IERC6372, IERC721Metadata
Functions
token
Address of token (RED) used to create a veNFT
function token() external view returns (address);
distributor
Address of RewardsDistributor.sol
function distributor() external view returns (address);
voter
Address of Voter.sol
function voter() external view returns (address);
artProxy
Address of art proxy used for on-chain art generation
function artProxy() external view returns (address);
allowedManager
address which can create managed NFTs
function allowedManager() external view returns (address);
tokenId
Current count of token
function tokenId() external view returns (uint256);
infrared
Address of Infrared contract
function infrared() external view returns (IInfraredUpgradeable);
Returns
Name | Type | Description |
---|---|---|
<none> | IInfraredUpgradeable | IInfrared instance of contract address |
escrowType
Mapping of token id to escrow type Takes advantage of the fact default value is EscrowType.NORMAL
function escrowType(uint256 tokenId) external view returns (EscrowType);
idToManaged
Mapping of token id to managed id
function idToManaged(uint256 tokenId)
external
view
returns (uint256 managedTokenId);
weights
Mapping of user token id to managed token id to weight of token id
function weights(uint256 tokenId, uint256 managedTokenId)
external
view
returns (uint256 weight);
deactivated
Mapping of managed id to deactivated state
function deactivated(uint256 tokenId) external view returns (bool inactive);
createManagedLockFor
Create managed NFT (a permanent lock) for use within ecosystem.
Throws if address already owns a managed NFT.
function createManagedLockFor(address _to)
external
returns (uint256 _mTokenId);
Returns
Name | Type | Description |
---|---|---|
_mTokenId | uint256 | managed token id. |
depositManaged
Delegates balance to managed nft Note that NFTs deposited into a managed NFT will be re-locked to the maximum lock time on withdrawal. Permanent locks that are deposited will automatically unlock.
Managed nft will remain max-locked as long as there is at least one deposit or withdrawal per week. Throws if deposit nft is managed. Throws if recipient nft is not managed. Throws if deposit nft is already locked. Throws if not called by voter.
function depositManaged(uint256 _tokenId, uint256 _mTokenId) external;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | tokenId of NFT being deposited |
_mTokenId | uint256 | tokenId of managed NFT that will receive the deposit |
withdrawManaged
Retrieves locked rewards and withdraws balance from managed nft. Note that the NFT withdrawn is re-locked to the maximum lock time.
Throws if NFT not locked. Throws if not called by voter.
function withdrawManaged(uint256 _tokenId) external;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | tokenId of NFT being deposited. |
setAllowedManager
Permit one address to call createManagedLockFor() that is not Voter.governor()
function setAllowedManager(address _allowedManager) external;
setManagedState
Set Managed NFT state. Inactive NFTs cannot be deposited into.
function setManagedState(uint256 _mTokenId, bool _state) external;
Parameters
Name | Type | Description |
---|---|---|
_mTokenId | uint256 | managed nft state to set |
_state | bool | true => inactive, false => active |
name
function name() external view returns (string memory);
symbol
function symbol() external view returns (string memory);
version
function version() external view returns (string memory);
decimals
function decimals() external view returns (uint8);
setArtProxy
function setArtProxy(address _proxy) external;
tokenURI
A distinct Uniform Resource Identifier (URI) for a given asset.
Throws if _tokenId
is not a valid NFT. URIs are defined in RFC
3986. The URI may point to a JSON file that conforms to the "ERC721
Metadata JSON Schema".
function tokenURI(uint256 tokenId) external view returns (string memory);
ownerToNFTokenIdList
Mapping from owner address to mapping of index to tokenId
function ownerToNFTokenIdList(address _owner, uint256 _index)
external
view
returns (uint256 _tokenId);
ownerOf
Find the owner of an NFT
NFTs assigned to zero address are considered invalid, and queries about them do throw.
function ownerOf(uint256 tokenId) external view returns (address owner);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 |
Returns
Name | Type | Description |
---|---|---|
owner | address | The address of the owner of the NFT |
balanceOf
Count all NFTs assigned to an owner
NFTs assigned to the zero address are considered invalid, and this function throws for queries about the zero address.
function balanceOf(address owner) external view returns (uint256 balance);
Parameters
Name | Type | Description |
---|---|---|
owner | address |
Returns
Name | Type | Description |
---|---|---|
balance | uint256 | The number of NFTs owned by _owner , possibly zero |
getApproved
Get the approved address for a single NFT
Throws if _tokenId
is not a valid NFT.
function getApproved(uint256 _tokenId)
external
view
returns (address operator);
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | The NFT to find the approved address for |
Returns
Name | Type | Description |
---|---|---|
operator | address | The approved address for this NFT, or the zero address if there is none |
isApprovedForAll
Query if an address is an authorized operator for another address
function isApprovedForAll(address owner, address operator)
external
view
returns (bool);
Parameters
Name | Type | Description |
---|---|---|
owner | address | |
operator | address |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | True if _operator is an approved operator for _owner , false otherwise |
isApprovedOrOwner
Check whether spender is owner or an approved user for a given veNFT
function isApprovedOrOwner(address _spender, uint256 _tokenId)
external
returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_spender | address | . |
_tokenId | uint256 | . |
approve
Change or reaffirm the approved address for an NFT
The zero address indicates there is no approved address.
Throws unless msg.sender
is the current NFT owner, or an authorized
operator of the current owner.
function approve(address to, uint256 tokenId) external;
Parameters
Name | Type | Description |
---|---|---|
to | address | |
tokenId | uint256 |
setApprovalForAll
Enable or disable approval for a third party ("operator") to manage
all of msg.sender
's assets
Emits the ApprovalForAll event. The contract MUST allow multiple operators per owner.
function setApprovalForAll(address operator, bool approved) external;
Parameters
Name | Type | Description |
---|---|---|
operator | address | |
approved | bool |
transferFrom
Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE
TO CONFIRM THAT _to
IS CAPABLE OF RECEIVING NFTS OR ELSE
THEY MAY BE PERMANENTLY LOST
Throws unless msg.sender
is the current owner, an authorized
operator, or the approved address for this NFT. Throws if _from
is
not the current owner. Throws if _to
is the zero address. Throws if
_tokenId
is not a valid NFT.
function transferFrom(address from, address to, uint256 tokenId) external;
Parameters
Name | Type | Description |
---|---|---|
from | address | |
to | address | |
tokenId | uint256 |
safeTransferFrom
Transfers the ownership of an NFT from one address to another address
Throws unless msg.sender
is the current owner, an authorized
operator, or the approved address for this NFT. Throws if _from
is
not the current owner. Throws if _to
is the zero address. Throws if
_tokenId
is not a valid NFT. When transfer is complete, this function
checks if _to
is a smart contract (code size > 0). If so, it calls
onERC721Received
on _to
and throws if the return value is not
bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))
.
function safeTransferFrom(address from, address to, uint256 tokenId) external;
Parameters
Name | Type | Description |
---|---|---|
from | address | |
to | address | |
tokenId | uint256 |
safeTransferFrom
Transfers the ownership of an NFT from one address to another address
Throws unless msg.sender
is the current owner, an authorized
operator, or the approved address for this NFT. Throws if _from
is
not the current owner. Throws if _to
is the zero address. Throws if
_tokenId
is not a valid NFT. When transfer is complete, this function
checks if _to
is a smart contract (code size > 0). If so, it calls
onERC721Received
on _to
and throws if the return value is not
bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))
.
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
Parameters
Name | Type | Description |
---|---|---|
from | address | |
to | address | |
tokenId | uint256 | |
data | bytes | Additional data with no specified format, sent in call to _to |
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 _interfaceID) external view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_interfaceID | bytes4 |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
epoch
Total count of epochs witnessed since contract creation
function epoch() external view returns (uint256);
supply
Total amount of token() deposited
function supply() external view returns (uint256);
permanentLockBalance
Aggregate permanent locked balances
function permanentLockBalance() external view returns (uint256);
userPointEpoch
function userPointEpoch(uint256 _tokenId)
external
view
returns (uint256 _epoch);
slopeChanges
time -> signed slope change
function slopeChanges(uint256 _timestamp) external view returns (int128);
canSplit
account -> can split
function canSplit(address _account) external view returns (bool);
pointHistory
Global point history at a given index
function pointHistory(uint256 _loc)
external
view
returns (GlobalPoint memory);
locked
Get the LockedBalance (amount, end) of a _tokenId
function locked(uint256 _tokenId)
external
view
returns (LockedBalance memory);
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | . |
Returns
Name | Type | Description |
---|---|---|
<none> | LockedBalance | LockedBalance of _tokenId |
userPointHistory
User -> UserPoint[userEpoch]
function userPointHistory(uint256 _tokenId, uint256 _loc)
external
view
returns (UserPoint memory);
checkpoint
Record global data to checkpoint
function checkpoint() external;
depositFor
Deposit _value
tokens for _tokenId
and add to the lock
Anyone (even a smart contract) can deposit for someone else, but cannot extend their locktime and deposit for a brand new user
function depositFor(uint256 _tokenId, uint256 _value) external;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | lock NFT |
_value | uint256 | Amount to add to user's lock |
createLock
Deposit _value
tokens for msg.sender
and lock for _lockDuration
function createLock(uint256 _value, uint256 _lockDuration)
external
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_value | uint256 | Amount to deposit |
_lockDuration | uint256 | Number of seconds to lock tokens for (rounded down to nearest week) |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | TokenId of created veNFT |
createLockFor
Deposit _value
tokens for _to
and lock for _lockDuration
function createLockFor(uint256 _value, uint256 _lockDuration, address _to)
external
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_value | uint256 | Amount to deposit |
_lockDuration | uint256 | Number of seconds to lock tokens for (rounded down to nearest week) |
_to | address | Address to deposit |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | TokenId of created veNFT |
increaseAmount
Deposit _value
additional tokens for _tokenId
without modifying the unlock time
function increaseAmount(uint256 _tokenId, uint256 _value) external;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | |
_value | uint256 | Amount of tokens to deposit and add to the lock |
increaseUnlockTime
Extend the unlock time for _tokenId
Cannot extend lock time of permanent locks
function increaseUnlockTime(uint256 _tokenId, uint256 _lockDuration) external;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | |
_lockDuration | uint256 | New number of seconds until tokens unlock |
withdraw
Withdraw all tokens for _tokenId
Only possible if the lock is both expired and not permanent This will burn the veNFT. Any rebases or rewards that are unclaimed will no longer be claimable. Claim all rebases and rewards prior to calling this.
function withdraw(uint256 _tokenId) external;
merge
Merges _from
into _to
.
Cannot merge _from
locks that are permanent or have already voted this epoch.
Cannot merge _to
locks that have already expired.
This will burn the veNFT. Any rebases or rewards that are unclaimed
will no longer be claimable. Claim all rebases and rewards prior to calling this.
function merge(uint256 _from, uint256 _to) external;
Parameters
Name | Type | Description |
---|---|---|
_from | uint256 | VeNFT to merge from. |
_to | uint256 | VeNFT to merge into. |
split
Splits veNFT into two new veNFTS - one with oldLocked.amount - _amount
, and the second with _amount
This burns the tokenId of the target veNFT
Callable by approved or owner
If this is called by approved, approved will not have permissions to manipulate the newly created veNFTs
Returns the two new split veNFTs to owner
If from
is permanent, will automatically dedelegate.
This will burn the veNFT. Any rebases or rewards that are unclaimed
will no longer be claimable. Claim all rebases and rewards prior to calling this.
function split(uint256 _from, uint256 _amount)
external
returns (uint256 _tokenId1, uint256 _tokenId2);
Parameters
Name | Type | Description |
---|---|---|
_from | uint256 | VeNFT to split. |
_amount | uint256 | Amount to split from veNFT. |
Returns
Name | Type | Description |
---|---|---|
_tokenId1 | uint256 | Return tokenId of veNFT with oldLocked.amount - _amount . |
_tokenId2 | uint256 | Return tokenId of veNFT with _amount . |
toggleSplit
Toggle split for a specific address.
Toggle split for address(0) to enable or disable for all.
function toggleSplit(address _account, bool _bool) external;
Parameters
Name | Type | Description |
---|---|---|
_account | address | Address to toggle split permissions |
_bool | bool | True to allow, false to disallow |
lockPermanent
Permanently lock a veNFT. Voting power will be equal to
LockedBalance.amount
with no decay. Required to delegate.
Only callable by unlocked normal veNFTs.
function lockPermanent(uint256 _tokenId) external;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | tokenId to lock. |
unlockPermanent
Unlock a permanently locked veNFT. Voting power will decay. Will automatically dedelegate if delegated.
Only callable by permanently locked veNFTs. Cannot unlock if already voted this epoch.
function unlockPermanent(uint256 _tokenId) external;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | tokenId to unlock. |
balanceOfNFT
Get the voting power for _tokenId at the current timestamp
Returns 0 if called in the same block as a transfer.
function balanceOfNFT(uint256 _tokenId) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | . |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Voting power |
balanceOfNFTAt
Get the voting power for _tokenId at a given timestamp
function balanceOfNFTAt(uint256 _tokenId, uint256 _t)
external
view
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | . |
_t | uint256 | Timestamp to query voting power |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Voting power |
totalSupply
Calculate total voting power at current timestamp
function totalSupply() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Total voting power at current timestamp |
totalSupplyAt
Calculate total voting power at a given timestamp
function totalSupplyAt(uint256 _t) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_t | uint256 | Timestamp to query total voting power |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Total voting power at given timestamp |
voted
See if a queried _tokenId has actively voted
function voted(uint256 _tokenId) external view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | . |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | True if voted, else false |
setVoterAndDistributor
Set the global state voter and distributor
This is only called once, at setup
function setVoterAndDistributor(address _voter, address _distributor)
external;
voting
Set voted
for _tokenId to true or false
Only callable by voter
function voting(uint256 _tokenId, bool _voted) external;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | . |
_voted | bool | . |
numCheckpoints
The number of checkpoints for each tokenId
function numCheckpoints(uint256 tokenId) external view returns (uint48);
nonces
A record of states for signing / validating signatures
function nonces(address account) external view returns (uint256);
delegates
Returns the delegate that tokenId
has chosen. Can never be equal to the delegator's tokenId
.
Returns 0 if not delegated.
function delegates(uint256 delegator) external view returns (uint256);
checkpoints
A record of delegated token checkpoints for each account, by index
function checkpoints(uint256 tokenId, uint48 index)
external
view
returns (Checkpoint memory);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | . |
index | uint48 | . |
Returns
Name | Type | Description |
---|---|---|
<none> | Checkpoint | Checkpoint |
getPastVotes
Returns the amount of votes that tokenId
had at a specific moment in the past.
If the account passed in is not the owner, returns 0.
function getPastVotes(address account, uint256 tokenId, uint256 timestamp)
external
view
returns (uint256);
getPastTotalSupply
Returns the total supply of votes available at a specific moment in the past. If the clock()
is
configured to use block numbers, this will return the value the end of the corresponding block.
NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.
Votes that have not been delegated are still part of total supply, even though they would not participate in a
vote.
function getPastTotalSupply(uint256 timestamp)
external
view
returns (uint256);
delegate
Delegates votes from the sender to delegatee
.
function delegate(uint256 delegator, uint256 delegatee) external;
delegateBySig
Delegates votes from delegator
to delegatee
. Signer must own delegator
.
function delegateBySig(
uint256 delegator,
uint256 delegatee,
uint256 nonce,
uint256 expiry,
uint8 v,
bytes32 r,
bytes32 s
) external;
clock
Clock used for flagging checkpoints. Can be overridden to implement timestamp based checkpoints (and voting).
function clock() external view returns (uint48);
CLOCK_MODE
Description of the clock
function CLOCK_MODE() external view returns (string memory);
Events
Deposit
event Deposit(
address indexed provider,
uint256 indexed tokenId,
DepositType indexed depositType,
uint256 value,
uint256 locktime,
uint256 ts
);
Withdraw
event Withdraw(
address indexed provider, uint256 indexed tokenId, uint256 value, uint256 ts
);
LockPermanent
event LockPermanent(
address indexed _owner,
uint256 indexed _tokenId,
uint256 amount,
uint256 _ts
);
UnlockPermanent
event UnlockPermanent(
address indexed _owner,
uint256 indexed _tokenId,
uint256 amount,
uint256 _ts
);
Supply
event Supply(uint256 prevSupply, uint256 supply);
Merge
event Merge(
address indexed _sender,
uint256 indexed _from,
uint256 indexed _to,
uint256 _amountFrom,
uint256 _amountTo,
uint256 _amountFinal,
uint256 _locktime,
uint256 _ts
);
Split
event Split(
uint256 indexed _from,
uint256 indexed _tokenId1,
uint256 indexed _tokenId2,
address _sender,
uint256 _splitAmount1,
uint256 _splitAmount2,
uint256 _locktime,
uint256 _ts
);
CreateManaged
event CreateManaged(
address indexed _to, uint256 indexed _mTokenId, address indexed _from
);
DepositManaged
event DepositManaged(
address indexed _owner,
uint256 indexed _tokenId,
uint256 indexed _mTokenId,
uint256 _weight,
uint256 _ts
);
WithdrawManaged
event WithdrawManaged(
address indexed _owner,
uint256 indexed _tokenId,
uint256 indexed _mTokenId,
uint256 _weight,
uint256 _ts
);
SetAllowedManager
event SetAllowedManager(address indexed _allowedManager);
ToggleSplit
event ToggleSplit(address indexed account, bool indexed canSplit);
VoterAndDistributorSet
event VoterAndDistributorSet(
address indexed voter, address indexed distributor
);
Errors
AlreadyVoted
error AlreadyVoted();
AmountTooBig
error AmountTooBig();
ERC721ReceiverRejectedTokens
error ERC721ReceiverRejectedTokens();
ERC721TransferToNonERC721ReceiverImplementer
error ERC721TransferToNonERC721ReceiverImplementer();
InvalidNonce
error InvalidNonce();
InvalidSignature
error InvalidSignature();
InvalidSignatureS
error InvalidSignatureS();
InvalidManagedNFTId
error InvalidManagedNFTId();
LockDurationNotInFuture
error LockDurationNotInFuture();
LockDurationTooLong
error LockDurationTooLong();
LockExpired
error LockExpired();
LockNotExpired
error LockNotExpired();
NoLockFound
error NoLockFound();
NonExistentToken
error NonExistentToken();
NotApprovedOrOwner
error NotApprovedOrOwner();
NotDistributor
error NotDistributor();
NotEmergencyCouncilOrGovernor
error NotEmergencyCouncilOrGovernor();
NotGovernor
error NotGovernor();
NotGovernorOrManager
error NotGovernorOrManager();
NotManagedNFT
error NotManagedNFT();
NotManagedOrNormalNFT
error NotManagedOrNormalNFT();
NotLockedNFT
error NotLockedNFT();
NotNormalNFT
error NotNormalNFT();
NotPermanentLock
error NotPermanentLock();
NotOwner
error NotOwner();
NotTeam
error NotTeam();
NotVoter
error NotVoter();
OwnershipChange
error OwnershipChange();
PermanentLock
error PermanentLock();
SameAddress
error SameAddress();
SameNFT
error SameNFT();
SameState
error SameState();
SplitNoOwner
error SplitNoOwner();
SplitNotAllowed
error SplitNotAllowed();
SignatureExpired
error SignatureExpired();
TooManyTokenIDs
error TooManyTokenIDs();
ZeroAddress
error ZeroAddress();
ZeroAmount
error ZeroAmount();
ZeroBalance
error ZeroBalance();
Structs
LockedBalance
Represents a locked token balance in the voting escrow system
struct LockedBalance {
int128 amount;
uint256 end;
bool isPermanent;
}
Properties
Name | Type | Description |
---|---|---|
amount | int128 | The amount of tokens locked by the user |
end | uint256 | The expiration timestamp for the lock |
isPermanent | bool | Flag indicating if the lock is permanent |
UserPoint
Represents a snapshot of a user's voting power at a given point
struct UserPoint {
int128 bias;
int128 slope;
uint256 ts;
uint256 blk;
uint256 permanent;
}
Properties
Name | Type | Description |
---|---|---|
bias | int128 | Voting power, decaying over time |
slope | int128 | Rate of decay of voting power |
ts | uint256 | Timestamp of this snapshot |
blk | uint256 | Block number of this snapshot |
permanent | uint256 | Amount locked permanently without decay |
GlobalPoint
Tracks cumulative voting power and its decay across all users
struct GlobalPoint {
int128 bias;
int128 slope;
uint256 ts;
uint256 blk;
uint256 permanentLockBalance;
}
Properties
Name | Type | Description |
---|---|---|
bias | int128 | Total voting power, decaying over time |
slope | int128 | Global decay rate of voting power |
ts | uint256 | Timestamp of this global checkpoint |
blk | uint256 | Block number of this global checkpoint |
permanentLockBalance | uint256 | Cumulative balance of permanently locked tokens |
Checkpoint
Snapshot of delegated voting weights at a particular timestamp
struct Checkpoint {
uint256 fromTimestamp;
address owner;
uint256 delegatedBalance;
uint256 delegatee;
}
Properties
Name | Type | Description |
---|---|---|
fromTimestamp | uint256 | Timestamp when the delegation was made |
owner | address | Address of the NFT owner |
delegatedBalance | uint256 | Balance that has been delegated |
delegatee | uint256 | Address receiving the delegated voting power |
Enums
DepositType
Types of deposits supported in the voting escrow contract
enum DepositType {
DEPOSIT_FOR_TYPE,
CREATE_LOCK_TYPE,
INCREASE_LOCK_AMOUNT,
INCREASE_UNLOCK_TIME
}
EscrowType
Specifies the type of voting escrow NFT (veNFT)
enum EscrowType {
NORMAL,
LOCKED,
MANAGED
}
Contents
BalanceLogicLibrary
State Variables
WEEK
uint256 internal constant WEEK = 1 weeks;
Functions
getPastUserPointIndex
Binary search to get the user point index for a token id at or prior to a given timestamp
If a user point does not exist prior to the timestamp, this will return 0.
function getPastUserPointIndex(
mapping(uint256 => uint256) storage _userPointEpoch,
mapping(uint256 => IVotingEscrow.UserPoint[1000000000]) storage
_userPointHistory,
uint256 _tokenId,
uint256 _timestamp
) internal view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_userPointEpoch | mapping(uint256 => uint256) | State of all user point epochs |
_userPointHistory | mapping(uint256 => IVotingEscrow.UserPoint[1000000000]) | State of all user point history |
_tokenId | uint256 | . |
_timestamp | uint256 | . |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | User point index |
getPastGlobalPointIndex
Binary search to get the global point index at or prior to a given timestamp
If a checkpoint does not exist prior to the timestamp, this will return 0.
function getPastGlobalPointIndex(
uint256 _epoch,
mapping(uint256 => IVotingEscrow.GlobalPoint) storage _pointHistory,
uint256 _timestamp
) internal view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_epoch | uint256 | Current global point epoch |
_pointHistory | mapping(uint256 => IVotingEscrow.GlobalPoint) | State of all global point history |
_timestamp | uint256 | . |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Global point index |
balanceOfNFTAt
Get the current voting power for _tokenId
Adheres to the ERC20 balanceOf
interface for Aragon compatibility
Although only true of curve, but not solidly and its forks.
Fetches last user point prior to a certain timestamp, then walks forward to timestamp.
function balanceOfNFTAt(
mapping(uint256 => uint256) storage _userPointEpoch,
mapping(uint256 => IVotingEscrow.UserPoint[1000000000]) storage
_userPointHistory,
uint256 _tokenId,
uint256 _t
) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_userPointEpoch | mapping(uint256 => uint256) | State of all user point epochs |
_userPointHistory | mapping(uint256 => IVotingEscrow.UserPoint[1000000000]) | State of all user point history |
_tokenId | uint256 | NFT for lock |
_t | uint256 | Epoch time to return voting power at |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | User voting power |
supplyAt
Calculate total voting power at some point in the past
function supplyAt(
mapping(uint256 => int128) storage _slopeChanges,
mapping(uint256 => IVotingEscrow.GlobalPoint) storage _pointHistory,
uint256 _epoch,
uint256 _t
) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_slopeChanges | mapping(uint256 => int128) | State of all slopeChanges |
_pointHistory | mapping(uint256 => IVotingEscrow.GlobalPoint) | State of all global point history |
_epoch | uint256 | The epoch to start search from |
_t | uint256 | Time to calculate the total voting power at |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Total voting power at that time |
DelegationLogicLibrary
Functions
checkpointDelegator
Used by _mint
, _transferFrom
, _burn
and delegate
to update delegator voting checkpoints.
Automatically dedelegates, then updates checkpoint.
This function depends on _locked
and must be called prior to token state changes.
If you wish to dedelegate only, use _delegate(tokenId, 0)
instead.
function checkpointDelegator(
mapping(uint256 => IVotingEscrow.LockedBalance) storage _locked,
mapping(uint256 => uint48) storage _numCheckpoints,
mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) storage
_checkpoints,
mapping(uint256 => uint256) storage _delegates,
uint256 _delegator,
uint256 _delegatee,
address _owner
) external;
Parameters
Name | Type | Description |
---|---|---|
_locked | mapping(uint256 => IVotingEscrow.LockedBalance) | State of all locked balances |
_numCheckpoints | mapping(uint256 => uint48) | State of all user checkpoint counts |
_checkpoints | mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) | State of all user checkpoints |
_delegates | mapping(uint256 => uint256) | State of all user delegatees |
_delegator | uint256 | The delegator to update checkpoints for |
_delegatee | uint256 | The new delegatee for the delegator. Cannot be equal to _delegator (use 0 instead). |
_owner | address | The new (or current) owner for the delegator |
checkpointDelegatee
Update delegatee's delegatedBalance
by balance
.
Only updates if delegating to a new delegatee.
If used with balance
== _locked[_tokenId].amount
, then this is the same as
delegating or dedelegating from _tokenId
If used with balance
< _locked[_tokenId].amount
, then this is used to adjust
delegatedBalance
when a user's balance is modified (e.g. increaseAmount
, merge
etc).
If delegatee
is 0 (i.e. user is not delegating), then do nothing.
function checkpointDelegatee(
mapping(uint256 => uint48) storage _numCheckpoints,
mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) storage
_checkpoints,
uint256 _delegatee,
uint256 balance_,
bool _increase
) public;
Parameters
Name | Type | Description |
---|---|---|
_numCheckpoints | mapping(uint256 => uint48) | State of all user checkpoint counts |
_checkpoints | mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) | State of all user checkpoints |
_delegatee | uint256 | The delegatee's tokenId |
balance_ | uint256 | The delta in balance change |
_increase | bool | True if balance is increasing, false if decreasing |
_isCheckpointInNewBlock
function _isCheckpointInNewBlock(
mapping(uint256 => uint48) storage _numCheckpoints,
mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) storage
_checkpoints,
uint256 _tokenId
) internal view returns (bool);
getPastVotesIndex
Binary search to get the voting checkpoint for a token id at or prior to a given timestamp.
If a checkpoint does not exist prior to the timestamp, this will return 0.
function getPastVotesIndex(
mapping(uint256 => uint48) storage _numCheckpoints,
mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) storage
_checkpoints,
uint256 _tokenId,
uint256 _timestamp
) internal view returns (uint48);
Parameters
Name | Type | Description |
---|---|---|
_numCheckpoints | mapping(uint256 => uint48) | State of all user checkpoint counts |
_checkpoints | mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) | State of all user checkpoints |
_tokenId | uint256 | . |
_timestamp | uint256 | . |
Returns
Name | Type | Description |
---|---|---|
<none> | uint48 | The index of the checkpoint. |
getPastVotes
Retrieves historical voting balance for a token id at a given timestamp.
If a checkpoint does not exist prior to the timestamp, this will return 0. The user must also own the token at the time in order to receive a voting balance.
function getPastVotes(
mapping(uint256 => uint48) storage _numCheckpoints,
mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) storage
_checkpoints,
address _account,
uint256 _tokenId,
uint256 _timestamp
) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_numCheckpoints | mapping(uint256 => uint48) | State of all user checkpoint counts |
_checkpoints | mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) | State of all user checkpoints |
_account | address | . |
_tokenId | uint256 | . |
_timestamp | uint256 | . |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Total voting balance including delegations at a given timestamp. |
VelodromeTimeLibrary
State Variables
WEEK
uint256 internal constant WEEK = 7 days;
Functions
epochStart
Calculate the start of the current epoch based on the timestamp provided
Epochs are aligned to weekly intervals, with each epoch starting at midnight UTC.
function epochStart(uint256 timestamp) internal pure returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
timestamp | uint256 | The current timestamp to align |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The start timestamp of the epoch week |
epochNext
Calculate the start of the next epoch or end of the current epoch
Returns the timestamp at the start of the next weekly epoch following the given timestamp.
function epochNext(uint256 timestamp) internal pure returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
timestamp | uint256 | The current timestamp |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The start timestamp of the next epoch |
epochVoteStart
Determine the start of the voting window for the current epoch
Voting windows start one hour into the weekly epoch.
function epochVoteStart(uint256 timestamp) internal pure returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
timestamp | uint256 | The timestamp to calculate from |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The start timestamp of the voting window within the epoch |
epochVoteEnd
Calculate the end of the voting window within the current epoch
Voting windows close one hour before the next epoch begins.
function epochVoteEnd(uint256 timestamp) internal pure returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
timestamp | uint256 | The timestamp to calculate from |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The end timestamp of the voting window within the epoch |
Contents
BribeVotingReward
Inherits: VotingReward
Implementation of voting rewards for bribes based on user votes
Final implementation of voting rewards specifically for bribe distribution
Functions
constructor
Initializes bribe voting rewards
constructor(address _voter, address[] memory _rewards)
VotingReward(_voter, _rewards);
Parameters
Name | Type | Description |
---|---|---|
_voter | address | Address of voter contract |
_rewards | address[] | Initial array of reward token addresses |
notifyRewardAmount
Validates and whitelists reward tokens before processing
function notifyRewardAmount(address token, uint256 amount)
external
override
nonReentrant;
removeNoLongerWhitelistedTokens
Removes tokens from the rewards list that are no longer whitelisted
function removeNoLongerWhitelistedTokens(address[] calldata tokens) external;
Parameters
Name | Type | Description |
---|---|---|
tokens | address[] | The list of tokens to remove |
Events
NoLongerWhitelistedTokenRemoved
event NoLongerWhitelistedTokenRemoved(address indexed token);
Reward
Inherits: IReward, ReentrancyGuard
Author: velodrome.finance, @figs999, @pegahcarter
Base implementation for reward distribution contracts
Abstract contract providing core reward distribution functionality
State Variables
DURATION
Duration of each reward epoch in seconds
uint256 public constant DURATION = 7 days;
voter
Address of the Voter contract that manages rewards
address public immutable voter;
ve
Address of the VotingEscrow contract that manages veNFTs
address public immutable ve;
authorized
Address permitted to call privileged state-changing functions
address public immutable authorized;
totalSupply
Total amount of staking tokens locked in contract
uint256 public totalSupply;
supplyNumCheckpoints
Total number of supply checkpoints recorded
uint256 public supplyNumCheckpoints;
rewards
List of all reward tokens supported by this contract
Used for token enumeration and management
address[] public rewards;
balanceOf
Retrieves current staked balance for a veNFT
mapping(uint256 => uint256) public balanceOf;
tokenRewardsPerEpoch
Gets reward amount allocated for a specific epoch
mapping(address => mapping(uint256 => uint256)) public tokenRewardsPerEpoch;
lastEarn
Retrieves timestamp of last reward claim for a veNFT
mapping(address => mapping(uint256 => uint256)) public lastEarn;
isReward
Checks if a token is configured as a reward token
mapping(address => bool) public isReward;
checkpoints
A record of balance checkpoints for each account, by index
mapping(uint256 => mapping(uint256 => Checkpoint)) public checkpoints;
numCheckpoints
Number of balance checkpoints for a veNFT
mapping(uint256 => uint256) public numCheckpoints;
supplyCheckpoints
A record of balance checkpoints for each token, by index
mapping(uint256 => SupplyCheckpoint) public supplyCheckpoints;
Functions
constructor
Initializes reward contract with voter address
constructor(address _voter);
Parameters
Name | Type | Description |
---|---|---|
_voter | address | Address of voter contract managing rewards |
getPriorBalanceIndex
Gets historical balance index for a veNFT at timestamp
Uses binary search to find checkpoint index
function getPriorBalanceIndex(uint256 tokenId, uint256 timestamp)
public
view
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | ID of veNFT to query |
timestamp | uint256 | Time to query balance at |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Index of nearest checkpoint before timestamp |
getPriorSupplyIndex
Gets historical supply index at timestamp
Uses binary search to find checkpoint index
function getPriorSupplyIndex(uint256 timestamp) public view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
timestamp | uint256 | Time to query supply at |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Index of nearest checkpoint before timestamp |
_writeCheckpoint
Writes user checkpoint with updated balance
Updates or creates checkpoint based on epoch timing
function _writeCheckpoint(uint256 tokenId, uint256 balance) internal;
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | ID of veNFT to checkpoint |
balance | uint256 | New balance to record |
_writeSupplyCheckpoint
Writes global supply checkpoint
Updates or creates checkpoint based on epoch timing
function _writeSupplyCheckpoint() internal;
rewardsListLength
Number of tokens configured for rewards
function rewardsListLength() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Length of rewards token list |
earned
Calculates unclaimed rewards for a veNFT
function earned(address token, uint256 tokenId) public view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
token | address | Address of reward token to calculate |
tokenId | uint256 | ID of veNFT to calculate for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Amount of unclaimed rewards |
_deposit
Records a token deposit and updates checkpoints
Can only be called by authorized address
function _deposit(uint256 amount, uint256 tokenId) external;
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | Amount of tokens being deposited |
tokenId | uint256 | ID of veNFT receiving deposit |
_withdraw
Records a token withdrawal and updates checkpoints
Can only be called by authorized address
function _withdraw(uint256 amount, uint256 tokenId) external;
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | Amount of tokens being withdrawn |
tokenId | uint256 | ID of veNFT withdrawing from |
getReward
Claims accumulated rewards for a veNFT
function getReward(uint256 tokenId, address[] memory tokens)
external
virtual
nonReentrant;
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | ID of veNFT claiming rewards |
tokens | address[] | Array of reward token addresses to claim |
_getReward
Internal helper for processing reward claims
Calculates and transfers earned rewards to recipient
function _getReward(address recipient, uint256 tokenId, address[] memory tokens)
internal;
Parameters
Name | Type | Description |
---|---|---|
recipient | address | Address to receive claimed rewards |
tokenId | uint256 | ID of veNFT claiming rewards |
tokens | address[] | Array of reward tokens to claim |
notifyRewardAmount
Adds new reward tokens for distribution
Transfers tokens from caller and updates reward accounting
function notifyRewardAmount(address token, uint256 amount)
external
virtual
nonReentrant;
Parameters
Name | Type | Description |
---|---|---|
token | address | Address of token to add as reward |
amount | uint256 | Amount of token to add to rewards |
renotifyRewardAmount
in case rewards where distributed during a epoch with no deposits, redistribute the rewards
function renotifyRewardAmount(uint256 timestamp, address token) external;
Parameters
Name | Type | Description |
---|---|---|
timestamp | uint256 | Timestamp of the start of the epoch to renotify |
token | address | Address of token to renotify |
_notifyRewardAmount
Internal helper for adding rewards
Transfers tokens and updates reward accounting
function _notifyRewardAmount(address sender, address token, uint256 amount)
internal;
Parameters
Name | Type | Description |
---|---|---|
sender | address | Address providing reward tokens |
token | address | Address of reward token |
amount | uint256 | Amount of tokens to add as rewards |
VotingReward
Inherits: Reward
Base contract for rewards distributed based on voting power
Extends Reward with voting-specific reward logic
Functions
constructor
Configures voting rewards with initial reward tokens
constructor(address _voter, address[] memory _rewards) Reward(_voter);
Parameters
Name | Type | Description |
---|---|---|
_voter | address | Address of voter contract |
_rewards | address[] | Initial array of reward token addresses |
getReward
Validates caller is token owner or voter before processing claim
function getReward(uint256 tokenId, address[] memory tokens)
external
override
nonReentrant;
notifyRewardAmount
function notifyRewardAmount(address token, uint256 amount)
external
virtual
override
nonReentrant;
Voter
Inherits: IVoter, InfraredUpgradeable, ReentrancyGuardUpgradeable
Author: Modified from Velodrome (https://github.com/velodrome-finance/contracts/blob/main/contracts/Voter.sol)
Ensure new epoch before voting and manage staking tokens and bribe vaults.
This contract manages votes for POL CuttingBoard allocation and respective bribeVault creation. It also provides support for depositing and withdrawing from managed veNFTs. Inspired by Velodrome V2 Voter.
State Variables
ve
Returns the VotingEscrow contract address
address public ve;
totalWeight
Returns total voting weight across all votes
uint256 public totalWeight;
maxVotingNum
Returns maximum number of staking tokens one voter can vote for
uint256 public maxVotingNum;
MIN_MAXVOTINGNUM
Minimum allowed value for maximum voting number
Used as validation threshold in setMaxVotingNum
uint256 internal constant MIN_MAXVOTINGNUM = 1;
feeVault
Returns global fee distribution vault address
address public feeVault;
stakingTokens
Internal array of all staking tokens with active bribe vaults Used for token enumeration and state tracking
address[] public stakingTokens;
bribeVaults
Returns bribe vault address for a given staking token
mapping(address => address) public bribeVaults;
weights
Returns total weight allocated to a staking token
mapping(address => uint256) public weights;
votes
Returns vote weight allocated by token ID for specific staking token
mapping(uint256 => mapping(address => uint256)) public votes;
stakingTokenVote
NFT => List of stakingTokens voted for by NFT
mapping(uint256 => address[]) public stakingTokenVote;
usedWeights
Returns total vote weight used by specific token ID
mapping(uint256 => uint256) public usedWeights;
lastVoted
Returns timestamp of last vote for a token ID
mapping(uint256 => uint256) public lastVoted;
isWhitelistedNFT
Checks if NFT is whitelisted for special voting
mapping(uint256 => bool) public isWhitelistedNFT;
isAlive
Checks if bribe vault is active
mapping(address => bool) public isAlive;
Functions
onlyNewEpoch
Ensures operations only occur in new epochs and outside distribution window
Validates both epoch transition and proper timing within epoch
modifier onlyNewEpoch(uint256 _tokenId);
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | The token ID to check last vote timestamp for |
epochStart
Calculates start of epoch containing timestamp
function epochStart(uint256 _timestamp) external pure returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_timestamp | uint256 | Input timestamp |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Start of epoch time |
epochNext
Calculates start of next epoch after timestamp
function epochNext(uint256 _timestamp) external pure returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_timestamp | uint256 | Input timestamp |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Start of next epoch time |
epochVoteStart
Calculates start of voting window for epoch containing timestamp
function epochVoteStart(uint256 _timestamp) external pure returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_timestamp | uint256 | Input timestamp |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Vote window start time |
epochVoteEnd
Calculates end of voting window for epoch containing timestamp
function epochVoteEnd(uint256 _timestamp) external pure returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_timestamp | uint256 | Input timestamp |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Vote window end time |
constructor
Constructor for Voter contract
Reverts if infrared address is zero
constructor(address _infrared) InfraredUpgradeable(_infrared);
Parameters
Name | Type | Description |
---|---|---|
_infrared | address | Address of the Infrared contract |
initialize
Initializes the Voter contract with the voting escrow and fee vault
Sets up initial state including fee vault with configured reward tokens
function initialize(address _ve, address _gov, address _keeper)
external
initializer;
Parameters
Name | Type | Description |
---|---|---|
_ve | address | Address of the voting escrow contract |
_gov | address | Address of the governance multisig |
_keeper | address | Address of the keeper |
setMaxVotingNum
Updates maximum allowed votes per voter
function setMaxVotingNum(uint256 _maxVotingNum) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_maxVotingNum | uint256 | New maximum number of allowed votes |
reset
Resets voting state for a token ID
Required before making changes to veNFT state
function reset(uint256 _tokenId) external onlyNewEpoch(_tokenId) nonReentrant;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | veNFT token ID to reset |
_reset
Resets vote state for a token ID
Cleans up all vote accounting and emits appropriate events
function _reset(uint256 _tokenId) internal;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | Token ID to reset voting state for |
poke
Updates voting balances in rewards contracts for a token ID
Should be called after any action that affects vote weight
function poke(uint256 _tokenId) external nonReentrant;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | veNFT token ID to update |
_poke
Updates voting power for a token ID
Recalculates and updates all vote weightings
function _poke(uint256 _tokenId, uint256 _weight) internal;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | Token ID to update voting power for |
_weight | uint256 | New voting power weight to apply |
_vote
Core voting logic to allocate weights to staking tokens
Handles vote accounting, reward deposits and event emissions
*Implementation sequence:
- Reset all existing votes and accounting via _reset
- Calculate total vote weight for normalizing allocations
- For each staking token:
- Validate bribe vault exists and is active
- Calculate and apply normalized vote weight
- Update token-specific accounting
- Deposit into bribe vault
- Update global vote accounting if votes were cast
- If _isPoke is true, skip processing for tokens with killed bribe vaults*
function _vote(
uint256 _tokenId,
uint256 _weight,
address[] memory _stakingTokenVote,
uint256[] memory _weights,
bool _isPoke
) internal;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | Token ID that is voting |
_weight | uint256 | Total voting power weight available |
_stakingTokenVote | address[] | Array of staking tokens to vote for |
_weights | uint256[] | Array of weights to allocate to each token |
_isPoke | bool | if fees should be deposited in addition to marking tokenId as voted |
vote
Distributes voting weight to multiple staking tokens
Weight is allocated proportionally based on provided weights
function vote(
uint256 _tokenId,
address[] calldata _stakingTokenVote,
uint256[] calldata _weights
) external onlyNewEpoch(_tokenId) nonReentrant;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | veNFT token ID voting with |
_stakingTokenVote | address[] | Array of staking token addresses receiving votes |
_weights | uint256[] | Array of weights to allocate to each token |
depositManaged
Deposits veNFT into a managed NFT
NFT will be re-locked to max time on withdrawal
function depositManaged(uint256 _tokenId, uint256 _mTokenId)
external
nonReentrant
onlyNewEpoch(_tokenId);
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | veNFT token ID to deposit |
_mTokenId | uint256 | Managed NFT token ID to deposit into |
withdrawManaged
Withdraws veNFT from a managed NFT
Withdrawing locks NFT to max lock time
function withdrawManaged(uint256 _tokenId)
external
nonReentrant
onlyNewEpoch(_tokenId);
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | veNFT token ID to withdraw |
isWhitelistedToken
Checks if a token is whitelisted for rewards
function isWhitelistedToken(address _token) external view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_token | address |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | True if token is whitelisted |
whitelistNFT
Updates whitelist status for veNFT for privileged voting
function whitelistNFT(uint256 _tokenId, bool _bool) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | veNFT token ID to update |
_bool | bool | New whitelist status |
createBribeVault
Creates new bribe vault for staking token
function createBribeVault(address _stakingToken, address[] calldata _rewards)
external
onlyKeeper
nonReentrant
whenInitialized
returns (address);
Parameters
Name | Type | Description |
---|---|---|
_stakingToken | address | Address of staking token |
_rewards | address[] |
Returns
Name | Type | Description |
---|---|---|
<none> | address | Address of created bribe vault |
killBribeVault
Disables a bribe vault
function killBribeVault(address _stakingToken) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_stakingToken | address | Address of staking token for vault to disable |
reviveBribeVault
Re-enables a disabled bribe vault
function reviveBribeVault(address _stakingToken) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_stakingToken | address | Address of staking token for vault to re-enable |
length
Returns number of staking tokens with active bribe vaults
function length() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Count of staking tokens with bribe vaults |
claimBribes
Claims bribes from multiple sources for a veNFT
function claimBribes(
address[] memory _bribes,
address[][] memory _tokens,
uint256 _tokenId
) external;
Parameters
Name | Type | Description |
---|---|---|
_bribes | address[] | Array of bribe vault addresses to claim from |
_tokens | address[][] | Array of reward tokens to claim for each vault |
_tokenId | uint256 | veNFT token ID to claim for |
claimFees
Claims fee rewards for a veNFT
function claimFees(address[] memory _tokens, uint256 _tokenId) external;
Parameters
Name | Type | Description |
---|---|---|
_tokens | address[] | Array of fee tokens to claim |
_tokenId | uint256 | veNFT token ID to claim for |
getStakingTokenWeights
Returns all staking tokens and their current voting weights
Helper function that aggregates staking token data
function getStakingTokenWeights()
public
view
returns (
address[] memory _stakingTokens,
uint256[] memory _weights,
uint256 _totalWeight
);
Returns
Name | Type | Description |
---|---|---|
_stakingTokens | address[] | Array of staking token addresses |
_weights | uint256[] | Array of voting weights corresponding to each token |
_totalWeight | uint256 | Sum of all voting weights |
VotingEscrow
Inherits: IVotingEscrow, ReentrancyGuard
Authors: Modified from Solidly (https://github.com/solidlyexchange/solidly/blob/master/contracts/ve.sol), Modified from Curve (https://github.com/curvefi/curve-dao-contracts/blob/master/contracts/VotingEscrow.vy), Modified from velodrome.finance (https://github.com/velodrome-finance/contracts/blob/main/contracts/VotingEscrow.sol)
veNFT implementation that escrows ERC-20 tokens in the form of an ERC-721 NFT
Votes have a weight depending on time, so that users are committed to the future of (whatever they are voting for)
Vote weight decays linearly over time. Lock time cannot be more than MAXTIME
(4 years).
State Variables
keeper
address public immutable keeper;
token
Address of token (RED) used to create a veNFT
address public immutable token;
distributor
Address of RewardsDistributor.sol
address public distributor;
voter
Address of Voter.sol
address public voter;
artProxy
Address of art proxy used for on-chain art generation
address public artProxy;
allowedManager
address which can create managed NFTs
address public allowedManager;
_pointHistory
mapping(uint256 => GlobalPoint) internal _pointHistory;
supportedInterfaces
Mapping of interface id to bool about whether or not it's supported
mapping(bytes4 => bool) internal supportedInterfaces;
ERC165_INTERFACE_ID
ERC165 interface ID of ERC165
bytes4 internal constant ERC165_INTERFACE_ID = 0x01ffc9a7;
ERC721_INTERFACE_ID
ERC165 interface ID of ERC721
bytes4 internal constant ERC721_INTERFACE_ID = 0x80ac58cd;
ERC721_METADATA_INTERFACE_ID
ERC165 interface ID of ERC721Metadata
bytes4 internal constant ERC721_METADATA_INTERFACE_ID = 0x5b5e139f;
ERC4906_INTERFACE_ID
ERC165 interface ID of ERC4906
bytes4 internal constant ERC4906_INTERFACE_ID = 0x49064906;
ERC6372_INTERFACE_ID
ERC165 interface ID of ERC6372
bytes4 internal constant ERC6372_INTERFACE_ID = 0xda287a1d;
tokenId
Current count of token
uint256 public tokenId;
infrared
Address of Infrared contract
IInfraredUpgradeable public immutable infrared;
escrowType
Mapping of token id to escrow type Takes advantage of the fact default value is EscrowType.NORMAL
mapping(uint256 => EscrowType) public escrowType;
idToManaged
Mapping of token id to managed id
mapping(uint256 => uint256) public idToManaged;
weights
Mapping of user token id to managed token id to weight of token id
mapping(uint256 => mapping(uint256 => uint256)) public weights;
deactivated
Mapping of managed id to deactivated state
mapping(uint256 => bool) public deactivated;
name
string public constant name = "veNFT";
symbol
string public constant symbol = "veNFT";
version
string public constant version = "2.0.0";
decimals
uint8 public constant decimals = 18;
idToOwner
Mapping from NFT ID to the address that owns it.
mapping(uint256 => address) internal idToOwner;
ownerToNFTokenCount
Mapping from owner address to count of his tokens.
mapping(address => uint256) internal ownerToNFTokenCount;
idToApprovals
Mapping from NFT ID to approved address.
mapping(uint256 => address) internal idToApprovals;
ownerToOperators
Mapping from owner address to mapping of operator addresses.
mapping(address => mapping(address => bool)) internal ownerToOperators;
ownershipChange
mapping(uint256 => uint256) internal ownershipChange;
ownerToNFTokenIdList
Mapping from owner address to mapping of index to tokenId
mapping(address => mapping(uint256 => uint256)) public ownerToNFTokenIdList;
tokenToOwnerIndex
Mapping from NFT ID to index of owner
mapping(uint256 => uint256) internal tokenToOwnerIndex;
WEEK
uint256 internal constant WEEK = 1 weeks;
MAXTIME
uint256 internal constant MAXTIME = 4 * 365 * 86400;
iMAXTIME
int128 internal constant iMAXTIME = 4 * 365 * 86400;
MULTIPLIER
uint256 internal constant MULTIPLIER = 1 ether;
epoch
Total count of epochs witnessed since contract creation
uint256 public epoch;
supply
Total amount of token() deposited
uint256 public supply;
_locked
mapping(uint256 => LockedBalance) internal _locked;
_userPointHistory
mapping(uint256 => UserPoint[1000000000]) internal _userPointHistory;
userPointEpoch
mapping(uint256 => uint256) public userPointEpoch;
slopeChanges
time -> signed slope change
mapping(uint256 => int128) public slopeChanges;
canSplit
account -> can split
mapping(address => bool) public canSplit;
permanentLockBalance
Aggregate permanent locked balances
uint256 public permanentLockBalance;
voted
See if a queried _tokenId has actively voted
mapping(uint256 => bool) public voted;
DOMAIN_TYPEHASH
The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256(
"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
);
DELEGATION_TYPEHASH
The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256(
"Delegation(uint256 delegator,uint256 delegatee,uint256 nonce,uint256 expiry)"
);
_delegates
A record of each accounts delegate
mapping(uint256 => uint256) private _delegates;
_checkpoints
A record of delegated token checkpoints for each tokenId, by index
mapping(uint256 => mapping(uint48 => Checkpoint)) private _checkpoints;
numCheckpoints
The number of checkpoints for each tokenId
mapping(uint256 => uint48) public numCheckpoints;
nonces
A record of states for signing / validating signatures
mapping(address => uint256) public nonces;
Functions
constructor
Initializes VotingEscrow contract
constructor(address _keeper, address _token, address _voter, address _infrared);
Parameters
Name | Type | Description |
---|---|---|
_keeper | address | Address of keeper contract |
_token | address | Address of token (RED) used to create a veNFT |
_voter | address | Address of Voter contract |
_infrared | address | Address of Infrared contract |
createManagedLockFor
Create managed NFT (a permanent lock) for use within ecosystem.
Throws if address already owns a managed NFT.
function createManagedLockFor(address _to)
external
nonReentrant
returns (uint256 _mTokenId);
Returns
Name | Type | Description |
---|---|---|
_mTokenId | uint256 | managed token id. |
depositManaged
Delegates balance to managed nft Note that NFTs deposited into a managed NFT will be re-locked to the maximum lock time on withdrawal. Permanent locks that are deposited will automatically unlock.
Managed nft will remain max-locked as long as there is at least one deposit or withdrawal per week. Throws if deposit nft is managed. Throws if recipient nft is not managed. Throws if deposit nft is already locked. Throws if not called by voter.
function depositManaged(uint256 _tokenId, uint256 _mTokenId)
external
nonReentrant;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | tokenId of NFT being deposited |
_mTokenId | uint256 | tokenId of managed NFT that will receive the deposit |
withdrawManaged
Retrieves locked rewards and withdraws balance from managed nft. Note that the NFT withdrawn is re-locked to the maximum lock time.
Throws if NFT not locked. Throws if not called by voter.
function withdrawManaged(uint256 _tokenId) external nonReentrant;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | tokenId of NFT being deposited. |
setAllowedManager
Permit one address to call createManagedLockFor() that is not Voter.governor()
function setAllowedManager(address _allowedManager) external;
setManagedState
Set Managed NFT state. Inactive NFTs cannot be deposited into.
function setManagedState(uint256 _mTokenId, bool _state) external;
Parameters
Name | Type | Description |
---|---|---|
_mTokenId | uint256 | managed nft state to set |
_state | bool | true => inactive, false => active |
setArtProxy
function setArtProxy(address _proxy) external;
tokenURI
function tokenURI(uint256 _tokenId) external view returns (string memory);
_ownerOf
function _ownerOf(uint256 _tokenId) internal view returns (address);
ownerOf
function ownerOf(uint256 _tokenId) external view returns (address);
balanceOf
function balanceOf(address _owner) external view returns (uint256);
getApproved
function getApproved(uint256 _tokenId) external view returns (address);
isApprovedForAll
function isApprovedForAll(address _owner, address _operator)
external
view
returns (bool);
isApprovedOrOwner
Check whether spender is owner or an approved user for a given veNFT
function isApprovedOrOwner(address _spender, uint256 _tokenId)
external
view
returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_spender | address | . |
_tokenId | uint256 | . |
_isApprovedOrOwner
function _isApprovedOrOwner(address _spender, uint256 _tokenId)
internal
view
returns (bool);
approve
function approve(address _approved, uint256 _tokenId) external;
setApprovalForAll
function setApprovalForAll(address _operator, bool _approved) external;
_transferFrom
function _transferFrom(
address _from,
address _to,
uint256 _tokenId,
address _sender
) internal;
transferFrom
function transferFrom(address _from, address _to, uint256 _tokenId) external;
safeTransferFrom
function safeTransferFrom(address _from, address _to, uint256 _tokenId)
external;
_isContract
function _isContract(address account) internal view returns (bool);
safeTransferFrom
function safeTransferFrom(
address _from,
address _to,
uint256 _tokenId,
bytes memory _data
) public;
supportsInterface
function supportsInterface(bytes4 _interfaceID) external view returns (bool);
_addTokenToOwnerList
Add a NFT to an index mapping to a given address
function _addTokenToOwnerList(address _to, uint256 _tokenId) internal;
Parameters
Name | Type | Description |
---|---|---|
_to | address | address of the receiver |
_tokenId | uint256 | uint ID Of the token to be added |
_addTokenTo
Add a NFT to a given address
Throws if _tokenId
is owned by someone.
function _addTokenTo(address _to, uint256 _tokenId) internal;
_mint
Function to mint tokens
Throws if _to
is zero address.
Throws if _tokenId
is owned by someone.
function _mint(address _to, uint256 _tokenId) internal returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_to | address | The address that will receive the minted tokens. |
_tokenId | uint256 | The token id to mint. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | A boolean that indicates if the operation was successful. |
_removeTokenFromOwnerList
Remove a NFT from an index mapping to a given address
function _removeTokenFromOwnerList(address _from, uint256 _tokenId) internal;
Parameters
Name | Type | Description |
---|---|---|
_from | address | address of the sender |
_tokenId | uint256 | uint ID Of the token to be removed |
_removeTokenFrom
Remove a NFT from a given address
Throws if _from
is not the current owner.
function _removeTokenFrom(address _from, uint256 _tokenId) internal;
_burn
Must be called prior to updating LockedBalance
function _burn(uint256 _tokenId) internal;
locked
Get the LockedBalance (amount, end) of a _tokenId
function locked(uint256 _tokenId)
external
view
returns (LockedBalance memory);
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | . |
Returns
Name | Type | Description |
---|---|---|
<none> | LockedBalance | LockedBalance of _tokenId |
userPointHistory
User -> UserPoint[userEpoch]
function userPointHistory(uint256 _tokenId, uint256 _loc)
external
view
returns (UserPoint memory);
pointHistory
Global point history at a given index
function pointHistory(uint256 _loc)
external
view
returns (GlobalPoint memory);
_checkpoint
Record global and per-user data to checkpoints. Used by VotingEscrow system.
function _checkpoint(
uint256 _tokenId,
LockedBalance memory _oldLocked,
LockedBalance memory _newLocked
) internal;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | NFT token ID. No user checkpoint if 0 |
_oldLocked | LockedBalance | Pevious locked amount / end lock time for the user |
_newLocked | LockedBalance | New locked amount / end lock time for the user |
_depositFor
Deposit and lock tokens for a user
function _depositFor(
uint256 _tokenId,
uint256 _value,
uint256 _unlockTime,
LockedBalance memory _oldLocked,
DepositType _depositType
) internal;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | NFT that holds lock |
_value | uint256 | Amount to deposit |
_unlockTime | uint256 | New time when to unlock the tokens, or 0 if unchanged |
_oldLocked | LockedBalance | Previous locked amount / timestamp |
_depositType | DepositType | The type of deposit |
checkpoint
Record global data to checkpoint
function checkpoint() external nonReentrant;
depositFor
Deposit _value
tokens for _tokenId
and add to the lock
Anyone (even a smart contract) can deposit for someone else, but cannot extend their locktime and deposit for a brand new user
function depositFor(uint256 _tokenId, uint256 _value) external nonReentrant;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | lock NFT |
_value | uint256 | Amount to add to user's lock |
_createLock
Deposit _value
tokens for _to
and lock for _lockDuration
function _createLock(uint256 _value, uint256 _lockDuration, address _to)
internal
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_value | uint256 | Amount to deposit |
_lockDuration | uint256 | Number of seconds to lock tokens for (rounded down to nearest week) |
_to | address | Address to deposit |
createLock
Deposit _value
tokens for msg.sender
and lock for _lockDuration
function createLock(uint256 _value, uint256 _lockDuration)
external
nonReentrant
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_value | uint256 | Amount to deposit |
_lockDuration | uint256 | Number of seconds to lock tokens for (rounded down to nearest week) |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | TokenId of created veNFT |
createLockFor
Deposit _value
tokens for _to
and lock for _lockDuration
function createLockFor(uint256 _value, uint256 _lockDuration, address _to)
external
nonReentrant
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_value | uint256 | Amount to deposit |
_lockDuration | uint256 | Number of seconds to lock tokens for (rounded down to nearest week) |
_to | address | Address to deposit |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | TokenId of created veNFT |
_increaseAmountFor
function _increaseAmountFor(
uint256 _tokenId,
uint256 _value,
DepositType _depositType
) internal;
increaseAmount
Deposit _value
additional tokens for _tokenId
without modifying the unlock time
function increaseAmount(uint256 _tokenId, uint256 _value)
external
nonReentrant;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | |
_value | uint256 | Amount of tokens to deposit and add to the lock |
increaseUnlockTime
Extend the unlock time for _tokenId
Cannot extend lock time of permanent locks
function increaseUnlockTime(uint256 _tokenId, uint256 _lockDuration)
external
nonReentrant;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | |
_lockDuration | uint256 | New number of seconds until tokens unlock |
withdraw
Withdraw all tokens for _tokenId
Only possible if the lock is both expired and not permanent This will burn the veNFT. Any rebases or rewards that are unclaimed will no longer be claimable. Claim all rebases and rewards prior to calling this.
function withdraw(uint256 _tokenId) external nonReentrant;
merge
Merges _from
into _to
.
Cannot merge _from
locks that are permanent or have already voted this epoch.
Cannot merge _to
locks that have already expired.
This will burn the veNFT. Any rebases or rewards that are unclaimed
will no longer be claimable. Claim all rebases and rewards prior to calling this.
function merge(uint256 _from, uint256 _to) external nonReentrant;
Parameters
Name | Type | Description |
---|---|---|
_from | uint256 | VeNFT to merge from. |
_to | uint256 | VeNFT to merge into. |
split
Splits veNFT into two new veNFTS - one with oldLocked.amount - _amount
, and the second with _amount
This burns the tokenId of the target veNFT
Callable by approved or owner
If this is called by approved, approved will not have permissions to manipulate the newly created veNFTs
Returns the two new split veNFTs to owner
If from
is permanent, will automatically dedelegate.
This will burn the veNFT. Any rebases or rewards that are unclaimed
will no longer be claimable. Claim all rebases and rewards prior to calling this.
function split(uint256 _from, uint256 _amount)
external
nonReentrant
returns (uint256 _tokenId1, uint256 _tokenId2);
Parameters
Name | Type | Description |
---|---|---|
_from | uint256 | VeNFT to split. |
_amount | uint256 | Amount to split from veNFT. |
Returns
Name | Type | Description |
---|---|---|
_tokenId1 | uint256 | Return tokenId of veNFT with oldLocked.amount - _amount . |
_tokenId2 | uint256 | Return tokenId of veNFT with _amount . |
_createSplitNFT
function _createSplitNFT(address _to, LockedBalance memory _newLocked)
private
returns (uint256 _tokenId);
toggleSplit
Toggle split for a specific address.
Toggle split for address(0) to enable or disable for all.
function toggleSplit(address _account, bool _bool) external;
Parameters
Name | Type | Description |
---|---|---|
_account | address | Address to toggle split permissions |
_bool | bool | True to allow, false to disallow |
lockPermanent
Permanently lock a veNFT. Voting power will be equal to
LockedBalance.amount
with no decay. Required to delegate.
Only callable by unlocked normal veNFTs.
function lockPermanent(uint256 _tokenId) external;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | tokenId to lock. |
unlockPermanent
Unlock a permanently locked veNFT. Voting power will decay. Will automatically dedelegate if delegated.
Only callable by permanently locked veNFTs. Cannot unlock if already voted this epoch.
function unlockPermanent(uint256 _tokenId) external;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | tokenId to unlock. |
_balanceOfNFTAt
function _balanceOfNFTAt(uint256 _tokenId, uint256 _t)
internal
view
returns (uint256);
_supplyAt
function _supplyAt(uint256 _timestamp) internal view returns (uint256);
balanceOfNFT
Get the voting power for _tokenId at the current timestamp
Returns 0 if called in the same block as a transfer.
function balanceOfNFT(uint256 _tokenId) public view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | . |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Voting power |
balanceOfNFTAt
Get the voting power for _tokenId at a given timestamp
function balanceOfNFTAt(uint256 _tokenId, uint256 _t)
external
view
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | . |
_t | uint256 | Timestamp to query voting power |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Voting power |
totalSupply
Calculate total voting power at current timestamp
function totalSupply() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Total voting power at current timestamp |
totalSupplyAt
Calculate total voting power at a given timestamp
function totalSupplyAt(uint256 _timestamp) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_timestamp | uint256 |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Total voting power at given timestamp |
setVoterAndDistributor
Set the global state voter and distributor
This is only called once, at setup
function setVoterAndDistributor(address _voter, address _distributor)
external;
voting
Set voted
for _tokenId to true or false
Only callable by voter
function voting(uint256 _tokenId, bool _voted) external;
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | . |
_voted | bool | . |
delegates
function delegates(uint256 delegator) external view returns (uint256);
checkpoints
A record of delegated token checkpoints for each account, by index
function checkpoints(uint256 _tokenId, uint48 _index)
external
view
returns (Checkpoint memory);
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | |
_index | uint48 |
Returns
Name | Type | Description |
---|---|---|
<none> | Checkpoint | Checkpoint |
getPastVotes
function getPastVotes(address _account, uint256 _tokenId, uint256 _timestamp)
external
view
returns (uint256);
getPastTotalSupply
function getPastTotalSupply(uint256 _timestamp)
external
view
returns (uint256);
_checkpointDelegator
function _checkpointDelegator(
uint256 _delegator,
uint256 _delegatee,
address _owner
) internal;
_checkpointDelegatee
function _checkpointDelegatee(
uint256 _delegatee,
uint256 balance_,
bool _increase
) internal;
_delegate
Record user delegation checkpoints. Used by voting system.
Skips delegation if already delegated to delegatee
.
function _delegate(uint256 _delegator, uint256 _delegatee) internal;
delegate
function delegate(uint256 delegator, uint256 delegatee) external;
delegateBySig
function delegateBySig(
uint256 delegator,
uint256 delegatee,
uint256 nonce,
uint256 expiry,
uint8 v,
bytes32 r,
bytes32 s
) external;
clock
function clock() external view returns (uint48);
CLOCK_MODE
function CLOCK_MODE() external pure returns (string memory);