Comment on page
Market
Instructions from the ferum::market module
Public Functions are denoted by:
public entry fun
: These are functions individuals call from Move Modules or Clients (such as Aptos CLI).public fun
: These are functions you can call from Move Modules and are commonly used by protocols when building integrations. These functions also return additional variables that the protocols can utilize.
Initializes a market for the given instrument and quote coins.
I
: CoinType of the instrument coin of this market. For APT/USDC, APT is I.Q
: CoinType for the quote coin of this market. For APT/USDC, USDC is Q.
owner: &signer
Wallet signing the transactioninstrumentDecimals: u8
Number of decimal places the instrument coin should support for this market. Must satisfyinstrumentDecimals + quoteDecimals <= min(coin::decimals(), coin::decimals())
quoteDecimals: u8
Number of decimal places the quote coin should support for this market. Must satisfyinstrumentDecimals + quoteDecimals <= min(coin::decimals(), coin::decimals())
Open a market account.
Users must first create a market account (using this function) and deposit into it (using the next function), before trading on ferum.
I
: CoinType for the instrument coin of this market. For APT/USDC, APT is I.Q
: CoinType of the quote coin of this market. For APT/USDC, USDC is Q.
owner: &signer
Owner of the market account.
Deposit funds to trade with into the market account from the address of the owner.
Users must first create a market account (using the above function) and deposit into it (using this function), before trading on ferum.
I
: CoinType for the instrument coin of this market. For APT/USDC, APT is I.Q
: CoinType of the quote coin of this market. For APT/USDC, USDC is Q.
owner: &signer
Owner of the market account. Assets will be withdrawn from this address.
Withdraws coins from the market account into the address of the owner.
I
: CoinType for the instrument coin of this market. For APT/USDC, APT is I.Q
: CoinType of the quote coin of this market. For APT/USDC, USDC is Q.
owner: &signer
Owner of the market account. Assets will be deposited into this address.
Rebalances the orders in Vector Cache and B+ Tree based on existing prices, usually called by the a crank process.
owner: &signer
Signer for the transaction.limit: u8
: The maximum number of price levels that should be rebalanced.
I
: CoinType for the instrument coin of this market. For APT/USDC, APT is I.Q
: CoinType of the quote coin of this market. For APT/USDC, USDC is Q.
owner: &signer
Signer for the transaction.limit: u8
: The number ofNodes
to crank. EachNode
contains a set number of events (currently 5). So this means that at most,5*limit
events will be processed.
Adds an order to the market for types I/Q. As this is an entry function, nothing is returned. If you need a function that returns the id of the order, use add_order.
I
: CoinType for the instrument coin of this market. For APT/USDC, APT is I.Q
: CoinType of the quote coin of this market. For APT/USDC, USDC is Q.
owner: &signer
Signer for the owner of the order.side: u8
Side the order is taking. Valid choices are:buy = 1, sell = 2
. All other values will result in an error.behaviour: u8
Behaviour of the order. Valid choices are:gtc = 1, post = 2, ioc = 3, fok = 4
. All other values will result in an error. See Order Behaviour for more details.price: u64
For a buy, the maximum price the order will execute at. For a sell, the minimum price the order will execute at. For a market order, set the price to 0. Fixedpoint Value.clientOrderID: u32
Optional metadata added to order.marketBuyMaxCollateral: u64
For market orders, specify the amount of funds that can be utilized. If theprice
is 0 (market order) andmarketBuyMaxCollateral
is not specified, the transaction will error. Fixedpoint Value.
Cancels an order with the given id.
I
: CoinType of the instrument coin of this market. For APT/USDC, APT is I.Q
: CoinType for the quote coin of this market. For APT/USDC, USDC is Q.
owner: &signer
Signer for user that placed this order.
Cancels all orders placed by the signer.
I
: CoinType of the instrument coin of this market. For APT/USDC, APT is I.Q
: CoinType for the quote coin of this market. For APT/USDC, USDC is Q.
owner: &signer
Signer for the wallet that the orders were placed through.
Usually used by integrated protocols to place trades on behalf of users or manage to margin, returns additional variables that the protocol can utilize.
accountKey: MarketAccountKey
Market account for the order. Can be generated from get_market_account_key.counter: u32
Counter portion of the order id
OrderID
OrderID of a specific order based on Market Account Key and Counter.
Open a market account.
Users must first create a market account (using this function) and deposit into it (using the next function), before trading on ferum.
I
: CoinType for the instrument coin of this market. For APT/USDC, APT is I.Q
: CoinType of the quote coin of this market. For APT/USDC, USDC is Q.
owner: &signer
User to open market account foraccountIdentifier: vector<AccountIdentifier>
Vector containing single AccountIdentifier generated from gen_account_identifier. If empty, will return the key for the ferum market account for this user.
osit funds to trade with into the market account from the address of the owner.
Users must first create a market account (using the above function) and deposit into it (using this function), before trading on ferum.
I
: CoinType for the instrument coin of this market. For APT/USDC, APT is I.Q
: CoinType of the quote coin of this market. For APT/USDC, USDC is Q.
owner: &signer
Owner of the market account. Assets will be withdrawn from this address.
Withdraws coins from a market account created earlier, useful after trades are settled.
I
: CoinType for the instrument coin of this market. For APT/USDC, APT is I.Q
: CoinType of the quote coin of this market. For APT/USDC, USDC is Q.
owner: &signer
Owner of the market account. Assets will be deposited to this address.
I
: CoinType for the instrument coin of this market. For APT/USDC, APT is I.Q
: CoinType of the quote coin of this market. For APT/USDC, USDC is Q.
owner: &signer
User to get the market account ofaccountIdentifier: vector<AccountIdentifier>
Vector containing single AccountIdentifier generated from gen_account_identifier. If empty, will return the key for the ferum market account for this user.
I
: CoinType for the instrument coin of this market. For APT/USDC, APT is I.Q
: CoinType of the quote coin of this market. For APT/USDC, USDC is Q.
owner: &signer
Signer for the owner of the order.accountKey: MarketAccountKey
MarketAccountKey of the account placing this order. the owner must be able to take actions for this market account. Trades will be settled into this account.side: u8
Side the order is taking. Valid choices are:buy = 1, sell = 2
. All other values will result in an error.behaviour: u8
Valid choices are:GTC = 1, post = 2, ioc = 3, fok = 4
. All other values will result in an error. See Order Types for more details.price: u64
FixedPoint Value. Set 0 for a market order, and specify a price for a limit order. For a buy, the maximum price the order will execute at. For a sell, the minimum price the order will execute at.clientOrderID: u32
Optional metadata added to order.marketBuyMaxCollateral: u64
For market orders, specify the amount of funds that can be utilized. If theprice
is 0 (market order) andmarketBuyMaxCollateral
is not specified, the transaction will error. Fixedpoint Value.
Cancel an order, takes in an OrderID as input.
I
: CoinType of the instrument coin of this market. For APT/USDC, APT is I.Q
: CoinType for the quote coin of this market. For APT/USDC, USDC is Q.
owner: &signer
Signer for the transaction.orderID: OrderID
OrderID that should be canceled. The owner must be able to take actions for the market account this order was placed from.
Returns the address this specified market is stored at.
I
: CoinType of the instrument coin of this market. For APT/USDC, APT is I.Q
: CoinType for the quote coin of this market. For APT/USDC, USDC is Q.
address
Address the specified market is stored at.
View functions are currently not supported on the Aptos testnet
Helpful functions to see the state of a market.
Returns the specified market account
I
: CoinType of the instrument coin of this market. For APT/USDC, APT is I.Q
: CoinType for the quote coin of this market. For APT/USDC, USDC is Q.
MarketAccountView
JSON representation of a market account
struct MarketAccountView {
activeOrders: vector<OrderID>,
instrumentBalance: u64, // Fixedpoint
quoteBalance: u64, // Fixedpoint
}
curl --request POST \
--url https://fullnode.testnet.aptoslabs.com/v1/view \
--header 'Content-Type: application/json; charset=utf-8' \
--data '{
"function": "0x8909e0bb1dc6426039fec370bad122cf223c3ef26f05b4264e7ce7921e498b8b::market::view_market_account",
"type_arguments": [
"0x8909e0bb1dc6426039fec370bad122cf223c3ef26f05b4264e7ce7921e498b8b::test_coins::APTF",
"0x8909e0bb1dc6426039fec370bad122cf223c3ef26f05b4264e7ce7921e498b8b::test_coins::USDF"
],
"arguments": [
"0x8909e0bb1dc6426039fec370bad122cf223c3ef26f05b4264e7ce7921e498b8b",
"0x8909e0bb1dc6426039fec370bad122cf223c3ef26f05b4264e7ce7921e498b8b"
]
}' | jq .
Returns the specified order
I
: CoinType of the instrument coin of this market. For APT/USDC, APT is I.Q
: CoinType for the quote coin of this market. For APT/USDC, USDC is Q.
MarketAccountView
JSON representation of a market account
struct OrderView {
buyCollateral: u64, // Fixedpoint.
sellCollateral: u64, // Fixedpoint.
side: u8,
behaviour: u8,
price: u64, // Fixedpoint.
originalQty: u64, // Fixedpoint.
unfilledQty: u64, // Fixedpoint.
takerCrankPendingQty: u64, // Fixedpoint.
clientOrderID: u32,
marketBuyRemainingCollateral: u64, // Fixedpoint.
}
curl --request POST \
--url https://fullnode.testnet.aptoslabs.com/v1/view \
--header 'Content-Type: application/json; charset=utf-8' \
--data '{
"function": "0x25e00c9375cf2ad1370c16c1f2cbbfaa523ae6bbb0b05449599c50fa6ee6aff4::market::view_order",
"type_arguments": [
"0x25e00c9375cf2ad1370c16c1f2cbbfaa523ae6bbb0b05449599c50fa6ee6aff4::test_coins::APTF",
"0x25e00c9375cf2ad1370c16c1f2cbbfaa523ae6bbb0b05449599c50fa6ee6aff4::test_coins::USDF"
],
"arguments": [
"0x25e00c9375cf2ad1370c16c1f2cbbfaa523ae6bbb0b05449599c50fa6ee6aff4",
"0x25e00c9375cf2ad1370c16c1f2cbbfaa523ae6bbb0b05449599c50fa6ee6aff4",
"1"
]
}' | jq .
Last modified 9mo ago