Skip to main content

ITwabRewards

Git Source

Author: PoolTogether Inc. & G9 Software Inc.

TwabRewards contract interface.

Functions

createPromotion

Creates a new promotion.

function createPromotion(
address vault,
IERC20 token,
uint64 startTimestamp,
uint256 tokensPerEpoch,
uint48 epochDuration,
uint8 numberOfEpochs
) external returns (uint256);

Parameters

NameTypeDescription
vaultaddressAddress of the vault that the promotion applies to
tokenIERC20Address of the token to be distributed
startTimestampuint64Timestamp at which the promotion starts
tokensPerEpochuint256Number of tokens to be distributed per epoch
epochDurationuint48Duration of one epoch in seconds
numberOfEpochsuint8Number of epochs the promotion will last for

Returns

NameTypeDescription
<none>uint256Id of the newly created promotion

endPromotion

End currently active promotion and send promotion tokens back to the creator.

Will only send back tokens from the epochs that have not completed.

function endPromotion(uint256 promotionId, address to) external returns (bool);

Parameters

NameTypeDescription
promotionIduint256Promotion id to end
toaddressAddress that will receive the remaining tokens if there are any left

Returns

NameTypeDescription
<none>boolTrue if operation was successful

destroyPromotion

Delete an inactive promotion and send promotion tokens back to the creator.

Will send back all the tokens that have not been claimed yet by users.

This function will revert if the promotion is still active.

This function will revert if the grace period is not over yet.

function destroyPromotion(uint256 promotionId, address to) external returns (bool);

Parameters

NameTypeDescription
promotionIduint256Promotion id to destroy
toaddressAddress that will receive the remaining tokens if there are any left

Returns

NameTypeDescription
<none>boolTrue if operation was successful

extendPromotion

Extend promotion by adding more epochs.

function extendPromotion(uint256 promotionId, uint8 numberOfEpochs) external returns (bool);

Parameters

NameTypeDescription
promotionIduint256Id of the promotion to extend
numberOfEpochsuint8Number of epochs to add

Returns

NameTypeDescription
<none>boolTrue if the operation was successful

claimRewards

Claim rewards for a given promotion and epoch.

Rewards can be claimed on behalf of a user.

Rewards can only be claimed for a past epoch.

function claimRewards(address user, uint256 promotionId, uint8[] calldata epochIds) external returns (uint256);

Parameters

NameTypeDescription
useraddressAddress of the user to claim rewards for
promotionIduint256Id of the promotion to claim rewards for
epochIdsuint8[]Epoch ids to claim rewards for

Returns

NameTypeDescription
<none>uint256Total amount of rewards claimed

getPromotion

Get settings for a specific promotion.

function getPromotion(uint256 promotionId) external view returns (Promotion memory);

Parameters

NameTypeDescription
promotionIduint256Id of the promotion to get settings for

Returns

NameTypeDescription
<none>PromotionPromotion settings

getCurrentEpochId

Get the current epoch id of a promotion.

function getCurrentEpochId(uint256 promotionId) external view returns (uint256);

Parameters

NameTypeDescription
promotionIduint256Id of the promotion to get current epoch for

Returns

NameTypeDescription
<none>uint256Current epoch id of the promotion

getRemainingRewards

Get the total amount of tokens left to be rewarded.

function getRemainingRewards(uint256 promotionId) external view returns (uint256);

Parameters

NameTypeDescription
promotionIduint256Id of the promotion to get the total amount of tokens left to be rewarded for

Returns

NameTypeDescription
<none>uint256Amount of tokens left to be rewarded

getRewardsAmount

Get amount of tokens to be rewarded for a given epoch.

Rewards amount can only be retrieved for epochs that are over.

Will revert if epochId is over the total number of epochs or if epoch is not over.

Will return 0 if the user average balance for the promoted vault is 0.

Will be 0 if user has already claimed rewards for the epoch.

function getRewardsAmount(address user, uint256 promotionId, uint8[] calldata epochIds)
external
view
returns (uint256[] memory);

Parameters

NameTypeDescription
useraddressAddress of the user to get amount of rewards for
promotionIduint256Id of the promotion from which the epoch is
epochIdsuint8[]Epoch ids to get reward amount for

Returns

NameTypeDescription
<none>uint256[]Amount of tokens per epoch to be rewarded

Structs

Promotion

Struct to keep track of each promotion's settings.

struct Promotion {
address creator;
uint64 startTimestamp;
uint8 numberOfEpochs;
address vault;
uint48 epochDuration;
uint48 createdAt;
IERC20 token;
uint256 tokensPerEpoch;
uint256 rewardsUnclaimed;
}