Comment on page
Core Concepts: Ferum
A couple of core concept essential to understand Ferum
Ferum uses FixedPoint numbers consistently for all inputs into public and entry functions.
These numbers are interpreted to have fixed decimal places of 10 and a max value of
MAX_U64 = 18446744073709551615.
Most Ferum contract instructions will require the
Qtype parameters. These type parameters represent the Aptos coin types for the pair being traded. Each Ferum market is identified by the pair, I/Q.
For example, if you want to place an order for APT/USDF, you would call:
In the above example,
Iis the fully qualified type name of APT (
Qis the fully qualified type name of USDF (
Qcan be any type used to create an Aptos coin. This means that a Ferum market can be created for any asset, making Ferum completely asset agnostic.
Each market specifies the max amount of decimal places supported for each asset in the pair.
quoteDecimalsis how many decimals of precision the instrument asset and the quote asset support respectively.
The market's asset decimal precision must satisfy the following:
instrumentDecimals + quoteDecimals <= min(coin::decimals<I>(), coin::decimals<Q>())
This constraint ensures that decimal overflow doesn't occur when processing orders.
Similar to other exchanges, Ferum classifies orders as either maker or taker. A maker order is an execution that provides liquidity, while a taker order is an order that takes liquidity. For a more in-depth description, see this article.
An order is defined as a maker or a taker is defined at execution time. Each execution will have a maker side and a taker side. If the order being executed was resting on the orderbook, it is the maker order. If the order is executed immediately after being placed, it is the taker order.
Below are the type of behaviours Ferum supports.
GTC: A standard limit order. Can either be a maker or a taker.
POST: A limit order that can only be a maker order. If at the time of being placed, the order would be executed, it is cancelled.
IOC: Immediate or cancel. The limit order is cancelled if it is not fully filled immediately after being placed. Can result in partial executions.
FOK: Fill or kill. The limit order is cancelled if it is not fully filled immediately after being placed. Does not allow partial executions.
Ferum supports both market and limit orders. Market orders are denoted with
price == 0.
Order matching is still atomic and does not lead to a bad UX.
Anyone can call
crank_entryand callers are rewarded proportional to the fees accrued by the instruction call.