Leverage delegate program

The leverage-delegate program: take-profit, stop-loss, entry and hLP orders.

Updated Sep 25, 2026

Orders are accounts on a second program. A position owner grants it a delegation on the Dusk program; the delegate then holds the order and, when a keeper executes it, approves the close through a before-hook and settles it through an after-hook inside delegated_close_leverage.

Entry orders and hLP orders escrow the user's assets in the delegate program until they fill, expire or are cancelled. See Leverage and Leverage and hedging.

Program ID
AXUucZ…PqqHbX
IDL
leverage_delegate 2.0.0
Instructions
18
Accounts
12
Events
2
Errors
6

Instructions

after_close_order

The delegate's after-hook: verify the settlement, pay the executor and the protocol order fee, finish or reduce the order.

Caller
A keeper, inside delegated_close_leverage
Discriminator
9ce0eefa5fe5eb3b

Arguments

args: ExecuteOrderArgs

FieldTypeNotes
order_idu64

Accounts

AccountFlagsResolutionNotes
orderwritablePDA ["leverage_order", order.position, order.owner, args.args.order_id]
ownerwritable
leverage_position
leverage_delegation
owner_token_account
executor_token_account
fee_recipient
token_mint
executoracross the delegated callback boundary.
futarchy_authority

before_stop_loss

The delegate's before-hook: verify a stop-loss trigger and stage the close approval.

Caller
A keeper, inside delegated_close_leverage
Discriminator
f63e52e8a8c7794e

Arguments

args: ExecuteOrderArgs

FieldTypeNotes
order_idu64

Accounts

AccountFlagsResolutionNotes
orderwritablePDA ["leverage_order", leverage_position, order.owner, args.args.order_id]
market
leverage_position
leverage_delegation
owner_token_account
fee_recipient
executor_token_account
futarchy_authority
collateral_mintCollateral mint is needed to reproduce the exact net reserve credit for Token-2022 transfer-fee assets before approving a partial close.
token_mint
executoracross the delegated callback boundary.

before_take_profit

The delegate's before-hook: verify a take-profit trigger and stage the close approval.

Caller
A keeper, inside delegated_close_leverage
Discriminator
05236f00df83c11f

Arguments

args: ExecuteOrderArgs

FieldTypeNotes
order_idu64

Accounts

AccountFlagsResolutionNotes
orderwritablePDA ["leverage_order", leverage_position, order.owner, args.args.order_id]
market
leverage_position
leverage_delegation
owner_token_account
fee_recipient
executor_token_account
futarchy_authority
collateral_mintCollateral mint is needed to reproduce the exact net reserve credit for Token-2022 transfer-fee assets before approving a partial close.
token_mint
executoracross the delegated callback boundary.

cancel_hlp_order

Cancel an hLP order and return the escrowed shares.

Caller
The order owner
In the app
Portfolio · Orders
Discriminator
81b2584df4270cc2

Arguments

args: HlpOrderIdArgs

FieldTypeNotes
order_idu64

Accounts

AccountFlagsResolutionNotes
orderwritablePDA ["hlp_order", order.market, owner, order.target_hlp_mint, args.args.order_id]
target_hlp_mint
custody_hlp_accountwritable
owner_hlp_accountwritable
ownersigner
token_2022_programTokenzQd…xuEb

cancel_leverage_entry_order

Cancel an unfilled entry order and return the escrowed margin.

Caller
The order owner
In the app
Portfolio · Orders
Discriminator
ab2204562dd37752

Arguments

args: LeverageEntryOrderIdArgs

FieldTypeNotes
order_idu64
min_owner_refund_outu64Minimum amount actually credited to the owner on cancel or execution. Zero keeps cancellation available when transfer fees consume escrow.

Accounts

AccountFlagsResolutionNotes
orderwritablePDA ["leverage_entry_order", order.market, owner, args.args.order_id]
debt_mintwritable
funding_vaultwritable
owner_funding_accountwritable
ownerwritable · signer
token_programTokenkeg…Q5DA
token_2022_programTokenzQd…xuEb

cancel_leverage_order

Cancel an order and close its account.

Caller
The position owner
In the app
Portfolio · Orders
Discriminator
1a58ad6aaff2cb7a

Arguments

_args: CancelLeverageOrderArgs

FieldTypeNotes
order_idu64

Accounts

AccountFlagsResolutionNotes
orderwritablePDA ["leverage_order", order.position, owner, args.args.order_id]
ownerwritable · signer

cancel_protection_order

Close a protection order and return its remaining escrowed LP shares to the owner.

Caller
The order owner
In the app
Portfolio · Protection orders
Discriminator
2efe5336c1c5978a

Arguments

None.

Accounts

AccountFlagsResolutionNotes
orderwritablePDA ["protection_order", owner, order.order_id]
lp_mint
custody_lp_accountwritable
owner_lp_accountwritable
ownersigner
token_2022_programTokenzQd…xuEb

create_hlp_order

Escrow hLP shares under a stop-loss (kind 1, on NAV per share) or stop-rate (kind 2, on the funding average) order.

Caller
The hLP holder
In the app
Earn · Orders
Discriminator
41389dba6bd07da3

Arguments

args: CreateHlpOrderArgs

FieldTypeNotes
order_idu64
kindu81 for stop-loss, 2 for stop-rate.
hlp_amountu64Shares escrowed.
trigger_nadu64The NAV or funding APR that arms the order.
min_target_amount_outu64Minimum received on execution, after bounties.

Accounts

