Submit DEX Order
Account name (user1) needs to be updated along with market specific information
JavaScript
Python
const actions = [
{
account: 'eosio.token',
name: 'transfer',
data: {
from: username,
to: 'dex',
// Must match precision of transferred asset (XPR -> 4 -> .0000)
quantity: '1000.0000 XPR',
memo: ''
},
authorization
},
{
account: 'dex',
name: 'placeorder',
data: {
market_id: 1,
account: username,
order_type: 1, // Limit order
order_side: 2, // Sell
// Raw amount without precision (1000.0000 XPR -> 1000000)
quantity: 7000000,
// In terms of ask precision (6 in this case is price 0.002025)
price: '002100',
bid_symbol: {
sym: '4,XPR',
contract: 'eosio.token'
},
ask_symbol: {
sym: "6,XMD",
contract: 'xmd.token'
},
// Not stop loss / take profit
trigger_price: 0,
// 0 = Good Till Cancel, 1 = Immediate or cancel, 2 = Post Only
fill_type: 0,
referrer: 'marlon'
},
authorization
},
{
account: 'dex',
name: "process",
data: {
q_size: 5,
show_error_msg: 0
},
authorization
}
]
const main = async () => {
await transact(actions)
}
main()
args1 = {
# Trading account
'from': username,
'to': 'dex',
# Must match precision of transferred asset (XPR -> 4 -> .0000)
'quantity': '1000.0000 XPR',
'memo': ''
}
args2 = {
# ID of market
"market_id": 5,
# Trading account
"account": username,
# 1 = Limit order, 2 = Stop Loss, 3 = Take Profit
"order_type": 1,
# 1 = Buy, 2 = Sell
"order_side": 2,
# Raw amount without precision (100.0000 XPR -> 1000000)
"quantity": 1000000,
# In terms of ask precision (6 in this case is price 0.002025)
"price": 20250,
# Bid & ask symbols
"bid_symbol": {
"sym": '4,XPR',
"contract": 'eosio.token'
},
"ask_symbol": {
"sym": "6,XUSDC",
"contract": 'xtokens'
},
# Not stop loss / take profit
"trigger_price": 0,
# 0 = Good Till Cancel, 1 = Immediate or cancel, 2 = Post Only
"fill_type": 0,
# Can add referrer
"referrer": ''
}
args3 = {
# To process orders in Q
"q_size": 10,
# Whether to throw error if no orders in queue
"show_error_msg": 0
}
permission = {username:'active'}
a1 = ['eosio.token', 'transfer', args1, permission]
a2 = ['dex', 'placeorder', args2, permission]
a3 = ['dex', 'process', args3, permission]
eosapi.push_actions([a1, a2, a3])
Last modified 1mo ago