Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ITreasureXRewards

Git Source

Title: ITreasureXRewards

Interface for the TreasureX multi-campaign reward claiming contract

Functions

createCampaign

Create a new campaign with reward token and claim window

function createCampaign(address rewardToken, uint64 claimStartTime, uint64 claimEndTime)
    external
    returns (uint256 campaignId);

Parameters

NameTypeDescription
rewardTokenaddressERC20 token address for rewards
claimStartTimeuint64Timestamp when claims open
claimEndTimeuint64Timestamp when claims close

Returns

NameTypeDescription
campaignIduint256The ID of the newly created campaign

updateCampaignTime

Update claim window for a campaign

function updateCampaignTime(uint256 campaignId, uint64 claimStartTime, uint64 claimEndTime)
    external;

Parameters

NameTypeDescription
campaignIduint256The campaign to update
claimStartTimeuint64New start timestamp
claimEndTimeuint64New end timestamp

setCampaignActive

Toggle campaign active status

function setCampaignActive(uint256 campaignId, bool active) external;

Parameters

NameTypeDescription
campaignIduint256The campaign to update
activeboolWhether the campaign should be active

setAllocation

Set allocation for a single user in a campaign

function setAllocation(uint256 campaignId, address account, uint256 amount) external;

Parameters

NameTypeDescription
campaignIduint256The campaign ID
accountaddressThe user address
amountuint256The allocation amount

setAllocations

Set allocations for multiple users in a campaign

function setAllocations(
    uint256 campaignId,
    address[] calldata accounts,
    uint256[] calldata amounts
) external;

Parameters

NameTypeDescription
campaignIduint256The campaign ID
accountsaddress[]Array of user addresses
amountsuint256[]Array of allocation amounts

withdrawTokens

Withdraw tokens from a campaign

function withdrawTokens(uint256 campaignId, uint256 amount) external;

Parameters

NameTypeDescription
campaignIduint256The campaign ID
amountuint256Amount to withdraw

claim

Claim a specific amount from a campaign

function claim(uint256 campaignId, uint256 amount) external;

Parameters

NameTypeDescription
campaignIduint256The campaign ID
amountuint256Amount to claim

claimAll

Claim all available tokens from a campaign

function claimAll(uint256 campaignId) external;

Parameters

NameTypeDescription
campaignIduint256The campaign ID

getCampaign

Get campaign info

function getCampaign(uint256 campaignId) external view returns (CampaignInfo memory info);

Parameters

NameTypeDescription
campaignIduint256The campaign ID

Returns

NameTypeDescription
infoCampaignInfoCampaignInfo struct

getCampaignCount

Get total number of campaigns

function getCampaignCount() external view returns (uint256 count);

Returns

NameTypeDescription
countuint256The campaign count

getAllocation

Get allocation info for a user in a campaign

function getAllocation(uint256 campaignId, address account)
    external
    view
    returns (AllocationInfo memory info);

Parameters

NameTypeDescription
campaignIduint256The campaign ID
accountaddressThe user address

Returns

NameTypeDescription
infoAllocationInfoAllocationInfo struct

getClaimableAmount

Get claimable amount for a user in a campaign

function getClaimableAmount(uint256 campaignId, address account)
    external
    view
    returns (uint256 claimable);

Parameters

NameTypeDescription
campaignIduint256The campaign ID
accountaddressThe user address

Returns

NameTypeDescription
claimableuint256Amount that can be claimed

isCampaignClaimActive

Check if a campaign’s claim period is active

function isCampaignClaimActive(uint256 campaignId) external view returns (bool active);

Parameters

NameTypeDescription
campaignIduint256The campaign ID

Returns

NameTypeDescription
activeboolTrue if claims are allowed

Structs

CampaignInfo

Campaign configuration (view)

struct CampaignInfo {
    uint256 campaignId;
    address rewardToken;
    uint64 claimStartTime;
    uint64 claimEndTime;
    bool active;
    uint256 totalAllocated;
    uint256 totalClaimed;
}

AllocationInfo

User allocation info for a campaign (view)

struct AllocationInfo {
    uint128 allocated;
    uint128 claimed;
}