Contract 2bd0eeb781b2f570671aa980a1cd72b8b584f7420cade4706d3088a7f3e4a1fb

← Back to Index 📥 Download WASM

Meta

rssdkver 22.0.8#f46e9e0610213bbb72285566f9dd960ff96d03d8
rsver 1.90.0

Instances

  • CDCN2D4OF5IHPAHUIF6RPVH654KW6LKTYKYK3IQULBBWURD7L4CDNSRO

Interface

Initialize the HITZ token

Arguments

  • owner - Admin address with privileged rights
  • halving_start_ts - Unix timestamp when halving schedule begins
  • halving_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).

Arguments

  • to - Recipient address
  • difficulty - Difficulty multiplier for reward calculation

Returns

Actual 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)

Legacy-only: remove instance keys (Admin/Network). Admin-only.

fn reset_legacy_instance(env: soroban_sdk::Env)

Legacy-only: remove legacy entries in chunks to stay under footprint limits. Admin-only. Removes entries at indexes [start, start+limit).

fn reset_legacy_entries_chunk(env: soroban_sdk::Env, start: u32, limit: u32)

Current-only: remove instance keys (Admin/Treasury/HitzToken/XlmToken/BaseFee). Admin-only.

fn reset_current_instance(env: soroban_sdk::Env)

Current-only: remove entries in chunks to stay under footprint limits. Admin-only. Removes entries at indexes [start, start+limit) using EntryAt(i).

fn reset_current_entries_chunk(env: soroban_sdk::Env, start: u32, limit: u32)

Helpers to introspect counts before chunking.

fn legacy_index_len(env: soroban_sdk::Env) -> u32
fn current_entry_count(env: soroban_sdk::Env) -> u32

Read-only: return a slice of the legacy index IDs [start, start+limit).

fn legacy_index_slice(
    env: soroban_sdk::Env,
    start: u32,
    limit: u32,
) -> soroban_sdk::Vec

Admin-only: remove one legacy entry by id and drop it from the legacy index if present.

fn reset_legacy_entry_by_id(env: soroban_sdk::Env, id: soroban_sdk::String)

Admin-only: remove the legacy Index vector entirely.

fn reset_legacy_index(env: soroban_sdk::Env)

Admin-only: remove one current entry by its position (EntryAt(i)) and related keys.

fn reset_current_entry_by_pos(env: soroban_sdk::Env, i: u32)

Initialize the contract (one-time only)

Arguments

  • admin - Admin address with privileged rights
  • treasury - Treasury address receiving all XLM fees
  • hitz_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,
)

Accept ownership of the HITZ token (admin-only) Call this after initiating transfer_ownership on the token so that the core contract becomes the token owner and can mint rewards.

fn accept_hitz_ownership(env: soroban_sdk::Env)

Update base fee (admin-only)

Arguments

  • 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.

Arguments

  • caller - Treasury address that holds the HITZ
  • hitz_amount - Total HITZ to distribute across all entries

Performance

Optimized 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.

Arguments

  • entry_id - The entry to unstake from
  • caller - The user unstaking (must have stake)
  • amount - Amount of HITZ to unstake (in stroops)

Returns

Amount unstaked

Panics

  • If user has no stake
  • If amount exceeds user's stake
  • If amount <= 0
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

Imports

WebAssembly Text (WAT) ▶