RewardsLib
State Variables
UNIT_DENOMINATOR
Unit denominotor for calculating all fees and rates in the system
All fees and rates are calculated out of 1e6
uint256 internal constant UNIT_DENOMINATOR = 1e6;
Functions
harvestOperatorRewards
Harvest rewards given to our operators for setting their cuttingboard weights ref - https://github.com/infrared-dao/infrared-contracts/blob/develop/src/staking/InfraredBERAFeeReceivor.sol#L83
function harvestOperatorRewards(
RewardsStorage storage $,
address ibera,
address voter,
address distributor
) external returns (uint256 _amt);
Parameters
Name | Type | Description |
---|---|---|
$ | RewardsStorage | The storage pointer for all rewards accumulators |
ibera | address | The address of the InfraredBERA token |
voter | address | The address of the voter (address(0) if IR token is not live) |
distributor | address | The address of the distributor |
Returns
Name | Type | Description |
---|---|---|
_amt | uint256 | The amount of rewards harvested |
chargedFeesOnRewards
The amount of rewards going to the protocol treasury
Generic function to calculate the fees charged on rewards, returning the amount owed to the recipient, protocol, and voter.
the recepient is the amount of rewards being sent forward into the protocol for example a vault
function chargedFeesOnRewards(
uint256 amount,
uint256 totalFeeRate,
uint256 protocolFeeRate
)
public
pure
returns (uint256 recepient, uint256 voterFees, uint256 protocolFees);
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | The amount of rewards to calculate fees on |
totalFeeRate | uint256 | The total fee rate to charge on rewards (protocol + voter) |
protocolFeeRate | uint256 | The rate to charge for protocol fees |
Returns
Name | Type | Description |
---|---|---|
recepient | uint256 | The amount of rewards to send to the recipient |
voterFees | uint256 | The amount of rewards to send to the voter |
protocolFees | uint256 | The amount of rewards to send to the protocol |
_distributeFeesOnRewards
Distributes fees on rewards to the protocol, voter, and recipient.
_protocolFeeAmounts The accumulator for protocol fees per token
_voter The address of the voter
_token The address of the reward token
_amtVoter The amount of rewards for the voter
_amtProtocol The amount of rewards for the protocol
function _distributeFeesOnRewards(
mapping(address => uint256) storage protocolFeeAmounts,
address _voter,
address _token,
uint256 _amtVoter,
uint256 _amtProtocol
) internal;
_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 | RewardsStorage The storage pointer for all rewards accumulators. |
_vault | IInfraredVault | IInfraredVault The address of the vault. |
_token | address | address The reward token. |
voter | address | address The address of the voter. |
_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 | uint256 The duration of the rewards. |
updateIRMintRate
Update the IR minting rate for the protocol.
This rate determines how many IR tokens are minted whenever BGT rewards are harvested.
For example, if the rate is 500,000 (0.5 * UNIT_DENOMINATOR), 0.5 IR is minted per BGT.
If the rate is 2,000,000 (2 * UNIT_DENOMINATOR), 2 IR are minted per BGT.
The actuall calculation is done in the harvestVault
function when BGT rewards are harvested and IR tokens are minted accordingly.
function updateIRMintRate(RewardsStorage storage $, uint256 newRate) external;
Parameters
Name | Type | Description |
---|---|---|
$ | RewardsStorage | The storage pointer for all rewards accumulators |
newRate | uint256 | The new IR minting rate out of UNIT_DENOMINATOR(1e6 being 100% or a 1:1 rate) |
delegateBGT
Delegates Berachain Governance Voting Power to a delegatee
function delegateBGT(address _delegatee, address bgt) external;
Parameters
Name | Type | Description |
---|---|---|
_delegatee | address | The address to delegate voting power to |
bgt | address | The address of the BGT token |
updateInfraredBERABribeSplit
Update the split ratio for iBERA and iBGT rewards
function updateInfraredBERABribeSplit(RewardsStorage storage $, uint256 _split)
external;
Parameters
Name | Type | Description |
---|---|---|
$ | RewardsStorage | The storage pointer for all rewards accumulators |
_split | uint256 | The ratio for splitting received bribes to be iBERA and iBGT, weighted towards iBERA |
updateFee
Update the fee rate for a given fee type
function updateFee(
RewardsStorage storage $,
ConfigTypes.FeeType _t,
uint256 _fee
) external;
Parameters
Name | Type | Description |
---|---|---|
$ | RewardsStorage | The storage pointer for all rewards accumulators |
_t | ConfigTypes.FeeType | The fee type to update |
_fee | uint256 | The new fee rate |
claimProtocolFees
Claim protocol fees for a given token
function claimProtocolFees(
RewardsStorage storage $,
address _to,
address _token
) external returns (uint256 _amountClaimed);
Parameters
Name | Type | Description |
---|---|---|
$ | RewardsStorage | The storage pointer for all rewards accumulators |
_to | address | The address to send the protocol fees to |
_token | address | The token to claim protocol fees for |
harvestBase
Harvet's base rewards from the BGT contract, ie rewards from Distributor, given in BGT ref - https://github.com/berachain/contracts-monorepo/blob/main/src/pol/rewards/Distributor.sol#L160
The BGT accumilates in the contract, therfore can check balance(this) since all other BGT rewards are claimed and harvested atomically
Reward paid out to validators proposing a block, MUST be forwarded to IBERA.receivor, the fees are handled there. TODO: Link here.
function harvestBase(address ibgt, address bgt, address ibera)
external
returns (uint256 bgtAmt);
Parameters
Name | Type | Description |
---|---|---|
ibgt | address | The address of the InfraredBGT toke |
bgt | address | The address of the BGT token |
ibera | address | The address of the InfraredBERA token |
Returns
Name | Type | Description |
---|---|---|
bgtAmt | uint256 | The amount of BGT rewards harvested |
harvestVault
Harvests the accrued BGT rewards to a vault.
BGT transferred here directly to the user https://github.com/berachain/contracts-monorepo/blob/c374de32077ede0147985cf2bf6ed89570244a7e/src/pol/rewards/RewardVault.sol#L404
function harvestVault(
RewardsStorage storage $,
IInfraredVault vault,
address bgt,
address ibgt,
address voter,
address ir,
uint256 rewardsDuration
) external returns (uint256 bgtAmt);
Parameters
Name | Type | Description |
---|---|---|
$ | RewardsStorage | |
vault | IInfraredVault | The address of the InfraredRewardVault, wrapping an underlying RewardVault |
bgt | address | The address of the BGT token |
ibgt | address | The address of the InfraredBGT token |
voter | address | The address of the voter (0 until IR token is live) |
ir | address | The address of the Infrared token |
rewardsDuration | uint256 | The duration of the rewards |
Returns
Name | Type | Description |
---|---|---|
bgtAmt | uint256 | The amount of BGT rewards harvested |
harvestOldVault
Harvests the accrued BGT rewards to a vault.
BGT transferred here directly to the user https://github.com/berachain/contracts-monorepo/blob/c374de32077ede0147985cf2bf6ed89570244a7e/src/pol/rewards/RewardVault.sol#L404
function harvestOldVault(
RewardsStorage storage $,
IInfraredVault vault,
IInfraredVault newVault,
address bgt,
address ibgt,
address voter
) external returns (uint256 bgtAmt);
Parameters
Name | Type | Description |
---|---|---|
$ | RewardsStorage | |
vault | IInfraredVault | The address of the InfraredRewardVault, wrapping an underlying RewardVault |
newVault | IInfraredVault | |
bgt | address | The address of the BGT token |
ibgt | address | The address of the InfraredBGT token |
voter | address | The address of the voter (0 until IR token is live) |
Returns
Name | Type | Description |
---|---|---|
bgtAmt | uint256 | The amount of BGT rewards harvested |
harvestBribes
Harvest Bribes in tokens from RewardVault, sent to us via processIncentive ref - https://github.com/berachain/contracts-monorepo/blob/c374de32077ede0147985cf2bf6ed89570244a7e/src/pol/rewards/RewardVault.sol#L421
function harvestBribes(
RewardsStorage storage $,
address collector,
address[] memory _tokens,
bool[] memory whitelisted
) external returns (address[] memory tokens, uint256[] memory amounts);
Parameters
Name | Type | Description |
---|---|---|
$ | RewardsStorage | The storage pointer for all rewards accumulators |
collector | address | The address of the bribe collector, which will auction off fees for WBERA |
_tokens | address[] | The array of token addresses to harvest |
whitelisted | bool[] | The array of booleans indicating if the token is whitelisted, and should be collected |
harvestBoostRewards
Harvest boost rewards from the BGT staker (in HONEY -- likely)
function harvestBoostRewards(
RewardsStorage storage $,
address bgt,
address ibgtVault,
address voter,
uint256 rewardsDuration
) external returns (address _token, uint256 _amount);
Parameters
Name | Type | Description |
---|---|---|
$ | RewardsStorage | The storage pointer for all rewards accumulators |
bgt | address | The address of the BGT token |
ibgtVault | address | The address of the InfraredBGT vault |
voter | address | The address of the voter (address(0) if IR token is not live) |
rewardsDuration | uint256 | The duration of the rewards |
Returns
Name | Type | Description |
---|---|---|
_token | address | The rewards token harvested (likely hunny) |
_amount | uint256 | The amount of rewards harvested |
collectBribesInWBERA
Callback from the BribeCollector to payout the WBERA bribes were auctioned off for ref - https://github.com/infrared-dao/infrared-contracts/blob/develop/src/core/BribeCollector.sol#L87
WBERA is split between the iBERA product (where it is redeemed for BERA) and the rest is sent to the IBGT vault.
function collectBribesInWBERA(
RewardsStorage storage $,
uint256 _amount,
address wbera,
address ibera,
address ibgtVault,
address voter,
uint256 rewardsDuration
) external returns (uint256 amtInfraredBERA, uint256 amtIbgtVault);
Parameters
Name | Type | Description |
---|---|---|
$ | RewardsStorage | Storage pointer for reward accumulators |
_amount | uint256 | The amount of WBERA our bribes were auctioned off for |
wbera | address | The address of the WBERA token |
ibera | address | The address of the InfraredBERA token |
ibgtVault | address | The address of the InfraredBGT vault |
voter | address | The address of the voter (address(0) if IR token is not live) |
rewardsDuration | uint256 | The duration of the rewards |
Returns
Name | Type | Description |
---|---|---|
amtInfraredBERA | uint256 | The amount of WBERA sent to the iBERA product |
amtIbgtVault | uint256 | The amount of WBERA sent to the IBGT vault |
Events
ErrorMisconfiguredIRMinting
Emitted when protocol wants to mint IR
but fails.
event ErrorMisconfiguredIRMinting(uint256 amount);
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | uint256 The amount of IR that failed to mint |
Structs
RewardsStorage
struct RewardsStorage {
mapping(address => uint256) protocolFeeAmounts;
uint256 irMintRate;
uint256 bribeSplitRatio;
mapping(uint256 => uint256) fees;
}