> ## Documentation Index
> Fetch the complete documentation index at: https://docs.solana.vanna.finance/llms.txt
> Use this file to discover all available pages before exploring further.

# Margin Instructions

> Create, deposit, withdraw, close vaults and the account.

## `user_create_margin`

Init the PDA. Authority = signer.

## `user_deposit_collateral(amount)`

`init_if_needed` vault ATA. Measured transfer in. Register the asset index on first use.

## `user_withdraw_collateral(amount, min_health_factor_wad)`

Full-set health after the withdrawal. Must exceed `min_health_factor_wad` and the 1.1 threshold when debt remains.

## `user_close_collateral_position`

Empty vault only. Frees an index slot.

## `user_close_margin`

Zero collateral, zero debt, no Lite. Closes the PDA.
