pub fn close_position(
    ctx: Context<'_, '_, '_, '_, ClosePosition<'_>>
) -> Result<()>
Expand description

Close out a position, removing it from the account.

Since there is a finite number of positions a single account can maintain it may be necessary for a user to close out old positions to take new ones.

Accounts

NameTypeDescription
authoritysignerThe authority that can change the margin account.
receiverwritableThe receiver for the rent released.
margin_accountwritableThe margin account with the position to close.
position_token_mintread_onlyThe mint for the position token being deregistered.
token_accountwritableThe token account for the position being closed.
token_programread_onlyThe spl token program.

Events

Event NameDescription
events::PositionClosedMarks the closure of the position.