@percolatorct/sdk 1.0.0-beta.2 → 1.0.0-beta.21

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.
@@ -50,7 +50,7 @@ export declare const ACCOUNTS_CLOSE_ACCOUNT: readonly AccountSpec[];
50
50
  */
51
51
  export declare const ACCOUNTS_TOPUP_INSURANCE: readonly AccountSpec[];
52
52
  /**
53
- * TradeCpi: 7 accounts (PERC-199: clock sysvar removed uses Clock::get() syscall)
53
+ * TradeCpi: 8 accounts (deployed program expects clock sysvar at index 3)
54
54
  */
55
55
  export declare const ACCOUNTS_TRADE_CPI: readonly AccountSpec[];
56
56
  /**
@@ -207,11 +207,6 @@ export declare const ACCOUNTS_AUDIT_CRANK: readonly AccountSpec[];
207
207
  * Permissionless — no signer required beyond fee payer.
208
208
  */
209
209
  export declare const ACCOUNTS_ADVANCE_ORACLE_PHASE: readonly AccountSpec[];
210
- /**
211
- * TopUpKeeperFund: 3 accounts
212
- * Permissionless — anyone can fund. Transfers lamports directly (no system program).
213
- */
214
- export declare const ACCOUNTS_TOPUP_KEEPER_FUND: readonly AccountSpec[];
215
210
  /**
216
211
  * SetOiImbalanceHardBlock: 2 accounts
217
212
  * Sets the OI imbalance hard-block threshold (admin only)
@@ -249,6 +244,12 @@ export declare const ACCOUNTS_CLEAR_PENDING_SETTLEMENT: readonly AccountSpec[];
249
244
  * Sets the per-wallet position cap (admin only). capE6=0 disables.
250
245
  */
251
246
  export declare const ACCOUNTS_SET_WALLET_CAP: readonly AccountSpec[];
247
+ /**
248
+ * SetDexPool: 3 accounts
249
+ * Admin pins the approved DEX pool address for a HYPERP market.
250
+ * After this call, UpdateHyperpMark rejects any pool that does not match.
251
+ */
252
+ export declare const ACCOUNTS_SET_DEX_POOL: readonly AccountSpec[];
252
253
  /**
253
254
  * InitMatcherCtx: 5 accounts
254
255
  * Admin CPI-initializes the matcher context account for an LP slot.
@@ -19,27 +19,16 @@ export declare function getErrorName(code: number): string;
19
19
  * Get actionable hint for error code.
20
20
  */
21
21
  export declare function getErrorHint(code: number): string | undefined;
22
- /**
23
- * Check whether an error code is in the Anchor framework error range
24
- * (used by Lighthouse, not Percolator).
25
- */
26
- export declare function isAnchorErrorCode(code: number): boolean;
27
22
  /**
28
23
  * Parse error from transaction logs.
29
24
  * Looks for "Program ... failed: custom program error: 0x..."
30
25
  *
31
26
  * Hex capture is bounded (1–8 digits) so pathological logs cannot feed unbounded
32
27
  * strings into `parseInt` or produce precision-loss codes above u32.
33
- *
34
- * Distinguishes between:
35
- * - Percolator program errors (codes 0–65): returns Percolator error info
36
- * - Anchor/Lighthouse errors (codes 0x1770–0x1FFF): returns Lighthouse-specific
37
- * name and hint so callers can handle wallet middleware failures
38
28
  */
39
29
  export declare function parseErrorFromLogs(logs: string[]): {
40
30
  code: number;
41
31
  name: string;
42
32
  hint?: string;
43
- source?: "percolator" | "lighthouse" | "unknown";
44
33
  } | null;
45
34
  export {};