AccountFlagsResolutionNotes
market
target_hlp_mint
base_mint
quote_mint
orderwritablePDA ["hlp_order", market, owner, target_hlp_mint, args.args.order_id]
owner_hlp_accountwritable
custody_hlp_accountwritable
base_yield_accountwritable
quote_yield_accountwritable
ownerwritable · signer
dusk_event_authorityPDA ["__event_authority"]
dusk_program2rYBVfGu…o16Y
token_2022_programTokenzQd…xuEb
system_program11111111…1111

create_leverage_entry_order

Escrow margin for a limit entry: the position opens when the market reaches the price, before the expiry.

Caller
The future position owner
In the app
Leverage · Limit
Discriminator
8eea74af19d09717

Arguments

args: CreateLeverageEntryOrderArgs

FieldTypeNotes
order_idu64
position_idpubkey
debt_assetu8
deposit_amountu64Margin escrowed, plus the protocol fee deposit.
protocol_fee_deposit_amountu64Additional gross fee funding, transferred separately so margin and bounty stay intact.
min_margin_amountu64
executor_bountyu64Paid to whoever fills the order.
multiplier_bpsu64Notional over margin at fill.
limit_price_nadu64The price condition.
min_collateral_outu64
expiry_unix_timestampi64One hour to thirty days out; no good-till-cancelled.
referrerOption<pubkey>

Accounts

AccountFlagsResolutionNotes
market
debt_mint
collateral_mint
orderwritablePDA ["leverage_entry_order", market, owner, args.args.order_id]
owner_funding_accountwritable
funding_vaultwritable
ownerwritable · signer
token_programTokenkeg…Q5DA
token_2022_programTokenzQd…xuEb
system_program11111111…1111

create_leverage_order

Create a take-profit (kind 1) or stop-loss (kind 2) order on a delegated leverage position.

Caller
The position owner
In the app
Leverage · TP/SL
Discriminator
c5ce0adf592e5d11

Arguments

args: CreateLeverageOrderArgs

FieldTypeNotes
order_idu64Owner-chosen id; part of the order address.
kindu81 for take-profit, 2 for stop-loss.
trigger_closeout_price_nadu64The closeout price that arms the order.
close_bpsu16How much of the position to close, 10,000 for all.

Accounts

AccountFlagsResolutionNotes
market
leverage_position
orderwritablePDA ["leverage_order", leverage_position, owner, args.args.order_id]
ownerwritable · signer
system_program11111111…1111

create_protection_order

Escrow LP shares for a borrow or leverage position and set the health trigger, repayment target, and keeper payment limits.

Caller
The order's owner, who need not own the position
In the app
Portfolio · Protection orders
Discriminator
0a188c91311887c7

Arguments

args: CreateProtectionOrderArgs

FieldTypeNotes
order_idu64
actionu8
debt_assetu8
lp_amountu64
max_lp_per_executionu64
max_payment_per_executionu64
trigger_health_bpsu64
target_health_bpsu64
min_payment_per_lp_nadu64Minimum gross payment per LP smallest unit, scaled by 1e9.
keeper_fee_bpsu16
expires_ati64

Accounts

AccountFlagsResolutionNotes
market
borrow_positionoptional
leverage_positionoptional
lp_mint
base_mint
quote_mint
orderwritablePDA ["protection_order", owner, args.args.order_id]
owner_lp_accountwritable
custody_lp_accountwritable
base_yield_accountwritable
quote_yield_accountwritable
ownerwritable · signer
dusk_event_authorityPDA ["__event_authority"]
dusk_program2rYBVfGu…o16Y
token_2022_programTokenzQd…xuEb
system_program11111111…1111

execute_hlp_order

Withdraw the escrowed shares to the target asset once the trigger holds, deducting the executor bounty and the protocol fee.

Caller
Any keeper
Discriminator
ba32b16ca8ca8ec9

Arguments

args: HlpOrderIdArgs

FieldTypeNotes
order_idu64

Accounts

AccountFlagsResolutionNotes
orderwritablePDA ["hlp_order", market, order.owner, order.target_hlp_mint, args.args.order_id]
marketwritable
futarchy_authority
base_mintwritable
quote_mintwritable
srlp_mintwritable
target_hlp_mintwritable
base_reserve_vaultwritable
quote_reserve_vaultwritable
borrowed_interest_vaultwritable
custody_target_accountwritable
custody_hlp_accountwritable
hlp_srlp_accountwritable
base_yield_accountwritable
quote_yield_accountwritable
owner_target_accountwritable
executor_target_accountwritable
executorsigner
order_ownerwritable
dusk_event_authorityPDA ["__event_authority"]
dusk_program2rYBVfGu…o16Y
protocol_fee.fee_recipientwritable
token_programTokenkeg…Q5DA
token_2022_programTokenzQd…xuEb

execute_leverage_entry_order

Fill an entry order whose price condition holds, opening the position for its owner.

Caller
Any keeper
Discriminator
63433961cc47ac90

Arguments

args: LeverageEntryOrderIdArgs

FieldTypeNotes
order_idu64
min_owner_refund_outu64Minimum amount actually credited to the owner on cancel or execution. Zero keeps cancellation available when transfer fees consume escrow.

Accounts

AccountFlagsResolutionNotes
orderwritablePDA ["leverage_entry_order", market, order.owner, args.args.order_id]
marketwritable
futarchy_authority
ownerwritable
leverage_positionwritable
debt_mintwritable
collateral_mint
debt_reserve_vaultwritable
collateral_reserve_vaultwritable
leverage_collateral_vaultwritable
funding_vaultwritable
owner_refund_accountwritable
executor_bounty_accountwritable
referral_partneroptional
referral_accrualoptional
instructions_sysvarSysvar1n…1111
executorwritable · signer
dusk_event_authorityPDA ["__event_authority"]
dusk_program2rYBVfGu…o16Y
protocol_fee.fee_recipientwritable
token_programTokenkeg…Q5DA
token_2022_programTokenzQd…xuEb
system_program11111111…1111

