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

ISTOStaking

Git Source

Author: luoyhang003

Interface for the STO staking contract used in the Genesis Expedition event.

This interface defines:

  • Locking STO to earn Hammers, Raw Stones, and Golden Stones
  • Time-indexed unlocking mechanism
  • View helpers for lock entries, unlockable amounts, and price configurations STO is locked for 70 days before becoming withdrawable.

Functions

lockFor

Locks STO for hammers and raw stones in a single transaction.

  • _hammers and _rawStones determine how much STO is required
  • System distributes resources accordingly
function lockFor(uint256 _hammers, uint256 _rawStones, address _referrer) external;

Parameters

NameTypeDescription
_hammersuint256Number of hammers to purchase via locking.
_rawStonesuint256Number of raw stones to purchase via locking.
_referreraddressOptional referral address.

lockForHammers

Locks STO exclusively for hammers.

function lockForHammers(uint256 _amount, address _referrer) external;

Parameters

NameTypeDescription
_amountuint256Number of hammers to purchase.
_referreraddressOptional referral address.

lockForRawStones

Locks STO exclusively for raw stones.

function lockForRawStones(uint256 _amount, address _referrer) external;

Parameters

NameTypeDescription
_amountuint256Number of raw stones to purchase.
_referreraddressOptional referral address.

unlock

Unlocks a specific lock entry after maturity.

Unlock is allowed only when event has ended and the entry has matured.

function unlock(uint256 _lockIndex) external;

Parameters

NameTypeDescription
_lockIndexuint256Index of the lock entry to unlock.

unlockAll

Unlocks all matured lock entries at once.

Stops iterating when an entry is not yet matured.

function unlockAll() external;

getUnlockableAmount

Returns the total STO amount that is currently withdrawable by a user.

A lock becomes unlockable after: END_TIME + (timeIndex * 1 day).

function getUnlockableAmount(address _player) external view returns (uint256 unlockableAmount_);

Parameters

NameTypeDescription
_playeraddressAddress querying unlockable STO.

Returns

NameTypeDescription
unlockableAmount_uint256Amount of STO eligible for unlocking.

getTotalLockedAmount

Returns total STO locked by a player (including un-matured entries).

function getTotalLockedAmount(address _player) external view returns (uint256 lockedAmount_);

Parameters

NameTypeDescription
_playeraddressUser address.

Returns

NameTypeDescription
lockedAmount_uint256Total STO currently locked.

getLockEntries

Returns all lock entries for a player.

function getLockEntries(address _player) external view returns (LockEntry[] memory lockEntries_);

Parameters

NameTypeDescription
_playeraddressThe user whose lock entries are queried.

Returns

NameTypeDescription
lockEntries_LockEntry[]Dynamic array of LockEntry structs.

getLockEntries

Returns a paginated slice of a user's lock entries.

Reverts if _start + _limit exceeds total entries.

function getLockEntries(address _player, uint256 _start, uint256 _limit)
    external
    view
    returns (LockEntry[] memory lockEntries_);

Parameters

NameTypeDescription
_playeraddressUser address.
_startuint256Starting index.
_limituint256Number of entries to return.

Returns

NameTypeDescription
lockEntries_LockEntry[]Array slice of LockEntry records.

getLockEntryLength

Returns total number of lock entries created by a player.

function getLockEntryLength(address _player) external view returns (uint256 length_);

Parameters

NameTypeDescription
_playeraddressUser address.

Returns

NameTypeDescription
length_uint256Number of lock entries.

getLastUnlockIndex

Returns the player's last processed unlock index.

Used internally to track which entries have been unlocked already.

function getLastUnlockIndex(address _player) external view returns (uint256 index_);

Parameters

NameTypeDescription
_playeraddressUser address.

Returns

NameTypeDescription
index_uint256Last unlocked index (exclusive).

getMintedRawStones

Returns the amount of raw stones minted for a specific player on a given day.

The timestamp parameter is normalized to the corresponding UTC-0 day boundary using floor-to-day logic before querying storage. The returned value represents only the raw stones minted on that day, not the cumulative total. This function is intended for off-chain indexing (e.g., Subgraph) and historical reward analysis.

function getMintedRawStones(address _player, uint256 _timestamp) external view returns (uint256 _amount);

Parameters

NameTypeDescription
_playeraddressThe address of the player to query.
_timestampuint256Any timestamp within the target day (will be floored to UTC-0).

Returns

NameTypeDescription
_amountuint256The number of raw stones minted for the player on the specified day.

Events

TokenLockedForHammer

Emitted when a player locks STO for hammers.

event TokenLockedForHammer(address indexed player, address indexed token, uint256 amount);

Parameters

NameTypeDescription
playeraddressAddress performing the lock.
tokenaddressThe STO token address.
amountuint256Amount of STO locked.

TokenLockedForRawStone

Emitted when a player locks STO for raw stones.

event TokenLockedForRawStone(address indexed player, address indexed token, uint256 amount);

Parameters

NameTypeDescription
playeraddressAddress performing the lock.
tokenaddressThe STO token address.
amountuint256Amount of STO locked.

TokenUnlocked

Emitted when locked STO becomes unlocked and is withdrawn.

event TokenUnlocked(address indexed player, address indexed token, uint256 amount);

Parameters

NameTypeDescription
playeraddressThe user unlocking STO.
tokenaddressThe STO token address.
amountuint256Amount unlocked.

SetHammerPrice

Emitted when the STO -> Hammer conversion price changes.

event SetHammerPrice(uint256 oldPrice, uint256 newPrice);

Parameters

NameTypeDescription
oldPriceuint256Previous price.
newPriceuint256New price.

SetRawStonePrice

Emitted when the STO -> Raw Stone conversion price changes.

event SetRawStonePrice(uint256 oldPrice, uint256 newPrice);

Parameters

NameTypeDescription
oldPriceuint256Previous price.
newPriceuint256New price.

SetGoldenStonePrice

Emitted when the STO -> Golden Stone conversion price changes.

event SetGoldenStonePrice(uint256 oldPrice, uint256 newPrice);

Parameters

NameTypeDescription
oldPriceuint256Previous price.
newPriceuint256New price.

SetMaxDailyRawStoneMintAmount

Emitted when the maximum daily raw stone mint limit is updated.

event SetMaxDailyRawStoneMintAmount(uint256 oldAmount, uint256 newAmount);

Parameters

NameTypeDescription
oldAmountuint256The previous maximum daily raw stone mint amount.
newAmountuint256The new maximum daily raw stone mint amount.

Structs

LockEntry

Represents a time-indexed STO lock entry.

  • timeIndex: (timestamp / 1 days) - startTimeIndex, representing day offset
  • lockedAmount: amount of STO locked on this day
struct LockEntry {
    uint256 timeIndex;
    uint256 lockedAmount;
}

Enums

LOCK_TYPE

Defines lock type used during locking operations.

LOCK_FOR_HAMMER: lock STO to receive hammers LOCK_FOR_RAW_STONE: lock STO to receive raw stones

enum LOCK_TYPE {
    LOCK_FOR_HAMMER,
    LOCK_FOR_RAW_STONE
}