An order is a token transfer to hexbook.near through intents.near with a JSON msg. The token you send sets the
side (base = sell, quote = buy); the amount you send is what the order spends.
The token must already be in your intents.near balance: deposit it into NEAR Intents first (see
Deposits in the NEAR
Intents docs).
Market makers quoting many levels should use batch: one signed intent cancels up to 64
and places up to 32 orders atomically from the internal balance. Transfers are how takers trade and how to place a single
order.
The msg
Flat: every field is at the top level of msg. Unknown fields are ignored.
refs is required. Without it the call fails (Failed to parse protocol message: missing field 'refs') and is refunded.
Always send at least "refs": [].
What happens to a limit order
- It matches the opposite side up to its price (unless
post_only), at the makers’ prices.
- The remainder rests at
price with your current epoch and expires_at. It is refunded instead when it is below the
minimum, you already have 200 orders, the level is full (500), or the fill was truncated (max_fills, gas, log size).
- A resting remainder logs
order_created; a trade logs trade.
A market order never rests: what it does not spend is refunded. An unmet min_amount_out fails the call
(Slippage too high) and the transfer is refunded.
Always quote first
Call get_quote_pub with the same amount, token, msg fields and your taker_id. If the book
does not change before your transaction lands and the receipt has enough gas, the trade does exactly what the
quote says.
Option A: direct mt_transfer_call
Your NEAR account calls intents.near itself and pays its own gas.
This sells 0.01 QTC (12 decimals) at 140 USDT.
attached-deposit is 1 yoctoNEAR.
- Attach 300 Tgas for anything that may fill several orders (see Gas); keep the
gas reserve on the account.
Option B: signed transfer intent (gasless)
The same order as a NEAR Intents transfer intent with msg, signed with NEP-413
and submitted through the NEAR Intents solver relay (no NEAR needed) or with
execute_intents.
This buys QTC for 0.7 USDT at up to 140 USDT.
tokens must hold exactly one token.
min_gas is the gas intents.near gives mt_on_transfer. Of the relay’s 300 Tgas, ~278 Tgas reach the book: keep
max_fills around 40.
Gas
The book’s receipt keeps gas for what it still has to do and stops filling before it runs short:
- With too little gas for the next fill the trade stops there and the rest is refunded (
rf, truncated in the
quote). With too little for even one fill it panics (Not enough gas to fill the order) and the transfer is refunded.
- Payouts that do not fit in the gas left are credited to internal balances instead of paid out: the trade event’s
np says how many were paid (Payouts and balances). As a taker, check
get_user_balance after a trade with np below the number of payouts and collect it
with claim_balance.
- Attach 300 Tgas to
mt_transfer_call (or give the transfer intent a high min_gas) unless you know the trade
fills one or two orders.
Failures and refunds