diff --git a/crates/core/src/scenarios/README.md b/crates/core/src/scenarios/README.md index 04d18df3d..6a677f8f2 100644 --- a/crates/core/src/scenarios/README.md +++ b/crates/core/src/scenarios/README.md @@ -17,6 +17,7 @@ Protocols that are natively supported by Surfpool will have their IDLs included - **Jupiter v6** - DEX aggregator with TokenLedger manipulation template - **Switchboard On-Demand** - On-demand oracle with QuoteAccount override template - **Kamino** – Lending (v1.23.0), Scope oracle, Farms, Swap/LIMO, Earn vaults and Liquidity, across six programs. See [protocols/kamino/README.md](./protocols/kamino/README.md) +- **Project 0** – Lending (marginfi v2, v0.1.12): bank risk, limits, oracle and share settings, and account positions. See [protocols/project0/README.md](./protocols/project0/README.md) - **Drift v2** - Perp and spot markets, user state, and global state - **Pump v1** - Bonding curve launchpad with curve reserve and global config override templates - **Phoenix Eternal** - Perpetuals venue with trader collateral, mark price, maintenance margin, market fee, withdraw limit, trader capability, stop-loss trigger and delegated permission templates. See [protocols/phoenix-eternal/README.md](./protocols/phoenix-eternal/README.md) @@ -52,6 +53,13 @@ accounts from mainnet, so they need a network connection and are compiled only b cargo test -p surfpool-core --features integration-tests kamino ``` +Project 0 has the same kind of suite in `crates/core/src/tests/protocols/project0/`, plus a test +that runs the deployed program over overridden state: + +``` +cargo test -p surfpool-core --features integration-tests tests::protocols::project0 +``` + Set `SURFPOOL_TEST_RPC_URL` to use a private endpoint instead of the public one. The default test run needs no network. diff --git a/crates/core/src/scenarios/protocols/project0/README.md b/crates/core/src/scenarios/protocols/project0/README.md new file mode 100644 index 000000000..95d6590af --- /dev/null +++ b/crates/core/src/scenarios/protocols/project0/README.md @@ -0,0 +1,236 @@ +# Project 0 + +Surfpool bundles the IDL and override templates for **Project 0**, the lending program formerly +known as marginfi v2 (`MFv2hWf31Z9kbCa1snEPYctwafyhdvnV7FZnsebVacA`, v0.1.12), so a scenario can +put a bank or a user account into whatever state you need before your code runs against it. + +The bundled IDL is the program's published 0.1.12 IDL with one change: `address`, empty in the +published IDL, holds the program's address. Surfpool registers each bundled IDL under its +`address` and cannot load one without it. + +| IDL | Source | sha256 | +|---|---|---| +| Published | Program Metadata account `B66dYmjB9pJ3unjp3QMiEpySb8i44Zhev3qaYj5SfLPG` | `f621c9e4eb789084b088dbd61e5e086224546934b6f0859caea837241501d79f` | +| Bundled | `v1/idl.json` | `6b1adb134a6a8ff0a1450bfdf3b26aedc211a2e69f046e08dd6415091bb802de` | + +This is a how-to. For how scenarios work in general see the [scenarios README](../../README.md). +Every field's own purpose and units are on the template itself, visible in Studio and via +`get_override_templates`. + +## Override inputs, not results + +Project 0 recomputes an account's health on every borrow, withdraw and liquidation, from the +account's shares, the banks' share values and weights, and the live oracle price. The account's +`health_cache` and a bank's `cache` are outputs written along the way; nothing reads them back. + +| Want to change | Override this | Not this | +|---|---|---| +| A price | the bank's Pyth feed with `pyth-core-compatible-price-feed-v2` (see [Move a price](#move-a-price)) | `cache.last_oracle_price` | +| Position health | `project0-bank-risk-weights` → `config.asset_weight_maint.value` | `health_cache` | +| A position | `project0-account-balance` | | + +## Number formats + +| You'll see | It means | Example | +|---|---|---| +| `.value` of a weight, share, share value or reference price | an I80F48 number: the 16 little-endian bytes of value x 2^48. Studio shows and takes a decimal | 1.0 → `[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]` | +| Shares | tokens / share value | 10 SOL at share value 1.0 → 10000000000, `[0, 0, 0, 0, 0, 0, 0, 228, 11, 84, 2, 0, 0, 0, 0, 0]` | +| Interest rates | out of 1000% as u32 | 100% APR → `429496729` | +| Utilization | out of 100% as u32 | 50% → `2147483647` | +| Token amounts, limits | the mint's smallest unit | 1 USDC → `1000000` | +| `operational_state` | a variant name | `"ReduceOnly"` | + +## Picking a bank + +Every template takes the account it writes; callers are responsible for passing a Bank or a +MarginfiAccount. Symbols repeat: the main group (`4qp6Fx6tnZkY5Wropq9wUYgtFxXKwE6viZxFHg3rdAG8`) +holds native banks and Kamino-, Drift- or JupLend-wrapped banks of the same mint, so key +everything by address. + +A token's native bank and the price account it reads come from one `getProgramAccounts` call on +the program: filter on the Bank discriminator at offset 0 (`QnTef4UXSzF` in base58), the group at +offset 41, the mint at offset 8 and an oracle setup byte of 3 at offset 609 (a Pyth push oracle), +with a `dataSlice` of 32 bytes at offset 610 (`config.oracle_keys.0`). The templates' +`llm_context` spells the call out. A wallet's accounts are the program's MarginfiAccounts +(discriminator `CKkRR4La3xu` at offset 0) with the group at offset 8 and the authority at offset 40. +Filter on the discriminator rather than the account size, which program upgrades change. + +For example, the native SOL bank is `CCKtUs6Cgwo4aaQUmBPmyoApH2gUDErxNZCAntD6LYGh` (asset tag 1) +and reads `7AviUf9nL62mcxNbQGKm4nKDQnPjswo6c5MX4D57HmyE`; the native USDC bank is +`2s37akK2eyBbp8DZgCm7RtsaEz8eJP3Nxd4urLHQv7yB` (asset tag 0) and reads +`6HAuqASbHEh4w4REJEUUUCginTLfj1kwCh215ZLtMkrT`. + +--- + +# Recipes + +## Make a position liquidatable + +``` +project0-bank-risk-weights on the SOL bank + config.asset_weight_maint.value: [205, 204, 204, 204, 204, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # 0.3 + config.asset_weight_init.value: [205, 204, 204, 204, 204, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # 0.3 +``` + +**Why:** health is `sum(deposits x asset_weight_maint) - sum(debts x liability_weight_maint)`, +recomputed from the bank on every check. Tested against the deployed program: a SOL-backed USDC +borrow goes from healthy to liquidatable. + +## Move a price + +Project 0 banks read Pyth `PriceUpdateV2` accounts of the Pyth Core Compatible receiver, +`rec2HHDDnjLfj4kE7VyEtFA1HPGQLK33259532cRyHp`. Use `pyth-core-compatible-price-feed-v2` on the account the +bank names at `config.oracle_keys.0`: + +``` +project0-bank-oracle on the SOL bank, fetchBeforeUse: true + cb_reference_price.value: [0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0] # $20 + cb_window_reference_price.value: [0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0] +pyth-core-compatible-price-feed-v2 on the bank's config.oracle_keys.0, fetchBeforeUse: true + price_message.price: 2000000000 # $20, exponent -8 + price_message.ema_price: 2000000000 + price_message.conf: + price_message.ema_conf: +``` + +**Why:** the price must be fresh: `clock - publish_time <= config.oracle_max_age`. Keep-alive +keeps the overridden price published, and the other banks' prices need an override each, see +[Prices on a fork](#prices-on-a-fork). +Borrow and withdraw checks use the EMA price, liquidation the spot price, so move both. +Scale `conf` and `ema_conf` by the same factor: Project 0 multiplies the confidence by 2.12 and +refuses a price whose result is over the bank's `config.oracle_max_confidence` share of it (10% +when the field is 0), so a crash that keeps the live confidence can be refused. +Tested against the deployed program: SOL at $20 turns a healthy SOL-backed USDC borrow +liquidatable. + +**Most banks have a price circuit breaker**, among them the stablecoins, SOL and its liquid staking +tokens, BTC and ETH. It is on when the bank's `flags` include `2048` (bit 11). Once the price, net +of the oracle's confidence, is `config.cb_deviation_bps_tiers[0]` basis points (50 for USDC, 600 +for SOL) away from the bank's `cb_reference_price`, borrow, withdraw and liquidation fail with +`CircuitBreakerPriceJump` (6604). The confidence counts 2.12 times, so at a typical USDC +confidence the 50 bps take about a 0.7% move. Read the bank to see its flags and tiers, and move +both references by the same factor as the price. They hold the price the bank computes, which for +liquid staking tokens includes the exchange rate, so scale the bank's current values; on SOL and +USDC they are the price in dollars, as above for SOL and here for USDC: + +``` +project0-bank-oracle on the USDC bank, fetchBeforeUse: true + cb_reference_price.value: [51, 51, 51, 51, 51, 243, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # $0.95 + cb_window_reference_price.value: [51, 51, 51, 51, 51, 243, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] +pyth-core-compatible-price-feed-v2 on the bank's config.oracle_keys.0, fetchBeforeUse: true + price_message.price: 95000000 # $0.95, exponent -8 + price_message.ema_price: 95000000 + price_message.conf: + price_message.ema_conf: +``` + +The breaker then treats $0.95 as normal and still guards further moves, as after a slow move it +has adapted to. That is the default: it keeps the breaker on and tests the protocol as deployed. + +The other way is to change the breaker's own thresholds on the bank with the same template: the +three `config.cb_deviation_bps_tiers` entries and the `config.cb_window_max_up_bps` / +`config.cb_window_max_down_bps` caps. Use it to test the breaker itself, with a price just under +or just over the first tier, or to model the admin loosening it. Raising the first tier alone is +not enough: a borrow or withdrawal still checks the higher tiers and the 24h caps and can halt the +bank (`BankCircuitBreakerHalted`, 6600). All five at `10000` let any move through. The breaker's +own off switch is bit 11 of `flags`, which these templates do not write. + +## Build a position from scratch + +On an account whose other slots are empty (`active` 0, `bank_pk` `11111111111111111111111111111111`, +zero shares; clear them first on an account in use): + +``` +project0-account-balance + lending_account.balances.0.active: 1 + lending_account.balances.0.bank_pk: + lending_account.balances.0.bank_asset_tag: 1 + lending_account.balances.0.asset_shares.value: [0, 0, 0, 0, 0, 0, 0, 228, 11, 84, 2, 0, 0, 0, 0, 0] + lending_account.balances.0.liability_shares.value: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] +project0-account-balance + lending_account.balances.1.active: 1 + lending_account.balances.1.bank_pk: + lending_account.balances.1.bank_asset_tag: 0 + lending_account.balances.1.asset_shares.value: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + lending_account.balances.1.liability_shares.value: [0, 0, 0, 0, 0, 0, 0, 101, 205, 29, 0, 0, 0, 0, 0, 0] +``` + +**Why:** slots stay sorted by `bank_pk`, highest first, so SOL's bank goes before USDC's, and +`bank_asset_tag` must match the bank's `config.asset_tag`. The shares above are 10 SOL +(10000000000) and 500 USDC (500000000) at a share value of 1.0; divide by each bank's current +share value. The template lists +the other rules. + +## Take over a real account + +``` +project0-account-authority authority: +``` + +## Age every loan in a bank + +``` +project0-bank-shares liability_share_value.value: +``` + +**Why:** a debt is `liability_shares x liability_share_value`. Raise `asset_share_value` too if +depositors should earn, and keep the vault balance in line (see Troubleshooting). + +## Block an action to test the rejection + +``` +project0-bank-status config.operational_state: "ReduceOnly" # no new deposits or borrows +project0-bank-limits config.borrow_limit: 1 # bank lent out +project0-bank-limits config.deposit_limit: 1 # bank full +``` + +--- + +## Prices on a fork + +Nothing publishes Pyth prices on a surfnet, so a bank refuses a price once the Surfnet clock is its +`config.oracle_max_age` seconds past the price's `publish_time`: + +- From the slot a `pyth-core-compatible-price-feed-v2` override plays until the network is reset, + keep-alive writes the Clock's time to the price account it writes, every slot, time travels + included. +- A health check or liquidation reads the price of every bank the account uses. Give each of those + banks' `config.oracle_keys.0` its own `pyth-core-compatible-price-feed-v2` override that sets only + `price_message.publish_time`. Any value works, because keep-alive rewrites it in the same slot. +- A price account with no override ages. To keep one price stale while the others stay fresh, leave + that bank's `config.oracle_keys.0` out of the overrides above. To let it age only later, give it + a later override with `"keepAlive": []` and a value, such as its current price. +- A bank priced by anything other than a Pyth Core Compatible feed is not kept alive. Raise its + `oracle_max_age` with `project0-bank-oracle`. + +# Troubleshooting + +| Rejection | Fix | +|---|---| +| Stale oracle | No `pyth-core-compatible-price-feed-v2` override writes that bank's price account, an override of it set `"keepAlive": []`, or the bank is not priced by a Pyth Core Compatible feed. Give the price account its own override, or raise that bank's `oracle_max_age` - see [Prices on a fork](#prices-on-a-fork) | +| `CircuitBreakerPriceJump` (6604) | The price moved past the bank's circuit breaker. Move the reference prices with it, see [Move a price](#move-a-price) | +| `BankCircuitBreakerHalted` (6600) | `lending_pool_pulse_bank_price_cache` ran during a breach and halted the bank. Refetch the bank with `fetchBeforeUse: true` and move its reference prices | +| The program panics in `accrue_interest` | The bank was loaded from upstream after the Surfnet clock stopped, so its `last_update` is ahead of the clock. Move the clock to the current time with `surfnet_timeTravel`: `[{"absoluteTimestamp": }]` | +| Your price override did nothing | Write the bank's `config.oracle_keys.0` with `pyth-core-compatible-price-feed-v2`. The Pyth Core receiver's account for the same feed (`pyth-price-feed-v2`) is a different address, which the bank never reads. See [Move a price](#move-a-price) | +| Wrong oracle account | Pass exactly the bank's `config.oracle_keys.0` | +| Withdraw fails on the token transfer | Shares imply more tokens than the bank's `liquidity_vault` holds. Raise the vault with `spl-token-account-balance` | +| `invalid value for idl type: expected vec, found string` or `expected array length of 16` | Pass a `.value` field as an array of 16 bytes, see [Number formats](#number-formats) | +| A Kamino-, Drift- or JupLend-wrapped bank rejects its price | Those need the venue account refreshed in the same transaction, which these templates do not cover | +| An earlier change to a bank or account is gone | A later override with `fetchBeforeUse: true` loaded the account from mainnet again, which drops every local change to it. Give later overrides of the same account `fetchBeforeUse: false` | + +--- + +# Template index + +**Project 0** · `MFv2hWf31Z9kbCa1snEPYctwafyhdvnV7FZnsebVacA` + +| Template | Overrides | +|---|---| +| `project0-bank-risk-weights` | the collateral and debt weights of a bank | +| `project0-bank-limits` | the deposit, borrow and collateral value caps of a bank | +| `project0-bank-status` | a bank's operational state (pause, reduce-only) | +| `project0-bank-oracle` | the oracle staleness, confidence and circuit breaker guards of a bank | +| `project0-bank-interest-rate` | the bank borrow-rate curve | +| `project0-bank-shares` | the total shares and share values of a bank | +| `project0-account-balance` | one balance slot of a MarginfiAccount | +| `project0-account-authority` | the authority of a MarginfiAccount | diff --git a/crates/core/src/scenarios/protocols/project0/v1/idl.json b/crates/core/src/scenarios/protocols/project0/v1/idl.json new file mode 100644 index 000000000..1abd100f0 --- /dev/null +++ b/crates/core/src/scenarios/protocols/project0/v1/idl.json @@ -0,0 +1,24012 @@ +{ + "address": "MFv2hWf31Z9kbCa1snEPYctwafyhdvnV7FZnsebVacA", + "metadata": { + "name": "marginfi", + "version": "0.1.12", + "spec": "0.1.0", + "description": "Borrow Lending Prime Broker" + }, + "instructions": [ + { + "name": "admin_close_account", + "docs": [ + "(permissionless) Close an account that is empty, inactive for >60 days, and has no", + "blocking state flags. Rent is returned to the group's global fee wallet." + ], + "discriminator": [ + 131, + 60, + 75, + 215, + 109, + 34, + 157, + 26 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "marginfi_account" + ] + }, + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "global_fee_wallet", + "writable": true + }, + { + "name": "rebalance_fee_pool", + "docs": [ + "`withdraw_rebalance_fee_pool`) before close so its lamports are not orphaned." + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 98, + 97, + 108, + 97, + 110, + 99, + 101, + 95, + 102, + 101, + 101, + 95, + 112, + 111, + 111, + 108 + ] + }, + { + "kind": "account", + "path": "marginfi_account" + } + ] + } + } + ], + "args": [] + }, + { + "name": "config_group_fee", + "docs": [ + "(global fee admin only) Enable or disable program fees for any group. Does not require the", + "group admin to sign: the global fee state admin can turn program fees on or off for any", + "group" + ], + "discriminator": [ + 231, + 205, + 66, + 242, + 220, + 87, + 145, + 38 + ], + "accounts": [ + { + "name": "marginfi_group", + "writable": true + }, + { + "name": "global_fee_admin", + "docs": [ + "`global_fee_admin` of the FeeState" + ], + "signer": true, + "relations": [ + "fee_state" + ] + }, + { + "name": "fee_state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "enable_program_fee", + "type": "bool" + } + ] + }, + { + "name": "configure_bank_rate_limits", + "docs": [ + "(admin or delegate_limit_admin) Configure bank-level rate limits for withdraw/borrow.", + "Rate limits track net outflow in native tokens. Deposits offset withdraws.", + "Set to 0 to disable. Hourly and daily windows are independent." + ], + "discriminator": [ + 175, + 84, + 85, + 221, + 206, + 220, + 110, + 174 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank" + ] + }, + { + "name": "admin", + "signer": true + }, + { + "name": "bank", + "writable": true + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "hourly_max_outflow", + "type": { + "option": "u64" + } + }, + { + "name": "daily_max_outflow", + "type": { + "option": "u64" + } + } + ] + }, + { + "name": "configure_deleverage_withdrawal_limit", + "docs": [ + "(admin or delegate_limit_admin) Set the daily withdrawal limit for deleverages per group." + ], + "discriminator": [ + 28, + 132, + 205, + 158, + 67, + 77, + 177, + 63 + ], + "accounts": [ + { + "name": "marginfi_group", + "writable": true + }, + { + "name": "admin", + "signer": true + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "limit", + "type": "u32" + } + ] + }, + { + "name": "configure_group_rate_limits", + "docs": [ + "(admin or delegate_limit_admin) Configure group-level rate limits for withdraw/borrow.", + "Rate limits track aggregate net outflow in USD.", + "Example: $10M = 10_000_000. Set to 0 to disable." + ], + "discriminator": [ + 111, + 47, + 213, + 142, + 158, + 51, + 226, + 102 + ], + "accounts": [ + { + "name": "marginfi_group", + "writable": true + }, + { + "name": "admin", + "signer": true + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "hourly_max_outflow_usd", + "type": { + "option": "u64" + } + }, + { + "name": "daily_max_outflow_usd", + "type": { + "option": "u64" + } + } + ] + }, + { + "name": "disable_staked_oracles", + "docs": [ + "(slow governance_admin only) Disable stake pricing, i.e. effectively forbidding all operations", + "involving stake banks.", + "To be used during the rollout of the SVSP upgrade.", + "To be removed once SVSP update is rolled out (likely in 1.10)" + ], + "discriminator": [ + 43, + 90, + 152, + 55, + 66, + 101, + 232, + 200 + ], + "accounts": [ + { + "name": "group" + }, + { + "name": "governance_admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "staked_settings", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 100, + 95, + 115, + 101, + 116, + 116, + 105, + 110, + 103, + 115 + ] + }, + { + "kind": "account", + "path": "group" + } + ] + } + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "drift_claim_bad_debt", + "docs": [ + "(permissionless) Claim a Drift bad-debt portal allocation for a Drift bank.", + "The merkle claimant is the bank's liquidity_vault_authority PDA, and claimed tokens are", + "swept to the global fee wallet's canonical ATA." + ], + "discriminator": [ + 163, + 67, + 144, + 231, + 119, + 20, + 220, + 33 + ], + "accounts": [ + { + "name": "payer", + "docs": [ + "Pays transaction fees, ATA creation, and ClaimStatus rent." + ], + "writable": true, + "signer": true + }, + { + "name": "bank" + }, + { + "name": "fee_state", + "docs": [ + "Global fee state containing the global_fee_wallet destination owner." + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "liquidity_vault_authority", + "docs": [ + "The bank's liquidity vault authority. This PDA is the claimant in Drift's merkle tree." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "integration_acc_2", + "docs": [ + "Drift user account owned by liquidity_vault_authority." + ], + "relations": [ + "bank" + ] + }, + { + "name": "integration_acc_3", + "docs": [ + "Drift user stats account owned by liquidity_vault_authority." + ], + "relations": [ + "bank" + ] + }, + { + "name": "distributor", + "writable": true + }, + { + "name": "claim_status", + "docs": [ + "program. The distributor initializes and validates this account." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 108, + 97, + 105, + 109, + 83, + 116, + 97, + 116, + 117, + 115 + ] + }, + { + "kind": "account", + "path": "liquidity_vault_authority" + }, + { + "kind": "account", + "path": "distributor" + } + ], + "program": { + "kind": "const", + "value": [ + 9, + 104, + 66, + 137, + 242, + 19, + 6, + 78, + 81, + 244, + 68, + 178, + 48, + 241, + 73, + 140, + 115, + 106, + 124, + 196, + 140, + 137, + 125, + 100, + 116, + 110, + 35, + 131, + 181, + 173, + 8, + 135 + ] + } + } + }, + { + "name": "from", + "docs": [ + "Distributor token vault." + ], + "writable": true + }, + { + "name": "claim_mint" + }, + { + "name": "global_fee_wallet" + }, + { + "name": "claimant_token_account", + "docs": [ + "Canonical ATA for the claim mint owned by liquidity_vault_authority." + ], + "writable": true + }, + { + "name": "destination_token_account", + "docs": [ + "Canonical ATA for the claim mint owned by FeeState.global_fee_wallet." + ], + "writable": true + }, + { + "name": "merkle_distributor_program", + "address": "distAitdwx9mDm3SaPMtGZRjpXMPUenLhmPwoySV3Hp" + }, + { + "name": "associated_token_program", + "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "proof", + "type": { + "vec": { + "array": [ + "u8", + 32 + ] + } + } + } + ] + }, + { + "name": "drift_deposit", + "docs": [ + "(user) Deposit into a Drift spot market through a marginfi account", + "* amount - in the underlying token (e.g., USDC), in native decimals" + ], + "discriminator": [ + 252, + 63, + 250, + 201, + 98, + 55, + 130, + 12 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "marginfi_account", + "bank" + ] + }, + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "bank", + "writable": true + }, + { + "name": "drift_oracle", + "docs": [ + "The oracle account for the asset (not needed if using oracle type QuoteAsset)" + ], + "optional": true + }, + { + "name": "liquidity_vault_authority", + "docs": [ + "The bank's liquidity vault authority, which owns the Drift user account" + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "liquidity_vault", + "docs": [ + "Used as an intermediary to deposit tokens into Drift" + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "signer_token_account", + "docs": [ + "Owned by authority, the source account for the token deposit" + ], + "writable": true + }, + { + "name": "drift_state", + "docs": [ + "The Drift state account" + ] + }, + { + "name": "integration_acc_2", + "docs": [ + "The Drift user account owned by liquidity_vault_authority" + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "integration_acc_3", + "docs": [ + "The Drift user stats account owned by liquidity_vault_authority" + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "integration_acc_1", + "docs": [ + "The Drift spot market for this asset" + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "drift_spot_market_vault", + "docs": [ + "The Drift spot market vault that will receive tokens" + ], + "writable": true + }, + { + "name": "mint", + "docs": [ + "Bank's liquidity token mint" + ], + "relations": [ + "bank" + ] + }, + { + "name": "drift_program", + "address": "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH" + }, + { + "name": "token_program" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "drift_harvest_reward", + "docs": [ + "(permissionless) Harvest rewards from admin deposits in Drift spot markets.", + "Rewards are always sent to the global fee wallet's canonical ATA.", + "The harvest spot market must be different from the bank's main drift spot market." + ], + "discriminator": [ + 167, + 161, + 240, + 194, + 138, + 54, + 87, + 189 + ], + "accounts": [ + { + "name": "bank" + }, + { + "name": "fee_state", + "docs": [ + "Global fee state that contains the global_fee_wallet" + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "liquidity_vault_authority", + "docs": [ + "The bank's liquidity vault authority" + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "intermediary_token_account", + "docs": [ + "To create this manually just send some of the reward token", + "to the liquidity vault authority address before claiming" + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "liquidity_vault_authority" + }, + { + "kind": "account", + "path": "token_program" + }, + { + "kind": "account", + "path": "reward_mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "destination_token_account", + "docs": [ + "Destination token account must be owned by the global fee wallet" + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "fee_state" + }, + { + "kind": "account", + "path": "token_program" + }, + { + "kind": "account", + "path": "reward_mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "drift_state", + "docs": [ + "Drift accounts" + ] + }, + { + "name": "integration_acc_2", + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "integration_acc_3", + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "harvest_drift_spot_market", + "docs": [ + "The harvest spot market - MUST be different from bank's Drift spot market (integration_acc_1)", + "This is the market that contains admin deposits to harvest" + ], + "writable": true + }, + { + "name": "harvest_drift_spot_market_vault", + "docs": [ + "The harvest spot market vault - derived from harvest_drift_spot_market" + ], + "writable": true + }, + { + "name": "drift_signer", + "docs": [ + "The Drift signer PDA" + ] + }, + { + "name": "reward_mint" + }, + { + "name": "drift_program", + "address": "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH" + }, + { + "name": "token_program" + } + ], + "args": [] + }, + { + "name": "drift_init_user", + "docs": [ + "(permissionless) Initialize a Drift user and user stats for a marginfi bank", + "Creates user with sub_account_id = 0 and empty name", + "Requires a minimum deposit to ensure the account remains active", + "* amount - minimum deposit amount (at least 10 units) in native decimals" + ], + "discriminator": [ + 29, + 18, + 236, + 190, + 29, + 254, + 114, + 169 + ], + "accounts": [ + { + "name": "fee_payer", + "docs": [ + "Pays to init the drift user and user stats accounts and provides initial deposit" + ], + "writable": true, + "signer": true + }, + { + "name": "signer_token_account", + "docs": [ + "The fee payer must provide a nominal amount of bank tokens so the account is not empty.", + "This amount is irrecoverable and will prevent the account from being closed." + ], + "writable": true + }, + { + "name": "bank" + }, + { + "name": "liquidity_vault_authority", + "docs": [ + "The liquidity vault authority (PDA that will own the Drift user)" + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "liquidity_vault", + "docs": [ + "Used as an intermediary to deposit a nominal amount of token into Drift." + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "mint", + "docs": [ + "Bank's liquidity token mint (e.g., USDC)" + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "integration_acc_3", + "docs": [ + "The user stats account to be created" + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114, + 95, + 115, + 116, + 97, + 116, + 115 + ] + }, + { + "kind": "account", + "path": "liquidity_vault_authority" + } + ], + "program": { + "kind": "const", + "value": [ + 9, + 84, + 219, + 190, + 158, + 201, + 96, + 201, + 138, + 122, + 41, + 63, + 226, + 19, + 54, + 150, + 111, + 225, + 128, + 209, + 81, + 174, + 75, + 129, + 121, + 86, + 31, + 137, + 133, + 74, + 83, + 246 + ] + } + }, + "relations": [ + "bank" + ] + }, + { + "name": "integration_acc_2", + "docs": [ + "The user account to be created (sub_account_id = 0)" + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "liquidity_vault_authority" + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ], + "program": { + "kind": "const", + "value": [ + 9, + 84, + 219, + 190, + 158, + 201, + 96, + 201, + 138, + 122, + 41, + 63, + 226, + 19, + 54, + 150, + 111, + 225, + 128, + 209, + 81, + 174, + 75, + 129, + 121, + 86, + 31, + 137, + 133, + 74, + 83, + 246 + ] + } + }, + "relations": [ + "bank" + ] + }, + { + "name": "drift_state", + "writable": true + }, + { + "name": "integration_acc_1", + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "drift_spot_market_vault", + "docs": [ + "The Drift spot market vault where tokens will be deposited" + ], + "writable": true + }, + { + "name": "drift_oracle", + "docs": [ + "Oracle for the asset (can be null for USDC/market 0)" + ], + "optional": true + }, + { + "name": "drift_program", + "address": "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH" + }, + { + "name": "token_program" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "drift_withdraw", + "docs": [ + "(user) Withdraw from a Drift spot market through a marginfi account", + "* amount - in the underlying token (e.g., USDC), in native decimals", + "* if group rate limits are enabled, include the withdrawn bank's oracle group in", + "`remaining_accounts`", + "* withdraw_all - if true, withdraws entire position" + ], + "discriminator": [ + 86, + 59, + 186, + 123, + 183, + 181, + 234, + 137 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "marginfi_account", + "bank" + ] + }, + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "bank", + "writable": true + }, + { + "name": "drift_oracle", + "docs": [ + "The oracle account for the asset (not needed if using oracle type QuoteAsset)" + ], + "optional": true + }, + { + "name": "liquidity_vault_authority", + "docs": [ + "The bank's liquidity vault authority, which owns the Drift user account" + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "liquidity_vault", + "docs": [ + "Receives tokens from Drift withdrawal" + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "destination_token_account", + "docs": [ + "Token account that will receive the withdrawn tokens" + ], + "writable": true + }, + { + "name": "drift_state", + "docs": [ + "The Drift state account" + ] + }, + { + "name": "integration_acc_2", + "docs": [ + "The Drift user account owned by liquidity_vault_authority" + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "integration_acc_3", + "docs": [ + "The Drift user stats account owned by liquidity_vault_authority" + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "integration_acc_1", + "docs": [ + "The Drift spot market for this asset" + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "drift_spot_market_vault", + "docs": [ + "The Drift spot market vault that holds tokens" + ], + "writable": true + }, + { + "name": "drift_reward_oracle", + "docs": [ + "Optional: Oracle for first reward asset (only needed if rewards exist)" + ], + "optional": true + }, + { + "name": "drift_reward_spot_market", + "docs": [ + "Optional: Spot market for first reward asset (only needed if rewards exist)" + ], + "optional": true + }, + { + "name": "drift_reward_mint", + "docs": [ + "Optional: Mint for first reward asset (only needed if rewards exist)" + ], + "optional": true + }, + { + "name": "drift_reward_oracle_2", + "docs": [ + "Optional: Oracle for second reward asset (backup in case multiple rewards)" + ], + "optional": true + }, + { + "name": "drift_reward_spot_market_2", + "docs": [ + "Optional: Spot market for second reward asset (backup in case multiple rewards)" + ], + "optional": true + }, + { + "name": "drift_reward_mint_2", + "docs": [ + "Optional: Mint for second reward asset (backup in case multiple rewards)" + ], + "optional": true + }, + { + "name": "drift_signer", + "docs": [ + "The Drift signer PDA" + ] + }, + { + "name": "mint", + "docs": [ + "Bank's liquidity token mint" + ], + "relations": [ + "bank" + ] + }, + { + "name": "drift_program", + "address": "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH" + }, + { + "name": "token_program" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "withdraw_all", + "type": { + "option": "bool" + } + } + ] + }, + { + "name": "edit_fee_state_premium", + "docs": [ + "(global fee admin only) Adjust the variable-borrow premium wallet on the fee state." + ], + "discriminator": [ + 159, + 148, + 85, + 109, + 94, + 212, + 93, + 233 + ], + "accounts": [ + { + "name": "global_fee_admin", + "docs": [ + "Admin of the global FeeState" + ], + "signer": true, + "relations": [ + "fee_state" + ] + }, + { + "name": "fee_state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "premium_wallet", + "type": "pubkey" + } + ] + }, + { + "name": "edit_global_fee_state", + "docs": [ + "(global fee admin only) Adjust fees, admin, wallet, or pause delegate admin" + ], + "discriminator": [ + 52, + 62, + 35, + 129, + 93, + 69, + 165, + 202 + ], + "accounts": [ + { + "name": "global_fee_admin", + "docs": [ + "Admin of the global FeeState" + ], + "signer": true, + "relations": [ + "fee_state" + ] + }, + { + "name": "fee_state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "admin", + "type": { + "option": "pubkey" + } + }, + { + "name": "fee_wallet", + "type": { + "option": "pubkey" + } + }, + { + "name": "bank_init_flat_sol_fee", + "type": { + "option": "u32" + } + }, + { + "name": "liquidation_flat_sol_fee", + "type": { + "option": "u32" + } + }, + { + "name": "order_init_flat_sol_fee", + "type": { + "option": "u32" + } + }, + { + "name": "program_fee_fixed", + "type": { + "option": { + "defined": { + "name": "WrappedI80F48" + } + } + } + }, + { + "name": "program_fee_rate", + "type": { + "option": { + "defined": { + "name": "WrappedI80F48" + } + } + } + }, + { + "name": "liquidation_max_fee", + "type": { + "option": { + "defined": { + "name": "WrappedI80F48" + } + } + } + }, + { + "name": "order_execution_max_fee", + "type": { + "option": { + "defined": { + "name": "WrappedI80F48" + } + } + } + }, + { + "name": "pause_delegate_admin", + "type": { + "option": "pubkey" + } + }, + { + "name": "account_transfer_fee", + "type": { + "option": "u32" + } + } + ] + }, + { + "name": "edit_staked_settings", + "docs": [ + "(slow governance_admin only) Edit the staked collateral settings for the group." + ], + "discriminator": [ + 11, + 108, + 215, + 87, + 240, + 9, + 66, + 241 + ], + "accounts": [ + { + "name": "marginfi_group", + "relations": [ + "staked_settings" + ] + }, + { + "name": "governance_admin", + "signer": true, + "relations": [ + "marginfi_group" + ] + }, + { + "name": "staked_settings", + "writable": true + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "settings", + "type": { + "defined": { + "name": "StakedSettingsEditConfig" + } + } + } + ] + }, + { + "name": "enable_staked_oracle_onramp", + "docs": [ + "(slow governance_admin only) Enable SPL single-pool on-ramp lamports in staked-collateral oracle", + "pricing.", + "To be removed once SVSP update is rolled out (likely in 1.10)", + "This flips a per-group config flag so that every staked oracle uses the canonical single-pool NAV", + "formula." + ], + "discriminator": [ + 114, + 248, + 244, + 6, + 74, + 212, + 222, + 230 + ], + "accounts": [ + { + "name": "group" + }, + { + "name": "governance_admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "staked_settings", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 100, + 95, + 115, + 101, + 116, + 116, + 105, + 110, + 103, + 115 + ] + }, + { + "kind": "account", + "path": "group" + } + ] + } + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "end_deleverage", + "docs": [ + "(risk_admin only) End forced deleverage. Validates health did not worsen." + ], + "discriminator": [ + 114, + 14, + 250, + 143, + 252, + 104, + 214, + 209 + ], + "accounts": [ + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "liquidation_record", + "writable": true, + "relations": [ + "marginfi_account" + ] + }, + { + "name": "group", + "relations": [ + "marginfi_account" + ] + }, + { + "name": "risk_admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "end_liquidation", + "docs": [ + "(liquidation_receiver, set in start_liquidation) End receivership liquidation. Validates", + "health improved and seized assets are within fee limits. Charges a flat SOL fee." + ], + "discriminator": [ + 110, + 11, + 244, + 54, + 229, + 181, + 22, + 184 + ], + "accounts": [ + { + "name": "marginfi_account", + "docs": [ + "Account under liquidation" + ], + "writable": true + }, + { + "name": "liquidation_record", + "docs": [ + "The associated liquidation record PDA for the given `marginfi_account`" + ], + "writable": true, + "relations": [ + "marginfi_account" + ] + }, + { + "name": "group", + "relations": [ + "marginfi_account" + ] + }, + { + "name": "liquidation_receiver", + "writable": true, + "signer": true, + "relations": [ + "liquidation_record" + ] + }, + { + "name": "fee_state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "global_fee_wallet", + "writable": true, + "relations": [ + "fee_state" + ] + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "fee_payer", + "docs": [ + "Optional separate payer for the flat liquidation fee. When provided it must sign and pays the", + "fee; when omitted, the `liquidation_receiver` pays (the default)." + ], + "writable": true, + "signer": true, + "optional": true + } + ], + "args": [] + }, + { + "name": "init_bank_metadata", + "docs": [ + "(permissionless) pay the rent to open metadata for a bank. The bank account does not have", + "to exist yet — callers can pre-create metadata for an upcoming bank pubkey at their own", + "rent expense. When the bank is initialized and its seed is on-chain, the PDA is verified." + ], + "discriminator": [ + 94, + 239, + 50, + 136, + 137, + 204, + 254, + 213 + ], + "accounts": [ + { + "name": "bank", + "docs": [ + "keypair-based bank. When initialized with a known seed, the PDA is verified in the handler." + ] + }, + { + "name": "fee_payer", + "docs": [ + "Pays the init fee" + ], + "writable": true, + "signer": true + }, + { + "name": "metadata", + "docs": [ + "Note: unique per-bank." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "init_global_fee_state", + "docs": [ + "(Runs once per program) Configures the fee state account, where the global admin sets fees", + "that are assessed to the protocol" + ], + "discriminator": [ + 82, + 48, + 247, + 59, + 220, + 109, + 231, + 44 + ], + "accounts": [ + { + "name": "payer", + "docs": [ + "Pays the init fee" + ], + "writable": true, + "signer": true + }, + { + "name": "fee_state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "admin", + "type": "pubkey" + }, + { + "name": "fee_wallet", + "type": "pubkey" + }, + { + "name": "bank_init_flat_sol_fee", + "type": "u32" + }, + { + "name": "liquidation_flat_sol_fee", + "type": "u32" + }, + { + "name": "order_init_flat_sol_fee", + "type": "u32" + }, + { + "name": "program_fee_fixed", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "program_fee_rate", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "liquidation_max_fee", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "order_execution_max_fee", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + } + ] + }, + { + "name": "init_staked_settings", + "docs": [ + "(slow governance_admin only) Init the Staked Settings account, which is used to create staked", + "collateral banks, and must run before any staked collateral bank can be created with", + "`add_pool_permissionless`. Running this ix effectively opts the group into the staked", + "collateral feature." + ], + "discriminator": [ + 52, + 35, + 149, + 44, + 69, + 86, + 69, + 80 + ], + "accounts": [ + { + "name": "marginfi_group" + }, + { + "name": "governance_admin", + "signer": true, + "relations": [ + "marginfi_group" + ] + }, + { + "name": "fee_payer", + "docs": [ + "Pays the init fee" + ], + "writable": true, + "signer": true + }, + { + "name": "staked_settings", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 100, + 95, + 115, + 101, + 116, + 116, + 105, + 110, + 103, + 115 + ] + }, + { + "kind": "account", + "path": "marginfi_group" + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "settings", + "type": { + "defined": { + "name": "StakedSettingsConfig" + } + } + } + ] + }, + { + "name": "juplend_deposit", + "docs": [ + "(user) Deposit into a JupLend lending pool through a marginfi account.", + "* amount - in the underlying token (e.g., USDC), in native decimals" + ], + "discriminator": [ + 114, + 11, + 218, + 81, + 183, + 165, + 143, + 255 + ], + "accounts": [ + { + "name": "group", + "writable": true, + "relations": [ + "marginfi_account", + "bank" + ] + }, + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "bank", + "writable": true + }, + { + "name": "signer_token_account", + "docs": [ + "Owned by authority, the source account for the token deposit." + ], + "writable": true + }, + { + "name": "liquidity_vault_authority", + "docs": [ + "The bank's liquidity vault authority PDA (acts as signer for JupLend CPIs).", + "NOTE: JupLend marks the signer as writable in their deposit instruction." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "liquidity_vault", + "docs": [ + "Bank liquidity vault (holds underlying mint and is used as depositor_token_account)." + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "mint", + "docs": [ + "Underlying mint." + ], + "relations": [ + "bank" + ] + }, + { + "name": "integration_acc_1", + "docs": [ + "JupLend lending state account." + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "f_token_mint", + "docs": [ + "JupLend fToken mint." + ], + "writable": true, + "relations": [ + "integration_acc_1" + ] + }, + { + "name": "integration_acc_2", + "docs": [ + "Bank's fToken vault (validated via has_one on bank)." + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "lending_admin" + }, + { + "name": "supply_token_reserves_liquidity", + "writable": true + }, + { + "name": "lending_supply_position_on_liquidity", + "writable": true + }, + { + "name": "rate_model" + }, + { + "name": "vault", + "writable": true + }, + { + "name": "liquidity", + "writable": true + }, + { + "name": "liquidity_program", + "address": "jupeiUmn818Jg1ekPURTpr4mFo29p46vygyykFJ3wZC" + }, + { + "name": "rewards_rate_model" + }, + { + "name": "juplend_program", + "address": "jup3YeL8QhtSx1e253b2FDvsMNC87fDrgQZivbrndc9" + }, + { + "name": "token_program" + }, + { + "name": "associated_token_program", + "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "juplend_init_position", + "docs": [ + "(permissionless) Initialize the bank-level JupLend position.", + "", + "This creates the bank's fToken ATA (owned by the bank liquidity vault authority) and", + "performs a nominal seed deposit into JupLend, then flips the bank from `Paused` to", + "`Operational`." + ], + "discriminator": [ + 176, + 255, + 151, + 106, + 5, + 207, + 74, + 215 + ], + "accounts": [ + { + "name": "fee_payer", + "docs": [ + "Provides a nominal deposit amount." + ], + "writable": true, + "signer": true + }, + { + "name": "signer_token_account", + "docs": [ + "Token account owned by the fee payer holding the underlying mint." + ], + "writable": true + }, + { + "name": "bank", + "writable": true + }, + { + "name": "liquidity_vault_authority", + "docs": [ + "The bank's liquidity vault authority PDA (acts as signer for JupLend CPIs)." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "liquidity_vault", + "docs": [ + "Bank liquidity vault (holds underlying mint and is used as depositor_token_account)." + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "mint", + "docs": [ + "Underlying mint (must match bank mint and JupLend lending state mint)." + ], + "relations": [ + "bank" + ] + }, + { + "name": "integration_acc_1", + "docs": [ + "JupLend lending state account." + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "f_token_mint", + "docs": [ + "JupLend fToken mint." + ], + "writable": true, + "relations": [ + "integration_acc_1" + ] + }, + { + "name": "integration_acc_2", + "docs": [ + "Bank's fToken vault (validated via has_one on bank)." + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "lending_admin" + }, + { + "name": "supply_token_reserves_liquidity", + "writable": true + }, + { + "name": "lending_supply_position_on_liquidity", + "writable": true + }, + { + "name": "rate_model" + }, + { + "name": "vault", + "writable": true + }, + { + "name": "liquidity", + "writable": true + }, + { + "name": "liquidity_program", + "address": "jupeiUmn818Jg1ekPURTpr4mFo29p46vygyykFJ3wZC" + }, + { + "name": "rewards_rate_model" + }, + { + "name": "juplend_program", + "address": "jup3YeL8QhtSx1e253b2FDvsMNC87fDrgQZivbrndc9" + }, + { + "name": "token_program" + }, + { + "name": "associated_token_program", + "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "juplend_withdraw", + "docs": [ + "(user) Withdraw from a JupLend lending pool through a marginfi account.", + "* amount - in the underlying token (e.g., USDC), in native decimals", + "* if group rate limits are enabled, include the withdrawn bank's oracle group in", + "`remaining_accounts`" + ], + "discriminator": [ + 245, + 164, + 253, + 202, + 53, + 77, + 251, + 221 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "marginfi_account", + "bank" + ] + }, + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "bank", + "writable": true + }, + { + "name": "destination_token_account", + "docs": [ + "Token account that will receive the underlying withdrawal.", + "WARN: Completely unchecked!" + ], + "writable": true + }, + { + "name": "liquidity_vault_authority", + "docs": [ + "The bank's liquidity vault authority PDA (acts as signer for JupLend CPIs).", + "NOTE: JupLend marks the signer as writable in their withdraw instruction." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "mint", + "docs": [ + "Underlying mint." + ], + "relations": [ + "bank" + ] + }, + { + "name": "integration_acc_1", + "docs": [ + "JupLend lending state account." + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "f_token_mint", + "docs": [ + "JupLend fToken mint." + ], + "writable": true, + "relations": [ + "integration_acc_1" + ] + }, + { + "name": "integration_acc_2", + "docs": [ + "Bank's fToken vault (validated via has_one on bank)." + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "integration_acc_3", + "docs": [ + "Withdraw intermediary ATA (authority = liquidity_vault_authority).", + "This must be an ATA to satisfy JupLend's withdraw constraints." + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "lending_admin" + }, + { + "name": "supply_token_reserves_liquidity", + "writable": true + }, + { + "name": "lending_supply_position_on_liquidity", + "writable": true + }, + { + "name": "rate_model" + }, + { + "name": "vault", + "writable": true + }, + { + "name": "claim_account", + "docs": [ + "JupLend claim account for liquidity_vault_authority.", + "TEMPORARY: Mainnet currently requires this account (passing None causes ConstraintMut errors),", + "but an upcoming upgrade is expected to make it truly optional. The account is never actually", + "validated or used - you can pass any mutable account. We create the canonical PDA for consistency.", + "Seeds: [\"user_claim\", liquidity_vault_authority, mint] on Liquidity program." + ], + "writable": true + }, + { + "name": "liquidity", + "writable": true + }, + { + "name": "liquidity_program", + "address": "jupeiUmn818Jg1ekPURTpr4mFo29p46vygyykFJ3wZC" + }, + { + "name": "rewards_rate_model" + }, + { + "name": "juplend_program", + "address": "jup3YeL8QhtSx1e253b2FDvsMNC87fDrgQZivbrndc9" + }, + { + "name": "token_program" + }, + { + "name": "associated_token_program", + "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "withdraw_all", + "type": { + "option": "bool" + } + } + ] + }, + { + "name": "kamino_deposit", + "docs": [ + "(user) Deposit into a Kamino pool through a marginfi account", + "* amount - in the liquidity token (e.g. if there is a Kamino USDC bank, pass the amount of", + "USDC desired), in native decimals." + ], + "discriminator": [ + 237, + 8, + 188, + 187, + 115, + 99, + 49, + 85 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "marginfi_account", + "bank" + ] + }, + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "bank", + "writable": true + }, + { + "name": "signer_token_account", + "docs": [ + "Owned by authority, the source account for the token deposit." + ], + "writable": true + }, + { + "name": "liquidity_vault_authority", + "docs": [ + "The bank's liquidity vault authority, which owns the Kamino obligation. Note: Kamino needs", + "this to be mut because `deposit` might return the rent here" + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "liquidity_vault", + "docs": [ + "Used as an intermediary to deposit token into Kamino" + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "integration_acc_2", + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "lending_market" + }, + { + "name": "lending_market_authority" + }, + { + "name": "integration_acc_1", + "docs": [ + "The Kamino reserve that holds liquidity" + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "mint", + "docs": [ + "Bank's liquidity token mint (e.g., USDC). Kamino calls this the `reserve_liquidity_mint`" + ], + "relations": [ + "bank" + ] + }, + { + "name": "reserve_liquidity_supply", + "writable": true + }, + { + "name": "reserve_collateral_mint", + "docs": [ + "The reserve's mint for tokenized representations of Kamino deposits." + ], + "writable": true + }, + { + "name": "reserve_destination_deposit_collateral", + "docs": [ + "The reserve's destination for tokenized representations of deposits. Note: the", + "`reserve_collateral_mint` will mint tokens directly to this account." + ], + "writable": true + }, + { + "name": "obligation_farm_user_state", + "docs": [ + "Required if the Kamino reserve has an active farm." + ], + "writable": true, + "optional": true + }, + { + "name": "reserve_farm_state", + "docs": [ + "Required if the Kamino reserve has an active farm." + ], + "writable": true, + "optional": true + }, + { + "name": "kamino_program", + "address": "KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD" + }, + { + "name": "farms_program", + "docs": [ + "Farms program for Kamino staking functionality" + ], + "address": "FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr" + }, + { + "name": "collateral_token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "liquidity_token_program" + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "refresh_reserve", + "type": { + "option": "bool" + } + } + ] + }, + { + "name": "kamino_harvest_reward", + "docs": [ + "(permissionless) Harvest the specified reward index from the Kamino Farm attached to this", + "bank. Rewards are always sent to the global fee wallet's canonical ATA.", + "", + "* `reward_index` — index of the reward token in the Kamino Farm's reward list" + ], + "discriminator": [ + 163, + 202, + 248, + 141, + 106, + 20, + 116, + 5 + ], + "accounts": [ + { + "name": "bank" + }, + { + "name": "fee_state", + "docs": [ + "Global fee state that contains the global_fee_admin" + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "destination_token_account", + "docs": [ + "Destination token account must be owned by the global fee admin" + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "fee_state" + }, + { + "kind": "account", + "path": "token_program" + }, + { + "kind": "account", + "path": "reward_mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "liquidity_vault_authority", + "docs": [ + "The bank's liquidity vault authority, which owns the Kamino obligation." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "user_state", + "writable": true + }, + { + "name": "farm_state", + "writable": true + }, + { + "name": "global_config" + }, + { + "name": "reward_mint" + }, + { + "name": "user_reward_ata", + "docs": [ + "An initialized ATA of type reward mint owned by liquidity vault" + ], + "writable": true + }, + { + "name": "rewards_vault", + "writable": true + }, + { + "name": "rewards_treasury_vault", + "writable": true + }, + { + "name": "farm_vaults_authority" + }, + { + "name": "scope_prices", + "optional": true + }, + { + "name": "farms_program", + "address": "FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr" + }, + { + "name": "token_program" + } + ], + "args": [ + { + "name": "reward_index", + "type": "u64" + } + ] + }, + { + "name": "kamino_init_obligation", + "docs": [ + "(permissionless) Initialize a Kamino obligation for a marginfi bank", + "* amount - In token, in native decimals. Must be >10 (i.e. 10 lamports, not 10 tokens). Lost", + "forever. Generally, try to make this the equivalent of around $1, in case Kamino ever", + "rounds small balances down to zero." + ], + "discriminator": [ + 253, + 177, + 160, + 225, + 70, + 156, + 217, + 109 + ], + "accounts": [ + { + "name": "fee_payer", + "docs": [ + "Pays to init the obligation and pays a nominal amount to ensure the obligation has a", + "non-zero balance." + ], + "writable": true, + "signer": true + }, + { + "name": "bank" + }, + { + "name": "signer_token_account", + "docs": [ + "The fee payer must provide a nominal amount of bank tokens so the obligation is not empty.", + "This amount is irrecoverable and and will prevent the obligation from ever being closed,", + "even if the bank is otherwise empty (Kamino normally closes empty obligations automatically)" + ], + "writable": true + }, + { + "name": "liquidity_vault_authority", + "docs": [ + "The liquidity vault authority (PDA that will own the Kamino obligation). Note: Kamino needs", + "this to be mut because `deposit` might return the rent here" + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "liquidity_vault", + "docs": [ + "Used as an intermediary to deposit a nominal amount of token into the obligation." + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "integration_acc_2", + "docs": [ + "The obligation account to be created. Note that the key was already derived when", + "initializing the bank, and this must match the obligation recorded at that time." + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "user_metadata", + "writable": true + }, + { + "name": "lending_market" + }, + { + "name": "lending_market_authority" + }, + { + "name": "integration_acc_1", + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "mint", + "docs": [ + "Bank's liquidity token mint (e.g., USDC). Kamino calls this the `reserve_liquidity_mint`" + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "reserve_liquidity_supply", + "writable": true + }, + { + "name": "reserve_collateral_mint", + "docs": [ + "The reserve's mint for tokenized representations of Kamino deposits." + ], + "writable": true + }, + { + "name": "reserve_destination_deposit_collateral", + "docs": [ + "The reserve's destination for tokenized representations of deposits. Note: the", + "`reserve_collateral_mint` will mint tokens directly to this account." + ], + "writable": true + }, + { + "name": "obligation_farm_user_state", + "docs": [ + "Required if the Kamino reserve has an active farm." + ], + "writable": true, + "optional": true + }, + { + "name": "reserve_farm_state", + "docs": [ + "Required if the Kamino reserve has an active farm." + ], + "writable": true, + "optional": true + }, + { + "name": "kamino_program", + "address": "KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD" + }, + { + "name": "farms_program", + "docs": [ + "Farms program for Kamino staking functionality" + ], + "address": "FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr" + }, + { + "name": "collateral_token_program", + "docs": [ + "Note: the collateral token always uses Token classic, never Token22." + ], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "liquidity_token_program", + "docs": [ + "Note: Kamino does not have full Token22 support, certain Token22 features are disallowed.", + "Expect this to update over time. Check with the Kamino source." + ] + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "kamino_withdraw", + "docs": [ + "(user) Withdraw from a Kamino pool through a marginfi account", + "* amount - in the collateral token (NOT liquidity token), in native decimals. Must convert", + "from collateral to liquidity token amounts using the current exchange rate.", + "* if group rate limits are enabled, include the withdrawn bank's oracle group in", + "`remaining_accounts`", + "* flags - optional bitflags:", + "- bit 0 (`0x01`): withdraw all", + "- bit 1 (`0x02`): refresh reserve via batch refresh" + ], + "discriminator": [ + 199, + 101, + 41, + 45, + 213, + 98, + 224, + 200 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "marginfi_account", + "bank" + ] + }, + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "bank", + "writable": true + }, + { + "name": "destination_token_account", + "docs": [ + "Token account that will receive the withdrawn tokens. Mint/owner are validated by the", + "SPL transfer; the caller controls the destination." + ], + "writable": true + }, + { + "name": "liquidity_vault_authority", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "liquidity_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + }, + "relations": [ + "bank" + ] + }, + { + "name": "integration_acc_2", + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "lending_market", + "docs": [ + "The Kamino lending market" + ] + }, + { + "name": "lending_market_authority", + "docs": [ + "The Kamino lending market authority" + ] + }, + { + "name": "integration_acc_1", + "docs": [ + "The Kamino reserve that holds liquidity" + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "mint", + "docs": [ + "The liquidity token mint (e.g., USDC)", + "Needs serde to get the mint decimals for transfer checked" + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "reserve_liquidity_supply", + "docs": [ + "The reserve's liquidity supply account" + ], + "writable": true + }, + { + "name": "reserve_collateral_mint", + "docs": [ + "The reserve's collateral mint" + ], + "writable": true + }, + { + "name": "reserve_source_collateral", + "docs": [ + "The reserve's source for collateral tokens" + ], + "writable": true + }, + { + "name": "obligation_farm_user_state", + "docs": [ + "Optional farms accounts for Kamino staking functionality" + ], + "writable": true, + "optional": true + }, + { + "name": "reserve_farm_state", + "writable": true, + "optional": true + }, + { + "name": "kamino_program", + "address": "KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD" + }, + { + "name": "farms_program", + "docs": [ + "Farms program for Kamino staking functionality" + ], + "address": "FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr" + }, + { + "name": "collateral_token_program", + "docs": [ + "The token program for the collateral token" + ], + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "liquidity_token_program", + "docs": [ + "The token program for the liquidity token" + ] + }, + { + "name": "instruction_sysvar_account", + "docs": [ + "Used by kamino validate CPI calls" + ], + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "flags", + "type": { + "option": "u8" + } + } + ] + }, + { + "name": "lending_account_borrow", + "docs": [ + "(account authority) Borrow assets from a bank. Accrues interest, records liability, applies", + "origination fee, transfers tokens, and runs a health check. If group rate limits are", + "enabled, `remaining_accounts` must include the borrowed bank's oracle group for USD", + "pricing." + ], + "discriminator": [ + 4, + 126, + 116, + 53, + 48, + 5, + 212, + 31 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "marginfi_account", + "bank" + ] + }, + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "bank", + "writable": true + }, + { + "name": "destination_token_account", + "writable": true + }, + { + "name": "bank_liquidity_vault_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "liquidity_vault", + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "token_program" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "lending_account_close_balance", + "docs": [ + "(account authority) Close a balance position with dust-level amounts." + ], + "discriminator": [ + 245, + 54, + 41, + 4, + 243, + 202, + 31, + 17 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "marginfi_account", + "bank" + ] + }, + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "bank", + "writable": true + } + ], + "args": [] + }, + { + "name": "lending_account_deposit", + "docs": [ + "(account authority) Deposit assets into a bank. Accrues interest, records deposit, and", + "transfers tokens from the signer's token account to the bank's liquidity vault." + ], + "discriminator": [ + 171, + 94, + 235, + 103, + 82, + 64, + 212, + 140 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "marginfi_account", + "bank" + ] + }, + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "bank", + "writable": true + }, + { + "name": "signer_token_account", + "writable": true + }, + { + "name": "liquidity_vault", + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "token_program" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "deposit_up_to_limit", + "type": { + "option": "bool" + } + } + ] + }, + { + "name": "lending_account_end_flashloan", + "docs": [ + "(account authority) End a flash loan and run the health check." + ], + "discriminator": [ + 105, + 124, + 201, + 106, + 153, + 2, + 8, + 156 + ], + "accounts": [ + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "group", + "docs": [ + "Needed for the same-asset emode checks and the premium snapshot recompute; validated by", + "the `has_one = group` on `marginfi_account`." + ], + "relations": [ + "marginfi_account" + ] + }, + { + "name": "authority", + "signer": true, + "relations": [ + "marginfi_account" + ] + } + ], + "args": [] + }, + { + "name": "lending_account_liquidate", + "docs": [ + "(permissionless) Liquidate a lending account balance of an unhealthy marginfi account.", + "The liquidator takes on the liability and receives discounted collateral (2.5% liquidator", + "fee + 2.5% insurance fee).", + "* `asset_amount` - amount of collateral to liquidate", + "* `liquidatee_accounts` - number of remaining accounts for the liquidatee", + "* `liquidator_accounts` - number of remaining accounts for the liquidator" + ], + "discriminator": [ + 214, + 169, + 151, + 213, + 251, + 167, + 86, + 219 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "asset_bank", + "liab_bank", + "liquidator_marginfi_account", + "liquidatee_marginfi_account" + ] + }, + { + "name": "asset_bank", + "writable": true + }, + { + "name": "liab_bank", + "writable": true + }, + { + "name": "liquidator_marginfi_account", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "liquidatee_marginfi_account", + "writable": true + }, + { + "name": "bank_liquidity_vault_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "liab_bank" + } + ] + } + }, + { + "name": "bank_liquidity_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "liab_bank" + } + ] + } + }, + { + "name": "bank_insurance_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "liab_bank" + } + ] + } + }, + { + "name": "token_program" + } + ], + "args": [ + { + "name": "asset_amount", + "type": "u64" + }, + { + "name": "liquidatee_accounts", + "type": "u8" + }, + { + "name": "liquidator_accounts", + "type": "u8" + } + ] + }, + { + "name": "lending_account_pulse_health", + "docs": [ + "(Permissionless) Refresh the internal risk engine health cache. Useful for liquidators and", + "other consumers that want to see the internal risk state of a user account. This cache is", + "read-only and serves no purpose except being populated by this ix.", + "* remaining accounts expected in the same order as borrow, etc. I.e., for each balance the", + "user has, pass bank and oracle: " + ], + "discriminator": [ + 186, + 52, + 117, + 97, + 34, + 74, + 39, + 253 + ], + "accounts": [ + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "group", + "docs": [ + "Needed for same-asset emode checks and the premium snapshot recompute" + ], + "relations": [ + "marginfi_account" + ] + } + ], + "args": [] + }, + { + "name": "lending_account_repay", + "docs": [ + "(account authority, or any signer during receivership) Repay borrowed assets. Accrues", + "interest, records repayment, and transfers tokens to the bank's liquidity vault." + ], + "discriminator": [ + 79, + 209, + 172, + 177, + 222, + 51, + 173, + 151 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "marginfi_account", + "bank" + ] + }, + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "authority", + "docs": [ + "Must be marginfi_account's authority, unless in liquidation/deleverage receivership or order execution", + "", + "Note: during receivership and order execution, there are no signer checks whatsoever: any key can repay as", + "long as the invariants checked at the end of execution are met." + ], + "signer": true + }, + { + "name": "bank", + "writable": true + }, + { + "name": "signer_token_account", + "writable": true + }, + { + "name": "liquidity_vault", + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "token_program" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "repay_all", + "type": { + "option": "bool" + } + } + ] + }, + { + "name": "lending_account_start_flashloan", + "docs": [ + "(account authority) Start a flash loan. Must have a corresponding `end_flashloan` ix in the", + "same tx. Health checks are skipped until the flash loan ends." + ], + "discriminator": [ + 14, + 131, + 33, + 220, + 81, + 186, + 180, + 107 + ], + "accounts": [ + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "authority", + "signer": true, + "relations": [ + "marginfi_account" + ] + }, + { + "name": "ixs_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "end_index", + "type": "u64" + } + ] + }, + { + "name": "lending_account_withdraw", + "docs": [ + "(account authority, or any signer during receivership) Withdraw assets from a bank. Accrues", + "interest, records withdrawal, transfers tokens, and runs a health check (skipped during", + "receivership). If group rate limits are enabled, `remaining_accounts` must include the", + "withdrawn bank's oracle group for USD pricing." + ], + "discriminator": [ + 36, + 72, + 74, + 19, + 210, + 210, + 192, + 192 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "marginfi_account", + "bank" + ] + }, + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "authority", + "docs": [ + "Must be marginfi_account's authority, unless in liquidation/deleverage receivership or order execution", + "", + "Note: during receivership and order execution, there are no signer checks whatsoever: any key can repay as", + "long as the invariants checked at the end of execution are met." + ], + "signer": true + }, + { + "name": "bank", + "writable": true + }, + { + "name": "destination_token_account", + "writable": true + }, + { + "name": "bank_liquidity_vault_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "liquidity_vault", + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "token_program" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "withdraw_all", + "type": { + "option": "bool" + } + } + ] + }, + { + "name": "lending_pool_accrue_bank_interest", + "docs": [ + "(permissionless) Accrue interest on a bank, updating share values and collecting fees." + ], + "discriminator": [ + 108, + 201, + 30, + 87, + 47, + 65, + 97, + 188 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank" + ] + }, + { + "name": "bank", + "writable": true + } + ], + "args": [] + }, + { + "name": "lending_pool_add_bank", + "docs": [ + "(governance_admin only) Add a new bank to the lending pool" + ], + "discriminator": [ + 215, + 68, + 72, + 78, + 208, + 218, + 103, + 182 + ], + "accounts": [ + { + "name": "marginfi_group", + "writable": true + }, + { + "name": "governance_admin", + "signer": true, + "relations": [ + "marginfi_group" + ] + }, + { + "name": "fee_payer", + "docs": [ + "Pays to init accounts and pays `fee_state.bank_init_flat_sol_fee` lamports to the protocol" + ], + "writable": true, + "signer": true + }, + { + "name": "fee_state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "global_fee_wallet", + "writable": true, + "relations": [ + "fee_state" + ] + }, + { + "name": "bank_mint" + }, + { + "name": "bank", + "writable": true, + "signer": true + }, + { + "name": "liquidity_vault_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "liquidity_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "insurance_vault_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "insurance_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "fee_vault_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "fee_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "token_program" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "bank_config", + "type": { + "defined": { + "name": "BankConfigCompact" + } + } + } + ] + }, + { + "name": "lending_pool_add_bank_drift", + "docs": [ + "(governance_admin only) Add a Drift bank to the group." + ], + "discriminator": [ + 62, + 63, + 49, + 48, + 76, + 55, + 108, + 155 + ], + "accounts": [ + { + "name": "group", + "writable": true + }, + { + "name": "governance_admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "fee_payer", + "writable": true, + "signer": true + }, + { + "name": "bank_mint", + "docs": [ + "Must match the mint used by `integration_acc_1`" + ] + }, + { + "name": "bank", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "group" + }, + { + "kind": "account", + "path": "bank_mint" + }, + { + "kind": "arg", + "path": "bank_seed" + } + ] + } + }, + { + "name": "integration_acc_1", + "docs": [ + "Drift spot market account that must match the bank mint" + ] + }, + { + "name": "integration_acc_2", + "docs": [ + "Drift user account for the marginfi program (derived from liquidity_vault_authority)" + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "liquidity_vault_authority" + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ], + "program": { + "kind": "const", + "value": [ + 9, + 84, + 219, + 190, + 158, + 201, + 96, + 201, + 138, + 122, + 41, + 63, + 226, + 19, + 54, + 150, + 111, + 225, + 128, + 209, + 81, + 174, + 75, + 129, + 121, + 86, + 31, + 137, + 133, + 74, + 83, + 246 + ] + } + } + }, + { + "name": "integration_acc_3", + "docs": [ + "Drift user stats account for the marginfi program (derived from liquidity_vault_authority)" + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114, + 95, + 115, + 116, + 97, + 116, + 115 + ] + }, + { + "kind": "account", + "path": "liquidity_vault_authority" + } + ], + "program": { + "kind": "const", + "value": [ + 9, + 84, + 219, + 190, + 158, + 201, + 96, + 201, + 138, + 122, + 41, + 63, + 226, + 19, + 54, + 150, + 111, + 225, + 128, + 209, + 81, + 174, + 75, + 129, + 121, + 86, + 31, + 137, + 133, + 74, + 83, + 246 + ] + } + } + }, + { + "name": "liquidity_vault_authority", + "docs": [ + "Will be authority of the bank's liquidity vault. Used as intermediary for deposits/withdraws" + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "liquidity_vault", + "docs": [ + "For Drift banks, the `liquidity_vault` never holds assets, but is instead used as an", + "intermediary when depositing/withdrawing, e.g., withdrawn funds move from Drift -> here ->", + "the user's token account." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "insurance_vault_authority", + "docs": [ + "Note: Currently does nothing." + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "insurance_vault", + "docs": [ + "Note: Currently does nothing." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "fee_vault_authority", + "docs": [ + "Note: Currently does nothing." + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "fee_vault", + "docs": [ + "Note: Currently does nothing." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "token_program" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "bank_config", + "type": { + "defined": { + "name": "DriftConfigCompact" + } + } + }, + { + "name": "bank_seed", + "type": "u64" + } + ] + }, + { + "name": "lending_pool_add_bank_juplend", + "docs": [ + "(slow governance_admin) Add a JupLend bank to the marginfi group.", + "", + "Remaining accounts (for oracle validation):", + "0. underlying oracle feed (pyth push or switchboard pull)", + "1. JupLend `Lending` state" + ], + "discriminator": [ + 18, + 208, + 117, + 90, + 53, + 111, + 195, + 41 + ], + "accounts": [ + { + "name": "group", + "writable": true + }, + { + "name": "governance_admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "fee_payer", + "writable": true, + "signer": true + }, + { + "name": "bank_mint", + "docs": [ + "Must match the mint used by the JupLend lending state." + ] + }, + { + "name": "bank", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "group" + }, + { + "kind": "account", + "path": "bank_mint" + }, + { + "kind": "arg", + "path": "bank_seed" + } + ] + } + }, + { + "name": "integration_acc_1", + "docs": [ + "JupLend lending state account that must match the bank mint." + ] + }, + { + "name": "liquidity_vault_authority", + "docs": [ + "Will be authority of the bank's liquidity vault. Used as intermediary for deposits/withdraws." + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "liquidity_vault", + "docs": [ + "For JupLend banks, the `liquidity_vault` is used as an intermediary when depositing/", + "withdrawing, e.g., withdrawn funds move from JupLend -> here -> the user's token account." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "insurance_vault_authority", + "docs": [ + "Note: Currently does nothing." + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "insurance_vault", + "docs": [ + "Note: Currently does nothing." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "fee_vault_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "fee_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "f_token_mint", + "relations": [ + "integration_acc_1" + ] + }, + { + "name": "integration_acc_2", + "docs": [ + "The bank's fToken vault holds the fTokens received when depositing into JupLend.", + "" + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 95, + 116, + 111, + 107, + 101, + 110, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "token_program", + "docs": [ + "Token program for both underlying mint and fToken mint (SPL Token or Token-2022).", + "JupLend creates fToken mints using the same token program as the underlying." + ] + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "bank_config", + "type": { + "defined": { + "name": "JuplendConfigCompact" + } + } + }, + { + "name": "bank_seed", + "type": "u64" + } + ] + }, + { + "name": "lending_pool_add_bank_kamino", + "docs": [ + "(governance_admin only) Add a Kamino bank to the group. Pass the oracle and reserve in remaining", + "accounts 0 and 1 respectively." + ], + "discriminator": [ + 118, + 53, + 16, + 243, + 255, + 245, + 149, + 241 + ], + "accounts": [ + { + "name": "group", + "writable": true + }, + { + "name": "governance_admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "fee_payer", + "writable": true, + "signer": true + }, + { + "name": "bank_mint", + "docs": [ + "Must match the mint used by the Kamino reserve (integration_acc_1), Kamino calls this the", + "`reserve_liquidity_mint` aka `liquidity.mint_pubkey`" + ] + }, + { + "name": "bank", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "group" + }, + { + "kind": "account", + "path": "bank_mint" + }, + { + "kind": "arg", + "path": "bank_seed" + } + ] + } + }, + { + "name": "integration_acc_1" + }, + { + "name": "integration_acc_2", + "docs": [ + "Note: not yet initialized in this instruction, run `init_obligation` after." + ] + }, + { + "name": "liquidity_vault_authority", + "docs": [ + "Will be authority of the bank's Kamino obligation (integration_acc_2). Note: When", + "depositing/withdrawing Kamino assets, the source/destination must also be owned by the", + "obligation authority.", + "Kamino assets, the source/destination must also be owned by the obligation authority. This", + "account owns the `liquidity_vault`, and thus acts as intermediary for deposits/withdraws" + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "liquidity_vault", + "docs": [ + "For Kamino banks, the `liquidity_vault` never holds assets, but is instead used as an", + "intermediary when depositing/withdrawing, e.g., withdrawn funds move from Kamino -> here ->", + "the user's token account." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "insurance_vault_authority", + "docs": [ + "Note: Currently does nothing." + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "insurance_vault", + "docs": [ + "Note: Currently does nothing." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "fee_vault_authority", + "docs": [ + "Note: Currently does nothing." + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "fee_vault", + "docs": [ + "Note: Currently does nothing." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "token_program" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "bank_config", + "type": { + "defined": { + "name": "KaminoConfigCompact" + } + } + }, + { + "name": "bank_seed", + "type": "u64" + } + ] + }, + { + "name": "lending_pool_add_bank_permissionless", + "docs": [ + "(permissionless) Add a staked collateral bank. Requires a valid SPL single-pool LST mint." + ], + "discriminator": [ + 127, + 187, + 121, + 34, + 187, + 167, + 238, + 102 + ], + "accounts": [ + { + "name": "marginfi_group", + "writable": true, + "relations": [ + "staked_settings" + ] + }, + { + "name": "staked_settings" + }, + { + "name": "fee_payer", + "writable": true, + "signer": true + }, + { + "name": "bank_mint", + "docs": [ + "Mint of the spl-single-pool LST (a PDA derived from `stake_pool`)", + "", + "because the sol_pool and stake_pool will not derive to a valid PDA which is also owned by", + "the staking program and spl-single-pool program." + ] + }, + { + "name": "sol_pool" + }, + { + "name": "pool_onramp" + }, + { + "name": "stake_pool", + "docs": [ + "this key.", + "", + "If derives the same `bank_mint`, then this must be the correct stake pool for that mint, and", + "we can subsequently use it to validate the `sol_pool`" + ] + }, + { + "name": "validator_vote_account", + "docs": [ + "Validator vote account for this staked bank.", + "", + "vote -> stake_pool -> mint/stake/on-ramp." + ] + }, + { + "name": "bank", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "marginfi_group" + }, + { + "kind": "account", + "path": "bank_mint" + }, + { + "kind": "arg", + "path": "bank_seed" + } + ] + } + }, + { + "name": "liquidity_vault_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "liquidity_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "insurance_vault_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "insurance_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "fee_vault_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "fee_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "token_program" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "bank_seed", + "type": "u64" + } + ] + }, + { + "name": "lending_pool_add_bank_solend", + "docs": [ + "(slow governance_admin) Add a Solend bank to the marginfi group" + ], + "discriminator": [ + 81, + 233, + 203, + 199, + 47, + 226, + 0, + 68 + ], + "accounts": [ + { + "name": "group", + "writable": true + }, + { + "name": "governance_admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "fee_payer", + "writable": true, + "signer": true + }, + { + "name": "bank_mint", + "docs": [ + "Must match the mint used by `integration_acc_1`, Solend calls this the `liquidity.mint_pubkey`" + ] + }, + { + "name": "bank", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "group" + }, + { + "kind": "account", + "path": "bank_mint" + }, + { + "kind": "arg", + "path": "bank_seed" + } + ] + } + }, + { + "name": "integration_acc_1", + "docs": [ + "Solend reserve account that must match the bank mint" + ] + }, + { + "name": "integration_acc_2", + "docs": [ + "Obligation PDA for this bank in Solend", + "Will be initialized and transferred to Solend in init_obligation instruction" + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 111, + 108, + 101, + 110, + 100, + 95, + 111, + 98, + 108, + 105, + 103, + 97, + 116, + 105, + 111, + 110 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "liquidity_vault_authority", + "docs": [ + "Will be authority of the bank's liquidity vault. Used as intermediary for deposits/withdraws" + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "liquidity_vault", + "docs": [ + "For Solend banks, the `liquidity_vault` never holds assets, but is instead used as an", + "intermediary when depositing/withdrawing, e.g., withdrawn funds move from Solend -> here ->", + "the user's token account." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "insurance_vault_authority", + "docs": [ + "Note: Currently does nothing." + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "insurance_vault", + "docs": [ + "Note: Currently does nothing." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "fee_vault_authority", + "docs": [ + "Note: Currently does nothing." + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "fee_vault", + "docs": [ + "Note: Currently does nothing." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "token_program" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "bank_config", + "type": { + "defined": { + "name": "SolendConfigCompact" + } + } + }, + { + "name": "bank_seed", + "type": "u64" + } + ] + }, + { + "name": "lending_pool_add_bank_with_seed", + "docs": [ + "(governance_admin only) A copy of lending_pool_add_bank with an additional bank seed.", + "This seed is used to create a PDA for the bank's signature.", + "lending_pool_add_bank is preserved for backwards compatibility." + ], + "discriminator": [ + 76, + 211, + 213, + 171, + 117, + 78, + 158, + 76 + ], + "accounts": [ + { + "name": "marginfi_group", + "writable": true + }, + { + "name": "governance_admin", + "signer": true, + "relations": [ + "marginfi_group" + ] + }, + { + "name": "fee_payer", + "docs": [ + "Pays to init accounts and pays `fee_state.bank_init_flat_sol_fee` lamports to the protocol" + ], + "writable": true, + "signer": true + }, + { + "name": "fee_state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "global_fee_wallet", + "writable": true, + "relations": [ + "fee_state" + ] + }, + { + "name": "bank_mint" + }, + { + "name": "bank", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "marginfi_group" + }, + { + "kind": "account", + "path": "bank_mint" + }, + { + "kind": "arg", + "path": "bank_seed" + } + ] + } + }, + { + "name": "liquidity_vault_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "liquidity_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "insurance_vault_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "insurance_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "fee_vault_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "fee_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "token_program" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "bank_config", + "type": { + "defined": { + "name": "BankConfigCompact" + } + } + }, + { + "name": "bank_seed", + "type": "u64" + } + ] + }, + { + "name": "lending_pool_backfill_bank_is_t22_flag", + "docs": [ + "(permissionless) Backfill `IS_T22` on existing banks created before this flag existed.", + "Also optionally backfills `bank_seed` in the same call.", + "Pass `None` to skip seed backfill, `Some(seed)` to backfill (including `Some(0)`)." + ], + "discriminator": [ + 189, + 14, + 205, + 160, + 172, + 46, + 157, + 52 + ], + "accounts": [ + { + "name": "bank", + "writable": true + }, + { + "name": "group", + "relations": [ + "bank" + ] + }, + { + "name": "mint", + "relations": [ + "bank" + ] + } + ], + "args": [ + { + "name": "bank_seed", + "type": { + "option": "u64" + } + } + ] + }, + { + "name": "lending_pool_backfill_staked_bank_validator_vote_account", + "docs": [ + "(permissionless) Backfill validator vote account on existing staked-collateral banks.", + "No-op if already set to the same validator vote account." + ], + "discriminator": [ + 141, + 6, + 23, + 125, + 72, + 34, + 199, + 24 + ], + "accounts": [ + { + "name": "bank", + "writable": true + }, + { + "name": "validator_vote_account" + } + ], + "args": [] + }, + { + "name": "lending_pool_clear_circuit_breaker", + "docs": [ + "(admin or risk_admin) Clear an active circuit-breaker halt on a bank.", + "* `reseed_reference` - If true, also zero the EMA reference so the next pulse reseeds it", + "from live oracle data (use when clearing because the new price level is valid and the", + "pre-halt reference would cause an immediate re-halt)." + ], + "discriminator": [ + 64, + 73, + 106, + 46, + 213, + 86, + 31, + 48 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank" + ] + }, + { + "name": "authority", + "docs": [ + "Either `group.admin` or `group.risk_admin`. Validated in the handler." + ], + "signer": true + }, + { + "name": "bank", + "writable": true + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "reseed_reference", + "type": "bool" + } + ] + }, + { + "name": "lending_pool_clone_bank", + "docs": [ + "(governance_admin only) Staging or localnet only, panics on mainnet", + "This instruction is used to clone a bank to a new PDA." + ], + "discriminator": [ + 214, + 93, + 17, + 236, + 177, + 228, + 78, + 17 + ], + "accounts": [ + { + "name": "marginfi_group", + "writable": true + }, + { + "name": "governance_admin", + "writable": true, + "signer": true, + "relations": [ + "marginfi_group" + ] + }, + { + "name": "fee_payer", + "writable": true, + "signer": true + }, + { + "name": "bank_mint" + }, + { + "name": "source_bank", + "docs": [ + "Source bank to clone from mainnet program", + "" + ] + }, + { + "name": "bank", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "marginfi_group" + }, + { + "kind": "account", + "path": "bank_mint" + }, + { + "kind": "arg", + "path": "bank_seed" + } + ] + } + }, + { + "name": "liquidity_vault_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "liquidity_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "insurance_vault_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "insurance_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "fee_vault_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "fee_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "token_program" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "bank_seed", + "type": "u64" + } + ] + }, + { + "name": "lending_pool_clone_emode", + "docs": [ + "(governance_admin only) Copies emode settings from one bank to another. Useful when applying", + "emode settings from e.g. one LST to another." + ], + "discriminator": [ + 146, + 167, + 94, + 106, + 184, + 202, + 15, + 10 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "copy_from_bank", + "copy_to_bank" + ] + }, + { + "name": "governance_admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "copy_from_bank" + }, + { + "name": "copy_to_bank", + "writable": true + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "lending_pool_close_bank", + "docs": [ + "(admin only) Close a bank. Requires CLOSE_ENABLED_FLAG and zero positions/shares.", + "", + "Pass `force_close = Some(true)` to bypass the CLOSE_ENABLED_FLAG and open-position checks", + "(zero-shares/emissions are still required). Forcing a bank closed is **VERY DANGEROUS**.", + "Only do it if a Bank was fundamentally broken in some way. The admin **MUST ENSURE** that:", + "", + "* **NO USER** has a Balance in this bank (zero-shares on the bank is not sufficient to", + "guarantee this, a user can have a zero-share Balance, this could brick their account.)", + "* fee and insurance vault balances are withdrawn (unless you don't care if they are lost", + "**FOREVER**).", + "* all three vault token-account balances are zero (or you don't care if anything remaining", + "is lost **FOREVER**), including the liquidity vault", + "* all three outstanding-fee fields are zero (or you don't care if anything remaining is lost", + "**FOREVER**)" + ], + "discriminator": [ + 22, + 115, + 7, + 130, + 227, + 85, + 0, + 47 + ], + "accounts": [ + { + "name": "group", + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "bank", + "writable": true + }, + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "force_close", + "type": { + "option": "bool" + } + } + ] + }, + { + "name": "lending_pool_collect_bank_fees", + "docs": [ + "(permissionless) Transfer accrued fees from the liquidity vault to insurance/fee/program", + "vaults." + ], + "discriminator": [ + 201, + 5, + 215, + 116, + 230, + 92, + 75, + 150 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank" + ] + }, + { + "name": "bank", + "writable": true + }, + { + "name": "liquidity_vault_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "liquidity_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "insurance_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "fee_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "fee_state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "fee_ata", + "docs": [ + "(validated in handler). Must already exist, may require initializing the ATA if it does not", + "already exist prior to this ix." + ], + "writable": true + }, + { + "name": "token_program" + } + ], + "args": [] + }, + { + "name": "lending_pool_collect_bank_premium_fees", + "docs": [ + "(permissionless) Sweep realized variable-borrow premium from the liquidity vault to the", + "canonical ATA of `FeeState.premium_wallet` for the bank's mint." + ], + "discriminator": [ + 193, + 168, + 164, + 176, + 80, + 191, + 33, + 180 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank" + ] + }, + { + "name": "bank", + "writable": true + }, + { + "name": "liquidity_vault_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "liquidity_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "fee_state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "premium_ata", + "docs": [ + "Canonical ATA of the `FeeState.premium_wallet` for the mint used by this bank", + "(validated in handler). Must already exist." + ], + "writable": true + }, + { + "name": "token_program" + } + ], + "args": [] + }, + { + "name": "lending_pool_configure_bank", + "docs": [ + "Configure fast-admin bank parameters. Operational banks may be paused, set to", + "ReduceOnly, or set to ReduceOnlyWithBorrowingPower; the latter may subsequently be set to", + "ReduceOnly. The fast admin may pause a bank from any state. Restoring a bank to", + "Operational requires `lending_pool_configure_bank_gov`." + ], + "discriminator": [ + 121, + 173, + 156, + 40, + 93, + 148, + 56, + 237 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank" + ] + }, + { + "name": "admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "bank", + "writable": true + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "bank_config_opt", + "type": { + "defined": { + "name": "BankConfigFast" + } + } + } + ] + }, + { + "name": "lending_pool_configure_bank_emode", + "docs": [ + "(governance_admin only)" + ], + "discriminator": [ + 17, + 175, + 91, + 57, + 239, + 86, + 49, + 71 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank" + ] + }, + { + "name": "governance_admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "bank", + "writable": true + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "emode_tag", + "type": "u16" + }, + { + "name": "entries", + "type": { + "array": [ + { + "defined": { + "name": "EmodeEntry" + } + }, + 10 + ] + } + } + ] + }, + { + "name": "lending_pool_configure_bank_gov", + "docs": [ + "Configure slow, timelocked governance bank parameters, including risk settings,", + "freezing bank settings, and restoring a bank to Operational." + ], + "discriminator": [ + 122, + 87, + 141, + 86, + 182, + 34, + 146, + 25 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank" + ] + }, + { + "name": "governance_admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "bank", + "writable": true + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "bank_config_opt", + "type": { + "defined": { + "name": "BankConfigGov" + } + } + } + ] + }, + { + "name": "lending_pool_configure_bank_interest_only", + "docs": [ + "(delegate_curve_admin only) Update interest rate config. Does nothing if bank has", + "`FREEZE_SETTINGS`." + ], + "discriminator": [ + 245, + 107, + 83, + 38, + 103, + 219, + 163, + 241 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank" + ] + }, + { + "name": "delegate_curve_admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "bank", + "writable": true + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "interest_rate_config", + "type": { + "defined": { + "name": "InterestRateConfigOpt" + } + } + } + ] + }, + { + "name": "lending_pool_configure_bank_limits_only", + "docs": [ + "(delegate_limit_admin only) Update deposit/borrow/init limits only." + ], + "discriminator": [ + 157, + 196, + 221, + 200, + 202, + 62, + 84, + 21 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank" + ] + }, + { + "name": "delegate_limit_admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "bank", + "writable": true + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "deposit_limit", + "type": { + "option": "u64" + } + }, + { + "name": "borrow_limit", + "type": { + "option": "u64" + } + }, + { + "name": "total_asset_value_init_limit", + "type": { + "option": "u64" + } + } + ] + }, + { + "name": "lending_pool_configure_bank_oracle", + "docs": [ + "(governance_admin only)" + ], + "discriminator": [ + 209, + 82, + 255, + 171, + 124, + 21, + 71, + 81 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank" + ] + }, + { + "name": "governance_admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "bank", + "writable": true + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "setup", + "type": "u8" + }, + { + "name": "oracle", + "type": "pubkey" + } + ] + }, + { + "name": "lending_pool_configure_bank_oracle_scope", + "docs": [ + "(governance_admin only) Point a bank at a Scope feed entry. Picks `Scope`, `ScopeKamino`, or", + "`ScopeJuplend` from the bank's asset tag; Kamino/JupLend banks pass their reserve/lending", + "account after the feed in remaining accounts.", + "* oracle - the feed's `OraclePrices` account", + "* entry_index - which of the 512 entries in that account prices this bank" + ], + "discriminator": [ + 134, + 228, + 127, + 3, + 117, + 132, + 85, + 146 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank" + ] + }, + { + "name": "governance_admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "bank", + "writable": true + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "oracle", + "type": "pubkey" + }, + { + "name": "entry_index", + "type": "u16" + } + ] + }, + { + "name": "lending_pool_configure_bank_premium", + "docs": [ + "(fast group admin only) Set a bank's premium tag and toggle premium accrual for its borrowers." + ], + "discriminator": [ + 216, + 82, + 134, + 217, + 11, + 240, + 78, + 42 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank" + ] + }, + { + "name": "admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "bank", + "writable": true + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "premium_tag", + "type": "u16" + }, + { + "name": "active", + "type": "bool" + } + ] + }, + { + "name": "lending_pool_configure_group_premium", + "docs": [ + "(fast group admin only) Set one pair of the group's variable-borrow premium matrix:", + "`rate > 0` inserts or updates the pair, `rate == 0` removes it." + ], + "discriminator": [ + 184, + 196, + 245, + 41, + 203, + 77, + 75, + 170 + ], + "accounts": [ + { + "name": "group", + "writable": true + }, + { + "name": "admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "collateral_tag", + "type": "u16" + }, + { + "name": "liability_tag", + "type": "u16" + }, + { + "name": "rate", + "type": "u32" + } + ] + }, + { + "name": "lending_pool_emissions_deposit", + "docs": [ + "(permissionless) Deposit same-bank emissions directly into liquidity vault and increase", + "depositors' value via `asset_share_value`." + ], + "discriminator": [ + 121, + 118, + 123, + 58, + 59, + 192, + 74, + 138 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank" + ] + }, + { + "name": "bank", + "writable": true + }, + { + "name": "mint", + "relations": [ + "bank" + ] + }, + { + "name": "emissions_funding_account", + "docs": [ + "NOTE: This is a TokenAccount, spl transfer will validate it.", + "" + ], + "writable": true + }, + { + "name": "depositor", + "writable": true, + "signer": true + }, + { + "name": "liquidity_vault", + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "token_program" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "lending_pool_force_tokenless_repay_complete", + "docs": [ + "(risk_admin only) - Signals all of a bank's liability have been deleveraged. Used if a bank", + "still has liability dust after the risk admin has completed deleveraging all debts. The", + "risk admin is trusted not to execute this until all non-dust debts have been deleveraged." + ], + "discriminator": [ + 15, + 203, + 147, + 232, + 199, + 14, + 231, + 37 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank" + ] + }, + { + "name": "risk_admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "bank", + "writable": true + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "lending_pool_handle_bankruptcy", + "docs": [ + "(risk_admin or admin, unless `PERMISSIONLESS_BAD_DEBT_SETTLEMENT_FLAG` is set on the bank)", + "Handle bad debt of a bankrupt marginfi account for a given bank. Covers bad debt from the", + "insurance fund and socializes any remainder among depositors." + ], + "discriminator": [ + 162, + 11, + 56, + 139, + 90, + 128, + 70, + 173 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank", + "marginfi_account" + ] + }, + { + "name": "signer", + "docs": [ + "Must be risk_admin or admin, unless the bank has PERMISSIONLESS_BAD_DEBT_SETTLEMENT_FLAG", + "set, in which case any signer is accepted." + ], + "signer": true + }, + { + "name": "bank", + "writable": true + }, + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "liquidity_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "insurance_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "insurance_vault_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "token_program" + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "lending_pool_init_same_asset_emode_registry", + "docs": [ + "(governance_admin only) Initialize the per-group same-asset e-mode registry." + ], + "discriminator": [ + 217, + 78, + 227, + 223, + 147, + 231, + 213, + 108 + ], + "accounts": [ + { + "name": "group" + }, + { + "name": "governance_admin", + "writable": true, + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "same_asset_emode_registry", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 97, + 109, + 101, + 95, + 97, + 115, + 115, + 101, + 116, + 95, + 101, + 109, + 111, + 100, + 101, + 95, + 114, + 101, + 103, + 105, + 115, + 116, + 114, + 121 + ] + }, + { + "kind": "account", + "path": "group" + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "lending_pool_pulse_bank_price_cache", + "docs": [ + "(Permissionless) Refresh the cached oracle price for a bank." + ], + "discriminator": [ + 192, + 19, + 201, + 135, + 105, + 203, + 32, + 222 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank" + ] + }, + { + "name": "bank", + "writable": true + } + ], + "args": [] + }, + { + "name": "lending_pool_resize_bank_account", + "docs": [ + "(permissionless) Resize a v1-sized bank account to the current struct size; `payer`", + "funds the added rent." + ], + "discriminator": [ + 44, + 109, + 34, + 113, + 110, + 33, + 139, + 160 + ], + "accounts": [ + { + "name": "bank", + "docs": [ + "undersized bank can still be resized under the future (larger-struct) program." + ], + "writable": true + }, + { + "name": "payer", + "docs": [ + "Funds the rent for the added account space." + ], + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "lending_pool_resize_group_account", + "docs": [ + "(permissionless) Resize the group account to the v2 layout size; `payer` funds the", + "added rent." + ], + "discriminator": [ + 97, + 221, + 69, + 96, + 204, + 162, + 174, + 250 + ], + "accounts": [ + { + "name": "group", + "docs": [ + "undersized group can still be resized under the future (larger-struct) program." + ], + "writable": true + }, + { + "name": "payer", + "docs": [ + "Funds the rent for the added account space." + ], + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "lending_pool_set_bank_same_asset_emode_eligibility", + "docs": [ + "(governance_admin only) Opt a bank in/out of same-asset e-mode participation." + ], + "discriminator": [ + 149, + 50, + 162, + 236, + 150, + 119, + 9, + 47 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank", + "same_asset_emode_registry" + ] + }, + { + "name": "governance_admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "bank", + "writable": true + }, + { + "name": "same_asset_emode_registry", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 97, + 109, + 101, + 95, + 97, + 115, + 115, + 101, + 116, + 95, + 101, + 109, + 111, + 100, + 101, + 95, + 114, + 101, + 103, + 105, + 115, + 116, + 114, + 121 + ] + }, + { + "kind": "account", + "path": "group" + } + ] + } + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "enabled", + "type": "bool" + } + ] + }, + { + "name": "lending_pool_set_oracle_price", + "docs": [ + "(governance_admin only)" + ], + "discriminator": [ + 234, + 244, + 37, + 65, + 101, + 255, + 217, + 160 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank" + ] + }, + { + "name": "governance_admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "bank", + "writable": true + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "price", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "setup", + "type": "u8" + } + ] + }, + { + "name": "lending_pool_update_fees_destination_account", + "docs": [ + "(admin only) Set the destination wallet for permissionless fee withdrawals." + ], + "discriminator": [ + 102, + 4, + 121, + 243, + 237, + 110, + 95, + 13 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank" + ] + }, + { + "name": "bank", + "writable": true + }, + { + "name": "admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "destination_account", + "docs": [ + "Bank fees will be sent to this account which must be an ATA of the bank's mint." + ] + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "lending_pool_withdraw_fees", + "docs": [ + "(admin only) Withdraw collected group fees from the fee vault." + ], + "discriminator": [ + 92, + 140, + 215, + 254, + 170, + 0, + 83, + 174 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank" + ] + }, + { + "name": "bank" + }, + { + "name": "admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "fee_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "fee_vault_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "dst_token_account", + "writable": true + }, + { + "name": "token_program" + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "lending_pool_withdraw_fees_permissionless", + "docs": [ + "(permissionless) Withdraw group fees to the pre-configured `fees_destination_account`." + ], + "discriminator": [ + 57, + 245, + 1, + 208, + 130, + 18, + 145, + 113 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank" + ] + }, + { + "name": "bank" + }, + { + "name": "fee_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "fee_vault_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "fees_destination_account", + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "token_program" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "lending_pool_withdraw_insurance", + "docs": [ + "(admin only) Withdraw from the insurance vault." + ], + "discriminator": [ + 108, + 60, + 60, + 246, + 104, + 79, + 159, + 243 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank" + ] + }, + { + "name": "bank" + }, + { + "name": "admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "insurance_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "insurance_vault_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "dst_token_account", + "writable": true + }, + { + "name": "token_program" + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "marginfi_account_close", + "docs": [ + "(account authority) Close a marginfi account. Requires all balances to be empty and no", + "active flags (disabled, flashloan, receivership)." + ], + "discriminator": [ + 186, + 221, + 93, + 34, + 50, + 97, + 194, + 241 + ], + "accounts": [ + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "authority", + "signer": true, + "relations": [ + "marginfi_account" + ] + }, + { + "name": "fee_payer", + "writable": true, + "signer": true + }, + { + "name": "rebalance_fee_pool", + "docs": [ + "`withdraw_rebalance_fee_pool`) before close so its lamports are not orphaned." + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 98, + 97, + 108, + 97, + 110, + 99, + 101, + 95, + 102, + 101, + 101, + 95, + 112, + 111, + 111, + 108 + ] + }, + { + "kind": "account", + "path": "marginfi_account" + } + ] + } + } + ], + "args": [] + }, + { + "name": "marginfi_account_close_liq_record", + "docs": [ + "(permissionless) Close a liquidation record PDA and return rent to the original payer.", + "Rent always goes to `record_payer`. Fails if the account is in receivership or deleverage." + ], + "discriminator": [ + 187, + 222, + 41, + 134, + 102, + 10, + 112, + 147 + ], + "accounts": [ + { + "name": "marginfi_account", + "writable": true, + "relations": [ + "liquidation_record" + ] + }, + { + "name": "liquidation_record", + "writable": true, + "relations": [ + "marginfi_account" + ] + }, + { + "name": "record_payer", + "docs": [ + "The wallet that originally paid to create this record.", + "Rent is returned here via Anchor's `close` constraint." + ], + "writable": true + } + ], + "args": [] + }, + { + "name": "marginfi_account_close_order", + "docs": [ + "(user) Close an existing Order, returning rent to the user" + ], + "discriminator": [ + 212, + 223, + 79, + 182, + 172, + 183, + 205, + 237 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "marginfi_account" + ] + }, + { + "name": "marginfi_account", + "writable": true, + "relations": [ + "order" + ] + }, + { + "name": "authority", + "signer": true + }, + { + "name": "order", + "writable": true + }, + { + "name": "fee_recipient", + "writable": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "marginfi_account_close_rebalance_order", + "docs": [ + "Close an auto-rebalance order. The authority may cancel their own order at any time; anyone", + "may permissionlessly close a stale order once the account was closed or it no longer holds a", + "position in any allowed venue. Rent goes to `fee_recipient`." + ], + "discriminator": [ + 218, + 239, + 199, + 221, + 92, + 158, + 134, + 62 + ], + "accounts": [ + { + "name": "marginfi_account", + "docs": [ + "are validated in the handler." + ], + "writable": true, + "relations": [ + "rebalance_order" + ] + }, + { + "name": "authority", + "docs": [ + "Signs to close an order that still holds a position; omitted for the permissionless close of a", + "dead order." + ], + "signer": true, + "optional": true + }, + { + "name": "fee_recipient", + "writable": true + }, + { + "name": "rebalance_order", + "writable": true + } + ], + "args": [] + }, + { + "name": "marginfi_account_end_execute_order", + "docs": [ + "(permissionless keeper) End Order execution", + "* Closes the Order (keeper keeps the rent)", + "* Closes the borrow position involved in the Order, the lending position remains open", + "* User health must be \"unchanged\" (within Order requirements i.e. minus slippage). Keeper", + "may keep any slippage in excess of what was needed to complete the Order as profit.", + "* `StartExecuteOrder` must appear earlier in the tx", + "* Must appear last in the tx", + "* CPI is forbidden", + "* Returns rent for ephemeral accounts created during `StartExecuteOrder`" + ], + "discriminator": [ + 115, + 42, + 20, + 93, + 121, + 84, + 178, + 83 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "marginfi_account" + ] + }, + { + "name": "marginfi_account", + "docs": [ + "The account owning the order" + ], + "writable": true, + "relations": [ + "order" + ] + }, + { + "name": "executor", + "docs": [ + "The executioner ☠️" + ], + "signer": true, + "relations": [ + "execute_record" + ] + }, + { + "name": "fee_recipient", + "writable": true + }, + { + "name": "order", + "writable": true, + "relations": [ + "execute_record" + ] + }, + { + "name": "execute_record", + "docs": [ + "This keeps track of the relevant state to be checked at the end of execution." + ], + "writable": true + }, + { + "name": "fee_state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + } + ], + "args": [] + }, + { + "name": "marginfi_account_end_rebalance", + "docs": [ + "(permissionless keeper) End an auto-rebalance. Re-checks dst >= src post-move, value", + "conservation, untouched balances, and health; the order persists. The keeper tip is escrowed", + "into the record and paid later via `settle_rebalance_tip`." + ], + "discriminator": [ + 47, + 225, + 163, + 216, + 213, + 214, + 225, + 155 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "marginfi_account" + ] + }, + { + "name": "marginfi_account", + "writable": true, + "relations": [ + "rebalance_order" + ] + }, + { + "name": "rebalance_order", + "writable": true + }, + { + "name": "rebalance_record", + "writable": true + }, + { + "name": "executor", + "writable": true, + "signer": true, + "relations": [ + "rebalance_record" + ] + }, + { + "name": "fee_pool", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 98, + 97, + 108, + 97, + 110, + 99, + 101, + 95, + 102, + 101, + 101, + 95, + 112, + 111, + 111, + 108 + ] + }, + { + "kind": "account", + "path": "marginfi_account" + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "marginfi_account_init_liq_record", + "docs": [ + "(permissionless) Initialize a liquidation record PDA for a marginfi account. The fee_payer", + "pays rent; the record is required for receivership liquidation." + ], + "discriminator": [ + 236, + 213, + 238, + 126, + 147, + 251, + 164, + 8 + ], + "accounts": [ + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "fee_payer", + "writable": true, + "signer": true + }, + { + "name": "liquidation_record", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 95, + 114, + 101, + 99, + 111, + 114, + 100 + ] + }, + { + "kind": "account", + "path": "marginfi_account" + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "marginfi_account_initialize", + "docs": [ + "Initialize a marginfi account for a given group. The account is a fresh keypair, and must", + "sign. If you are a CPI caller, consider using `marginfi_account_initialize_pda` instead, or", + "create the account manually and use `transfer_to_new_account` to gift it to the owner you", + "wish." + ], + "discriminator": [ + 43, + 78, + 61, + 255, + 148, + 52, + 249, + 154 + ], + "accounts": [ + { + "name": "marginfi_group" + }, + { + "name": "marginfi_account", + "writable": true, + "signer": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "fee_payer", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "marginfi_account_initialize_pda", + "docs": [ + "The same as `marginfi_account_initialize`, except the created marginfi account uses a PDA", + "(Program Derived Address)", + "", + "seeds:", + "- marginfi_group", + "- authority: The account authority (owner)", + "- account_index: A u16 value to allow multiple accounts per authority", + "- third_party_id: Optional u16 for third-party tagging. Seeds < PDA_FREE_THRESHOLD can be", + "used freely. For a dedicated seed used by just your program (via CPI), contact us." + ], + "discriminator": [ + 87, + 177, + 91, + 80, + 218, + 119, + 245, + 31 + ], + "accounts": [ + { + "name": "marginfi_group" + }, + { + "name": "marginfi_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 109, + 97, + 114, + 103, + 105, + 110, + 102, + 105, + 95, + 97, + 99, + 99, + 111, + 117, + 110, + 116 + ] + }, + { + "kind": "account", + "path": "marginfi_group" + }, + { + "kind": "account", + "path": "authority" + }, + { + "kind": "arg", + "path": "account_index" + }, + { + "kind": "arg", + "path": "third_party_id.unwrap_or(0)" + } + ] + } + }, + { + "name": "authority", + "signer": true + }, + { + "name": "fee_payer", + "writable": true, + "signer": true + }, + { + "name": "instructions_sysvar", + "docs": [ + "Instructions sysvar for CPI validation", + "" + ], + "address": "Sysvar1nstructions1111111111111111111111111" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "account_index", + "type": "u16" + }, + { + "name": "third_party_id", + "type": { + "option": "u16" + } + } + ] + }, + { + "name": "marginfi_account_keeper_close_order", + "docs": [ + "(permissionless keeper) Close an existing Order after the user account was closed, or it no", + "longer has the associated positions, or the user has executed", + "`marginfi_account_set_keeper_close_flags`. Keeper keeps the rent." + ], + "discriminator": [ + 128, + 114, + 71, + 46, + 194, + 71, + 186, + 106 + ], + "accounts": [ + { + "name": "marginfi_account", + "docs": [ + "marginfi account was closed.", + "The handler validates ownership and layout unless the account is already closed." + ], + "writable": true, + "relations": [ + "order" + ] + }, + { + "name": "fee_recipient", + "writable": true + }, + { + "name": "order", + "writable": true + } + ], + "args": [] + }, + { + "name": "marginfi_account_place_order", + "docs": [ + "(user) Create a new Order.", + "* bank_keys - Currently only two keys: the lending position and borrowing position in the", + "users's Balances for which the order is being placed", + "* trigger - the type of order (stop loss, take profit, or both), and the threshold at which", + "to trigger the order, in dollars" + ], + "discriminator": [ + 244, + 112, + 75, + 138, + 143, + 108, + 7, + 186 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "marginfi_account" + ] + }, + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "fee_payer", + "writable": true, + "signer": true + }, + { + "name": "authority", + "signer": true, + "relations": [ + "marginfi_account" + ] + }, + { + "name": "order", + "writable": true + }, + { + "name": "fee_state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "global_fee_wallet", + "writable": true, + "relations": [ + "fee_state" + ] + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "bank_keys", + "type": { + "vec": "pubkey" + } + }, + { + "name": "trigger", + "type": { + "defined": { + "name": "OrderTrigger" + } + } + } + ] + }, + { + "name": "marginfi_account_place_rebalance_order", + "docs": [ + "(user) Create a persistent same-mint auto-rebalance order: keep `mint` in the highest-yield", + "bank among `allowed_banks`. Persists until cancelled." + ], + "discriminator": [ + 161, + 48, + 11, + 214, + 229, + 132, + 192, + 149 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "marginfi_account" + ] + }, + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "authority", + "signer": true, + "relations": [ + "marginfi_account" + ] + }, + { + "name": "mint" + }, + { + "name": "rebalance_order", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 98, + 97, + 108, + 97, + 110, + 99, + 101, + 95, + 111, + 114, + 100, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "marginfi_account" + }, + { + "kind": "account", + "path": "mint" + } + ] + } + }, + { + "name": "fee_payer", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "allowed_banks", + "type": { + "vec": "pubkey" + } + }, + { + "name": "min_improvement", + "type": { + "option": { + "defined": { + "name": "WrappedI80F48" + } + } + } + }, + { + "name": "cooldown_seconds", + "type": { + "option": "u64" + } + }, + { + "name": "amount", + "type": { + "option": "u64" + } + }, + { + "name": "keeper_tip", + "type": { + "option": "u64" + } + } + ] + }, + { + "name": "marginfi_account_set_freeze", + "docs": [ + "Freeze a marginfi account with the fast admin, or unfreeze it with the slow governance", + "admin. A frozen account can only be operated on by the slow governance admin." + ], + "discriminator": [ + 199, + 179, + 231, + 30, + 138, + 247, + 110, + 227 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "marginfi_account" + ] + }, + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "admin", + "docs": [ + "Fast admin when freezing; governance admin when unfreezing. The legacy account name is", + "retained for instruction compatibility." + ], + "signer": true + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "frozen", + "type": "bool" + } + ] + }, + { + "name": "marginfi_account_set_keeper_close_flags", + "docs": [ + "(user) Purge flags from some balances, enabling a Keeper to call", + "`marginfi_account_keeper_close_order` on associated Orders. Typically, use", + "`marginfi_account_close_order` instead if trying to close an Order." + ], + "discriminator": [ + 82, + 163, + 165, + 222, + 212, + 255, + 33, + 210 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "marginfi_account" + ] + }, + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "bank_keys_opt", + "type": { + "option": { + "vec": "pubkey" + } + } + } + ] + }, + { + "name": "marginfi_account_settle_rebalance_tip", + "docs": [ + "(permissionless) Settle a rebalance's escrowed keeper tip after the settlement delay. Pays the", + "recorded keeper only if the destinations realized more yield than the sources over the window", + "(defeats cross-tx rate manipulation); otherwise refunds the tip to the fee pool. Closes the", + "record, returning its rent to the recorded keeper." + ], + "discriminator": [ + 198, + 13, + 185, + 127, + 7, + 105, + 88, + 182 + ], + "accounts": [ + { + "name": "group" + }, + { + "name": "marginfi_account", + "docs": [ + "record's `has_one` pins this key; `group` is pinned by the recorded banks, which must belong", + "to it." + ], + "relations": [ + "rebalance_record" + ] + }, + { + "name": "rebalance_record", + "writable": true + }, + { + "name": "executor", + "docs": [ + "`record.executor`." + ], + "writable": true + }, + { + "name": "fee_pool", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 98, + 97, + 108, + 97, + 110, + 99, + 101, + 95, + 102, + 101, + 101, + 95, + 112, + 111, + 111, + 108 + ] + }, + { + "kind": "account", + "path": "marginfi_account" + } + ] + } + }, + { + "name": "caller", + "docs": [ + "The permissionless caller; pays the tx." + ], + "writable": true, + "signer": true + } + ], + "args": [] + }, + { + "name": "marginfi_account_start_execute_order", + "docs": [ + "(permissionless keeper) Begin Order execution", + "* Enables the Keeper to withdraw/repay associated positions until the end of the tx", + "* Only one `StartExecuteOrder` is allowed per tx", + "* Must appear before `EndExecuteOrder` in the tx, and before any instructions except certain", + "allowed ones (compute budget, kamino refresh, etc)", + "* `EndExecuteOrder` must also appear in the tx", + "* CPI is forbidden", + "* Costs a small amount of rent, which is returned at the end of the tx, make sure you have", + "enough SOL to start the tx." + ], + "discriminator": [ + 1, + 70, + 140, + 134, + 183, + 29, + 208, + 224 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "marginfi_account" + ] + }, + { + "name": "marginfi_account", + "docs": [ + "The account owning the order" + ], + "writable": true, + "relations": [ + "order" + ] + }, + { + "name": "fee_payer", + "writable": true, + "signer": true + }, + { + "name": "executor", + "docs": [ + "This account will have the authority to withdraw/repay as if they are the user authority", + "until the end of the tx.", + "" + ] + }, + { + "name": "order", + "writable": true + }, + { + "name": "execute_record", + "docs": [ + "This keeps track of the relevant state to be checked at the end of execution." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 101, + 120, + 101, + 99, + 117, + 116, + 101, + 95, + 111, + 114, + 100, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "order" + } + ] + } + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "marginfi_account_start_rebalance", + "docs": [ + "(permissionless keeper) Begin an auto-rebalance. `moves` declares each value relocation as", + "`(src_index, dst_index, amount)` over the banks passed in remaining_accounts; validates", + "same-mint, allowed venues, and every move's dst APR > src + min_improvement. Opens the", + "start/end sandwich; `end_rebalance` must be the last ix; CPI forbidden." + ], + "discriminator": [ + 251, + 122, + 91, + 161, + 219, + 98, + 5, + 236 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "marginfi_account" + ] + }, + { + "name": "marginfi_account", + "writable": true, + "relations": [ + "rebalance_order" + ] + }, + { + "name": "rebalance_order" + }, + { + "name": "executor" + }, + { + "name": "rebalance_record", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 98, + 97, + 108, + 97, + 110, + 99, + 101, + 95, + 114, + 101, + 99, + 111, + 114, + 100 + ] + }, + { + "kind": "account", + "path": "marginfi_account" + }, + { + "kind": "arg", + "path": "execution_seq" + } + ] + } + }, + { + "name": "fee_payer", + "writable": true, + "signer": true + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "moves", + "type": { + "vec": { + "defined": { + "name": "RebalanceMove" + } + } + } + }, + { + "name": "execution_seq", + "type": "u64" + } + ] + }, + { + "name": "marginfi_account_tag_liq_record", + "docs": [ + "(permissionless) Tag an unhealthy account, growing the allowed liquidation premium over", + "time. Calling it on an account that is healthy again clears its existing tag." + ], + "discriminator": [ + 12, + 189, + 215, + 239, + 231, + 122, + 220, + 158 + ], + "accounts": [ + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "group", + "relations": [ + "marginfi_account" + ] + } + ], + "args": [] + }, + { + "name": "marginfi_account_top_up_rebalance_fee_pool", + "docs": [ + "(permissionless) Fund an account's rebalance fee pool with SOL, used to pay keeper tips." + ], + "discriminator": [ + 83, + 123, + 125, + 204, + 200, + 119, + 247, + 91 + ], + "accounts": [ + { + "name": "marginfi_account" + }, + { + "name": "fee_pool", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 98, + 97, + 108, + 97, + 110, + 99, + 101, + 95, + 102, + 101, + 101, + 95, + 112, + 111, + 111, + 108 + ] + }, + { + "kind": "account", + "path": "marginfi_account" + } + ] + } + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "marginfi_account_update_emissions_destination_account", + "docs": [ + "(account authority) Set the wallet whose canonical ATA will receive off-chain emissions." + ], + "discriminator": [ + 73, + 185, + 162, + 201, + 111, + 24, + 116, + 185 + ], + "accounts": [ + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "destination_account", + "docs": [ + "the canonical ATA for each emissions mint." + ] + } + ], + "args": [] + }, + { + "name": "marginfi_account_update_rebalance_order", + "docs": [ + "(user) Update an existing auto-rebalance order's allowlist and/or policy in place; `None`", + "fields are left unchanged." + ], + "discriminator": [ + 175, + 230, + 251, + 122, + 168, + 128, + 207, + 142 + ], + "accounts": [ + { + "name": "marginfi_account", + "relations": [ + "rebalance_order" + ] + }, + { + "name": "authority", + "signer": true, + "relations": [ + "marginfi_account", + "rebalance_order" + ] + }, + { + "name": "rebalance_order", + "writable": true + } + ], + "args": [ + { + "name": "allowed_banks", + "type": { + "option": { + "vec": "pubkey" + } + } + }, + { + "name": "min_improvement", + "type": { + "option": { + "defined": { + "name": "WrappedI80F48" + } + } + } + }, + { + "name": "cooldown_seconds", + "type": { + "option": "u64" + } + }, + { + "name": "amount", + "type": { + "option": "u64" + } + }, + { + "name": "keeper_tip", + "type": { + "option": "u64" + } + } + ] + }, + { + "name": "marginfi_account_withdraw_rebalance_fee_pool", + "docs": [ + "(user) Withdraw SOL from an account's rebalance fee pool back to the authority." + ], + "discriminator": [ + 121, + 157, + 246, + 242, + 240, + 63, + 254, + 16 + ], + "accounts": [ + { + "name": "marginfi_account" + }, + { + "name": "authority", + "signer": true, + "relations": [ + "marginfi_account" + ] + }, + { + "name": "fee_pool", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 98, + 97, + 108, + 97, + 110, + 99, + 101, + 95, + 102, + 101, + 101, + 95, + 112, + 111, + 111, + 108 + ] + }, + { + "kind": "account", + "path": "marginfi_account" + } + ] + } + }, + { + "name": "destination", + "writable": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "marginfi_group_configure", + "docs": [ + "Configure fast-admin group roles. `None` leaves a field unchanged.", + "", + "Note: `new_emissions_admin` is deprecated and currently has no on-chain effect." + ], + "discriminator": [ + 62, + 199, + 81, + 78, + 33, + 13, + 236, + 61 + ], + "accounts": [ + { + "name": "marginfi_group", + "writable": true + }, + { + "name": "admin", + "signer": true, + "relations": [ + "marginfi_group" + ] + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "new_admin", + "type": { + "option": "pubkey" + } + }, + { + "name": "new_curve_admin", + "type": { + "option": "pubkey" + } + }, + { + "name": "new_limit_admin", + "type": { + "option": "pubkey" + } + }, + { + "name": "new_flow_admin", + "type": { + "option": "pubkey" + } + }, + { + "name": "new_emissions_admin", + "type": { + "option": "pubkey" + } + }, + { + "name": "new_metadata_admin", + "type": { + "option": "pubkey" + } + } + ] + }, + { + "name": "marginfi_group_configure_gov", + "docs": [ + "Configure slow, timelocked governance group roles, the fast admin, and e-mode leverage", + "caps. `None` leaves a field unchanged.", + "Same-asset emode leverage is disabled by configuring both init and maint leverage to `1`;", + "values below `1`, including `0`, are invalid." + ], + "discriminator": [ + 3, + 33, + 122, + 31, + 239, + 33, + 35, + 5 + ], + "accounts": [ + { + "name": "marginfi_group", + "writable": true + }, + { + "name": "governance_admin", + "signer": true, + "relations": [ + "marginfi_group" + ] + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "new_admin", + "type": { + "option": "pubkey" + } + }, + { + "name": "new_emode_admin", + "type": { + "option": "pubkey" + } + }, + { + "name": "new_risk_admin", + "type": { + "option": "pubkey" + } + }, + { + "name": "emode_max_init_leverage", + "type": { + "option": { + "defined": { + "name": "WrappedI80F48" + } + } + } + }, + { + "name": "emode_max_maint_leverage", + "type": { + "option": { + "defined": { + "name": "WrappedI80F48" + } + } + } + }, + { + "name": "same_asset_emode_init_leverage", + "type": { + "option": { + "defined": { + "name": "WrappedI80F48" + } + } + } + }, + { + "name": "same_asset_emode_maint_leverage", + "type": { + "option": { + "defined": { + "name": "WrappedI80F48" + } + } + } + } + ] + }, + { + "name": "marginfi_group_initialize", + "docs": [ + "(admin only) Initialize a new marginfi group. The signer becomes the group admin." + ], + "discriminator": [ + 255, + 67, + 67, + 26, + 94, + 31, + 34, + 20 + ], + "accounts": [ + { + "name": "marginfi_group", + "writable": true, + "signer": true + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "fee_state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "marginfi_group_set_governance_admin", + "docs": [ + "Bootstrap or rotate the slow governance admin. When the stored value is zero on a resized", + "legacy group, the fast admin may bootstrap it once; thereafter only the current governance", + "admin may rotate it." + ], + "discriminator": [ + 87, + 57, + 22, + 85, + 152, + 57, + 23, + 75 + ], + "accounts": [ + { + "name": "marginfi_group", + "writable": true + }, + { + "name": "signer", + "signer": true + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "new_governance_admin", + "type": "pubkey" + } + ] + }, + { + "name": "monitor_archive_initialize", + "docs": [ + "(snapshot manager only) Initialize the monitor snapshot archive account metadata." + ], + "discriminator": [ + 5, + 144, + 117, + 234, + 36, + 188, + 147, + 216 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "archive", + "docs": [ + "`MAX_ACCOUNT_DATA_LEN`. `MintSnapshotsArchive::initialize` rejects it unless it is", + "large enough and its discriminator is still zero." + ], + "writable": true + } + ], + "args": [ + { + "name": "snapshot_manager", + "type": "pubkey" + } + ] + }, + { + "name": "monitor_archive_upsert_batch", + "docs": [ + "(snapshot manager only) Upsert a batch of monitor snapshots into the archive account.", + "", + "Mints are sourced positionally from `remaining_accounts`: `updates[i]` maps to", + "`remaining_accounts[i]`." + ], + "discriminator": [ + 203, + 39, + 50, + 74, + 141, + 37, + 14, + 248 + ], + "accounts": [ + { + "name": "snapshot_manager", + "docs": [ + "Dedicated signer for monitor snapshot archive writes. Must match", + "`ArchiveMeta.authority`." + ], + "signer": true + }, + { + "name": "archive", + "docs": [ + "[8-byte discriminator][ArchiveMeta][index_map][payload]." + ], + "writable": true + } + ], + "args": [ + { + "name": "updates", + "type": { + "vec": { + "defined": { + "name": "SnapshotUpdateInput" + } + } + } + } + ] + }, + { + "name": "panic_pause", + "docs": [ + "(global_fee_admin or pause_delegate_admin only) Pause the protocol. Auto-expires after 6", + "hours. Limited to 3 pauses per day and 4 consecutive pauses." + ], + "discriminator": [ + 76, + 164, + 123, + 25, + 4, + 43, + 79, + 165 + ], + "accounts": [ + { + "name": "pause_authority", + "docs": [ + "Global fee admin or the dedicated pause delegate admin." + ], + "signer": true + }, + { + "name": "fee_state", + "docs": [ + "Global fee state account containing the panic state" + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "panic_unpause", + "docs": [ + "(global_fee_admin only) Unpause the protocol before auto-expiry." + ], + "discriminator": [ + 236, + 107, + 194, + 242, + 99, + 51, + 121, + 128 + ], + "accounts": [ + { + "name": "global_fee_admin", + "docs": [ + "Global fee admin only." + ], + "writable": true, + "signer": true, + "relations": [ + "fee_state" + ] + }, + { + "name": "fee_state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "panic_unpause_permissionless", + "docs": [ + "(permissionless) Unpause the protocol when pause time has expired" + ], + "discriminator": [ + 245, + 139, + 50, + 159, + 213, + 62, + 91, + 248 + ], + "accounts": [ + { + "name": "fee_state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + } + ], + "args": [] + }, + { + "name": "propagate_fee_state", + "docs": [ + "(Permissionless) Force any group to adopt the current FeeState settings" + ], + "discriminator": [ + 64, + 3, + 166, + 194, + 129, + 21, + 101, + 155 + ], + "accounts": [ + { + "name": "fee_state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "marginfi_group", + "docs": [ + "Any group, this ix is permisionless and can propagate the fee to any group" + ], + "writable": true + } + ], + "args": [] + }, + { + "name": "propagate_kamino_market_emergency", + "docs": [ + "(permissionless) Copy the emergency flag of a Kamino lending market onto a bank in that", + "market. While set, the bank backs no new borrowing, exactly as a bank on a reserve in", + "emergency mode does. Clearing the flag works the same way, once Kamino resumes the market." + ], + "discriminator": [ + 252, + 182, + 246, + 73, + 108, + 118, + 102, + 142 + ], + "accounts": [ + { + "name": "reserve", + "docs": [ + "The reserve `bank` deposits into. Read only to reach its market." + ] + }, + { + "name": "lending_market", + "docs": [ + "The market that owns `reserve`, and the source of the propagated flag." + ] + }, + { + "name": "bank", + "writable": true + } + ], + "args": [] + }, + { + "name": "propagate_staked_settings", + "docs": [ + "(permissionless) Propagate updated staked settings to a staked collateral bank." + ], + "discriminator": [ + 210, + 30, + 152, + 69, + 130, + 99, + 222, + 170 + ], + "accounts": [ + { + "name": "marginfi_group", + "relations": [ + "staked_settings" + ] + }, + { + "name": "staked_settings" + }, + { + "name": "bank", + "writable": true + } + ], + "args": [] + }, + { + "name": "purge_deleverage_balance", + "docs": [ + "(risk admin only) Purge a user's lending balance on a bank being sunset, without paying the", + "user anything. Only usable after all the debt has been settled on a bank in deleveraging", + "mode, i.e. `TOKENLESS_REPAYMENTS_ALLOWED` and `TOKENLESS_REPAYMENTS_COMPLETE`. Used to clear", + "abandoned lending positions in a now-worthless bank so it can be closed via", + "`lending_pool_close_bank`." + ], + "discriminator": [ + 132, + 187, + 25, + 149, + 181, + 59, + 253, + 136 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "marginfi_account", + "bank" + ] + }, + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "risk_admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "bank", + "writable": true + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "resize_global_fee_state", + "docs": [ + "(permissionless) Resize the fee-state account to the v2 layout size; `payer` funds the", + "added rent." + ], + "discriminator": [ + 141, + 111, + 97, + 79, + 111, + 143, + 77, + 159 + ], + "accounts": [ + { + "name": "fee_state", + "docs": [ + "Not an AccountLoader so an undersized fee state can still be resized under the future", + "(larger-struct) program." + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "payer", + "docs": [ + "Funds the rent for the added account space." + ], + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "solend_deposit", + "docs": [ + "(user) Deposit into a Solend reserve through a marginfi account", + "* amount - in the underlying token (e.g., USDC), in native decimals" + ], + "discriminator": [ + 56, + 127, + 176, + 148, + 12, + 25, + 3, + 24 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "marginfi_account", + "bank" + ] + }, + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "bank", + "writable": true + }, + { + "name": "signer_token_account", + "docs": [ + "Owned by authority, the source account for the token deposit." + ], + "writable": true + }, + { + "name": "liquidity_vault_authority", + "docs": [ + "The bank's liquidity vault authority, which owns the Solend obligation" + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "liquidity_vault", + "docs": [ + "Used as an intermediary to deposit tokens into Solend" + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "integration_acc_2", + "docs": [ + "The Solend obligation account" + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "lending_market" + }, + { + "name": "lending_market_authority", + "docs": [ + "Derived from the lending market" + ] + }, + { + "name": "integration_acc_1", + "docs": [ + "The Solend reserve that holds liquidity" + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "mint", + "docs": [ + "Bank's liquidity token mint (e.g., USDC)" + ], + "relations": [ + "bank" + ] + }, + { + "name": "reserve_liquidity_supply", + "docs": [ + "Reserve's liquidity supply SPL Token account" + ], + "writable": true + }, + { + "name": "reserve_collateral_mint", + "docs": [ + "The reserve's mint for cTokens" + ], + "writable": true + }, + { + "name": "reserve_collateral_supply", + "docs": [ + "The reserve's collateral supply account (where cTokens are stored)" + ], + "writable": true + }, + { + "name": "user_collateral", + "docs": [ + "The user's destination for cTokens (collateral). This is a temporary account owned by", + "liquidity_vault_authority that will hold cTokens between deposit and obligation update." + ], + "writable": true + }, + { + "name": "pyth_price", + "docs": [ + "Oracle accounts - required by Solend even if not actively used" + ] + }, + { + "name": "switchboard_feed" + }, + { + "name": "solend_program", + "address": "So1endDq2YkqhipRh3WViPa8hdiSpxWy6z3Z6tMCpAo" + }, + { + "name": "token_program" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "solend_init_obligation", + "docs": [ + "(permissionless) Initialize a Solend obligation for a marginfi bank", + "Requires a minimum deposit to ensure the obligation remains active", + "* amount - minimum deposit amount (at least 10 units) in native decimals" + ], + "discriminator": [ + 81, + 96, + 123, + 149, + 218, + 116, + 235, + 196 + ], + "accounts": [ + { + "name": "fee_payer", + "docs": [ + "Pays to init the obligation and pays a nominal amount to ensure the obligation has a", + "non-zero balance." + ], + "writable": true, + "signer": true + }, + { + "name": "bank" + }, + { + "name": "signer_token_account", + "docs": [ + "The fee payer must provide a nominal amount of bank tokens so the obligation is not empty.", + "This amount is irrecoverable and will prevent the obligation from ever being closed." + ], + "writable": true + }, + { + "name": "liquidity_vault_authority", + "docs": [ + "The liquidity vault authority (PDA that will own the Solend obligation)" + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "liquidity_vault", + "docs": [ + "Used as an intermediary to deposit a nominal amount of token into the obligation." + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "integration_acc_2", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 111, + 108, + 101, + 110, + 100, + 95, + 111, + 98, + 108, + 105, + 103, + 97, + 116, + 105, + 111, + 110 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + }, + "relations": [ + "bank" + ] + }, + { + "name": "lending_market" + }, + { + "name": "lending_market_authority", + "docs": [ + "Derived from the lending market" + ] + }, + { + "name": "integration_acc_1", + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "mint", + "docs": [ + "Bank's liquidity token mint (e.g., USDC)" + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "reserve_liquidity_supply", + "writable": true + }, + { + "name": "reserve_collateral_mint", + "docs": [ + "The reserve's mint for cTokens" + ], + "writable": true + }, + { + "name": "reserve_collateral_supply", + "docs": [ + "The reserve's collateral supply account (where cTokens are stored)" + ], + "writable": true + }, + { + "name": "user_collateral", + "docs": [ + "The user's destination for cTokens (collateral). This is a temporary account owned by", + "liquidity_vault_authority that will hold cTokens between deposit and obligation update." + ], + "writable": true + }, + { + "name": "pyth_price", + "docs": [ + "Oracle accounts - required by Solend even if not actively used" + ] + }, + { + "name": "switchboard_feed" + }, + { + "name": "solend_program", + "address": "So1endDq2YkqhipRh3WViPa8hdiSpxWy6z3Z6tMCpAo" + }, + { + "name": "token_program" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "solend_withdraw", + "docs": [ + "(user) Withdraw from a Solend reserve through a marginfi account", + "* amount - in collateral tokens (cTokens), in native decimals", + "* if group rate limits are enabled, include the withdrawn bank's oracle group in", + "`remaining_accounts`", + "* withdraw_all - withdraw entire position if true" + ], + "discriminator": [ + 238, + 144, + 170, + 199, + 21, + 72, + 155, + 36 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "marginfi_account", + "bank" + ] + }, + { + "name": "marginfi_account", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "bank", + "writable": true + }, + { + "name": "destination_token_account", + "docs": [ + "Token account that will receive the withdrawn tokens. Mint/owner are validated by the", + "SPL transfer; the caller controls the destination." + ], + "writable": true + }, + { + "name": "liquidity_vault_authority", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "liquidity_vault", + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "integration_acc_2", + "docs": [ + "The Solend obligation account" + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "lending_market", + "writable": true + }, + { + "name": "lending_market_authority", + "docs": [ + "Derived from the lending market" + ] + }, + { + "name": "integration_acc_1", + "docs": [ + "The Solend reserve that holds liquidity" + ], + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "mint", + "docs": [ + "Bank's liquidity token mint (e.g., USDC)" + ], + "relations": [ + "bank" + ] + }, + { + "name": "reserve_liquidity_supply", + "docs": [ + "Reserve's liquidity supply SPL Token account" + ], + "writable": true + }, + { + "name": "reserve_collateral_mint", + "docs": [ + "The reserve's mint for cTokens" + ], + "writable": true + }, + { + "name": "reserve_collateral_supply", + "docs": [ + "The reserve's collateral supply account (where cTokens are stored)" + ], + "writable": true + }, + { + "name": "user_collateral", + "docs": [ + "The user's destination for cTokens (collateral). This is a temporary account owned by", + "liquidity_vault_authority that holds cTokens." + ], + "writable": true + }, + { + "name": "solend_program", + "address": "So1endDq2YkqhipRh3WViPa8hdiSpxWy6z3Z6tMCpAo" + }, + { + "name": "token_program" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "withdraw_all", + "type": { + "option": "bool" + } + } + ] + }, + { + "name": "start_deleverage", + "docs": [ + "(risk_admin only) Begin forced deleverage on an account. Similar to start_liquidation but", + "does not require the account to be unhealthy." + ], + "discriminator": [ + 10, + 138, + 10, + 57, + 40, + 232, + 182, + 193 + ], + "accounts": [ + { + "name": "marginfi_account", + "docs": [ + "Account to deleverage" + ], + "writable": true + }, + { + "name": "liquidation_record", + "docs": [ + "The associated liquidation record PDA for the given `marginfi_account`" + ], + "writable": true, + "relations": [ + "marginfi_account" + ] + }, + { + "name": "group", + "relations": [ + "marginfi_account" + ] + }, + { + "name": "risk_admin", + "docs": [ + "The risk admin will have the authority to withdraw/repay as if they are the user authority", + "until the end of the tx." + ], + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "start_liquidation", + "docs": [ + "(permissionless) Begin receivership liquidation on an unhealthy account. Snapshots health", + "and marks the account in receivership. Must have `end_liquidation` as the last ix in the tx." + ], + "discriminator": [ + 244, + 93, + 90, + 214, + 192, + 166, + 191, + 21 + ], + "accounts": [ + { + "name": "marginfi_account", + "docs": [ + "Account under liquidation" + ], + "writable": true + }, + { + "name": "liquidation_record", + "docs": [ + "The associated liquidation record PDA for the given `marginfi_account`" + ], + "writable": true, + "relations": [ + "marginfi_account" + ] + }, + { + "name": "group", + "relations": [ + "marginfi_account" + ] + }, + { + "name": "liquidation_receiver", + "docs": [ + "This account will have the authority to withdraw/repay as if they are the user authority", + "until the end of the tx.", + "" + ] + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "super_admin_deposit", + "docs": [ + "(primary admin only) Deposit directly into a bank liquidity vault and raise", + "`asset_share_value` proportionally. No marginfi account is involved." + ], + "discriminator": [ + 241, + 189, + 199, + 17, + 207, + 225, + 64, + 75 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank" + ] + }, + { + "name": "admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "bank", + "writable": true + }, + { + "name": "admin_token_account", + "writable": true + }, + { + "name": "liquidity_vault", + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "token_program" + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "super_admin_withdraw", + "docs": [ + "(primary admin only) Withdraw directly from a bank liquidity vault and lower", + "`asset_share_value` proportionally. No marginfi account is involved." + ], + "discriminator": [ + 202, + 67, + 85, + 126, + 104, + 138, + 79, + 197 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank" + ] + }, + { + "name": "admin", + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "bank", + "writable": true + }, + { + "name": "destination_token_account", + "writable": true + }, + { + "name": "liquidity_vault_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 105, + 113, + 117, + 105, + 100, + 105, + 116, + 121, + 95, + 118, + 97, + 117, + 108, + 116, + 95, + 97, + 117, + 116, + 104 + ] + }, + { + "kind": "account", + "path": "bank" + } + ] + } + }, + { + "name": "liquidity_vault", + "writable": true, + "relations": [ + "bank" + ] + }, + { + "name": "token_program" + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "sync_indexer_flags", + "docs": [ + "(Permissionless) Batch-sync balance-derived indexer flags for existing accounts.", + "Pass MarginfiAccounts as writable remaining_accounts." + ], + "discriminator": [ + 171, + 146, + 145, + 43, + 190, + 175, + 9, + 32 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + } + ], + "args": [] + }, + { + "name": "transfer_to_new_account", + "docs": [ + "(account authority) Transfer all positions to a new account under a new authority. The old", + "account is disabled. Pays a flat SOL fee to the protocol." + ], + "discriminator": [ + 28, + 79, + 129, + 231, + 169, + 69, + 69, + 65 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "old_marginfi_account" + ] + }, + { + "name": "old_marginfi_account", + "writable": true + }, + { + "name": "new_marginfi_account", + "writable": true, + "signer": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "fee_payer", + "writable": true, + "signer": true + }, + { + "name": "new_authority" + }, + { + "name": "global_fee_wallet", + "writable": true + }, + { + "name": "fee_state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "transfer_to_new_account_pda", + "docs": [ + "(account authority) Same as `transfer_to_new_account` except the resulting account is a PDA", + "", + "seeds:", + "- marginfi_group", + "- authority: The account authority (owner)", + "- account_index: A u16 value to allow multiple accounts per authority", + "- third_party_id: Optional u16 for third-party tagging. Seeds < PDA_FREE_THRESHOLD can be", + "used freely. For a dedicated seed used by just your program (via CPI), contact us." + ], + "discriminator": [ + 172, + 210, + 224, + 220, + 146, + 212, + 253, + 49 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "old_marginfi_account" + ] + }, + { + "name": "old_marginfi_account", + "writable": true + }, + { + "name": "new_marginfi_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 109, + 97, + 114, + 103, + 105, + 110, + 102, + 105, + 95, + 97, + 99, + 99, + 111, + 117, + 110, + 116 + ] + }, + { + "kind": "account", + "path": "group" + }, + { + "kind": "account", + "path": "new_authority" + }, + { + "kind": "arg", + "path": "account_index" + }, + { + "kind": "arg", + "path": "third_party_id.unwrap_or(0)" + } + ] + } + }, + { + "name": "authority", + "signer": true + }, + { + "name": "fee_payer", + "writable": true, + "signer": true + }, + { + "name": "new_authority" + }, + { + "name": "global_fee_wallet", + "writable": true + }, + { + "name": "fee_state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 101, + 101, + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "instructions_sysvar", + "docs": [ + "Instructions sysvar for CPI validation" + ], + "address": "Sysvar1nstructions1111111111111111111111111" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "account_index", + "type": "u16" + }, + { + "name": "third_party_id", + "type": { + "option": "u16" + } + } + ] + }, + { + "name": "update_deleverage_withdrawals", + "docs": [ + "(delegate_flow_admin only) Update the deleverage daily withdraw outflow with", + "aggregated data. The delegate flow admin aggregates", + "`DeleverageWithdrawFlowEvent` events off-chain and calls this instruction at intervals." + ], + "discriminator": [ + 56, + 3, + 181, + 118, + 27, + 247, + 207, + 227 + ], + "accounts": [ + { + "name": "marginfi_group", + "writable": true + }, + { + "name": "delegate_flow_admin", + "signer": true, + "relations": [ + "marginfi_group" + ] + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "outflow_usd", + "type": "u32" + }, + { + "name": "update_seq", + "type": "u64" + }, + { + "name": "event_start_slot", + "type": "u64" + }, + { + "name": "event_end_slot", + "type": "u64" + } + ] + }, + { + "name": "update_group_rate_limiter", + "docs": [ + "(delegate_flow_admin only) Update the group rate limiter with aggregated", + "inflow/outflow. The delegate flow admin aggregates", + "`RateLimitFlowEvent` events off-chain, converts to USD, and calls this instruction at", + "intervals to update group rate limiter state." + ], + "discriminator": [ + 23, + 78, + 60, + 139, + 187, + 44, + 129, + 37 + ], + "accounts": [ + { + "name": "marginfi_group", + "writable": true + }, + { + "name": "delegate_flow_admin", + "signer": true, + "relations": [ + "marginfi_group" + ] + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "outflow_usd", + "type": { + "option": "u64" + } + }, + { + "name": "inflow_usd", + "type": { + "option": "u64" + } + }, + { + "name": "update_seq", + "type": "u64" + }, + { + "name": "event_start_slot", + "type": "u64" + }, + { + "name": "event_end_slot", + "type": "u64" + } + ] + }, + { + "name": "write_bank_metadata", + "docs": [ + "(metadata admin only) Write ticker/description for an initialized bank. The bank account", + "must exist; when its seed is on-chain, the canonical PDA is verified." + ], + "discriminator": [ + 147, + 78, + 81, + 133, + 129, + 138, + 233, + 59 + ], + "accounts": [ + { + "name": "group", + "relations": [ + "bank" + ] + }, + { + "name": "bank", + "docs": [ + "Must be initialized. The metadata-to-bank binding is enforced by `metadata.has_one = bank`,", + "and `bank.has_one = group` ties this bank to the admin's group." + ], + "relations": [ + "metadata" + ] + }, + { + "name": "metadata_admin", + "writable": true, + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "metadata", + "writable": true + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "ticker", + "type": { + "option": "bytes" + } + }, + { + "name": "description", + "type": { + "option": "bytes" + } + } + ] + }, + { + "name": "write_bank_metadata_pre_init", + "docs": [ + "(metadata admin only) Write ticker/description before bank initialization, for canonical", + "seeded banks only." + ], + "discriminator": [ + 224, + 124, + 22, + 73, + 60, + 209, + 80, + 170 + ], + "accounts": [ + { + "name": "group" + }, + { + "name": "bank_mint" + }, + { + "name": "bank", + "pda": { + "seeds": [ + { + "kind": "account", + "path": "group" + }, + { + "kind": "account", + "path": "bank_mint" + }, + { + "kind": "arg", + "path": "bank_seed" + } + ] + }, + "relations": [ + "metadata" + ] + }, + { + "name": "metadata_admin", + "writable": true, + "signer": true, + "relations": [ + "group" + ] + }, + { + "name": "metadata", + "writable": true + }, + { + "name": "instruction_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "bank_seed", + "type": "u64" + }, + { + "name": "ticker", + "type": { + "option": "bytes" + } + }, + { + "name": "description", + "type": { + "option": "bytes" + } + } + ] + } + ], + "accounts": [ + { + "name": "Bank", + "discriminator": [ + 142, + 49, + 166, + 242, + 50, + 66, + 97, + 188 + ] + }, + { + "name": "BankMetadata", + "discriminator": [ + 49, + 207, + 31, + 34, + 67, + 225, + 169, + 186 + ] + }, + { + "name": "ExecuteOrderRecord", + "discriminator": [ + 6, + 100, + 107, + 60, + 164, + 226, + 56, + 97 + ] + }, + { + "name": "FeeState", + "discriminator": [ + 63, + 224, + 16, + 85, + 193, + 36, + 235, + 220 + ] + }, + { + "name": "LiquidationRecord", + "discriminator": [ + 95, + 116, + 23, + 132, + 89, + 210, + 245, + 162 + ] + }, + { + "name": "MarginfiAccount", + "discriminator": [ + 67, + 178, + 130, + 109, + 126, + 114, + 28, + 42 + ] + }, + { + "name": "MarginfiGroup", + "discriminator": [ + 182, + 23, + 173, + 240, + 151, + 206, + 182, + 67 + ] + }, + { + "name": "Order", + "discriminator": [ + 134, + 173, + 223, + 185, + 77, + 86, + 28, + 51 + ] + }, + { + "name": "RebalanceOrder", + "discriminator": [ + 51, + 5, + 186, + 251, + 144, + 119, + 75, + 197 + ] + }, + { + "name": "RebalanceRecord", + "discriminator": [ + 190, + 69, + 228, + 114, + 34, + 217, + 70, + 102 + ] + }, + { + "name": "SameAssetEmodeRegistry", + "discriminator": [ + 222, + 21, + 195, + 149, + 193, + 72, + 219, + 31 + ] + }, + { + "name": "StakedSettings", + "discriminator": [ + 157, + 140, + 6, + 77, + 89, + 173, + 173, + 125 + ] + } + ], + "events": [ + { + "name": "AdminCloseAccountEvent", + "discriminator": [ + 166, + 92, + 180, + 81, + 158, + 251, + 225, + 73 + ] + }, + { + "name": "CircuitBreakerAutoBrokenEvent", + "discriminator": [ + 104, + 30, + 251, + 194, + 213, + 139, + 21, + 230 + ] + }, + { + "name": "CircuitBreakerClearedEvent", + "discriminator": [ + 97, + 244, + 85, + 48, + 246, + 155, + 29, + 219 + ] + }, + { + "name": "CircuitBreakerTrippedEvent", + "discriminator": [ + 112, + 68, + 182, + 85, + 54, + 184, + 4, + 134 + ] + }, + { + "name": "DeleverageEvent", + "discriminator": [ + 161, + 8, + 108, + 204, + 209, + 198, + 12, + 30 + ] + }, + { + "name": "DeleverageWithdrawFlowEvent", + "discriminator": [ + 109, + 90, + 139, + 200, + 10, + 204, + 84, + 176 + ] + }, + { + "name": "DriftClaimBadDebtEvent", + "discriminator": [ + 20, + 106, + 26, + 156, + 28, + 116, + 250, + 172 + ] + }, + { + "name": "EditStakedSettingsEvent", + "discriminator": [ + 29, + 58, + 155, + 191, + 75, + 220, + 145, + 206 + ] + }, + { + "name": "HealthPulseEvent", + "discriminator": [ + 183, + 159, + 218, + 110, + 61, + 220, + 65, + 1 + ] + }, + { + "name": "KeeperCloseOrderEvent", + "discriminator": [ + 46, + 152, + 11, + 174, + 92, + 157, + 77, + 64 + ] + }, + { + "name": "KeeperCloseRebalanceOrderEvent", + "discriminator": [ + 162, + 156, + 215, + 175, + 216, + 69, + 165, + 208 + ] + }, + { + "name": "LendingAccountBorrowEvent", + "discriminator": [ + 223, + 96, + 81, + 10, + 156, + 99, + 26, + 59 + ] + }, + { + "name": "LendingAccountDepositEvent", + "discriminator": [ + 161, + 54, + 237, + 217, + 105, + 248, + 122, + 151 + ] + }, + { + "name": "LendingAccountLiquidateEvent", + "discriminator": [ + 166, + 160, + 249, + 154, + 183, + 39, + 23, + 242 + ] + }, + { + "name": "LendingAccountPremiumSettledEvent", + "discriminator": [ + 4, + 26, + 72, + 83, + 55, + 79, + 238, + 25 + ] + }, + { + "name": "LendingAccountRepayEvent", + "discriminator": [ + 16, + 220, + 55, + 111, + 7, + 80, + 16, + 25 + ] + }, + { + "name": "LendingAccountWithdrawEvent", + "discriminator": [ + 3, + 220, + 148, + 243, + 33, + 249, + 54, + 88 + ] + }, + { + "name": "LendingPoolBankAccrueInterestEvent", + "discriminator": [ + 104, + 117, + 187, + 156, + 111, + 154, + 106, + 186 + ] + }, + { + "name": "LendingPoolBankCollectFeesEvent", + "discriminator": [ + 101, + 119, + 97, + 250, + 169, + 175, + 156, + 253 + ] + }, + { + "name": "LendingPoolBankConfigureEvent", + "discriminator": [ + 246, + 35, + 233, + 110, + 93, + 152, + 235, + 40 + ] + }, + { + "name": "LendingPoolBankConfigureFrozenEvent", + "discriminator": [ + 24, + 10, + 55, + 18, + 49, + 150, + 157, + 179 + ] + }, + { + "name": "LendingPoolBankConfigureOracleEvent", + "discriminator": [ + 119, + 140, + 110, + 253, + 150, + 64, + 210, + 62 + ] + }, + { + "name": "LendingPoolBankCreateEvent", + "discriminator": [ + 236, + 220, + 201, + 63, + 239, + 126, + 136, + 249 + ] + }, + { + "name": "LendingPoolBankHandleBankruptcyEvent", + "discriminator": [ + 166, + 77, + 41, + 140, + 36, + 94, + 10, + 57 + ] + }, + { + "name": "LendingPoolBankPremiumConfigureEvent", + "discriminator": [ + 147, + 142, + 111, + 159, + 48, + 210, + 62, + 226 + ] + }, + { + "name": "LendingPoolBankSetOraclePriceEvent", + "discriminator": [ + 92, + 180, + 117, + 175, + 131, + 24, + 159, + 141 + ] + }, + { + "name": "LendingPoolBankSetSameAssetEmodeEligibilityEvent", + "discriminator": [ + 186, + 247, + 119, + 107, + 251, + 215, + 15, + 79 + ] + }, + { + "name": "LendingPoolGroupPremiumConfigureEvent", + "discriminator": [ + 44, + 126, + 109, + 163, + 173, + 83, + 73, + 169 + ] + }, + { + "name": "LendingPoolPremiumFeesCollectedEvent", + "discriminator": [ + 81, + 224, + 49, + 3, + 197, + 4, + 10, + 84 + ] + }, + { + "name": "LendingPoolSuperAdminDepositEvent", + "discriminator": [ + 99, + 152, + 211, + 30, + 58, + 165, + 210, + 71 + ] + }, + { + "name": "LendingPoolSuperAdminWithdrawEvent", + "discriminator": [ + 107, + 168, + 232, + 181, + 144, + 161, + 252, + 37 + ] + }, + { + "name": "LiquidationReceiverEvent", + "discriminator": [ + 40, + 131, + 224, + 220, + 151, + 83, + 24, + 230 + ] + }, + { + "name": "LiquidationTagEvent", + "discriminator": [ + 81, + 203, + 83, + 137, + 115, + 26, + 217, + 86 + ] + }, + { + "name": "MarginfiAccountCloseOrderEvent", + "discriminator": [ + 158, + 34, + 122, + 98, + 23, + 146, + 229, + 212 + ] + }, + { + "name": "MarginfiAccountCloseRebalanceOrderEvent", + "discriminator": [ + 187, + 136, + 207, + 156, + 141, + 155, + 230, + 172 + ] + }, + { + "name": "MarginfiAccountCreateEvent", + "discriminator": [ + 183, + 5, + 117, + 104, + 122, + 199, + 68, + 51 + ] + }, + { + "name": "MarginfiAccountExecuteOrderEvent", + "discriminator": [ + 225, + 224, + 93, + 157, + 202, + 84, + 223, + 107 + ] + }, + { + "name": "MarginfiAccountFreezeEvent", + "discriminator": [ + 219, + 219, + 57, + 178, + 75, + 86, + 146, + 122 + ] + }, + { + "name": "MarginfiAccountPlaceOrderEvent", + "discriminator": [ + 1, + 105, + 79, + 28, + 142, + 242, + 99, + 145 + ] + }, + { + "name": "MarginfiAccountPlaceRebalanceOrderEvent", + "discriminator": [ + 136, + 247, + 221, + 216, + 15, + 232, + 108, + 141 + ] + }, + { + "name": "MarginfiAccountTransferToNewAccount", + "discriminator": [ + 59, + 105, + 171, + 110, + 223, + 136, + 80, + 89 + ] + }, + { + "name": "MarginfiAccountUpdateRebalanceOrderEvent", + "discriminator": [ + 128, + 90, + 140, + 155, + 175, + 56, + 233, + 99 + ] + }, + { + "name": "MarginfiGroupConfigureEvent", + "discriminator": [ + 241, + 104, + 172, + 167, + 41, + 195, + 199, + 170 + ] + }, + { + "name": "MarginfiGroupCreateEvent", + "discriminator": [ + 233, + 125, + 61, + 14, + 98, + 240, + 136, + 253 + ] + }, + { + "name": "RateLimitFlowEvent", + "discriminator": [ + 229, + 5, + 73, + 200, + 0, + 107, + 105, + 109 + ] + }, + { + "name": "RebalanceExecutedEvent", + "discriminator": [ + 114, + 34, + 215, + 49, + 130, + 101, + 33, + 2 + ] + }, + { + "name": "RebalanceFeePoolTopUpEvent", + "discriminator": [ + 180, + 200, + 130, + 239, + 91, + 99, + 253, + 49 + ] + }, + { + "name": "RebalanceFeePoolWithdrawEvent", + "discriminator": [ + 198, + 221, + 159, + 93, + 100, + 193, + 147, + 180 + ] + }, + { + "name": "RebalanceTipSettledEvent", + "discriminator": [ + 180, + 146, + 87, + 198, + 207, + 186, + 254, + 203 + ] + }, + { + "name": "SetGovernanceAdminEvent", + "discriminator": [ + 232, + 208, + 132, + 193, + 42, + 110, + 80, + 234 + ] + }, + { + "name": "SetKeeperCloseFlagsEvent", + "discriminator": [ + 193, + 230, + 93, + 128, + 117, + 87, + 96, + 21 + ] + } + ], + "errors": [ + { + "code": 6000, + "name": "InternalLogicError", + "msg": "Internal Marginfi logic error" + }, + { + "code": 6001, + "name": "BankNotFound", + "msg": "Invalid bank index" + }, + { + "code": 6002, + "name": "LendingAccountBalanceNotFound", + "msg": "Lending account balance not found" + }, + { + "code": 6003, + "name": "BankAssetCapacityExceeded", + "msg": "Bank deposit capacity exceeded" + }, + { + "code": 6004, + "name": "InvalidTransfer", + "msg": "Invalid transfer" + }, + { + "code": 6005, + "name": "MissingPythOrBankAccount", + "msg": "Missing Oracle, Bank, LST mint, or Sol Pool" + }, + { + "code": 6006, + "name": "MissingPythAccount", + "msg": "Missing Pyth account" + }, + { + "code": 6007, + "name": "MissingBankAccount", + "msg": "Missing Bank account" + }, + { + "code": 6008, + "name": "InvalidBankAccount", + "msg": "Invalid Bank account" + }, + { + "code": 6009, + "name": "RiskEngineInitRejected", + "msg": "RiskEngine rejected due to either bad health or stale oracles" + }, + { + "code": 6010, + "name": "LendingAccountBalanceSlotsFull", + "msg": "Lending account balance slots are full" + }, + { + "code": 6011, + "name": "BankAlreadyExists", + "msg": "Bank already exists" + }, + { + "code": 6012, + "name": "ZeroLiquidationAmount", + "msg": "Amount to liquidate must be positive" + }, + { + "code": 6013, + "name": "AccountNotBankrupt", + "msg": "Account is not bankrupt" + }, + { + "code": 6014, + "name": "BalanceNotBadDebt", + "msg": "Account balance is not bad debt" + }, + { + "code": 6015, + "name": "InvalidConfig", + "msg": "Invalid group config" + }, + { + "code": 6016, + "name": "BankPaused", + "msg": "Bank paused" + }, + { + "code": 6017, + "name": "BankReduceOnly", + "msg": "Bank is ReduceOnly mode" + }, + { + "code": 6018, + "name": "BankAccountNotFound", + "msg": "Bank is missing" + }, + { + "code": 6019, + "name": "OperationDepositOnly", + "msg": "Operation is deposit-only" + }, + { + "code": 6020, + "name": "OperationWithdrawOnly", + "msg": "Operation is withdraw-only" + }, + { + "code": 6021, + "name": "OperationBorrowOnly", + "msg": "Operation is borrow-only" + }, + { + "code": 6022, + "name": "OperationRepayOnly", + "msg": "Operation is repay-only" + }, + { + "code": 6023, + "name": "NoAssetFound", + "msg": "No asset found" + }, + { + "code": 6024, + "name": "NoLiabilityFound", + "msg": "No liability found" + }, + { + "code": 6025, + "name": "InvalidOracleSetup", + "msg": "Invalid oracle setup" + }, + { + "code": 6026, + "name": "IllegalUtilizationRatio", + "msg": "Invalid bank utilization ratio" + }, + { + "code": 6027, + "name": "BankLiabilityCapacityExceeded", + "msg": "Bank borrow cap exceeded" + }, + { + "code": 6028, + "name": "InvalidPrice", + "msg": "Invalid Price" + }, + { + "code": 6029, + "name": "IsolatedAccountIllegalState", + "msg": "Account can have only one liability when account is under isolated risk" + }, + { + "code": 6030, + "name": "EmissionsAlreadySetup", + "msg": "Emissions already setup" + }, + { + "code": 6031, + "name": "OracleNotSetup", + "msg": "Oracle is not set" + }, + { + "code": 6032, + "name": "InvalidSwitchboardDecimalConversion", + "msg": "Invalid switchboard decimal conversion" + }, + { + "code": 6033, + "name": "CannotCloseOutstandingEmissions", + "msg": "Cannot close balance because of outstanding emissions" + }, + { + "code": 6034, + "name": "EmissionsUpdateError", + "msg": "Update emissions error" + }, + { + "code": 6035, + "name": "AccountDisabled", + "msg": "Account disabled" + }, + { + "code": 6036, + "name": "AccountTempActiveBalanceLimitExceeded", + "msg": "Account can't temporarily open 3 balances, please close a balance first" + }, + { + "code": 6037, + "name": "AccountInFlashloan", + "msg": "Illegal action during flashloan" + }, + { + "code": 6038, + "name": "IllegalFlashloan", + "msg": "Illegal flashloan" + }, + { + "code": 6039, + "name": "IllegalFlag", + "msg": "Illegal flag" + }, + { + "code": 6040, + "name": "IllegalBalanceState", + "msg": "Illegal balance state" + }, + { + "code": 6041, + "name": "IllegalAccountAuthorityTransfer", + "msg": "Illegal account authority transfer" + }, + { + "code": 6042, + "name": "Unauthorized", + "msg": "Unauthorized" + }, + { + "code": 6043, + "name": "IllegalAction", + "msg": "Invalid account authority" + }, + { + "code": 6044, + "name": "T22MintRequired", + "msg": "Token22 Banks require mint account as first remaining account" + }, + { + "code": 6045, + "name": "InvalidFeeAta", + "msg": "Invalid ATA for global fee account" + }, + { + "code": 6046, + "name": "AddedStakedPoolManually", + "msg": "Use add pool permissionless instead" + }, + { + "code": 6047, + "name": "AssetTagMismatch", + "msg": "Staked SOL accounts can only deposit staked assets and borrow SOL" + }, + { + "code": 6048, + "name": "StakePoolValidationFailed", + "msg": "Stake pool validation failed: check the stake pool, mint, or sol pool" + }, + { + "code": 6049, + "name": "SwitchboardStalePrice", + "msg": "Switchboard oracle: stale price" + }, + { + "code": 6050, + "name": "PythPushStalePrice", + "msg": "Pyth Push oracle: stale price" + }, + { + "code": 6051, + "name": "WrongNumberOfOracleAccounts", + "msg": "Oracle error: wrong number of accounts" + }, + { + "code": 6052, + "name": "WrongOracleAccountKeys", + "msg": "Oracle error: wrong account keys" + }, + { + "code": 6053, + "name": "StakeOraclesDisabled", + "msg": "Stake oracles are temporarily disabled" + }, + { + "code": 6054, + "name": "AccountAlreadyTagged", + "msg": "Account is already tagged for liquidation" + }, + { + "code": 6055, + "name": "OracleMaxConfidenceExceeded", + "msg": "Oracle max confidence exceeded: try again later" + }, + { + "code": 6056, + "name": "PythPushInsufficientVerificationLevel", + "msg": "Pyth Push oracle: insufficient verification level" + }, + { + "code": 6057, + "name": "ZeroAssetPrice", + "msg": "Zero asset price" + }, + { + "code": 6058, + "name": "ZeroLiabilityPrice", + "msg": "Zero liability price" + }, + { + "code": 6059, + "name": "SwitchboardWrongAccountOwner", + "msg": "Switchboard oracle: wrong account owner" + }, + { + "code": 6060, + "name": "PythPushInvalidAccount", + "msg": "Pyth Push oracle: invalid account" + }, + { + "code": 6061, + "name": "SwitchboardInvalidAccount", + "msg": "Switchboard oracle: invalid account" + }, + { + "code": 6062, + "name": "MathError", + "msg": "Math error" + }, + { + "code": 6063, + "name": "InvalidEmissionsDestinationAccount", + "msg": "Invalid emissions destination account" + }, + { + "code": 6064, + "name": "SameAssetAndLiabilityBanks", + "msg": "Asset and liability bank cannot be the same" + }, + { + "code": 6065, + "name": "OverliquidationAttempt", + "msg": "Trying to withdraw more assets than available" + }, + { + "code": 6066, + "name": "NoLiabilitiesInLiabilityBank", + "msg": "Liability bank has no liabilities" + }, + { + "code": 6067, + "name": "AssetsInLiabilityBank", + "msg": "Liability bank has assets" + }, + { + "code": 6068, + "name": "HealthyAccount", + "msg": "Account is healthy and cannot be liquidated" + }, + { + "code": 6069, + "name": "ExhaustedLiability", + "msg": "Liability payoff too severe, exhausted liability" + }, + { + "code": 6070, + "name": "TooSeverePayoff", + "msg": "Liability payoff too severe, liability balance has assets" + }, + { + "code": 6071, + "name": "TooSevereLiquidation", + "msg": "Liquidation too severe, account above maintenance requirement" + }, + { + "code": 6072, + "name": "WorseHealthPostLiquidation", + "msg": "Liquidation would worsen account health" + }, + { + "code": 6073, + "name": "CostlyPositionLimitExceeded", + "msg": "Exceeded the maximum allowed integration or staked positions" + }, + { + "code": 6074, + "name": "MaxInitLeverageExceeded", + "msg": "Maximum initial leverage exceeded" + }, + { + "code": 6075, + "name": "BadEmodeConfig", + "msg": "The Emode config was invalid" + }, + { + "code": 6076, + "name": "PythPushInvalidWindowSize", + "msg": "TWAP window size does not match expected duration" + }, + { + "code": 6077, + "name": "InvalidFeesDestinationAccount", + "msg": "Invalid fees destination account" + }, + { + "code": 6078, + "name": "BankCannotClose", + "msg": "Banks cannot close when they have open positions or emissions outstanding" + }, + { + "code": 6079, + "name": "AccountAlreadyMigrated", + "msg": "Account already migrated" + }, + { + "code": 6080, + "name": "ProtocolPaused", + "msg": "Protocol is paused" + }, + { + "code": 6081, + "name": "MetadataTooLong", + "msg": "Metadata is too long" + }, + { + "code": 6082, + "name": "PauseLimitExceeded", + "msg": "Pause limit exceeded" + }, + { + "code": 6083, + "name": "ProtocolNotPaused", + "msg": "Protocol is not paused" + }, + { + "code": 6084, + "name": "BankKilledByBankruptcy", + "msg": "Bank killed by bankruptcy: bank shutdown and value of all holdings is zero" + }, + { + "code": 6085, + "name": "UnexpectedLiquidationState", + "msg": "Liquidation state issue. Check start before end, end last, and both unique" + }, + { + "code": 6086, + "name": "StartNotFirst", + "msg": "Liquidation start must be first instruction (other than compute program ixes)" + }, + { + "code": 6087, + "name": "StartRepeats", + "msg": "Only one liquidation event allowed per tx" + }, + { + "code": 6088, + "name": "EndNotLast", + "msg": "The end instruction must be the last ix in the tx" + }, + { + "code": 6089, + "name": "ForbiddenIx", + "msg": "Tried to call an instruction that is forbidden during liquidation" + }, + { + "code": 6090, + "name": "LiquidationPremiumTooHigh", + "msg": "Seized too much of the asset relative to liability repaid" + }, + { + "code": 6091, + "name": "NotAllowedInCPI", + "msg": "Start and end liquidation and flashloan must be top-level instructions" + }, + { + "code": 6092, + "name": "ZeroSupplyInStakePool", + "msg": "Stake pool supply is zero: cannot compute price" + }, + { + "code": 6093, + "name": "InvalidGroup", + "msg": "Invalid group: account constraint violated" + }, + { + "code": 6094, + "name": "InvalidLiquidityVault", + "msg": "Invalid liquidity vault: account constraint violated" + }, + { + "code": 6095, + "name": "InvalidLiquidationRecord", + "msg": "Invalid liquidation record: account constraint violated" + }, + { + "code": 6096, + "name": "InvalidLiquidationReceiver", + "msg": "Invalid liquidation receiver: account constraint violated" + }, + { + "code": 6097, + "name": "InvalidEmissionsMint", + "msg": "Invalid emissions mint: account constraint violated" + }, + { + "code": 6098, + "name": "InvalidMint", + "msg": "Invalid mint: account constraint violated" + }, + { + "code": 6099, + "name": "InvalidFeeWallet", + "msg": "Invalid fee wallet: account constraint violated" + }, + { + "code": 6100, + "name": "FixedOraclePriceNegative", + "msg": "Fixed oracle price must be zero or greater" + }, + { + "code": 6101, + "name": "DailyWithdrawalLimitExceeded", + "msg": "Daily withdrawal limit exceeded: try again later" + }, + { + "code": 6102, + "name": "ZeroWithdrawalLimit", + "msg": "Cannot set daily withdrawal limit to zero" + }, + { + "code": 6103, + "name": "AccountFrozen", + "msg": "Account is frozen by the group admin" + }, + { + "code": 6104, + "name": "DuplicateBalance", + "msg": "Cannot reference duplicate balances" + }, + { + "code": 6105, + "name": "InvalidBalanceCount", + "msg": "Invalid amount of balances referenced" + }, + { + "code": 6106, + "name": "LiquidatorOrderCloseNotAllowed", + "msg": "Liquidator not allowed to close order" + }, + { + "code": 6107, + "name": "OrderTriggerNotMet", + "msg": "Order trigger is yet to be met" + }, + { + "code": 6108, + "name": "UnexpectedOrderExecutionState", + "msg": "Order execution state issue. Check not in flashloan, disabled, etc" + }, + { + "code": 6109, + "name": "OrderLiabilityNotClosed", + "msg": "Order liability not closed" + }, + { + "code": 6110, + "name": "InvalidAssetOrLiabilitiesCount", + "msg": "Invalid asset or liabilities count" + }, + { + "code": 6111, + "name": "WorseHealthPostExecution", + "msg": "Account health can only worsen if account is healthy" + }, + { + "code": 6112, + "name": "InvalidOrderTakeProfitOrStopLoss", + "msg": "TP must be > 0, SL must be > 0 and TP > SL if both are set" + }, + { + "code": 6113, + "name": "InvalidSlippage", + "msg": "Max slippage must be less than 100%" + }, + { + "code": 6114, + "name": "OrderExecutionOverWithdrawal", + "msg": "Executor withdrew too much: slippage or max fee constraint violated" + }, + { + "code": 6115, + "name": "BankHourlyRateLimitExceeded", + "msg": "Bank hourly rate limit exceeded: try again later" + }, + { + "code": 6116, + "name": "BankDailyRateLimitExceeded", + "msg": "Bank daily rate limit exceeded: try again later" + }, + { + "code": 6117, + "name": "GroupHourlyRateLimitExceeded", + "msg": "Group hourly rate limit exceeded: try again later" + }, + { + "code": 6118, + "name": "GroupDailyRateLimitExceeded", + "msg": "Group daily rate limit exceeded: try again later" + }, + { + "code": 6119, + "name": "InvalidRateLimitPrice", + "msg": "Invalid rate limit price: pass oracle or pre-crank cache" + }, + { + "code": 6120, + "name": "GroupRateLimiterUpdateEmpty", + "msg": "Group rate limiter admin update must include inflow and/or outflow" + }, + { + "code": 6121, + "name": "GroupRateLimiterUpdateInvalidSlotRange", + "msg": "Group rate limiter admin update slot range is invalid" + }, + { + "code": 6122, + "name": "GroupRateLimiterUpdateFutureSlot", + "msg": "Group rate limiter admin update cannot reference future slots" + }, + { + "code": 6123, + "name": "GroupRateLimiterUpdateStale", + "msg": "Group rate limiter admin update is too stale" + }, + { + "code": 6124, + "name": "GroupRateLimiterUpdateOutOfOrderSlot", + "msg": "Group rate limiter admin update slot progression is out of order" + }, + { + "code": 6125, + "name": "GroupRateLimiterUpdateOutOfOrderSeq", + "msg": "Group rate limiter admin update sequence is out of order" + }, + { + "code": 6126, + "name": "DeleverageWithdrawalUpdateEmpty", + "msg": "Deleverage withdrawal admin update must include outflow" + }, + { + "code": 6127, + "name": "DeleverageWithdrawalUpdateInvalidSlotRange", + "msg": "Deleverage withdrawal admin update slot range is invalid" + }, + { + "code": 6128, + "name": "DeleverageWithdrawalUpdateFutureSlot", + "msg": "Deleverage withdrawal admin update cannot reference future slots" + }, + { + "code": 6129, + "name": "DeleverageWithdrawalUpdateStale", + "msg": "Deleverage withdrawal admin update is too stale" + }, + { + "code": 6130, + "name": "DeleverageWithdrawalUpdateOutOfOrderSlot", + "msg": "Deleverage withdrawal admin update slot progression is out of order" + }, + { + "code": 6131, + "name": "DeleverageWithdrawalUpdateOutOfOrderSeq", + "msg": "Deleverage withdrawal admin update sequence is out of order" + }, + { + "code": 6132, + "name": "UseSetOraclePrice", + "msg": "Use set_oracle_price instead" + }, + { + "code": 6133, + "name": "InvalidGlobalFeeWallet", + "msg": "Provided global fee wallet does not match group fee state cache" + }, + { + "code": 6134, + "name": "BankUninitialized", + "msg": "Bank has not completed one-time initialization" + }, + { + "code": 6135, + "name": "SlippageTooHigh", + "msg": "Max slippage exceeds the allowed cap" + }, + { + "code": 6136, + "name": "MarinadeStateValidationFailed", + "msg": "Marinade state validation failed" + }, + { + "code": 6137, + "name": "ExponentVaultValidationFailed", + "msg": "Exponent vault validation failed" + }, + { + "code": 6138, + "name": "InvalidPtStartPrice", + "msg": "PT start price must be in (0, 1]" + }, + { + "code": 6139, + "name": "StakePoolStale", + "msg": "Stake pool balance has not been updated recently enough" + }, + { + "code": 6140, + "name": "MixedBankConfigAuthority", + "msg": "Deprecated: bank configuration now uses explicit fast and governance instructions" + }, + { + "code": 6141, + "name": "InvalidGovernanceAdmin", + "msg": "Governance admin cannot be set to the default pubkey (all zeros); this would disable slow-authority operations" + }, + { + "code": 6142, + "name": "MixedGroupConfigAuthority", + "msg": "Deprecated: group configuration now uses explicit fast and governance instructions" + }, + { + "code": 6143, + "name": "InvalidFastBankOperationalState", + "msg": "Fast bank configuration may only make a risk-reducing operational-state transition" + }, + { + "code": 6144, + "name": "InvalidGovernanceBankOperationalState", + "msg": "Governance bank configuration may only transition a bank to Operational" + }, + { + "code": 6200, + "name": "WrongAssetTagForStandardInstructions", + "msg": "Wrong asset tag for standard instructions, expected DEFAULT, SOL, or STAKED asset tag" + }, + { + "code": 6201, + "name": "WrongAssetTagForKaminoInstructions", + "msg": "Wrong asset tag for Kamino instructions, expected KAMINO asset tag" + }, + { + "code": 6202, + "name": "CantAddPool", + "msg": "Cannot create a kamino bank with this instruction, use add_bank_kamino" + }, + { + "code": 6203, + "name": "KaminoReserveMintAddressMismatch", + "msg": "Kamino reserve mint address doesn't match the bank mint address" + }, + { + "code": 6204, + "name": "KaminoDepositFailed", + "msg": "Deposit failed: obligation deposit amount increase did not match the expected increase, left - actual, right - expected" + }, + { + "code": 6205, + "name": "KaminoWithdrawFailed", + "msg": "Withdraw failed: token vault increase did not match the expected increase, left - actual, right - expected" + }, + { + "code": 6206, + "name": "ReserveStale", + "msg": "Kamino Reserve data is stale - run refresh_reserve on kamino program first" + }, + { + "code": 6207, + "name": "InvalidObligationDepositCount", + "msg": "Kamino obligation must have exactly one active deposit, at index 0" + }, + { + "code": 6208, + "name": "ObligationDepositReserveMismatch", + "msg": "Kamino obligation deposit doesn't match the expected reserve" + }, + { + "code": 6209, + "name": "ObligationInitDepositInsufficient", + "msg": "Failed to meet minimum deposit amount requirement for init obligation" + }, + { + "code": 6210, + "name": "KaminoReserveValidationFailed", + "msg": "Kamino reserve validation failed" + }, + { + "code": 6211, + "name": "KaminoInvalidOracleSetup", + "msg": "Invalid oracle setup: only KaminoPythPush and KaminoSwitchboardPull are supported" + }, + { + "code": 6212, + "name": "MaxMaintLeverageExceeded", + "msg": "Maximum Maintenance leverage exceeded" + }, + { + "code": 6213, + "name": "InvalidKaminoReserve", + "msg": "Invalid Kamino reserve: account constraint violated" + }, + { + "code": 6214, + "name": "InvalidKaminoObligation", + "msg": "Invalid Kamino obligation: account constraint violated" + }, + { + "code": 6300, + "name": "DriftInvalidOracleSetup", + "msg": "Invalid oracle setup: only DriftPythPull and DriftSwitchboardPull are supported" + }, + { + "code": 6301, + "name": "DriftSpotMarketMintMismatch", + "msg": "Drift spot market mint does not match bank mint" + }, + { + "code": 6302, + "name": "WrongBankAssetTagForDriftOperation", + "msg": "Wrong bank asset tag for Drift operation" + }, + { + "code": 6303, + "name": "CantUseStandardOperationsOnDriftAssets", + "msg": "Cannot use standard operations on Drift assets" + }, + { + "code": 6304, + "name": "DriftSpotMarketValidationFailed", + "msg": "Drift spot market validation failed" + }, + { + "code": 6305, + "name": "DriftInvalidSpotPositions", + "msg": "Drift user has invalid spot positions (only first position can have balance)" + }, + { + "code": 6306, + "name": "DriftSpotPositionMarketMismatch", + "msg": "Drift spot position market does not match bank's configured market" + }, + { + "code": 6307, + "name": "DriftInvalidPositionType", + "msg": "Drift position has invalid balance type (must be deposit)" + }, + { + "code": 6308, + "name": "DriftScaledBalanceMismatch", + "msg": "Drift scaled balance change does not match expected amount" + }, + { + "code": 6309, + "name": "DriftWithdrawFailed", + "msg": "Drift withdrawal failed - token amount mismatch" + }, + { + "code": 6310, + "name": "DriftUserInitDepositInsufficient", + "msg": "Drift user initial deposit insufficient (minimum 10 units required)" + }, + { + "code": 6311, + "name": "InvalidDriftAccount", + "msg": "Invalid drift account" + }, + { + "code": 6312, + "name": "DriftAuthorityMismatch", + "msg": "Drift authority mismatch" + }, + { + "code": 6313, + "name": "DriftInvalidHarvestPositionIndex", + "msg": "Invalid harvest position index - must be between 2 and 7" + }, + { + "code": 6314, + "name": "DriftPositionEmpty", + "msg": "Drift position is empty" + }, + { + "code": 6315, + "name": "DriftInvalidBalanceType", + "msg": "Drift position has invalid balance type" + }, + { + "code": 6316, + "name": "DriftNoAdminDeposit", + "msg": "No admin deposits found in Drift positions 2-7 for this market" + }, + { + "code": 6317, + "name": "DriftHarvestSameMarket", + "msg": "Cannot harvest from the same market as the bank's main drift spot market" + }, + { + "code": 6318, + "name": "DriftBrickedAccount", + "msg": "Drift account bricked: too many active deposits from admin operations" + }, + { + "code": 6319, + "name": "DriftMissingRewardOracle", + "msg": "Drift reward oracle required when 2+ active deposits exist" + }, + { + "code": 6320, + "name": "DriftMissingRewardSpotMarket", + "msg": "Drift reward spot market required when 2+ active deposits exist" + }, + { + "code": 6321, + "name": "DriftMissingRewardAccounts", + "msg": "Drift account has admin deposits that require reward accounts to be provided" + }, + { + "code": 6322, + "name": "DriftSpotMarketStale", + "msg": "Drift spot market is stale, interest needs to be updated" + }, + { + "code": 6323, + "name": "InvalidDriftSpotMarket", + "msg": "Invalid Drift spot market: account constraint violated" + }, + { + "code": 6324, + "name": "InvalidDriftUser", + "msg": "Invalid Drift user: account constraint violated" + }, + { + "code": 6325, + "name": "InvalidDriftUserStats", + "msg": "Invalid Drift user stats: account constraint violated" + }, + { + "code": 6326, + "name": "DriftUnsupportedTokenDecimals", + "msg": "Drift cannot support tokens with more than 19 decimals" + }, + { + "code": 6400, + "name": "SolendInvalidOracleSetup", + "msg": "Invalid oracle setup: only SolendPythPull and SolendSwitchboardPull are supported" + }, + { + "code": 6401, + "name": "SolendReserveValidationFailed", + "msg": "Solend reserve validation failed" + }, + { + "code": 6402, + "name": "SolendObligationOwnerMismatch", + "msg": "Solend obligation owner mismatch" + }, + { + "code": 6403, + "name": "WrongBankAssetTagForSolendOperation", + "msg": "Wrong bank asset tag for Solend operation" + }, + { + "code": 6404, + "name": "CantUseStandardOperationsOnSolendAssets", + "msg": "Cannot use standard operations on Solend assets" + }, + { + "code": 6405, + "name": "SolendReserveMismatch", + "msg": "Solend reserve mismatch" + }, + { + "code": 6406, + "name": "SolendReserveMintMismatch", + "msg": "Solend reserve mint mismatch" + }, + { + "code": 6407, + "name": "SolendInvalidDepositPositions", + "msg": "Solend obligation has invalid deposits (only first position can have balance)" + }, + { + "code": 6408, + "name": "SolendDepositPositionReserveMismatch", + "msg": "Solend deposit position reserve does not match bank's configured reserve" + }, + { + "code": 6409, + "name": "SolendCTokenBalanceMismatch", + "msg": "Solend cToken balance change does not match expected amount" + }, + { + "code": 6410, + "name": "SolendWithdrawFailed", + "msg": "Solend withdrawal failed - token amount mismatch" + }, + { + "code": 6411, + "name": "SolendReserveStale", + "msg": "Solend reserve is stale" + }, + { + "code": 6412, + "name": "SolendDepositFailed", + "msg": "Solend deposit failed - collateral amount mismatch" + }, + { + "code": 6413, + "name": "InvalidSolendAccount", + "msg": "Invalid Solend account owner" + }, + { + "code": 6414, + "name": "InvalidSolendAccountVersion", + "msg": "Invalid Solend account version" + }, + { + "code": 6415, + "name": "InvalidSolendReserve", + "msg": "Invalid Solend reserve: account constraint violated" + }, + { + "code": 6416, + "name": "InvalidSolendObligation", + "msg": "Invalid Solend obligation: account constraint violated" + }, + { + "code": 6500, + "name": "JuplendInvalidOracleSetup", + "msg": "Invalid oracle setup: only JuplendPythPull and JuplendSwitchboardPull are supported" + }, + { + "code": 6501, + "name": "JuplendLendingValidationFailed", + "msg": "Juplend lending state validation failed" + }, + { + "code": 6502, + "name": "WrongBankAssetTagForJuplendOperation", + "msg": "Wrong bank asset tag for Juplend operation" + }, + { + "code": 6503, + "name": "CantUseStandardOperationsOnJuplendAssets", + "msg": "Cannot use standard operations on Juplend assets" + }, + { + "code": 6504, + "name": "JuplendLendingStale", + "msg": "Juplend lending state is stale" + }, + { + "code": 6505, + "name": "InvalidJuplendLending", + "msg": "Invalid Juplend lending: account constraint violated" + }, + { + "code": 6506, + "name": "JuplendLendingMintMismatch", + "msg": "Juplend lending mint mismatch" + }, + { + "code": 6507, + "name": "JuplendBankAlreadyActivated", + "msg": "Juplend bank is already activated" + }, + { + "code": 6508, + "name": "InvalidJuplendFTokenVault", + "msg": "Invalid Juplend fToken vault" + }, + { + "code": 6509, + "name": "JuplendDepositFailed", + "msg": "Juplend deposit failed" + }, + { + "code": 6510, + "name": "JuplendWithdrawFailed", + "msg": "Juplend withdraw failed" + }, + { + "code": 6511, + "name": "JuplendInitPositionDepositInsufficient", + "msg": "Juplend init position deposit insufficient" + }, + { + "code": 6512, + "name": "InvalidJuplendWithdrawIntermediaryAta", + "msg": "Invalid Juplend withdraw intermediary ATA" + }, + { + "code": 6513, + "name": "InvalidResize", + "msg": "Account is already at (or above) the target size" + }, + { + "code": 6600, + "name": "BankCircuitBreakerHalted", + "msg": "Bank is halted by oracle circuit breaker" + }, + { + "code": 6601, + "name": "CircuitBreakerAdminOnly", + "msg": "Action requires risk admin while bank is circuit-breaker halted" + }, + { + "code": 6602, + "name": "CircuitBreakerInvalidConfig", + "msg": "Invalid circuit breaker config" + }, + { + "code": 6603, + "name": "CircuitBreakerRequiresWarmCache", + "msg": "Circuit breaker cannot be enabled until the oracle price cache is warm (call pulse first)" + }, + { + "code": 6604, + "name": "CircuitBreakerPriceJump", + "msg": "Oracle price deviates too far from the circuit breaker reference; action rejected" + }, + { + "code": 6605, + "name": "DurableNonceNotAllowed", + "msg": "Durable nonce cannot be used for this instruction" + }, + { + "code": 6610, + "name": "PremiumEntryInvalid", + "msg": "Premium entry has a zero collateral or liability tag" + }, + { + "code": 6611, + "name": "PremiumMatrixFull", + "msg": "Too many premium entries for the group's capacity" + }, + { + "code": 6612, + "name": "InvalidPremiumAta", + "msg": "Premium ATA does not match the canonical ATA of the premium wallet" + }, + { + "code": 6613, + "name": "PremiumWalletNotSet", + "msg": "Premium wallet is not configured on the fee state" + }, + { + "code": 6614, + "name": "PremiumEntryNotFound", + "msg": "Premium (collateral, liability) pair is not in the matrix" + }, + { + "code": 6615, + "name": "PremiumSnapshotUnavailable", + "msg": "Premium rate cannot be computed (a collateral oracle failed); retry with valid oracles" + }, + { + "code": 6700, + "name": "RebalanceVenueUnsupported", + "msg": "Rebalance venue not supported for on-chain rate verification" + }, + { + "code": 6701, + "name": "RebalanceCooldown", + "msg": "Rebalance cooldown has not elapsed" + }, + { + "code": 6702, + "name": "RebalanceIncompleteMove", + "msg": "Rebalance moved no value" + }, + { + "code": 6703, + "name": "RebalanceNotImproving", + "msg": "Rebalance destination rate not better than source by the required margin" + }, + { + "code": 6704, + "name": "RebalanceOvershoot", + "msg": "Rebalance improvement did not survive the move's own market impact" + }, + { + "code": 6705, + "name": "RebalanceValueLeak", + "msg": "Rebalance leaked value beyond the allowed dust tolerance" + }, + { + "code": 6706, + "name": "RebalanceMintMismatch", + "msg": "Rebalance bank mint does not match the order mint" + }, + { + "code": 6707, + "name": "RebalanceBankNotAllowed", + "msg": "Rebalance bank not in the order's allowed venue set" + }, + { + "code": 6708, + "name": "RebalanceInvalidMinImprovement", + "msg": "Rebalance min improvement must be non-negative" + }, + { + "code": 6709, + "name": "RebalanceExceedsAmount", + "msg": "Rebalance moved more than the order's amount" + }, + { + "code": 6710, + "name": "RebalanceMalformedSandwich", + "msg": "Rebalance sandwich must contain exactly one start and one end instruction" + }, + { + "code": 6711, + "name": "RebalanceSettleTooEarly", + "msg": "Rebalance tip cannot be settled until the settlement delay has elapsed" + }, + { + "code": 6712, + "name": "RebalanceForeignAccountLeg", + "msg": "Rebalance deposit/withdraw legs must all act on the rebalanced marginfi account" + }, + { + "code": 6713, + "name": "RebalanceNoAllowlistPosition", + "msg": "Rebalance order requires a deposit in at least one allowed bank" + }, + { + "code": 6714, + "name": "RebalanceUntrackedBalance", + "msg": "Rebalance opened a balance outside the referenced bank set" + }, + { + "code": 6715, + "name": "RebalanceNotBestVenue", + "msg": "Rebalance passed over a higher-rate bank that still has deposit capacity" + }, + { + "code": 6716, + "name": "RebalanceStaleExecutionSeq", + "msg": "Rebalance execution sequence does not match the account's next value" + }, + { + "code": 6717, + "name": "RebalanceAllowlistLiability", + "msg": "Rebalance allowlist contains a bank the account owes into" + }, + { + "code": 6718, + "name": "RebalanceBankSourceAndDestination", + "msg": "Rebalance moves use a bank as both a source and a destination" + }, + { + "code": 6719, + "name": "RebalanceForeignBankLeg", + "msg": "Rebalance deposit/withdraw legs must all act on a bank the order allows" + }, + { + "code": 6720, + "name": "RebalanceTaggedBalanceSplit", + "msg": "Rebalance must move an order-tagged balance whole, alone, into an empty bank" + }, + { + "code": 6800, + "name": "ScopeInvalidAccount", + "msg": "Scope oracle account is not owned by the Scope program or is malformed" + }, + { + "code": 6801, + "name": "ScopeInvalidEntry", + "msg": "Scope entry is out of range, never refreshed, or dated in the future" + }, + { + "code": 6802, + "name": "ScopeStalePrice", + "msg": "Scope price is stale" + }, + { + "code": 6803, + "name": "UseConfigureBankOracleScope", + "msg": "Use lending_pool_configure_bank_oracle_scope; Scope requires an entry index" + } + ], + "types": [ + { + "name": "AccountEventHeader", + "type": { + "kind": "struct", + "fields": [ + { + "name": "signer", + "type": { + "option": "pubkey" + } + }, + { + "name": "marginfi_account", + "type": "pubkey" + }, + { + "name": "marginfi_account_authority", + "type": "pubkey" + }, + { + "name": "marginfi_group", + "type": "pubkey" + } + ] + } + }, + { + "name": "AdminCloseAccountEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "AccountEventHeader" + } + } + }, + { + "name": "global_fee_wallet", + "type": "pubkey" + } + ] + } + }, + { + "name": "Balance", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "active", + "docs": [ + "Whether this balance slot is in use (nonzero = active)" + ], + "type": "u8" + }, + { + "name": "bank_pk", + "docs": [ + "The bank this balance corresponds to" + ], + "type": "pubkey" + }, + { + "name": "bank_asset_tag", + "docs": [ + "Inherited from the bank when the position is first created and CANNOT BE CHANGED after that.", + "Note that all balances created before the addition of this feature use `ASSET_TAG_DEFAULT`" + ], + "type": "u8" + }, + { + "name": "tag", + "docs": [ + "Tag used by orders to reference this balance (0 means unused/unassigned).", + "A tag may also have a non-zero value while having no orders." + ], + "type": "u16" + }, + { + "name": "premium_rate_snapshot", + "docs": [ + "Collateral-weighted variable-borrow premium APR snapshot for this liability position,", + "encoded like interest-curve points via `milli_to_u32` (0-1000%). Recomputed by every", + "oracle-carrying ix (borrow, withdraw, liquidation, order end, `pulse_health`) but not", + "deposit/repay, which carry no oracles. 0 = no premium." + ], + "type": "u32" + }, + { + "name": "asset_shares", + "docs": [ + "The user's asset (deposit) shares in the bank. Multiply by `bank.asset_share_value` for", + "the token amount." + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "liability_shares", + "docs": [ + "The user's liability (borrow) shares in the bank. Multiply by `bank.liability_share_value`", + "for the token amount." + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "premium_outstanding", + "docs": [ + "Accrued (materialized) variable-borrow premium owed on this liability position, in native", + "token units. Settled (with real tokens) only on repay; written off on bankruptcy,", + "tokenless repayment, or a liability→asset flip." + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "last_update", + "docs": [ + "Unix timestamp (u64) of the last premium accrual (claim) for this position. Set at", + "balance creation and bumped on every `claim_premium`." + ], + "type": "u64" + }, + { + "name": "_padding", + "docs": [ + "Reserved for future use" + ], + "type": { + "array": [ + "u64", + 1 + ] + } + } + ] + } + }, + { + "name": "Bank", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "mint", + "docs": [ + "The SPL token mint this bank manages" + ], + "type": "pubkey" + }, + { + "name": "mint_decimals", + "docs": [ + "Number of decimals of the `mint`. Must be < 24." + ], + "type": "u8" + }, + { + "name": "group", + "docs": [ + "The `MarginfiGroup` this bank belongs to" + ], + "type": "pubkey" + }, + { + "name": "_pad0", + "type": { + "array": [ + "u8", + 7 + ] + } + }, + { + "name": "asset_share_value", + "docs": [ + "Monotonically increases as interest rate accumulates. For typical banks, a user's asset", + "value in token = (number of shares the user has * asset_share_value).", + "* A float (arbitrary decimals)", + "* Initially 1" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "liability_share_value", + "docs": [ + "Monotonically increases as interest rate accumulates. For typical banks, a user's liabilty", + "value in token = (number of shares the user has * liability_share_value)", + "* A float (arbitrary decimals)", + "* Initially 1" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "liquidity_vault", + "docs": [ + "The SPL token account holding deposited liquidity" + ], + "type": "pubkey" + }, + { + "name": "liquidity_vault_bump", + "docs": [ + "PDA bump for the liquidity vault" + ], + "type": "u8" + }, + { + "name": "liquidity_vault_authority_bump", + "docs": [ + "PDA bump for the liquidity vault authority" + ], + "type": "u8" + }, + { + "name": "insurance_vault", + "docs": [ + "The SPL token account holding insurance fund tokens" + ], + "type": "pubkey" + }, + { + "name": "insurance_vault_bump", + "docs": [ + "PDA bump for the insurance vault" + ], + "type": "u8" + }, + { + "name": "insurance_vault_authority_bump", + "docs": [ + "PDA bump for the insurance vault authority" + ], + "type": "u8" + }, + { + "name": "_pad1", + "type": { + "array": [ + "u8", + 4 + ] + } + }, + { + "name": "collected_insurance_fees_outstanding", + "docs": [ + "Fees collected and pending withdraw for the `insurance_vault`" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "fee_vault", + "docs": [ + "The SPL token account holding collected group fees" + ], + "type": "pubkey" + }, + { + "name": "fee_vault_bump", + "docs": [ + "PDA bump for the fee vault" + ], + "type": "u8" + }, + { + "name": "fee_vault_authority_bump", + "docs": [ + "PDA bump for the fee vault authority" + ], + "type": "u8" + }, + { + "name": "_pad2", + "type": { + "array": [ + "u8", + 6 + ] + } + }, + { + "name": "collected_group_fees_outstanding", + "docs": [ + "Fees collected and pending withdraw for the `fee_vault`" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "total_liability_shares", + "docs": [ + "Sum of all liability shares held by all borrowers in this bank.", + "Multiply by `liability_share_value` to get the total liability amount in native token units." + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "total_asset_shares", + "docs": [ + "Sum of all asset shares held by all depositors in this bank.", + "Multiply by `asset_share_value` to get the total asset amount in native token units.", + "* For Kamino banks, this is the quantity of collateral tokens (NOT liquidity tokens) in the", + "bank, and also uses `mint_decimals`, though the mint itself will always show (6) decimals", + "exactly (i.e Kamino ignores this and treats it as if it was using `mint_decimals`)" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "last_update", + "docs": [ + "Unix timestamp (i64) of the last interest accrual" + ], + "type": "i64" + }, + { + "name": "config", + "docs": [ + "The bank's configuration parameters (weights, limits, oracle setup, interest rate config)" + ], + "type": { + "defined": { + "name": "BankConfig" + } + } + }, + { + "name": "flags", + "docs": [ + "Bank flags bitfield (u64).", + "", + "- Bit 0 (1): `EMISSIONS_FLAG_BORROW_ACTIVE` — borrow-side emissions are active", + "- Bit 1 (2): `EMISSIONS_FLAG_LENDING_ACTIVE` — lending-side emissions are active", + "- Bit 2 (4): `PERMISSIONLESS_BAD_DEBT_SETTLEMENT_FLAG` — anyone can settle bad debt", + "- Bit 3 (8): `FREEZE_SETTINGS` — bank configuration is frozen (only limits can change)", + "- Bit 4 (16): `CLOSE_ENABLED_FLAG` — bank can be closed (set at creation for banks >= 0.1.4)", + "- Bit 5 (32): `TOKENLESS_REPAYMENTS_ALLOWED` — risk admin can repay debt without tokens", + "- Bit 6 (64): `TOKENLESS_REPAYMENTS_COMPLETE` — all debt cleared, lender purge enabled", + "- Bit 7 (128): `IS_T22` — 1 if T22, 0 if token classic", + "- Bit 8 (256): `BANK_SEED_KNOWN` — bank is known to be PDA/seed-derived. If not set, bank", + "may still be a PDA, but created before this flag launched (1.8 or earlier) or is a legacy", + "keypair-based bank.", + "- Bit 9 (512): `STAKED_ORACLE_DISABLED` — staked oracle pricing is temporarily disabled.", + "- Bit 10 (1024): `STAKED_ORACLE_PRICE_USES_ONRAMP` — staked oracle pricing includes the SPL", + "single-pool on-ramp account in NAV.", + "- Bit 11 (2048): `CIRCUIT_BREAKER_ENABLED` — oracle deviation breaker active on this bank", + "- Bit 12 (4096): `BANK_SAME_ASSET_EMODE_ELIGIBLE` — bank may participate in same-asset e-mode.", + "- Bit 13 (8192): `PREMIUM_ACTIVE` — a liability-bank flag: balances borrowing from this", + "bank accrue the pairwise variable-borrow premium and project it in health checks.", + "- Bit 14 (16384): `KAMINO_MARKET_EMERGENCY` — the Kamino lending market behind this bank is", + "in emergency mode, so the bank backs no new borrowing." + ], + "type": "u64" + }, + { + "name": "emissions_rate", + "docs": [ + "Emissions APR. Number of emitted tokens (emissions_mint) per 1e(bank.mint_decimal) tokens", + "(bank mint) (native amount) per 1 YEAR." + ], + "type": "u64" + }, + { + "name": "emissions_remaining", + "docs": [ + "Remaining emissions tokens available for distribution" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "emissions_mint", + "docs": [ + "The SPL token mint used for emissions rewards" + ], + "type": "pubkey" + }, + { + "name": "collected_program_fees_outstanding", + "docs": [ + "Fees collected and pending withdraw for the `FeeState.global_fee_wallet`'s canonical ATA for `mint`" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "emode", + "docs": [ + "Controls this bank's emode configuration, which enables some banks to treat the assets of", + "certain other banks more preferentially as collateral." + ], + "type": { + "defined": { + "name": "EmodeSettings" + } + } + }, + { + "name": "fees_destination_account", + "docs": [ + "Set with `update_fees_destination_account`. Fees can be withdrawn to the canonical ATA of", + "this wallet without the admin's input (withdraw_fees_permissionless). If pubkey default, the", + "bank doesn't support this feature, and the fees must be collected manually (withdraw_fees)." + ], + "type": "pubkey" + }, + { + "name": "cache", + "docs": [ + "Cached bank metrics (interest rates, oracle price, etc.)" + ], + "type": { + "defined": { + "name": "BankCache" + } + } + }, + { + "name": "lending_position_count", + "docs": [ + "Number of user lending positions currently open in this bank", + "* For banks created prior to 0.1.4, this is the number of positions opened/closed after", + "0.1.4 goes live, and may be negative.", + "* For banks created in 0.1.4 or later, this is the number of positions open in total, and", + "the bank may safely be closed if this is zero. Will never go negative." + ], + "type": "i32" + }, + { + "name": "borrowing_position_count", + "docs": [ + "Number of user borrowing positions currently open in this bank", + "* For banks created prior to 0.1.4, this is the number of positions opened/closed after", + "0.1.4 goes live, and may be negative.", + "* For banks created in 0.1.4 or later, this is the number of positions open in total, and", + "the bank may safely be closed if this is zero. Will never go negative." + ], + "type": "i32" + }, + { + "name": "liquidation_liquidator_fee", + "docs": [ + "Fee the liquidator earns when liquidating against this bank's liability. Decode with", + "`u32_to_centi` (`u32::MAX` = 100%).", + "* 0 falls back to the default (`DEFAULT_LIQUIDATION_FEE` = 2.5%)." + ], + "type": "u32" + }, + { + "name": "liquidation_insurance_fee", + "docs": [ + "Fee routed to this bank's insurance fund on a liquidation against its liability. Decode", + "with `u32_to_centi` (`u32::MAX` = 100%).", + "* 0 falls back to the default (`DEFAULT_LIQUIDATION_FEE` = 2.5%)." + ], + "type": "u32" + }, + { + "name": "_padding_0", + "docs": [ + "Reserved for future use" + ], + "type": { + "array": [ + "u8", + 8 + ] + } + }, + { + "name": "integration_acc_1", + "docs": [ + "Integration account slot 1 (default Pubkey for non-integrations).", + "- Kamino: reserve", + "- Drift: spot market", + "- Solend: reserve", + "- JupLend: lending state", + "- Staked Collateral: Validator vote account" + ], + "type": "pubkey" + }, + { + "name": "integration_acc_2", + "docs": [ + "Integration account slot 2 (default Pubkey for non-integrations).", + "- Kamino: obligation", + "- Drift: user", + "- Solend: obligation", + "- JupLend: fToken vault" + ], + "type": "pubkey" + }, + { + "name": "integration_acc_3", + "docs": [ + "Integration account slot 3 (default Pubkey for non-integrations).", + "- Drift: user stats", + "- JupLend: withdraw intermediary ATA (ATA of liquidity_vault_authority for bank mint)" + ], + "type": "pubkey" + }, + { + "name": "rate_limiter", + "docs": [ + "Rate limiter for controlling withdraw/borrow outflow.", + "Tracks net outflow (outflows - inflows) in native tokens." + ], + "type": { + "defined": { + "name": "BankRateLimiter" + } + } + }, + { + "name": "collected_premium_outstanding", + "docs": [ + "Realized variable-borrow premium sitting in the liquidity vault, pending sweep to the", + "protocol premium wallet's canonical ATA for `mint`. Only incremented when premium tokens", + "are actually received (repay); never by mere accrual." + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "bank_seed", + "docs": [ + "* `0` for legacy banks created via `lending_pool_add_bank` (created via keypair, not a PDA),", + "or pre-backfill banks (1.8 or earlier) where seed remains unknown.", + "* Otherwise the `bank_seed: u64` argument passed when creating the bank.", + "* Use `flags & BANK_SEED_KNOWN` to verify this value has known seed provenance." + ], + "type": "u64" + }, + { + "name": "cb_halt_started_at", + "docs": [ + "Unix-seconds when the current halt started, zero if not halted." + ], + "type": "i64" + }, + { + "name": "cb_halt_ended_at", + "docs": [ + "Unix-seconds when the current halt's tier duration ends. Tier stays sticky past this for", + "the escalation window; a fresh breach within the window ratchets to the next tier." + ], + "type": "i64" + }, + { + "name": "cb_tier", + "docs": [ + "0 = operational, 1..=3 = escalating halt severity." + ], + "type": "u8" + }, + { + "name": "cb_tier3_consecutive_trips", + "docs": [ + "Consecutive tier-3 trips with no clean escalation-window between them. Hitting", + "`CB_MAX_TIER3_BEFORE_CIRCUIT_BREAK` forces the bank to `CircuitBroken`." + ], + "type": "u8" + }, + { + "name": "cb_pre_break_state", + "docs": [ + "`BankOperationalState` (as `u8`) the bank held before the breaker forced it to", + "`CircuitBroken`. Restored by `clear_circuit_breaker`. Meaningless unless", + "`operational_state == CircuitBroken`." + ], + "type": "u8" + }, + { + "name": "_cb_pad", + "type": { + "array": [ + "u8", + 5 + ] + } + }, + { + "name": "cb_last_observed_slot", + "docs": [ + "Solana slot of the last counted CB observation; used for slot-level dedup." + ], + "type": "u64" + }, + { + "name": "cb_last_oracle_source_time", + "docs": [ + "Publisher-side timestamp of the last counted CB observation; rejects re-reads of the same", + "publication across multiple Solana slots. Zero when the adapter doesn't expose one." + ], + "type": "i64" + }, + { + "name": "cb_reference_price", + "docs": [ + "EMA reference price used by the circuit breaker, in the multiplier-adjusted effective-price", + "domain the risk engine uses. Frozen while halted, zero until the first observation after", + "enable." + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "cb_window_reference_price", + "docs": [ + "Long-window reference price (same multiplier-adjusted domain as `cb_reference_price`) used", + "to catch slow oracle walking that stays below the per-observation breaker threshold." + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "cb_window_started_at", + "docs": [ + "Unix-seconds when `cb_window_reference_price` was anchored." + ], + "type": "i64" + }, + { + "name": "cb_frozen_seconds_pending", + "docs": [ + "Frozen halt seconds from halt intervals overwritten or cleared before `accrue_interest`", + "consumed them. Non-zero only when the halt record changes without a preceding accrual, i.e.", + "a paused pulse; the next accrual excludes these on top of the current halt. Zero normally." + ], + "type": "u64" + }, + { + "name": "premium_tag", + "docs": [ + "Tag for the group's pairwise variable-borrow premium matrix. Determines the rate other", + "accounts pay when this bank is offered as collateral (as `collateral_tag`) and the rate", + "this bank's borrowers pay (as `liability_tag`).", + "* 0 = untagged: never matches any premium entry." + ], + "type": "u16" + }, + { + "name": "_pad3", + "type": { + "array": [ + "u8", + 6 + ] + } + }, + { + "name": "premium_activated_at", + "docs": [ + "Unix timestamp of the most recent inactive->active `PREMIUM_ACTIVE` transition. Premium", + "accrual is clamped to start no earlier than this, so toggling the flag off and back on", + "can never charge for (or health-project) the deactivated window.", + "* 0 on banks that never activated premium." + ], + "type": "i64" + }, + { + "name": "_padding_1", + "type": { + "array": [ + { + "array": [ + "u64", + 8 + ] + }, + 32 + ] + } + } + ] + } + }, + { + "name": "BankCache", + "docs": [ + "A read-only cache of the bank's key metrics, e.g. spot interest/fee rates." + ], + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "base_rate", + "docs": [ + "Actual (spot) interest/fee rates of the bank, based on utilization", + "* APR (annual percentage rate) values", + "* From 0-1000%, as u32, e.g. u32::MAX = 1000%, u32::MAX/2 = 500%, etc" + ], + "type": "u32" + }, + { + "name": "lending_rate", + "docs": [ + "Equivalent to `base_rate` * utilization", + "* From 0-1000%, as u32, e.g. u32::MAX = 1000%, u32::MAX/2 = 500%, etc" + ], + "type": "u32" + }, + { + "name": "borrowing_rate", + "docs": [ + "Equivalent to `base_rate` * (1 + ir_fees) + fixed_fees", + "* From 0-1000%, as u32, e.g. u32::MAX = 1000%, u32::MAX/2 = 500%, etc" + ], + "type": "u32" + }, + { + "name": "interest_accumulated_for", + "docs": [ + "* in seconds" + ], + "type": "u32" + }, + { + "name": "accumulated_since_last_update", + "docs": [ + "equivalent to (share value increase in the last `interest_accumulated_for` seconds *", + "shares), i.e. the delta in `asset_share_value`, in token.", + "* Note: if the tx that triggered this cache update increased or decreased the net shares,", + "this value still reports using the PRE-CHANGE share amount, since interest is always", + "earned on that amount.", + "* in token, in native decimals, as I80F48" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "last_oracle_price", + "docs": [ + "Oracle price used in the last instruction that consumed an oracle price", + "* Only updated when instruction uses an oracle price, not updated for operations that don't", + "require prices (e.g., deposit, repay)", + "* Price in USD, with no price bias", + "* Zero if never updated" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "last_oracle_price_timestamp", + "docs": [ + "Unix timestamp (seconds) when last_oracle_price was last updated", + "* Used to determine staleness of cached price", + "* Zero if never updated" + ], + "type": "i64" + }, + { + "name": "last_oracle_price_confidence", + "docs": [ + "Confidence interval reported by the oracle when last_oracle_price was fetched", + "* Always non-negative", + "* Zero if never updated", + "* Pyth: confidence * 2.12", + "* Switchboard: price * oracle_max_confidence / U32_MAX" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "liq_cache_flags", + "docs": [ + "Liquidation cache flags, set during receivership flow.", + "* 1 (LIQ_CACHE_LOCKED_FLAG) - We \"lock\" the liquidation cache when writing to it in Start", + "Liquidate as an additional safeguard, if the liquidation prices stored here were to be", + "edited between start and end, it would completely break the risk engine. End validates that", + "the lock is set, panics if not, and removes it - which prevents footguns if the cache was", + "e.g. accidently set to default. The lock is also removed when a Balance is closed via", + "withdraw_all, repay_all, or close_balance, but only when the account has", + "ACCOUNT_IN_RECEIVERSHIP set, so that operations on unrelated accounts sharing the same", + "bank do not interfere with an in-progress liquidation." + ], + "type": "u8" + }, + { + "name": "_cb_cache_pad", + "type": { + "array": [ + "u8", + 7 + ] + } + }, + { + "name": "price_multiplier", + "docs": [ + "For integration banks, this is the exchange rate of cToken/token or similar. The \"real\"", + "price of one deposited token is `price_multiplier` * `last_oracle_price`, we split it here", + "for consumers who are only interested in reading the oracle price and are applying the", + "multiplier already elsewhere." + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "liquidation_price_rt", + "docs": [ + "Cached real-time price for receivership liquidation." + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "liquidation_price_rt_confidence", + "docs": [ + "Cached real-time price confidence for receivership liquidation." + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "liquidation_price_twap", + "docs": [ + "Cached TWAP price for receivership liquidation." + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "liquidation_price_twap_confidence", + "docs": [ + "Cached TWAP price confidence for receivership liquidation." + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + } + ] + } + }, + { + "name": "BankConfig", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "asset_weight_init", + "docs": [ + "Discount factor for asset values in initial margin calculation (0 to 1).", + "E.g., 0.8 means assets count as 80% of their value for borrowing purposes." + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "asset_weight_maint", + "docs": [ + "Discount factor for asset values in maintenance margin calculation (0 to 2).", + "Used for liquidation eligibility. Generally >= asset_weight_init." + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "liability_weight_init", + "docs": [ + "Premium factor for liability values in initial margin calculation (>= 1).", + "E.g., 1.2 means liabilities count as 120% of their value for borrowing purposes." + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "liability_weight_maint", + "docs": [ + "Premium factor for liability values in maintenance margin calculation (>= 1).", + "Used for liquidation eligibility. Generally <= liability_weight_init." + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "deposit_limit", + "docs": [ + "Maximum total deposits allowed in this bank, in native token units (0 = no limit)" + ], + "type": "u64" + }, + { + "name": "interest_rate_config", + "docs": [ + "Interest rate model configuration" + ], + "type": { + "defined": { + "name": "InterestRateConfig" + } + } + }, + { + "name": "operational_state", + "docs": [ + "Current operational state of the bank (Paused, Operational, ReduceOnly, KilledByBankruptcy)" + ], + "type": { + "defined": { + "name": "BankOperationalState" + } + } + }, + { + "name": "oracle_setup", + "docs": [ + "Oracle type used for price feeds" + ], + "type": { + "defined": { + "name": "OracleSetup" + } + } + }, + { + "name": "oracle_keys", + "docs": [ + "Oracle account keys (usage depends on oracle_setup type)" + ], + "type": { + "array": [ + "pubkey", + 5 + ] + } + }, + { + "name": "cb_window_max_up_bps", + "docs": [ + "CB long-window upward move cap in bps; `0` uses the `CB_WINDOW_MAX_UP_BPS` default." + ], + "type": "u16" + }, + { + "name": "cb_window_max_down_bps", + "docs": [ + "CB long-window downward move cap in bps; `0` uses the `CB_WINDOW_MAX_DOWN_BPS` default." + ], + "type": "u16" + }, + { + "name": "_pad0", + "type": { + "array": [ + "u8", + 2 + ] + } + }, + { + "name": "borrow_limit", + "docs": [ + "Maximum total borrows allowed in this bank, in native token units (0 = no limit)" + ], + "type": "u64" + }, + { + "name": "risk_tier", + "docs": [ + "Risk tier for this bank (Collateral or Isolated)" + ], + "type": { + "defined": { + "name": "RiskTier" + } + } + }, + { + "name": "asset_tag", + "docs": [ + "Determines what kinds of assets users of this bank can interact with. Options:", + "* `ASSET_TAG_DEFAULT` (0) - A regular asset that can be comingled with any other regular", + "asset or with `ASSET_TAG_SOL`", + "* `ASSET_TAG_SOL` (1) - Accounts with a SOL position can comingle with **either**", + "`ASSET_TAG_DEFAULT` or `ASSET_TAG_STAKED` positions, but not both", + "* `ASSET_TAG_STAKED` (2) - Staked SOL assets. Accounts with a STAKED position can only", + "deposit other STAKED assets or SOL (`ASSET_TAG_SOL`) and can only borrow SOL", + "* `ASSET_TAG_KAMINO` (3) - Treated the same as `ASSET_TAG_DEFAULT`", + "* `ASSET_TAG_DRIFT` (4) - Treated the same as `ASSET_TAG_DEFAULT`", + "* `ASSET_TAG_SOLEND` (5) - Treated the same as `ASSET_TAG_DEFAULT`" + ], + "type": "u8" + }, + { + "name": "config_flags", + "docs": [ + "Flags for various config options", + "* 1 - Always set if bank created in 0.1.4 or later, or if migrated to the new pyth oracle", + "setup from a prior version. Not set in 0.1.3 or earlier banks using pyth that have not yet", + "migrated. Does nothing for banks that use switchboard.", + "* 2, 4, 8, 16, etc - reserved for future use." + ], + "type": "u8" + }, + { + "name": "_pad1", + "type": { + "array": [ + "u8", + 1 + ] + } + }, + { + "name": "cb_window_seconds", + "docs": [ + "CB long-window length in seconds; `0` uses the `CB_WINDOW_SECONDS` default." + ], + "type": "u32" + }, + { + "name": "total_asset_value_init_limit", + "docs": [ + "USD denominated limit for calculating asset value for initialization margin requirements.", + "Example, if total SOL deposits are equal to $1M and the limit it set to $500K, then SOL", + "assets will be discounted by 50%.", + "", + "In other words the max value of liabilities that can be backed by the asset is $500K. This", + "is useful for limiting the damage of oracle attacks.", + "", + "Value is UI USD value, for example value 100 -> $100" + ], + "type": "u64" + }, + { + "name": "oracle_max_age", + "docs": [ + "Time window in seconds for the oracle price feed to be considered live." + ], + "type": "u16" + }, + { + "name": "scope_entry_index", + "docs": [ + "Entry index into the Scope `OraclePrices` price list. Only read by the Scope setups", + "(`Scope`, `ScopeKamino`, `ScopeJuplend`); ignored (and zero) for every other setup.", + "Occupies what was previously `_padding0`, so the layout is unchanged." + ], + "type": "u16" + }, + { + "name": "oracle_max_confidence", + "docs": [ + "A %, as u32, e.g. 100% = u32::MAX, 50% = u32::MAX/2, etc.", + "", + "Oracle confidence configuration. Semantics depend on the oracle type:", + "* Pyth: Maximum allowed confidence interval. Prices exceeding this threshold are rejected.", + "- 0 defaults to 10%.", + "* Switchboard: Confidence spread used for price biasing.", + "- 0 disables confidence adjustment.", + "- Non-zero: confidence = price * oracle_max_confidence / U32_MAX.", + "- Clamped to MAX_CONF_INTERVAL (5% of price)." + ], + "type": "u32" + }, + { + "name": "fixed_price", + "docs": [ + "Stored oracle price for `OracleSetup::Fixed`, otherwise does nothing" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "cb_deviation_bps_tiers", + "docs": [ + "Deviation thresholds in basis points for tiers 1/2/3, strictly monotonic." + ], + "type": { + "array": [ + "u16", + 3 + ] + } + }, + { + "name": "cb_tier_durations_seconds", + "docs": [ + "Halt durations in seconds for tiers 1/2/3, strictly monotonic." + ], + "type": { + "array": [ + "u16", + 3 + ] + } + }, + { + "name": "cb_escalation_window_mult", + "docs": [ + "Escalation window multiplier: a re-breach within `prev_tier_duration * mult` seconds", + "after a halt ends ratchets to the next tier." + ], + "type": "u8" + }, + { + "name": "_cb_config_pad", + "type": "u8" + }, + { + "name": "cb_ema_alpha_bps", + "docs": [ + "EMA smoothing factor for the reference price, in basis points (e.g. 1000 = α=0.1)." + ], + "type": "u16" + } + ] + } + }, + { + "name": "BankConfigCompact", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "asset_weight_init", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "asset_weight_maint", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "liability_weight_init", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "liability_weight_maint", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "deposit_limit", + "type": "u64" + }, + { + "name": "interest_rate_config", + "type": { + "defined": { + "name": "InterestRateConfigCompact" + } + } + }, + { + "name": "operational_state", + "type": { + "defined": { + "name": "BankOperationalState" + } + } + }, + { + "name": "borrow_limit", + "type": "u64" + }, + { + "name": "risk_tier", + "type": { + "defined": { + "name": "RiskTier" + } + } + }, + { + "name": "asset_tag", + "docs": [ + "Determines what kinds of assets users of this bank can interact with. Options:", + "* `ASSET_TAG_DEFAULT` (0) - A regular asset that can be comingled with any other regular", + "asset or with `ASSET_TAG_SOL`", + "* `ASSET_TAG_SOL` (1) - Accounts with a SOL position can comingle with **either**", + "`ASSET_TAG_DEFAULT` or `ASSET_TAG_STAKED` positions, but not both", + "* `ASSET_TAG_STAKED` (2) - Staked SOL assets. Accounts with a STAKED position can only", + "deposit other STAKED assets or SOL (`ASSET_TAG_SOL`) and can only borrow SOL", + "* `ASSET_TAG_KAMINO` (3) - Treated the same as `ASSET_TAG_DEFAULT`", + "* `ASSET_TAG_DRIFT` (4) - Treated the same as `ASSET_TAG_DEFAULT`", + "* `ASSET_TAG_SOLEND` (5) - Treated the same as `ASSET_TAG_DEFAULT`" + ], + "type": "u8" + }, + { + "name": "config_flags", + "docs": [ + "Flags for various config options", + "* 1 - Always set if bank created in 0.1.4 or later, or if migrated to the new oracle setup", + "from a prior version. Not set in 0.1.3 or earlier banks that have not yet migrated.", + "* 2, 4, 8, 16, etc - reserved for future use." + ], + "type": "u8" + }, + { + "name": "_pad0", + "type": { + "array": [ + "u8", + 5 + ] + } + }, + { + "name": "total_asset_value_init_limit", + "docs": [ + "USD denominated limit for calculating asset value for initialization margin requirements.", + "Example, if total SOL deposits are equal to $1M and the limit it set to $500K, then SOL", + "assets will be discounted by 50%.", + "", + "In other words the max value of liabilities that can be backed by the asset is $500K. This", + "is useful for limiting the damage of oracle attacks.", + "", + "Value is UI USD value, for example value 100 -> $100" + ], + "type": "u64" + }, + { + "name": "oracle_max_age", + "docs": [ + "Time window in seconds for the oracle price feed to be considered live." + ], + "type": "u16" + }, + { + "name": "oracle_max_confidence", + "docs": [ + "A %, as u32, e.g. 100% = u32::MAX, 50% = u32::MAX/2, etc.", + "", + "Oracle confidence configuration. Semantics depend on the oracle type.", + "* Pyth: Maximum allowed confidence interval. Prices exceeding this threshold are rejected.", + "- 0 defaults to 10%.", + "* Switchboard: Confidence spread used for price biasing.", + "- 0 disables confidence adjustment.", + "- Non-zero: confidence = price * oracle_max_confidence / U32_MAX.", + "- Clamped to MAX_CONF_INTERVAL (5% of price)." + ], + "type": "u32" + } + ] + } + }, + { + "name": "BankConfigFast", + "docs": [ + "Configuration fields controlled by the fast operational admin.", + "", + "`operational_state`, when present, may only make a risk-reducing transition: Operational", + "to `Paused`, `ReduceOnly`, or `ReduceOnlyWithBorrowingPower`; or", + "`ReduceOnlyWithBorrowingPower` to `ReduceOnly`. It may also set a bank to `Paused` from", + "any administratively configurable state. Restoring a bank to `Operational` is governed by", + "[`BankConfigGov`]." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "deposit_limit", + "type": { + "option": "u64" + } + }, + { + "name": "borrow_limit", + "type": { + "option": "u64" + } + }, + { + "name": "operational_state", + "type": { + "option": { + "defined": { + "name": "BankOperationalState" + } + } + } + }, + { + "name": "interest_rate_config", + "type": { + "option": { + "defined": { + "name": "InterestRateConfigOpt" + } + } + } + }, + { + "name": "total_asset_value_init_limit", + "type": { + "option": "u64" + } + }, + { + "name": "permissionless_bad_debt_settlement", + "type": { + "option": "bool" + } + }, + { + "name": "liquidation_liquidator_fee", + "type": { + "option": "u32" + } + }, + { + "name": "liquidation_insurance_fee", + "type": { + "option": "u32" + } + }, + { + "name": "circuit_breaker_enabled", + "type": { + "option": "bool" + } + }, + { + "name": "cb_deviation_bps_tiers", + "type": { + "option": { + "array": [ + "u16", + 3 + ] + } + } + }, + { + "name": "cb_tier_durations_seconds", + "type": { + "option": { + "array": [ + "u16", + 3 + ] + } + } + }, + { + "name": "cb_escalation_window_mult", + "type": { + "option": "u8" + } + }, + { + "name": "cb_ema_alpha_bps", + "type": { + "option": "u16" + } + }, + { + "name": "cb_window_seconds", + "type": { + "option": "u32" + } + }, + { + "name": "cb_window_max_up_bps", + "type": { + "option": "u16" + } + }, + { + "name": "cb_window_max_down_bps", + "type": { + "option": "u16" + } + } + ] + } + }, + { + "name": "BankConfigGov", + "docs": [ + "Configuration fields controlled by the slow, timelocked governance admin.", + "", + "`operational_state`, when present, may only restore a bank to `Operational`." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "asset_weight_init", + "type": { + "option": { + "defined": { + "name": "WrappedI80F48" + } + } + } + }, + { + "name": "asset_weight_maint", + "type": { + "option": { + "defined": { + "name": "WrappedI80F48" + } + } + } + }, + { + "name": "liability_weight_init", + "type": { + "option": { + "defined": { + "name": "WrappedI80F48" + } + } + } + }, + { + "name": "liability_weight_maint", + "type": { + "option": { + "defined": { + "name": "WrappedI80F48" + } + } + } + }, + { + "name": "operational_state", + "type": { + "option": { + "defined": { + "name": "BankOperationalState" + } + } + } + }, + { + "name": "risk_tier", + "type": { + "option": { + "defined": { + "name": "RiskTier" + } + } + } + }, + { + "name": "asset_tag", + "type": { + "option": "u8" + } + }, + { + "name": "oracle_max_confidence", + "type": { + "option": "u32" + } + }, + { + "name": "oracle_max_age", + "type": { + "option": "u16" + } + }, + { + "name": "tokenless_repayments_allowed", + "type": { + "option": "bool" + } + }, + { + "name": "freeze_settings", + "type": { + "option": "bool" + } + } + ] + } + }, + { + "name": "BankConfigOpt", + "type": { + "kind": "struct", + "fields": [ + { + "name": "asset_weight_init", + "type": { + "option": { + "defined": { + "name": "WrappedI80F48" + } + } + } + }, + { + "name": "asset_weight_maint", + "type": { + "option": { + "defined": { + "name": "WrappedI80F48" + } + } + } + }, + { + "name": "liability_weight_init", + "type": { + "option": { + "defined": { + "name": "WrappedI80F48" + } + } + } + }, + { + "name": "liability_weight_maint", + "type": { + "option": { + "defined": { + "name": "WrappedI80F48" + } + } + } + }, + { + "name": "deposit_limit", + "type": { + "option": "u64" + } + }, + { + "name": "borrow_limit", + "type": { + "option": "u64" + } + }, + { + "name": "operational_state", + "type": { + "option": { + "defined": { + "name": "BankOperationalState" + } + } + } + }, + { + "name": "interest_rate_config", + "type": { + "option": { + "defined": { + "name": "InterestRateConfigOpt" + } + } + } + }, + { + "name": "risk_tier", + "type": { + "option": { + "defined": { + "name": "RiskTier" + } + } + } + }, + { + "name": "asset_tag", + "type": { + "option": "u8" + } + }, + { + "name": "total_asset_value_init_limit", + "type": { + "option": "u64" + } + }, + { + "name": "oracle_max_confidence", + "type": { + "option": "u32" + } + }, + { + "name": "oracle_max_age", + "type": { + "option": "u16" + } + }, + { + "name": "permissionless_bad_debt_settlement", + "type": { + "option": "bool" + } + }, + { + "name": "freeze_settings", + "type": { + "option": "bool" + } + }, + { + "name": "tokenless_repayments_allowed", + "type": { + "option": "bool" + } + }, + { + "name": "liquidation_liquidator_fee", + "docs": [ + "Per-bank liquidation fees, encoded as `u32_to_centi` (`u32::MAX` = 100%; 0 => default 2.5%)." + ], + "type": { + "option": "u32" + } + }, + { + "name": "liquidation_insurance_fee", + "type": { + "option": "u32" + } + }, + { + "name": "circuit_breaker_enabled", + "type": { + "option": "bool" + } + }, + { + "name": "cb_deviation_bps_tiers", + "type": { + "option": { + "array": [ + "u16", + 3 + ] + } + } + }, + { + "name": "cb_tier_durations_seconds", + "type": { + "option": { + "array": [ + "u16", + 3 + ] + } + } + }, + { + "name": "cb_escalation_window_mult", + "type": { + "option": "u8" + } + }, + { + "name": "cb_ema_alpha_bps", + "type": { + "option": "u16" + } + }, + { + "name": "cb_window_seconds", + "type": { + "option": "u32" + } + }, + { + "name": "cb_window_max_up_bps", + "type": { + "option": "u16" + } + }, + { + "name": "cb_window_max_down_bps", + "type": { + "option": "u16" + } + } + ] + } + }, + { + "name": "BankMetadata", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "bank", + "docs": [ + "Bank this metadata corresponds to" + ], + "type": "pubkey" + }, + { + "name": "placeholder", + "type": "u64" + }, + { + "name": "ticker", + "docs": [ + "The token's ticker name, e.g. USDC", + "* utf-8" + ], + "type": { + "array": [ + "u8", + 64 + ] + } + }, + { + "name": "description", + "docs": [ + "The token's plain english description, e.g US Dollar Coin", + "* utf-8" + ], + "type": { + "array": [ + "u8", + 128 + ] + } + }, + { + "name": "data_blob", + "docs": [ + "Reserved for future use. Room for a very small icon or something else cool" + ], + "type": { + "array": [ + "u8", + 256 + ] + } + }, + { + "name": "end_description_byte", + "docs": [ + "The last data byte in description (padding follows)" + ], + "type": "u16" + }, + { + "name": "end_data_blob", + "docs": [ + "The last data byte in data_blob (padding follows)" + ], + "type": "u16" + }, + { + "name": "end_ticker_byte", + "docs": [ + "The last data byte in ticker (padding follows)" + ], + "type": "u8" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "_pad0", + "type": { + "array": [ + "u8", + 2 + ] + } + } + ] + } + }, + { + "name": "BankOperationalState", + "repr": { + "kind": "rust" + }, + "type": { + "kind": "enum", + "variants": [ + { + "name": "Paused" + }, + { + "name": "Operational" + }, + { + "name": "ReduceOnly" + }, + { + "name": "KilledByBankruptcy" + }, + { + "name": "Uninitialized" + }, + { + "name": "ReduceOnlyWithBorrowingPower" + }, + { + "name": "CircuitBroken" + } + ] + } + }, + { + "name": "BankRateLimiter", + "docs": [ + "Per-bank rate limiting configuration and state.", + "Tracks net outflow in native tokens." + ], + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "hourly", + "docs": [ + "Hourly window rate limiter (native tokens)." + ], + "type": { + "defined": { + "name": "RateLimitWindow" + } + } + }, + { + "name": "daily", + "docs": [ + "Daily window rate limiter (native tokens)." + ], + "type": { + "defined": { + "name": "RateLimitWindow" + } + } + } + ] + } + }, + { + "name": "BorrowRateCurve", + "docs": [ + "Mirrors Kamino's `BorrowRateCurve`: a fixed 11-point curve.", + "https://github.com/Kamino-Finance/klend/blob/master/programs/klend/src/utils/borrow_rate_curve.rs#L23-L25" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "points", + "type": { + "array": [ + { + "defined": { + "name": "CurvePoint" + } + }, + 11 + ] + } + } + ] + } + }, + { + "name": "CircuitBreakerAutoBrokenEvent", + "docs": [ + "Emitted when consecutive tier-3 trips force a bank into `CircuitBroken`." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "consecutive_tier3_trips", + "type": "u8" + }, + { + "name": "current_timestamp", + "type": "i64" + } + ] + } + }, + { + "name": "CircuitBreakerClearedEvent", + "docs": [ + "Emitted when a halt is cleared (admin override or escalation-window expiry)." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "prior_tier", + "type": "u8" + }, + { + "name": "reason", + "docs": [ + "One of the `CB_CLEAR_REASON_*` constants." + ], + "type": "u8" + }, + { + "name": "current_timestamp", + "type": "i64" + } + ] + } + }, + { + "name": "CircuitBreakerTrippedEvent", + "docs": [ + "Emitted when the per-bank oracle circuit breaker trips or escalates a halt." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "tier", + "type": "u8" + }, + { + "name": "deviation_bps", + "type": "u64" + }, + { + "name": "halt_started_at", + "type": "i64" + }, + { + "name": "halt_ended_at", + "type": "i64" + } + ] + } + }, + { + "name": "CurvePoint", + "docs": [ + "Mirrors Kamino's `CurvePoint` (`BorrowRateCurve` point). bps: 10_000 = 100%.", + "https://github.com/Kamino-Finance/klend/blob/master/programs/klend/src/utils/borrow_rate_curve.rs#L74-L91" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "utilization_rate_bps", + "type": "u32" + }, + { + "name": "borrow_rate_bps", + "type": "u32" + } + ] + } + }, + { + "name": "DeleverageEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "marginfi_account", + "type": "pubkey" + }, + { + "name": "risk_admin", + "type": "pubkey" + }, + { + "name": "deleveragee_assets_seized", + "type": "f64" + }, + { + "name": "deleveragee_liability_repaid", + "type": "f64" + } + ] + } + }, + { + "name": "DeleverageWithdrawFlowEvent", + "docs": [ + "Emitted for deleverage-only withdraw outflows.", + "The delegate flow admin aggregates these off-chain and", + "updates the deleverage daily withdraws via `update_deleverage_withdrawals`." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "group", + "type": "pubkey" + }, + { + "name": "bank", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "outflow_usd", + "docs": [ + "Equity-denominated outflow value in USD, rounded to integer." + ], + "type": "u32" + }, + { + "name": "current_timestamp", + "docs": [ + "Unix timestamp when the flow was recorded" + ], + "type": "i64" + } + ] + } + }, + { + "name": "DriftClaimBadDebtEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "GroupEventHeader" + } + } + }, + { + "name": "bank", + "type": "pubkey" + }, + { + "name": "claim_mint", + "type": "pubkey" + }, + { + "name": "distributor", + "type": "pubkey" + }, + { + "name": "claim_status", + "type": "pubkey" + }, + { + "name": "liquidity_vault_authority", + "type": "pubkey" + }, + { + "name": "global_fee_wallet", + "type": "pubkey" + }, + { + "name": "requested_amount", + "type": "u64" + }, + { + "name": "received_amount", + "type": "u64" + }, + { + "name": "swept_amount", + "type": "u64" + } + ] + } + }, + { + "name": "DriftConfigCompact", + "docs": [ + "Used to configure Drift banks. A simplified version of `BankConfigCompact` which omits most", + "values related to interest since Drift banks cannot earn interest or be borrowed from." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "oracle", + "type": "pubkey" + }, + { + "name": "asset_weight_init", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "asset_weight_maint", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "deposit_limit", + "type": "u64" + }, + { + "name": "oracle_setup", + "docs": [ + "Either `DriftPythPull` or `DriftSwitchboardPull`" + ], + "type": { + "defined": { + "name": "OracleSetup" + } + } + }, + { + "name": "operational_state", + "docs": [ + "Bank operational state - allows starting banks in paused state" + ], + "type": { + "defined": { + "name": "BankOperationalState" + } + } + }, + { + "name": "risk_tier", + "docs": [ + "Risk tier - determines if assets can be borrowed in isolation" + ], + "type": { + "defined": { + "name": "RiskTier" + } + } + }, + { + "name": "config_flags", + "docs": [ + "Config flags for future-proofing" + ], + "type": "u8" + }, + { + "name": "total_asset_value_init_limit", + "type": "u64" + }, + { + "name": "oracle_max_age", + "type": "u16" + }, + { + "name": "oracle_max_confidence", + "docs": [ + "Oracle confidence threshold (0 = use default 10%)" + ], + "type": "u32" + } + ] + } + }, + { + "name": "EditStakedSettingsEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "group", + "type": "pubkey" + }, + { + "name": "settings", + "type": { + "defined": { + "name": "StakedSettingsEditConfig" + } + } + } + ] + } + }, + { + "name": "EmodeConfig", + "docs": [ + "An emode configuration. Each bank has one such configuration, but this may also be the", + "intersection of many configurations (see `reconcile_emode_configs`). For example, the risk", + "engine creates such an intersection from all the emode config of all banks the user is borrowing", + "from." + ], + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "entries", + "type": { + "array": [ + { + "defined": { + "name": "EmodeEntry" + } + }, + 10 + ] + } + } + ] + } + }, + { + "name": "EmodeEntry", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "collateral_bank_emode_tag", + "docs": [ + "emode_tag of the bank(s) whose collateral you wish to treat preferentially." + ], + "type": "u16" + }, + { + "name": "flags", + "docs": [ + "* APPLIES_TO_ISOLATED (1) - (NOT YET IMPLEMENTED) if set, isolated banks with this tag", + "also benefit. If not set, isolated banks continue to offer zero collateral, even if they", + "use this tag.", + "* 2, 4, 8, 16, 32, etc - reserved for future use" + ], + "type": "u8" + }, + { + "name": "pad0", + "type": { + "array": [ + "u8", + 5 + ] + } + }, + { + "name": "asset_weight_init", + "docs": [ + "Note: If set below the collateral bank's weight, does nothing." + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "asset_weight_maint", + "docs": [ + "Note: If set below the collateral bank's weight, does nothing." + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + } + ] + } + }, + { + "name": "EmodeSettings", + "docs": [ + "Controls the bank's e-mode configuration, allowing certain collateral sources to be treated more", + "favorably as collateral when used to borrow from this bank." + ], + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "emode_tag", + "docs": [ + "This bank's NON-unique id that other banks will use to determine what emode rate to use when", + "this bank is offered as collateral.", + "", + "For example, all stablecoin banks might share the same emode_tag, and in their entries, each", + "such stablecoin bank will recognize that collateral sources with this \"stable\" tag get", + "preferential weights. When a new stablecoin is added that is considered riskier, it may get", + "a new, less favorable emode tag, and eventually get upgraded to the same one as the other", + "stables", + "", + "* 0 is in an invalid tag and will do nothing." + ], + "type": "u16" + }, + { + "name": "pad0", + "type": { + "array": [ + "u8", + 6 + ] + } + }, + { + "name": "timestamp", + "docs": [ + "Unix timestamp from the system clock when emode state was last updated" + ], + "type": "i64" + }, + { + "name": "flags", + "docs": [ + "EMODE_ON (1) - If set, at least one entry is configured", + "2, 4, 8, etc, Reserved for future use" + ], + "type": "u64" + }, + { + "name": "emode_config", + "type": { + "defined": { + "name": "EmodeConfig" + } + } + } + ] + } + }, + { + "name": "ExecuteOrderBalanceRecord", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "bank", + "type": "pubkey" + }, + { + "name": "is_asset", + "type": "u8" + }, + { + "name": "_pad0", + "type": { + "array": [ + "u8", + 5 + ] + } + }, + { + "name": "tag", + "type": "u16" + }, + { + "name": "shares", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + } + ] + } + }, + { + "name": "ExecuteOrderRecord", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "order", + "type": "pubkey" + }, + { + "name": "executor", + "type": "pubkey" + }, + { + "name": "balance_states", + "type": { + "array": [ + { + "defined": { + "name": "ExecuteOrderBalanceRecord" + } + }, + 14 + ] + } + }, + { + "name": "active_balance_count", + "type": "u8" + }, + { + "name": "inactive_balance_count", + "type": "u8" + }, + { + "name": "_reserved0", + "type": { + "array": [ + "u8", + 6 + ] + } + }, + { + "name": "order_start_health", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + } + ] + } + }, + { + "name": "FeeState", + "docs": [ + "Unique per-program. The Program Owner uses this account to administrate fees collected by the protocol" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "key", + "docs": [ + "The fee state's own key. A PDA derived from just `b\"feestate\"`" + ], + "type": "pubkey" + }, + { + "name": "global_fee_admin", + "docs": [ + "Can modify fees, pause the protocol, etc" + ], + "type": "pubkey" + }, + { + "name": "global_fee_wallet", + "docs": [ + "The base wallet for all protocol fees. All SOL fees go to this wallet. All non-SOL fees go", + "to the cannonical ATA of this wallet for that asset." + ], + "type": "pubkey" + }, + { + "name": "account_transfer_fee", + "docs": [ + "Flat fee in lamports paid to the global fee wallet when initiating an account transfer", + "(anti-spam; 5,000,000 lamports ~= $0.50). A stored 0 means \"use the default\"", + "(`DEFAULT_ACCOUNT_TRANSFER_FEE_LAMPORTS`), which preserves the legacy fee for FeeStates", + "created before this field existed." + ], + "type": "u32" + }, + { + "name": "_placeholder0", + "type": { + "array": [ + "u8", + 4 + ] + } + }, + { + "name": "bank_init_flat_sol_fee", + "docs": [ + "Flat fee assessed when a new bank is initialized, in lamports.", + "* In SOL, in native decimals." + ], + "type": "u32" + }, + { + "name": "bump_seed", + "type": "u8" + }, + { + "name": "_padding0", + "type": { + "array": [ + "u8", + 3 + ] + } + }, + { + "name": "liquidation_max_fee", + "docs": [ + "Liquidators can claim at this premium, when liquidating an asset in receivership", + "liquidation, e.g. (1 + this) * amount repaid >= asset seized", + "* A percentage" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "program_fee_fixed", + "docs": [ + "Fee collected by the program owner from all groups", + "* A percentage" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "program_fee_rate", + "docs": [ + "Fee collected by the program owner from all groups", + "* A percentage" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "panic_state", + "docs": [ + "When the global admin pauses the protocol in the event of an emergency, information about", + "the pause duration will be stored here and propagated to groups." + ], + "type": { + "defined": { + "name": "PanicState" + } + } + }, + { + "name": "placeholder1", + "type": "u64" + }, + { + "name": "liquidation_flat_sol_fee", + "docs": [ + "Flat fee assessed for insurance/program use when a liquidation is executed", + "* In SOL, in native decimals." + ], + "type": "u32" + }, + { + "name": "order_init_flat_sol_fee", + "docs": [ + "Flat fee assessed for preventing spam use when creating an order", + "* In SOL, in native decimals." + ], + "type": "u32" + }, + { + "name": "order_execution_max_fee", + "docs": [ + "Take-profit Orders can be executed at this premium, which Keepers are allowed to keep (no", + "pun intended) e.g. (1 + this) * amount repaid >= asset seized", + "* A percentage" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "pause_delegate_admin", + "docs": [ + "Can pause (not unpause) the protocol, but cannot modify any fee configuration." + ], + "type": "pubkey" + }, + { + "name": "premium_wallet", + "docs": [ + "Destination wallet for swept variable-borrow premium fees. Premium collected by banks is", + "swept (permissionlessly) to the canonical ATA of this wallet for the bank's mint.", + "* `Pubkey::default()` = unset (sweeps are rejected until the fee admin configures it),", + "which is what v1-sized accounts hold after `resize_global_fee_state` zero-fills them." + ], + "type": "pubkey" + }, + { + "name": "_reserved0", + "docs": [ + "Reserved for future use. Accounts created before the struct grew to this size are", + "v1-sized (`8 + V1_LEN` bytes) and must be grown via `resize_global_fee_state` before", + "this program version can load them; the new bytes are zero-filled." + ], + "type": { + "array": [ + "u64", + 28 + ] + } + } + ] + } + }, + { + "name": "FeeStateCache", + "docs": [ + "Cached fee configuration propagated from the global FeeState" + ], + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "global_fee_wallet", + "docs": [ + "The wallet that receives program-level fees" + ], + "type": "pubkey" + }, + { + "name": "program_fee_fixed", + "docs": [ + "Fixed fee APR charged to borrowers (program-level)" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "program_fee_rate", + "docs": [ + "Proportional fee rate on interest (program-level)" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "last_update", + "docs": [ + "Unix timestamp of the last fee state propagation" + ], + "type": "i64" + } + ] + } + }, + { + "name": "GroupEventHeader", + "type": { + "kind": "struct", + "fields": [ + { + "name": "signer", + "type": { + "option": "pubkey" + } + }, + { + "name": "marginfi_group", + "type": "pubkey" + } + ] + } + }, + { + "name": "GroupRateLimiter", + "docs": [ + "Per-group rate limiting configuration and state.", + "Tracks aggregate net outflow in USD." + ], + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "hourly", + "docs": [ + "Hourly window rate limiter (USD)." + ], + "type": { + "defined": { + "name": "RateLimitWindow" + } + } + }, + { + "name": "daily", + "docs": [ + "Daily window rate limiter (USD)." + ], + "type": { + "defined": { + "name": "RateLimitWindow" + } + } + } + ] + } + }, + { + "name": "HealthCache", + "docs": [ + "A read-only cache of the internal risk engine's information. Only valid in borrow/withdraw if", + "the tx does not fail. To see the state in any context, e.g. to figure out if the risk engine is", + "failing due to some bad price information, use `pulse_health`." + ], + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "asset_value", + "docs": [ + "Internal risk engine asset value, using initial weight (e.g. what is used for borrowing", + "purposes), with all confidence adjustments, and other discounts on price.", + "* Uses EMA price", + "* In dollars" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "liability_value", + "docs": [ + "Internal risk engine liability value, using initial weight (e.g. what is used for borrowing", + "purposes), with all confidence adjustments, and other discounts on price.", + "* Uses EMA price", + "* In dollars" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "asset_value_maint", + "docs": [ + "Internal risk engine asset value, using maintenance weight (e.g. what is used for", + "liquidation purposes), with all confidence adjustments.", + "* Zero if the risk engine failed to load", + "* Uses SPOT price", + "* In dollars" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "liability_value_maint", + "docs": [ + "Internal risk engine liability value, using maintenance weight (e.g. what is used for", + "liquidation purposes), with all confidence adjustments.", + "* Zero if the risk engine failed to load", + "* Uses SPOT price", + "* In dollars" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "asset_value_equity", + "docs": [ + "The \"true\" value of assets without any confidence or weight adjustments. Internally, used", + "only for bankruptcies.", + "* Zero if the risk engine failed to load", + "* Uses EMA price", + "* In dollars" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "liability_value_equity", + "docs": [ + "The \"true\" value of liabilities without any confidence or weight adjustments.", + "Internally, used only for bankruptcies.", + "* Zero if the risk engine failed to load", + "* Uses EMA price", + "* In dollars" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "timestamp", + "docs": [ + "Unix timestamp from the system clock when this cache was last updated" + ], + "type": "i64" + }, + { + "name": "flags", + "docs": [ + "The flags that indicate the state of the health cache. This is a u32 bitfield, where each", + "bit represents a flag.", + "", + "* HEALTHY = 1 - If set, the account cannot be liquidated. If 0, the account is unhealthy and", + "can be liquidated.", + "* ENGINE STATUS = 2 - If set, the engine did not error during the last health pulse. If 0,", + "the engine would have errored and this cache is likely invalid. `RiskEngineInitRejected`", + "is ignored and will allow the flag to be set anyways.", + "* ORACLE OK = 4 - If set, the engine did not error due to an oracle issue. If 0, engine was", + "passed a bad bank or oracle account, or an oracle was stale. Check the order in which", + "accounts were passed and ensure each balance has the correct banks/oracles, and that", + "oracle cranks ran recently enough. Check `internal_err` and `err_index` for more details", + "in some circumstances. Invalid if generated after borrow/withdraw (these instructions will", + "ignore oracle issues if health is still satisfactory with some balance zeroed out).", + "* EMODE BOOSTED = 8 - If set, an emode or same-asset entry weights every collateral balance", + "above its own bank's maintenance weight. Only written by maintenance passes.", + "* LIQUIDATION START = 16 - Cache was computed at the start of a liquidation.", + "* DELEVERAGE START = 32 - Cache was computed at the start of a deleverage.", + "* 64, 128, etc - reserved for future use" + ], + "type": "u32" + }, + { + "name": "mrgn_err", + "docs": [ + "If the engine errored, look here for the error code. If the engine returns ok, you may also", + "check here to see if the risk engine rejected this tx (3009)." + ], + "type": "u32" + }, + { + "name": "prices", + "docs": [ + "Each price corresponds to that index of Balances in the LendingAccount. Useful for debugging", + "or liquidator consumption, to determine how a user's position is priced internally.", + "* An f64 stored as bytes" + ], + "type": { + "array": [ + { + "array": [ + "u8", + 8 + ] + }, + 16 + ] + } + }, + { + "name": "internal_err", + "docs": [ + "Errors in asset oracles are ignored (with prices treated as zero). If you see a zero price", + "and the `ORACLE_OK` flag is not set, check here to see what error was ignored internally." + ], + "type": "u32" + }, + { + "name": "err_index", + "docs": [ + "Index in `balances` where `internal_err` appeared" + ], + "type": "u8" + }, + { + "name": "program_version", + "docs": [ + "Since 0.1.3, the version will be encoded here. See PROGRAM_VERSION." + ], + "type": "u8" + }, + { + "name": "pad0", + "type": { + "array": [ + "u8", + 2 + ] + } + }, + { + "name": "internal_liq_err", + "docs": [ + "Error code from the liquidation health check during the last health pulse (0 if none)" + ], + "type": "u32" + }, + { + "name": "internal_bankruptcy_err", + "docs": [ + "Error code from the bankruptcy check during the last health pulse (0 if none)" + ], + "type": "u32" + }, + { + "name": "reserved0", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "reserved1", + "type": { + "array": [ + "u8", + 16 + ] + } + } + ] + } + }, + { + "name": "HealthPulseEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "account", + "type": "pubkey" + }, + { + "name": "health_cache", + "type": { + "defined": { + "name": "HealthCache" + } + } + } + ] + } + }, + { + "name": "IndexerFlags", + "docs": [ + "On-chain flags for indexer tranching. Each flag is a full byte so off-chain consumers can", + "filter accounts via `memcmp`. Balance-derived flags are synced automatically on every", + "balance-mutating instruction. Pulse-derived flags are updated in `pulse_health`." + ], + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "is_lending_only", + "docs": [ + "1 if the account has no liabilities" + ], + "type": "u8" + }, + { + "name": "is_empty", + "docs": [ + "1 if the account has no balances above the dust threshold" + ], + "type": "u8" + }, + { + "name": "is_single_borrower", + "docs": [ + "1 if the account has exactly one liability position" + ], + "type": "u8" + }, + { + "name": "has_ever_been_liquidated", + "docs": [ + "1 if the account has ever entered receivership (liquidation or deleverage), permanent." + ], + "type": "u8" + }, + { + "name": "has_ever_been_deleveraged", + "docs": [ + "1 if the account has ever been forcibly deleveraged (permanent, never unset)" + ], + "type": "u8" + }, + { + "name": "has_been_bankrupted", + "docs": [ + "1 if `handle_bankruptcy` has ever been executed on this account (permanent, never unset)" + ], + "type": "u8" + }, + { + "name": "has_isolated", + "docs": [ + "1 if the account has any liability on a bank with `RiskTier::Isolated`. Note: Not", + "authoritative due to a variety of edge cases, such as a Bank being configured from", + "Collateral -> Isolated after the user deposits. Set at borrow time and refreshed best-effort", + "by pulse from live bank state. Cleared by balance-derived sync only when liability count", + "reaches zero." + ], + "type": "u8" + }, + { + "name": "has_staked", + "docs": [ + "1 if the account has a STAKED asset tag position" + ], + "type": "u8" + }, + { + "name": "has_kamino", + "docs": [ + "1 if the account has a KAMINO asset tag position" + ], + "type": "u8" + }, + { + "name": "has_drift", + "docs": [ + "1 if the account has a DRIFT asset tag position" + ], + "type": "u8" + }, + { + "name": "has_juplend", + "docs": [ + "1 if the account has a JUPLEND asset tag position" + ], + "type": "u8" + }, + { + "name": "was_liquidatable", + "docs": [ + "1 if maintenance health was negative at last pulse" + ], + "type": "u8" + }, + { + "name": "was_underwater", + "docs": [ + "1 if equity health was negative at last pulse" + ], + "type": "u8" + }, + { + "name": "was_active_30d", + "docs": [ + "1 if account was active within the last 30 days. Raised to 1 on every", + "balance-mutating instruction; can only transition 1 → 0 at pulse time, when the", + "elapsed-since-`last_update` check fails.", + "Combined with `is_empty`, indicates an account pending closure." + ], + "type": "u8" + }, + { + "name": "was_active_60d", + "docs": [ + "1 if account was active within the last 60 days. Raised to 1 on every", + "balance-mutating instruction; can only transition 1 → 0 at pulse time, when the", + "elapsed-since-`last_update` check fails.", + "Combined with `is_empty`, indicates an account eligible for permissionless close." + ], + "type": "u8" + }, + { + "name": "has_trivial_balance", + "docs": [ + "1 if net equity value was greater than $0 and less than $1 at last pulse" + ], + "type": "u8" + }, + { + "name": "_pad", + "type": { + "array": [ + "u8", + 8 + ] + } + } + ] + } + }, + { + "name": "InsuranceFund", + "docs": [ + "Mirrors Drift's `SpotMarket.insurance_fund` field-for-field (`struct InsuranceFund`). u128 fields", + "are stored as raw bytes to preserve 8-byte alignment.", + "https://github.com/drift-labs/protocol-v2/blob/master/programs/drift/src/state/spot_market.rs#L689-L702" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "vault", + "type": "pubkey" + }, + { + "name": "total_shares", + "type": { + "array": [ + "u8", + 16 + ] + } + }, + { + "name": "user_shares", + "type": { + "array": [ + "u8", + 16 + ] + } + }, + { + "name": "shares_base", + "type": { + "array": [ + "u8", + 16 + ] + } + }, + { + "name": "unstaking_period", + "type": "i64" + }, + { + "name": "last_revenue_settle_ts", + "type": "i64" + }, + { + "name": "revenue_settle_period", + "type": "i64" + }, + { + "name": "total_factor", + "docs": [ + "Percentage of interest taken by the insurance fund (PERCENTAGE_PRECISION = 1e6)." + ], + "type": "u32" + }, + { + "name": "user_factor", + "type": "u32" + } + ] + } + }, + { + "name": "InterestRateConfig", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "placeholder0", + "docs": [ + "DEPRECATED placeholder field. Formerly used for legacy curve math." + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "placeholder1", + "docs": [ + "DEPRECATED placeholder field. Formerly used for legacy curve math." + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "placeholder2", + "docs": [ + "DEPRECATED placeholder field. Formerly used for legacy curve math." + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "insurance_fee_fixed_apr", + "docs": [ + "Goes to insurance, funds `collected_insurance_fees_outstanding`" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "insurance_ir_fee", + "docs": [ + "Goes to insurance, funds `collected_insurance_fees_outstanding`" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "protocol_fixed_fee_apr", + "docs": [ + "Earned by the group, goes to `collected_group_fees_outstanding`" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "protocol_ir_fee", + "docs": [ + "Earned by the group, goes to `collected_group_fees_outstanding`" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "protocol_origination_fee", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "zero_util_rate", + "docs": [ + "The base rate at utilization = 0", + "* a %, as u32, out of 1000%, e.g. 100% = 0.1 * u32::MAX" + ], + "type": "u32" + }, + { + "name": "hundred_util_rate", + "docs": [ + "The base rate at utilization = 100", + "* a %, as u32, out of 1000%, e.g. 100% = 0.1 * u32::MAX" + ], + "type": "u32" + }, + { + "name": "points", + "docs": [ + "The base rate at various points between 0 and 100%, exclusive. Essentially a piece-wise", + "linear curve.", + "* always in ascending order, e.g. points[0] = first kink point, points[1] = second kink", + "point, and so forth.", + "* points where util = 0 are unused" + ], + "type": { + "array": [ + { + "defined": { + "name": "RatePoint" + } + }, + 5 + ] + } + }, + { + "name": "curve_type", + "docs": [ + "Determines which interest rate curve implementation is active.", + "- 0 (`INTEREST_CURVE_LEGACY`) is deprecated and unsupported.", + "- 1 (`INTEREST_CURVE_SEVEN_POINT`) is the active multi-point curve." + ], + "type": "u8" + }, + { + "name": "_pad0", + "type": { + "array": [ + "u8", + 7 + ] + } + }, + { + "name": "_padding1", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "_padding2", + "type": { + "array": [ + "u8", + 16 + ] + } + }, + { + "name": "_padding3", + "type": { + "array": [ + "u8", + 8 + ] + } + } + ] + } + }, + { + "name": "InterestRateConfigCompact", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "insurance_fee_fixed_apr", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "insurance_ir_fee", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "protocol_fixed_fee_apr", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "protocol_ir_fee", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "protocol_origination_fee", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "zero_util_rate", + "docs": [ + "The base rate at utilization = 0", + "* a %, as u32, out of 1000%, e.g. 100% = 0.1 * u32::MAX" + ], + "type": "u32" + }, + { + "name": "hundred_util_rate", + "docs": [ + "The base rate at utilization = 100", + "* a %, as u32, out of 1000%, e.g. 100% = 0.1 * u32::MAX" + ], + "type": "u32" + }, + { + "name": "points", + "docs": [ + "The base rate at various points between 0 and 100%, exclusive. Essentially a piece-wise", + "linear curve.", + "* always in ascending order, e.g. points[0] = first kink point, points[1] = second kink", + "point, and so forth.", + "* points where util = 0 are unused" + ], + "type": { + "array": [ + { + "defined": { + "name": "RatePoint" + } + }, + 5 + ] + } + } + ] + } + }, + { + "name": "InterestRateConfigOpt", + "type": { + "kind": "struct", + "fields": [ + { + "name": "insurance_fee_fixed_apr", + "type": { + "option": { + "defined": { + "name": "WrappedI80F48" + } + } + } + }, + { + "name": "insurance_ir_fee", + "type": { + "option": { + "defined": { + "name": "WrappedI80F48" + } + } + } + }, + { + "name": "protocol_fixed_fee_apr", + "type": { + "option": { + "defined": { + "name": "WrappedI80F48" + } + } + } + }, + { + "name": "protocol_ir_fee", + "type": { + "option": { + "defined": { + "name": "WrappedI80F48" + } + } + } + }, + { + "name": "protocol_origination_fee", + "type": { + "option": { + "defined": { + "name": "WrappedI80F48" + } + } + } + }, + { + "name": "zero_util_rate", + "docs": [ + "The base rate at utilization = 0", + "* a %, as u32, out of 1000%, e.g. 100% = 0.1 * u32::MAX" + ], + "type": { + "option": "u32" + } + }, + { + "name": "hundred_util_rate", + "docs": [ + "The base rate at utilization = 100", + "* a %, as u32, out of 1000%, e.g. 100% = 0.1 * u32::MAX" + ], + "type": { + "option": "u32" + } + }, + { + "name": "points", + "docs": [ + "The base rate at various points between 0 and 100%, exclusive. Essentially a piece-wise", + "linear curve.", + "* always in ascending order, e.g. points[0] = first kink point, points[1] = second kink", + "point, and so forth.", + "* points where util = 0 are unused" + ], + "type": { + "option": { + "array": [ + { + "defined": { + "name": "RatePoint" + } + }, + 5 + ] + } + } + } + ] + } + }, + { + "name": "JuplendConfigCompact", + "docs": [ + "Used to configure JupLend banks. A simplified version of `BankConfigCompact` which omits most", + "values related to interest since JupLend banks cannot earn interest or be borrowed from.", + "", + "Note: JupLend banks do not take an Operational State, they always start in `Uninitialized`", + "state and are set to `Operational` via `juplend_init_position` (seed deposit + protocol fToken", + "vault)." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "oracle", + "type": "pubkey" + }, + { + "name": "asset_weight_init", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "asset_weight_maint", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "deposit_limit", + "docs": [ + "Cap in **fToken units**, not underlying. As `token_exchange_price` grows, the same", + "cap admits more underlying — re-tune against the current rate." + ], + "type": "u64" + }, + { + "name": "oracle_setup", + "docs": [ + "Either `JuplendPythPull` or `JuplendSwitchboardPull`" + ], + "type": { + "defined": { + "name": "OracleSetup" + } + } + }, + { + "name": "risk_tier", + "docs": [ + "Isolated or Collateral" + ], + "type": { + "defined": { + "name": "RiskTier" + } + } + }, + { + "name": "config_flags", + "docs": [ + "Config flags for future-proofing, currently ignored" + ], + "type": "u8" + }, + { + "name": "total_asset_value_init_limit", + "docs": [ + "In $" + ], + "type": "u64" + }, + { + "name": "oracle_max_age", + "docs": [ + "In seconds" + ], + "type": "u16" + }, + { + "name": "oracle_max_confidence", + "docs": [ + "Oracle confidence threshold (0 = use default 10%)" + ], + "type": "u32" + } + ] + } + }, + { + "name": "KaminoConfigCompact", + "docs": [ + "Used to configure Kamino banks. A simplified version of `BankConfigCompact` which omits most", + "values related to interest since Kamino banks cannot earn interest or be borrowed against." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "oracle", + "type": "pubkey" + }, + { + "name": "asset_weight_init", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "asset_weight_maint", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "deposit_limit", + "docs": [ + "Cap in **Kamino collateral units**, not underlying. As the reserve collateral", + "exchange rate grows, the same cap admits more underlying — re-tune against the", + "current rate." + ], + "type": "u64" + }, + { + "name": "oracle_setup", + "docs": [ + "Either `KaminoPythPush` or `KaminoSwitchboardPull`" + ], + "type": { + "defined": { + "name": "OracleSetup" + } + } + }, + { + "name": "operational_state", + "docs": [ + "Bank operational state - allows starting banks in paused state" + ], + "type": { + "defined": { + "name": "BankOperationalState" + } + } + }, + { + "name": "risk_tier", + "docs": [ + "Risk tier - determines if assets can be borrowed in isolation" + ], + "type": { + "defined": { + "name": "RiskTier" + } + } + }, + { + "name": "config_flags", + "docs": [ + "Config flags for future-proofing" + ], + "type": "u8" + }, + { + "name": "total_asset_value_init_limit", + "type": "u64" + }, + { + "name": "oracle_max_age", + "docs": [ + "Currently unused: Kamino's oracle age applies to kamino banks." + ], + "type": "u16" + }, + { + "name": "oracle_max_confidence", + "docs": [ + "Oracle confidence threshold (0 = use default 10%)" + ], + "type": "u32" + } + ] + } + }, + { + "name": "KeeperCloseOrderEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "AccountEventHeader" + } + } + }, + { + "name": "order", + "type": "pubkey" + } + ] + } + }, + { + "name": "KeeperCloseRebalanceOrderEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "AccountEventHeader" + } + } + }, + { + "name": "rebalance_order", + "type": "pubkey" + } + ] + } + }, + { + "name": "Lending", + "docs": [ + "Minimal representation of the on-chain JupLend `Lending` account.", + "", + "Notes:", + "- We intentionally use a **zero-copy** layout here to match how other integrations load large", + "external accounts (and to avoid paying Borsh (de)serialization cost on every access).", + "- `repr(C, packed)` keeps the byte layout identical to a field-by-field serialization", + "(i.e. no implicit padding). This is important because `Pubkey` has alignment=1 while `u64`", + "has alignment=8; using plain `repr(C)` would insert padding before the first `u64`." + ], + "serialization": "bytemuck", + "repr": { + "kind": "c", + "packed": true + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "f_token_mint", + "type": "pubkey" + }, + { + "name": "lending_id", + "type": "u16" + }, + { + "name": "decimals", + "docs": [ + "number of decimals for the fToken, same as underlying mint" + ], + "type": "u8" + }, + { + "name": "rewards_rate_model", + "docs": [ + "PDA of rewards rate model (LRRM)" + ], + "type": "pubkey" + }, + { + "name": "liquidity_exchange_price", + "docs": [ + "exchange price in the liquidity layer (no rewards)" + ], + "type": "u64" + }, + { + "name": "token_exchange_price", + "docs": [ + "exchange price between fToken and underlying (with rewards)" + ], + "type": "u64" + }, + { + "name": "last_update_timestamp", + "docs": [ + "unix timestamp when exchange prices were updated last" + ], + "type": "u64" + }, + { + "name": "token_reserves_liquidity", + "type": "pubkey" + }, + { + "name": "supply_position_on_liquidity", + "type": "pubkey" + }, + { + "name": "bump", + "type": "u8" + } + ] + } + }, + { + "name": "LendingAccount", + "docs": [ + "The lending account holds up to 16 balance positions for a user." + ], + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "balances", + "docs": [ + "Array of balance positions (max 16). Sorted in descending order by bank_pk." + ], + "type": { + "array": [ + { + "defined": { + "name": "Balance" + } + }, + 16 + ] + } + }, + { + "name": "last_tag_used", + "docs": [ + "Last allocated balance tag (u16), used to find the next unused tag." + ], + "type": "u16" + }, + { + "name": "_pad1", + "docs": [ + "Reserved for future use" + ], + "type": { + "array": [ + "u8", + 6 + ] + } + }, + { + "name": "_padding", + "docs": [ + "Reserved for future use" + ], + "type": { + "array": [ + "u64", + 7 + ] + } + } + ] + } + }, + { + "name": "LendingAccountBorrowEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "AccountEventHeader" + } + } + }, + { + "name": "bank", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "share_amount", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + } + ] + } + }, + { + "name": "LendingAccountDepositEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "AccountEventHeader" + } + } + }, + { + "name": "bank", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "share_amount", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + } + ] + } + }, + { + "name": "LendingAccountLiquidateEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "AccountEventHeader" + } + } + }, + { + "name": "liquidatee_marginfi_account", + "type": "pubkey" + }, + { + "name": "liquidatee_marginfi_account_authority", + "type": "pubkey" + }, + { + "name": "asset_bank", + "type": "pubkey" + }, + { + "name": "asset_mint", + "type": "pubkey" + }, + { + "name": "liability_bank", + "type": "pubkey" + }, + { + "name": "liability_mint", + "type": "pubkey" + }, + { + "name": "liquidatee_pre_health", + "type": "f64" + }, + { + "name": "liquidatee_post_health", + "type": "f64" + }, + { + "name": "pre_balances", + "type": { + "defined": { + "name": "LiquidationBalances" + } + } + }, + { + "name": "post_balances", + "type": { + "defined": { + "name": "LiquidationBalances" + } + } + } + ] + } + }, + { + "name": "LendingAccountPremiumSettledEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "AccountEventHeader" + } + } + }, + { + "name": "bank", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "premium_settled", + "docs": [ + "Vault-backed premium moved into `bank.collected_premium_outstanding` by a repayment", + "or seized-collateral liquidation credit, in native token units." + ], + "type": "f64" + }, + { + "name": "premium_written_off", + "docs": [ + "Premium receivable written off with no tokens (tokenless risk-admin repayment), in", + "native token units." + ], + "type": "f64" + }, + { + "name": "premium_outstanding_remaining", + "docs": [ + "Premium receivable still outstanding on the balance after this settlement." + ], + "type": "f64" + } + ] + } + }, + { + "name": "LendingAccountRepayEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "AccountEventHeader" + } + } + }, + { + "name": "bank", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "close_balance", + "type": "bool" + }, + { + "name": "share_amount", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + } + ] + } + }, + { + "name": "LendingAccountWithdrawEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "AccountEventHeader" + } + } + }, + { + "name": "bank", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "close_balance", + "type": "bool" + }, + { + "name": "share_amount", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + } + ] + } + }, + { + "name": "LendingPoolBankAccrueInterestEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "GroupEventHeader" + } + } + }, + { + "name": "bank", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "delta", + "type": "u64" + }, + { + "name": "fees_collected", + "type": "f64" + }, + { + "name": "insurance_collected", + "type": "f64" + } + ] + } + }, + { + "name": "LendingPoolBankCollectFeesEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "GroupEventHeader" + } + } + }, + { + "name": "bank", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "group_fees_collected", + "type": "f64" + }, + { + "name": "group_fees_outstanding", + "type": "f64" + }, + { + "name": "insurance_fees_collected", + "type": "f64" + }, + { + "name": "insurance_fees_outstanding", + "type": "f64" + } + ] + } + }, + { + "name": "LendingPoolBankConfigureEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "GroupEventHeader" + } + } + }, + { + "name": "bank", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "config", + "type": { + "defined": { + "name": "BankConfigOpt" + } + } + } + ] + } + }, + { + "name": "LendingPoolBankConfigureFrozenEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "GroupEventHeader" + } + } + }, + { + "name": "bank", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "deposit_limit", + "type": "u64" + }, + { + "name": "borrow_limit", + "type": "u64" + } + ] + } + }, + { + "name": "LendingPoolBankConfigureOracleEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "GroupEventHeader" + } + } + }, + { + "name": "bank", + "type": "pubkey" + }, + { + "name": "oracle_setup", + "type": "u8" + }, + { + "name": "oracle", + "type": "pubkey" + } + ] + } + }, + { + "name": "LendingPoolBankCreateEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "GroupEventHeader" + } + } + }, + { + "name": "bank", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + } + ] + } + }, + { + "name": "LendingPoolBankHandleBankruptcyEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "AccountEventHeader" + } + } + }, + { + "name": "bank", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "bad_debt", + "type": "f64" + }, + { + "name": "covered_amount", + "type": "f64" + }, + { + "name": "socialized_amount", + "type": "f64" + }, + { + "name": "premium_written_off", + "docs": [ + "Uncollectable premium receivable written off with the bad debt (never socialized,", + "never covered by insurance, never credited to the bank)." + ], + "type": "f64" + } + ] + } + }, + { + "name": "LendingPoolBankPremiumConfigureEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "GroupEventHeader" + } + } + }, + { + "name": "bank", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "premium_tag", + "type": "u16" + }, + { + "name": "active", + "type": "bool" + } + ] + } + }, + { + "name": "LendingPoolBankSetOraclePriceEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "GroupEventHeader" + } + } + }, + { + "name": "bank", + "type": "pubkey" + }, + { + "name": "price", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + } + ] + } + }, + { + "name": "LendingPoolBankSetSameAssetEmodeEligibilityEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "GroupEventHeader" + } + } + }, + { + "name": "bank", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "enabled", + "type": "bool" + } + ] + } + }, + { + "name": "LendingPoolGroupPremiumConfigureEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "GroupEventHeader" + } + } + }, + { + "name": "collateral_tag", + "type": "u16" + }, + { + "name": "liability_tag", + "type": "u16" + }, + { + "name": "old_rate", + "type": "u32" + }, + { + "name": "new_rate", + "type": "u32" + } + ] + } + }, + { + "name": "LendingPoolPremiumFeesCollectedEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "GroupEventHeader" + } + } + }, + { + "name": "bank", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "premium_collected", + "docs": [ + "Realized premium swept from the liquidity vault to the premium wallet ATA this call." + ], + "type": "f64" + }, + { + "name": "premium_outstanding", + "docs": [ + "Realized premium still awaiting sweep after this call." + ], + "type": "f64" + } + ] + } + }, + { + "name": "LendingPoolSuperAdminDepositEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "GroupEventHeader" + } + } + }, + { + "name": "bank", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "transfer_amount", + "docs": [ + "Amount requested in SPL transfer instruction." + ], + "type": "u64" + }, + { + "name": "vault_inflow_amount", + "docs": [ + "Assumed vault inflow. Token-2022 transfer fees are not handled by this instruction path." + ], + "type": "u64" + } + ] + } + }, + { + "name": "LendingPoolSuperAdminWithdrawEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "GroupEventHeader" + } + } + }, + { + "name": "bank", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "vault_outflow_amount", + "type": "u64" + } + ] + } + }, + { + "name": "LiquidationBalances", + "type": { + "kind": "struct", + "fields": [ + { + "name": "liquidatee_asset_balance", + "type": "f64" + }, + { + "name": "liquidatee_liability_balance", + "type": "f64" + }, + { + "name": "liquidator_asset_balance", + "type": "f64" + }, + { + "name": "liquidator_liability_balance", + "type": "f64" + }, + { + "name": "liquidator_liability_bank_asset_balance", + "type": "f64" + } + ] + } + }, + { + "name": "LiquidationCache", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "asset_value_maint", + "docs": [ + "Internal risk engine asset value snapshot taken when liquidation begins, using maintenance", + "weight with all confidence adjustments.", + "* Uses SPOT price", + "* In dollars" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "liability_value_maint", + "docs": [ + "Internal risk engine liability value snapshot taken when liquidation begins, using", + "maintenance weight with all confidence adjustments.", + "* Uses SPOT price", + "* In dollars" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "asset_value_equity", + "docs": [ + "Actual cash value of assets pre-liquidation (inclusive of price adjustment for oracle", + "confidence, but without any weights)", + "* Liquidator is allowed to seize up to `liability_value_equity` - this amount", + "* Uses EMA price", + "* In dollars" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "liability_value_equity", + "docs": [ + "Actual cash value of liabilities pre-liquidation (inclusive of price adjustment for oracle", + "confidence, but without any weights)", + "* Liquidator is allowed to seize up to this amount - `asset_value_equity`", + "* Uses EMA price", + "* In dollars" + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "_placeholder", + "type": "u64" + }, + { + "name": "_reserved0", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + } + }, + { + "name": "LiquidationEntry", + "docs": [ + "Used to record key details of the last few liquidation events on the account" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "asset_amount_seized", + "docs": [ + "Dollar amount seized", + "* An f64 stored as bytes" + ], + "type": { + "array": [ + "u8", + 8 + ] + } + }, + { + "name": "liab_amount_repaid", + "docs": [ + "Dollar amount repaid", + "* An f64 stored as bytes" + ], + "type": { + "array": [ + "u8", + 8 + ] + } + }, + { + "name": "placeholder0", + "type": "u64" + }, + { + "name": "timestamp", + "type": "i64" + }, + { + "name": "_reserved0", + "type": { + "array": [ + "u8", + 16 + ] + } + } + ] + } + }, + { + "name": "LiquidationReceiverEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "marginfi_account", + "type": "pubkey" + }, + { + "name": "liquidation_receiver", + "type": "pubkey" + }, + { + "name": "liquidatee_assets_seized", + "type": "f64" + }, + { + "name": "liquidatee_liability_repaid", + "type": "f64" + }, + { + "name": "lamps_fee_paid", + "type": "u32" + } + ] + } + }, + { + "name": "LiquidationRecord", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "key", + "docs": [ + "This account's own key. A PDA derived from `marginfi_account`" + ], + "type": "pubkey" + }, + { + "name": "marginfi_account", + "docs": [ + "Account this record tracks" + ], + "type": "pubkey" + }, + { + "name": "record_payer", + "docs": [ + "The key that paid to create this account. At some point, we may allow this wallet to reclaim", + "the rent paid to open a record." + ], + "type": "pubkey" + }, + { + "name": "liquidation_receiver", + "docs": [ + "The liquidator taking receivership of the `marginfi_account` to complete a liquidation. Pays", + "the liquidation fee.", + "* Always pubkey default unless actively within a liquidation event." + ], + "type": "pubkey" + }, + { + "name": "entries", + "docs": [ + "Basic historical data for the last few liquidation events on this account" + ], + "type": { + "array": [ + { + "defined": { + "name": "LiquidationEntry" + } + }, + 4 + ] + } + }, + { + "name": "cache", + "type": { + "defined": { + "name": "LiquidationCache" + } + } + }, + { + "name": "_reserved0", + "type": { + "array": [ + "u8", + 64 + ] + } + }, + { + "name": "_reserved2", + "type": { + "array": [ + "u8", + 16 + ] + } + }, + { + "name": "_reserved3", + "type": { + "array": [ + "u8", + 8 + ] + } + } + ] + } + }, + { + "name": "LiquidationTagEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "marginfi_account", + "type": "pubkey" + }, + { + "name": "tagged_at", + "docs": [ + "0 when the tag was cleared" + ], + "type": "i64" + } + ] + } + }, + { + "name": "MarginfiAccount", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "group", + "type": "pubkey" + }, + { + "name": "authority", + "type": "pubkey" + }, + { + "name": "lending_account", + "type": { + "defined": { + "name": "LendingAccount" + } + } + }, + { + "name": "account_flags", + "docs": [ + "The flags that indicate the state of the account. This is u64 bitfield, where each bit", + "represents a flag.", + "", + "Flags:MarginfiAccount", + "- 1: `ACCOUNT_DISABLED` - Indicates that the account is disabled and no further actions can", + "be taken on it.", + "- 2: `ACCOUNT_IN_FLASHLOAN` - Only set when an account is within a flash loan, e.g. when", + "start_flashloan is called, then unset when the flashloan ends.", + "- 4: `ACCOUNT_FLAG_DEPRECATED` - Deprecated, available for future use", + "- 8: `ACCOUNT_TRANSFER_AUTHORITY_DEPRECATED` - the admin has flagged with account to be", + "moved, original owner can now call `set_account_transfer_authority`", + "- 16: `ACCOUNT_IN_RECEIVERSHIP` - the account is eligible to be liquidated and has entered", + "receivership, a liquidator is able to control borrows and withdraws until the end of the", + "tx. This flag will only appear within a tx.", + "- 32: `ACCOUNT_IN_DELEVERAGE - the account is being deleveraged by the risk admin", + "- 64: `ACCOUNT_FROZEN` - the admin has frozen the account; only the group admin may perform", + "actions until unfrozen." + ], + "type": "u64" + }, + { + "name": "emissions_destination_account", + "docs": [ + "Wallet whose canonical ATA receives off-chain emissions distributions." + ], + "type": "pubkey" + }, + { + "name": "health_cache", + "docs": [ + "Replace through `set_health_cache` or `set_receivership_start_health_cache` so that", + "ordinary updates cannot retain receivership-start provenance." + ], + "type": { + "defined": { + "name": "HealthCache" + } + } + }, + { + "name": "migrated_from", + "docs": [ + "If this account was migrated from another one, store the original account key" + ], + "type": "pubkey" + }, + { + "name": "migrated_to", + "docs": [ + "If this account has been migrated to another one, store the destination account key" + ], + "type": "pubkey" + }, + { + "name": "last_update", + "docs": [ + "Unix timestamp (u64) of the last account interaction. Note: Bank.last_update uses i64." + ], + "type": "u64" + }, + { + "name": "account_index", + "docs": [ + "If a PDA-based account, the account index, a seed used to derive the PDA that can be chosen", + "arbitrarily (0.1.5 or later). Otherwise, does nothing." + ], + "type": "u16" + }, + { + "name": "third_party_index", + "docs": [ + "If a PDA-based account (0.1.5 or later), a \"vendor specific\" id. Values < PDA_FREE_THRESHOLD", + "can be used by anyone with no restrictions. Values >= PDA_FREE_THRESHOLD can only be used by", + "a particular program via CPI. These values require being added to a list, contact us for", + "more details. For legacy non-pda accounts, does nothing.", + "", + "Note: use a unique seed to tag accounts related to some particular program or campaign so", + "you can easily fetch them all later." + ], + "type": "u16" + }, + { + "name": "bump", + "docs": [ + "This account's bump, if a PDA-based account (0.1.5 or later). Otherwise, does nothing." + ], + "type": "u8" + }, + { + "name": "active_orders", + "docs": [ + "Count of how many Orders this account has active. One is added when an Order is opened, and", + "subtracted when an Order is executed or cancelled.", + "* Accounts cannot open more than u8::MAX orders. Sorry power users: hopefully 256 stop", + "losses is enough for you." + ], + "type": "u8" + }, + { + "name": "_pad0", + "type": { + "array": [ + "u8", + 2 + ] + } + }, + { + "name": "liquidation_record", + "docs": [ + "Stores information related to liquidations made against this account. A pda of this", + "account's key, and \"liq_record\"", + "* Typically pubkey default if this account has never been liquidated or close to liquidation", + "* Opening this account is permissionless. Typically the liquidator pays, but e.g. we may", + "also charge the user if they are opening a risky position on the front end." + ], + "type": "pubkey" + }, + { + "name": "indexer_flags", + "type": { + "defined": { + "name": "IndexerFlags" + } + } + }, + { + "name": "rebalance_execution_seq", + "docs": [ + "Monotonic counter. seeding each rebalance execution's `RebalanceRecord`." + ], + "type": "u64" + }, + { + "name": "liquidation_tagged_at", + "docs": [ + "Unix timestamp when this account was tagged as unhealthy, growing the allowed liquidation", + "premium over time. Cleared once an instruction proves the account healthy again (deposit", + "and repay do not), restarted when a liquidation erases a material share of the health", + "deficit or repays a material share of the debt.", + "* 0 if not tagged" + ], + "type": "i64" + }, + { + "name": "_padding0", + "type": { + "array": [ + "u64", + 2 + ] + } + } + ] + } + }, + { + "name": "MarginfiAccountCloseOrderEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "AccountEventHeader" + } + } + }, + { + "name": "order", + "type": "pubkey" + } + ] + } + }, + { + "name": "MarginfiAccountCloseRebalanceOrderEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "AccountEventHeader" + } + } + }, + { + "name": "rebalance_order", + "type": "pubkey" + } + ] + } + }, + { + "name": "MarginfiAccountCreateEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "AccountEventHeader" + } + } + } + ] + } + }, + { + "name": "MarginfiAccountExecuteOrderEvent", + "docs": [ + "Emitted after end-execution checks pass. Consumers must also verify transaction success." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "docs": [ + "The signer is the executor." + ], + "type": { + "defined": { + "name": "AccountEventHeader" + } + } + }, + { + "name": "order", + "type": "pubkey" + }, + { + "name": "created_at", + "docs": [ + "Unix timestamp (seconds) when the order was created; 0 for legacy orders." + ], + "type": "i64" + }, + { + "name": "max_slippage", + "docs": [ + "Configured slippage limit, encoded as a u32 fraction (u32::MAX = 100%)." + ], + "type": "u32" + }, + { + "name": "asset_bank", + "docs": [ + "Bank of the surviving tagged asset balance." + ], + "type": "pubkey" + }, + { + "name": "asset_shares_after", + "docs": [ + "Position shares, not token amounts or swap proceeds." + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "triggered", + "docs": [ + "The validated execution branch: StopLoss or TakeProfit, never Both." + ], + "type": { + "defined": { + "name": "OrderTriggerType" + } + } + }, + { + "name": "equity_before_usd", + "docs": [ + "Protocol-valued equity of the tagged order balances immediately before execution." + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "equity_after_usd", + "docs": [ + "Protocol-valued equity after execution. The difference is not realized trading P/L." + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "closure_recipient", + "docs": [ + "Recipient of the closed accounts' lamports; these proceeds are not trading fees." + ], + "type": "pubkey" + }, + { + "name": "order_lamports_returned", + "type": "u64" + } + ] + } + }, + { + "name": "MarginfiAccountFreezeEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "AccountEventHeader" + } + } + }, + { + "name": "frozen", + "type": "bool" + } + ] + } + }, + { + "name": "MarginfiAccountPlaceOrderEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "AccountEventHeader" + } + } + }, + { + "name": "order", + "type": "pubkey" + }, + { + "name": "trigger", + "type": { + "defined": { + "name": "OrderTriggerType" + } + } + }, + { + "name": "stop_loss", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "take_profit", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "tags", + "type": { + "array": [ + "u16", + 2 + ] + } + } + ] + } + }, + { + "name": "MarginfiAccountPlaceRebalanceOrderEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "AccountEventHeader" + } + } + }, + { + "name": "rebalance_order", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "allowed_banks", + "type": { + "vec": "pubkey" + } + }, + { + "name": "min_improvement", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "cooldown_seconds", + "type": "u64" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "keeper_tip", + "type": "u64" + } + ] + } + }, + { + "name": "MarginfiAccountTransferToNewAccount", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "AccountEventHeader" + } + } + }, + { + "name": "old_account", + "type": "pubkey" + }, + { + "name": "old_account_authority", + "type": "pubkey" + }, + { + "name": "new_account_authority", + "type": "pubkey" + } + ] + } + }, + { + "name": "MarginfiAccountUpdateRebalanceOrderEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "AccountEventHeader" + } + } + }, + { + "name": "rebalance_order", + "type": "pubkey" + }, + { + "name": "allowed_banks", + "type": { + "vec": "pubkey" + } + }, + { + "name": "min_improvement", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "cooldown_seconds", + "type": "u64" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "keeper_tip", + "type": "u64" + } + ] + } + }, + { + "name": "MarginfiGroup", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "admin", + "docs": [ + "Broadly able to modify anything, and can set/remove other admins at will.", + "", + "Subsequent to the release of the `governance_admin`, this role can be considered the \"fast\" admin,", + "it can perform various tasks that do not require timelock sensitivity. High-risk activities", + "like changing oracles or bank weights are now under the control of the \"slow\" governance admin." + ], + "type": "pubkey" + }, + { + "name": "group_flags", + "docs": [ + "Bitmask for group settings flags.", + "* Bit 0 (1): `PROGRAM_FEES_ENABLED` — If set, program-level fees are enabled.", + "* Bits 1-63: Reserved for future use." + ], + "type": "u64" + }, + { + "name": "fee_state_cache", + "docs": [ + "Caches information from the global `FeeState` so the FeeState can be omitted on certain ixes" + ], + "type": { + "defined": { + "name": "FeeStateCache" + } + } + }, + { + "name": "banks", + "docs": [ + "For groups initialized in versions 0.1.2 or greater, this is an authoritative count", + "of the number of banks under this group. For groups initialized prior to 0.1.2,", + "a non-authoritative count of the number of banks initiated after 0.1.2 went live." + ], + "type": "u16" + }, + { + "name": "pad0", + "type": { + "array": [ + "u8", + 6 + ] + } + }, + { + "name": "emode_admin", + "docs": [ + "This admin can configure collateral ratios above (but not below) the collateral ratio of", + "certain banks, e.g. allow SOL to count as 90% collateral when borrowing an LST instead of", + "the default rate." + ], + "type": "pubkey" + }, + { + "name": "delegate_curve_admin", + "docs": [ + "Can modify the fields in `config.interest_rate_config` but nothing else, for every bank", + "under this group" + ], + "type": "pubkey" + }, + { + "name": "delegate_limit_admin", + "docs": [ + "Can modify the `deposit_limit`, `borrow_limit`, `total_asset_value_init_limit` but nothing", + "else, for every bank under this group" + ], + "type": "pubkey" + }, + { + "name": "delegate_emissions_admin", + "docs": [ + "DEPRECATED: currently has no on-chain authority.", + "Preserved in account layout for backward compatibility and historical metadata only." + ], + "type": "pubkey" + }, + { + "name": "panic_state_cache", + "docs": [ + "When program keeper temporarily puts the program into panic mode, information about the", + "duration of the lockup will be available here." + ], + "type": { + "defined": { + "name": "PanicStateCache" + } + } + }, + { + "name": "deleverage_withdraw_window_cache", + "docs": [ + "Keeps track of the liquidity withdrawn from the group over the day as a result of", + "deleverages. Used as a protection mechanism against too big (and unwanted) withdrawals (e.g.", + "when the risk admin is compromised)." + ], + "type": { + "defined": { + "name": "WithdrawWindowCache" + } + } + }, + { + "name": "risk_admin", + "docs": [ + "Can run bankruptcy and forced deleverage ixes to e.g. sunset risky/illiquid assets" + ], + "type": "pubkey" + }, + { + "name": "metadata_admin", + "docs": [ + "Can modify a Bank's metadata, and nothing else." + ], + "type": "pubkey" + }, + { + "name": "emode_max_init_leverage", + "docs": [ + "Maximum leverage allowed for emode positions (initial margin), stored as u32 basis.", + "Use `u32_to_basis` to convert to I80F48. Range: 1-100; 0 is unset and bounds nothing." + ], + "type": "u32" + }, + { + "name": "emode_max_maint_leverage", + "docs": [ + "Maximum leverage allowed for emode positions (maintenance margin), stored as u32 basis.", + "Must be > emode_max_init_leverage. Range: 1-100; 0 is unset and bounds nothing." + ], + "type": "u32" + }, + { + "name": "same_asset_emode_init_leverage", + "docs": [ + "Encoded same-asset automatic emode leverage for initial margin.", + "Decode with `u32_to_basis`. Same-asset treatment is disabled when the decoded leverage is", + "less than or equal to 1 and also requires each participating bank to opt in." + ], + "type": "u32" + }, + { + "name": "same_asset_emode_maint_leverage", + "docs": [ + "Encoded same-asset automatic emode leverage for maintenance margin.", + "Decode with `u32_to_basis`. Ordering is validated in decoded space.", + "Eligible banks have their liquidation fees checked against this value only when they opt in", + "while it is enabled or when they change fees. Enabling or raising it does not re-check them,", + "so verify every eligible bank off-chain first." + ], + "type": "u32" + }, + { + "name": "rate_limiter", + "docs": [ + "Rate limiter for controlling aggregate withdraw/borrow outflow across all banks.", + "Tracks net outflow in USD." + ], + "type": { + "defined": { + "name": "GroupRateLimiter" + } + } + }, + { + "name": "rate_limiter_last_admin_update_slot", + "docs": [ + "Last slot covered by an admin group rate limiter aggregation update." + ], + "type": "u64" + }, + { + "name": "rate_limiter_last_admin_update_seq", + "docs": [ + "Monotonic sequence number for admin group rate limiter updates.", + "This is used to enforce strict ordering and prevent duplicate/replayed batches", + "when slot ranges overlap or multiple updates happen in the same slot." + ], + "type": "u64" + }, + { + "name": "deleverage_withdraw_last_admin_update_slot", + "docs": [ + "Last slot covered by an admin deleverage withdraw-limit aggregation update." + ], + "type": "u64" + }, + { + "name": "deleverage_withdraw_last_admin_update_seq", + "docs": [ + "Monotonic sequence number for admin deleverage withdraw-limit updates." + ], + "type": "u64" + }, + { + "name": "delegate_flow_admin", + "docs": [ + "Can modify flow-control status for the group, i.e. update the withdraw caches with flow", + "information from banks. Typically this is a hot wallet that lives in e.g. some cron job. If", + "compromised, flow control can be effectively disabled until the admin is restored, which", + "does not itself compromise any funds, and is merely annoying." + ], + "type": "pubkey" + }, + { + "name": "premium_settings", + "docs": [ + "Header for the pairwise variable-borrow premium matrix stored in `premium_entries`.", + "Occupies the former `_padding_0`/`_padding_1` region of the v1 layout, so v1 accounts", + "resize to a zeroed header (matrix off)." + ], + "type": { + "defined": { + "name": "PremiumSettings" + } + } + }, + { + "name": "premium_entries", + "docs": [ + "Pairwise variable-borrow premium rates, keyed by (collateral `premium_tag`, liability", + "`premium_tag`). Live entries occupy the first `premium_settings.entry_count` slots.", + "Read only via `find_premium_rate`. Future capacity growth carves from `_padding_2`." + ], + "type": { + "array": [ + { + "defined": { + "name": "PremiumEntry" + } + }, + 64 + ] + } + }, + { + "name": "governance_admin", + "docs": [ + "Also called the \"slow\" admin. Dedicated authority for time-locked configuration. Legacy", + "groups have this field zeroed after resize and must be bootstrapped by the fast admin with", + "`marginfi_group_set_governance_admin` before slow-authority operations are available.", + "", + "This is the first 32 bytes of post-v1 reserved space; renaming the field does not alter", + "any serialized account bytes." + ], + "type": "pubkey" + }, + { + "name": "_padding_2", + "type": { + "array": [ + { + "array": [ + "u64", + 32 + ] + }, + 31 + ] + } + }, + { + "name": "_padding_3", + "type": { + "array": [ + "u64", + 28 + ] + } + } + ] + } + }, + { + "name": "MarginfiGroupConfigureEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "GroupEventHeader" + } + } + }, + { + "name": "admin", + "type": { + "option": "pubkey" + } + }, + { + "name": "flags", + "type": "u64" + } + ] + } + }, + { + "name": "MarginfiGroupCreateEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "GroupEventHeader" + } + } + } + ] + } + }, + { + "name": "MinimalLendingMarket", + "docs": [ + "Kamino's `LendingMarket`, mirrored only as far as `reserve_rewards_max_apr_bps`, which caps", + "every reserve's rewards emission. Size matches klend's `LENDING_MARKET_SIZE`.", + "https://github.com/Kamino-Finance/klend/blob/master/programs/klend/src/state/lending_market.rs#L230" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "_version", + "type": "u64" + }, + { + "name": "_bump_seed", + "type": "u64" + }, + { + "name": "_lending_market_owner", + "type": "pubkey" + }, + { + "name": "_lending_market_owner_cached", + "type": "pubkey" + }, + { + "name": "_quote_currency", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "_referral_fee_bps", + "type": "u16" + }, + { + "name": "emergency_mode", + "docs": [ + "Non-zero when Kamino has halted the entire market, the market-wide counterpart of", + "`ReserveConfig.emergency_mode`." + ], + "type": "u8" + }, + { + "name": "_padding1", + "type": { + "array": [ + "u8", + 2048 + ] + } + }, + { + "name": "_padding2", + "type": { + "array": [ + "u8", + 1024 + ] + } + }, + { + "name": "_padding3", + "type": { + "array": [ + "u8", + 128 + ] + } + }, + { + "name": "_padding4", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "_padding5", + "type": { + "array": [ + "u8", + 2 + ] + } + }, + { + "name": "_padding6", + "type": { + "array": [ + "u8", + 1 + ] + } + }, + { + "name": "reserve_rewards_max_apr_bps", + "docs": [ + "Ceiling on the APR a reserve may emit as rewards, in bps." + ], + "type": "u16" + }, + { + "name": "_padding7", + "type": { + "array": [ + "u8", + 1024 + ] + } + }, + { + "name": "_padding8", + "type": { + "array": [ + "u8", + 256 + ] + } + }, + { + "name": "_padding9", + "type": { + "array": [ + "u8", + 24 + ] + } + } + ] + } + }, + { + "name": "MinimalObligation", + "docs": [ + "A minimal copy of Kamino's Obligation for zero-copy deserialization" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "tag", + "type": "u64" + }, + { + "name": "last_update_slot", + "docs": [ + "Kamino obligations are only good for one slot, e.g. `refresh_obligation` must have run within the", + "same slot as any ix that needs a non-stale obligation e.g. withdraw." + ], + "type": "u64" + }, + { + "name": "last_update_stale", + "docs": [ + "True if the obligation is stale, which will cause various ixes like withdraw to fail. Typically", + "set to true in any tx that modifies obligation balance, and set to false at the end of a", + "successful `refresh_obligation`", + "* 0 = false, 1 = true" + ], + "type": "u8" + }, + { + "name": "last_update_price_status", + "docs": [ + "Each bit represents a passed check in price status.", + "* 63 = all checks passed", + "", + "Otherwise:", + "* PRICE_LOADED = 0b_0000_0001; // 1", + "* PRICE_AGE_CHECKED = 0b_0000_0010; // 2", + "* TWAP_CHECKED = 0b_0000_0100; // 4", + "* TWAP_AGE_CHECKED = 0b_0000_1000; // 8", + "* HEURISTIC_CHECKED = 0b_0001_0000; // 16", + "* PRICE_USAGE_ALLOWED = 0b_0010_0000; // 32" + ], + "type": "u8" + }, + { + "name": "last_update_placeholder", + "type": { + "array": [ + "u8", + 6 + ] + } + }, + { + "name": "lending_market", + "type": "pubkey" + }, + { + "name": "owner", + "docs": [ + "For mrgn banks, the bank's Liquidity Vault Authority (a pda which can be derived if the bank", + "key is known)" + ], + "type": "pubkey" + }, + { + "name": "deposits", + "type": { + "array": [ + { + "defined": { + "name": "MinimalObligationCollateral" + } + }, + 8 + ] + } + }, + { + "name": "lowest_reserve_deposit_liquidation_ltv", + "type": "u64" + }, + { + "name": "deposited_value_sf", + "type": { + "array": [ + "u8", + 16 + ] + } + }, + { + "name": "_padding1", + "type": { + "array": [ + "u8", + 2048 + ] + } + }, + { + "name": "padding_part5a", + "type": { + "array": [ + "u8", + 64 + ] + } + }, + { + "name": "padding_part5c", + "type": { + "array": [ + "u8", + 24 + ] + } + } + ] + } + }, + { + "name": "MinimalObligationCollateral", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "deposit_reserve", + "type": "pubkey" + }, + { + "name": "deposited_amount", + "docs": [ + "In collateral token (NOT liquidity token), use `collateral_to_liquidity` to convert back to", + "liquidity token!", + "* Always 6 decimals" + ], + "type": "u64" + }, + { + "name": "market_value_sf", + "docs": [ + "* In dollars, based on last oracle price update", + "* Actually an I68F60, stored as a u128 (i.e. BN) in Kamino.", + "* A float (arbitrary decimals)" + ], + "type": { + "array": [ + "u8", + 16 + ] + } + }, + { + "name": "borrowed_amount_against_this_collateral_in_elevation_group", + "type": "u64" + }, + { + "name": "padding", + "type": { + "array": [ + "u64", + 9 + ] + } + } + ] + } + }, + { + "name": "MinimalReserve", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "version", + "type": "u64" + }, + { + "name": "slot", + "docs": [ + "Kamino reserves are only good for one slot, e.g. `refresh_reserve` must have run within the", + "same slot as any ix that needs a non-stale reserve e.g. withdraw." + ], + "type": "u64" + }, + { + "name": "stale", + "docs": [ + "True if the reserve is stale, which will cause various ixes like withdraw to fail. Typically", + "set to true in any tx that modifies reserve balance, and set to false at the end of a", + "successful `refresh_reserve`", + "* 0 = false, 1 = true" + ], + "type": "u8" + }, + { + "name": "price_status", + "docs": [ + "Each bit represents a passed check in price status.", + "* 63 = all checks passed", + "", + "Otherwise:", + "* PRICE_LOADED = 0b_0000_0001; // 1", + "* PRICE_AGE_CHECKED = 0b_0000_0010; // 2", + "* TWAP_CHECKED = 0b_0000_0100; // 4", + "* TWAP_AGE_CHECKED = 0b_0000_1000; // 8", + "* HEURISTIC_CHECKED = 0b_0001_0000; // 16", + "* PRICE_USAGE_ALLOWED = 0b_0010_0000; // 32" + ], + "type": "u8" + }, + { + "name": "placeholder", + "type": { + "array": [ + "u8", + 6 + ] + } + }, + { + "name": "lending_market", + "type": "pubkey" + }, + { + "name": "farm_collateral", + "type": "pubkey" + }, + { + "name": "farm_debt", + "type": "pubkey" + }, + { + "name": "mint_pubkey", + "type": "pubkey" + }, + { + "name": "supply_vault", + "docs": [ + "* A PDA" + ], + "type": "pubkey" + }, + { + "name": "fee_vault", + "docs": [ + "* A PDA" + ], + "type": "pubkey" + }, + { + "name": "available_amount", + "docs": [ + "In simple terms: (amount in supply vault - outstanding borrows)", + "* In token, with `mint_decimals`" + ], + "type": "u64" + }, + { + "name": "borrowed_amount_sf", + "docs": [ + "* In token, with `mint_decimals`", + "* Actually an I68F60, stored as a u128 (i.e. BN) in Kamino." + ], + "type": { + "array": [ + "u8", + 16 + ] + } + }, + { + "name": "market_price_sf", + "docs": [ + "* Actually an I68F60, stored as a u128 (i.e. BN) in Kamino." + ], + "type": { + "array": [ + "u8", + 16 + ] + } + }, + { + "name": "market_price_last_updated_ts", + "type": "u64" + }, + { + "name": "mint_decimals", + "type": "u64" + }, + { + "name": "deposit_limit_crossed_timestamp", + "type": "u64" + }, + { + "name": "borrow_limit_crossed_timestamp", + "type": "u64" + }, + { + "name": "cumulative_borrow_rate_bsf", + "type": { + "array": [ + "u8", + 48 + ] + } + }, + { + "name": "accumulated_protocol_fees_sf", + "docs": [ + "* In token, with `mint_decimals`", + "* Actually an I68F60, stored as a u128 (i.e. BN) in Kamino." + ], + "type": { + "array": [ + "u8", + 16 + ] + } + }, + { + "name": "accumulated_referrer_fees_sf", + "docs": [ + "* In token, with `mint_decimals`", + "* Actually an I68F60, stored as a u128 (i.e. BN) in Kamino." + ], + "type": { + "array": [ + "u8", + 16 + ] + } + }, + { + "name": "pending_referrer_fees_sf", + "docs": [ + "* In token, with `mint_decimals`", + "* Actually an I68F60, stored as a u128 (i.e. BN) in Kamino." + ], + "type": { + "array": [ + "u8", + 16 + ] + } + }, + { + "name": "absolute_referral_rate_sf", + "docs": [ + "* In token, with `mint_decimals`", + "* Actually an I68F60, stored as a u128 (i.e. BN) in Kamino." + ], + "type": { + "array": [ + "u8", + 16 + ] + } + }, + { + "name": "token_program", + "docs": [ + "Token or Token22. If token22, note that Kamino does not support all Token22 extensions." + ], + "type": "pubkey" + }, + { + "name": "rewards_amount_available", + "docs": [ + "Undistributed reward tokens, native mint units. `distribute_rewards` moves these into", + "`available_amount`, raising the cToken exchange rate." + ], + "type": "u64" + }, + { + "name": "_padding1", + "type": { + "array": [ + "u8", + 512 + ] + } + }, + { + "name": "_padding2", + "type": { + "array": [ + "u8", + 256 + ] + } + }, + { + "name": "_padding3", + "type": { + "array": [ + "u8", + 128 + ] + } + }, + { + "name": "_padding4", + "type": { + "array": [ + "u8", + 16 + ] + } + }, + { + "name": "_padding5", + "type": { + "array": [ + "u8", + 1024 + ] + } + }, + { + "name": "_padding6", + "type": { + "array": [ + "u8", + 128 + ] + } + }, + { + "name": "_padding7", + "type": { + "array": [ + "u8", + 48 + ] + } + }, + { + "name": "collateral_mint_pubkey", + "docs": [ + "Mints collateral tokens", + "* A PDA", + "* technically 6 decimals, but uses `mint_decimals` regardless for all purposes", + "* authority = lending_market_authority" + ], + "type": "pubkey" + }, + { + "name": "mint_total_supply", + "docs": [ + "Total number of collateral tokens", + "* uses `mint_decimals`, even though it's technically 6 decimals under the hood" + ], + "type": "u64" + }, + { + "name": "collateral_supply_vault", + "docs": [ + "* A PDA" + ], + "type": "pubkey" + }, + { + "name": "_padding8", + "type": { + "array": [ + "u8", + 1024 + ] + } + }, + { + "name": "_padding9", + "type": { + "array": [ + "u8", + 1024 + ] + } + }, + { + "name": "_padding10", + "type": { + "array": [ + "u8", + 128 + ] + } + }, + { + "name": "_padding11", + "type": { + "array": [ + "u8", + 48 + ] + } + }, + { + "name": "config", + "type": { + "defined": { + "name": "ReserveConfig" + } + } + }, + { + "name": "_padding12", + "type": { + "array": [ + "u8", + 2048 + ] + } + }, + { + "name": "_padding13", + "type": { + "array": [ + "u8", + 512 + ] + } + }, + { + "name": "_padding14", + "type": { + "array": [ + "u8", + 256 + ] + } + } + ] + } + }, + { + "name": "MinimalSpotMarket", + "docs": [ + "Minimal representation of Drift's SpotMarket account", + "Only includes the fields we actually need for marginfi integration", + "https://github.com/drift-labs/protocol-v2/blob/master/programs/drift/src/state/spot_market.rs#L33-L211" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "pubkey", + "docs": [ + "The address of the spot market. It is a pda of the market index" + ], + "type": "pubkey" + }, + { + "name": "oracle", + "docs": [ + "The oracle used to price the markets deposits/borrows" + ], + "type": "pubkey" + }, + { + "name": "mint", + "docs": [ + "The token mint of the market" + ], + "type": "pubkey" + }, + { + "name": "vault", + "docs": [ + "The vault used to store the market's deposits" + ], + "type": "pubkey" + }, + { + "name": "name", + "docs": [ + "SpotMarket fields between `vault` and `insurance_fund`; unused by marginfi, sized to match", + "upstream." + ], + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "historical_oracle_data", + "type": { + "array": [ + "u64", + 6 + ] + } + }, + { + "name": "historical_index_data", + "type": { + "array": [ + "u64", + 5 + ] + } + }, + { + "name": "revenue_pool", + "type": { + "array": [ + "u64", + 3 + ] + } + }, + { + "name": "spot_fee_pool", + "type": { + "array": [ + "u64", + 3 + ] + } + }, + { + "name": "insurance_fund", + "type": { + "defined": { + "name": "InsuranceFund" + } + } + }, + { + "name": "total_spot_fee", + "type": { + "array": [ + "u64", + 2 + ] + } + }, + { + "name": "deposit_balance", + "docs": [ + "All the fields we need for testing (stored as raw bytes for simplicity)" + ], + "type": { + "array": [ + "u8", + 16 + ] + } + }, + { + "name": "borrow_balance", + "type": { + "array": [ + "u8", + 16 + ] + } + }, + { + "name": "cumulative_deposit_interest", + "type": { + "array": [ + "u8", + 16 + ] + } + }, + { + "name": "cumulative_borrow_interest", + "type": { + "array": [ + "u8", + 16 + ] + } + }, + { + "name": "_padding1", + "type": { + "array": [ + "u64", + 5 + ] + } + }, + { + "name": "max_token_deposits", + "docs": [ + "Deposit ceiling in native mint precision; `0` is uncapped." + ], + "type": "u64" + }, + { + "name": "_padding2", + "type": { + "array": [ + "u64", + 3 + ] + } + }, + { + "name": "last_interest_ts", + "docs": [ + "Last time the cumulative deposit and borrow interest was updated", + "Offset: 568 bytes from start of struct (including discriminator)" + ], + "type": "u64" + }, + { + "name": "_padding3", + "type": { + "array": [ + "u64", + 11 + ] + } + }, + { + "name": "_padding4", + "type": { + "array": [ + "u8", + 4 + ] + } + }, + { + "name": "optimal_utilization", + "docs": [ + "Drift spot interest-rate curve params (`SpotMarket`), precision 1e6." + ], + "type": "u32" + }, + { + "name": "optimal_borrow_rate", + "type": "u32" + }, + { + "name": "max_borrow_rate", + "type": "u32" + }, + { + "name": "decimals", + "type": "u32" + }, + { + "name": "market_index", + "type": "u16" + }, + { + "name": "_padding5", + "type": { + "array": [ + "u16", + 1 + ] + } + }, + { + "name": "status", + "docs": [ + "`MarketStatus`; `0` is `Initialized`, the warm-up state that rejects deposits, and `1` is", + "`Active`." + ], + "type": "u8" + }, + { + "name": "_padding6", + "type": { + "array": [ + "u8", + 1 + ] + } + }, + { + "name": "paused_operations", + "docs": [ + "`SpotOperation` pause bitmask; bit 0 (`UpdateCumulativeInterest`) stops interest accrual." + ], + "type": "u8" + }, + { + "name": "_padding7", + "type": { + "array": [ + "u8", + 30 + ] + } + }, + { + "name": "_padding8", + "type": { + "array": [ + "u8", + 7 + ] + } + }, + { + "name": "min_borrow_rate", + "docs": [ + "Borrow-rate floor, in units of `PERCENTAGE_PRECISION / 200`." + ], + "type": "u8" + }, + { + "name": "_padding9", + "type": { + "array": [ + "u8", + 6 + ] + } + }, + { + "name": "pool_id", + "type": "u8" + }, + { + "name": "_padding10", + "docs": [ + "Padding to reach 776 bytes total (including discriminator)" + ], + "type": { + "array": [ + "u64", + 5 + ] + } + } + ] + } + }, + { + "name": "MinimalUser", + "docs": [ + "Minimal representation of Drift's User account", + "Only includes the fields we actually need" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", + "docs": [ + "The owner/authority of the account" + ], + "type": "pubkey" + }, + { + "name": "delegate", + "docs": [ + "An addresses that can control the account on the authority's behalf" + ], + "type": "pubkey" + }, + { + "name": "name", + "docs": [ + "Encoded display name for the account" + ], + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "spot_positions", + "docs": [ + "The user's spot positions (8 positions)" + ], + "type": { + "array": [ + { + "defined": { + "name": "SpotPosition" + } + }, + 8 + ] + } + }, + { + "name": "_padding1", + "docs": [ + "Skip to the fields we need at the end" + ], + "type": { + "array": [ + "u64", + 256 + ] + } + }, + { + "name": "_padding2", + "type": { + "array": [ + "u64", + 128 + ] + } + }, + { + "name": "_padding3", + "type": { + "array": [ + "u64", + 64 + ] + } + }, + { + "name": "_padding4", + "type": { + "array": [ + "u64", + 32 + ] + } + }, + { + "name": "_padding5", + "type": { + "array": [ + "u64", + 8 + ] + } + }, + { + "name": "_padding6", + "type": { + "array": [ + "u64", + 2 + ] + } + }, + { + "name": "_padding7", + "type": { + "array": [ + "u16", + 1 + ] + } + }, + { + "name": "sub_account_id", + "docs": [ + "Sub account id for this user account" + ], + "type": "u16" + }, + { + "name": "status", + "type": { + "defined": { + "name": "UserStatus" + } + } + }, + { + "name": "_padding8", + "type": { + "array": [ + "u8", + 27 + ] + } + } + ] + } + }, + { + "name": "OracleSetup", + "repr": { + "kind": "rust" + }, + "type": { + "kind": "enum", + "variants": [ + { + "name": "None" + }, + { + "name": "PythLegacy" + }, + { + "name": "SwitchboardV2" + }, + { + "name": "PythPushOracle" + }, + { + "name": "SwitchboardPull" + }, + { + "name": "StakedWithPythPush" + }, + { + "name": "KaminoPythPush" + }, + { + "name": "KaminoSwitchboardPull" + }, + { + "name": "Fixed" + }, + { + "name": "DriftPythPull" + }, + { + "name": "DriftSwitchboardPull" + }, + { + "name": "SolendPythPull" + }, + { + "name": "SolendSwitchboardPull" + }, + { + "name": "FixedKamino" + }, + { + "name": "FixedDrift" + }, + { + "name": "JuplendPythPull" + }, + { + "name": "JuplendSwitchboardPull" + }, + { + "name": "FixedJuplend" + }, + { + "name": "Scope" + }, + { + "name": "PythMSOL" + }, + { + "name": "KaminoMSOL" + }, + { + "name": "JuplendMSOL" + }, + { + "name": "PythLST" + }, + { + "name": "KaminoLST" + }, + { + "name": "JuplendLST" + }, + { + "name": "PTPyth" + }, + { + "name": "PTFixed" + }, + { + "name": "ScopeKamino" + }, + { + "name": "ScopeJuplend" + } + ] + } + }, + { + "name": "Order", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "marginfi_account", + "type": "pubkey" + }, + { + "name": "stop_loss", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "take_profit", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "created_at", + "docs": [ + "Unix timestamp (seconds) when the order was created. Reads 0 for orders created before this", + "field existed (it was previously a reserved placeholder; same 8 bytes, so layout-compatible)." + ], + "type": "i64" + }, + { + "name": "max_slippage", + "docs": [ + "* a %, as u32, out of 100%, e.g. 50% = .5 * u32::MAX" + ], + "type": "u32" + }, + { + "name": "pad0", + "type": { + "array": [ + "u8", + 4 + ] + } + }, + { + "name": "tags", + "docs": [ + "Active tags (currently 2). Remaining capacity is stored in padding for layout compatibility.", + "Padding byte `ORDER_TAG_PADDING - 1` stores the tag count for forward compatibility. (u16 *", + "2 = 4 bytes)" + ], + "type": { + "array": [ + "u16", + 2 + ] + } + }, + { + "name": "pad1", + "type": { + "array": [ + "u8", + 4 + ] + } + }, + { + "name": "_tags_padding", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "trigger", + "docs": [ + "Stop Loss (0), Take Profit (1), or Both (2)" + ], + "type": { + "defined": { + "name": "OrderTriggerType" + } + } + }, + { + "name": "bump", + "docs": [ + "Bump to derive this pda" + ], + "type": "u8" + }, + { + "name": "pad2", + "type": { + "array": [ + "u8", + 6 + ] + } + }, + { + "name": "_reserved1", + "type": { + "array": [ + { + "array": [ + "u8", + 32 + ] + }, + 4 + ] + } + } + ] + } + }, + { + "name": "OrderTrigger", + "repr": { + "kind": "c" + }, + "type": { + "kind": "enum", + "variants": [ + { + "name": "StopLoss", + "fields": [ + { + "name": "threshold", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "max_slippage", + "type": "u32" + } + ] + }, + { + "name": "TakeProfit", + "fields": [ + { + "name": "threshold", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "max_slippage", + "type": "u32" + } + ] + }, + { + "name": "Both", + "fields": [ + { + "name": "stop_loss", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "take_profit", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "max_slippage", + "type": "u32" + } + ] + } + ] + } + }, + { + "name": "OrderTriggerType", + "repr": { + "kind": "rust" + }, + "type": { + "kind": "enum", + "variants": [ + { + "name": "StopLoss" + }, + { + "name": "TakeProfit" + }, + { + "name": "Both" + } + ] + } + }, + { + "name": "PanicState", + "docs": [ + "Panic state for emergency protocol pausing" + ], + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "pause_flags", + "docs": [ + "Whether the protocol is currently paused (1 = paused, 0 = not paused)" + ], + "type": "u8" + }, + { + "name": "daily_pause_count", + "docs": [ + "Number of times paused today (resets every 24 hours)" + ], + "type": "u8" + }, + { + "name": "consecutive_pause_count", + "docs": [ + "Number of consecutive pauses (resets when unpause happens)" + ], + "type": "u8" + }, + { + "name": "_reserved", + "type": { + "array": [ + "u8", + 5 + ] + } + }, + { + "name": "pause_start_timestamp", + "docs": [ + "Timestamp when the current pause started (0 if not paused)", + "* When a pause is extended before expiring, this could be in the future." + ], + "type": "i64" + }, + { + "name": "last_daily_reset_timestamp", + "docs": [ + "Timestamp of the last daily reset (for tracking daily pause count)" + ], + "type": "i64" + }, + { + "name": "_reserved_space", + "docs": [ + "Reserved for future use (making total struct 32 bytes)" + ], + "type": { + "array": [ + "u8", + 8 + ] + } + } + ] + } + }, + { + "name": "PanicStateCache", + "docs": [ + "Cached panic state information for fast checking during user operations" + ], + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "pause_flags", + "docs": [ + "Whether the protocol is currently paused (1 = paused, 0 = not paused)" + ], + "type": "u8" + }, + { + "name": "_reserved", + "type": { + "array": [ + "u8", + 7 + ] + } + }, + { + "name": "pause_start_timestamp", + "docs": [ + "Timestamp when the current pause started (0 if not paused)" + ], + "type": "i64" + }, + { + "name": "last_cache_update", + "docs": [ + "Timestamp when this cache was last updated" + ], + "type": "i64" + } + ] + } + }, + { + "name": "PremiumEntry", + "docs": [ + "One pairwise variable-borrow premium rate: accounts lending collateral tagged", + "`collateral_tag` pay an extra `rate` APR (proportional to that collateral's share of their", + "total collateral) when borrowing from banks tagged `liability_tag`." + ], + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "collateral_tag", + "docs": [ + "`premium_tag` of the collateral bank(s) this surcharge applies to. 0 = empty slot." + ], + "type": "u16" + }, + { + "name": "liability_tag", + "docs": [ + "`premium_tag` of the liability bank(s) this surcharge applies to. 0 = empty slot." + ], + "type": "u16" + }, + { + "name": "rate", + "docs": [ + "Premium APR for this pair, encoded like interest-curve points via `milli_to_u32`", + "(0-1000%)." + ], + "type": "u32" + } + ] + } + }, + { + "name": "PremiumSettings", + "docs": [ + "Header for the group's pairwise variable-borrow premium matrix.", + "* `entry_count > 0` is the single source of truth for whether the matrix is configured." + ], + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "timestamp", + "docs": [ + "Unix timestamp from the system clock when the premium matrix was last updated." + ], + "type": "i64" + }, + { + "name": "entry_count", + "docs": [ + "Number of live entries at the start of `premium_entries`. 0 = matrix off." + ], + "type": "u16" + }, + { + "name": "entry_capacity", + "docs": [ + "Storage capacity for entries. `MAX_PREMIUM_ENTRIES` for groups at the current account", + "size; a future group-account resize may raise this." + ], + "type": "u16" + }, + { + "name": "_pad0", + "type": { + "array": [ + "u8", + 4 + ] + } + }, + { + "name": "_reserved0", + "docs": [ + "Reserved for future use" + ], + "type": { + "array": [ + "u64", + 2 + ] + } + } + ] + } + }, + { + "name": "RateLimitFlowEvent", + "docs": [ + "Emitted when a bank-level inflow or outflow is recorded.", + "The delegate flow admin aggregates these off-chain and", + "updates the group rate limiter via `update_group_rate_limiter`." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "group", + "type": "pubkey" + }, + { + "name": "bank", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "flow_direction", + "docs": [ + "0 = outflow (withdraw/borrow), 1 = inflow (deposit/repay)" + ], + "type": "u8" + }, + { + "name": "native_amount", + "docs": [ + "Amount in native tokens" + ], + "type": "u64" + }, + { + "name": "mint_decimals", + "type": "u8" + }, + { + "name": "current_timestamp", + "docs": [ + "Unix timestamp when the flow was recorded" + ], + "type": "i64" + } + ] + } + }, + { + "name": "RateLimitWindow", + "docs": [ + "A sliding window rate limiter that tracks net outflow over a time window.", + "Uses weighted blend of previous and current windows for smooth transitions.", + "", + "Net outflow = (withdraws + borrows) - (deposits + repays).", + "A negative net outflow increases remaining capacity for subsequent outflows." + ], + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "max_outflow", + "docs": [ + "Maximum net outflow allowed per window (0 = disabled).", + "For bank-level: denominated in native tokens.", + "For group-level: denominated in USD." + ], + "type": "u64" + }, + { + "name": "window_duration", + "docs": [ + "Window duration in seconds (e.g., 3600 for hourly, 86400 for daily)." + ], + "type": "u64" + }, + { + "name": "window_start", + "docs": [ + "Unix timestamp when the current window started." + ], + "type": "i64" + }, + { + "name": "prev_window_outflow", + "docs": [ + "Net outflow accumulated in the previous window.", + "Signed to allow tracking when inflows exceed outflows." + ], + "type": "i64" + }, + { + "name": "cur_window_outflow", + "docs": [ + "Net outflow accumulated in the current window.", + "Signed to allow tracking when inflows exceed outflows." + ], + "type": "i64" + } + ] + } + }, + { + "name": "RatePoint", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "util", + "docs": [ + "The utilization rate where `rate` applies", + "* a %, as u32, out of 100%, e.g. 50% = .5 * u32::MAX" + ], + "type": "u32" + }, + { + "name": "rate", + "docs": [ + "The base rate that applies", + "* a %, as u32, out of 1000%, e.g. 100% = 0.1 * u32::MAX" + ], + "type": "u32" + } + ] + } + }, + { + "name": "RebalanceExecutedEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "AccountEventHeader" + } + } + }, + { + "name": "rebalance_order", + "type": "pubkey" + }, + { + "name": "executor", + "type": "pubkey" + }, + { + "name": "bank_count", + "type": "u8" + }, + { + "name": "value_moved", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "tip_escrowed", + "docs": [ + "Lamports escrowed into the rebalance record, released later by `settle_rebalance_tip`." + ], + "type": "u64" + } + ] + } + }, + { + "name": "RebalanceFeePoolTopUpEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "AccountEventHeader" + } + } + }, + { + "name": "fee_pool", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "new_balance", + "type": "u64" + } + ] + } + }, + { + "name": "RebalanceFeePoolWithdrawEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "AccountEventHeader" + } + } + }, + { + "name": "fee_pool", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "new_balance", + "type": "u64" + } + ] + } + }, + { + "name": "RebalanceMove", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "src_index", + "type": "u8" + }, + { + "name": "dst_index", + "type": "u8" + }, + { + "name": "_pad0", + "type": { + "array": [ + "u8", + 6 + ] + } + }, + { + "name": "amount", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + } + ] + } + }, + { + "name": "RebalanceOrder", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "marginfi_account", + "docs": [ + "The marginfi account this order belongs to." + ], + "type": "pubkey" + }, + { + "name": "authority", + "docs": [ + "The account authority (may cancel the order)." + ], + "type": "pubkey" + }, + { + "name": "mint", + "docs": [ + "The single SPL mint this order rotates across venues; every referenced bank must hold this mint." + ], + "type": "pubkey" + }, + { + "name": "allowed_banks", + "docs": [ + "Venue allowlist: the first `allowed_bank_count` entries are the banks this order may rotate", + "across; the rest are zero. Stored in full (not a hash) so a keeper discovers the set from a", + "single account read and `start_rebalance` validates that every referenced bank ∈ list against", + "on-chain state." + ], + "type": { + "array": [ + "pubkey", + 8 + ] + } + }, + { + "name": "min_improvement", + "docs": [ + "Minimum required APR improvement (dst - src) to move, I80F48 (1.0 = 100%)." + ], + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "cooldown_seconds", + "docs": [ + "Minimum wall-clock seconds between executions (anti-ping-pong cooldown)." + ], + "type": "u64" + }, + { + "name": "amount", + "docs": [ + "Per-execution token budget: each execution may relocate at most this many underlying tokens", + "(raw native units of the shared mint) summed across all referenced banks. `0` means no cap." + ], + "type": "u64" + }, + { + "name": "last_exec_timestamp", + "docs": [ + "Unix timestamp (seconds) of the last successful rebalance." + ], + "type": "u64" + }, + { + "name": "bump", + "docs": [ + "PDA bump." + ], + "type": "u8" + }, + { + "name": "allowed_bank_count", + "docs": [ + "Number of populated entries in `allowed_banks` (2..=MAX_ALLOWED_BANKS)." + ], + "type": "u8" + }, + { + "name": "_pad0", + "type": { + "array": [ + "u8", + 6 + ] + } + }, + { + "name": "keeper_tip", + "docs": [ + "Lamport tip a keeper earns for relocating the order's full target, paid proportionally to the", + "tokens actually moved and drawn from the account's rebalance fee pool. 0 = no tip." + ], + "type": "u64" + } + ] + } + }, + { + "name": "RebalanceRecord", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "order", + "type": "pubkey" + }, + { + "name": "marginfi_account", + "docs": [ + "The account the record belongs to; `settle_rebalance_tip` pays from and refunds to this", + "account's fee pool." + ], + "type": "pubkey" + }, + { + "name": "executor", + "type": "pubkey" + }, + { + "name": "ref_banks", + "docs": [ + "The distinct banks this execution touches (first `ref_bank_count` entries), with start", + "amounts and order tags." + ], + "type": { + "array": [ + { + "defined": { + "name": "RebalanceRefBank" + } + }, + 8 + ] + } + }, + { + "name": "moves", + "docs": [ + "The declared token moves (first `move_count` entries), referencing `ref_banks` by index." + ], + "type": { + "array": [ + { + "defined": { + "name": "RebalanceMove" + } + }, + 8 + ] + } + }, + { + "name": "balance_states", + "docs": [ + "Snapshot of every active balance NOT in the referenced set; end verifies these unchanged." + ], + "type": { + "array": [ + { + "defined": { + "name": "ExecuteOrderBalanceRecord" + } + }, + 15 + ] + } + }, + { + "name": "pre_rate", + "docs": [ + "Per-referenced-bank supply rate captured at `start_rebalance`, before the move. `end_rebalance`", + "requires each move's post-deposit destination rate to still beat its source's rate from here." + ], + "type": { + "array": [ + { + "defined": { + "name": "WrappedI80F48" + } + }, + 8 + ] + } + }, + { + "name": "move_yield_index", + "docs": [ + "Per-referenced-bank yield index (`asset_share_value` × venue multiplier) captured at", + "`end_rebalance`. `settle_rebalance_tip` compares current indices against these to require the", + "destinations actually out-yielded the sources over the settlement window." + ], + "type": { + "array": [ + { + "defined": { + "name": "WrappedI80F48" + } + }, + 8 + ] + } + }, + { + "name": "move_timestamp", + "docs": [ + "Unix seconds when the move completed (`end_rebalance`); the settlement window opens", + "`move_timestamp + settle_delay`." + ], + "type": "u64" + }, + { + "name": "pending_tip", + "docs": [ + "Keeper tip escrowed into this record at `end_rebalance`, paid to `executor` on a realized", + "settlement or refunded to the fee pool otherwise (lamports)." + ], + "type": "u64" + }, + { + "name": "settle_delay", + "docs": [ + "Settlement delay in seconds, captured at `end_rebalance` from the order's cooldown at move", + "time (clamped to [SETTLE_DELAY_MIN, SETTLE_DELAY_MAX]);" + ], + "type": "u64" + }, + { + "name": "ref_bank_count", + "type": "u8" + }, + { + "name": "move_count", + "type": "u8" + }, + { + "name": "active_balance_count", + "type": "u8" + }, + { + "name": "_pad0", + "type": { + "array": [ + "u8", + 5 + ] + } + } + ] + } + }, + { + "name": "RebalanceRefBank", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "bank", + "type": "pubkey" + }, + { + "name": "pre_underlying", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "tag", + "type": "u16" + }, + { + "name": "_pad0", + "type": { + "array": [ + "u8", + 6 + ] + } + } + ] + } + }, + { + "name": "RebalanceTipSettledEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "AccountEventHeader" + } + } + }, + { + "name": "rebalance_order", + "type": "pubkey" + }, + { + "name": "executor", + "type": "pubkey" + }, + { + "name": "realized", + "docs": [ + "Whether every move's destination out-yielded its source over the settlement window." + ], + "type": "bool" + }, + { + "name": "tip_paid", + "docs": [ + "Lamports the executor received. Nonzero without `realized` when the escrow was forfeited", + "because the fee pool had been drained below its rent-exempt reserve." + ], + "type": "u64" + } + ] + } + }, + { + "name": "ReserveConfig", + "docs": [ + "Mirrors Kamino's `ReserveConfig` through `borrow_rate_curve`; the remaining trailing fields are", + "grouped as `_rest`. Total size matches Kamino's `RESERVE_CONFIG_SIZE` (952).", + "https://github.com/Kamino-Finance/klend/blob/master/programs/klend/src/state/reserve.rs#L1573-L1602" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "status", + "type": "u8" + }, + { + "name": "asset_tier", + "type": "u8" + }, + { + "name": "host_fixed_interest_rate_bps", + "type": "u16" + }, + { + "name": "min_deleveraging_bonus_bps", + "type": "u16" + }, + { + "name": "block_ctoken_usage", + "type": "u8" + }, + { + "name": "early_repay_remaining_interest_pct", + "type": "u8" + }, + { + "name": "emergency_mode", + "type": "u8" + }, + { + "name": "interest_rate_basis", + "docs": [ + "klend `InterestRateBasis` as its raw byte. Read through [`InterestRateBasis::from_u8`]." + ], + "type": "u8" + }, + { + "name": "_padding1", + "type": { + "array": [ + "u8", + 3 + ] + } + }, + { + "name": "protocol_order_execution_fee_pct", + "type": "u8" + }, + { + "name": "protocol_take_rate_pct", + "docs": [ + "Percentage of interest taken by the protocol (0..100). Read as `from_percent(pct)`." + ], + "type": "u8" + }, + { + "name": "_padding2", + "type": { + "array": [ + "u8", + 48 + ] + } + }, + { + "name": "_padding3", + "type": { + "array": [ + "u8", + 1 + ] + } + }, + { + "name": "borrow_rate_curve", + "type": { + "defined": { + "name": "BorrowRateCurve" + } + } + }, + { + "name": "borrow_factor_pct", + "type": "u64" + }, + { + "name": "deposit_limit", + "docs": [ + "Total liquidity ceiling in native mint units; `u64::MAX` is unlimited." + ], + "type": "u64" + }, + { + "name": "borrow_limit", + "type": "u64" + }, + { + "name": "_padding4", + "type": { + "array": [ + "u8", + 512 + ] + } + }, + { + "name": "_padding5", + "type": { + "array": [ + "u8", + 128 + ] + } + }, + { + "name": "_padding6", + "type": { + "array": [ + "u8", + 96 + ] + } + }, + { + "name": "_padding7", + "type": { + "array": [ + "u8", + 24 + ] + } + }, + { + "name": "rewards_amount_per_accrual_unit", + "docs": [ + "Reward tokens emitted per accrual unit (a slot or a second, by `interest_rate_basis`),", + "native mint units." + ], + "type": "u64" + }, + { + "name": "_padding8", + "type": { + "array": [ + "u8", + 8 + ] + } + } + ] + } + }, + { + "name": "RiskTier", + "repr": { + "kind": "rust" + }, + "type": { + "kind": "enum", + "variants": [ + { + "name": "Collateral" + }, + { + "name": "Isolated" + } + ] + } + }, + { + "name": "SameAssetEmodeBank", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "bank", + "type": "pubkey" + }, + { + "name": "group_index", + "docs": [ + "Index into `SameAssetEmodeRegistry.groups`." + ], + "type": "u8" + }, + { + "name": "_padding", + "type": { + "array": [ + "u8", + 7 + ] + } + } + ] + } + }, + { + "name": "SameAssetEmodeGroup", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "oracle_key", + "docs": [ + "The canonical price source, matching `Bank.config.oracle_keys[0]`." + ], + "type": "pubkey" + } + ] + } + }, + { + "name": "SameAssetEmodeRegistry", + "docs": [ + "Read-only archive of same-asset-emode banks. Enables the emode admin to see, at a glance, which", + "banks are participating in same-asset-emode." + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "_padding_0", + "type": "u64" + }, + { + "name": "key", + "docs": [ + "This registry's own key." + ], + "type": "pubkey" + }, + { + "name": "group", + "docs": [ + "Group for which this registry applies." + ], + "type": "pubkey" + }, + { + "name": "bank_count", + "type": "u16" + }, + { + "name": "group_count", + "type": "u8" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "_padding_1", + "type": { + "array": [ + "u8", + 4 + ] + } + }, + { + "name": "groups", + "docs": [ + "Describes the same-asset-emode groupings that exist" + ], + "type": { + "array": [ + { + "defined": { + "name": "SameAssetEmodeGroup" + } + }, + 32 + ] + } + }, + { + "name": "banks", + "docs": [ + "Describes which bank belongs to which group" + ], + "type": { + "array": [ + { + "defined": { + "name": "SameAssetEmodeBank" + } + }, + 128 + ] + } + }, + { + "name": "_padding_2", + "type": { + "array": [ + "u8", + 1024 + ] + } + }, + { + "name": "_padding_3", + "type": { + "array": [ + "u8", + 512 + ] + } + }, + { + "name": "_padding_4", + "type": { + "array": [ + "u8", + 256 + ] + } + } + ] + } + }, + { + "name": "SetGovernanceAdminEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "GroupEventHeader" + } + } + }, + { + "name": "previous_governance_admin", + "type": "pubkey" + }, + { + "name": "new_governance_admin", + "type": "pubkey" + } + ] + } + }, + { + "name": "SetKeeperCloseFlagsEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "header", + "type": { + "defined": { + "name": "AccountEventHeader" + } + } + }, + { + "name": "bank_keys", + "type": { + "option": { + "vec": "pubkey" + } + } + } + ] + } + }, + { + "name": "SnapshotUpdateInput", + "type": { + "kind": "struct", + "fields": [ + { + "name": "snapshot_hour", + "type": "u64" + }, + { + "name": "price", + "type": "u64" + }, + { + "name": "native_apy", + "type": "u64" + } + ] + } + }, + { + "name": "SolendConfigCompact", + "docs": [ + "Used to configure Solend banks. A simplified version of `BankConfigCompact` which omits most", + "values related to interest since Solend banks cannot earn interest or be borrowed against." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "oracle", + "type": "pubkey" + }, + { + "name": "asset_weight_init", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "asset_weight_maint", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "deposit_limit", + "docs": [ + "Cap in **Solend collateral units**, not underlying. As the reserve collateral", + "exchange rate grows, the same cap admits more underlying — re-tune against the", + "current rate." + ], + "type": "u64" + }, + { + "name": "oracle_setup", + "docs": [ + "Either `SolendPythPull` or `SolendSwitchboardPull`" + ], + "type": { + "defined": { + "name": "OracleSetup" + } + } + }, + { + "name": "operational_state", + "docs": [ + "Bank operational state - allows starting banks in paused state" + ], + "type": { + "defined": { + "name": "BankOperationalState" + } + } + }, + { + "name": "risk_tier", + "docs": [ + "Risk tier - determines if assets can be borrowed in isolation" + ], + "type": { + "defined": { + "name": "RiskTier" + } + } + }, + { + "name": "config_flags", + "docs": [ + "Config flags for future-proofing" + ], + "type": "u8" + }, + { + "name": "total_asset_value_init_limit", + "type": "u64" + }, + { + "name": "oracle_max_age", + "type": "u16" + }, + { + "name": "oracle_max_confidence", + "docs": [ + "Oracle confidence threshold (0 = use default 10%)" + ], + "type": "u32" + } + ] + } + }, + { + "name": "SolendMinimalReserve", + "serialization": "bytemuck", + "repr": { + "kind": "c", + "packed": true + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "last_update_slot", + "docs": [ + "Last slot when supply and rates updated" + ], + "type": "u64" + }, + { + "name": "last_update_stale", + "docs": [ + "True when marked stale" + ], + "type": "u8" + }, + { + "name": "lending_market", + "docs": [ + "Lending market address" + ], + "type": "pubkey" + }, + { + "name": "liquidity_mint_pubkey", + "type": "pubkey" + }, + { + "name": "liquidity_mint_decimals", + "type": "u8" + }, + { + "name": "liquidity_supply_pubkey", + "type": "pubkey" + }, + { + "name": "liquidity_pyth_oracle_pubkey", + "type": "pubkey" + }, + { + "name": "liquidity_switchboard_oracle_pubkey", + "type": "pubkey" + }, + { + "name": "liquidity_available_amount", + "type": "u64" + }, + { + "name": "liquidity_borrowed_amount_wads", + "type": { + "array": [ + "u8", + 16 + ] + } + }, + { + "name": "liquidity_cumulative_borrow_rate_wads", + "type": { + "array": [ + "u8", + 16 + ] + } + }, + { + "name": "liquidity_market_price", + "type": { + "array": [ + "u8", + 16 + ] + } + }, + { + "name": "collateral_mint_pubkey", + "type": "pubkey" + }, + { + "name": "collateral_mint_total_supply", + "type": "u64" + }, + { + "name": "collateral_supply_pubkey", + "type": "pubkey" + }, + { + "name": "config_optimal_utilization_rate", + "type": "u8" + }, + { + "name": "config_loan_to_value_ratio", + "type": "u8" + }, + { + "name": "config_liquidation_bonus", + "type": "u8" + }, + { + "name": "config_liquidation_threshold", + "type": "u8" + }, + { + "name": "config_min_borrow_rate", + "type": "u8" + }, + { + "name": "config_optimal_borrow_rate", + "type": "u8" + }, + { + "name": "config_max_borrow_rate", + "type": "u8" + }, + { + "name": "_padding1", + "type": { + "array": [ + "u8", + 17 + ] + } + }, + { + "name": "config_deposit_limit", + "docs": [ + "Total liquidity ceiling in native mint units; `u64::MAX` is unlimited." + ], + "type": "u64" + }, + { + "name": "_padding2", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "_padding3", + "type": { + "array": [ + "u8", + 9 + ] + } + }, + { + "name": "config_protocol_take_rate", + "type": "u8" + }, + { + "name": "liquidity_accumulated_protocol_fees_wads", + "type": { + "array": [ + "u8", + 16 + ] + } + }, + { + "name": "_padding4", + "type": { + "array": [ + "u8", + 64 + ] + } + }, + { + "name": "_padding5", + "type": { + "array": [ + "u8", + 17 + ] + } + }, + { + "name": "config_max_utilization_rate", + "type": "u8" + }, + { + "name": "config_super_max_borrow_rate", + "type": "u64" + }, + { + "name": "_padding6", + "type": { + "array": [ + "u8", + 128 + ] + } + }, + { + "name": "_padding7", + "type": { + "array": [ + "u8", + 12 + ] + } + } + ] + } + }, + { + "name": "SpotBalanceType", + "repr": { + "kind": "rust" + }, + "type": { + "kind": "enum", + "variants": [ + { + "name": "Deposit" + }, + { + "name": "Borrow" + } + ] + } + }, + { + "name": "SpotPosition", + "docs": [ + "Minimal representation of a spot position within a User account" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "scaled_balance", + "docs": [ + "The scaled balance of the position.", + "* Precision: SPOT_BALANCE_PRECISION" + ], + "type": "u64" + }, + { + "name": "open_bids", + "docs": [ + "How many spot bids the user has open", + "* Precision: token mint precision" + ], + "type": "i64" + }, + { + "name": "open_asks", + "docs": [ + "How many spot asks the user has open", + "* Precision: token mint precision" + ], + "type": "i64" + }, + { + "name": "cumulative_deposits", + "docs": [ + "The cumulative deposits/borrows a user has made", + "* Precision: token mint precision" + ], + "type": "i64" + }, + { + "name": "market_index", + "docs": [ + "The market index of the corresponding spot market" + ], + "type": "u16" + }, + { + "name": "balance_type", + "docs": [ + "Whether the position is deposit or borrow" + ], + "type": { + "defined": { + "name": "SpotBalanceType" + } + } + }, + { + "name": "open_orders", + "docs": [ + "Number of open orders" + ], + "type": "u8" + }, + { + "name": "padding", + "docs": [ + "Padding" + ], + "type": { + "array": [ + "u8", + 4 + ] + } + } + ] + } + }, + { + "name": "StakedSettings", + "docs": [ + "Unique per-group. Staked Collateral banks created under a group automatically use these", + "settings. Groups that have not created this struct cannot create staked collateral banks. When", + "this struct updates, changes must be permissionlessly propagated to staked collateral banks.", + "Administrators can also edit the bank manually, i.e. with configure_bank, to temporarily make", + "changes such as raising the deposit limit for a single bank." + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "key", + "docs": [ + "This account's own key. A PDA derived from `marginfi_group` and `STAKED_SETTINGS_SEED`" + ], + "type": "pubkey" + }, + { + "name": "marginfi_group", + "docs": [ + "Group for which these settings apply" + ], + "type": "pubkey" + }, + { + "name": "oracle", + "docs": [ + "Generally, the Pyth push oracle for SOL" + ], + "type": "pubkey" + }, + { + "name": "asset_weight_init", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "asset_weight_maint", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "deposit_limit", + "type": "u64" + }, + { + "name": "total_asset_value_init_limit", + "type": "u64" + }, + { + "name": "oracle_max_age", + "type": "u16" + }, + { + "name": "risk_tier", + "type": { + "defined": { + "name": "RiskTier" + } + } + }, + { + "name": "_pad0", + "type": { + "array": [ + "u8", + 5 + ] + } + }, + { + "name": "flags", + "docs": [ + "Desired bitmask for staked-bank transition flags. These bits are copied to `Bank.flags`", + "when staked settings are propagated or when a new staked bank is created.", + "* Bit 9 (512): `STAKED_ORACLE_DISABLED` — staked oracle pricing is temporarily disabled.", + "* Bit 10 (1024): `STAKED_ORACLE_PRICE_USES_ONRAMP` — staked oracle pricing includes the SPL", + "single-pool on-ramp account in NAV." + ], + "type": "u64" + }, + { + "name": "_reserved1", + "docs": [ + "The following values are irrelevant because staked collateral positions do not support", + "borrowing." + ], + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "_reserved2", + "type": { + "array": [ + "u8", + 64 + ] + } + } + ] + } + }, + { + "name": "StakedSettingsConfig", + "type": { + "kind": "struct", + "fields": [ + { + "name": "oracle", + "type": "pubkey" + }, + { + "name": "asset_weight_init", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "asset_weight_maint", + "type": { + "defined": { + "name": "WrappedI80F48" + } + } + }, + { + "name": "deposit_limit", + "type": "u64" + }, + { + "name": "total_asset_value_init_limit", + "type": "u64" + }, + { + "name": "oracle_max_age", + "type": "u16" + }, + { + "name": "risk_tier", + "docs": [ + "WARN: You almost certainly want \"Collateral\", using Isolated risk tier makes the asset", + "worthless as collateral, and is generally useful only when creating a staked collateral pool", + "for rewards purposes only." + ], + "type": { + "defined": { + "name": "RiskTier" + } + } + } + ] + } + }, + { + "name": "StakedSettingsEditConfig", + "type": { + "kind": "struct", + "fields": [ + { + "name": "oracle", + "type": { + "option": "pubkey" + } + }, + { + "name": "asset_weight_init", + "type": { + "option": { + "defined": { + "name": "WrappedI80F48" + } + } + } + }, + { + "name": "asset_weight_maint", + "type": { + "option": { + "defined": { + "name": "WrappedI80F48" + } + } + } + }, + { + "name": "deposit_limit", + "type": { + "option": "u64" + } + }, + { + "name": "total_asset_value_init_limit", + "type": { + "option": "u64" + } + }, + { + "name": "oracle_max_age", + "type": { + "option": "u16" + } + }, + { + "name": "risk_tier", + "docs": [ + "WARN: You almost certainly want \"Collateral\", using Isolated risk tier makes the asset", + "worthless as collateral, making all outstanding accounts eligible to be liquidated, and is", + "generally useful only when creating a staked collateral pool for rewards purposes only." + ], + "type": { + "option": { + "defined": { + "name": "RiskTier" + } + } + } + } + ] + } + }, + { + "name": "UserStatus", + "repr": { + "kind": "rust" + }, + "type": { + "kind": "enum", + "variants": [ + { + "name": "Active" + }, + { + "name": "BeingLiquidated" + }, + { + "name": "Bankrupt" + }, + { + "name": "ReduceOnly" + }, + { + "name": "AdvancedLp" + }, + { + "name": "ProtectedMakerOrders" + } + ] + } + }, + { + "name": "WithdrawWindowCache", + "docs": [ + "Tracks deleverage withdrawal limits to protect against compromised risk admin" + ], + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "daily_limit", + "docs": [ + "Maximum USD value that can be withdrawn per day via deleverage (0 = no limit)" + ], + "type": "u32" + }, + { + "name": "withdrawn_today", + "docs": [ + "USD value withdrawn today via deleverage (approximate, rounded)" + ], + "type": "u32" + }, + { + "name": "last_daily_reset_timestamp", + "docs": [ + "Unix timestamp of the last daily counter reset" + ], + "type": "i64" + } + ] + } + }, + { + "name": "WrappedI80F48", + "serialization": "bytemuck", + "repr": { + "kind": "c", + "align": 8 + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "value", + "type": { + "array": [ + "u8", + 16 + ] + } + } + ] + } + } + ] +} \ No newline at end of file diff --git a/crates/core/src/scenarios/protocols/project0/v1/overrides.yaml b/crates/core/src/scenarios/protocols/project0/v1/overrides.yaml new file mode 100644 index 000000000..94a69f8e8 --- /dev/null +++ b/crates/core/src/scenarios/protocols/project0/v1/overrides.yaml @@ -0,0 +1,410 @@ +protocol: Project 0 +version: v0.1.12 +account_type: Bank +idl_file_path: idl.json + +tags: + - lending + - risk-engine + - defi + +llm_context: | + FINDING A BANK WHEN THE USER NAMES A TOKEN OR STUDIO DOES NOT LIST IT: + 1. Resolve the token's mint with get_token_address. + 2. Call getProgramAccounts with two positional params: the program id + "MFv2hWf31Z9kbCa1snEPYctwafyhdvnV7FZnsebVacA", then the config object + {"encoding":"base58","dataSlice":{"offset":610,"length":32},"filters":[ + {"memcmp":{"offset":0,"bytes":"QnTef4UXSzF"}}, + {"memcmp":{"offset":41,"bytes":"4qp6Fx6tnZkY5Wropq9wUYgtFxXKwE6viZxFHg3rdAG8"}}, + {"memcmp":{"offset":8,"bytes":""}},{"memcmp":{"offset":609,"bytes":"4"}}]}. + Offset 0 is the Bank account type, 41 the main group and 8 the mint. Byte 609 equal to 3 + ("4" in base58) keeps the bank priced straight from a Pyth push oracle and leaves out the + Kamino-, Drift- and JupLend-wrapped banks of the same mint. The result's pubkey is the bank, + and its data is the bank's price account (config.oracle_keys.0). + 3. No result: many tokens (staked SOL, LSTs such as jitoSOL or mSOL, PT tokens) have no bank + priced straight from Pyth. Repeat the call without the 609 filter; one result is the bank, + several are wrapped banks of the same mint, so pick the one the user means or ask. + 4. Still no result means a mistyped mint or no such bank. Copy the mint again and repeat once, + then ask the user for the bank address instead of saying none exists. + 5. A bank address the user gives is used as is. + + FINDING A WALLET'S ACCOUNT: getProgramAccounts on the same program with the config object + {"encoding":"base64","dataSlice":{"offset":0,"length":0},"filters":[ + {"memcmp":{"offset":0,"bytes":"CKkRR4La3xu"}},{"memcmp":{"offset":8,"bytes":""}}, + {"memcmp":{"offset":40,"bytes":""}}]}. Each result's pubkey is one MarginfiAccount. + + Put the bank or account in the override's account as {"pubkey":"
"}. Set + fetchBeforeUse: true to pull the account from upstream first; false only for a later override + that builds on state an earlier override in the same scenario prepared. + + FIXED-POINT VALUES: every path that ends in .value (weights, shares, share values and circuit + breaker prices) is an I80F48 number, stored as [u8; 16]. Pass a JSON array of 16 numbers from 0 + to 255: the little-endian bytes of the signed integer round(value x 2^48), two's complement when + negative. Bytes 0 to 5 hold the fraction and bytes 6 to 15 the whole part, so a whole number N + is six zeros followed by N's little-endian bytes. Examples: + 1.0 is [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0] + 20 is [0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0] + 0.3 is [205, 204, 204, 204, 204, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + getAccountInfo with encoding "jsonParsed" shows these fields as the same 16 numbers: read them + back as a little-endian signed integer and divide by 2^48. + +templates: + # ========================================== + # Bank + # ========================================== + - id: project0-bank-risk-weights + name: Override Bank Risk Weights + description: Override the collateral and debt weights of a Project 0 bank + idl_account_name: Bank + properties: + - path: config.asset_weight_init.value + label: Asset weight (borrowing) + description: >- + Share of a deposit's value that counts when borrowing or withdrawing, as an I80F48 + number. Example: 0.8, sent as the 16 little-endian bytes of value x 2^48: + [205, 204, 204, 204, 204, 204, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - path: config.asset_weight_maint.value + label: Asset weight (liquidation) + description: >- + Share of a deposit's value that counts against liquidation, as an I80F48 number. Keep it + at or above the borrowing weight. Example: 0.9, sent as the 16 little-endian bytes of + value x 2^48: [102, 102, 102, 102, 102, 230, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - path: config.liability_weight_init.value + label: Liability weight (borrowing) + description: >- + Premium on a debt's value when borrowing or withdrawing, as an I80F48 number, at least 1. + Example: 1.25, sent as the 16 little-endian bytes of value x 2^48: + [0, 0, 0, 0, 0, 64, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - path: config.liability_weight_maint.value + label: Liability weight (liquidation) + description: >- + Premium on a debt's value against liquidation, as an I80F48 number, at least 1. Example: + 1.1, sent as the 16 little-endian bytes of value x 2^48: + [154, 153, 153, 153, 153, 25, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0] + address: + type: pubkey + llm_context: | + Use this template to make positions liquidatable in a way that survives every instruction. + Project 0 recomputes health from these weights on each borrow, withdraw and liquidation, so + the MarginfiAccount health_cache is never the lever. + + HOW TO USE THIS TEMPLATE: + 1. Lower config.asset_weight_maint.value on the bank the borrower deposited into. The account + becomes liquidatable once sum(deposit value x asset_weight_maint) falls below + sum(debt value x liability_weight_maint). Lower config.asset_weight_init.value with it, + since the liquidation weight must stay at or above the borrowing weight + 2. Weights are I80F48 numbers: pass each as 16 bytes, as FIXED-POINT VALUES above shows + (1.0 is [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) + + THE PRICE LEVER: to crash a collateral price instead, use pyth-core-compatible-price-feed-v2 on the + bank's price account (the lookup above returns it). Move price and ema_price together: + liquidation reads the spot price, borrows and withdrawals check the EMA. That price account + stays published by itself, so leave its time fields unset. The bank refuses a price older + than config.oracle_max_age seconds, and a health check also reads the prices of the other + banks the account uses. Keep each of those fresh with its own + pyth-core-compatible-price-feed-v2 override on that bank's config.oracle_keys.0 that sets + only price_message.publish_time (any value; keep-alive rewrites it), or its price ages. For + a bank priced by another oracle, raise its oracle_max_age with project0-bank-oracle. Read + the bank first: when its + flags include 2048 (bit 11), the circuit breaker is on and the same scenario needs + project0-bank-oracle on that bank with both breaker references moved with the price, as that + template explains. + + EXAMPLE - "SOL collateral only counts at 30% against liquidation" (0.3): + config.asset_weight_maint.value: [205, 204, 204, 204, 204, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + config.asset_weight_init.value: [205, 204, 204, 204, 204, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + + - id: project0-bank-limits + name: Override Bank Deposit & Borrow Limits + description: Override the deposit, borrow and collateral value caps of a Project 0 bank + idl_account_name: Bank + properties: + - "config.deposit_limit" + - "config.borrow_limit" + - "config.total_asset_value_init_limit" + address: + type: pubkey + llm_context: | + Use this template to hit a cap and test the rejection. + + deposit_limit and borrow_limit are in the mint's smallest unit. total_asset_value_init_limit + is in whole US dollars and discounts the bank's collateral for borrowing once total deposits + are worth more than it. + + EXAMPLE - "the SOL bank is full" (10 SOL cap, far below current deposits): + config.deposit_limit: 10000000000 + + - id: project0-bank-status + name: Override Bank Operational State + description: Pause a Project 0 bank or put it into reduce-only mode + idl_account_name: Bank + properties: + - "config.operational_state" + address: + type: pubkey + llm_context: | + config.operational_state is an enum. Pass the variant name, e.g. "ReduceOnly". + + Variants: Paused, Operational, ReduceOnly, KilledByBankruptcy, Uninitialized, + ReduceOnlyWithBorrowingPower, CircuitBroken. Scenarios use the first three and + ReduceOnlyWithBorrowingPower; KilledByBankruptcy, Uninitialized and CircuitBroken are states + the program moves a bank into itself. + + EXAMPLE - "no new deposits or borrows, repayments still allowed": + config.operational_state: "ReduceOnly" + + - id: project0-bank-oracle + name: Override Bank Oracle Configuration + description: Override the oracle staleness, confidence and circuit breaker guards of a Project 0 bank + idl_account_name: Bank + properties: + - "config.oracle_max_age" + - "config.oracle_max_confidence" + - path: config.cb_deviation_bps_tiers.0 + label: Circuit breaker tier 1 (bps) + description: >- + Price deviation from cb_reference_price, in basis points, at which the breaker refuses + borrow, withdraw and liquidation. 10000 is 100% + - path: config.cb_deviation_bps_tiers.1 + label: Circuit breaker tier 2 (bps) + description: >- + Deviation at which the breaker's second, longer halt applies. Keep it above tier 1 + - path: config.cb_deviation_bps_tiers.2 + label: Circuit breaker tier 3 (bps) + description: >- + Deviation at which the breaker's longest halt applies. Keep it above tier 2 + - path: config.cb_window_max_up_bps + label: Circuit breaker 24h cap up (bps) + description: >- + Largest rise from cb_window_reference_price the breaker allows inside its window; 0 means + the program's default cap, not no cap + - path: config.cb_window_max_down_bps + label: Circuit breaker 24h cap down (bps) + description: >- + Largest drop from cb_window_reference_price the breaker allows inside its window; 0 means + the program's default cap, not no cap + - path: cb_reference_price.value + label: Circuit breaker reference price + description: >- + Price the circuit breaker treats as normal, as an I80F48 number. Set it to the new price + when moving the price of a bank whose breaker is on. Example: $0.95, sent as the 16 + little-endian bytes of value x 2^48: [51, 51, 51, 51, 51, 243, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - path: cb_window_reference_price.value + label: Circuit breaker 24h reference price + description: >- + Anchor of the circuit breaker's long-window cap, as an I80F48 number. Set it to the same + price as cb_reference_price.value + address: + type: pubkey + llm_context: | + Use this template to change how old a price the bank accepts, or to let a price move past + the bank's circuit breaker. + + A price is stale once the Surfnet clock is more than config.oracle_max_age seconds past its + publish_time. Lower oracle_max_age to make the bank refuse a price sooner, or raise it (max + 65535) to accept older prices. A pyth-core-compatible-price-feed-v2 override keeps the price + account it writes republished every slot; a price account no override writes, or a bank + priced by another oracle, still ages. To move the price itself, use + pyth-core-compatible-price-feed-v2 on the bank's price account, config.oracle_keys.0. + + ONE STALE PRICE, THE OTHERS FRESH: do not lower oracle_max_age for this, because a + republished price is never more than a second old. Find every bank the scenario reads with + the getProgramAccounts call above; each result's data is that bank's config.oracle_keys.0. + Add one pyth-core-compatible-price-feed-v2 override, with fetchBeforeUse: true, on the + config.oracle_keys.0 of each bank that must stay fresh, and set only + price_message.publish_time (any value; keep-alive rewrites it). Give the stale bank's price + account no override: its price ages and the bank refuses it once config.oracle_max_age + seconds have passed. To let it age only later, give it a later override with + "keepAlive": [] and a value, such as its current price. + + CIRCUIT BREAKER: most banks have one, among them the stablecoins, SOL and its liquid staking + tokens, BTC and ETH. It is on when the bank's flags include 2048 (bit 11). Such a bank + rejects borrow, withdraw and liquidation with error 6604 (CircuitBreakerPriceJump) once its + price, net of the oracle's confidence, is config.cb_deviation_bps_tiers.0 basis points (50 + for USDC, 600 for SOL) away from cb_reference_price, or past the 24h cap from + cb_window_reference_price. The confidence counts 2.12 times, so at a typical USDC confidence + the 50 bps take about a 0.7% move. Read the bank with getAccountInfo jsonParsed to see its + flags, tiers and references. Two ways to work with it: + - MOVE THE REFERENCES (the default): in the same scenario as the price override, multiply + the bank's current cb_reference_price.value and cb_window_reference_price.value by the + price move (new price / current price), read and written as FIXED-POINT VALUES above. + They hold the price the bank computes, which for liquid staking tokens includes the + exchange rate, so scaling the current values works for every bank; on SOL and USDC they + are the price in dollars. The breaker then treats the new + price as normal and still guards further moves, like a slow move it has adapted to. A + bank whose breaker is off ignores both fields. + - CHANGE THE THRESHOLDS: set the three config.cb_deviation_bps_tiers entries and the two + config.cb_window_max_*_bps caps. Use this to test the breaker itself, with a price just + under or just over tier 1, or to model the admin loosening it. Raising tier 1 alone is not + enough: a borrow or withdrawal still checks tiers 2 and 3 and the 24h caps and can halt + the bank (6600). All five at 10000 let any move through. The breaker's own off switch is + bit 11 of flags, which these templates do not write. + + EXAMPLE - "accept prices up to an hour old": + config.oracle_max_age: 3600 + + EXAMPLE - "USDC at $0.95", on the USDC bank (0.95 as FIXED-POINT VALUES): + cb_reference_price.value: [51, 51, 51, 51, 51, 243, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + cb_window_reference_price.value: [51, 51, 51, 51, 51, 243, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + plus pyth-core-compatible-price-feed-v2 on the bank's config.oracle_keys.0 with price_message.price and + price_message.ema_price 95000000 (exponent -8), and conf and ema_conf scaled by the same factor. + + EXAMPLE - "SOL at $20", on the SOL bank: + cb_reference_price.value: [0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0] + cb_window_reference_price.value: [0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0] + plus pyth-core-compatible-price-feed-v2 on the bank's config.oracle_keys.0 with price_message.price and + price_message.ema_price 2000000000, and conf and ema_conf scaled by the same factor. + + EXAMPLE - "the SOL breaker trips at 1% instead of 6%": + config.cb_deviation_bps_tiers.0: 100 + config.cb_deviation_bps_tiers.1: 1050 + config.cb_deviation_bps_tiers.2: 1800 + + - id: project0-bank-interest-rate + name: Override Bank Interest Rate Curve + description: Override the Project 0 bank borrow-rate curve + idl_account_name: Bank + properties: + - "config.interest_rate_config.zero_util_rate" + - "config.interest_rate_config.hundred_util_rate" + - path: config.interest_rate_config.points.0.util + label: Kink utilization + description: >- + Utilization at which this curve point applies, out of 100% as u32 (50% = 2147483647). Change + the index for other points. Example: 3435973836 + - path: config.interest_rate_config.points.0.rate + label: Kink rate + description: >- + Borrow rate at this curve point, out of 1000% as u32 (100% = 429496729). Example: 42949672 + - "config.interest_rate_config.curve_type" + address: + type: pubkey + llm_context: | + The borrow rate is a piecewise-linear curve from zero_util_rate at 0% utilization, through up + to 5 points, to hundred_util_rate at 100%. Points stay in ascending util order and a point with + util 0 is unused. Rates are out of 1000% (100% APR = 429496729), utilization out of 100% + (u32::MAX = 100%). Keep curve_type at 1; 0 is the retired legacy curve. + + Interest accrues on the next instruction that touches the bank, from its last_update to the + Surfnet clock. + + EXAMPLE - "borrowing costs 100% APR at full utilization": + config.interest_rate_config.hundred_util_rate: 429496729 + + - id: project0-bank-shares + name: Override Bank Share Accounting + description: Override the total shares and share values of a Project 0 bank + idl_account_name: Bank + properties: + - path: total_asset_shares.value + label: Total deposit shares + description: >- + Sum of every depositor's shares, as an I80F48 number. Tokens = shares x + asset_share_value. Example: 10 SOL of shares at a share value of 1.0 is 10000000000, sent + as the 16 little-endian bytes of value x 2^48: + [0, 0, 0, 0, 0, 0, 0, 228, 11, 84, 2, 0, 0, 0, 0, 0] + - path: total_liability_shares.value + label: Total debt shares + description: >- + Sum of every borrower's shares, as an I80F48 number. Tokens = shares x + liability_share_value. Example: 0, sent as 16 zero bytes + - path: asset_share_value.value + label: Deposit share value + description: >- + Tokens one deposit share is worth, as an I80F48 number. It only grows as interest + accrues. Example: 1.0, sent as the 16 little-endian bytes of value x 2^48: + [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0] + - path: liability_share_value.value + label: Debt share value + description: >- + Tokens one debt share is worth, as an I80F48 number. It only grows as interest accrues. + Example: 1.0, sent as the 16 little-endian bytes of value x 2^48: + [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0] + address: + type: pubkey + llm_context: | + CRITICAL: the bank's liquidity_vault token account must still hold the tokens these shares + imply. Keep total_asset_shares x asset_share_value - total_liability_shares x + liability_share_value close to the vault balance, and move the vault with + spl-token-account-balance in the same step, or withdrawals revert on the token transfer. + + All four fields are I80F48 numbers, passed as FIXED-POINT VALUES above. Raising + liability_share_value ages every loan in the bank at once. + + EXAMPLE - "debt in this bank grew 10%": read the bank's current liability_share_value and + write it times 1.1. If it reads [0, 0, 0, 0, 0, 64, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0] (1.25), + write 1.375: + liability_share_value.value: [0, 0, 0, 0, 0, 96, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0] + + # ========================================== + # MarginfiAccount + # ========================================== + - id: project0-account-balance + name: Override Account Position + description: Override one balance slot of a Project 0 MarginfiAccount + idl_account_name: MarginfiAccount + properties: + - "lending_account.balances.0.active" + - "lending_account.balances.0.bank_pk" + - "lending_account.balances.0.bank_asset_tag" + - path: lending_account.balances.0.asset_shares.value + label: Deposit shares + description: >- + Deposit shares in the bank, as an I80F48 number. Tokens = shares x the bank's + asset_share_value. Example: 10 SOL of shares at a share value of 1.0 is 10000000000, sent + as the 16 little-endian bytes of value x 2^48: + [0, 0, 0, 0, 0, 0, 0, 228, 11, 84, 2, 0, 0, 0, 0, 0] + - path: lending_account.balances.0.liability_shares.value + label: Debt shares + description: >- + Debt shares in the bank, as an I80F48 number. Tokens = shares x the bank's + liability_share_value. Example: 0, sent as 16 zero bytes + - "lending_account.balances.0.last_update" + address: + type: pubkey + llm_context: | + An account holds 16 fixed balance slots. Replace the 0 in the paths with the slot you edit. + + RULES TO KEEP: + - Active slots are kept sorted by bank_pk, highest first, compared as raw bytes. Pick the slot + so that order still holds + - An empty slot is active 0, bank_pk 11111111111111111111111111111111 and zero shares. Take a + free slot for a new position rather than overwriting one in use + - bank_asset_tag must equal the bank's config.asset_tag (SOL bank 1, most others 0) + - A slot holds either deposit shares or debt shares, never both + - Shares are not token amounts: tokens = shares x the bank's asset_share_value (deposits) or + liability_share_value (debts). Divide the amount you want by the share value, then pass + it as FIXED-POINT VALUES above + + Instructions that check health need every active slot's bank and oracle passed in slot order. + The bank's own totals (total_asset_shares, total_liability_shares) are not updated for you; + raise them with project0-bank-shares when the scenario depends on bank-wide numbers. + + EXAMPLE - "10 SOL deposited in the native SOL bank" in slot 0, with the SOL bank's + asset_share_value reading 1.25: 10 SOL / 1.25 = 8 SOL of shares, 8000000000. + lending_account.balances.0.active: 1 + lending_account.balances.0.bank_pk: + lending_account.balances.0.bank_asset_tag: 1 + lending_account.balances.0.asset_shares.value: [0, 0, 0, 0, 0, 0, 0, 80, 214, 220, 1, 0, 0, 0, 0, 0] + lending_account.balances.0.liability_shares.value: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + + - id: project0-account-authority + name: Override Account Authority + description: Take over a Project 0 MarginfiAccount by changing its authority + idl_account_name: MarginfiAccount + properties: + - path: authority + label: Authority + description: >- + The wallet allowed to deposit, borrow, withdraw and repay on this account. Example: your + test wallet's address + address: + type: pubkey + llm_context: | + Use this template to act as the owner of a real account in the local VM, so a test can borrow + or withdraw against its live positions. + + Set authority to a wallet whose keypair you hold, and sign with it. + + EXAMPLE: + authority: diff --git a/crates/core/src/scenarios/registry.rs b/crates/core/src/scenarios/registry.rs index e66548028..3c9250134 100644 --- a/crates/core/src/scenarios/registry.rs +++ b/crates/core/src/scenarios/registry.rs @@ -57,6 +57,10 @@ pub const KAMINO_LIQUIDITY_IDL_CONTENT: &str = pub const KAMINO_LIQUIDITY_OVERRIDES_CONTENT: &str = include_str!("./protocols/kamino/liquidity/v1/overrides.yaml"); +pub const PROJECT0_V1_IDL_CONTENT: &str = include_str!("./protocols/project0/v1/idl.json"); +pub const PROJECT0_V1_OVERRIDES_CONTENT: &str = + include_str!("./protocols/project0/v1/overrides.yaml"); + pub const DRIFT_V2_IDL_CONTENT: &str = include_str!("./protocols/drift/v2/idl.json"); pub const DRIFT_V2_OVERRIDES_CONTENT: &str = include_str!("./protocols/drift/v2/overrides.yaml"); @@ -136,6 +140,7 @@ impl TemplateRegistry { default.load_raydium_overrides(); default.load_meteora_overrides(); default.load_kamino_overrides(); + default.load_project0_overrides(); default.load_drift_overrides(); default.load_whirlpool_overrides(); default.load_spl_token_overrides(); @@ -314,6 +319,14 @@ impl TemplateRegistry { ); } + pub fn load_project0_overrides(&mut self) { + self.load_protocol_overrides( + PROJECT0_V1_IDL_CONTENT, + PROJECT0_V1_OVERRIDES_CONTENT, + "Project 0", + ); + } + pub fn load_drift_overrides(&mut self) { self.load_protocol_overrides(DRIFT_V2_IDL_CONTENT, DRIFT_V2_OVERRIDES_CONTENT, "drift"); } @@ -495,6 +508,42 @@ mod tests { use super::*; + #[test] + fn collection_llm_context_leads_every_template_context() { + let collection: YamlOverrideTemplateCollection = serde_yaml::from_str( + r#" +protocol: Example +version: v1 +raw_layout: true +llm_context: | + Shared lookup. +templates: + - id: with-own + name: With own + description: Has its own context + address: + type: pubkey + llm_context: | + Own guidance. + - id: without-own + name: Without own + description: Has no context of its own + address: + type: pubkey +"#, + ) + .unwrap(); + let templates = collection.to_override_templates(None).unwrap(); + assert_eq!( + templates[0].llm_context.as_deref(), + Some("Shared lookup.\n\nOwn guidance.\n") + ); + assert_eq!( + templates[1].llm_context.as_deref(), + Some("Shared lookup.\n") + ); + } + #[test] fn account_data_values_exclude_constant_ref_selectors() { let registry = TemplateRegistry::new(); @@ -742,11 +791,12 @@ mod tests { // Pyth (2) + Jupiter (1) + Raydium CLMM (1) + Raydium AMM v4 (4) + Drift (4) + Meteora (2) // + Kamino (Lend 17, Scope 3, Farms 5, Swap 2, Vault 5, Liquidity 4 = 36) - // + Whirlpool (6) + SPL Token (2) + Pump (2) + PumpSwap (3) + Phoenix Eternal (19) = 82 + // + Project 0 (Bank 6, MarginfiAccount 2 = 8) + // + Whirlpool (6) + SPL Token (2) + Pump (2) + PumpSwap (3) + Phoenix Eternal (19) = 90 assert_eq!( registry.count(), - 82, - "Registry should load 82 templates total" + 90, + "Registry should load 90 templates total" ); assert!(registry.contains("pyth-price-feed-v2")); @@ -797,6 +847,15 @@ mod tests { assert!(registry.contains("kamino-liquidity-strategy-rewards")); assert!(registry.contains("kamino-liquidity-strategy-guards")); + assert!(registry.contains("project0-bank-risk-weights")); + assert!(registry.contains("project0-bank-limits")); + assert!(registry.contains("project0-bank-status")); + assert!(registry.contains("project0-bank-oracle")); + assert!(registry.contains("project0-bank-interest-rate")); + assert!(registry.contains("project0-bank-shares")); + assert!(registry.contains("project0-account-balance")); + assert!(registry.contains("project0-account-authority")); + assert!(registry.contains("drift-perp-market")); assert!(registry.contains("drift-spot-market")); assert!(registry.contains("drift-user-state")); @@ -1329,6 +1388,7 @@ templates: [] ("kamino-swap", vec!["Order", "GlobalConfig"]), ("kamino-vault", vec!["VaultState", "ReserveWhitelistEntry"]), ("kamino-liquidity", vec!["WhirlpoolStrategy"]), + ("Project 0", vec!["Bank", "MarginfiAccount"]), ] { let account_types: BTreeSet<&str> = registry .by_protocol(protocol) @@ -1345,6 +1405,12 @@ templates: [] } } + assert_eq!( + registry.by_protocol("Project 0").len(), + 8, + "Should have 8 Project 0 templates" + ); + let whirlpool_templates = registry.by_protocol("Whirlpool"); assert_eq!( whirlpool_templates.len(), @@ -1673,6 +1739,26 @@ templates: [] ); } + #[test] + fn project0_templates_require_caller_selected_accounts() { + let registry = TemplateRegistry::new(); + let templates = registry.by_protocol("Project 0"); + assert_eq!(templates.len(), 8); + for template in templates { + assert_eq!( + template.address, + AccountAddress::Pubkey(String::new()), + "{} must require an explicit target account", + template.id + ); + assert!( + template.constants.is_empty(), + "{} must not embed a backend account catalog", + template.id + ); + } + } + #[test] fn test_pyth_core_compatible_price_feed_takes_a_caller_selected_account() { let registry = TemplateRegistry::new(); @@ -1699,6 +1785,47 @@ templates: [] ); } + /// `WrappedI80F48.value` is the published `[u8; 16]`: an override takes the 16 little-endian + /// bytes of value x 2^48 as an array of numbers, and refuses a decimal string. + #[test] + fn project0_fixed_point_value_takes_its_sixteen_bytes() { + let registry = TemplateRegistry::new(); + let template = registry.get("project0-bank-risk-weights").unwrap(); + let discriminator = &template + .idl() + .accounts + .iter() + .find(|account| account.name == "Bank") + .unwrap() + .discriminator; + let mut bank = vec![0u8; 4096]; + bank[..8].copy_from_slice(discriminator); + + let (svm, _simnet_events_rx, _geyser_events_rx) = + crate::surfnet::svm::SurfnetSvm::default(); + let forge = |value: serde_json::Value| { + svm.get_forged_account_data( + &Pubkey::new_unique(), + &bank, + template.idl(), + &HashMap::from([("config.asset_weight_init.value".to_string(), value)]), + ) + }; + + let weight = -(85i128 << 48) / 100; + let forged = forge(serde_json::json!(weight.to_le_bytes())).expect("a 16-byte array"); + assert_eq!(forged.len(), bank.len()); + assert_eq!(forged[296..312], weight.to_le_bytes()); + assert_eq!(forged[..296], bank[..296]); + assert_eq!(forged[312..], bank[312..]); + + let refusal = |value| forge(value).unwrap_err().to_string(); + let decimal = refusal(serde_json::json!(weight.to_string())); + assert!(decimal.contains("expected vec, found string"), "{decimal}"); + let short = refusal(serde_json::json!([1, 2, 3])); + assert!(short.contains("expected array length of 16"), "{short}"); + } + #[test] fn pyth_price_feeds_keep_their_price_published() { let registry = TemplateRegistry::new(); @@ -2149,7 +2276,7 @@ templates: [] /// Descriptions come from the IDL's own `docs`, or from an explicit `description` in the /// YAML. Studio and any LLM reading a template rely on them. #[test] - fn test_every_kamino_property_has_a_description() { + fn test_every_kamino_and_project0_property_has_a_description() { let registry = TemplateRegistry::new(); let mut missing = Vec::new(); let mut described = 0; @@ -2161,6 +2288,7 @@ templates: [] "kamino-swap", "kamino-vault", "kamino-liquidity", + "Project 0", ] { for template in registry.by_protocol(protocol) { for property in &template.properties { @@ -2174,7 +2302,7 @@ templates: [] assert!( missing.is_empty(), - "{} Kamino propert(ies) have no description ({} do):\n {}", + "{} Kamino or Project 0 propert(ies) have no description ({} do):\n {}", missing.len(), described, missing.join("\n ") diff --git a/crates/core/src/surfnet/svm.rs b/crates/core/src/surfnet/svm.rs index 9df65b65c..b0ae305a7 100644 --- a/crates/core/src/surfnet/svm.rs +++ b/crates/core/src/surfnet/svm.rs @@ -364,6 +364,19 @@ pub(crate) fn json_to_txtx_value_for_idl_type( .collect::>>()?; Ok(Value::Array(Box::new(converted))) } + // The encoder takes a unit variant as `{"Variant": null}`; editors and clients send its name. + (IdlType::Defined { name, .. }, serde_json::Value::String(variant)) + if idl_types.iter().any(|t| { + &t.name == name + && matches!(&t.ty, IdlTypeDefTy::Enum { variants } + if variants.iter().any(|v| &v.name == variant && v.fields.is_none())) + }) => + { + Ok(Value::Object(IndexMap::from([( + variant.clone(), + Value::Null, + )]))) + } (IdlType::Defined { name, .. }, serde_json::Value::Object(fields)) => { let Some(IdlTypeDefTy::Struct { fields: Some(IdlDefinedFields::Named(named_fields)), @@ -9762,6 +9775,54 @@ mod tests { assert_eq!(update.data.decode(), Some(account.data)); } + /// A unit enum variant can be overridden by its name as well as by `{"Variant": null}`. + #[test] + fn idl_override_takes_a_unit_enum_variant_by_name() { + let (svm, _events, _geyser) = SurfnetSvm::default(); + let idl: Idl = serde_json::from_value(serde_json::json!({ + "address": Pubkey::new_unique().to_string(), + "metadata": { "name": "example", "version": "0.1.0", "spec": "0.1.0" }, + "instructions": [], + "accounts": [{ "name": "State", "discriminator": [1, 2, 3, 4, 5, 6, 7, 8] }], + "types": [ + { "name": "State", "type": { "kind": "struct", "fields": [ + { "name": "status", "type": { "defined": { "name": "Status" } } }, + { "name": "amount", "type": "u64" } + ] } }, + { "name": "Status", "type": { "kind": "enum", "variants": [ + { "name": "Active" }, + { "name": "Paused" }, + { "name": "Limited", "fields": ["u8"] } + ] } } + ] + })) + .expect("example idl"); + let pubkey = Pubkey::new_unique(); + let mut data = vec![1, 2, 3, 4, 5, 6, 7, 8, 0]; + data.extend_from_slice(&5u64.to_le_bytes()); + let forge = |status: serde_json::Value| { + svm.get_forged_account_data( + &pubkey, + &data, + &idl, + &HashMap::from([("status".to_string(), status)]), + ) + }; + + let by_name = forge(serde_json::json!("Paused")).expect("variant name"); + let by_object = forge(serde_json::json!({ "Paused": null })).expect("variant object"); + assert_eq!(by_name, by_object); + assert_eq!(by_name.len(), data.len()); + assert_eq!(by_name[8], 1, "Paused is variant 1"); + assert_eq!(by_name[9..], data[9..], "amount must not move"); + + assert!(forge(serde_json::json!("Unknown")).is_err()); + assert!( + forge(serde_json::json!("Limited")).is_err(), + "a variant with fields still needs its data" + ); + } + #[tokio::test] async fn an_empty_keep_alive_list_stops_keep_alive_on_the_account_it_writes() { let (mut svm, _simnet_events_rx, _geyser_events_rx) = SurfnetSvm::default(); diff --git a/crates/core/src/tests/protocols/mod.rs b/crates/core/src/tests/protocols/mod.rs index 90666f341..1fbb15377 100644 --- a/crates/core/src/tests/protocols/mod.rs +++ b/crates/core/src/tests/protocols/mod.rs @@ -8,4 +8,5 @@ //! //! A protocol's module is declared here and nowhere else; the filter above then covers it. +pub mod project0; pub mod pyth; diff --git a/crates/core/src/tests/protocols/project0/mod.rs b/crates/core/src/tests/protocols/project0/mod.rs new file mode 100644 index 000000000..2d1a71eba --- /dev/null +++ b/crates/core/src/tests/protocols/project0/mod.rs @@ -0,0 +1,944 @@ +//! Project 0 (marginfi v2) integration tests. +//! +//! Like the Kamino suite these fetch real mainnet accounts, so they need a network connection and +//! are compiled only behind a feature: +//! +//! ```text +//! cargo test -p surfpool-core --features integration-tests tests::protocols::project0 +//! ``` +//! +//! Set `SURFPOOL_TEST_RPC_URL` to use a private endpoint if the public one rate-limits. +//! +//! A correct byte offset does not show that the risk engine reads it, so the last tests run the +//! deployed program over overridden state. + +use std::collections::HashMap; + +use litesvm::LiteSVM; +use solana_account_decoder::{UiAccountEncoding, UiDataSliceConfig}; +use solana_client::{ + rpc_config::RpcAccountInfoConfig, + rpc_filter::{Memcmp, MemcmpEncodedBytes, RpcFilterType}, +}; +use solana_commitment_config::CommitmentConfig; +use solana_instruction::{AccountMeta, Instruction}; +use solana_keypair::Keypair; +use solana_pubkey::Pubkey; +use solana_signer::Signer; +use solana_transaction::Transaction; + +use crate::{ + scenarios::TemplateRegistry, + surfnet::{GetAccountResult, remote::SurfnetRemoteClient, svm::SurfnetSvm}, + types::RemoteRpcResult, +}; + +const RPC_URL_ENV: &str = "SURFPOOL_TEST_RPC_URL"; +const DEFAULT_RPC_URL: &str = "https://api.mainnet-beta.solana.com"; + +const PROGRAM: &str = "MFv2hWf31Z9kbCa1snEPYctwafyhdvnV7FZnsebVacA"; +const PROGRAM_DATA: &str = "4Q8u2ny8YYgytJEncwZQfVWbd5axZtfgDxYKHehvPQR7"; +const GROUP: &str = "4qp6Fx6tnZkY5Wropq9wUYgtFxXKwE6viZxFHg3rdAG8"; +const USDC_BANK: &str = "2s37akK2eyBbp8DZgCm7RtsaEz8eJP3Nxd4urLHQv7yB"; +const SOL_BANK: &str = "CCKtUs6Cgwo4aaQUmBPmyoApH2gUDErxNZCAntD6LYGh"; +const ACCOUNT: &str = "CGnzJGWscJAasjwngK1Jixx4xHfxF5EZaMje6uRtnbMy"; +const USDC_BANK_ORACLE: &str = "6HAuqASbHEh4w4REJEUUUCginTLfj1kwCh215ZLtMkrT"; +const SOL_BANK_ORACLE: &str = "7AviUf9nL62mcxNbQGKm4nKDQnPjswo6c5MX4D57HmyE"; + +/// Fixed-point Bank fields and their offsets in program 0.1.12. +const BANK_FIXED_POINT: [(&str, usize); 10] = [ + ("asset_share_value.value", 80), + ("liability_share_value.value", 96), + ("total_liability_shares.value", 256), + ("total_asset_shares.value", 272), + ("config.asset_weight_init.value", 296), + ("config.asset_weight_maint.value", 312), + ("config.liability_weight_init.value", 328), + ("config.liability_weight_maint.value", 344), + ("cb_reference_price.value", 1800), + ("cb_window_reference_price.value", 1816), +]; + +/// Fetches the accounts in one request, so every account returned is from the same slot. +async fn fetch(addresses: &[&str]) -> Vec { + let client = SurfnetRemoteClient::new( + std::env::var(RPC_URL_ENV).unwrap_or_else(|_| DEFAULT_RPC_URL.to_string()), + ); + let pubkeys: Vec = addresses + .iter() + .map(|a| Pubkey::from_str_const(a)) + .collect(); + + client + .get_multiple_accounts(&pubkeys, CommitmentConfig::confirmed()) + .await + .unwrap_or_else(|e| panic!("failed to fetch {addresses:?} from mainnet: {e}")) + .into_iter() + .zip(addresses) + .map(|(result, address)| match result { + GetAccountResult::FoundAccount(_, account, _) + | GetAccountResult::FoundCoupledAccount((_, account), _, _) => account, + GetAccountResult::None(_) => { + panic!("{address} no longer exists on mainnet; the test needs a new address") + } + }) + .collect() +} + +/// Byte indices at which two buffers differ. +fn diff_indices(a: &[u8], b: &[u8]) -> Vec { + a.iter() + .zip(b.iter()) + .enumerate() + .filter(|(_, (x, y))| x != y) + .map(|(i, _)| i) + .collect() +} + +fn read_i128(data: &[u8], offset: usize) -> i128 { + i128::from_le_bytes(data[offset..offset + 16].try_into().unwrap()) +} + +/// A `WrappedI80F48.value` override: the 16 little-endian bytes of the fixed-point integer. +fn fixed_point(value: i128) -> serde_json::Value { + serde_json::json!(value.to_le_bytes()) +} + +/// Offset of a balance slot's first byte: `lending_account.balances` starts at 72, 104 bytes each. +fn balance_slot(slot: usize) -> usize { + 72 + 104 * slot +} + +/// A failure here means the bundled IDL disagrees with the live on-chain layout. +#[tokio::test] +async fn real_mainnet_accounts_round_trip_unchanged() { + let cases: &[(&str, &str, &str)] = &[ + ("project0-bank-limits", "Bank", USDC_BANK), + ("project0-bank-limits", "Bank", SOL_BANK), + ("project0-account-balance", "MarginfiAccount", ACCOUNT), + ]; + + let addresses: Vec<&str> = cases.iter().map(|(_, _, a)| *a).collect(); + let accounts = fetch(&addresses).await; + + let (surfnet_svm, _simnet_events_rx, _geyser_events_rx) = SurfnetSvm::default(); + let registry = TemplateRegistry::new(); + let pubkey = Pubkey::new_unique(); + + for ((template_id, account_name, _), account) in cases.iter().zip(&accounts) { + let data = &account.data; + let template = registry + .get(template_id) + .unwrap_or_else(|| panic!("template {template_id} should exist")); + + let account_def = template + .idl() + .accounts + .iter() + .find(|a| a.name == *account_name) + .unwrap_or_else(|| panic!("{account_name} not in the IDL")); + assert_eq!( + &data[..8], + account_def.discriminator.as_slice(), + "{account_name} discriminator does not match the IDL" + ); + + let forged = surfnet_svm + .get_forged_account_data(&pubkey, data, template.idl(), &HashMap::new()) + .unwrap_or_else(|e| panic!("live {account_name} failed to round-trip: {e}")); + + assert_eq!( + forged.len(), + data.len(), + "{account_name} changed size on round-trip" + ); + let diffs = diff_indices(&forged, data); + assert!( + diffs.is_empty(), + "live {account_name} changed at {} byte(s), first at {:?}", + diffs.len(), + diffs.first() + ); + } +} + +/// Runs a getProgramAccounts call on the Project 0 program against mainnet, as the llm_context +/// recipes write it. +async fn program_accounts( + encoding: UiAccountEncoding, + data_slice: UiDataSliceConfig, + memcmps: &[(usize, &str)], +) -> Vec<(Pubkey, solana_account_decoder::UiAccount)> { + let client = SurfnetRemoteClient::new( + std::env::var(RPC_URL_ENV).unwrap_or_else(|_| DEFAULT_RPC_URL.to_string()), + ); + let filters = memcmps + .iter() + .map(|(offset, bytes)| { + RpcFilterType::Memcmp(Memcmp::new( + *offset, + MemcmpEncodedBytes::Base58(bytes.to_string()), + )) + }) + .collect(); + let config = RpcAccountInfoConfig { + encoding: Some(encoding), + data_slice: Some(data_slice), + commitment: Some(CommitmentConfig::confirmed()), + ..Default::default() + }; + match client + .get_program_accounts(&Pubkey::from_str_const(PROGRAM), config, Some(filters)) + .await + .unwrap_or_else(|e| panic!("getProgramAccounts {memcmps:?} failed: {e}")) + { + RemoteRpcResult::Ok(found) => found, + RemoteRpcResult::MethodNotSupported => panic!("the RPC does not serve getProgramAccounts"), + } +} + +const ORACLE_SLICE: UiDataSliceConfig = UiDataSliceConfig { + offset: 610, + length: 32, +}; + +/// The bank lookup the llm_context teaches: Bank discriminator, main group, mint and a Pyth push +/// oracle setup, with the bank's price account sliced from config.oracle_keys.0. It filters on the +/// discriminator because program upgrades change the Bank's size. +#[tokio::test] +async fn llm_context_bank_lookup_finds_the_native_sol_and_usdc_banks() { + for (mint, bank, oracle) in [ + ( + "So11111111111111111111111111111111111111112", + SOL_BANK, + SOL_BANK_ORACLE, + ), + ( + "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", + USDC_BANK, + USDC_BANK_ORACLE, + ), + ] { + let filters = [(0, "QnTef4UXSzF"), (41, GROUP), (8, mint), (609, "4")]; + let found = program_accounts(UiAccountEncoding::Base58, ORACLE_SLICE, &filters).await; + + assert_eq!(found.len(), 1, "expected one native bank for {mint}"); + let (pubkey, account) = &found[0]; + assert_eq!(pubkey.to_string(), bank); + let price_account = account.data.decode().expect("base58 data slice"); + assert_eq!( + Pubkey::try_from(price_account.as_slice()) + .unwrap() + .to_string(), + oracle + ); + } +} + +/// A token whose banks are not priced straight from Pyth (here jitoSOL, a PythLST bank) has no +/// result with the oracle setup filter; the llm_context's second call, without it, finds the bank. +#[tokio::test] +async fn llm_context_bank_lookup_falls_back_for_a_bank_not_priced_by_pyth_push() { + const JITOSOL_MINT: &str = "J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn"; + const JITOSOL_BANK: &str = "Bohoc1ikHLD7xKJuzTyiTyCwzaL5N7ggJQu75A8mKYM8"; + let filters = [(0, "QnTef4UXSzF"), (41, GROUP), (8, JITOSOL_MINT)]; + + let with_oracle_filter = [filters.as_slice(), &[(609, "4")]].concat(); + let pyth_push = + program_accounts(UiAccountEncoding::Base58, ORACLE_SLICE, &with_oracle_filter).await; + assert!( + pyth_push.is_empty(), + "jitoSOL now has a Pyth push bank: {pyth_push:?}" + ); + + let found = program_accounts(UiAccountEncoding::Base58, ORACLE_SLICE, &filters).await; + let banks: Vec = found.iter().map(|(pubkey, _)| pubkey.to_string()).collect(); + assert_eq!(banks, [JITOSOL_BANK], "expected the one jitoSOL bank"); +} + +/// The wallet lookup the llm_context teaches, sent as written: base58 is refused for accounts this +/// large, so it asks for base64 with a zero-length slice and reads only the pubkeys. +#[tokio::test] +async fn llm_context_wallet_lookup_finds_the_wallets_account() { + let account = fetch(&[ACCOUNT]).await.remove(0); + let wallet = Pubkey::new_from_array(account.data[40..72].try_into().unwrap()).to_string(); + let empty = UiDataSliceConfig { + offset: 0, + length: 0, + }; + let filters = [(0, "CKkRR4La3xu"), (8, GROUP), (40, wallet.as_str())]; + + let found = program_accounts(UiAccountEncoding::Base64, empty, &filters).await; + assert!( + found + .iter() + .any(|(pubkey, _)| pubkey.to_string() == ACCOUNT), + "the wallet's account {ACCOUNT} is missing from {found:?}" + ); +} + +/// `WrappedI80F48.value` is `[u8; 16]`, the little-endian i128 of value x 2^48. Writing back the +/// bytes of the i128 read from the raw data must be a no-op, which pins the byte order. +#[tokio::test] +async fn fixed_point_fields_read_as_little_endian_i128() { + let fetched = fetch(&[SOL_BANK, ACCOUNT]).await; + let (bank_data, account_data) = (&fetched[0].data, &fetched[1].data); + + let (surfnet_svm, _simnet_events_rx, _geyser_events_rx) = SurfnetSvm::default(); + let registry = TemplateRegistry::new(); + let pubkey = Pubkey::new_unique(); + + let bank = registry.get("project0-bank-shares").unwrap(); + let overrides: HashMap = BANK_FIXED_POINT + .iter() + .map(|(path, offset)| { + let raw = read_i128(bank_data, *offset); + (path.to_string(), fixed_point(raw)) + }) + .collect(); + let forged = surfnet_svm + .get_forged_account_data(&pubkey, bank_data, bank.idl(), &overrides) + .expect("write-back on the live SOL bank"); + assert!( + diff_indices(&forged, bank_data).is_empty(), + "write-back changed the bank" + ); + + let one = 1i128 << 48; + let weight = read_i128(bank_data, 312); + assert!( + weight > 0 && weight <= 2 * one, + "SOL asset_weight_maint should be between 0 and 2, got {weight}" + ); + + let account = registry.get("project0-account-balance").unwrap(); + let mut overrides = HashMap::new(); + for slot in 0..16 { + let base = balance_slot(slot); + overrides.insert( + format!("lending_account.balances.{slot}.asset_shares.value"), + fixed_point(read_i128(account_data, base + 40)), + ); + overrides.insert( + format!("lending_account.balances.{slot}.liability_shares.value"), + fixed_point(read_i128(account_data, base + 56)), + ); + } + let forged = surfnet_svm + .get_forged_account_data(&pubkey, account_data, account.idl(), &overrides) + .expect("write-back on the live account"); + assert!( + diff_indices(&forged, account_data).is_empty(), + "write-back changed the account" + ); +} + +/// Writes every property of every Project 0 template alone, against real padding and live enums, +/// and checks that only its own bytes change. +#[tokio::test] +async fn each_template_touches_only_its_offsets() { + let fetched = fetch(&[SOL_BANK, ACCOUNT]).await; + let (bank_data, account_data) = (&fetched[0].data, &fetched[1].data); + + let (surfnet_svm, _simnet_events_rx, _geyser_events_rx) = SurfnetSvm::default(); + let registry = TemplateRegistry::new(); + let pubkey = Pubkey::new_unique(); + + let fixed = |v: i128| (fixed_point(v), v.to_le_bytes().to_vec()); + let int = |v: u64, width: usize| (serde_json::json!(v), v.to_le_bytes()[..width].to_vec()); + let key = |k: Pubkey| (serde_json::json!(k.to_string()), k.to_bytes().to_vec()); + + // (path, offset, (value, bytes)). Each value differs from the live one. + let mut bank_rows: Vec<_> = BANK_FIXED_POINT + .iter() + .map(|(path, offset)| (*path, *offset, fixed(123_456_789_012_345))) + .collect(); + bank_rows.extend([ + ("config.deposit_limit", 360, int(12_345, 8)), + ( + "config.interest_rate_config.zero_util_rate", + 496, + int(11, 4), + ), + ( + "config.interest_rate_config.hundred_util_rate", + 500, + int(22, 4), + ), + ("config.interest_rate_config.points.0.util", 504, int(33, 4)), + ("config.interest_rate_config.points.0.rate", 508, int(44, 4)), + ("config.interest_rate_config.curve_type", 544, int(2, 1)), + ( + "config.operational_state", + 608, + (serde_json::json!("ReduceOnly"), vec![2]), + ), + ("config.borrow_limit", 776, int(23_456, 8)), + ("config.total_asset_value_init_limit", 792, int(34_567, 8)), + ("config.oracle_max_age", 800, int(3_600, 2)), + ("config.oracle_max_confidence", 804, int(777_777, 4)), + ("config.cb_window_max_up_bps", 770, int(2_100, 2)), + ("config.cb_window_max_down_bps", 772, int(5_100, 2)), + ("config.cb_deviation_bps_tiers.0", 824, int(650, 2)), + ("config.cb_deviation_bps_tiers.1", 826, int(1_100, 2)), + ("config.cb_deviation_bps_tiers.2", 828, int(1_900, 2)), + ]); + let slot = balance_slot(0); + let account_rows = vec![ + ("lending_account.balances.0.active", slot, int(7, 1)), + ( + "lending_account.balances.0.bank_pk", + slot + 1, + key(Pubkey::new_unique()), + ), + ( + "lending_account.balances.0.bank_asset_tag", + slot + 33, + int(9, 1), + ), + ( + "lending_account.balances.0.asset_shares.value", + slot + 40, + fixed(1 << 60), + ), + ( + "lending_account.balances.0.liability_shares.value", + slot + 56, + fixed(1 << 50), + ), + ( + "lending_account.balances.0.last_update", + slot + 88, + int(1_234_567, 8), + ), + ("authority", 40, key(Pubkey::new_unique())), + ]; + + let mut used = std::collections::BTreeSet::new(); + for template in registry.by_protocol("Project 0") { + let (data, rows) = match template.account_type.as_str() { + "Bank" => (bank_data, &bank_rows), + "MarginfiAccount" => (account_data, &account_rows), + other => panic!("{} targets {other}", template.id), + }; + for path in template.property_paths() { + let (_, offset, (value, bytes)) = rows + .iter() + .find(|(row, ..)| *row == path) + .unwrap_or_else(|| panic!("{}:{path} has no row", template.id)); + used.insert(path); + + let forged = surfnet_svm + .get_forged_account_data( + &pubkey, + data, + template.idl(), + &HashMap::from([(path.to_string(), value.clone())]), + ) + .unwrap_or_else(|e| panic!("[{}] {path}: {e}", template.id)); + + assert_eq!(forged.len(), data.len(), "[{}] {path}", template.id); + let target = *offset..offset + bytes.len(); + let diffs = diff_indices(&forged, data); + assert!( + !diffs.is_empty() && diffs.iter().all(|i| target.contains(i)), + "[{}] {path} changed {diffs:?}, expected {target:?}", + template.id + ); + assert_eq!( + &forged[target], + bytes.as_slice(), + "[{}] {path}", + template.id + ); + } + } + for (path, ..) in bank_rows.iter().chain(&account_rows) { + assert!(used.contains(path), "no template exposes {path}"); + } +} + +/// The deployed program. 45 bytes of `UpgradeableLoaderState::ProgramData` precede the ELF: a u32 +/// tag, the deploy slot and the upgrade authority. +async fn project0_elf() -> Vec { + let program_data = fetch(&[PROGRAM_DATA]).await.remove(0).data; + program_data[45..].to_vec() +} + +/// The live accounts `lending_account_pulse_health` reads, all from one slot. +struct Fixture { + elf: Vec, + accounts: HashMap<&'static str, solana_account::Account>, +} + +impl Fixture { + async fn load() -> Self { + let addresses = [ + GROUP, + SOL_BANK, + USDC_BANK, + SOL_BANK_ORACLE, + USDC_BANK_ORACLE, + ACCOUNT, + ]; + let fetched = fetch(&addresses).await; + Self { + elf: project0_elf().await, + accounts: addresses.iter().copied().zip(fetched).collect(), + } + } + + fn data(&self, address: &str) -> &[u8] { + &self.accounts[address].data + } +} + +/// `price_message.publish_time` of a fully verified `PriceUpdateV2`. +fn pyth_publish_time(data: &[u8]) -> i64 { + i64::from_le_bytes(data[93..101].try_into().unwrap()) +} + +/// `conf` and `ema_conf` of a fully verified `PriceUpdateV2` scaled to `price`, keeping their share +/// of the price: Project 0 refuses a price whose confidence is too wide a share of it. +fn confidence_scaled_to(data: &[u8], price: i64) -> [(String, serde_json::Value); 2] { + let at = + |offset: usize| u64::from_le_bytes(data[offset..offset + 8].try_into().unwrap()) as u128; + let scaled = |conf: u128, from: u128| serde_json::json!((conf * price as u128 / from) as u64); + [ + ("price_message.conf".to_string(), scaled(at(81), at(73))), + ( + "price_message.ema_conf".to_string(), + scaled(at(117), at(109)), + ), + ] +} + +/// What the risk engine wrote into `health_cache` after a pulse. +#[derive(Debug)] +struct Health { + flags: u32, + asset_value: i128, + liability_value: i128, + asset_value_maint: i128, + liability_value_maint: i128, +} + +impl Health { + const HEALTHY: u32 = 1; + const ENGINE_OK: u32 = 2; + const ORACLE_OK: u32 = 4; + + fn healthy(&self) -> bool { + self.flags & Self::HEALTHY != 0 + } + + fn engine_ran(&self) -> bool { + self.flags & (Self::ENGINE_OK | Self::ORACLE_OK) == Self::ENGINE_OK | Self::ORACLE_OK + } +} + +/// The deployed program and the fixture's accounts on a LiteSVM, with `account` as the +/// MarginfiAccount and `overrides` replacing fetched account data by address. The clock sits one +/// second after the newest price, so both prices are fresh. +fn loaded_svm(fixture: &Fixture, account: &[u8], overrides: &[(&str, Vec)]) -> LiteSVM { + let mut svm = LiteSVM::new() + .with_sigverify(false) + .with_blockhash_check(false); + svm.add_program(Pubkey::from_str_const(PROGRAM), &fixture.elf) + .expect("load the Project 0 program"); + + let mut accounts = fixture.accounts.clone(); + accounts.get_mut(ACCOUNT).unwrap().data = account.to_vec(); + for (address, data) in overrides { + accounts.get_mut(address).unwrap().data = data.clone(); + } + + let newest_price = [SOL_BANK_ORACLE, USDC_BANK_ORACLE] + .iter() + .map(|address| pyth_publish_time(&accounts[address].data)) + .max() + .unwrap(); + let mut clock: solana_clock::Clock = svm.get_sysvar(); + clock.unix_timestamp = newest_price + 1; + svm.set_sysvar(&clock); + + for (address, account) in accounts { + svm.set_account(Pubkey::from_str_const(address), account) + .unwrap_or_else(|e| panic!("set {address}: {e:?}")); + } + svm +} + +/// The (bank, oracle) list in balance-slot order, as the risk engine reads it. +fn remaining_metas(remaining: &[(&str, &str)]) -> Vec { + remaining + .iter() + .flat_map(|(bank, oracle)| { + [ + AccountMeta::new_readonly(Pubkey::from_str_const(bank), false), + AccountMeta::new_readonly(Pubkey::from_str_const(oracle), false), + ] + }) + .collect() +} + +/// Runs `lending_account_pulse_health` on the deployed program. `overrides` replaces fetched +/// account data by address, and `remaining` is the (bank, oracle) list in balance-slot order. +fn pulse_health( + fixture: &Fixture, + account: &[u8], + overrides: &[(&str, Vec)], + remaining: &[(&str, &str)], +) -> Health { + const PULSE_HEALTH: [u8; 8] = [186, 52, 117, 97, 34, 74, 39, 253]; + const HEALTH_CACHE: usize = 1840; + + let program = Pubkey::from_str_const(PROGRAM); + let mut svm = loaded_svm(fixture, account, overrides); + + let mut metas = vec![ + AccountMeta::new(Pubkey::from_str_const(ACCOUNT), false), + AccountMeta::new_readonly(Pubkey::from_str_const(GROUP), false), + ]; + metas.extend(remaining_metas(remaining)); + + let payer = Keypair::new(); + svm.airdrop(&payer.pubkey(), 10_000_000_000).unwrap(); + let tx = Transaction::new_signed_with_payer( + &[Instruction { + program_id: program, + accounts: metas, + data: PULSE_HEALTH.to_vec(), + }], + Some(&payer.pubkey()), + &[&payer], + svm.latest_blockhash(), + ); + if let Err(failed) = svm.send_transaction(tx) { + panic!( + "pulse_health failed: {:?}\n{}", + failed.err, + failed.meta.logs.join("\n") + ); + } + + let data = svm + .get_account(&Pubkey::from_str_const(ACCOUNT)) + .unwrap() + .data; + Health { + flags: u32::from_le_bytes( + data[HEALTH_CACHE + 104..HEALTH_CACHE + 108] + .try_into() + .unwrap(), + ), + asset_value: read_i128(&data, HEALTH_CACHE), + liability_value: read_i128(&data, HEALTH_CACHE + 16), + asset_value_maint: read_i128(&data, HEALTH_CACHE + 32), + liability_value_maint: read_i128(&data, HEALTH_CACHE + 48), + } +} + +/// Runs an empty flash loan, `lending_account_start_flashloan` then `_end_flashloan`, signed by +/// `authority`. Its end runs the circuit breaker gate over the banks of an account with debt, +/// and moves no tokens. +fn empty_flashloan( + fixture: &Fixture, + account: &[u8], + overrides: &[(&str, Vec)], + remaining: &[(&str, &str)], + authority: &Keypair, +) -> Result<(), String> { + const START_FLASHLOAN: [u8; 8] = [14, 131, 33, 220, 81, 186, 180, 107]; + const END_FLASHLOAN: [u8; 8] = [105, 124, 201, 106, 153, 2, 8, 156]; + + let program = Pubkey::from_str_const(PROGRAM); + let marginfi_account = Pubkey::from_str_const(ACCOUNT); + let mut svm = loaded_svm(fixture, account, overrides); + + // end_index: the end instruction is the second one in the transaction. + let start = Instruction { + program_id: program, + accounts: vec![ + AccountMeta::new(marginfi_account, false), + AccountMeta::new_readonly(authority.pubkey(), true), + AccountMeta::new_readonly( + Pubkey::from_str_const("Sysvar1nstructions1111111111111111111111111"), + false, + ), + ], + data: [START_FLASHLOAN.as_slice(), &1u64.to_le_bytes()].concat(), + }; + let mut end_metas = vec![ + AccountMeta::new(marginfi_account, false), + AccountMeta::new_readonly(Pubkey::from_str_const(GROUP), false), + AccountMeta::new_readonly(authority.pubkey(), true), + ]; + end_metas.extend(remaining_metas(remaining)); + let end = Instruction { + program_id: program, + accounts: end_metas, + data: END_FLASHLOAN.to_vec(), + }; + + svm.airdrop(&authority.pubkey(), 10_000_000_000).unwrap(); + let tx = Transaction::new_signed_with_payer( + &[start, end], + Some(&authority.pubkey()), + &[authority], + svm.latest_blockhash(), + ); + svm.send_transaction(tx) + .map(|_| ()) + .map_err(|failed| format!("{:?}\n{}", failed.err, failed.meta.logs.join("\n"))) +} + +fn forge(template_id: &str, data: &[u8], values: &[(String, serde_json::Value)]) -> Vec { + let (surfnet_svm, _simnet_events_rx, _geyser_events_rx) = SurfnetSvm::default(); + let registry = TemplateRegistry::new(); + let template = registry.get(template_id).unwrap(); + surfnet_svm + .get_forged_account_data( + &Pubkey::new_unique(), + data, + template.idl(), + &values.iter().cloned().collect(), + ) + .unwrap_or_else(|e| panic!("[{template_id}] {e}")) +} + +/// The live account rebuilt with `project0-account-balance` into 10 SOL of collateral against a +/// USDC debt, every other slot empty. The debt's initial-weight value is half the collateral's, as +/// the program values both at live prices, so the account stays healthy whatever SOL trades at. +fn sol_backed_usdc_borrow(fixture: &Fixture) -> Vec { + // Balances are sorted by bank_pk, highest first. + let sol = Pubkey::from_str_const(SOL_BANK); + let usdc = Pubkey::from_str_const(USDC_BANK); + assert!( + sol.to_bytes() > usdc.to_bytes(), + "SOL must sort before USDC" + ); + + let one = 1i128 << 48; + let empty = Pubkey::default().to_string(); + let balances = |usdc_shares: i128| { + let mut values = Vec::new(); + let mut slot = |index: usize, bank: &str, tag: u8, asset: i128, liability: i128| { + let prefix = format!("lending_account.balances.{index}"); + let active = u8::from(bank != empty); + values.extend([ + (format!("{prefix}.active"), serde_json::json!(active)), + (format!("{prefix}.bank_pk"), serde_json::json!(bank)), + (format!("{prefix}.bank_asset_tag"), serde_json::json!(tag)), + (format!("{prefix}.asset_shares.value"), fixed_point(asset)), + ( + format!("{prefix}.liability_shares.value"), + fixed_point(liability), + ), + ]); + }; + slot(0, SOL_BANK, 1, 10_000_000_000 * one, 0); + slot(1, USDC_BANK, 0, 0, usdc_shares * one); + for index in 2..16 { + slot(index, &empty, 0, 0, 0); + } + forge("project0-account-balance", fixture.data(ACCOUNT), &values) + }; + + let remaining = [(SOL_BANK, SOL_BANK_ORACLE), (USDC_BANK, USDC_BANK_ORACLE)]; + let measured = pulse_health(fixture, &balances(500_000_000), &[], &remaining); + balances(500_000_000 * measured.asset_value / (2 * measured.liability_value)) +} + +/// Differential check against the deployed program: a SOL-backed USDC borrow, built on the live +/// account with `project0-account-balance`, is healthy on live state and becomes liquidatable +/// after either the weight lever or the price lever. +#[tokio::test] +async fn risk_engine_honours_weight_and_price_overrides() { + let fixture = Fixture::load().await; + let registry = TemplateRegistry::new(); + + let price_feed = registry.get("pyth-core-compatible-price-feed-v2").unwrap(); + for oracle in [SOL_BANK_ORACLE, USDC_BANK_ORACLE] { + assert_eq!( + fixture.accounts[oracle].owner.to_string(), + price_feed.idl().address, + "{oracle} owner" + ); + } + + // The bank names its price account at config.oracle_keys.0; the template writes that account. + let sol_feed = + Pubkey::new_from_array(fixture.data(SOL_BANK)[610..642].try_into().unwrap()).to_string(); + assert_eq!( + sol_feed, SOL_BANK_ORACLE, + "the SOL bank reads a different price account" + ); + + let account = sol_backed_usdc_borrow(&fixture); + let remaining = [(SOL_BANK, SOL_BANK_ORACLE), (USDC_BANK, USDC_BANK_ORACLE)]; + + let baseline = pulse_health(&fixture, &account, &[], &remaining); + assert!( + baseline.engine_ran() && baseline.healthy(), + "baseline should be healthy: {baseline:?}" + ); + assert!(baseline.asset_value_maint > baseline.liability_value_maint); + + // Each lever goes halfway past the point where the program turns the account liquidatable. + // SOL is its only asset, so the SOL weight and price scale the asset value one-for-one. + let (assets, debt) = (baseline.asset_value_maint, baseline.liability_value_maint); + let live_weight = read_i128(fixture.data(SOL_BANK), 312); + let weight = fixed_point(live_weight * debt / (2 * assets)); + let weakened_bank = forge( + "project0-bank-risk-weights", + fixture.data(SOL_BANK), + &[ + ("config.asset_weight_init.value".to_string(), weight.clone()), + ("config.asset_weight_maint.value".to_string(), weight), + ], + ); + let weakened = pulse_health(&fixture, &account, &[(SOL_BANK, weakened_bank)], &remaining); + assert!( + weakened.engine_ran() && !weakened.healthy(), + "half the liquidation weight should be liquidatable: {weakened:?}" + ); + assert!(weakened.asset_value_maint < baseline.asset_value_maint); + assert_eq!( + weakened.liability_value_maint, baseline.liability_value_maint, + "debt moved" + ); + + let fresh = pyth_publish_time(fixture.data(&sol_feed)) + .max(pyth_publish_time(fixture.data(USDC_BANK_ORACLE))); + let live_price = i64::from_le_bytes(fixture.data(&sol_feed)[73..81].try_into().unwrap()); + let crash_price = (live_price as i128 * debt / (2 * assets)) as i64; + let [conf, ema_conf] = confidence_scaled_to(fixture.data(&sol_feed), crash_price); + let crashed_oracle = forge( + "pyth-core-compatible-price-feed-v2", + fixture.data(&sol_feed), + &[ + ( + "price_message.price".to_string(), + serde_json::json!(crash_price), + ), + ( + "price_message.ema_price".to_string(), + serde_json::json!(crash_price), + ), + conf, + ema_conf, + ( + "price_message.publish_time".to_string(), + serde_json::json!(fresh), + ), + ( + "price_message.prev_publish_time".to_string(), + serde_json::json!(fresh), + ), + ], + ); + let crashed = pulse_health( + &fixture, + &account, + &[(sol_feed.as_str(), crashed_oracle)], + &remaining, + ); + assert!( + crashed.engine_ran() && !crashed.healthy(), + "SOL at half its liquidation price should be liquidatable: {crashed:?}" + ); + assert!(crashed.asset_value_maint < baseline.asset_value_maint); + assert_eq!( + crashed.liability_value_maint, baseline.liability_value_maint, + "debt moved" + ); +} + +/// Stablecoin banks run a price circuit breaker: once USDC moves past its first tier, an account +/// with USDC debt fails every risk-carrying action with `CircuitBreakerPriceJump`, until +/// `project0-bank-oracle` moves the breaker's reference prices to the new price. +#[tokio::test] +async fn usdc_breaker_accepts_a_move_once_its_reference_prices_follow() { + let fixture = Fixture::load().await; + let usdc_bank = fixture.data(USDC_BANK); + let flags = u64::from_le_bytes(usdc_bank[840..848].try_into().unwrap()); + assert_eq!(flags >> 11 & 1, 1, "the USDC bank's circuit breaker is off"); + + let authority = Keypair::new(); + let account = forge( + "project0-account-authority", + &sol_backed_usdc_borrow(&fixture), + &[( + "authority".to_string(), + serde_json::json!(authority.pubkey().to_string()), + )], + ); + let remaining = [(SOL_BANK, SOL_BANK_ORACLE), (USDC_BANK, USDC_BANK_ORACLE)]; + + let usdc_feed = fixture.data(USDC_BANK_ORACLE); + assert_eq!(usdc_feed[40], 1, "Full verification"); + let price = i64::from_le_bytes(usdc_feed[73..81].try_into().unwrap()); + let exponent = i32::from_le_bytes(usdc_feed[89..93].try_into().unwrap()); + let depeg = price * 95 / 100; + let fresh = pyth_publish_time(usdc_feed).max(pyth_publish_time(fixture.data(SOL_BANK_ORACLE))); + let [conf, ema_conf] = confidence_scaled_to(usdc_feed, depeg); + let moved_feed = forge( + "pyth-core-compatible-price-feed-v2", + usdc_feed, + &[ + ("price_message.price".to_string(), serde_json::json!(depeg)), + ( + "price_message.ema_price".to_string(), + serde_json::json!(depeg), + ), + conf, + ema_conf, + ( + "price_message.publish_time".to_string(), + serde_json::json!(fresh), + ), + ( + "price_message.prev_publish_time".to_string(), + serde_json::json!(fresh), + ), + ], + ); + let reference = ((depeg as i128) << 48) / 10i128.pow(exponent.unsigned_abs()); + let moved_bank = forge( + "project0-bank-oracle", + usdc_bank, + &[ + ( + "cb_reference_price.value".to_string(), + fixed_point(reference), + ), + ( + "cb_window_reference_price.value".to_string(), + fixed_point(reference), + ), + ], + ); + + empty_flashloan(&fixture, &account, &[], &remaining, &authority) + .unwrap_or_else(|e| panic!("live prices should pass the breaker: {e}")); + + let refused = empty_flashloan( + &fixture, + &account, + &[(USDC_BANK_ORACLE, moved_feed.clone())], + &remaining, + &authority, + ) + .expect_err("USDC 5% down must trip the breaker"); + assert!(refused.contains("CircuitBreakerPriceJump"), "{refused}"); + + empty_flashloan( + &fixture, + &account, + &[(USDC_BANK_ORACLE, moved_feed), (USDC_BANK, moved_bank)], + &remaining, + &authority, + ) + .unwrap_or_else(|e| panic!("the breaker should accept a price its references follow: {e}")); +} diff --git a/crates/types/src/scenarios.rs b/crates/types/src/scenarios.rs index 418c183e0..7022e3a1f 100644 --- a/crates/types/src/scenarios.rs +++ b/crates/types/src/scenarios.rs @@ -1046,6 +1046,9 @@ pub struct YamlOverrideTemplateCollection { /// Protocol-specific constants shared by all templates in this collection #[serde(default)] pub constants: HashMap, + /// LLM context shared by all templates in this collection, placed before each template's own + #[serde(default)] + pub llm_context: Option, /// Selects offset-and-encoding writes for programs with no usable IDL. #[serde(default)] pub raw_layout: bool, @@ -1515,6 +1518,10 @@ impl YamlOverrideTemplateCollection { let account_type = entry .idl_account_name .unwrap_or_else(|| default_account_type.clone()); + let llm_context = match (&self.llm_context, entry.llm_context) { + (Some(shared), Some(own)) => Some(format!("{}\n\n{own}", shared.trim_end())), + (shared, own) => own.or_else(|| shared.clone()), + }; let properties = describe_properties_from_idl(entry.properties, idl.as_ref(), &account_type) .map_err(|e| format!("template '{}': {e}", entry.id))?; @@ -1529,7 +1536,7 @@ impl YamlOverrideTemplateCollection { account_type, constants: constants.clone(), tags: self.tags.clone(), - llm_context: entry.llm_context, + llm_context, raw_layout: self.raw_layout, keep_alive: entry .keep_alive