Creating a Buy Order
Step 1: Encode the order data
scaled_quantity = quantity * baseTokenInternalScale
scaled_price = price * quoteTokenInternalScale
order_data = (scaled_quantity << 256) | scaled_pricescaled_quantity = 0.01 * 10 000 000 000
scaled_price = 100 * 10 000
full_word = 256
order_data = (scaled_quantity << full_word) | scaled_price
order_type = 0
execution_condition = 2
lifetime = 90
order_data = order_data << full_word | order_type
order_data = order_data << full_word | execution_condition
order_data = order_data << full_word | lifetimeStep 2: Calculate the quantity to approve
Step 3: Prepare additional payload data
Step 4: Approve the allowance
Step 5: Create a buy order
Last updated

