
Avantis · Acts onchain
Asks Avantis to close some or all of an open trade at the market. The Trading router's closeTradeMarket records a pending close of the collateral stated, at most what the trade holds, and refuses a trade that is already being closed. All reads the trade's collateral from TradingStorage when the program runs and closes all of it. A keeper executes the close in a later block at the oracle price it supplies and pays the trader the collateral closed with its profit or loss, less the closing fee, the borrowing and funding fees and the gas fee Avantis charges on a close. The order id this returns names that pending close; the trade stays open until a keeper has executed it. Avantis keys every book on its trader, the address that sent the order, so an entry is acted on only by its own trader: an entry of the Plug account's book runs in the Plug account's program, and an entry of the wallet's own book is a call the wallet sends itself. Reach for it to take profit or cut a loss when a price condition is met, to close before funding turns against the trade, or to close in step with another position.
On other protocols · 1