Python CLI
CLI provides the following set of commands:
bind_to_signer
Binds the trading account to the public key so the public key becomes the signer of the trading account
This can only be invoked for a trading account
Sends the transaction on chain
The public key and trading account taken is from cli_config.toml
r_auth
Issues a JWT token that is needed to interact with the Exchange
query_gas
Queries and saves usage the gas price that is needed for taker orders, off-chain withdrawals and increase nonce commands
user_info
Queries and saves user info that includes:
trading_account balance on the Exchange for each trading token
account nonce
taker and maker fees
approve_exchange <token_name> <amount>
Grants Exchange the permission to move user funds up to a specified amount
Sends the transaction on chain
Example:
approve_exchange ETH 1.2
deposit <token_name> <amount>
Deposits a specified amount of tokens to the Exchange
Sends the transaction on chain
Before executing this command, the user should have approval for this amount. Otherwise, this transaction simulation will fail
Example:
deposit ETH 1.2
get_order <order_hash>
Queries information about the order from the Exchange
Users can only get information about their orders i.e orders that were signed by the signer address of the obtained the JWT token
Example:
get_order 4385348239423
get_orders <mode either 1 full or 2 reduced> <offset> <limit, max 20>
Queries all orders of trading account from cli_config.toml
Example:
get_orders 1 0 20
get_bbo <base_token/quote_token> <is_ecosystem_book flag>
Queries the best bid and best offer of a particular trading pair from the Exchange
Flags controls whether it be from the Ecosystem Book or the Router Book
Example:
get_bbo <ETH/USDC> 1
cancel_all
Cancels all trading account orders on the Exchange
cancel_order <order_hash>
Cancels an order associated with order_hash on the Exchange
Only existing orders and orders that were signed by the signer address can be cancelled
Example:
cancel_order 4385348239423
withdraw <token> <amount>
Initiates an off-chain withdrawal through exchange
Before executing this command user should have queried the gas via the
query_gas
commandThe user should have a specified amount of tokens on the Exchange to be able to successfully execute the command and should have enough to cover the gas
Example:
withdraw ETH 0.1
request_withdraw_on_chain <token> <amount>
Initiates an on-chain withdrawal via the smart contract
Users can only have one pending on-chain withdrawal per token
Sends the transaction on chain
The user should have a specified amount of tokens in the smart contract at the time of this call to be able to successfully execute the command and should also have enough to cover the gas
Withdrawal hash can be used later by the user to finish the on-chain withdrawal via the command
apply_onchain_withdraw
Example:
request_withdraw_on_chain USDC 150.5
apply_onchain_withdraw <token> <withdrawal_hash>
Finalizes the on-chain withdrawal
Sends the transaction on chain
Note that the user should allow enough blocks and seconds passed after
request_withdraw_on_chain
to successfully execute the command. Otherwise, theFEW_TIME_PASSED
error will be raised in the smart-contract
place_order <base/quote> <price> <quantity> <BUY/SELL> <MARKET/LIMIT> <is_post_only> <is_full_fill_only> <is_best_level_only> <to_ecosystem_book:ECOSYSTEM/ROUTER> <stp_mode>
Places an order on the Exchange
STP modes:
NONE = 0
EXPIRE_TAKER = 1
EXPIRE_MAKER = 2
EXPIRE_BOTH = 3
Example:
place_order ETH/USDC 2765.4 0.32 BUY LIMIT 1 0 0 ECOSYSTEM 0
start_ws <signer pub address>
Starts WebSocket client with listen key issued to provided signer key (support for signer key from config)
subscribe_book <stream: trade/bbo/snap> <base> <quote> <is_ecosystem_book>
User should start the WebSocket client first
Example:
subscribe_book trade ETH USDC 1
subscribe_fills <trading_account>
User should start the WebSocket client first
Example:
subscribe_fills 0x...x
User can only subscribe for execution reports for accounts where the signer who started the WebSocket is the signer
refresh_chain_info
:
Queries chain info namely nonce, balances of tokens, approvals, signer, and balances inside the smart contract for the trading account
display_chain_info
Displays the latest queried chain info that was queried through
refresh_chain_info
increase_nonce <new_nonce>
Increase nonce onchain, invalidating all orders with different nonce
Usual flow for the trader that uses CLI:
In cli_config.toml the user must specify the:
Exchange address
Trading account: account address, public address, and private key,
HTTP and WS URLs of LayerAkira exchange
kind of chain used:
is_testnet
flag
On the very first launch the user should execute:
bind_to_signer:
to bind the account address to the signer (the public address). Otherwise, the signer cannot execute trading activity actions on the ExchangeDeposit to Exchange tokens if wishes to trade on the Ecosystem book:
approve_exchange
deposit
To be able to interact with LayerAkira users need to obtain a JWT token via r_auth
command
Last updated