@@ -30,16 +30,18 @@ export declare const IX_TAG: {
30
30
  readonly ResolveMarket: 19;
31
31
  readonly WithdrawInsurance: 20;
32
32
  readonly AdminForceClose: 21;
33
- readonly UpdateRiskParams: 22;
34
- readonly RenounceAdmin: 23;
35
- readonly CreateInsuranceMint: 24;
36
- readonly DepositInsuranceLP: 25;
37
- readonly WithdrawInsuranceLP: 26;
38
- readonly PauseMarket: 27;
39
- readonly UnpauseMarket: 28;
40
- readonly AcceptAdmin: 29;
41
- readonly SetInsuranceWithdrawPolicy: 30;
42
- readonly WithdrawInsuranceLimited: 31;
33
+ readonly SetInsuranceWithdrawPolicy: 22;
34
+ /** @deprecated Use SetInsuranceWithdrawPolicy */ readonly UpdateRiskParams: 22;
35
+ readonly WithdrawInsuranceLimited: 23;
36
+ /** @deprecated Use WithdrawInsuranceLimited */ readonly RenounceAdmin: 23;
37
+ readonly QueryLpFees: 24;
38
+ readonly ReclaimEmptyAccount: 25;
39
+ readonly SettleAccount: 26;
40
+ readonly DepositFeeCredits: 27;
41
+ readonly ConvertReleasedPnl: 28;
42
+ readonly ResolvePermissionless: 29;
43
+ /** @deprecated Use ResolvePermissionless */ readonly AcceptAdmin: 29;
44
+ readonly ForceCloseResolved: 30;
43
45
  readonly SetPythOracle: 32;
44
46
  readonly UpdateMarkPrice: 33;
45
47
  readonly UpdateHyperpMark: 34;
@@ -81,8 +83,6 @@ export declare const IX_TAG: {
81
83
  readonly AttestCrossMargin: 55;
82
84
  /** PERC-622: Advance oracle phase (permissionless crank) */
83
85
  readonly AdvanceOraclePhase: 56;
84
- /** PERC-623: Top up a market's keeper fund (permissionless) */
85
- readonly TopUpKeeperFund: 57;
86
86
  /** PERC-629: Slash a market creator's deposit (permissionless) */
87
87
  readonly SlashCreationDeposit: 58;
88
88
  /** PERC-628: Initialize the global shared vault (admin) */
@@ -119,6 +119,10 @@ export declare const IX_TAG: {
119
119
  readonly SetDexPool: 74;
120
120
  /** CPI to the matcher program to initialize a matcher context account for an LP slot. Admin-only. */
121
121
  readonly InitMatcherCtx: 75;
122
+ /** PauseMarket (tag 76): admin emergency pause. Blocks Trade/Deposit/Withdraw/InitUser. */
123
+ readonly PauseMarket: 76;
124
+ /** UnpauseMarket (tag 77): admin unpause. Re-enables all operations. */
125
+ readonly UnpauseMarket: 77;
122
126
  };
123
127
  /**
124
128
  * InitMarket instruction data (256 bytes total)
@@ -138,19 +142,33 @@ export interface InitMarketArgs {
138
142
  invert: number;
139
143
  unitScale: number;
140
144
  initialMarkPriceE6: bigint | string;
141
- warmupPeriodSlots: bigint | string;
145
+ maxMaintenanceFeePerSlot?: bigint | string;
146
+ maxInsuranceFloor?: bigint | string;
147
+ minOraclePriceCap?: bigint | string;
148
+ /**
149
+ * @deprecated Use hMin and hMax instead (v12.15+). Accepted as fallback for both hMin and hMax
150
+ * when hMin/hMax are not provided.
151
+ */
152
+ warmupPeriodSlots?: bigint | string;
153
+ /** Minimum horizon slots (v12.15+). Falls back to warmupPeriodSlots if not provided. */
154
+ hMin?: bigint | string;
155
+ /** Maximum horizon slots (v12.15+). Falls back to warmupPeriodSlots if not provided. */
156
+ hMax?: bigint | string;
142
157
  maintenanceMarginBps: bigint | string;
143
158
  initialMarginBps: bigint | string;
144
159
  tradingFeeBps: bigint | string;
145
160
  maxAccounts: bigint | string;
146
161
  newAccountFee: bigint | string;
147
- riskReductionThreshold: bigint | string;
162
+ insuranceFloor?: bigint | string;
148
163
  maintenanceFeePerSlot: bigint | string;
149
164
  maxCrankStalenessSlots: bigint | string;
150
165
  liquidationFeeBps: bigint | string;
151
166
  liquidationFeeCap: bigint | string;
152
- liquidationBufferBps: bigint | string;
167
+ liquidationBufferBps?: bigint | string;
153
168
  minLiquidationAbs: bigint | string;
169
+ minInitialDeposit: bigint | string;
170
+ minNonzeroMmReq: bigint | string;
171
+ minNonzeroImReq: bigint | string;
154
172
  }
155
173
  export declare function encodeInitMarket(args: InitMarketArgs): Uint8Array;
156
174
  /**
@@ -390,27 +408,6 @@ export declare const UNRESOLVE_CONFIRMATION = 16045690984503054900n;
390
408
  * to prevent accidental invocation.
391
409
  */
392
410
  export declare function encodeRenounceAdmin(): Uint8Array;
393
- /**
394
- * CreateInsuranceMint instruction data (1 byte)
395
- * Creates the SPL mint PDA for insurance LP tokens. Admin only, once per market.
396
- */
397
- export declare function encodeCreateInsuranceMint(): Uint8Array;
398
- /**
399
- * DepositInsuranceLP instruction data (9 bytes)
400
- * Deposit collateral into insurance fund, receive LP tokens proportional to share.
401
- */
402
- export interface DepositInsuranceLPArgs {
403
- amount: bigint | string;
404
- }
405
- export declare function encodeDepositInsuranceLP(args: DepositInsuranceLPArgs): Uint8Array;
406
- /**
407
- * WithdrawInsuranceLP instruction data (9 bytes)
408
- * Burn LP tokens and withdraw proportional share of insurance fund.
409
- */
410
- export interface WithdrawInsuranceLPArgs {
411
- lpAmount: bigint | string;
412
- }
413
- export declare function encodeWithdrawInsuranceLP(args: WithdrawInsuranceLPArgs): Uint8Array;
414
411
  /**
415
412
  * LpVaultWithdraw (Tag 39, PERC-627 / GH#1926 / PERC-8287) — burn LP vault tokens and
416
413
  * withdraw proportional collateral.
@@ -701,21 +698,6 @@ export declare const PHASE2_MATURITY_SLOTS = 3024000n;
701
698
  * @returns [newPhase, shouldTransition]
702
699
  */
703
700
  export declare function checkPhaseTransition(currentSlot: bigint, marketCreatedSlot: bigint, oraclePhase: number, cumulativeVolumeE6: bigint, phase2DeltaSlots: number, hasMatureOracle: boolean): [number, boolean];
704
- /**
705
- * TopUpKeeperFund (Tag 57) — permissionless keeper fund top-up.
706
- *
707
- * Instruction data: tag(1) + amount(8) = 9 bytes
708
- *
709
- * Accounts:
710
- * 0. [signer, writable] Funder
711
- * 1. [writable] Slab
712
- * 2. [writable] Keeper fund PDA
713
- * 3. [] System program
714
- */
715
- export interface TopUpKeeperFundArgs {
716
- amount: bigint | string;
717
- }
718
- export declare function encodeTopUpKeeperFund(args: TopUpKeeperFundArgs): Uint8Array;
719
701
  /**
720
702
  * SlashCreationDeposit (Tag 58) — permissionless: slash a market creator's deposit
721
703
  * after the spam grace period has elapsed (PERC-629).
@@ -847,28 +829,24 @@ export declare function encodeSetOiImbalanceHardBlock(args: {
847
829
  * Creates a PositionNft PDA + Token-2022 mint with metadata, then mints 1 NFT to the
848
830
  * position owner's ATA. The NFT represents ownership of `user_idx` in the slab.
849
831
  *
850
- * Instruction data layout: tag(1) + user_idx(2) = 3 bytes
832
+ * The program creates the ATA internally via CPI when the 11th account (Associated Token
833
+ * Program) is provided. This is required because the NFT mint PDA doesn't exist until the
834
+ * program creates it, so the ATA can't be created in a preceding instruction.
851
835
  *
852
- * Accounts:
853
- * 0. [signer, writable] payer
854
- * 1. [writable] slab
855
- * 2. [writable] position_nft PDA (created — seeds: ["position_nft", slab, user_idx])
856
- * 3. [writable] nft_mint PDA (created)
857
- * 4. [writable] owner_ata (Token-2022 ATA for owner)
858
- * 5. [signer] owner (must match engine account owner)
859
- * 6. [] vault_authority PDA
860
- * 7. [] token_2022_program
861
- * 8. [] system_program
862
- * 9. [] rent sysvar
836
+ * Instruction data layout: tag(1) + user_idx(2) = 3 bytes
863
837
  *
864
- * @example
865
- * ```ts
866
- * const ix = new TransactionInstruction({
867
- * programId: PROGRAM_ID,
868
- * keys: buildAccountMetas(ACCOUNTS_MINT_POSITION_NFT, [payer, slab, nftPda, nftMint, ownerAta, owner, vaultAuth, TOKEN_2022_PROGRAM_ID, SystemProgram.programId, SYSVAR_RENT_PUBKEY]),
869
- * data: Buffer.from(encodeMintPositionNft({ userIdx: 5 })),
870
- * });
871
- * ```
838
+ * Accounts (11):
839
+ * 0. [signer, writable] payer
840
+ * 1. [writable] slab
841
+ * 2. [writable] position_nft PDA (created — seeds: ["position_nft", slab, user_idx_u16_le])
842
+ * 3. [writable] nft_mint PDA (created — seeds: ["position_nft_mint", slab, user_idx_u16_le])
843
+ * 4. [writable] owner_ata (Token-2022 ATA for nft_mint — created by program if absent)
844
+ * 5. [signer] owner (must match engine account owner)
845
+ * 6. [] vault_authority PDA (seeds: ["vault", slab])
846
+ * 7. [] token_2022_program (TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb)
847
+ * 8. [] system_program
848
+ * 9. [] rent sysvar
849
+ * 10. [] associated_token_program (ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL)
872
850
  */
873
851
  export interface MintPositionNftArgs {
874
852
  userIdx: number;
@@ -1056,3 +1034,77 @@ export interface InitMatcherCtxArgs {
1056
1034
  skewSpreadMultBps: number;
1057
1035
  }
1058
1036
  export declare function encodeInitMatcherCtx(args: InitMatcherCtxArgs): Uint8Array;
1037
+ /** SetInsuranceWithdrawPolicy (tag 22): authority + min_withdraw_base + max_withdraw_bps + cooldown_slots */
1038
+ export interface SetInsuranceWithdrawPolicyArgs {
1039
+ authority: PublicKey | string;
1040
+ minWithdrawBase: bigint | string;
1041
+ maxWithdrawBps: number;
1042
+ cooldownSlots: bigint | string;
1043
+ }
1044
+ export declare function encodeSetInsuranceWithdrawPolicy(args: SetInsuranceWithdrawPolicyArgs): Uint8Array;
1045
+ /** WithdrawInsuranceLimited (tag 23): amount */
1046
+ export declare function encodeWithdrawInsuranceLimited(args: {
1047
+ amount: bigint | string;
1048
+ }): Uint8Array;
1049
+ /** ResolvePermissionless (tag 29): no args */
1050
+ export declare function encodeResolvePermissionless(): Uint8Array;
1051
+ /** ForceCloseResolved (tag 30): user_idx */
1052
+ export declare function encodeForceCloseResolved(args: {
1053
+ userIdx: number;
1054
+ }): Uint8Array;
1055
+ /** CreateLpVault (tag 37): fee_share_bps + util_curve_enabled */
1056
+ export declare function encodeCreateLpVault(args: {
1057
+ feeShareBps: bigint | string;
1058
+ utilCurveEnabled?: boolean;
1059
+ }): Uint8Array;
1060
+ /** LpVaultDeposit (tag 38): amount */
1061
+ export declare function encodeLpVaultDeposit(args: {
1062
+ amount: bigint | string;
1063
+ }): Uint8Array;
1064
+ /** LpVaultCrankFees (tag 40): no args */
1065
+ export declare function encodeLpVaultCrankFees(): Uint8Array;
1066
+ /** ChallengeSettlement (tag 43): proposed_price_e6 */
1067
+ export declare function encodeChallengeSettlement(args: {
1068
+ proposedPriceE6: bigint | string;
1069
+ }): Uint8Array;
1070
+ /** ResolveDispute (tag 44): accept (0 = reject, 1 = accept) */
1071
+ export declare function encodeResolveDispute(args: {
1072
+ accept: number;
1073
+ }): Uint8Array;
1074
+ /** DepositLpCollateral (tag 45): user_idx + lp_amount */
1075
+ export declare function encodeDepositLpCollateral(args: {
1076
+ userIdx: number;
1077
+ lpAmount: bigint | string;
1078
+ }): Uint8Array;
1079
+ /** WithdrawLpCollateral (tag 46): user_idx + lp_amount */
1080
+ export declare function encodeWithdrawLpCollateral(args: {
1081
+ userIdx: number;
1082
+ lpAmount: bigint | string;
1083
+ }): Uint8Array;
1084
+ /** SetOffsetPair (tag 54): offset_bps */
1085
+ export declare function encodeSetOffsetPair(args: {
1086
+ offsetBps: number;
1087
+ }): Uint8Array;
1088
+ /** AttestCrossMargin (tag 55): user_idx_a + user_idx_b */
1089
+ export declare function encodeAttestCrossMargin(args: {
1090
+ userIdxA: number;
1091
+ userIdxB: number;
1092
+ }): Uint8Array;
1093
+ /** RescueOrphanVault (tag 72): no args */
1094
+ export declare function encodeRescueOrphanVault(): Uint8Array;
1095
+ /** CloseOrphanSlab (tag 73): no args */
1096
+ export declare function encodeCloseOrphanSlab(): Uint8Array;
1097
+ /** SetDexPool (tag 74): pool pubkey */
1098
+ export declare function encodeSetDexPool(args: {
1099
+ pool: PublicKey | string;
1100
+ }): Uint8Array;
1101
+ /** CreateInsuranceMint: creates the insurance LP mint PDA (tag 37, same as CreateLpVault) */
1102
+ export declare function encodeCreateInsuranceMint(): Uint8Array;
1103
+ /** DepositInsuranceLP: deposit collateral, receive LP tokens (tag 38, same as LpVaultDeposit) */
1104
+ export declare function encodeDepositInsuranceLP(args: {
1105
+ amount: bigint | string;
1106
+ }): Uint8Array;
1107
+ /** WithdrawInsuranceLP: burn LP tokens, withdraw collateral (tag 39, same as LpVaultWithdraw) */
1108
+ export declare function encodeWithdrawInsuranceLP(args: {
1109
+ lpAmount: bigint | string;
1110
+ }): Uint8Array;
@@ -17,7 +17,7 @@ export declare const PROGRAM_IDS: {
17
17
  readonly matcher: "GTRgyTDfrMvBubALAqtHuQwT8tbGyXid7svXZKtWfC9k";
18
18
  };
19
19
  readonly mainnet: {
20
- readonly percolator: "GM8zjJ8LTBMv9xEsverh6H6wLyevgMHEJXcEzyY3rY24";
20
+ readonly percolator: "ESa89R5Es3rJ5mnwGybVRG1GrNt9etP11Z5V2QWD4edv";
21
21
  readonly matcher: "DHP6DtwXP1yJsz8YzfoeigRFPB979gzmumkmCxDLSkUX";
22
22
  };
23
23
  };