Lending
Instructions for collateral, borrowing and repayment.
Updated Sep 25, 2026
Public credit: a position holds collateral on either side and debt on either side, each debt side secured by the opposite collateral. Admission uses the shadow curve; the stored liquidation factor judges the position afterwards. See Borrow and Borrowing and rates.
deposit_collateral
Deposit one market asset as collateral into a borrow position, creating the position if needed.
- Caller
- The position owner
- In the app
- Borrow · Portfolio
- Discriminator
9c838e7492f7a278
Arguments
args: DepositCollateralArgs
| Field | Type | Notes |
|---|---|---|
| position_id | pubkey | Any public key the owner chooses; it seeds the position address. |
| deposit_amount | u64 | Collateral atoms to deposit. |
Accounts
| Account | Flags | Resolution | Notes |
|---|---|---|---|
| market | writable | PDA ["market_v2", market.base_side.asset_mint, market.quote_side.asset_mint, market.params_hash] | |
| futarchy_authority | PDA ["futarchy_authority"] | ||
| owner | writable · signer | ||
| asset_mint | |||
| collateral_vault | writable | ||
| owner_asset_account | writable | ||
| borrow_position | writable | PDA ["borrow_position_v2", market, owner, args.args.position_id] | |
| token_program | Tokenkeg…Q5DA | ||
| token_2022_program | TokenzQd…xuEb | ||
| system_program | 11111111…1111 | ||
| event_authority | PDA ["__event_authority"] | ||
| program |
withdraw_collateral
Withdraw collateral while the position stays within its buffered borrow limit.
The check uses the greater of the stored liquidation factor and a freshly computed one, then tests capacity after the withdrawal. Blocked in reduce-only mode while debt remains.
- Caller
- The position owner
- In the app
- Portfolio
- Discriminator
7387a86a8bd68a96
Arguments
args: WithdrawCollateralArgs
| Field | Type | Notes |
|---|---|---|
| withdraw_amount | u64 | Collateral atoms to withdraw. |
| min_asset_amount_out | u64 | Minimum received after transfer fees. |
| min_liquidation_cf_bps | u16 | Lowest liquidation collateral factor the owner accepts for the recomputed terms. |
Accounts
| Account | Flags | Resolution | Notes |
|---|---|---|---|
| market | writable | PDA ["market_v2", market.base_side.asset_mint, market.quote_side.asset_mint, market.params_hash] | |
| futarchy_authority | PDA ["futarchy_authority"] | ||
| owner | writable · signer | ||
| asset_mint | |||
| collateral_vault | writable | ||
| owner_asset_account | writable | ||
| borrow_position | writable | PDA ["borrow_position_v2", market, borrow_position.owner, borrow_position.position_id] | |
| token_program | Tokenkeg…Q5DA | ||
| token_2022_program | TokenzQd…xuEb | ||
| event_authority | PDA ["__event_authority"] | ||
| program |
borrow
Borrow the opposite asset against a position's collateral and store the resulting liquidation factor.
Admission uses the shadow constant-product curve at the pessimistic price and depth. Consumes the asset's daily borrow bucket. An optional referral partner can be bound the first time a debt side is opened.
- Caller
- The position owner
- In the app
- Borrow
- Discriminator
e4fd83cacf745912
Arguments
args: BorrowArgs
| Field | Type | Notes |
|---|---|---|
| borrow_amount | u64 | Debt atoms to draw. |
| min_debt_amount_out | u64 | Minimum net receipt after transfer fees. |
| min_liquidation_cf_bps | u16 | Lowest liquidation collateral factor the borrower accepts; the program stores the computed factor. |
| referrer | Option<pubkey> | Optional listed referral partner authority. |
Accounts
| Account | Flags | Resolution | Notes |
|---|---|---|---|
| market | writable | PDA ["market_v2", market.base_side.asset_mint, market.quote_side.asset_mint, market.params_hash] | |
| futarchy_authority | PDA ["futarchy_authority"] | ||
| owner | writable · signer | ||
| debt_asset_mint | |||
| collateral_asset_mint | |||
| reserve_vault | writable | ||
| owner_debt_account | writable | ||
| borrow_position | writable | PDA ["borrow_position_v2", market, borrow_position.owner, borrow_position.position_id] | |
| referral_partner | optional | Optional; required together with referral_accrual when a referrer is passed. | |
| referral_accrual | optional | ||
| token_program | Tokenkeg…Q5DA | ||
| token_2022_program | TokenzQd…xuEb | ||
| event_authority | PDA ["__event_authority"] | ||
| program |
repay
Repay part or all of a position's debt on one side; anyone may pay.
Pass u64::MAX to clear the side exactly. The payer's amount is a maximum gross debit; the program takes only what the burnable shares need. Realized interest follows the interest distribution path.
- Caller
- The owner or any payer
- In the app
- Portfolio
- Discriminator
ea674352d0eadba6
Arguments
args: RepayArgs
| Field | Type | Notes |
|---|---|---|
| repay_amount | u64 | Maximum atoms to debit from the payer. |
Accounts
| Account | Flags | Resolution | Notes |
|---|---|---|---|
| market | writable | PDA ["market_v2", market.base_side.asset_mint, market.quote_side.asset_mint, market.params_hash] | |
| futarchy_authority | PDA ["futarchy_authority"] | ||
| owner | writable · signer | Token payer; need not own the borrow position. | |
| debt_asset_mint | |||
| collateral_asset_mint | |||
| reserve_vault | writable | ||
| interest_vault | writable | ||
| owner_debt_account | writable | ||
| borrow_position | writable | PDA ["borrow_position_v2", market, borrow_position.owner, borrow_position.position_id] | |
| referral_partner | optional | ||
| referral_accrual | writable · optional | ||
| token_program | Tokenkeg…Q5DA | ||
| token_2022_program | TokenzQd…xuEb | ||
| event_authority | PDA ["__event_authority"] | ||
| program |
preview_borrow_capacity
Read-only: for a collateral amount, the maximum debt by health, by cash and by the daily limit, with the collateral factors that would apply.
- Caller
- Any client, by simulation
- Discriminator
cbaa1c4f20b4b146
Arguments
args: PreviewBorrowCapacityArgs
| Field | Type | Notes |
|---|---|---|
| collateral_amount | u64 | Net deposit credit in the collateral vault. Capacity also accounts for the current fee when that collateral later exits the vault. |
| projected_borrow_amount | Option<u64> |
Accounts
| Account | Flags | Resolution | Notes |
|---|---|---|---|
| market | writable | PDA ["market_v2", market.base_side.asset_mint, market.quote_side.asset_mint, market.params_hash] | |
| collateral_asset_mint | |||
| debt_asset_mint |
preview_borrow_position
Read-only: an existing position with interest accrued and its health terms.
- Caller
- Any client, by simulation
- Discriminator
f0ec2d1eac922da3
Arguments
None.
Accounts
| Account | Flags | Resolution | Notes |
|---|---|---|---|
| market | writable | PDA ["market_v2", market.base_side.asset_mint, market.quote_side.asset_mint, market.params_hash] | |
| borrow_position | PDA ["borrow_position_v2", market, borrow_position.owner, borrow_position.position_id] | ||
| base_mint | Liquidation values each side's collateral after its mint's current transfer fee, so the preview reads both mints. | ||
| quote_mint |
preview_borrow_position_capacity
Read-only: additional borrow or collateral withdrawal capacity for an existing position, using the instructions' own calculations.
Choose borrow or withdraw mode; only that limit is computed to stay within the compute budget.
- Caller
- Any client, by simulation
- Discriminator
753f948ac925bd01
Arguments
args: PreviewBorrowPositionCapacityArgs
| Field | Type | Notes |
|---|---|---|
| capacity_kind | BorrowPositionCapacityKind | |
| collateral_change | i128 | Net collateral credit (positive) or vault debit (negative), in raw mint units. |
| projected_borrow_amount | Option<u64> | Additional debt to draw. None quotes the maximum additional draw. |
BorrowPositionCapacityKind
| Variant | Fields |
|---|---|
| Borrow | unit |
| Withdraw | unit |
Accounts
| Account | Flags | Resolution | Notes |
|---|---|---|---|
| market | PDA ["market_v2", market.base_side.asset_mint, market.quote_side.asset_mint, market.params_hash] | ||
| borrow_position | PDA ["borrow_position_v2", market, borrow_position.owner, borrow_position.position_id] | ||
| collateral_asset_mint | |||
| debt_asset_mint |
donate_collateral
Add the signer's tokens to another owner's existing borrow position without changing ownership.
- Caller
- Any donor
- Discriminator
edeacd54b16ac626
Arguments
args: DonateCollateralArgs
| Field | Type | Notes |
|---|---|---|
| deposit_amount | u64 |
Accounts
| Account | Flags | Resolution | Notes |
|---|---|---|---|
| market | writable | PDA ["market_v2", market.base_side.asset_mint, market.quote_side.asset_mint, market.params_hash] | |
| futarchy_authority | PDA ["futarchy_authority"] | ||
| owner | writable · signer | ||
| asset_mint | |||
| collateral_vault | writable | ||
| owner_asset_account | writable | ||
| borrow_position | writable | PDA ["borrow_position_v2", market, borrow_position.owner, borrow_position.position_id] | |
| token_program | Tokenkeg…Q5DA | ||
| token_2022_program | TokenzQd…xuEb | ||
| event_authority | PDA ["__event_authority"] | ||
| program |
withdraw_all_collateral
Sweep both collateral balances and close a borrow position after its debt is fully repaid.
- Caller
- The position owner
- Discriminator
25b99fd6251ea392
Arguments
args: WithdrawAllCollateralArgs
| Field | Type | Notes |
|---|---|---|
| min_base_out | u64 | |
| min_quote_out | u64 |
Accounts
| Account | Flags | Resolution | Notes |
|---|---|---|---|
| market | writable | PDA ["market_v2", market.base_side.asset_mint, market.quote_side.asset_mint, market.params_hash] | |
| owner | writable · signer | ||
| borrow_position | writable | PDA ["borrow_position_v2", market, borrow_position.owner, borrow_position.position_id] | |
| base_mint | |||
| quote_mint | |||
| base_collateral_vault | writable | ||
| quote_collateral_vault | writable | ||
| owner_base_account | writable | ||
| owner_quote_account | writable | ||
| token_program | Tokenkeg…Q5DA | ||
| token_2022_program | TokenzQd…xuEb | ||
| event_authority | PDA ["__event_authority"] | ||
| program |