Contract 0d35ebf3898052d07b09f4463637b4265aaa7b1ef2ab90fcb0b991df4bb36929

← Back to Index 📥 Download WASM

Meta

cliver 27.0.0#5a7c5fe76530bf4248477ac812fc757146b98cc4
rssdkver 21.7.7#5da789c50b18a4c2be53394138212fed56f0dfc4
rsver 1.96.1

Instances

  • CCDIK5EJL2L2A5UY76BYY2JR5W25OHVAZQ3CBB6ZKK7QDUELP34NMUGD

Interface

Deploy-time initialisation. Must be called exactly once.

  • admin — address that can call admin-only functions.
  • reward_token — SEP-41 contract address for Zi (the reward currency).
  • lp_token — SEP-41 LP token contract address stakers must deposit. Can be updated later by the admin via set_lp_token().
fn init(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    reward_token: soroban_sdk::Address,
    lp_token: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>

Claim all pending Zi rewards without unstaking. Can be called at any time, regardless of the lock status.

fn claim(
    env: soroban_sdk::Env,
    staker: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>

Stake amount LP tokens. Starts (or extends) a 1-year hard lock.

If the staker already has an active position, the new tokens are added and the lock is reset to now + 1 year from the new deposit time. Rewards already accrued up to this point are snapshotted into pending_rewards.

fn stake(
    env: soroban_sdk::Env,
    staker: soroban_sdk::Address,
    amount: i128,
) -> Result<(), soroban_sdk::Error>

Withdraw all staked LP tokens. Reverts if the 1-year lock has not expired. Automatically claims any pending Zi rewards.

fn unstake(
    env: soroban_sdk::Env,
    staker: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>

Returns the configured LP token address.

fn lp_token(env: soroban_sdk::Env) -> Option

Pause the contract — blocks stake / unstake / claim. Admin only.

fn set_paused(env: soroban_sdk::Env, paused: bool) -> Result<(), soroban_sdk::Error>

Returns the current reward rate (Zi stroops per second).

fn reward_rate(env: soroban_sdk::Env) -> i128

Returns the staker's current position: (staked, unlock_time, pending_rewards).

fn staker_info(
    env: soroban_sdk::Env,
    staker: soroban_sdk::Address,
) -> (i128, u64, i128)

Deposit Zi into the reward pool. Can be called by any account (G-address or Soroban contract address) at any time.

When called:

  1. Transfers amount Zi from funder to this contract.
  2. If there is an active reward period with remaining rewards, those remaining rewards roll forward into the new period budget.
  3. Recalculates reward_rate = total_budget / SECONDS_PER_YEAR.
  4. Sets period_finish = now + SECONDS_PER_YEAR.

The 10% APR target is achieved by the caller depositing 10% of the total staked LP value in Zi per year. The contract does not enforce the 10% figure — it emits whatever rate the pool can sustain.

fn fund_rewards(
    env: soroban_sdk::Env,
    funder: soroban_sdk::Address,
    amount: i128,
) -> Result<(), soroban_sdk::Error>

Returns the configured reward token address.

fn reward_token(env: soroban_sdk::Env) -> Option

Update the LP token address the contract accepts for staking. Admin only. Existing stakers are unaffected — their positions remain valid under the old token; only new stakes use the new address.

fn set_lp_token(
    env: soroban_sdk::Env,
    new_lp_token: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>

Returns total LP tokens staked across all accounts.

fn total_staked(env: soroban_sdk::Env) -> i128

Returns the timestamp when the current reward period ends.

fn period_finish(env: soroban_sdk::Env) -> u64

Transfer the admin role to a new address.

fn transfer_admin(
    env: soroban_sdk::Env,
    new_admin: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>

Returns the current pending rewards for a staker (without mutating state).

fn pending_rewards(env: soroban_sdk::Env, staker: soroban_sdk::Address) -> i128

Imports

WebAssembly Text (WAT) ▶