execute_protection_order

Use escrowed LP shares to repay an unhealthy position, then pay the keeper and protocol fees within the owner's limits.

Caller
Any keeper
Discriminator
f3c130e0ada18157

Arguments

args: ExecuteProtectionOrderArgs

FieldTypeNotes
lp_amountu64
payment_amountu64Maximum gross payment taken from the keeper's own token account.

Accounts

AccountFlagsResolutionNotes
orderwritablePDA ["protection_order", order.owner, order.order_id]
marketwritable
futarchy_authority
borrow_positionwritable · optional
leverage_positionwritable · optional
position_owner
base_mint
quote_mint
lp_mintwritable
srlp_mintwritable
base_reserve_vaultwritable
quote_reserve_vaultwritable
payment_vaultwritableNative repayment reserve or collateral donation vault, validated by Dusk.
debt_interest_vaultwritable
borrowed_interest_vaultwritable · optional
hlp_srlp_accountwritable · optional
custody_lp_accountwritable
custody_base_accountwritable
custody_quote_accountwritable
base_yield_accountwritable
quote_yield_accountwritable
owner_base_accountwritable
owner_quote_accountwritable
keeper_payment_accountwritable
referral_partneroptional
referral_accrualwritable · optional
keeperwritable · signer
dusk_event_authorityPDA ["__event_authority"]
dusk_program2rYBVfGu…o16Y
protocol_fee.fee_recipientwritable
token_programTokenkeg…Q5DA
token_2022_programTokenzQd…xuEb

fund_protection_order

Add owner-held LP shares to an existing protection order's escrow.

Caller
The order owner
In the app
Portfolio · Protection orders
Discriminator
8cf4782889a659b2

Arguments

args: FundProtectionOrderArgs

FieldTypeNotes
lp_amountu64

Accounts

AccountFlagsResolutionNotes
orderwritablePDA ["protection_order", owner, order.order_id]
lp_mint
custody_lp_accountwritable
owner_lp_accountwritable
ownersigner
token_2022_programTokenzQd…xuEb

preview_protection_order

Read-only: calculate the linked position's health using the current market state and collateral mint.

Caller
Any client, by simulation
Discriminator
90d39074ff66fcef

Arguments

None.

Accounts

AccountFlagsResolutionNotes
order
market
borrow_positionoptional
leverage_positionoptional
collateral_mint

settle_hlp_order_yield

Pay yield that accrued to escrowed shares after the order left escrow.

Caller
Anyone
Discriminator
0168c10d0d09f397

Arguments

args: HlpOrderIdArgs

FieldTypeNotes
order_idu64

Accounts

AccountFlagsResolutionNotes
orderwritablePDA ["hlp_order", market, order.owner, order.target_hlp_mint, args.args.order_id]
marketwritable
futarchy_authorityPDA ["futarchy_authority"]
target_hlp_mint
custody_hlp_accountwritable
owner_hlp_accountwritable
base_mint
quote_mint
base_reserve_vaultwritable
quote_reserve_vaultwritable
base_interest_vaultwritable
quote_interest_vaultwritable
base_yield_accountwritable
quote_yield_accountwritable
owner_base_accountwritable
owner_quote_accountwritable
ownerwritable
dusk_event_authorityPDA ["__event_authority"]
dusk_program2rYBVfGu…o16Y
token_programTokenkeg…Q5DA
token_2022_programTokenzQd…xuEb

update_leverage_order

Change an order's trigger price or size.

Caller
The position owner
In the app
Portfolio · Orders
Discriminator
196565037de52ef2

Arguments

args: UpdateLeverageOrderArgs

FieldTypeNotes
order_idu64
kindu8
trigger_closeout_price_nadu64
close_bpsu16

Accounts

AccountFlagsResolutionNotes
market
leverage_position
orderwritablePDA ["leverage_order", leverage_position, owner, args.args.order_id]
ownerwritable · signer

Accounts

The delegate program reads several Dusk accounts (Market, LeveragePosition, LeverageDelegation, YieldAccount, the referral accounts and the FutarchyAuthority) and owns the three order accounts.

BorrowPosition

A public credit position: collateral on both sides, fixed debt shares per side, stored liquidation factors, referral bindings and fields left from the retired liquidation auction.

PDA seeds
"borrow_position_v2", market, position id
SDK helper
deriveBorrowPositionAddress
Discriminator
f38c148b20f37237
FieldTypeNotes
ownerpubkey
marketpubkey
position_idpubkey
base_collateralu64
quote_collateralu64
global_health_base_contribution_for_quote_debtu64
global_health_quote_contribution_for_base_debtu64
base_liquidation_cf_bpsu16
quote_liquidation_cf_bpsu16
base_referral_partnerpubkey
quote_referral_partnerpubkey
base_referral_interest_share_bpsu16
quote_referral_interest_share_bpsu16
fixed_base_sharesu128
fixed_quote_sharesu128
fixed_base_principalu64Original base borrowed by this position that has not been repaid or written off.
fixed_quote_principalu64Original quote borrowed by this position that has not been repaid or written off.
active_liquidation_sessionpubkey
auction_debt_assetu8
auction_start_timei64
auction_start_price_nadu64
auction_floor_price_nadu64
bumpu8

FutarchyAuthority

The protocol-level authority: revenue shares, recipients, referral share cap, auction configuration and the global reduce-only flag.

