@percolatorct/sdk 1.0.0-beta.20 → 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.
- package/dist/abi/accounts.d.ts +22 -1
- package/dist/abi/errors.d.ts +0 -11
- package/dist/abi/instructions.d.ts +36 -28
- package/dist/index.js +329 -351
- package/dist/index.js.map +1 -1
- package/dist/math/trading.d.ts +1 -116
- package/dist/math/warmup.d.ts +0 -50
- package/dist/runtime/lighthouse.d.ts +1 -1
- package/dist/solana/oracle.d.ts +2 -10
- package/dist/solana/pda.d.ts +5 -0
- package/dist/solana/slab.d.ts +13 -8
- package/dist/solana/stake.d.ts +2 -2
- package/dist/validation.d.ts +1 -26
- package/package.json +1 -1
package/dist/abi/accounts.d.ts
CHANGED
|
@@ -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:
|
|
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
|
/**
|
|
@@ -117,6 +117,21 @@ export declare const ACCOUNTS_UNPAUSE_MARKET: readonly AccountSpec[];
|
|
|
117
117
|
* remember the positional order, and errors clearly on missing names.
|
|
118
118
|
*/
|
|
119
119
|
export declare function buildAccountMetas(spec: readonly AccountSpec[], keys: PublicKey[] | Record<string, PublicKey>): AccountMeta[];
|
|
120
|
+
/**
|
|
121
|
+
* CreateInsuranceMint: 9 accounts
|
|
122
|
+
* Creates SPL mint PDA for insurance LP tokens. Admin only, once per market.
|
|
123
|
+
*/
|
|
124
|
+
export declare const ACCOUNTS_CREATE_INSURANCE_MINT: readonly AccountSpec[];
|
|
125
|
+
/**
|
|
126
|
+
* DepositInsuranceLP: 8 accounts
|
|
127
|
+
* Deposit collateral into insurance fund, receive LP tokens.
|
|
128
|
+
*/
|
|
129
|
+
export declare const ACCOUNTS_DEPOSIT_INSURANCE_LP: readonly AccountSpec[];
|
|
130
|
+
/**
|
|
131
|
+
* WithdrawInsuranceLP: 8 accounts
|
|
132
|
+
* Burn LP tokens and withdraw proportional share of insurance fund.
|
|
133
|
+
*/
|
|
134
|
+
export declare const ACCOUNTS_WITHDRAW_INSURANCE_LP: readonly AccountSpec[];
|
|
120
135
|
/**
|
|
121
136
|
* LpVaultWithdraw: 10 accounts (tag 39, PERC-627 / GH#1926 / PERC-8287)
|
|
122
137
|
*
|
|
@@ -229,6 +244,12 @@ export declare const ACCOUNTS_CLEAR_PENDING_SETTLEMENT: readonly AccountSpec[];
|
|
|
229
244
|
* Sets the per-wallet position cap (admin only). capE6=0 disables.
|
|
230
245
|
*/
|
|
231
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[];
|
|
232
253
|
/**
|
|
233
254
|
* InitMatcherCtx: 5 accounts
|
|
234
255
|
* Admin CPI-initializes the matcher context account for an LP slot.
|
package/dist/abi/errors.d.ts
CHANGED
|
@@ -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 {};
|
|
@@ -38,9 +38,7 @@ export declare const IX_TAG: {
|
|
|
38
38
|
readonly ReclaimEmptyAccount: 25;
|
|
39
39
|
readonly SettleAccount: 26;
|
|
40
40
|
readonly DepositFeeCredits: 27;
|
|
41
|
-
/** @deprecated No on-chain PauseMarket instruction */ readonly PauseMarket: 27;
|
|
42
41
|
readonly ConvertReleasedPnl: 28;
|
|
43
|
-
/** @deprecated No on-chain UnpauseMarket instruction */ readonly UnpauseMarket: 28;
|
|
44
42
|
readonly ResolvePermissionless: 29;
|
|
45
43
|
/** @deprecated Use ResolvePermissionless */ readonly AcceptAdmin: 29;
|
|
46
44
|
readonly ForceCloseResolved: 30;
|
|
@@ -121,6 +119,10 @@ export declare const IX_TAG: {
|
|
|
121
119
|
readonly SetDexPool: 74;
|
|
122
120
|
/** CPI to the matcher program to initialize a matcher context account for an LP slot. Admin-only. */
|
|
123
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;
|
|
124
126
|
};
|
|
125
127
|
/**
|
|
126
128
|
* InitMarket instruction data (256 bytes total)
|
|
@@ -144,25 +146,25 @@ export interface InitMarketArgs {
|
|
|
144
146
|
maxInsuranceFloor?: bigint | string;
|
|
145
147
|
minOraclePriceCap?: bigint | string;
|
|
146
148
|
/**
|
|
147
|
-
* @deprecated Use hMin
|
|
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.
|
|
149
151
|
*/
|
|
150
152
|
warmupPeriodSlots?: bigint | string;
|
|
151
|
-
/** Minimum horizon slots (v12.15+).
|
|
153
|
+
/** Minimum horizon slots (v12.15+). Falls back to warmupPeriodSlots if not provided. */
|
|
152
154
|
hMin?: bigint | string;
|
|
153
|
-
/** Maximum horizon slots (v12.15+).
|
|
155
|
+
/** Maximum horizon slots (v12.15+). Falls back to warmupPeriodSlots if not provided. */
|
|
154
156
|
hMax?: bigint | string;
|
|
155
157
|
maintenanceMarginBps: bigint | string;
|
|
156
158
|
initialMarginBps: bigint | string;
|
|
157
159
|
tradingFeeBps: bigint | string;
|
|
158
160
|
maxAccounts: bigint | string;
|
|
159
161
|
newAccountFee: bigint | string;
|
|
160
|
-
|
|
162
|
+
insuranceFloor?: bigint | string;
|
|
161
163
|
maintenanceFeePerSlot: bigint | string;
|
|
162
164
|
maxCrankStalenessSlots: bigint | string;
|
|
163
165
|
liquidationFeeBps: bigint | string;
|
|
164
166
|
liquidationFeeCap: bigint | string;
|
|
165
|
-
liquidationBufferBps
|
|
167
|
+
liquidationBufferBps?: bigint | string;
|
|
166
168
|
minLiquidationAbs: bigint | string;
|
|
167
169
|
minInitialDeposit: bigint | string;
|
|
168
170
|
minNonzeroMmReq: bigint | string;
|
|
@@ -827,28 +829,24 @@ export declare function encodeSetOiImbalanceHardBlock(args: {
|
|
|
827
829
|
* Creates a PositionNft PDA + Token-2022 mint with metadata, then mints 1 NFT to the
|
|
828
830
|
* position owner's ATA. The NFT represents ownership of `user_idx` in the slab.
|
|
829
831
|
*
|
|
830
|
-
*
|
|
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.
|
|
831
835
|
*
|
|
832
|
-
*
|
|
833
|
-
* 0. [signer, writable] payer
|
|
834
|
-
* 1. [writable] slab
|
|
835
|
-
* 2. [writable] position_nft PDA (created — seeds: ["position_nft", slab, user_idx])
|
|
836
|
-
* 3. [writable] nft_mint PDA (created)
|
|
837
|
-
* 4. [writable] owner_ata (Token-2022 ATA for owner)
|
|
838
|
-
* 5. [signer] owner (must match engine account owner)
|
|
839
|
-
* 6. [] vault_authority PDA
|
|
840
|
-
* 7. [] token_2022_program
|
|
841
|
-
* 8. [] system_program
|
|
842
|
-
* 9. [] rent sysvar
|
|
836
|
+
* Instruction data layout: tag(1) + user_idx(2) = 3 bytes
|
|
843
837
|
*
|
|
844
|
-
*
|
|
845
|
-
*
|
|
846
|
-
*
|
|
847
|
-
*
|
|
848
|
-
*
|
|
849
|
-
*
|
|
850
|
-
*
|
|
851
|
-
*
|
|
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)
|
|
852
850
|
*/
|
|
853
851
|
export interface MintPositionNftArgs {
|
|
854
852
|
userIdx: number;
|
|
@@ -1100,3 +1098,13 @@ export declare function encodeCloseOrphanSlab(): Uint8Array;
|
|
|
1100
1098
|
export declare function encodeSetDexPool(args: {
|
|
1101
1099
|
pool: PublicKey | string;
|
|
1102
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;
|