instructions/account_manager/borrow.rs.
user_borrow(assets, max_debt_shares)
- Gate on operating mode, reserve status (
Active) andborrow_enabled. init_if_neededtheDebtPosition ["debt", margin, reserve]and the margin vault. The margin must have room undermax_debts_per_marginfor a new debt.- Accrue. Require
total_borrow + assets ≤ borrow_capandassets ≤ available_cash. - Mint debt shares (rounded up), at most
max_debt_shares. - Transfer the tokens from the reserve to the margin vault.
- Value every holding through the oracle. The full-set health factor must exceed 1.10.
borrow_enabled.
user_repay_from_margin(max_assets, repay_all)
Repay from the margin vault’s own balance. repay_all repays the exact accrued debt. The amount is capped at what the vault holds. When shares reach zero, the debt leaves the margin’s active list. Close the DebtPosition with user_reclaim_rent.
There is no wallet-side repay instruction for owners. To repay with wallet funds, deposit them into the margin first, then repay from margin. Liquidators repay from their own wallet inside
public_liquidate.
