Close trade
Close trade

gTrade · Acts onchain

Asks gTrade to close the whole of an open trade at the market. The diamond's closeTradeMarket records a pending close of the trade at the price stated, refusing a trade that already has a market order pending. The oracle network answers in a later block, and the trade closes at that price within the trade's closing slippage of the one stated, paying the trader the collateral with its profit or loss, less the closing fee and the holding fees the trade owes. gTrade keys every book on its trader. A program on a Plug account apart from its wallet acts on the wallet's own book: the Plug account calls the diamond's delegatedTradingAction naming the wallet, which runs the call as the wallet, so collateral is pulled from and proceeds are paid to the wallet and every trade stays the wallet's. The wallet's one standing grant is setTradingDelegate naming its Plug account, sent with its approvals before the first program that needs it; a wallet that is its own socket trades as itself. Reach for it to take profit or cut a loss when a price condition is met, or to close in step with another position.

On other protocols · 1