Open trade

Open trade on Avantis

Base
Base

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.

Plug lets you combine onchain actions like this one into a single transaction, without writing a smart contract. Use in App opens a new plug with this action already in it.

BTC 5x Long on Avantis

avantis
1action
  1. 1·Open trade

    Opens a long market order on Avantis for [BTC/USD] funded with 100 [USDC] collateral at 5x leverage, targeting an entry near 81440 while capping execution to within 1% slippage, with take profit set to 0 and stop loss set to 0, meaning neither exit is configured.

Open a order on with at x near within % slippage, take profit at and stop loss at
  • BTC 5x Long on Avantis

    avantis

More on Avantis · 37

On other protocols · 1