Contract 02aa342f5e6e084c8e5728b74aee77864f77ea720896e61a689da8252f95943c

← Back to Index 📥 Download WASM

Meta

cliver 27.1.0#8e402ea28202950b272fbabc34caad4d2f64fe87
rssdk_spec_shaking 2
rssdkver 26.1.1#8ac18efb681a1c0b4b85a38c5a380300344e3f39
rsver 1.98.1
source_commit 26b0f4577a17dfa365e463577f312a5ede34adc3

Instances

  • CAOZCITWHWAXH5FRU4EULQ5EN2HMTCHICRNC4R5ZAOVD7XHCCQSJ42IB

Interface

fn accrue(env: soroban_sdk::Env, price: soroban_sdk::Bytes) -> MarketData
fn get_adl(env: soroban_sdk::Env) -> AdlState

Replaces the contract WASM. Storage is kept as is, not migrated.

Arguments

  • e - Access to the Soroban environment.
  • new_wasm_hash - The hash of an uploaded WASM blob.
  • operator - The owner.

Errors

  • OwnableError::OwnerNotSet - If ownership was renounced.
  • [MarketError::UpgradeNotOwner] - If operator is not the owner.

Notes

  • Authorization for the owner is required, and operator must be the owner.
fn upgrade(
    env: soroban_sdk::Env,
    new_wasm_hash: soroban_sdk::BytesN<32>,
    operator: soroban_sdk::Address,
)
fn get_feed(env: soroban_sdk::Env) -> soroban_sdk::BytesN<32>
fn get_order(env: soroban_sdk::Env, user: soroban_sdk::Address, id: u32) -> Order

Returns Some(Address) if ownership is set, or None if ownership has been renounced.

Arguments

  • e - Access to the Soroban environment.
fn get_owner(env: soroban_sdk::Env) -> Option
fn get_token(env: soroban_sdk::Env) -> soroban_sdk::Address
fn get_vault(env: soroban_sdk::Env) -> soroban_sdk::Address
fn get_config(env: soroban_sdk::Env) -> Config
fn get_oracle(env: soroban_sdk::Env) -> soroban_sdk::Address
fn get_status(env: soroban_sdk::Env) -> u32
fn set_config(env: soroban_sdk::Env, config: Config)
fn set_status(env: soroban_sdk::Env, status: u32)
fn execute_adl(
    env: soroban_sdk::Env,
    keeper: soroban_sdk::Address,
    user: soroban_sdk::Address,
    is_long: bool,
    amount: i128,
    price: soroban_sdk::Bytes,
) -> i128
fn cancel_order(env: soroban_sdk::Env, user: soroban_sdk::Address, id: u32) -> i128
fn claim_credit(env: soroban_sdk::Env, user: soroban_sdk::Address) -> i128
fn create_order(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    is_long: bool,
    kind: u32,
    notional: i128,
    margin: i128,
    trigger_price: i128,
    price_bound: i128,
    expiration: u32,
) -> u32
fn get_position(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    is_long: bool,
) -> Position
fn get_treasury(env: soroban_sdk::Env) -> soroban_sdk::Address

Initializes the market contract.

MarketData starts zeroed with its accrual timestamp at now. The status starts Status::Active.

Arguments

  • e - Access to the Soroban environment.
  • owner - The contract owner for the admin entries.
  • token - The settlement token.
  • vault - The strategy-vault contract.
  • oracle - The oracle contract.
  • treasury - The protocol fee sink.
  • feed_id - The price stream id. Immutable.
  • config - The initial global market configuration.

Errors

  • [MarketError::InvalidConfig] - If feed_id is not a V3 stream id (0x0003 prefix), or a config bound or range check fails.
  • [MarketError::NegativeValueNotAllowed] - If a fee, margin, borrowing, funding, ADL, or PnL field, min_order_margin, min_deposit, or exec_fee is negative. Any other negative field fails its own bound as [MarketError::InvalidConfig].

Notes

  • Called once at deployment. It sets owner as the contract owner.
fn __constructor(
    env: soroban_sdk::Env,
    owner: soroban_sdk::Address,
    token: soroban_sdk::Address,
    vault: soroban_sdk::Address,
    oracle: soroban_sdk::Address,
    treasury: soroban_sdk::Address,
    feed_id: soroban_sdk::BytesN<32>,
    config: Config,
)
fn execute_order(
    env: soroban_sdk::Env,
    keeper: soroban_sdk::Address,
    user: soroban_sdk::Address,
    id: u32,
    price: soroban_sdk::Bytes,
) -> i128
fn get_retirement(env: soroban_sdk::Env) -> Option<(i128, u64)>
fn get_market_data(env: soroban_sdk::Env) -> MarketData
fn get_vault_order(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    id: u32,
) -> VaultOrder

Accepts a pending ownership transfer.

Arguments

  • e - Access to the Soroban environment.

Errors

  • [crate::role_transfer::RoleTransferError::NoPendingTransfer] - If there is no pending transfer to accept.

Events

  • topics - ["ownership_transfer_completed"]
  • data - [new_owner: Address]
fn accept_ownership(env: soroban_sdk::Env)
fn update_adl_state(env: soroban_sdk::Env, price: soroban_sdk::Bytes) -> AdlState
fn get_order_counter(env: soroban_sdk::Env, user: soroban_sdk::Address) -> u32
fn cancel_vault_order(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    id: u32,
) -> i128
fn create_vault_order(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    kind: u32,
    amount: i128,
    min_out: i128,
) -> u32

Renounces ownership of the contract.

Permanently removes the owner, disabling all functions gated by #[only_owner].

Arguments

  • e - Access to the Soroban environment.

Errors

  • [OwnableError::TransferInProgress] - If there is a pending ownership transfer.
  • [OwnableError::OwnerNotSet] - If the owner is not set.

Notes

  • Authorization for the current owner is required.
fn renounce_ownership(env: soroban_sdk::Env)
fn set_terminal_price(env: soroban_sdk::Env, price: i128)

Initiates a 2-step ownership transfer to a new address.

Requires authorization from the current owner. The new owner must later call accept_ownership() to complete the transfer.

Arguments

  • e - Access to the Soroban environment.
  • new_owner - The proposed new owner.
  • live_until_ledger - Ledger number until which the new owner can accept. A value of 0 cancels any pending transfer.

Errors

  • [OwnableError::OwnerNotSet] - If the owner is not set.
  • [crate::role_transfer::RoleTransferError::NoPendingTransfer] - If trying to cancel a transfer that doesn't exist.
  • [crate::role_transfer::RoleTransferError::InvalidLiveUntilLedger] - If the specified ledger is in the past.
  • [crate::role_transfer::RoleTransferError::InvalidPendingAccount] - If the specified pending account is not the same as the provided new address.

Notes

  • Authorization for the current owner is required.
fn transfer_ownership(
    env: soroban_sdk::Env,
    new_owner: soroban_sdk::Address,
    live_until_ledger: u32,
)
fn execute_liquidation(
    env: soroban_sdk::Env,
    keeper: soroban_sdk::Address,
    user: soroban_sdk::Address,
    is_long: bool,
    price: soroban_sdk::Bytes,
) -> i128
fn execute_vault_order(
    env: soroban_sdk::Env,
    keeper: soroban_sdk::Address,
    user: soroban_sdk::Address,
    id: u32,
    price: soroban_sdk::Bytes,
) -> i128
fn get_claimable_credit(env: soroban_sdk::Env, user: soroban_sdk::Address) -> i128

Imports

WebAssembly Text (WAT) ▶