exchange.IO("trigger.*", ...)
Helper commands for Jupiter's native limit orders: choose the v1 or V2 API, view the V2 custodial vault, and simulate placing or canceling.
exchange.IO(k)
exchange.IO(k, mode)
exchange.IO(k, action)
exchange.IO(k, params)
exchange.IO(k, params, wallet)Examples
-
Check the API mode and simulate a SOL sell order above the price (read-only).
javascriptfunction main() { Log("API mode:", exchange.IO("trigger.api")) var t = exchange.GetTicker("SOL_USDC") if (!t) { Log("Ticker failed:", GetLastError()) return } var sim = exchange.IO("trigger.simulate", {symbol: "SOL_USDC", side: "sell", price: _N(t.Last * 1.2, 2), amount: 0.5, expiry: Date.now() + 7 * 86400 * 1000}) if (!sim) { Log("Invalid parameters:", GetLastError()) return } Log("simulation", sim.ok ? "ok" : "failed", sim.reason || "", "order account", sim.order, "gives", sim.makingAmount, "receives", sim.takingAmount) } -
Place a limit order once the simulation passes, query it and cancel it.
javascriptfunction main() { var t = exchange.GetTicker("SOL_USDC") var px = _N(t.Last * 0.8, 2) var params = {symbol: "SOL_USDC", side: "buy", price: px, amount: 0.5} var sim = exchange.IO("trigger.simulate", params) if (!sim || !sim.ok) { Log("Simulation did not pass:", sim ? sim.reason : GetLastError()) return } var id = exchange.CreateOrder("SOL_USDC", "buy", px, 0.5, {tif: "gtc"}) if (!id) { Log("Order failed:", GetLastError()) return } Log("Limit order", id, exchange.GetOrder(id)) Sleep(60 * 1000) Log("Cancel:", exchange.CancelOrder(id), GetLastError()) } -
With an API key, view the V2 vault and register it if needed.
javascriptfunction main() { var v = exchange.IO("trigger.vault") if (!v) { Log("Query failed (needs an API key or trigger.api v2):", GetLastError()) return } if (!v.registered) { v = exchange.IO("trigger.vault", "register") } Log("vault", v.vault, "SOL", v.sol) v.tokens.forEach(function(x) { Log(x.symbol || x.mint, x.amount) }) }
Returns
| Type | Description |
string / object / null value |
|
Arguments
| Name | Type | Required | Description |
k | string | Yes | The command: |
mode | string | No | The |
action | string | No | With |
params | object | No | The order parameters of |
wallet | string | No | For |
See Also
Jupiter exchange.IO exchange.CreateOrder exchange.CancelOrder exchange.ModifyOrder exchange.IO("dca.*")
Remarks
Where the limit orders are
Jupiter's native limit orders (Trigger) are not conditional orders: place them with exchange.CreateOrder(symbol, side, price, amount, {tif: "gtc"}) (or exchange.Buy and exchange.Sell with the same option), and Jupiter's keeper fills them once the price is reached; query and cancel them with exchange.GetOrder(), exchange.GetOrders(), exchange.CancelOrder() and exchange.GetHistoryOrders(), and change the price of V2 orders with exchange.ModifyOrder(). The order extra parameters are expiry (expiry timestamp in milliseconds) and slippage (allowed slippage ratio).
exchange.CreateConditionOrder() and the other conditional-order functions are not supported (Jupiter has no stop orders to map them to); each leg of V2 take-profit, stop-loss and OCO orders placed on jup.ag and elsewhere appears in exchange.GetOrders() as a plain limit order, priced at its USD trigger price, with the direction in Info's triggerCondition. The differences between the two APIs (v1 and V2), the fees and the custody risk are described in the "Limit orders" section of the Jupiter exchange page.
trigger.api
Which API new native limit orders and new DCA orders use: auto (default) uses Trigger V2 (funds deposited into a vault in Jupiter's custody) when an API key is set and the quote is USDC or USDT, and v1 (non-custodial, funds in an on-chain order account) otherwise; v1 always uses v1; v2 always uses V2, fails orders whose quote is not USDC or USDT, and works without an API key too (Jupiter currently accepts that, but its documentation requires a key). Only new orders are affected: existing orders go to the API matching the shape of their order ID (an account address for v1, a UUID for V2). Returns the mode after the call.
trigger.vault
Queries this wallet's custodial vault in Trigger V2 and its balances (needs the API key, or trigger.api v2). The funds of V2 limit orders and DCA orders sit here, including those of open orders, of expired orders not yet withdrawn and of canceled orders whose withdrawal did not complete. Without a vault it returns {wallet, registered: false}; otherwise {wallet, registered: true, vault, sol, tokens, info}, where tokens is [{mint, symbol, amount, raw}] (symbol only for tokens in the token table) and info is Jupiter's vault record.
With register a vault is registered first when the wallet has none (this only creates the custodial account at Jupiter; no transaction is sent and no funds move; an existing vault is returned as is). The first V2 order registers it by itself, but trigger.simulate and dca.simulate do not, so register before simulating ahead of the first order.
trigger.simulate
Builds the transaction placing a limit order and runs it with the node's simulateTransaction (not signed, nothing broadcast). params is {symbol, side, price, amount, expiry, slippage} with the meaning of an order (amount in the base token, price the limit price); written {cancel: orderId} it simulates canceling that v1 limit order (the order ID may carry the pair prefix).
- v1 returns
{ok, err, reason, logs, unitsConsumed, wallet, order, makingAmount, takingAmount, priorityFeeLamports}:orderis the order account that would be created, andmakingAmountandtakingAmountthe amounts given and received in smallest units (strings);reasonexplains a failure (when the paying wallet has no SOL at all the node only returnserrAccountNotFound, andreasonisAccountNotFound (the paying wallet has no SOL)). - V2 simulates the deposit into the vault, only for this wallet, and returns
{ok, err, reason, logs, unitsConsumed, version, wallet, vault, inputMint, inputAmount, triggerPriceUsd, triggerCondition, expiresAt, priorityFeeLamports}; it fails while the wallet has no vault. Canceling a V2 limit order cannot be simulated (the cancel call itself stops the order).