@percolatorct/sdk 1.0.0-beta.24 → 1.0.0-beta.26

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.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  TypeScript SDK for building clients, bots, and UIs on top of the [Percolator](https://github.com/dcccrypto/percolator) perpetual futures protocol on Solana.
4
4
 
5
- > **⚠️ BETA** — `1.0.0-beta.1`. Security audit (0x-SquidSol) complete. All 709 tests passing. Pending Helius API key + mainnet market deployment before `1.0.0` stable.
5
+ > **EXPERIMENTALNOT AUDITED.** `1.0.0-beta.25`. 742 tests passing. Do NOT use with real funds.
6
6
 
7
7
  [![npm](https://img.shields.io/npm/v/@percolator/sdk?color=14F195)](https://www.npmjs.com/package/@percolator/sdk)
8
8
  [![License](https://img.shields.io/badge/license-Apache--2.0-blue)](LICENSE)
@@ -434,8 +434,10 @@ const markets = await discoverMarkets(connection);
434
434
 
435
435
  | Program | Network | Address |
436
436
  |---------|---------|---------|
437
- | Percolator | Mainnet | `GM8zjJ8LTBMv9xEsverh6H6wLyevgMHEJXcEzyY3rY24` |
437
+ | Percolator | Mainnet | `ESa89R5Es3rJ5mnwGybVRG1GrNt9etP11Z5V2QWD4edv` |
438
438
  | Matcher | Mainnet | `DHP6DtwXP1yJsz8YzfoeigRFPB979gzmumkmCxDLSkUX` |
439
+ | Stake | Mainnet | `DC5fovFQD5SZYsetwvEqd4Wi4PFY1Yfnc669VMe6oa7F` |
440
+ | NFT | Mainnet | `FqhKJT9gtScjrmfUuRMjeg7cXNpif1fqsy5Jh65tJmTS` |
439
441
  | Percolator | Devnet | `FxfD37s1AZTeWfFQps9Zpebi2dNQ9QSSDtfMKdbsfKrD` |
440
442
  | Matcher | Devnet | `GTRgyTDfrMvBubALAqtHuQwT8tbGyXid7svXZKtWfC9k` |
441
443
 
@@ -689,19 +691,26 @@ const markets = await getMarketsByAddress(
689
691
  ```bash
690
692
  pnpm install # Install dependencies
691
693
  pnpm build # Build with tsup (outputs to dist/)
692
- pnpm test # Run test suite (vitest)
694
+ pnpm test # Run all 742 tests (vitest)
693
695
  pnpm lint # Type-check (tsc --noEmit)
696
+ pnpm verify-layout # Verify ABI byte offsets against on-chain layout
694
697
  ```
695
698
 
696
699
  ### Testing
697
700
 
698
- Tests cover ABI encoding roundtrips, PDA derivation, slab parsing, validation, and trading math:
701
+ Tests cover ABI encoding roundtrips, PDA derivation, slab parsing, validation, and trading math. 742 tests, 0 failures.
699
702
 
700
703
  ```bash
701
704
  pnpm test # Run all tests
702
705
  pnpm test -- --watch # Watch mode
703
706
  ```
704
707
 
708
+ ### v12.17 Layout Support
709
+
710
+ The SDK supports the v12.17 slab layout natively via `detectSlabLayout()`. The layout detection function inspects account size to select the correct field offsets for header, config, and per-account data.
711
+
712
+ A key fix in this version corrects the SBF byte offsets for `d1`/`d2` delta fields that were misaligned in earlier SDK versions. The `parseAllAccounts()` function applies the correct offsets for both devnet (legacy layout) and mainnet (v12.17 layout) slabs automatically.
713
+
705
714
  ### Publishing
706
715
 
707
716
  ```bash
@@ -2,3 +2,4 @@ export * from "./encode.js";
2
2
  export * from "./instructions.js";
3
3
  export * from "./accounts.js";
4
4
  export * from "./errors.js";
5
+ export * from "./nft.js";
@@ -123,6 +123,14 @@ export declare const IX_TAG: {
123
123
  readonly PauseMarket: 76;
124
124
  /** UnpauseMarket (tag 77): admin unpause. Re-enables all operations. */
125
125
  readonly UnpauseMarket: 77;
126
+ /** PERC-305 / SECURITY(H-4): Set PnL cap for ADL pre-check (admin only). */
127
+ readonly SetMaxPnlCap: 78;
128
+ /** PERC-309: Set OI cap multiplier for LP withdrawal limits (admin only). Packed u64. */
129
+ readonly SetOiCapMultiplier: 79;
130
+ /** PERC-314: Set dispute params (window_slots + bond_amount, admin only). */
131
+ readonly SetDisputeParams: 80;
132
+ /** PERC-315: Set LP collateral params (enabled + ltv_bps, admin only). */
133
+ readonly SetLpCollateralParams: 81;
126
134
  };
127
135
  /**
128
136
  * InitMarket instruction data (256 bytes total)
@@ -204,12 +212,41 @@ export interface WithdrawCollateralArgs {
204
212
  }
205
213
  export declare function encodeWithdrawCollateral(args: WithdrawCollateralArgs): Uint8Array;
206
214
  /**
207
- * KeeperCrank instruction data (4 bytes)
208
- * Funding rate is computed on-chain from LP inventory.
215
+ * Liquidation policy for KeeperCrank candidates (v12.17 two-phase crank).
216
+ *
217
+ * On-chain wire tags:
218
+ * 0x00 = FullClose — liquidate the entire position
219
+ * 0x01 = ExactPartial(u128) — reduce position by exactly `quantity` units
220
+ * 0xFF = TouchOnly — accrue fees / sweep dust, do NOT liquidate
221
+ */
222
+ export declare const LiquidationPolicyTag: {
223
+ readonly FullClose: 0;
224
+ readonly ExactPartial: 1;
225
+ readonly TouchOnly: 255;
226
+ };
227
+ export type KeeperCrankCandidate = {
228
+ policy: typeof LiquidationPolicyTag.FullClose;
229
+ idx: number;
230
+ } | {
231
+ policy: typeof LiquidationPolicyTag.ExactPartial;
232
+ idx: number;
233
+ quantity: bigint | string;
234
+ } | {
235
+ policy: typeof LiquidationPolicyTag.TouchOnly;
236
+ idx: number;
237
+ };
238
+ /**
239
+ * KeeperCrank instruction data (v12.17 two-phase crank).
240
+ *
241
+ * Wire format: tag(1) + caller_idx(u16) + format_version=1(u8) +
242
+ * candidates: [ idx(u16) + policy_tag(u8) [+ quantity(u128) if ExactPartial] ]*
243
+ *
244
+ * Empty candidates list = simple crank (accrue funding, sweep dust).
245
+ * With candidates = targeted liquidation/touch pass.
209
246
  */
210
247
  export interface KeeperCrankArgs {
211
248
  callerIdx: number;
212
- allowPanic: boolean;
249
+ candidates?: KeeperCrankCandidate[];
213
250
  }
214
251
  export declare function encodeKeeperCrank(args: KeeperCrankArgs): Uint8Array;
215
252
  /**
@@ -243,21 +280,24 @@ export interface TopUpInsuranceArgs {
243
280
  }
244
281
  export declare function encodeTopUpInsurance(args: TopUpInsuranceArgs): Uint8Array;
245
282
  /**
246
- * TradeCpi instruction data (21 bytes)
283
+ * TradeCpi instruction data (29 bytes)
284
+ *
285
+ * v12.17: limit_price_e6 is now REQUIRED (slippage protection).
286
+ * Set to 0 to accept any price (no slippage protection).
287
+ * For buys: tx reverts if execution price > limitPriceE6.
288
+ * For sells: tx reverts if execution price < limitPriceE6.
247
289
  */
248
290
  export interface TradeCpiArgs {
249
291
  lpIdx: number;
250
292
  userIdx: number;
251
293
  size: bigint | string;
294
+ /** Limit price in e6 units. 0 = no limit (accept any price). */
295
+ limitPriceE6: bigint | string;
252
296
  }
253
297
  export declare function encodeTradeCpi(args: TradeCpiArgs): Uint8Array;
254
298
  /**
255
- * TradeCpiV2 instruction data (22 bytes) PERC-154 optimized trade CPI.
256
- *
257
- * Same as TradeCpi but includes a caller-provided PDA bump byte.
258
- * Uses create_program_address instead of find_program_address,
259
- * saving ~1500 CU per trade. The bump should be obtained once via
260
- * deriveLpPda() and cached for the lifetime of the market.
299
+ * @deprecated Tag 35 removed in v12.17. Use TradeCpi (tag 10) with limitPriceE6 instead.
300
+ * TradeCpi now handles PDA bump internally. Sending tag 35 will fail with InvalidInstructionData.
261
301
  */
262
302
  export interface TradeCpiV2Args {
263
303
  lpIdx: number;
@@ -265,13 +305,24 @@ export interface TradeCpiV2Args {
265
305
  size: bigint | string;
266
306
  bump: number;
267
307
  }
308
+ /** @deprecated Tag 35 removed in v12.17. Use encodeTradeCpi with limitPriceE6 instead. */
268
309
  export declare function encodeTradeCpiV2(args: TradeCpiV2Args): Uint8Array;
269
310
  /**
270
- * SetRiskThreshold instruction data (17 bytes)
311
+ * @deprecated Tag 36 removed in v12.17. Will fail on-chain with InvalidInstructionData.
312
+ */
313
+ export interface UnresolveMarketArgs {
314
+ confirmation: bigint | string;
315
+ }
316
+ /** @deprecated Tag 36 removed in v12.17. Will fail on-chain. */
317
+ export declare function encodeUnresolveMarket(args: UnresolveMarketArgs): Uint8Array;
318
+ /**
319
+ * @deprecated Tag 11 removed in v12.17. Insurance floor is now set at InitMarket.
320
+ * Sending this instruction will fail with InvalidInstructionData.
271
321
  */
272
322
  export interface SetRiskThresholdArgs {
273
323
  newThreshold: bigint | string;
274
324
  }
325
+ /** @deprecated Tag 11 removed in v12.17. Will fail on-chain. */
275
326
  export declare function encodeSetRiskThreshold(args: SetRiskThresholdArgs): Uint8Array;
276
327
  /**
277
328
  * UpdateAdmin instruction data (33 bytes)
@@ -285,31 +336,27 @@ export declare function encodeUpdateAdmin(args: UpdateAdminArgs): Uint8Array;
285
336
  */
286
337
  export declare function encodeCloseSlab(): Uint8Array;
287
338
  /**
288
- * UpdateConfig instruction data
289
- * Updates funding and threshold parameters at runtime (admin only)
339
+ * UpdateConfig instruction data (33 bytes)
340
+ *
341
+ * v12.17: Only 4 funding parameters. Threshold/insurance parameters are set
342
+ * at InitMarket and updated via dedicated instructions (SetRiskThreshold removed).
343
+ * fundingInvScaleNotionalE6 removed (now computed on-chain from LP state).
290
344
  */
291
345
  export interface UpdateConfigArgs {
292
346
  fundingHorizonSlots: bigint | string;
293
347
  fundingKBps: bigint | string;
294
- fundingInvScaleNotionalE6: bigint | string;
295
348
  fundingMaxPremiumBps: bigint | string;
296
349
  fundingMaxBpsPerSlot: bigint | string;
297
- threshFloor: bigint | string;
298
- threshRiskBps: bigint | string;
299
- threshUpdateIntervalSlots: bigint | string;
300
- threshStepBps: bigint | string;
301
- threshAlphaBps: bigint | string;
302
- threshMin: bigint | string;
303
- threshMax: bigint | string;
304
- threshMinStep: bigint | string;
305
350
  }
306
351
  export declare function encodeUpdateConfig(args: UpdateConfigArgs): Uint8Array;
307
352
  /**
308
- * SetMaintenanceFee instruction data (17 bytes)
353
+ * @deprecated Tag 15 removed in v12.17. Maintenance fee is set at InitMarket only.
354
+ * Sending this instruction will fail with InvalidInstructionData.
309
355
  */
310
356
  export interface SetMaintenanceFeeArgs {
311
357
  newFee: bigint | string;
312
358
  }
359
+ /** @deprecated Tag 15 removed in v12.17. Will fail on-chain. */
313
360
  export declare function encodeSetMaintenanceFee(args: SetMaintenanceFeeArgs): Uint8Array;
314
361
  /**
315
362
  * SetOracleAuthority instruction data (33 bytes)
@@ -378,18 +425,16 @@ export interface AdminForceCloseArgs {
378
425
  }
379
426
  export declare function encodeAdminForceClose(args: AdminForceCloseArgs): Uint8Array;
380
427
  /**
381
- * UpdateRiskParams instruction data (17 or 25 bytes)
382
- * Update initial and maintenance margin BPS (admin only).
383
- *
384
- * R2-S13: The Rust program uses `data.len() >= 25` to detect the optional
385
- * tradingFeeBps field, so variable-length encoding is safe. When tradingFeeBps
386
- * is omitted, the data is 17 bytes (tag + 2×u64). When included, 25 bytes.
428
+ * @deprecated Tag 22 is now SetInsuranceWithdrawPolicy in v12.17.
429
+ * This encoder sends the WRONG wire format (u64+u64 instead of pubkey+u64+u16+u64).
430
+ * Use encodeSetInsuranceWithdrawPolicy instead.
387
431
  */
388
432
  export interface UpdateRiskParamsArgs {
389
433
  initialMarginBps: bigint | string;
390
434
  maintenanceMarginBps: bigint | string;
391
435
  tradingFeeBps?: bigint | string;
392
436
  }
437
+ /** @deprecated Use encodeSetInsuranceWithdrawPolicy (tag 22). This sends wrong wire format. */
393
438
  export declare function encodeUpdateRiskParams(args: UpdateRiskParamsArgs): Uint8Array;
394
439
  /**
395
440
  * On-chain confirmation code for RenounceAdmin (must match program constant).
@@ -401,11 +446,9 @@ export declare const RENOUNCE_ADMIN_CONFIRMATION = 5928230587143701317n;
401
446
  */
402
447
  export declare const UNRESOLVE_CONFIRMATION = 16045690984503054900n;
403
448
  /**
404
- * RenounceAdmin instruction data (9 bytes)
405
- * Irreversibly set admin to all zeros. After this, all admin-only instructions fail.
406
- *
407
- * Requires the confirmation code 0x52454E4F554E4345 ("RENOUNCE" as u64 LE)
408
- * to prevent accidental invocation.
449
+ * @deprecated Tag 23 is now WithdrawInsuranceLimited in v12.17.
450
+ * This encoder sends the confirmation code as a withdrawal amount DANGEROUS.
451
+ * Use encodeWithdrawInsuranceLimited instead.
409
452
  */
410
453
  export declare function encodeRenounceAdmin(): Uint8Array;
411
454
  /**
@@ -464,29 +507,15 @@ export declare function encodePauseMarket(): Uint8Array;
464
507
  */
465
508
  export declare function encodeUnpauseMarket(): Uint8Array;
466
509
  /**
467
- * SetPythOracle (Tag 32) switch a market to Pyth-pinned mode.
468
- *
469
- * After this instruction:
470
- * - oracle_authority is cleared → PushOraclePrice is disabled
471
- * - index_feed_id is set to feed_id → validated on every price read
472
- * - max_staleness_secs and conf_filter_bps are updated
473
- * - All price reads go directly to read_pyth_price_e6() with on-chain
474
- * staleness + confidence + feed-ID validation (no silent fallback)
475
- *
476
- * Instruction data: tag(1) + feed_id(32) + max_staleness_secs(8) + conf_filter_bps(2) = 43 bytes
477
- *
478
- * Accounts:
479
- * 0. [signer, writable] Admin
480
- * 1. [writable] Slab
510
+ * @deprecated Tag 32 removed in v12.17. Pyth oracle is configured at InitMarket via indexFeedId.
511
+ * Sending this instruction will fail with InvalidInstructionData.
481
512
  */
482
513
  export interface SetPythOracleArgs {
483
- /** 32-byte Pyth feed ID. All zeros is invalid (reserved for Hyperp mode). */
484
514
  feedId: Uint8Array;
485
- /** Maximum age of Pyth price in seconds before OracleStale is returned. Must be > 0. */
486
515
  maxStalenessSecs: bigint;
487
- /** Max confidence/price ratio in bps (0 = no confidence check). */
488
516
  confFilterBps: number;
489
517
  }
518
+ /** @deprecated Tag 32 removed in v12.17. Pyth is configured at InitMarket. */
490
519
  export declare function encodeSetPythOracle(args: SetPythOracleArgs): Uint8Array;
491
520
  /**
492
521
  * Derive the expected Pyth PriceUpdateV2 account address for a given feed ID.
@@ -498,18 +527,8 @@ export declare function encodeSetPythOracle(args: SetPythOracleArgs): Uint8Array
498
527
  export declare const PYTH_RECEIVER_PROGRAM_ID = "rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ";
499
528
  export declare function derivePythPriceUpdateAccount(feedId: Uint8Array, shardId?: number): Promise<string>;
500
529
  /**
501
- * UpdateMarkPrice (Tag 33) permissionless EMA mark price crank.
502
- *
503
- * Reads the current oracle price on-chain, applies 8-hour EMA smoothing
504
- * with circuit breaker, and writes result to authority_price_e6.
505
- *
506
- * Instruction data: 1 byte (tag only — all params read from on-chain state)
507
- *
508
- * Accounts:
509
- * 0. [writable] Slab
510
- * 1. [] Oracle account (Pyth PriceUpdateV2 / Chainlink / DEX AMM)
511
- * 2. [] Clock sysvar (SysvarC1ock11111111111111111111111111111111)
512
- * 3..N [] Remaining accounts (PumpSwap vaults, etc. if needed)
530
+ * @deprecated Tag 33 removed in v12.17. Use UpdateHyperpMark (tag 34) for DEX-oracle markets.
531
+ * Sending this instruction will fail with InvalidInstructionData.
513
532
  */
514
533
  export declare function encodeUpdateMarkPrice(): Uint8Array;
515
534
  /**
@@ -1108,3 +1127,70 @@ export declare function encodeDepositInsuranceLP(args: {
1108
1127
  export declare function encodeWithdrawInsuranceLP(args: {
1109
1128
  lpAmount: bigint | string;
1110
1129
  }): Uint8Array;
1130
+ /**
1131
+ * SetMaxPnlCap (Tag 78, PERC-305 / SECURITY(H-4)) — set the PnL cap for ADL
1132
+ * pre-check (admin only). When `pnl_pos_tot <= max_pnl_cap`, ADL returns
1133
+ * early (no deleveraging needed).
1134
+ *
1135
+ * `capE6 = 0` disables the cap (ADL always runs when insurance is depleted).
1136
+ *
1137
+ * Instruction data: tag(1) + cap(u64, 8) = 9 bytes
1138
+ */
1139
+ export interface SetMaxPnlCapArgs {
1140
+ /** PnL cap in engine quote units (e.g., 1_000_000 = $1 e6). 0 = cap disabled. */
1141
+ cap: bigint | string;
1142
+ }
1143
+ export declare function encodeSetMaxPnlCap(args: SetMaxPnlCapArgs): Uint8Array;
1144
+ /**
1145
+ * SetOiCapMultiplier (Tag 79, PERC-309) — set the OI cap multiplier for LP
1146
+ * withdrawal limits (admin only). Packed u64:
1147
+ * lo 32 bits: multiplier_bps (e.g., 15000 = 1.5× soft cap in stressed state)
1148
+ * hi 32 bits: soft_cap_bps (e.g., 8000 = 80% base cap)
1149
+ *
1150
+ * `packed = 0` disables enforcement (no cap on LP withdrawals).
1151
+ *
1152
+ * Instruction data: tag(1) + packed(u64, 8) = 9 bytes
1153
+ */
1154
+ export interface SetOiCapMultiplierArgs {
1155
+ /** Packed u64: lo32 = multiplier_bps, hi32 = soft_cap_bps. 0 = disabled. */
1156
+ packed: bigint | string;
1157
+ }
1158
+ export declare function encodeSetOiCapMultiplier(args: SetOiCapMultiplierArgs): Uint8Array;
1159
+ /** Convenience: pack (multiplier_bps, soft_cap_bps) into the u64 expected by SetOiCapMultiplier. */
1160
+ export declare function packOiCap(multiplierBps: number, softCapBps: number): bigint;
1161
+ /**
1162
+ * SetDisputeParams (Tag 80, PERC-314) — configure settlement dispute window
1163
+ * and bond (admin only).
1164
+ *
1165
+ * - `windowSlots = 0` disables disputes (ChallengeSettlement returns
1166
+ * DisputeWindowClosed). Max: 2_000_000 slots (≈ 8 days at 400ms slots) to
1167
+ * prevent DoS via absurd freezes.
1168
+ * - `bondAmount` (collateral tokens): refunded on dispute upheld, forfeited
1169
+ * on reject. 0 = no bond required.
1170
+ *
1171
+ * Instruction data: tag(1) + window_slots(u64, 8) + bond_amount(u64, 8) = 17 bytes
1172
+ */
1173
+ export interface SetDisputeParamsArgs {
1174
+ /** Dispute window in slots. 0 = disputes disabled. Max 2_000_000. */
1175
+ windowSlots: bigint | string;
1176
+ /** Bond required to open a dispute (collateral units). 0 = no bond. */
1177
+ bondAmount: bigint | string;
1178
+ }
1179
+ export declare function encodeSetDisputeParams(args: SetDisputeParamsArgs): Uint8Array;
1180
+ /**
1181
+ * SetLpCollateralParams (Tag 81, PERC-315) — configure LP token collateral
1182
+ * acceptance (admin only).
1183
+ *
1184
+ * - `enabled = 0`: DepositLpCollateral rejects all new deposits.
1185
+ * - `enabled = 1`: deposits allowed, subject to `ltvBps` haircut on value.
1186
+ * - `ltvBps` max 10_000 (100%). Typical: 5000 (50% LTV).
1187
+ *
1188
+ * Instruction data: tag(1) + enabled(u8, 1) + ltv_bps(u16, 2) = 4 bytes
1189
+ */
1190
+ export interface SetLpCollateralParamsArgs {
1191
+ /** 0 = disabled (blocks new deposits), 1 = enabled. */
1192
+ enabled: number;
1193
+ /** LTV in bps (0-10000). 5000 = 50% LTV. */
1194
+ ltvBps: number;
1195
+ }
1196
+ export declare function encodeSetLpCollateralParams(args: SetLpCollateralParamsArgs): Uint8Array;
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Standalone percolator-nft program SDK module.
3
+ *
4
+ * This covers the NFT program at `PERCOLATOR_NFT_PROGRAM_ID` which is
5
+ * separate from the main Percolator program. It handles:
6
+ * - MintPositionNft (tag 0)
7
+ * - BurnPositionNft (tag 1)
8
+ * - SettleFunding (tag 2)
9
+ * - GetPositionValue (tag 3)
10
+ * - ExecuteTransferHook (tag 4, SPL interface — not called directly)
11
+ * - EmergencyBurn (tag 5)
12
+ *
13
+ * PDA seeds (matches percolator-nft/src/state.rs):
14
+ * PositionNft state : ["position_nft", slab, user_idx_u16_LE]
15
+ * PositionNft mint : ["position_nft_mint", slab, user_idx_u16_LE]
16
+ * Mint authority : ["mint_authority"]
17
+ */
18
+ import { PublicKey } from "@solana/web3.js";
19
+ /** The standalone percolator-nft program (TransferHook + mint authority). */
20
+ export declare const NFT_PROGRAM_ID: PublicKey;
21
+ export declare function getNftProgramId(): PublicKey;
22
+ export declare const NFT_IX_TAG: {
23
+ readonly MintPositionNft: 0;
24
+ readonly BurnPositionNft: 1;
25
+ readonly SettleFunding: 2;
26
+ readonly GetPositionValue: 3;
27
+ readonly ExecuteTransferHook: 4;
28
+ readonly EmergencyBurn: 5;
29
+ };
30
+ /** Encode MintPositionNft (tag 0). Data: tag(1) + user_idx(2). */
31
+ export declare function encodeNftMint(userIdx: number): Uint8Array;
32
+ /** Encode BurnPositionNft (tag 1). Data: tag(1). */
33
+ export declare function encodeNftBurn(): Uint8Array;
34
+ /** Encode SettleFunding (tag 2). Data: tag(1). */
35
+ export declare function encodeNftSettleFunding(): Uint8Array;
36
+ /** Encode EmergencyBurn (tag 5). Data: tag(1). */
37
+ export declare function encodeNftEmergencyBurn(): Uint8Array;
38
+ type AccountMeta = "s" | "w" | "sw" | "r";
39
+ /**
40
+ * Account metas for MintPositionNft (tag 0).
41
+ *
42
+ * 0. [signer, writable] payer / position owner
43
+ * 1. [writable] PositionNft PDA (created)
44
+ * 2. [writable, signer] NFT mint (Token-2022, fresh keypair)
45
+ * 3. [writable] Owner's NFT ATA (created)
46
+ * 4. [] Slab account
47
+ * 5. [] Mint authority PDA
48
+ * 6. [] Token-2022 program
49
+ * 7. [] Associated token account program
50
+ * 8. [] System program
51
+ * 9. [writable] ExtraAccountMetaList PDA
52
+ */
53
+ export declare const ACCOUNTS_NFT_MINT: AccountMeta[];
54
+ /**
55
+ * Account metas for BurnPositionNft (tag 1).
56
+ *
57
+ * 0. [signer] NFT holder
58
+ * 1. [writable] PositionNft PDA (closed)
59
+ * 2. [writable] NFT mint (supply → 0)
60
+ * 3. [writable] Holder's NFT ATA (closed)
61
+ * 4. [] Slab account
62
+ * 5. [] Mint authority PDA
63
+ * 6. [] Token-2022 program
64
+ */
65
+ export declare const ACCOUNTS_NFT_BURN: AccountMeta[];
66
+ /**
67
+ * Account metas for EmergencyBurn (tag 5).
68
+ *
69
+ * 0. [signer] NFT holder
70
+ * 1. [writable] PositionNft PDA (closed)
71
+ * 2. [writable] NFT mint
72
+ * 3. [writable] Holder's NFT ATA
73
+ * 4. [] Slab account
74
+ * 5. [] Mint authority PDA
75
+ * 6. [] Token-2022 program
76
+ */
77
+ export declare const ACCOUNTS_NFT_EMERGENCY_BURN: AccountMeta[];
78
+ /**
79
+ * Derive the PositionNft state PDA.
80
+ * Seeds: ["position_nft", slab, user_idx_u16_LE]
81
+ */
82
+ export declare function deriveNftPda(slab: PublicKey, userIdx: number, programId?: PublicKey): [PublicKey, number];
83
+ /**
84
+ * Derive the PositionNft mint PDA.
85
+ * Seeds: ["position_nft_mint", slab, user_idx_u16_LE]
86
+ */
87
+ export declare function deriveNftMint(slab: PublicKey, userIdx: number, programId?: PublicKey): [PublicKey, number];
88
+ /**
89
+ * Derive the program-wide mint authority PDA.
90
+ * Seeds: ["mint_authority"]
91
+ */
92
+ export declare function deriveMintAuthority(programId?: PublicKey): [PublicKey, number];
93
+ /**
94
+ * On-chain PositionNft state (208 bytes, matches percolator-nft/src/state.rs).
95
+ *
96
+ * [0..8] magic u64
97
+ * [8] version u8
98
+ * [9] bump u8
99
+ * [10..16] _pad0
100
+ * [16..48] slab [u8; 32]
101
+ * [48..50] user_idx u16 LE
102
+ * [50..56] _pad1
103
+ * [56..88] nft_mint [u8; 32]
104
+ * [88..96] entry_price_e6 u64
105
+ * [96..104] position_size u64
106
+ * [104] is_long u8
107
+ * [105..112] _pad2
108
+ * [112..128] position_basis_q i128
109
+ * [128..144] last_funding_index_e18 i128
110
+ * [144..152] minted_at i64
111
+ * [152..160] account_id u64
112
+ * [160..208] _reserved
113
+ */
114
+ export declare const POSITION_NFT_STATE_LEN = 208;
115
+ export interface PositionNftState {
116
+ version: number;
117
+ bump: number;
118
+ slab: PublicKey;
119
+ userIdx: number;
120
+ nftMint: PublicKey;
121
+ entryPriceE6: bigint;
122
+ positionSize: bigint;
123
+ isLong: boolean;
124
+ positionBasisQ: bigint;
125
+ lastFundingIndexE18: bigint;
126
+ mintedAt: bigint;
127
+ accountId: bigint;
128
+ }
129
+ /**
130
+ * Parse a PositionNft account from raw bytes.
131
+ * @throws if data is shorter than POSITION_NFT_STATE_LEN (208 bytes).
132
+ */
133
+ export declare function parsePositionNftAccount(data: Uint8Array): PositionNftState;
134
+ export {};
@@ -18,7 +18,7 @@ export declare const PROGRAM_IDS: {
18
18
  };
19
19
  readonly mainnet: {
20
20
  readonly percolator: "ESa89R5Es3rJ5mnwGybVRG1GrNt9etP11Z5V2QWD4edv";
21
- readonly matcher: "DHP6DtwXP1yJsz8YzfoeigRFPB979gzmumkmCxDLSkUX";
21
+ readonly matcher: "GDK8wx38kpiSVSfGTVNiSdptX3Z5R4kQyqh6Q3QX6wmi";
22
22
  };
23
23
  };
24
24
  export type Network = "devnet" | "mainnet";