Creating Your First Order
This guide will walk you through executing your first trades on Ferum!
Prerequisites
This guide assumes you have knowledge about Aptos and have the latest version of Aptos CLI installed.
The below tutorial works on the Aptos testnet.
Trading
Step 1: Setup
Create a new directory somewhere: mkdir ferum-tut
In this directory, run through the aptos init --profile ferum-tut
command as follows:
Note that the network above was set to testnet.
This command will setup your CLI with a freshly created account on testnet. You can view your account details (private key, etc) by running cat .aptos/config.yaml
For convenience, set the address of Ferum as an environment variable:
Step 2: Create Test Coins for Trading
Now let's fund your account with APTF and USDF, test tokens deployed by Ferum that allows anyone to mint freely. First, we need to register the tokens with our account so we can receive it:
Now we can mint some fresh tokens (100 APTF and 100 USDF):
Both APTF and USDF coin have 8 decimal places.
Step 3: Open and Fund Market Account
Before interacting/trading on Ferum, you need to open a market account and fund it.
Now we can fund the account.
All numeric decimal values are formatted as standard 10 decimal place FixedPoints. The above values would be for 1 APT and 100 USDF.
Step 4: Place a Limit Order
We can now trade! Let's create an order using the add_order_entry
instruction
Each Ferum market is identified by the coin types being traded. So the type-args param is identified with the market associated with the order.
The add_order_entry
instruction takes positional arguments: the side, a price, a quantity, and a client_order_id.
side
: au8
value representing the order side. 1 means you want to place a buy order. 2 means you want to place a sell order. See OrderSide for more details.type
: au8
value representing the Behaviour of the order. 1 means you want to place aGTC
order. See Order Behaviours for more details.price
: au64
value representing the limit price for the order. If it's a sell, this is the lowest price you are willing to receive. If the order is a buy, this is the highest price you are willing to pay. The price is a FixedPoint number with 10 decimal places, and 0 is used for a market order.quantity
: au64
value representing the limit quantity for the order. The quantity is a FixedPoint number with 10 decimal places.client_order_id
:u32
of extra metadata that can be attached to an order. In this example, we just pass in 0.
So above we placed a BUY order for 1 APT with a limit price of 1 USDF.
Step 5: Crank
After every order, cranks are necesary to complete settlement. See Crank for more details.
We can use the Ferum indexing API to see our order.
You've just submitted your first order using Ferum!
Last updated