Open trade
Open trade

Avantis · Acts onchain

Places an order on Avantis, the perpetuals exchange of Base, to go long or short one pair with stablecoin collateral at a chosen leverage. The Plug account approves TradingStorage for the collateral and calls the Trading router's openTrade, which pulls the collateral in and records the order. A market order asks for the price stated and accepts a fill within the slippage of it; a limit order opens once the price reaches the trigger, and a stop limit once it moves through it. A pair that trades as a PnL-fee pair takes its own market order type, which the program reads from PairStorage when it runs. The take profit and stop loss are prices, zero for none. The router refuses an order below the pair's minimum leveraged position, outside its leverage bounds, on a pair in close-only mode, or with a take profit or stop loss on the wrong side of the price. Avantis fills a market order asynchronously: the program's own transaction places it and escrows its collateral, and a keeper executes it in a later block at the oracle price it supplies, opening the trade only if that price falls within the slippage of the price asked for and refunding the collateral otherwise. The order id this returns names that pending order; it is not a fill, and the trade exists only once a keeper has executed it. A limit order returns no order id: it waits in the trader's book until a keeper triggers it. Reach for it to open a position when a condition is met, coiling the collateral from a swap or a withdrawal, and pair it with the open trade and pending order reads to act once the trade exists.

On other protocols · 1