Rust SDK
Spark Source Code: orderbook-contract
Spark Rust SDK Examples: spark-rust-sdk-examples
Installation
To install the Spark Market SDK, run the following command:
SDK Methods
Deploying the Market Contract
Deploys the market contract with the provided configurations.
base_asset: AssetId
- The asset identifier for the base token.base_decimals: u32
- The decimal precision for the base asset.quote_asset: AssetId
- The asset identifier for the quote token.quote_decimals: u32
- The decimal precision for the quote asset.price_decimals: u32
- The decimal precision for the price.owner: WalletUnlocked
- The wallet of the contract owner.fuel_asset: AssetId
- The asset identifier for the fuel token.
Creating a New Market Contract Instance
Creates a new instance of the market contract.
contract_id: ContractId
- The ID of the deployed contract.wallet: WalletUnlocked
- The wallet associated with the contract.
Associating an Account with the Contract
Associates a new account with the contract instance.
account: &WalletUnlocked
- The account to be associated with the contract.
Retrieving Contract ID
Retrieves the contract ID.
Retrieving Bech32 Contract ID
Retrieves the Bech32 formatted contract ID.
Depositing Assets
Deposits a specified amount of assets into the contract.
amount: u64
- The amount to be deposited.asset: AssetId
- The asset identifier.
Withdrawing Assets
Withdraws a specified amount of assets from the contract.
amount: u64
- The amount to be withdrawn.asset_type: AssetType
- The type of asset to withdraw.
Opening an Order
Opens a new order in the market.
amount: u64
- The amount of the order.asset_type: AssetType
- The type of asset for the order.order_type: OrderType
- The type of the order (buy/sell).price: u64
- The price for the order.
Opening an Order with Matcher Fee
Opens a new order in the market with a specified matcher fee.
amount: u64
- The amount of the order.asset_type: AssetType
- The type of asset for the order.order_type: OrderType
- The type of the order (buy/sell).price: u64
- The price for the order.matcher_fee: u32
- The matcher fee.
Canceling an Order
Cancels an existing order.
order_id: Bits256
- The identifier of the order to be canceled.
Matching an Order Pair
Matches a pair of orders.
order_id0: Bits256
- The first order ID.order_id1: Bits256
- The second order ID.
Matching Multiple Orders
Matches multiple orders.
orders: Vec<Bits256>
- A vector of order IDs to be matched.
Fulfilling Multiple Orders
Fulfills multiple orders with the specified parameters.
amount: u64
- The amount to fulfill.asset_type: AssetType
- The type of asset.order_type: OrderType
- The type of the order (buy/sell).limit_type: LimitType
- The type of limit.price: u64
- The price of the order.slippage: u64
- The slippage tolerance.orders: Vec<Bits256>
- A vector of order IDs to be fulfilled.
Setting the Protocol Fee
Sets the protocol fee amount.
amount: u32
- The protocol fee amount.
Setting the Matcher Fee
Sets the matcher fee amount.
amount: u32
- The matcher fee amount.
Withdrawing Protocol Fee
Withdraws the protocol fee to a specified identity.
to: Identity
- The identity to receive the protocol fee.
Retrieving Account Information
Retrieves the account information for a specified user.
user: Identity
- The identity of the user.
Retrieving Protocol Fee
Retrieves the current protocol fee.
Retrieving Total Protocol Fee
Retrieves the total accumulated protocol fee.
Calculating Protocol Fee Amount
Calculates the protocol fee amount for a given order.
amount: u64
- The amount of the order.asset_type: AssetType
- The type of asset.
Retrieving Matcher Fee
Retrieves the current matcher fee.
Retrieving Order Information
Retrieves information about a specific order.
order: Bits256
- The order ID.
Retrieving User Orders
Retrieves all orders associated with a specific user.
user: Identity
- The identity of the user.
Retrieving Order Change Information
Retrieves the change information for a specific order.
order_id: Bits256
- The order ID.
Retrieving Contract Configuration
Retrieves the contract configuration details.
Calculating Order ID
Calculates the order ID based on the provided parameters.
Last updated