Instructions Reference

This page lists every on-chain instruction across all four Keystone programs. Use it as a quick lookup while building integrations or writing keeper scripts.

Anchor clients: Alpha, Neutral, and Defense instructions take the main on-chain state PDA under the IDL field fundState (Rust fund_state). See Account Structure for PDA seeds and how that relates to program.account.fundState / basisFundState / defenseFundState when reading state.


Keystone Core

Keystone Core is the portfolio layer — it's what users interact with directly. Pick a risk profile, deposit, and Core handles routing your capital across the three underlying funds (Alpha, Neutral, Defense). Withdrawals and rebalancing flow through here too.

Public

Instruction
Parameters
Description

deposit

portfolio_id, usdc_amount, risk_profile

Deposit USDC. risk_profile (0/1/2) must match the portfolio's configured profile. ksCORE minted to caller.

deposit_jupsol

portfolio_id, jupsol_amount, min_usdc_out, risk_profile, swap_data

Deposit JupSOL. All JupSOL is swapped to USDC via Jupiter (PDA-signed, core_authority). USDC is then routed to all three funds per target allocations.

deposit_with_swap

portfolio_id, input_amount, min_usdc_out, risk_profile, swap_data

Deposit SOL, jitoSOL, hSOL, mSOL, bSOL, or any token. Jupiter swaps input → USDC (user signs), then routes to all three funds.

withdraw

portfolio_id, core_shares_in

Burn ksCORE, receive proportional USDC from all three funds.

withdraw_with_swap

portfolio_id, core_shares_in, min_token_out, swap_data

Burn ksCORE, redeem USDC from all three funds, then Jupiter-swap USDC → SOL, JupSOL, jitoSOL, hSOL, mSOL, or bSOL. core_authority PDA signs as userTransferAuthority.

rebalance

portfolio_id, alpha_share_price, neutral_share_price, defense_share_price

Permissionless rebalance toward target allocations

Admin

Instruction
Parameters
Description

initialize_portfolio

portfolio_id, risk_profile, alpha_fund_id, neutral_fund_id, defense_fund_id, deposit_cap, rebalance_interval, drift_threshold_bps

Initialize portfolio with a fixed risk profile. To change profile, users must fully withdraw and re-deposit.

register_fund_atas

portfolio_id

Create Core's ATAs for each fund's share token and USDC

update_params

portfolio_id, alpha_target_bps?, neutral_target_bps?, defense_target_bps?, deposit_cap?, rebalance_interval?, drift_threshold_bps?, min_rebalance_usdc?

Update targets and config (targets validated against profile bounds)

toggle_emergency

portfolio_id, activate

Activate emergency de-risk mode (overrides targets to 0%/max_neutral/max_defense). Deactivation restores saved targets.

pause_portfolio

portfolio_id, paused

Pause / unpause

Risk Profile Constants

Portfolio IDs: Conservative=1, Balanced=2, Growth=3. The risk_profile field inside each portfolio (0/1/2) is set at initialize_portfolio and matches the profile above.


Keystone Alpha Fund

Public

Instruction
Parameters
Description

deposit

fund_id, amount

Deposit USDC, receive shares

withdraw

fund_id, shares

Burn shares, receive USDC (auto-recalls from Marginfi if needed)

rebalance

fund_id, swap_data

Execute DCA rebalance — single atomic tx with Jupiter swap

execute_swap

fund_id, swap_data, min_amount_out

Permissionless Jupiter swap between USDC and jitoSOL

deploy_to_lending

fund_id, amount, reserve_bps

Deploy idle USDC to Marginfi. Permissionless when auto_lending_enabled; admin always

withdraw_from_lending

fund_id, amount

Recall USDC from Marginfi. Permissionless when auto_lending_enabled (non-zero amount only); admin can withdraw all

collect_fees

fund_id

Collect management + performance + rebalancing fees. Permissionless — fees always go to admin

Admin

Instruction
Parameters
Description

initialize_fund

fund_id, sol_feed_id, ath_price, low_pct_of_ath, high_pct_of_ath, sol_min_bps, sol_max_bps, max_step_bps, min_rebalance_interval, management_fee_bps, deposit_cap, max_slippage_bps, performance_fee_bps, rebalancing_fee_bps

Initialize fund

close_fund

fund_id

Close fund_state PDA and reclaim rent. Admin-only; uses raw byte validation to handle stale struct layouts.

update_fund_params

params (all optional)

Update config: ATH, thresholds, fees, vol/regime, circuit breaker, NAV guard, lending

enable_lending

fund_id, enabled

Toggle Marginfi lending

set_core_gate

fund_id, core_authority, enabled

Enable/disable CoreGate. When enabled, only the given core_authority PDA may deposit/withdraw. Pass findProgramAddress(["core_authority", portfolio_id], CORE_PROGRAM_ID).

pause_fund

fund_id, paused

Pause / unpause

transfer_authority

fund_id

Transfer admin to new address

update_fund_params — Full Parameter List


