Contract b1b74d5336e0a3824f378885ef03b0fec53454e0e16abe55f722528fedd60008

← Back to Index 📥 Download WASM

Meta

rssdkver 22.0.7#211569aa49c8d896877dfca1f2eb4fe9071121c8
rsver 1.81.0

Interface

Stores or replaces an Entry by id and appends the id to the global index. Only callable by Admin.

fn set_entry(env: soroban_sdk::Env, entry: Entry)

Removes an Entry by id and updates the global index. Only callable by Admin. Panics if the entry does not exist.

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

Returns an Entry by id. Panics if the entry does not exist.

fn get_entry(env: soroban_sdk::Env, id: soroban_sdk::String) -> Entry

Bumps when contract logic changes in a way that clients may care about.

fn version(env: soroban_sdk::Env) -> u32

One-time initialization of admin, network, and optional entry ids.

  • admin: Address with privileged rights (set/remove/upgrade).
  • network: Must be "public" or "testnet".
  • ids: Optional seed list of entry ids to create with zeroed values.

Panics if called more than once or if network is invalid.

fn init(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    network: soroban_sdk::String,
    ids: soroban_sdk::Vec,
)

Upgrades the contract code. Only callable by Admin.

fn upgrade(env: soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>)

Invest tokens into an entry.

Behavior:

  • Transfers amount from user to the contract.
  • Always increases escrow by amount.
  • If amount > download_amount threshold, increases user equity shares and tvl by amount.
  • Recomputes APR.
  • Lazily creates the entry if it does not exist, and ensures it’s listed in the global index.
fn invest(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    id: soroban_sdk::String,
    amount: i128,
)

Claim the caller's proportional earnings for an entry.

Earnings are defined as escrow - tvl when positive. The user's proportional share is (user_shares / tvl) * total_earnings, adjusted by previously withdrawn amounts. Transfers the claimable amount to the user and persists updated accounting. Returns the claimed amount.

fn claim_earnings(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    id: soroban_sdk::String,
) -> i128

Sell a portion of the caller's equity shares for an entry.

Behavior:

  • Requires the caller to have at least amount shares.
  • Decreases user's shares and entry tvl by amount.
  • Does NOT change this entry's escrow.
  • Computes commission based on holding duration and distributes the commission to other entries' escrow (entries with tvl > 0), proportionally to their tvl.
  • Transfers (amount - commission) to the user from the contract balance.
  • Recomputes APR for all affected entries.
  • Returns the amount paid out to the user.
fn sell_shares(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    id: soroban_sdk::String,
    amount: i128,
) -> i128

Merge one entry into another. Admin-only.

Behavior:

  • Sums tvl and escrow from from_id into to_id.
  • Merges shares and withdrawn_earnings maps by summing per-user values.
  • Recomputes APR for the destination entry.
  • Deletes the source entry and updates the global index accordingly.
fn merge_entries(
    env: soroban_sdk::Env,
    from_id: soroban_sdk::String,
    to_id: soroban_sdk::String,
)

Remove legacy entries that have both tvl = 0 and escrow = 0. Admin-only. Cleans Index and EligibleIndex accordingly.

fn clean_empty_entries(env: soroban_sdk::Env) -> u32

Batched variant: remove up to limit legacy entries with tvl=0 and escrow=0. Returns the number of entries removed in this batch.

fn clean_empty_entries_batch(env: soroban_sdk::Env, limit: u32) -> u32

Imports

WebAssembly Text (WAT) ▶