Method Signature
Parameters
The market application ID on Algorand
The position to trade:
1 for Yes, 0 for NoPrice in microunits (e.g.,
500_000 = $0.50). This is your target price — actual fills may be at this price ± slippage.Quantity in microunits (e.g.,
1_000_000 = 1 share)Whether this is a buy order (
true) or sell order (false)Slippage tolerance in microunits (e.g.,
50_000 = $0.05). The order will match against counterparty orders within price ± slippage.Fee base in microunits (e.g.,
70_000 = 7%). If omitted, reads from market’s on-chain global state.Pre-computed matching orders. If omitted, the SDK automatically fetches the orderbook and computes matches. Advanced use only.
Return Type
The escrow app ID of the newly created order. If the order is fully matched, this escrow may have zero remaining quantity.
Array of transaction IDs from the atomic group (includes order creation + all match proposals)
The confirmed round number on the blockchain
Total quantity that was matched in microunits. May be less than the requested quantity if insufficient liquidity exists within your slippage tolerance.
Volume-weighted average fill price in microunits. This is the actual price you paid/received, accounting for complementary matching.
Example
Behavior Notes
- Automatic Matching: The SDK fetches the orderbook, identifies all counterparty orders within your slippage tolerance, and proposes matches in a single atomic transaction.
- Slippage Protection: Only matches against orders within
price ± slippage. If insufficient liquidity exists, the order partially fills and the remainder sits on the orderbook. - Atomic Execution: Order creation and all matches execute atomically — either all succeed or all fail.
- Complementary Matching: The SDK handles complementary matching logic (e.g., buying YES at 0.40).
- Price Improvement: If better prices exist on the orderbook, you get them. The
matchedPricereflects the volume-weighted average of all fills. - Gas Fees: Each match proposal costs ~10,000 microAlgos in transaction fees. The SDK handles this automatically.