PDA seeds
"futarchy_authority"
SDK helper
deriveFutarchyAuthorityAddress
Discriminator
aff7a0b68c80d3e2
FieldTypeNotes
versionu8
authoritypubkey
recipientsRevenueRecipients
revenue_shareRevenueShare
max_referral_interest_share_bpsu16
revenue_distributionRevenueDistribution
protocol_auction_splitProtocolAuctionSplit
fee_auctionProtocolAuctionConfig
buyback_auctionProtocolAuctionConfig
global_reduce_onlybool
bumpu8
RevenueRecipients
FieldTypeNotes
futarchy_treasurypubkey
buybacks_vaultpubkey
team_treasurypubkey
RevenueShare
FieldTypeNotes
swap_bpsu16
interest_bpsu16Global markup added to base borrowing interest. Each market closes elapsed interest at its previous value before binding a changed markup.
RevenueDistribution
FieldTypeNotes
futarchy_treasury_bpsu16
buybacks_vault_bpsu16
team_treasury_bpsu16
ProtocolAuctionSplit
FieldTypeNotes
fee_auction_bpsu16
buyback_auction_bpsu16
ProtocolAuctionConfig
FieldTypeNotes
accepted_mintpubkey
recipientsProtocolAuctionRecipients
paramsProtocolAuctionParams
ProtocolAuctionRecipients
FieldTypeNotes
treasurypubkey
staking_vaultpubkey
treasury_bpsu16
staking_vault_bpsu16
ProtocolAuctionParams
FieldTypeNotes
start_multiplier_bpsu16
floor_multiplier_bpsu16
duration_slotsu64
max_reference_age_slotsu64

HlpOrder

An escrowed hLP stop-loss or stop-rate order: kind, status, shares, trigger and minimum output.

PDA seeds
"hlp_order", market, owner, target hLP mint, order id
Discriminator
a245440c2d0880d3
FieldTypeNotes
ownerpubkey
marketpubkey
target_hlp_mintpubkey
custody_hlp_accountpubkey
order_idu64
kindu8
statusu8
hlp_amountu64
trigger_nadu64
min_target_amount_outu64
bumpu8

LeverageDelegation

The delegate program allowed to act on a leverage position and the actions it may take.

PDA seeds
"leverage_delegation_v2", position
SDK helper
deriveLeverageDelegationAddress
Discriminator
313c1d17f3db10d6
FieldTypeNotes
ownerpubkey
marketpubkey
positionpubkey
debt_assetu8
delegated_programpubkey
approved_actionsu32
open_curve_revisionu64
bumpu8

LeverageEntryOrder

An escrowed limit entry: margin, executor bounty, multiplier, limit price, minimum collateral, expiry and optional referrer.

PDA seeds
"leverage_entry_order", market, owner, order id
Discriminator
30d28ac974aeed9f
FieldTypeNotes
ownerpubkey
marketpubkey
positionpubkey
position_idpubkey
debt_mintpubkey
collateral_mintpubkey
order_idu64
debt_assetu8
margin_amountu64Gross vault debit forwarded to Dusk as margin.
executor_bountyu64Minimum net credit paid to the successful executor.
multiplier_bpsu64
limit_price_nadu64
min_collateral_outu64
expiry_unix_timestampi64
referrerOption<pubkey>
bumpu8

LeverageOrder

A take-profit or stop-loss order on a delegated position: kind, trigger closeout price, size, and staged approval state.

PDA seeds
"leverage_order", position, owner, order id
Discriminator
e8a22d946a6a2584
FieldTypeNotes
ownerpubkey
marketpubkey
positionpubkey
open_curve_revisionu64
order_idu64
kindu8
trigger_closeout_price_nadu64
close_bpsu16
staged_marginu64
staged_collateral_amountu64
staged_remaining_collateral_amountu64
staged_remaining_debt_sharesu128
staged_remaining_debt_principalu128
staged_owner_token_accountpubkey
staged_owner_balanceu64
staged_fee_recipientpubkey
staged_fee_balanceu64
staged_executor_token_accountpubkey
staged_executor_balanceu64
staged_output_mintpubkey
staged_output_amountu64
staged_protocol_fee_debitu64
staged_protocol_fee_creditu64
staged_executor_creditu64
staged_execution_valueu64Executed collateral-sale value in debt tokens, before debt repayment.
bumpu8

LeveragePosition

An isolated leverage position: debt asset, collateral, margin, notional, debt shares, multiplier and timestamps.

PDA seeds
"leverage_position_v2", market, position id
SDK helper
deriveLeveragePositionAddress
Discriminator
584e7c44e48122fb
FieldTypeNotes
ownerpubkey
marketpubkey
namespace_authoritypubkeyFunding signer that established this position. Ordinary opens use the owner; sponsored entry orders use their owner-created order PDA.
position_idpubkey
referral_partnerpubkey
referral_interest_share_bpsu16
debt_assetu8
collateral_amountu64
margin_termsLeverageMarginTerms
margin_amountu64Entry equity valued in debt-token atoms.
open_notionalu64
debt_principalu128
debt_sharesu128
multiplier_bpsu64
opened_ati64
opened_slotu64
open_curve_revisionu64Market curve revision committed by this opening. A recreated PDA gets a new revision even if it reopens in the same slot.
active_liquidation_sessionpubkey
close_approvalCloseApprovalQuote
bumpu8
LeverageMarginTerms
FieldTypeNotes
reference_collateralu64
maintenance_boundaries_bps[u16; 2]
maintenance_rates_bps[u16; 3]
entry_buffer_bpsu16
admission_equity_collateral_nadu128Collateral atoms times NAD, not a fixed debt-token or dollar amount. Retained on equity extraction; released proportionally on size reduction.
CloseApprovalQuote
FieldTypeNotes
slotu64
close_bpsu16
collateral_creditu64
selected_outputu64
full_outputu64

