Skip to main content

KeeperRewards

Git Source

Inherits: KeeperOracles, IKeeperRewards

Author: StakeWise

Defines the functionality for updating Vaults' and OsToken rewards

State Variables

_rewardsUpdateTypeHash

bytes32 private constant _rewardsUpdateTypeHash = keccak256(
"KeeperRewards(bytes32 rewardsRoot,string rewardsIpfsHash,uint256 avgRewardPerSecond,uint64 updateTimestamp,uint64 nonce)"
);

_maxAvgRewardPerSecond

uint256 private immutable _maxAvgRewardPerSecond;

_sharedMevEscrow

address private immutable _sharedMevEscrow;

_osTokenVaultController

IOsTokenVaultController private immutable _osTokenVaultController;

_vaultsRegistry

IVaultsRegistry internal immutable _vaultsRegistry;

rewardsDelay

The rewards delay

uint256 public immutable override rewardsDelay;

rewards

Get last synced Vault cumulative reward

mapping(address => Reward) public override rewards;

unlockedMevRewards

Get last unlocked shared MEV Vault cumulative reward

mapping(address => UnlockedMevReward) public override unlockedMevRewards;

prevRewardsRoot

Previous Rewards Root

bytes32 public override prevRewardsRoot;

rewardsRoot

Rewards Root

bytes32 public override rewardsRoot;

rewardsMinOracles

The minimum number of oracles required to update rewards

uint256 public override rewardsMinOracles;

lastRewardsTimestamp

The last rewards update

uint64 public override lastRewardsTimestamp;

rewardsNonce

Rewards Nonce

uint64 public override rewardsNonce;

Functions

constructor

Constructor

constructor(
address sharedMevEscrow,
IVaultsRegistry vaultsRegistry,
IOsTokenVaultController osTokenVaultController,
uint256 _rewardsDelay,
uint256 maxAvgRewardPerSecond
);

Parameters

NameTypeDescription
sharedMevEscrowaddressThe address of the shared MEV escrow contract
vaultsRegistryIVaultsRegistryThe address of the VaultsRegistry contract
osTokenVaultControllerIOsTokenVaultControllerThe address of the OsTokenVaultController contract
_rewardsDelayuint256The delay in seconds between rewards updates
maxAvgRewardPerSeconduint256The maximum possible average reward per second

updateRewards

Update rewards data

function updateRewards(RewardsUpdateParams calldata params) external override;

Parameters

NameTypeDescription
paramsRewardsUpdateParamsThe struct containing rewards update parameters

canUpdateRewards

Checks whether rewards can be updated

function canUpdateRewards() public view override returns (bool);

Returns

NameTypeDescription
<none>booltrue if rewards can be updated, false otherwise

isHarvestRequired

Checks whether Vault must be harvested

function isHarvestRequired(address vault) external view override returns (bool);

Parameters

NameTypeDescription
vaultaddressThe address of the Vault

Returns

NameTypeDescription
<none>booltrue if the Vault requires harvesting, false otherwise

canHarvest

Checks whether the Vault can be harvested

function canHarvest(address vault) external view override returns (bool);

Parameters

NameTypeDescription
vaultaddressThe address of the Vault

Returns

NameTypeDescription
<none>booltrue if Vault can be harvested, false otherwise

isCollateralized

Checks whether the Vault has registered validators

function isCollateralized(address vault) public view override returns (bool);

Parameters

NameTypeDescription
vaultaddressThe address of the Vault

Returns

NameTypeDescription
<none>booltrue if Vault is collateralized, false otherwise

harvest

Harvest rewards. Can be called only by Vault.

function harvest(HarvestParams calldata params)
external
override
returns (int256 totalAssetsDelta, uint256 unlockedMevDelta, bool harvested);

Parameters

NameTypeDescription
paramsHarvestParamsThe struct containing rewards harvesting parameters

Returns

NameTypeDescription
totalAssetsDeltaint256The total reward/penalty accumulated by the Vault since the last sync
unlockedMevDeltauint256The Vault execution reward that can be withdrawn from shared MEV escrow. Only used by shared MEV Vaults.
harvestedbooltrue when the rewards were harvested, false otherwise

setRewardsMinOracles

Set min number of oracles for confirming rewards update. Can only be called by the owner.

function setRewardsMinOracles(uint256 _rewardsMinOracles) external override onlyOwner;

Parameters

NameTypeDescription
_rewardsMinOraclesuint256The new min number of oracles for confirming rewards update

_setRewardsMinOracles

Internal function for updating rewardsMinOracles

function _setRewardsMinOracles(uint256 _rewardsMinOracles) private;

Parameters

NameTypeDescription
_rewardsMinOraclesuint256The new value of rewardsMinOracles

_collateralize

Collateralize Vault so that it must be harvested in future reward updates

function _collateralize(address vault) internal;

Parameters

NameTypeDescription
vaultaddressThe address of the Vault