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 distributor
) external returns (uint256 amountOperators);
Parameters
| Name | Type | Description |
|---|---|---|
$ | RewardsStorage | The storage pointer for all rewards accumulators |
ibera | address | The address of the InfraredBERA token |
distributor | address | The address of the distributor |
Returns
| Name | Type | Description |
|---|---|---|
amountOperators | uint256 | The amount of rewards harvested |
chargedFeesOnRewards
Generic function to calculate the fees charged on rewards, returning the amount owed to the recipient and protocol.
the recipient is the amount of rewards being sent forward into the protocol for example a vault
function chargedFeesOnRewards(uint256 amount, uint256 totalFeeRate)
public
pure
returns (uint256 recipient, 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) |
Returns
| Name | Type | Description |
|---|---|---|
recipient | uint256 | The amount of rewards to send to the recipient |
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
_token The address of the reward token
_amtProtocol The amount of rewards for the protocol
function _distributeFeesOnRewards(
mapping(address => uint256) storage protocolFeeAmounts,
address _token,
uint256 _amtProtocol
) internal;
_handleTokenRewardsForVault
Handles non-InfraredBGT token rewards to the vault.
function _handleTokenRewardsForVault(
RewardsStorage storage $,
IInfraredVault _vault,
address _token,
uint256 _amount,
uint256 _feeTotal,
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. |
_amount | uint256 | uint256 The amount of reward token to send to vault. |
_feeTotal | uint256 | uint256 The rate to charge for total fees on _amount. |
rewardsDuration | uint256 | uint256 The duration of the rewards. |
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 |
updateIRSplit
Update the split ratio for IR and iBGT rewards
function updateIRSplit(RewardsStorage storage $, uint256 _split) external;
Parameters
| Name | Type | Description |
|---|---|---|
$ | RewardsStorage | The storage pointer for all rewards accumulators |
_split | uint256 | The ratio for splitting iBGT Vault rewards to IR, weighted towards IR |
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 |
auctionBase
Alternative to Harvet base rewards, auctioning iBGT on harvestBaseCollector, from BGT rewards from Distributor 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
function auctionBase(
address ibgt,
address bgt,
address harvestBaseCollector
) external returns (uint256 bgtAmt);
Parameters
| Name | Type | Description |
|---|---|---|
ibgt | address | The address of the InfraredBGT toke |
bgt | address | The address of the BGT token |
harvestBaseCollector | address | The address of the harvestBaseCollector contract |
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
) 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 |
Returns
| Name | Type | Description |
|---|---|---|
bgtAmt | uint256 | The amount of BGT rewards harvested |
harvestVaultForUser
Harvests berachain reward vault as operator for user.
BGT transferred here, iBGT minted to user
function harvestVaultForUser(
RewardsStorage storage $,
IBerachainRewardsVault vault,
address bgt,
address ibgt,
address user
) external returns (uint256 bgtAmt);
Parameters
| Name | Type | Description |
|---|---|---|
$ | RewardsStorage | |
vault | IBerachainRewardsVault | The address of the Berachain reward vault |
bgt | address | The address of the BGT token |
ibgt | address | The address of the InfraredBGT token |
user | address | The address of the User to claim bgt on behalf of |
Returns
| Name | Type | Description |
|---|---|---|
bgtAmt | uint256 | The amount of BGT rewards harvested = amount of iBGT minted |
externalVaultRewards
View rewards to claim for berachain reward vault as operator for user.
function externalVaultRewards(
RewardsStorage storage $,
IBerachainRewardsVault vault,
address user
) external view returns (uint256 iBgtAmount);
Parameters
| Name | Type | Description |
|---|---|---|
$ | RewardsStorage | |
vault | IBerachainRewardsVault | The address of the Berachain reward vault |
user | address | The address of the User to claim bgt on behalf of |
Returns
| Name | Type | Description |
|---|---|---|
iBgtAmount | uint256 | The amount of BGT rewards harvested = amount of iBGT minted |
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
) 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 |
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,
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 |
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 |
redeemIbgtForBera
redeem ibgt for bera
function redeemIbgtForBera(address bgt, address ibgt, uint256 amount)
external;
Parameters
| Name | Type | Description |
|---|---|---|
bgt | address | The address of the BGT token |
ibgt | address | The address of the iBGT token |
amount | uint256 | Amount of ibgt to redeem |
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/depreciated/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 irCollector,
uint256 rewardsDuration
)
external
returns (
uint256 amtInfraredBERA,
uint256 amtIbgtVault,
uint256 amountIR
);
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 |
irCollector | address | |
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 |
amountIR | uint256 |
collectBribesInIBGT
Callback from the BribeCollector to payout the iBGT bribes were auctioned off for ref - https://github.com/infrared-dao/infrared-contracts/blob/develop/src/depreciated/core/BribeCollector.sol#L87
iBGT is split between the iBERA product (where it is redeemed for BERA) and the rest is sent to the IBGT vault.
function collectBribesInIBGT(
RewardsStorage storage $,
uint256 _amount,
address ibgt,
address ibgtVault,
address irCollector,
address harvestBaseCollector,
uint256 rewardsDuration
)
external
returns (
uint256 amtInfraredBERA,
uint256 amtIbgtVault,
uint256 amountIR
);
Parameters
| Name | Type | Description |
|---|---|---|
$ | RewardsStorage | Storage pointer for reward accumulators |
_amount | uint256 | The amount of iBGT our bribes were auctioned off for |
ibgt | address | The address of the iBGT token |
ibgtVault | address | The address of the InfraredBGT vault |
irCollector | address | |
harvestBaseCollector | address | The address of base collector auction contract |
rewardsDuration | uint256 | The duration of the rewards |
Returns
| Name | Type | Description |
|---|---|---|
amtInfraredBERA | uint256 | The amount of iBGT sent to the iBERA product |
amtIbgtVault | uint256 | The amount of iBGT sent to the IBGT vault |
amountIR | uint256 |
collectBribesInIR
Callback from the BribeCollector to payout the IR bribes were auctioned off for ref - https://github.com/infrared-dao/infrared-contracts/blob/develop/src/core/BribeCollector.sol#L87
IR is split between the iBERA product (where it is redeemed for BERA) and the rest is sent to the IBGT vault and sIR.
function collectBribesInIR(
RewardsStorage storage $,
uint256 _amount,
address ir,
address ibgtVault,
address irCollector,
address harvestBaseCollector,
uint256 rewardsDuration
)
external
returns (
uint256 amtInfraredBERA,
uint256 amtIbgtVault,
uint256 amountIR
);
Parameters
| Name | Type | Description |
|---|---|---|
$ | RewardsStorage | Storage pointer for reward accumulators |
_amount | uint256 | The amount of IR our bribes were auctioned off for |
ir | address | The address of the IR token |
ibgtVault | address | The address of the InfraredBGT vault |
irCollector | address | |
harvestBaseCollector | address | The address of base collector auction contract |
rewardsDuration | uint256 | The duration of the rewards |
Returns
| Name | Type | Description |
|---|---|---|
amtInfraredBERA | uint256 | The amount of iBGT sent to the iBERA product |
amtIbgtVault | uint256 | The amount of iBGT sent to the IBGT vault |
amountIR | uint256 | The amount of IR sent to the sIR |
Structs
RewardsStorage
struct RewardsStorage {
mapping(address => uint256) protocolFeeAmounts;
uint256 irMintRate;
uint256 bribeSplitRatio;
mapping(uint256 => uint256) fees;
uint256 irSplitRatio;
}