Market

One market: configuration, curve state, both sides' reserves and fee liabilities, debt indexes, the two hLP vaults, risk observations, oracle policy, tranche capital and policy, the active jrLP mint, the income books, operator/manager authority and parameter revisions and the reduce-only flag.

PDA seeds
"market_v2", base mint, quote mint, params hash
SDK helper
deriveMarketAddress
Discriminator
dbbed53700e3c69a
FieldTypeNotes
oracleOracleState
versionu8
srlp_mintpubkey
base_sideMarketSide
quote_sideMarketSide
configMarketConfig
ammAmmState
debtDebt
tranchesTrancheCapitalOne shared junior capital budget across both reserve/debt books.
incomeMarketIncomeBooks
junior_exit_configJuniorExitConfig
tranche_policyTranchePolicy
junior_mintpubkey
base_hlp_vaultHlpVault
quote_hlp_vaultHlpVault
riskRisk
params_hash[u8; 32]
initial_liquidity_authoritypubkeyOne-shot signer allowed to provide the first fully-backed Base/Quote seed. It is cleared permanently once srLP supply becomes nonzero.
operatorOperatorStateSole per-market authority; token ownership carries no configuration rights.
protocol_interest_markup_bpsu16Internal mirror of the global FutarchyAuthority markup, never an operator parameter.
parameter_revisions[u64; 7]Independent monotone revisions for fee, concentration, IRM, EMA, daily-borrow-limit, center-controller, and tranche parameter families.
last_marginal_observation_nadu64Latest trader-visible marginal price committed by a curve mutation.
curve_revisionu64Monotone revision for executable-curve mutations.
risk_revisionu64Curve revision represented by the materialized lending-risk snapshot.
last_update_slotu64
reduce_onlybool
bumpu8
OracleState
FieldTypeNotes
policyOraclePolicy
last_observationOracleObservation
revisionu64
recognized_tail_liquidityu128Recognized native-tail depth cannot grow merely because an OP trade moves to a different native invariant. Real ordinary LP capital scales the ceiling through its share supply; losses reduce it immediately.
recognized_ordinary_supplyu64
runtimeRuntimePricing
OraclePolicy
FieldTypeNotes
formatu8
providerpubkey
base_accountpubkey
quote_accountpubkey
base_feed_id[u8; 32]
quote_feed_id[u8; 32]
lambda_bpsu16
adjustment_cap_nadu64
max_age_secondsu32
max_age_slotsu64
max_confidence_bpsu16
max_publish_skew_secondsu32
OracleObservation
FieldTypeNotes
price_nadu64
confidence_nadu64
publish_timei64
posted_slotu64
sequenceu64
hash[u8; 32]
source_times[i64; 2]
source_slots[u64; 2]
source_sequences[u64; 2]Independent counters retain replay protection when only one leg updates.
source_hashes[[u8; 32]; 2]Each normalized report is immutable at an already observed counter.
RuntimePricing
FieldTypeNotes
MarketSide
FieldTypeNotes
asset_mintpubkey
asset_decimalsu8
hlp_mintpubkey
reserve_vaultpubkey
collateral_vaultpubkey
interest_vaultpubkey
reservesReserves
sharesReserveShares
feesFees
daily_borrow_bucketDailyBorrowBucket
Reserves
FieldTypeNotes
flash_receivableu64Same-transaction collateral receivable. Included in backing, excluded from cash available to swaps, loans and withdrawals.
live_reserveu128Wider than SPL custody: includes cash, indexed public debt and synthetic hLP backing. Unpaid interest never becomes executable curve inventory.
cash_reserveu64
base_hlp_backing_inventoryu64Physical reserve-vault atoms removed from executable AMM inventory by base-hLP deleveraging. They are conservation-only bookkeeping, excluded from hLP NAV and exit output, and return to executable cash pro rata as base hLP exits.
quote_hlp_backing_inventoryu64Quote-hLP counterpart of `base_hlp_backing_inventory`; never a second hLP NAV or withdrawal claim.
protected_recenter_reserveu64Physical reserve-vault atoms retained from toxicity surcharge for a future protected recenter. They are custody-backed but excluded from executable cash/live reserves, srLP NAV, and every withdrawal claim.
ReserveShares
FieldTypeNotes
srlp_supplyu64
Fees
FieldTypeNotes
juniorTrancheIncome
public_interest_advancePublicInterestAdvance
swap_fee_growth_index_q64u128
interest_growth_index_q64u128
swap_fee_growth_remainder_scaledu64Scaled fee entitlement not yet representable by the integer growth index. The corresponding whole-token backing already sits in `swap_fee_liability`; it must never be redistributed as unallocated revenue.
interest_growth_remainder_scaledu64Interest counterpart of `swap_fee_growth_remainder_scaled`.
hlp_funding_interest_growth_remainder_scaledu64Source-scoped Q64 carry for interest paid by hLP funding debt. Funding uses a non-hLP denominator, while public interest uses total srLP supply; sharing one carry across those denominators would eventually leak rounding entitlement between the two populations.
swap_fee_custody_balanceu64Claimable swap fees physically held in the reserve vault but excluded from executable cash and live reserves.
interest_vault_balanceu64
swap_fee_liabilityu64
interest_liabilityu64
unallocated_swap_fee_liabilityu64
unallocated_interest_liabilityu64
swap_protocol_fee_liabilityu64
swap_buyback_fee_liabilityu64
interest_protocol_fee_liabilityu64
interest_buyback_fee_liabilityu64
referral_interest_liabilityu64
revenue_interest_liabilityu64Shared custody for operator claims and protocol fractional carry.
fee_auction_reference_marketpubkeyGovernance-approved reference market for fee-lane auctions. A default key permits only the sold market itself when it directly pairs the sold and accepted mints.
buyback_auction_reference_marketpubkeyGovernance-approved reference market for buyback-lane auctions. A default key has the same direct-market-only meaning as above.
fee_swap_auction_epochProtocolAuctionEpoch
fee_interest_auction_epochProtocolAuctionEpoch
buyback_swap_auction_epochProtocolAuctionEpoch
buyback_interest_auction_epochProtocolAuctionEpoch
DailyBorrowBucket
FieldTypeNotes
borrowed_bucketu64Gross principal lent out through the public borrow path. Internal hLP funding and isolated leverage do not consume this capacity. This is a 24-hour leaky/token bucket, not an exact trailing-window sum: it permits a full burst after idle and then refills at the configured daily rate.
last_decay_slotu64
decay_remainder_msu64Numerator remainder from `limit * elapsed_ms / MS_PER_DAY`. For a fixed absolute limit, carrying it makes refill independent of how often the bucket is checkpointed. The bps-derived absolute limit can still move when conservative market depth changes.
MarketConfig
FieldTypeNotes
swap_fee_bpsu16
divergence_fee_share_cap_bpsu16
volatility_fee_share_cap_bpsu16
target_hlp_leverage_bpsu16
settlement_divergence_bpsu16
ema_half_life_msu64
directional_ema_half_life_msu64
curve_depth_ema_half_life_msu64
max_daily_borrow_bpsu16
global_health_contribution_cap_bpsu16
borrow_market_health_floor_bpsu16
ammAmmConfig
irmRiskRateConfig
start_timei64
AmmConfig
FieldTypeNotes
peak_amplification_nadu64
core_half_width_bpsu16
fade_width_bpsu16
center_ema_half_life_msu64
volatility_half_life_msu64
adjustment_step_nadu64
volatility_shock_cap_nadu64
volatility_cap_nadu64
divergence_fee_coefficient_nadu64
volatility_fee_coefficient_nadu64
swap_fee_collect_modeu8Asset in which swap, toxicity, volatility, and retained-recenter fees are denominated. Lending and hLP funding interest remain in the borrowed asset and are not affected by this setting.
compounding_fee_bpsu16Share of the LP-owned swap fee which becomes ordinary reserve principal instead of a claimable fee liability. Zero disables native compounding; `BPS_DENOMINATOR` compounds the complete LP share.
launch_fee_start_bpsu16Optional launch-only base fee. The premium above `swap_fee_bps` decays from `start_time` and is zero after the configured duration.
launch_fee_duration_secondsu64
launch_fee_decay_modeu8
launch_market_price_step_bpsu16When all three values are zero, the launch fee follows the time schedule above. A fully nonzero tuple selects a price-milestone scheduler whose reference price is bound by the first liquidity seed.
launch_market_number_of_periodsu16
launch_market_reduction_factor_bpsu16
launch_rate_limit_assetu8Optional launch buy-size limiter. The configured asset is the asset being bought, not the input asset. Each full/partial reference amount after the first adds `launch_rate_limit_increment_bps`, capped by `launch_rate_limit_max_fee_bps`.
launch_rate_limit_reference_nadu64
launch_rate_limit_increment_bpsu16
launch_rate_limit_max_fee_bpsu16
launch_rate_limit_duration_secondsu64
reserved[u8; 0]
RiskRateConfig
FieldTypeNotes
lower_signal_nadu64
upper_signal_nadu64
lower_utilization_bpsu16
upper_utilization_bpsu16
half_life_msu64
initial_apr_nadu64
AmmState
FieldTypeNotes
initializedbool
concentration_rampConcentrationRamp
concentrated_curve_cacheConcentratedCurveCacheConcentrated CPMM-tail/band geometry. CPMM is represented by zero concentrated liquidity in this same cache.
center_price_nadu64
price_ema_nadu64
last_trade_price_nadu64
last_observation_slotu64
last_adjustment_slotu64
launch_reference_price_nadu64Immutable launch price reference bound by the first fully-backed liquidity seed. Zero is allowed only before that seed.
launch_fee_progress_offsetu16Fee-schedule progress already completed by a bootstrap adapter before the market graduates into GAMM.
volatility_accumulator_nadu64
curve_depth_per_share_nadu128
protected_floor_per_share_nadu128srLP principal floor protected from funded recenter/ramp impairment.
retention_required_nadu128Fresh protected-profit target that arms retained surcharge routing. This is a principal-budget target, never a cap on trader fees.
retention_stop_nadu128Hysteresis threshold below which retention remains armed.
retention_hard_cap_nadu128Maximum protected principal one controller target may request/spend. It does not clip divergence or volatility surcharge amounts.
retain_dynamic_surchargeboolWhen true, dynamic surcharge is locked in the non-quoteable protected recenter bucket; when false, the identical trader charge is routed to claimable srLP fee accounting.
retention_target_saturatedboolThe requested protection target exceeded its principal-budget cap.
retention_target_staleboolThe protected bucket changed after the last exact forward-target solve. While stale, retention stays on until a decision point refreshes the target or executes a funded recenter.
deferred_controller_targetDeferredControllerTargetExact unfunded controller target retried by later real operations.
frozen_hlp_masku8A distressed hLP cannot be reconstructed as positive one-sided equity. Each bit freezes only that vault's share/debt hedge during swaps.
frozen_base_vault_base_offset_nadi128Fixed virtual-coordinate adjustment captured when the vault freezes. It preserves the pre-freeze executable price without treating the vault's negative equity as spendable token inventory.
frozen_base_vault_quote_offset_nadi128
frozen_quote_vault_base_offset_nadi128
frozen_quote_vault_quote_offset_nadi128
_reserved[u8; 0]
ConcentrationRamp
FieldTypeNotes
activebool
startConcentratedCurveParameters
targetConcentratedCurveParameters
start_slotu64
end_slotu64
last_attempt_slotu64Successful or rejected steps are attempted at most once per slot.
ConcentratedCurveCache
FieldTypeNotes
math_revisionu8
peak_amplification_nadu64
core_half_width_bpsu16
fade_width_bpsu16
tail_liquidityu128
concentrated_liquidityu128
core_lower_sqrt_price_nadu128
core_upper_sqrt_price_nadu128
outer_lower_sqrt_price_nadu128
outer_upper_sqrt_price_nadu128
DeferredControllerTarget
FieldTypeNotes
kindu80 = none, 2 = center move.
center_price_nadu64
required_nadu128
evaluated_base_reserve_nadu128
evaluated_quote_reserve_nadu128
created_slotu64
saturatedbool
Debt
FieldTypeNotes
fixed_base_sharesu128
fixed_quote_sharesu128
base_borrow_index_nadu128
quote_borrow_index_nadu128
base_borrow_index_remainderu128Fractional index growth carried across checkpoints. Denominator is `NAD * MS_PER_YEAR`, so frequent checkpoints cannot discard interest.
quote_borrow_index_remainderu128
base_borrow_apr_nadu128
quote_borrow_apr_nadu128
base_borrow_apr_fraction_e18u64Fractional NAD APR carried by the exponential controller (scale 1e9).
quote_borrow_apr_fraction_e18u64
global_health_base_contribution_for_quote_debtu64
global_health_quote_contribution_for_base_debtu64
base_last_accrual_slotu64
quote_last_accrual_slotu64
fixed_base_principalu64Aggregate outstanding *principal* (borrowed token amount, excluding accrued interest) backing fixed margin debt on each side. Accrued interest is `fixed_*_debt - fixed_*_principal`; tracked so interest can be routed to the interest vault (non-compounding) instead of compounding into reserves. Principal is a raw token-atom balance and is therefore bounded by the corresponding `u64` reserve custody domain.
fixed_quote_principalu64
isolated_base_sharesu128Aggregate isolated leverage debt. This debt contributes to utilization and interest, but is intentionally not utilized as normal margin debt. Shares remain `u128`; raw principal remains in the token account's `u64` amount domain.
isolated_quote_sharesu128
isolated_base_principalu64
isolated_quote_principalu64
leverage_base_collateralu64Gross collateral atoms in debt-bearing leverage positions. Counts all owners and namespaces; custody donations cannot create exposure credit.
leverage_quote_collateralu64
TrancheCapital
FieldTypeNotes
junior_reserve_sharesu64
junior_receipt_supplyu64
permanent_receiptsu64Funded, nonredeemable protocol receipts; included in junior supply.
queued_receiptsu64Escrow remains junior until a successful conversion or cancellation.
generationu64
MarketIncomeBooks
FieldTypeNotes
books[IncomeReceivableBook; 4]base public, quote public, base hLP funding, quote hLP funding.
revenue[InterestRevenueBook; 4]
pending[u64; 4]Gross settlement budget awaiting measured net custody credit.
seed[IncomeReceivableClaim; 4]
hlp[[IncomeReceivableClaim; 2]; 2][hLP target][income asset], owned by the vault rather than its holders.
junior_end[IncomeExposureEnd; 4]
split_carry_bps[u16; 4]
IncomeReceivableBook
FieldTypeNotes
epochu64
unpaidu64
unitsu64
paid_per_unit_q64u128
paid_remainderu64
growth[ReceivableGrowth; 4]Ordinary senior, junior, base hLP, quote hLP.
InterestRevenueBook
FieldTypeNotes
gross_unpaidu64
protocol_unpaidu64
operator_unpaidu64
pending_grossu64
pending_protocol_grossu64
operator_claimableu64
protocol_fraction_q64u64
operator_fraction_q64u64
protocol_cash_fraction_q64u64
IncomeReceivableClaim
FieldTypeNotes
epochu64
units_q64u128
paid_checkpoint_q64u128
growth_checkpointReceivableGrowth
paid_fraction_q128u128
claimableu64
IncomeExposureEnd
FieldTypeNotes
endedbool
epochu64
growthReceivableGrowth
JuniorExitConfig
FieldTypeNotes
minimum_notice_slotsu64
maximum_notice_slotsu64
exercise_window_slotsu64
TranchePolicy
FieldTypeNotes
junior_income_share_bpsu16
HlpVault
FieldTypeNotes
flash_collateral_debitu64Collateral committed to one atomic flash recovery. Receipt supply is fixed until settlement; retail operations on other positions may run.
srlp_vaultpubkey
srlp_sharesu64
base_hlp_live_reserveu64hLP-owned live reserve depth that is not backed by reserve cash or normal cash-backed debt. This is the explicit synthetic live component in `r_virtual = r_cash + r_cash_backed_debt + r_hlp_live`.
quote_hlp_live_reserveu64
debt_sharesu128Funding debt used by the hLP vault. It accrues interest and counts toward utilization, but is not same-side cash-backed reserve debt.
debt_principalu64Raw borrowed token atoms; products and indexed shares stay `u128`.
hlp_supplyu64
residual_exposurei128
base_swap_fee_growth_index_q64u128
base_interest_growth_index_q64u128
quote_swap_fee_growth_index_q64u128
quote_interest_growth_index_q64u128
base_swap_fee_checkpoint_q64u128
base_interest_checkpoint_q64u128
quote_swap_fee_checkpoint_q64u128
quote_interest_checkpoint_q64u128
base_swap_fee_remainder_q64u64Aggregate sub-atom srLP entitlement carried across hLP checkpoints. These are distinct from each holder YieldAccount remainder: this layer converts vault-owned srLP growth into hLP growth without double-flooring.
base_interest_remainder_q64u64
quote_swap_fee_remainder_q64u64
quote_interest_remainder_q64u64
base_swap_fee_growth_remainder_scaledu64Sub-index distribution carry for the second, srLP-to-hLP allocation layer. Whole-token backing represented here has already left the corresponding `unallocated_*` bucket.
base_interest_growth_remainder_scaledu64
quote_swap_fee_growth_remainder_scaledu64
quote_interest_growth_remainder_scaledu64
unallocated_base_swap_fee_amountu64
unallocated_base_interest_amountu64
unallocated_quote_swap_fee_amountu64
unallocated_quote_interest_amountu64
last_nav_nadu128
cached_settlement_price_nadu128Base quoted in quote NAD units for either target asset; zero means unset.
funding_apr_ema_nadu128Smoothed APR of the opposite asset borrowed by this target-asset hLP. The fixed twelve-hour half-life gives Stop Rate orders stable semantics.
funding_apr_ema_last_slotu64
Risk
FieldTypeNotes
base_price_ema_nadu64
quote_price_ema_nadu64
directional_base_price_ema_nadu64
directional_quote_price_ema_nadu64
cached_spot_base_price_nadu64
cached_spot_quote_price_nadu64
observed_curve_depth_nadu128Last observed total active curve depth in market amount units (see Market).
curve_depth_ema_nadu128EMA of total active curve depth in market amount units (see Market).
last_snapshot_slotu64
OperatorState
FieldTypeNotes
authoritypubkey
managerpubkeyOptional parameter delegate; operator ownership and revenue stay with authority.
epochu64
revenue_epochu64
next_nonceu64Monotone across authority transfers; a closed proposal PDA cannot be reused.
pendingpubkey
pending_authorpubkeyPrevents a manager from replacing an operator-authored bundle.
revenue_recipientpubkey
interest_share_bpsu16