Keystone Neutral Fund

Public

Instruction
Parameters
Description

deposit

fund_id, amount

Deposit USDC, receive shares

withdraw

fund_id, shares

Immediate if idle USDC sufficient, otherwise creates PendingWithdrawal PDA

deploy_capital

fund_id, swap_data, jupiter_account_count, collateral_bps, acceptable_price

Deploy into standard basis trade (split USDC: collateral → Jupiter Perps short; remainder → jitoSOL). If Marginfi has idle USDC from park_capital, withdraws it here before deploying (no separate unpark instruction). Requires total_pending_withdrawals == 0 — call claim_withdrawal for all pending users first.

deploy_reverse

fund_id, swap_data, jupiter_account_count, acceptable_price

Deploy reverse basis (Kamino jitoSOL borrow + SOL-PERP long on Jupiter Perps)

close_reverse

fund_id, swap_data, jupiter_account_count, acceptable_price

Close reverse basis position

unwind_position

fund_id, swap_data, jupiter_account_count, acceptable_price

Close standard basis short, swap jitoSOL → USDC; services withdrawal queue

claim_withdrawal

fund_id

Transfer queued USDC to user after unwind, close PendingWithdrawal PDA

park_capital

fund_id, swap_data, jupiter_account_count

After basis closed: optional jitoSOL→USDC swap, then deposit USDC into Marginfi (requires enable_basis_lending). Requires total_pending_withdrawals == 0.

park_in_jitosol

fund_id, swap_data, jupiter_account_count

Park idle USDC as jitoSOL for staking yield when swap_to_jitosol_when_parking is enabled (or admin)

settle_funding

fund_id

Read Jupiter Perps position account, compute carry delta, update share price

adjust_position

fund_id, new_size_usd, acceptable_price

Rebalance hedge ratio or deleverage

emergency_close_position

fund_id, acceptable_price

Close on N consecutive negative funding periods or NAV drawdown

collect_fees

fund_id

Collect management + performance fees

Admin

Instruction
Parameters
Description

initialize_fund

fund_id, sol_feed_id, management_fee_bps, deposit_cap, performance_fee_bps, min_settle_interval, min_health_factor_bps, target_health_factor_bps, max_position_bps, min_deploy_amount, max_swap_slippage_bps

Initialize fund

close_fund

fund_id

Close fund_state PDA and reclaim rent. Admin-only; uses raw byte validation to handle stale struct layouts.

open_position

fund_id, collateral_usdc, size_usd, acceptable_price

Manual: deposit USDC as collateral + open short on Jupiter Perps

close_position

fund_id, acceptable_price

Manual: close short on Jupiter Perps, recover USDC collateral

enable_basis_lending

fund_id

One-time Marginfi account setup for park_capital

enable_reverse_basis

fund_id, tag, id

One-time Kamino obligation setup for deploy_reverse / close_reverse

set_core_gate

fund_id, core_authority, enabled

Enable/disable CoreGate. When enabled, only the given core_authority PDA may deposit/withdraw.

update_fund_params

fund_id, many optional fields

Update health, fees, vol sizing, funding gates, jitoSOL parking flag, NAV drawdown guard, etc.

pause_fund

fund_id, paused

Pause / unpause

transfer_authority

fund_id

Transfer admin

Funding Regime Cycle


Keystone Defense Fund

Public

Instruction
Parameters
Description

deposit

fund_id, amount

Deposit USDC, receive shares

withdraw

fund_id, shares

Burn shares, receive USDC

deploy_to_lending

fund_id, amount

Deploy USDC to lending market

recall_from_lending

fund_id, amount

Recall USDC from lending

open_long_position

fund_id, usdc_collateral, size_usd, acceptable_price

Open SOL-PERP long on Jupiter Perps to capture negative funding

close_long_position

fund_id, acceptable_price

Close SOL-PERP long on Jupiter Perps

execute_liquidation

fund_id, ...

Participate in liquidation arb

buy_distressed_collateral

fund_id, ...

Purchase LSTs trading below fair value

settle

fund_id

Permissionless NAV crank — reads on-chain balances (JupSOL, USDC, Marginfi lending), recomputes share price, emits SettleEvent. Rate-limited by min_settle_interval; admin bypasses.

settle_funding

fund_id

Read Jupiter Perps position account, compute carry delta, update NAV

collect_fees

fund_id

Collect fees

Admin

Instruction
Parameters
Description

initialize_fund

fund_id, ...

Initialize Defense fund

close_fund

fund_id

Close fund_state PDA and reclaim rent. Admin-only; uses raw byte validation to handle stale struct layouts.

set_core_gate

fund_id, core_authority, enabled

Enable/disable CoreGate. When enabled, only the given core_authority PDA may deposit/withdraw.

update_fund_params

params

Update config

enable_lending

fund_id, enabled

Toggle lending

pause_fund

fund_id, paused

Pause / unpause

transfer_authority

fund_id

Transfer admin


See Admin Operations for full code examples.

Last updated