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:
amount Zi from funder to this contract.reward_rate = total_budget / SECONDS_PER_YEAR.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