Initialize the HITZ token
owner - Admin address with privileged rightshalving_start_ts - Unix timestamp when halving schedule beginshalving_interval_sec - Seconds per epoch (126,144,000 = 4 years)epoch0_unit_reward - Initial unit reward in stroops (3,000,000 = 0.3 HITZ)fn __constructor(
env: soroban_sdk::Env,
owner: soroban_sdk::Address,
halving_start_ts: u64,
halving_interval_sec: u64,
epoch0_unit_reward: i128,
)
Mint reward tokens based on difficulty
Calculates reward using halving schedule and enforces max supply cap. Only callable by owner (Skyhitz Core contract).
to - Recipient addressdifficulty - Difficulty multiplier for reward calculationActual amount minted (may be less than calculated if near max supply)
fn mint_reward(
env: soroban_sdk::Env,
_caller: soroban_sdk::Address,
to: soroban_sdk::Address,
difficulty: i128,
) -> i128
Get emission info: (epoch_index, current_unit_reward, released_total, remaining_supply)
fn emission_info(env: soroban_sdk::Env) -> (u64, i128, i128, i128)
Get max supply
fn max_supply(env: soroban_sdk::Env) -> i128
Get released total
fn released_total(env: soroban_sdk::Env) -> i128
Admin mint (for initial distribution or emergency) Still respects max supply cap
fn admin_mint(
env: soroban_sdk::Env,
_caller: soroban_sdk::Address,
account: soroban_sdk::Address,
amount: i128,
)
Upgrade contract to new WASM code Only callable by owner (admin)
fn upgrade(
env: soroban_sdk::Env,
_caller: soroban_sdk::Address,
new_wasm_hash: soroban_sdk::BytesN<32>,
)
fn transfer(
env: soroban_sdk::Env,
from: soroban_sdk::Address,
to: soroban_sdk::Address,
amount: i128,
)
fn transfer_from(
env: soroban_sdk::Env,
spender: soroban_sdk::Address,
from: soroban_sdk::Address,
to: soroban_sdk::Address,
amount: i128,
)
fn total_supply(env: soroban_sdk::Env) -> i128
fn balance(env: soroban_sdk::Env, account: soroban_sdk::Address) -> i128
fn allowance(
env: soroban_sdk::Env,
owner: soroban_sdk::Address,
spender: soroban_sdk::Address,
) -> i128
fn approve(
env: soroban_sdk::Env,
owner: soroban_sdk::Address,
spender: soroban_sdk::Address,
amount: i128,
live_until_ledger: u32,
)
fn decimals(env: soroban_sdk::Env) -> u32
fn name(env: soroban_sdk::Env) -> soroban_sdk::String
fn symbol(env: soroban_sdk::Env) -> soroban_sdk::String
fn get_owner(env: soroban_sdk::Env) -> Option
fn transfer_ownership(
env: soroban_sdk::Env,
new_owner: soroban_sdk::Address,
live_until_ledger: u32,
)
fn accept_ownership(env: soroban_sdk::Env)
fn renounce_ownership(env: soroban_sdk::Env)
Upgrade core contract to new WASM code (admin-only)
Note: Named upgrade_core to avoid export name collision with token's upgrade.
fn upgrade_core(env: soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>)
Reset storage for both legacy and current keys (admin-only)
Intended for use immediately after upgrading from the legacy contract, to wipe old state while keeping the same contract ID. Safe to call even if some keys don't exist.
fn reset_all(env: soroban_sdk::Env)
Initialize the contract (one-time only)
admin - Admin address with privileged rightstreasury - Treasury address receiving all XLM feeshitz_token - HITZ token contract address (OpenZeppelin token)xlm_token - XLM token contract address (SAC)base_fee - Base fee per difficulty unit in stroops (default 100,000 = 0.01 XLM)fn init(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
treasury: soroban_sdk::Address,
hitz_token: soroban_sdk::Address,
xlm_token: soroban_sdk::Address,
base_fee: i128,
)
Update base fee (admin-only)
new_base_fee - New base fee per difficulty unit in stroops (e.g., 100,000 = 0.01 XLM)fn set_base_fee(env: soroban_sdk::Env, new_base_fee: i128)
Get current base fee
fn get_base_fee(env: soroban_sdk::Env) -> i128
Create a new entry (admin-only)
fn create_entry(env: soroban_sdk::Env, entry_id: soroban_sdk::String)
Record a user action (main entrypoint)
Handles fee transfer, reward calculation, and optional auto-staking For invest action, amount_xlm specifies the investment (min 0.3 XLM), ignored for other actions
fn record_action(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
entry_id: soroban_sdk::String,
kind: soroban_sdk::Symbol,
amount_xlm: Option,
)
Get entry data
fn get_entry(env: soroban_sdk::Env, entry_id: soroban_sdk::String) -> Option
List entry IDs with pagination
fn list_entries(
env: soroban_sdk::Env,
start: u32,
limit: u32,
) -> soroban_sdk::Vec
Get user's stake for an entry
fn get_stake(
env: soroban_sdk::Env,
entry_id: soroban_sdk::String,
owner: soroban_sdk::Address,
) -> i128
Get total stake for an entry
fn get_stake_total(env: soroban_sdk::Env, entry_id: soroban_sdk::String) -> i128
Contract version Distribute HITZ rewards proportionally based on escrow performance
Treasury bot calls this after buying HITZ with accumulated XLM fees. Contract automatically distributes to entries based on their escrow_xlm.
caller - Treasury address that holds the HITZhitz_amount - Total HITZ to distribute across all entriesOptimized to single loop - O(n) where n = number of entries Handles rounding dust by allocating to last entry
fn distribute_rewards(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
hitz_amount: i128,
)
Allocate HITZ rewards to a specific entry's reward pool
Admin-only function for manual reward allocation (e.g., promotions, bonuses)
fn allocate_rewards(
env: soroban_sdk::Env,
entry_id: soroban_sdk::String,
hitz_amount: i128,
)
Batch allocate rewards to multiple entries
Admin-only function for manual batch allocation (e.g., campaigns, airdrops)
fn batch_allocate_rewards(
env: soroban_sdk::Env,
entry_ids: soroban_sdk::Vec,
amounts: soroban_sdk::Vec,
)
Claim HITZ rewards from an entry's reward pool
Stakers receive rewards proportional to their stake Formula: claimable = (reward_pool × user_stake) / total_stake - already_claimed
fn claim_rewards(
env: soroban_sdk::Env,
entry_id: soroban_sdk::String,
claimer: soroban_sdk::Address,
) -> i128
Unstake HITZ tokens from an entry
Allows users to withdraw their staked HITZ back to their wallet. User loses their stake percentage and future rewards from this entry.
entry_id - The entry to unstake fromcaller - The user unstaking (must have stake)amount - Amount of HITZ to unstake (in stroops)Amount unstaked
fn unstake(
env: soroban_sdk::Env,
entry_id: soroban_sdk::String,
caller: soroban_sdk::Address,
amount: i128,
) -> i128
Get claimable HITZ rewards for a user
fn get_claimable_rewards(
env: soroban_sdk::Env,
entry_id: soroban_sdk::String,
user: soroban_sdk::Address,
) -> i128
Get reward pool size for an entry
fn get_reward_pool(env: soroban_sdk::Env, entry_id: soroban_sdk::String) -> i128
Calculate APR for an entry based on HITZ rewards
APR = ((reward_pool / total_stake) / days_since_creation) × 365 × 100 Returns APR as basis points (1% = 100, 10% = 1000)
fn calculate_apr(env: soroban_sdk::Env, entry_id: soroban_sdk::String) -> i128
Get comprehensive entry statistics for ranking
Returns: (tvl_xlm, escrow_xlm, total_stake_hitz, reward_pool_hitz, apr_basis_points)
fn get_entry_stats(
env: soroban_sdk::Env,
entry_id: soroban_sdk::String,
) -> (i128, i128, i128, i128, i128)
fn version(env: soroban_sdk::Env) -> u32