@percolatorct/sdk 1.0.0-beta.3 → 1.0.0-beta.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,4 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
- /**
3
- * Oracle price constraints.
4
- * Maximum oracle price that can be pushed to the on-chain oracle authority.
5
- */
6
- export declare const MAX_ORACLE_PRICE = 1000000000000n;
7
2
  /**
8
3
  * Instruction tags - exact match to Rust ix::Instruction::decode
9
4
  */
@@ -24,19 +19,21 @@ export declare const IX_TAG: {
24
19
  readonly CloseSlab: 13;
25
20
  readonly UpdateConfig: 14;
26
21
  readonly SetMaintenanceFee: 15;
27
- readonly SetOracleAuthority: 16;
28
- readonly PushOraclePrice: 17;
29
22
  readonly SetOraclePriceCap: 18;
30
23
  readonly ResolveMarket: 19;
31
24
  readonly WithdrawInsurance: 20;
32
25
  readonly AdminForceClose: 21;
33
- readonly UpdateRiskParams: 22;
34
- readonly RenounceAdmin: 23;
35
- readonly PauseMarket: 27;
36
- readonly UnpauseMarket: 28;
37
- readonly AcceptAdmin: 29;
38
- readonly SetInsuranceWithdrawPolicy: 30;
39
- readonly WithdrawInsuranceLimited: 31;
26
+ readonly SetInsuranceWithdrawPolicy: 22;
27
+ /** @deprecated Use SetInsuranceWithdrawPolicy */ readonly UpdateRiskParams: 22;
28
+ readonly WithdrawInsuranceLimited: 23;
29
+ /** @deprecated Use WithdrawInsuranceLimited */ readonly RenounceAdmin: 23;
30
+ readonly QueryLpFees: 24;
31
+ readonly ReclaimEmptyAccount: 25;
32
+ readonly SettleAccount: 26;
33
+ readonly DepositFeeCredits: 27;
34
+ readonly ConvertReleasedPnl: 28;
35
+ readonly ResolvePermissionless: 29;
36
+ readonly ForceCloseResolved: 30;
40
37
  readonly SetPythOracle: 32;
41
38
  readonly UpdateMarkPrice: 33;
42
39
  readonly UpdateHyperpMark: 34;
@@ -78,8 +75,6 @@ export declare const IX_TAG: {
78
75
  readonly AttestCrossMargin: 55;
79
76
  /** PERC-622: Advance oracle phase (permissionless crank) */
80
77
  readonly AdvanceOraclePhase: 56;
81
- /** PERC-623: Top up a market's keeper fund (permissionless) */
82
- readonly TopUpKeeperFund: 57;
83
78
  /** PERC-629: Slash a market creator's deposit (permissionless) */
84
79
  readonly SlashCreationDeposit: 58;
85
80
  /** PERC-628: Initialize the global shared vault (admin) */
@@ -116,6 +111,20 @@ export declare const IX_TAG: {
116
111
  readonly SetDexPool: 74;
117
112
  /** CPI to the matcher program to initialize a matcher context account for an LP slot. Admin-only. */
118
113
  readonly InitMatcherCtx: 75;
114
+ /** PauseMarket (tag 76): admin emergency pause. Blocks Trade/Deposit/Withdraw/InitUser. */
115
+ readonly PauseMarket: 76;
116
+ /** UnpauseMarket (tag 77): admin unpause. Re-enables all operations. */
117
+ readonly UnpauseMarket: 77;
118
+ /** PERC-305 / SECURITY(H-4): Set PnL cap for ADL pre-check (admin only). */
119
+ readonly SetMaxPnlCap: 78;
120
+ /** PERC-309: Set OI cap multiplier for LP withdrawal limits (admin only). Packed u64. */
121
+ readonly SetOiCapMultiplier: 79;
122
+ /** PERC-314: Set dispute params (window_slots + bond_amount, admin only). */
123
+ readonly SetDisputeParams: 80;
124
+ /** PERC-315: Set LP collateral params (enabled + ltv_bps, admin only). */
125
+ readonly SetLpCollateralParams: 81;
126
+ /** Phase E (2026-04-17): Accept a pending admin transfer. Signer must match pending_admin. */
127
+ readonly AcceptAdmin: 82;
119
128
  };
120
129
  /**
121
130
  * InitMarket instruction data (256 bytes total)
@@ -126,6 +135,46 @@ export declare const IX_TAG: {
126
135
  * Note: indexFeedId is the Pyth Pull feed ID (32 bytes hex), NOT an oracle pubkey.
127
136
  * The program validates PriceUpdateV2 accounts against this feed ID at runtime.
128
137
  */
138
+ /**
139
+ * Optional 66-byte extended tail for InitMarket (S-4).
140
+ *
141
+ * When present and any field is non-zero the encoder appends a 66-byte block
142
+ * in the exact order that the program reads it (percolator.rs:1516-1545):
143
+ * insurance_withdraw_max_bps u16 (2 bytes)
144
+ * insurance_withdraw_cooldown_slots u64 (8 bytes)
145
+ * permissionless_resolve_stale_slots u64 (8 bytes)
146
+ * funding_horizon_slots u64 (8 bytes)
147
+ * funding_k_bps u64 (8 bytes)
148
+ * funding_max_premium_bps i64 (8 bytes)
149
+ * funding_max_bps_per_slot i64 (8 bytes)
150
+ * mark_min_fee u64 (8 bytes)
151
+ * force_close_delay_slots u64 (8 bytes)
152
+ * total = 2 + 8*8 = 66 bytes
153
+ *
154
+ * When absent (or all fields are zero) the encoder omits the tail and the
155
+ * program treats all extended fields as their default zero values. This
156
+ * preserves full backward compatibility with existing 344-byte payloads.
157
+ */
158
+ export interface InitMarketExtendedTail {
159
+ /** Maximum percentage of insurance fund withdrawable per cooldown window (0–10 000 bps). */
160
+ insuranceWithdrawMaxBps: number;
161
+ /** Slots that must elapse between insurance withdrawals. Required when insuranceWithdrawMaxBps > 0. */
162
+ insuranceWithdrawCooldownSlots: bigint | string;
163
+ /** Slots after which an unresolved market may be permissionlessly resolved. */
164
+ permissionlessResolveStaleSlots: bigint | string;
165
+ /** Funding rate horizon in slots (custom_funding_k denominator). */
166
+ fundingHorizonSlots: bigint | string;
167
+ /** Funding rate K parameter in bps (0 = disabled). */
168
+ fundingKBps: bigint | string;
169
+ /** Maximum funding premium in bps (i64 — may be negative to flip direction). */
170
+ fundingMaxPremiumBps: bigint | string;
171
+ /** Maximum funding rate change per slot in bps (i64). */
172
+ fundingMaxBpsPerSlot: bigint | string;
173
+ /** Minimum fee charged per mark-price update (u64, in collateral base units). */
174
+ markMinFee: bigint | string;
175
+ /** Slots to delay forced close after trigger condition is met (0 = immediate). */
176
+ forceCloseDelaySlots: bigint | string;
177
+ }
129
178
  export interface InitMarketArgs {
130
179
  admin: PublicKey | string;
131
180
  collateralMint: PublicKey | string;
@@ -135,20 +184,76 @@ export interface InitMarketArgs {
135
184
  invert: number;
136
185
  unitScale: number;
137
186
  initialMarkPriceE6: bigint | string;
138
- warmupPeriodSlots: bigint | string;
187
+ maxMaintenanceFeePerSlot?: bigint | string;
188
+ maxInsuranceFloor?: bigint | string;
189
+ minOraclePriceCap?: bigint | string;
190
+ /**
191
+ * @deprecated Use hMin and hMax instead (v12.15+). Accepted as fallback for both hMin and hMax
192
+ * when hMin/hMax are not provided.
193
+ */
194
+ warmupPeriodSlots?: bigint | string;
195
+ /** Minimum horizon slots (v12.15+). Falls back to warmupPeriodSlots if not provided. */
196
+ hMin?: bigint | string;
197
+ /** Maximum horizon slots (v12.15+). Falls back to warmupPeriodSlots if not provided. */
198
+ hMax?: bigint | string;
139
199
  maintenanceMarginBps: bigint | string;
140
200
  initialMarginBps: bigint | string;
141
201
  tradingFeeBps: bigint | string;
142
202
  maxAccounts: bigint | string;
143
203
  newAccountFee: bigint | string;
144
- riskReductionThreshold: bigint | string;
204
+ insuranceFloor?: bigint | string;
145
205
  maintenanceFeePerSlot: bigint | string;
146
206
  maxCrankStalenessSlots: bigint | string;
147
207
  liquidationFeeBps: bigint | string;
148
208
  liquidationFeeCap: bigint | string;
149
- liquidationBufferBps: bigint | string;
209
+ liquidationBufferBps?: bigint | string;
150
210
  minLiquidationAbs: bigint | string;
211
+ minInitialDeposit: bigint | string;
212
+ minNonzeroMmReq: bigint | string;
213
+ minNonzeroImReq: bigint | string;
214
+ /**
215
+ * Optional 66-byte extended tail (S-4).
216
+ * When present and any field is non-zero, appended after the 344-byte base payload.
217
+ * When absent (or all zeros), the base 344-byte payload is sent and the program
218
+ * uses default zero values for all extended fields.
219
+ * @see InitMarketExtendedTail
220
+ */
221
+ extendedTail?: InitMarketExtendedTail;
151
222
  }
223
+ /**
224
+ * Encode InitMarket instruction data.
225
+ *
226
+ * Produces either a 344-byte base payload (no extended tail) or a 410-byte
227
+ * payload (344 + 66 extended tail) depending on whether `args.extendedTail`
228
+ * is provided and contains at least one non-zero field.
229
+ *
230
+ * The program (percolator.rs:1527-1545) treats an empty `rest` as all-zero
231
+ * defaults, so the 344-byte form is fully backward-compatible.
232
+ *
233
+ * @param args InitMarket arguments
234
+ * @returns Encoded instruction bytes
235
+ *
236
+ * @example
237
+ * ```ts
238
+ * const ix = encodeInitMarket({
239
+ * admin: adminPk,
240
+ * collateralMint: mintPk,
241
+ * indexFeedId: "0000...0000",
242
+ * // ... required fields ...
243
+ * extendedTail: {
244
+ * insuranceWithdrawMaxBps: 500,
245
+ * insuranceWithdrawCooldownSlots: 216000n,
246
+ * permissionlessResolveStaleSlots: 0n,
247
+ * fundingHorizonSlots: 0n,
248
+ * fundingKBps: 0n,
249
+ * fundingMaxPremiumBps: 0n,
250
+ * fundingMaxBpsPerSlot: 0n,
251
+ * markMinFee: 0n,
252
+ * forceCloseDelaySlots: 0n,
253
+ * },
254
+ * });
255
+ * ```
256
+ */
152
257
  export declare function encodeInitMarket(args: InitMarketArgs): Uint8Array;
153
258
  /**
154
259
  * InitUser instruction data (9 bytes)
@@ -183,12 +288,41 @@ export interface WithdrawCollateralArgs {
183
288
  }
184
289
  export declare function encodeWithdrawCollateral(args: WithdrawCollateralArgs): Uint8Array;
185
290
  /**
186
- * KeeperCrank instruction data (4 bytes)
187
- * Funding rate is computed on-chain from LP inventory.
291
+ * Liquidation policy for KeeperCrank candidates (v12.17 two-phase crank).
292
+ *
293
+ * On-chain wire tags:
294
+ * 0x00 = FullClose — liquidate the entire position
295
+ * 0x01 = ExactPartial(u128) — reduce position by exactly `quantity` units
296
+ * 0xFF = TouchOnly — accrue fees / sweep dust, do NOT liquidate
297
+ */
298
+ export declare const LiquidationPolicyTag: {
299
+ readonly FullClose: 0;
300
+ readonly ExactPartial: 1;
301
+ readonly TouchOnly: 255;
302
+ };
303
+ export type KeeperCrankCandidate = {
304
+ policy: typeof LiquidationPolicyTag.FullClose;
305
+ idx: number;
306
+ } | {
307
+ policy: typeof LiquidationPolicyTag.ExactPartial;
308
+ idx: number;
309
+ quantity: bigint | string;
310
+ } | {
311
+ policy: typeof LiquidationPolicyTag.TouchOnly;
312
+ idx: number;
313
+ };
314
+ /**
315
+ * KeeperCrank instruction data (v12.17 two-phase crank).
316
+ *
317
+ * Wire format: tag(1) + caller_idx(u16) + format_version=1(u8) +
318
+ * candidates: [ idx(u16) + policy_tag(u8) [+ quantity(u128) if ExactPartial] ]*
319
+ *
320
+ * Empty candidates list = simple crank (accrue funding, sweep dust).
321
+ * With candidates = targeted liquidation/touch pass.
188
322
  */
189
323
  export interface KeeperCrankArgs {
190
324
  callerIdx: number;
191
- allowPanic: boolean;
325
+ candidates?: KeeperCrankCandidate[];
192
326
  }
193
327
  export declare function encodeKeeperCrank(args: KeeperCrankArgs): Uint8Array;
194
328
  /**
@@ -222,21 +356,24 @@ export interface TopUpInsuranceArgs {
222
356
  }
223
357
  export declare function encodeTopUpInsurance(args: TopUpInsuranceArgs): Uint8Array;
224
358
  /**
225
- * TradeCpi instruction data (21 bytes)
359
+ * TradeCpi instruction data (29 bytes)
360
+ *
361
+ * v12.17: limit_price_e6 is now REQUIRED (slippage protection).
362
+ * Set to 0 to accept any price (no slippage protection).
363
+ * For buys: tx reverts if execution price > limitPriceE6.
364
+ * For sells: tx reverts if execution price < limitPriceE6.
226
365
  */
227
366
  export interface TradeCpiArgs {
228
367
  lpIdx: number;
229
368
  userIdx: number;
230
369
  size: bigint | string;
370
+ /** Limit price in e6 units. 0 = no limit (accept any price). */
371
+ limitPriceE6: bigint | string;
231
372
  }
232
373
  export declare function encodeTradeCpi(args: TradeCpiArgs): Uint8Array;
233
374
  /**
234
- * TradeCpiV2 instruction data (22 bytes) PERC-154 optimized trade CPI.
235
- *
236
- * Same as TradeCpi but includes a caller-provided PDA bump byte.
237
- * Uses create_program_address instead of find_program_address,
238
- * saving ~1500 CU per trade. The bump should be obtained once via
239
- * deriveLpPda() and cached for the lifetime of the market.
375
+ * @deprecated Tag 35 removed in v12.17. Use TradeCpi (tag 10) with limitPriceE6 instead.
376
+ * TradeCpi now handles PDA bump internally. Sending tag 35 will fail with InvalidInstructionData.
240
377
  */
241
378
  export interface TradeCpiV2Args {
242
379
  lpIdx: number;
@@ -244,13 +381,24 @@ export interface TradeCpiV2Args {
244
381
  size: bigint | string;
245
382
  bump: number;
246
383
  }
384
+ /** @deprecated Tag 35 removed in v12.17. Use encodeTradeCpi with limitPriceE6 instead. */
247
385
  export declare function encodeTradeCpiV2(args: TradeCpiV2Args): Uint8Array;
248
386
  /**
249
- * SetRiskThreshold instruction data (17 bytes)
387
+ * @deprecated Tag 36 removed in v12.17. Will fail on-chain with InvalidInstructionData.
388
+ */
389
+ export interface UnresolveMarketArgs {
390
+ confirmation: bigint | string;
391
+ }
392
+ /** @deprecated Tag 36 removed in v12.17. Will fail on-chain. */
393
+ export declare function encodeUnresolveMarket(args: UnresolveMarketArgs): Uint8Array;
394
+ /**
395
+ * @deprecated Tag 11 removed in v12.17. Insurance floor is now set at InitMarket.
396
+ * Sending this instruction will fail with InvalidInstructionData.
250
397
  */
251
398
  export interface SetRiskThresholdArgs {
252
399
  newThreshold: bigint | string;
253
400
  }
401
+ /** @deprecated Tag 11 removed in v12.17. Will fail on-chain. */
254
402
  export declare function encodeSetRiskThreshold(args: SetRiskThresholdArgs): Uint8Array;
255
403
  /**
256
404
  * UpdateAdmin instruction data (33 bytes)
@@ -264,61 +412,28 @@ export declare function encodeUpdateAdmin(args: UpdateAdminArgs): Uint8Array;
264
412
  */
265
413
  export declare function encodeCloseSlab(): Uint8Array;
266
414
  /**
267
- * UpdateConfig instruction data
268
- * Updates funding and threshold parameters at runtime (admin only)
415
+ * UpdateConfig instruction data (33 bytes)
416
+ *
417
+ * v12.17: Only 4 funding parameters. Threshold/insurance parameters are set
418
+ * at InitMarket and updated via dedicated instructions (SetRiskThreshold removed).
419
+ * fundingInvScaleNotionalE6 removed (now computed on-chain from LP state).
269
420
  */
270
421
  export interface UpdateConfigArgs {
271
422
  fundingHorizonSlots: bigint | string;
272
423
  fundingKBps: bigint | string;
273
- fundingInvScaleNotionalE6: bigint | string;
274
424
  fundingMaxPremiumBps: bigint | string;
275
425
  fundingMaxBpsPerSlot: bigint | string;
276
- threshFloor: bigint | string;
277
- threshRiskBps: bigint | string;
278
- threshUpdateIntervalSlots: bigint | string;
279
- threshStepBps: bigint | string;
280
- threshAlphaBps: bigint | string;
281
- threshMin: bigint | string;
282
- threshMax: bigint | string;
283
- threshMinStep: bigint | string;
284
426
  }
285
427
  export declare function encodeUpdateConfig(args: UpdateConfigArgs): Uint8Array;
286
428
  /**
287
- * SetMaintenanceFee instruction data (17 bytes)
429
+ * @deprecated Tag 15 removed in v12.17. Maintenance fee is set at InitMarket only.
430
+ * Sending this instruction will fail with InvalidInstructionData.
288
431
  */
289
432
  export interface SetMaintenanceFeeArgs {
290
433
  newFee: bigint | string;
291
434
  }
435
+ /** @deprecated Tag 15 removed in v12.17. Will fail on-chain. */
292
436
  export declare function encodeSetMaintenanceFee(args: SetMaintenanceFeeArgs): Uint8Array;
293
- /**
294
- * SetOracleAuthority instruction data (33 bytes)
295
- * Sets the oracle price authority. Pass zero pubkey to disable and require Pyth/Chainlink.
296
- */
297
- export interface SetOracleAuthorityArgs {
298
- newAuthority: PublicKey | string;
299
- }
300
- export declare function encodeSetOracleAuthority(args: SetOracleAuthorityArgs): Uint8Array;
301
- /**
302
- * PushOraclePrice instruction data (17 bytes)
303
- * Push a new oracle price (oracle authority only).
304
- * The price should be in e6 format and already include any inversion/scaling.
305
- */
306
- export interface PushOraclePriceArgs {
307
- priceE6: bigint | string;
308
- timestamp: bigint | string;
309
- }
310
- /**
311
- * Encode PushOraclePrice instruction data with validation.
312
- *
313
- * Validates oracle price constraints:
314
- * - Price cannot be zero (division by zero in on-chain engine)
315
- * - Price cannot exceed MAX_ORACLE_PRICE (prevents overflow in price math)
316
- *
317
- * @param args - PushOraclePrice arguments
318
- * @returns Encoded instruction data (17 bytes)
319
- * @throws Error if price is 0 or exceeds MAX_ORACLE_PRICE
320
- */
321
- export declare function encodePushOraclePrice(args: PushOraclePriceArgs): Uint8Array;
322
437
  /**
323
438
  * SetOraclePriceCap instruction data (9 bytes)
324
439
  * Set oracle price circuit breaker cap (admin only).
@@ -357,18 +472,16 @@ export interface AdminForceCloseArgs {
357
472
  }
358
473
  export declare function encodeAdminForceClose(args: AdminForceCloseArgs): Uint8Array;
359
474
  /**
360
- * UpdateRiskParams instruction data (17 or 25 bytes)
361
- * Update initial and maintenance margin BPS (admin only).
362
- *
363
- * R2-S13: The Rust program uses `data.len() >= 25` to detect the optional
364
- * tradingFeeBps field, so variable-length encoding is safe. When tradingFeeBps
365
- * is omitted, the data is 17 bytes (tag + 2×u64). When included, 25 bytes.
475
+ * @deprecated Tag 22 is now SetInsuranceWithdrawPolicy in v12.17.
476
+ * This encoder sends the WRONG wire format (u64+u64 instead of pubkey+u64+u16+u64).
477
+ * Use encodeSetInsuranceWithdrawPolicy instead.
366
478
  */
367
479
  export interface UpdateRiskParamsArgs {
368
480
  initialMarginBps: bigint | string;
369
481
  maintenanceMarginBps: bigint | string;
370
482
  tradingFeeBps?: bigint | string;
371
483
  }
484
+ /** @deprecated Use encodeSetInsuranceWithdrawPolicy (tag 22). This sends wrong wire format. */
372
485
  export declare function encodeUpdateRiskParams(args: UpdateRiskParamsArgs): Uint8Array;
373
486
  /**
374
487
  * On-chain confirmation code for RenounceAdmin (must match program constant).
@@ -380,11 +493,9 @@ export declare const RENOUNCE_ADMIN_CONFIRMATION = 5928230587143701317n;
380
493
  */
381
494
  export declare const UNRESOLVE_CONFIRMATION = 16045690984503054900n;
382
495
  /**
383
- * RenounceAdmin instruction data (9 bytes)
384
- * Irreversibly set admin to all zeros. After this, all admin-only instructions fail.
385
- *
386
- * Requires the confirmation code 0x52454E4F554E4345 ("RENOUNCE" as u64 LE)
387
- * to prevent accidental invocation.
496
+ * @deprecated Tag 23 is now WithdrawInsuranceLimited in v12.17.
497
+ * This encoder sends the confirmation code as a withdrawal amount DANGEROUS.
498
+ * Use encodeWithdrawInsuranceLimited instead.
388
499
  */
389
500
  export declare function encodeRenounceAdmin(): Uint8Array;
390
501
  /**
@@ -443,29 +554,15 @@ export declare function encodePauseMarket(): Uint8Array;
443
554
  */
444
555
  export declare function encodeUnpauseMarket(): Uint8Array;
445
556
  /**
446
- * SetPythOracle (Tag 32) switch a market to Pyth-pinned mode.
447
- *
448
- * After this instruction:
449
- * - oracle_authority is cleared → PushOraclePrice is disabled
450
- * - index_feed_id is set to feed_id → validated on every price read
451
- * - max_staleness_secs and conf_filter_bps are updated
452
- * - All price reads go directly to read_pyth_price_e6() with on-chain
453
- * staleness + confidence + feed-ID validation (no silent fallback)
454
- *
455
- * Instruction data: tag(1) + feed_id(32) + max_staleness_secs(8) + conf_filter_bps(2) = 43 bytes
456
- *
457
- * Accounts:
458
- * 0. [signer, writable] Admin
459
- * 1. [writable] Slab
557
+ * @deprecated Tag 32 removed in v12.17. Pyth oracle is configured at InitMarket via indexFeedId.
558
+ * Sending this instruction will fail with InvalidInstructionData.
460
559
  */
461
560
  export interface SetPythOracleArgs {
462
- /** 32-byte Pyth feed ID. All zeros is invalid (reserved for Hyperp mode). */
463
561
  feedId: Uint8Array;
464
- /** Maximum age of Pyth price in seconds before OracleStale is returned. Must be > 0. */
465
562
  maxStalenessSecs: bigint;
466
- /** Max confidence/price ratio in bps (0 = no confidence check). */
467
563
  confFilterBps: number;
468
564
  }
565
+ /** @deprecated Tag 32 removed in v12.17. Pyth is configured at InitMarket. */
469
566
  export declare function encodeSetPythOracle(args: SetPythOracleArgs): Uint8Array;
470
567
  /**
471
568
  * Derive the expected Pyth PriceUpdateV2 account address for a given feed ID.
@@ -477,18 +574,8 @@ export declare function encodeSetPythOracle(args: SetPythOracleArgs): Uint8Array
477
574
  export declare const PYTH_RECEIVER_PROGRAM_ID = "rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ";
478
575
  export declare function derivePythPriceUpdateAccount(feedId: Uint8Array, shardId?: number): Promise<string>;
479
576
  /**
480
- * UpdateMarkPrice (Tag 33) permissionless EMA mark price crank.
481
- *
482
- * Reads the current oracle price on-chain, applies 8-hour EMA smoothing
483
- * with circuit breaker, and writes result to authority_price_e6.
484
- *
485
- * Instruction data: 1 byte (tag only — all params read from on-chain state)
486
- *
487
- * Accounts:
488
- * 0. [writable] Slab
489
- * 1. [] Oracle account (Pyth PriceUpdateV2 / Chainlink / DEX AMM)
490
- * 2. [] Clock sysvar (SysvarC1ock11111111111111111111111111111111)
491
- * 3..N [] Remaining accounts (PumpSwap vaults, etc. if needed)
577
+ * @deprecated Tag 33 removed in v12.17. Use UpdateHyperpMark (tag 34) for DEX-oracle markets.
578
+ * Sending this instruction will fail with InvalidInstructionData.
492
579
  */
493
580
  export declare function encodeUpdateMarkPrice(): Uint8Array;
494
581
  /**
@@ -677,21 +764,6 @@ export declare const PHASE2_MATURITY_SLOTS = 3024000n;
677
764
  * @returns [newPhase, shouldTransition]
678
765
  */
679
766
  export declare function checkPhaseTransition(currentSlot: bigint, marketCreatedSlot: bigint, oraclePhase: number, cumulativeVolumeE6: bigint, phase2DeltaSlots: number, hasMatureOracle: boolean): [number, boolean];
680
- /**
681
- * TopUpKeeperFund (Tag 57) — permissionless keeper fund top-up.
682
- *
683
- * Instruction data: tag(1) + amount(8) = 9 bytes
684
- *
685
- * Accounts:
686
- * 0. [signer, writable] Funder
687
- * 1. [writable] Slab
688
- * 2. [writable] Keeper fund PDA
689
- * 3. [] System program
690
- */
691
- export interface TopUpKeeperFundArgs {
692
- amount: bigint | string;
693
- }
694
- export declare function encodeTopUpKeeperFund(args: TopUpKeeperFundArgs): Uint8Array;
695
767
  /**
696
768
  * SlashCreationDeposit (Tag 58) — permissionless: slash a market creator's deposit
697
769
  * after the spam grace period has elapsed (PERC-629).
@@ -823,28 +895,24 @@ export declare function encodeSetOiImbalanceHardBlock(args: {
823
895
  * Creates a PositionNft PDA + Token-2022 mint with metadata, then mints 1 NFT to the
824
896
  * position owner's ATA. The NFT represents ownership of `user_idx` in the slab.
825
897
  *
826
- * Instruction data layout: tag(1) + user_idx(2) = 3 bytes
898
+ * The program creates the ATA internally via CPI when the 11th account (Associated Token
899
+ * Program) is provided. This is required because the NFT mint PDA doesn't exist until the
900
+ * program creates it, so the ATA can't be created in a preceding instruction.
827
901
  *
828
- * Accounts:
829
- * 0. [signer, writable] payer
830
- * 1. [writable] slab
831
- * 2. [writable] position_nft PDA (created — seeds: ["position_nft", slab, user_idx])
832
- * 3. [writable] nft_mint PDA (created)
833
- * 4. [writable] owner_ata (Token-2022 ATA for owner)
834
- * 5. [signer] owner (must match engine account owner)
835
- * 6. [] vault_authority PDA
836
- * 7. [] token_2022_program
837
- * 8. [] system_program
838
- * 9. [] rent sysvar
902
+ * Instruction data layout: tag(1) + user_idx(2) = 3 bytes
839
903
  *
840
- * @example
841
- * ```ts
842
- * const ix = new TransactionInstruction({
843
- * programId: PROGRAM_ID,
844
- * keys: buildAccountMetas(ACCOUNTS_MINT_POSITION_NFT, [payer, slab, nftPda, nftMint, ownerAta, owner, vaultAuth, TOKEN_2022_PROGRAM_ID, SystemProgram.programId, SYSVAR_RENT_PUBKEY]),
845
- * data: Buffer.from(encodeMintPositionNft({ userIdx: 5 })),
846
- * });
847
- * ```
904
+ * Accounts (11):
905
+ * 0. [signer, writable] payer
906
+ * 1. [writable] slab
907
+ * 2. [writable] position_nft PDA (created — seeds: ["position_nft", slab, user_idx_u16_le])
908
+ * 3. [writable] nft_mint PDA (created — seeds: ["position_nft_mint", slab, user_idx_u16_le])
909
+ * 4. [writable] owner_ata (Token-2022 ATA for nft_mint — created by program if absent)
910
+ * 5. [signer] owner (must match engine account owner)
911
+ * 6. [] vault_authority PDA (seeds: ["vault", slab])
912
+ * 7. [] token_2022_program (TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb)
913
+ * 8. [] system_program
914
+ * 9. [] rent sysvar
915
+ * 10. [] associated_token_program (ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL)
848
916
  */
849
917
  export interface MintPositionNftArgs {
850
918
  userIdx: number;
@@ -1032,3 +1100,168 @@ export interface InitMatcherCtxArgs {
1032
1100
  skewSpreadMultBps: number;
1033
1101
  }
1034
1102
  export declare function encodeInitMatcherCtx(args: InitMatcherCtxArgs): Uint8Array;
1103
+ /** SetInsuranceWithdrawPolicy (tag 22): authority + min_withdraw_base + max_withdraw_bps + cooldown_slots */
1104
+ export interface SetInsuranceWithdrawPolicyArgs {
1105
+ authority: PublicKey | string;
1106
+ minWithdrawBase: bigint | string;
1107
+ maxWithdrawBps: number;
1108
+ cooldownSlots: bigint | string;
1109
+ }
1110
+ export declare function encodeSetInsuranceWithdrawPolicy(args: SetInsuranceWithdrawPolicyArgs): Uint8Array;
1111
+ /**
1112
+ * WithdrawInsuranceLimited (tag 23): amount.
1113
+ * Account count is 7 (resolved markets) or 8 (live markets — oracle required
1114
+ * for same-instruction accrue_market_to per upstream 8ce8d54).
1115
+ * See ACCOUNTS_WITHDRAW_INSURANCE_LIMITED_LIVE / _RESOLVED in accounts.ts.
1116
+ */
1117
+ export declare function encodeWithdrawInsuranceLimited(args: {
1118
+ amount: bigint | string;
1119
+ }): Uint8Array;
1120
+ /** ResolvePermissionless (tag 29): no args */
1121
+ export declare function encodeResolvePermissionless(): Uint8Array;
1122
+ /** ForceCloseResolved (tag 30): user_idx */
1123
+ export declare function encodeForceCloseResolved(args: {
1124
+ userIdx: number;
1125
+ }): Uint8Array;
1126
+ /** CreateLpVault (tag 37): fee_share_bps + util_curve_enabled */
1127
+ export declare function encodeCreateLpVault(args: {
1128
+ feeShareBps: bigint | string;
1129
+ utilCurveEnabled?: boolean;
1130
+ }): Uint8Array;
1131
+ /** LpVaultDeposit (tag 38): amount */
1132
+ export declare function encodeLpVaultDeposit(args: {
1133
+ amount: bigint | string;
1134
+ }): Uint8Array;
1135
+ /** LpVaultCrankFees (tag 40): no args */
1136
+ export declare function encodeLpVaultCrankFees(): Uint8Array;
1137
+ /** ChallengeSettlement (tag 43): proposed_price_e6 */
1138
+ export declare function encodeChallengeSettlement(args: {
1139
+ proposedPriceE6: bigint | string;
1140
+ }): Uint8Array;
1141
+ /** ResolveDispute (tag 44): accept (0 = reject, 1 = accept) */
1142
+ export declare function encodeResolveDispute(args: {
1143
+ accept: number;
1144
+ }): Uint8Array;
1145
+ /** DepositLpCollateral (tag 45): user_idx + lp_amount */
1146
+ export declare function encodeDepositLpCollateral(args: {
1147
+ userIdx: number;
1148
+ lpAmount: bigint | string;
1149
+ }): Uint8Array;
1150
+ /** WithdrawLpCollateral (tag 46): user_idx + lp_amount */
1151
+ export declare function encodeWithdrawLpCollateral(args: {
1152
+ userIdx: number;
1153
+ lpAmount: bigint | string;
1154
+ }): Uint8Array;
1155
+ /** SetOffsetPair (tag 54): offset_bps */
1156
+ export declare function encodeSetOffsetPair(args: {
1157
+ offsetBps: number;
1158
+ }): Uint8Array;
1159
+ /** AttestCrossMargin (tag 55): user_idx_a + user_idx_b */
1160
+ export declare function encodeAttestCrossMargin(args: {
1161
+ userIdxA: number;
1162
+ userIdxB: number;
1163
+ }): Uint8Array;
1164
+ /** RescueOrphanVault (tag 72): no args */
1165
+ export declare function encodeRescueOrphanVault(): Uint8Array;
1166
+ /** CloseOrphanSlab (tag 73): no args */
1167
+ export declare function encodeCloseOrphanSlab(): Uint8Array;
1168
+ /** SetDexPool (tag 74): pool pubkey */
1169
+ export declare function encodeSetDexPool(args: {
1170
+ pool: PublicKey | string;
1171
+ }): Uint8Array;
1172
+ /** CreateInsuranceMint: creates the insurance LP mint PDA (tag 37, same as CreateLpVault) */
1173
+ export declare function encodeCreateInsuranceMint(): Uint8Array;
1174
+ /** DepositInsuranceLP: deposit collateral, receive LP tokens (tag 38, same as LpVaultDeposit) */
1175
+ export declare function encodeDepositInsuranceLP(args: {
1176
+ amount: bigint | string;
1177
+ }): Uint8Array;
1178
+ /** WithdrawInsuranceLP: burn LP tokens, withdraw collateral (tag 39, same as LpVaultWithdraw) */
1179
+ export declare function encodeWithdrawInsuranceLP(args: {
1180
+ lpAmount: bigint | string;
1181
+ }): Uint8Array;
1182
+ /**
1183
+ * SetMaxPnlCap (Tag 78, PERC-305 / SECURITY(H-4)) — set the PnL cap for ADL
1184
+ * pre-check (admin only). When `pnl_pos_tot <= max_pnl_cap`, ADL returns
1185
+ * early (no deleveraging needed).
1186
+ *
1187
+ * `capE6 = 0` disables the cap (ADL always runs when insurance is depleted).
1188
+ *
1189
+ * Instruction data: tag(1) + cap(u64, 8) = 9 bytes
1190
+ */
1191
+ export interface SetMaxPnlCapArgs {
1192
+ /** PnL cap in engine quote units (e.g., 1_000_000 = $1 e6). 0 = cap disabled. */
1193
+ cap: bigint | string;
1194
+ }
1195
+ export declare function encodeSetMaxPnlCap(args: SetMaxPnlCapArgs): Uint8Array;
1196
+ /**
1197
+ * SetOiCapMultiplier (Tag 79, PERC-309) — set the OI cap multiplier for LP
1198
+ * withdrawal limits (admin only). Packed u64:
1199
+ * lo 32 bits: multiplier_bps (e.g., 15000 = 1.5× soft cap in stressed state)
1200
+ * hi 32 bits: soft_cap_bps (e.g., 8000 = 80% base cap)
1201
+ *
1202
+ * `packed = 0` disables enforcement (no cap on LP withdrawals).
1203
+ *
1204
+ * Instruction data: tag(1) + packed(u64, 8) = 9 bytes
1205
+ */
1206
+ export interface SetOiCapMultiplierArgs {
1207
+ /** Packed u64: lo32 = multiplier_bps, hi32 = soft_cap_bps. 0 = disabled. */
1208
+ packed: bigint | string;
1209
+ }
1210
+ export declare function encodeSetOiCapMultiplier(args: SetOiCapMultiplierArgs): Uint8Array;
1211
+ /** Convenience: pack (multiplier_bps, soft_cap_bps) into the u64 expected by SetOiCapMultiplier. */
1212
+ export declare function packOiCap(multiplierBps: number, softCapBps: number): bigint;
1213
+ /**
1214
+ * SetDisputeParams (Tag 80, PERC-314) — configure settlement dispute window
1215
+ * and bond (admin only).
1216
+ *
1217
+ * - `windowSlots = 0` disables disputes (ChallengeSettlement returns
1218
+ * DisputeWindowClosed). Max: 2_000_000 slots (≈ 8 days at 400ms slots) to
1219
+ * prevent DoS via absurd freezes.
1220
+ * - `bondAmount` (collateral tokens): refunded on dispute upheld, forfeited
1221
+ * on reject. 0 = no bond required.
1222
+ *
1223
+ * Instruction data: tag(1) + window_slots(u64, 8) + bond_amount(u64, 8) = 17 bytes
1224
+ */
1225
+ export interface SetDisputeParamsArgs {
1226
+ /** Dispute window in slots. 0 = disputes disabled. Max 2_000_000. */
1227
+ windowSlots: bigint | string;
1228
+ /** Bond required to open a dispute (collateral units). 0 = no bond. */
1229
+ bondAmount: bigint | string;
1230
+ }
1231
+ export declare function encodeSetDisputeParams(args: SetDisputeParamsArgs): Uint8Array;
1232
+ /**
1233
+ * SetLpCollateralParams (Tag 81, PERC-315) — configure LP token collateral
1234
+ * acceptance (admin only).
1235
+ *
1236
+ * - `enabled = 0`: DepositLpCollateral rejects all new deposits.
1237
+ * - `enabled = 1`: deposits allowed, subject to `ltvBps` haircut on value.
1238
+ * - `ltvBps` max 10_000 (100%). Typical: 5000 (50% LTV).
1239
+ *
1240
+ * Instruction data: tag(1) + enabled(u8, 1) + ltv_bps(u16, 2) = 4 bytes
1241
+ */
1242
+ export interface SetLpCollateralParamsArgs {
1243
+ /** 0 = disabled (blocks new deposits), 1 = enabled. */
1244
+ enabled: number;
1245
+ /** LTV in bps (0-10000). 5000 = 50% LTV. */
1246
+ ltvBps: number;
1247
+ }
1248
+ export declare function encodeSetLpCollateralParams(args: SetLpCollateralParamsArgs): Uint8Array;
1249
+ /**
1250
+ * AcceptAdmin (Tag 82, Phase E 2026-04-17) — complete a two-step admin transfer.
1251
+ *
1252
+ * Called by the PROPOSED new admin (the pubkey passed to UpdateAdmin with
1253
+ * `new_admin != default()`). The signer must match config.pending_admin
1254
+ * exactly. On success, header.admin is swapped to pending_admin and
1255
+ * pending_admin is cleared.
1256
+ *
1257
+ * Use `try_update_admin` then `try_accept_admin` for a full rotation, or
1258
+ * skip AcceptAdmin entirely to leave a pending transfer that the old
1259
+ * admin can overwrite (propose-again) or the new admin can never accept.
1260
+ *
1261
+ * Accounts:
1262
+ * [0] new admin (signer, must match pending_admin)
1263
+ * [1] slab (writable)
1264
+ *
1265
+ * Instruction data: tag(1) = 1 byte. No payload.
1266
+ */
1267
+ export declare function encodeAcceptAdmin(): Uint8Array;