Trade
Trade

SynFutures · Acts onchain

Trades a SynFutures instrument on Base at the market: a long or a short of the size stated, against the instrument's AMM, filled in the same block. The instrument's trade takes two packed words: SynFutures' default referral, the deadline (the plug's own), the limit tick and the expiry, then the signed size above the margin to post. The size is in the instrument's base at 18 decimals; a trade the other way reduces or closes a position, and all reads the Plug account's position on the expiry from the Observer when the program runs and trades exactly its size the other way, closing it. The worst price is converted to the limit tick on the trader's side, and zero trades at any price; the instrument refuses a trade whose fill would land past it, a trade below the instrument's minimum, and one that leaves the position under its initial margin. Closing a position whole returns its margin to the Plug account's Gate reserve. The program approves the Gate for exactly the margin before the call and clears the approval after it: the instrument takes margin out of the Plug account's Gate reserve first and has the Gate pull only what the reserve does not cover from the Plug account, so an approval the reserve covered never lingers. Margin is stated in the instrument's quote token and posted at the instrument's 18-decimal precision. Prices are quote per base on SynFutures' tick ladder, 1.0001 per tick; a price is converted to the tick on the trader's side of it, so a fill never lands past the price stated. SynFutures keys every Gate reserve, position, order and range on its trader, the address that sends the call, and Base's Gate has no operator, depositFor or withdrawFor through which another address could act for a trader. A plug's deposits, trades, orders and ranges are therefore the Plug account's: they sit in the Plug account's reserve and portfolio, later steps act on them from the Plug account, and a withdrawal pays the Plug account. A reserve, position, order or range of the wallet's own is acted on only by a call the wallet sends itself. Reach for it to open a position when a condition is met, to close one before the liquidation price gets close, or to scale in as a price confirms.