ProtectionOrder

An owner-funded LP escrow and execution limits for restoring a borrow or leverage position's health.

PDA seeds
"protection_order", owner, order id
Discriminator
fd52005bb2d560b9
FieldTypeNotes
ownerpubkey
marketpubkey
positionpubkey
position_ownerpubkey
lp_mintpubkey
custody_lp_accountpubkey
order_idu64
actionu80: borrow repayment; 1: borrow collateral donation; 2: leverage repayment.
debt_assetu8
activebool
remaining_lpu64
max_lp_per_executionu64
max_payment_per_executionu64
trigger_health_bpsu64
target_health_bpsu64
min_payment_per_lp_nadu64Minimum gross payment per LP smallest unit, scaled by 1e9.
keeper_fee_bpsu16
expires_ati64
bumpu8

ReferralAccrual

A partner's claimable interest for one market and asset mint.

PDA seeds
"referral_accrual", partner, market, asset mint
SDK helper
deriveReferralAccrualAddress
Discriminator
23f61942aea03027
FieldTypeNotes
referral_partnerpubkey
marketpubkey
asset_mintpubkey
amountu64
bumpu8

ReferralPartner

A listed referrer: its authority, recipient, interest share and active flag.

PDA seeds
"referral_partner", authority
SDK helper
deriveReferralPartnerAddress
Discriminator
ea36a99d8ebbe1d6
FieldTypeNotes
authoritypubkey
recipientpubkey
interest_share_bpsu16
activebool
bumpu8

