Skip to main content

RewardSplitter

Git Source

Inherits: IRewardSplitter, Initializable, Multicall

Author: StakeWise

The RewardSplitter can be used to split the rewards of the fee recipient of the vault based on configured shares

State Variables

_wad

uint256 private constant _wad = 1e18;

vault

The vault to which the RewardSplitter is connected

address public override vault;

totalShares

The total number of shares in the splitter

uint256 public override totalShares;

isClaimOnBehalfEnabled

Returns whether the claim on behalf is enabled

bool public override isClaimOnBehalfEnabled;

_shareHolders

mapping(address => ShareHolder) private _shareHolders;

_unclaimedRewards

mapping(address => uint256) private _unclaimedRewards;

exitPositions

mapping(uint256 positionTicket => address onBehalf) public override exitPositions;

_totalRewards

uint128 private _totalRewards;

_rewardPerShare

uint128 private _rewardPerShare;

Functions

onlyVaultAdmin

Modifier to check if the caller is the vault admin

modifier onlyVaultAdmin();

constructor

constructor();

setClaimOnBehalf

Sets the flag indicating whether the claim on behalf is enabled.

function setClaimOnBehalf(bool enabled) external onlyVaultAdmin;

Parameters

NameTypeDescription
enabledboolThe flag indicating whether the claim on behalf is enabled Can only be called by the vault admin.

totalRewards

The total amount of unclaimed rewards in the splitter

function totalRewards() external view override returns (uint128);

Returns

NameTypeDescription
<none>uint128The total amount of rewards

sharesOf

Retrieves the amount of splitter shares for the given account. The shares are used to calculate the amount of rewards the account is entitled to.

function sharesOf(address account) external view override returns (uint256);

Parameters

NameTypeDescription
accountaddressThe address of the account to get shares for

rewardsOf

Retrieves the amount of rewards the account is entitled to. The rewards are calculated based on the amount of shares the account has. Note, rewards must be synced using the syncRewards function.

function rewardsOf(address account) public view override returns (uint256);

Parameters

NameTypeDescription
accountaddressThe address of the account to get rewards for

canSyncRewards

Checks whether new rewards can be synced from the vault.

function canSyncRewards() external view override returns (bool);

Returns

NameTypeDescription
<none>boolTrue if new rewards can be synced, false otherwise

increaseShares

Increases the amount of shares for the given account. Can only be called by the owner.

function increaseShares(address account, uint128 amount) external override onlyVaultAdmin;

Parameters

NameTypeDescription
accountaddressThe address of the account to increase shares for
amountuint128The amount of shares to add

decreaseShares

Decreases the amount of shares for the given account. Can only be called by the owner.

function decreaseShares(address account, uint128 amount) external override onlyVaultAdmin;

Parameters

NameTypeDescription
accountaddressThe address of the account to decrease shares for
amountuint128The amount of shares to deduct

updateVaultState

Updates the vault state. Can be used in multicall to update state, sync rewards and withdraw them.

function updateVaultState(IKeeperRewards.HarvestParams calldata harvestParams) external override;

Parameters

NameTypeDescription
harvestParamsIKeeperRewards.HarvestParamsThe harvest params to use for updating the vault state

claimVaultTokens

Transfers the vault tokens to the given account. Can only be called for the vault with ERC-20 token.

function claimVaultTokens(uint256 rewards, address receiver) external override;

Parameters

NameTypeDescription
rewardsuint256The amount of vault tokens to transfer
receiveraddressThe address of the account to transfer tokens to

enterExitQueue

Sends the rewards to the exit queue

function enterExitQueue(uint256 rewards, address receiver) external override returns (uint256 positionTicket);

Parameters

NameTypeDescription
rewardsuint256The amount of rewards to send to the exit queue
receiveraddressThe address that will claim exited assets

Returns

NameTypeDescription
positionTicketuint256The position ticket of the exit queue

enterExitQueueOnBehalf

Enters the exit queue on behalf of the shareholder. Can only be called if claim on behalf is enabled.

function enterExitQueueOnBehalf(uint256 rewards, address onBehalf) external override returns (uint256 positionTicket);

Parameters

NameTypeDescription
rewardsuint256The amount of rewards to send to the exit queue
onBehalfaddressThe address of the account on behalf of which the rewards are sent to the exit queue

Returns

NameTypeDescription
positionTicketuint256The position ticket of the exit queue

claimExitedAssetsOnBehalf

Claims the exited assets from the vault.

function claimExitedAssetsOnBehalf(uint256 positionTicket, uint256 timestamp, uint256 exitQueueIndex)
external
override;

Parameters

NameTypeDescription
positionTicketuint256The position ticket in the exit queue
timestampuint256The timestamp when the shares entered the exit queue
exitQueueIndexuint256The exit queue index of the exit request

_transferRewards

Transfers the specified amount of rewards to the shareholder

function _transferRewards(address shareholder, uint256 amount) internal virtual;

Parameters

NameTypeDescription
shareholderaddressThe address of the shareholder
amountuint256The amount of rewards to transfer

syncRewards

Syncs the rewards from the vault to the splitter. The vault state must be up-to-date.

function syncRewards() public override;

_withdrawRewards

Withdraws rewards for the given account

function _withdrawRewards(address account, uint256 rewards) private returns (uint256);

Parameters

NameTypeDescription
accountaddressThe address of the account to withdraw rewards for
rewardsuint256The amount of rewards to withdraw

Returns

NameTypeDescription
<none>uint256The actual amount of rewards withdrawn

__RewardSplitter_init

Initializes the RewardSplitter contract

function __RewardSplitter_init(address _vault) internal onlyInitializing;

Parameters

NameTypeDescription
_vaultaddressThe address of the vault to which the RewardSplitter will be connected