ITreasureXRewards
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
| Name | Type | Description |
|---|---|---|
rewardToken | address | ERC20 token address for rewards |
claimStartTime | uint64 | Timestamp when claims open |
claimEndTime | uint64 | Timestamp when claims close |
Returns
| Name | Type | Description |
|---|---|---|
campaignId | uint256 | The ID of the newly created campaign |
updateCampaignTime
Update claim window for a campaign
function updateCampaignTime(uint256 campaignId, uint64 claimStartTime, uint64 claimEndTime)
external;
Parameters
| Name | Type | Description |
|---|---|---|
campaignId | uint256 | The campaign to update |
claimStartTime | uint64 | New start timestamp |
claimEndTime | uint64 | New end timestamp |
setCampaignActive
Toggle campaign active status
function setCampaignActive(uint256 campaignId, bool active) external;
Parameters
| Name | Type | Description |
|---|---|---|
campaignId | uint256 | The campaign to update |
active | bool | Whether 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
| Name | Type | Description |
|---|---|---|
campaignId | uint256 | The campaign ID |
account | address | The user address |
amount | uint256 | The allocation amount |
setAllocations
Set allocations for multiple users in a campaign
function setAllocations(
uint256 campaignId,
address[] calldata accounts,
uint256[] calldata amounts
) external;
Parameters
| Name | Type | Description |
|---|---|---|
campaignId | uint256 | The campaign ID |
accounts | address[] | Array of user addresses |
amounts | uint256[] | Array of allocation amounts |
withdrawTokens
Withdraw tokens from a campaign
function withdrawTokens(uint256 campaignId, uint256 amount) external;
Parameters
| Name | Type | Description |
|---|---|---|
campaignId | uint256 | The campaign ID |
amount | uint256 | Amount to withdraw |
claim
Claim a specific amount from a campaign
function claim(uint256 campaignId, uint256 amount) external;
Parameters
| Name | Type | Description |
|---|---|---|
campaignId | uint256 | The campaign ID |
amount | uint256 | Amount to claim |
claimAll
Claim all available tokens from a campaign
function claimAll(uint256 campaignId) external;
Parameters
| Name | Type | Description |
|---|---|---|
campaignId | uint256 | The campaign ID |
getCampaign
Get campaign info
function getCampaign(uint256 campaignId) external view returns (CampaignInfo memory info);
Parameters
| Name | Type | Description |
|---|---|---|
campaignId | uint256 | The campaign ID |
Returns
| Name | Type | Description |
|---|---|---|
info | CampaignInfo | CampaignInfo struct |
getCampaignCount
Get total number of campaigns
function getCampaignCount() external view returns (uint256 count);
Returns
| Name | Type | Description |
|---|---|---|
count | uint256 | The 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
| Name | Type | Description |
|---|---|---|
campaignId | uint256 | The campaign ID |
account | address | The user address |
Returns
| Name | Type | Description |
|---|---|---|
info | AllocationInfo | AllocationInfo struct |
getClaimableAmount
Get claimable amount for a user in a campaign
function getClaimableAmount(uint256 campaignId, address account)
external
view
returns (uint256 claimable);
Parameters
| Name | Type | Description |
|---|---|---|
campaignId | uint256 | The campaign ID |
account | address | The user address |
Returns
| Name | Type | Description |
|---|---|---|
claimable | uint256 | Amount that can be claimed |
isCampaignClaimActive
Check if a campaign’s claim period is active
function isCampaignClaimActive(uint256 campaignId) external view returns (bool active);
Parameters
| Name | Type | Description |
|---|---|---|
campaignId | uint256 | The campaign ID |
Returns
| Name | Type | Description |
|---|---|---|
active | bool | True 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;
}