YieldAccount

Per owner, market, LP mint, asset and kind: checkpoints against the growth indexes and income books, accrued amounts, jrLP held in an exit request, the recipient and an optional harvest authority.

PDA seeds
"yield", market, owner, LP mint, asset mint, kind
SDK helper
deriveYieldAccountAddress
Discriminator
e9f17706020e6a9c
FieldTypeNotes
ownerpubkey
marketpubkey
lp_mintpubkeyLP mint whose balance earns this account's revenue stream. This keeps base-hLP, quote-hLP, and srLP entitlements in disjoint PDA namespaces.
asset_mintpubkey
token_kindu8
recipientpubkey
swap_fee_checkpoint_q64u128
interest_checkpoint_q64u128
accrued_swap_fee_amountu64
accrued_interest_amountu64
swap_fee_remainder_q64u64Sub-token fixed-point entitlement carried across checkpoints. Keeping this remainder prevents transfer/checkpoint frequency from destroying holder yield through repeated flooring.
interest_remainder_q64u64
bumpu8
harvest_authorityOption<pubkey>Optional caller allowed to harvest to the recipient without controlling the LP or changing either yield permission. Only the owner may set it.
income_initializedbool
income[IncomeReceivableClaim; 2]
escrow_balanceu64Owner's junior exit escrow receipts. Historical unpaid-income ownership is checkpointed here alongside the liquid balance.
IncomeReceivableClaim
FieldTypeNotes
epochu64
units_q64u128
paid_checkpoint_q64u128
growth_checkpointReceivableGrowth
paid_fraction_q128u128
claimableu64
ReceivableGrowth
FieldTypeNotes
units_q64u128
weighted_paid_q128[u64; 4]

Errors

Leverage delegate program errors · 6 of 6

CodeNameMessage
6000InvalidOrderInvalid leverage order
6001TriggerNotMetOrder trigger is not met
6002InvalidTokenAccountInvalid token account
6003MathOverflowMath overflow
6004ApprovalSerializationFailedApproval serialization failed
6005InvalidMarketVersionUnsupported Dusk market version