@percolatorct/sdk 1.0.0-beta.3 → 1.0.0-beta.30
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 +13 -4
- package/dist/abi/accounts.d.ts +31 -16
- package/dist/abi/errors.d.ts +0 -11
- package/dist/abi/index.d.ts +1 -0
- package/dist/abi/instructions.d.ts +297 -146
- package/dist/abi/nft.d.ts +134 -0
- package/dist/config/program-ids.d.ts +2 -2
- package/dist/index.js +1473 -597
- 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/discovery.d.ts +2 -13
- package/dist/solana/oracle.d.ts +2 -10
- package/dist/solana/pda.d.ts +5 -5
- package/dist/solana/slab.d.ts +132 -5
- package/dist/solana/stake.d.ts +27 -2
- package/dist/validation.d.ts +1 -26
- package/package.json +2 -1
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
|
-
>
|
|
5
|
+
> **EXPERIMENTAL — NOT AUDITED.** `1.0.0-beta.25`. 742 tests passing. Do NOT use with real funds.
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/@percolator/sdk)
|
|
8
8
|
[](LICENSE)
|
|
@@ -434,8 +434,10 @@ const markets = await discoverMarkets(connection);
|
|
|
434
434
|
|
|
435
435
|
| Program | Network | Address |
|
|
436
436
|
|---------|---------|---------|
|
|
437
|
-
| Percolator | Mainnet | `
|
|
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
|
|
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
|
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
|
/**
|
|
@@ -73,21 +73,11 @@ export declare const ACCOUNTS_UPDATE_CONFIG: readonly AccountSpec[];
|
|
|
73
73
|
* SetMaintenanceFee: 2 accounts
|
|
74
74
|
*/
|
|
75
75
|
export declare const ACCOUNTS_SET_MAINTENANCE_FEE: readonly AccountSpec[];
|
|
76
|
-
/**
|
|
77
|
-
* SetOracleAuthority: 2 accounts
|
|
78
|
-
* Sets the oracle price authority (admin only)
|
|
79
|
-
*/
|
|
80
|
-
export declare const ACCOUNTS_SET_ORACLE_AUTHORITY: readonly AccountSpec[];
|
|
81
76
|
/**
|
|
82
77
|
* SetOraclePriceCap: 2 accounts
|
|
83
78
|
* Set oracle price circuit breaker cap (admin only)
|
|
84
79
|
*/
|
|
85
80
|
export declare const ACCOUNTS_SET_ORACLE_PRICE_CAP: readonly AccountSpec[];
|
|
86
|
-
/**
|
|
87
|
-
* PushOraclePrice: 2 accounts
|
|
88
|
-
* Push oracle price (oracle authority only)
|
|
89
|
-
*/
|
|
90
|
-
export declare const ACCOUNTS_PUSH_ORACLE_PRICE: readonly AccountSpec[];
|
|
91
81
|
/**
|
|
92
82
|
* ResolveMarket: 2 accounts
|
|
93
83
|
* Resolves a binary/premarket (admin only)
|
|
@@ -98,6 +88,15 @@ export declare const ACCOUNTS_RESOLVE_MARKET: readonly AccountSpec[];
|
|
|
98
88
|
* Withdraw insurance fund after market resolution (admin only)
|
|
99
89
|
*/
|
|
100
90
|
export declare const ACCOUNTS_WITHDRAW_INSURANCE: readonly AccountSpec[];
|
|
91
|
+
/**
|
|
92
|
+
* WithdrawInsuranceLimited (tag 23): 7 or 8 accounts.
|
|
93
|
+
* On live markets the 8th oracle account is REQUIRED (upstream 8ce8d54):
|
|
94
|
+
* the handler does a same-instruction accrue_market_to against the fresh
|
|
95
|
+
* oracle price to prevent withdrawals against overstated insurance.
|
|
96
|
+
* On resolved markets the oracle is frozen — 7 accounts suffice.
|
|
97
|
+
*/
|
|
98
|
+
export declare const ACCOUNTS_WITHDRAW_INSURANCE_LIMITED_RESOLVED: readonly AccountSpec[];
|
|
99
|
+
export declare const ACCOUNTS_WITHDRAW_INSURANCE_LIMITED_LIVE: readonly AccountSpec[];
|
|
101
100
|
/**
|
|
102
101
|
* PauseMarket: 2 accounts
|
|
103
102
|
*/
|
|
@@ -117,6 +116,21 @@ export declare const ACCOUNTS_UNPAUSE_MARKET: readonly AccountSpec[];
|
|
|
117
116
|
* remember the positional order, and errors clearly on missing names.
|
|
118
117
|
*/
|
|
119
118
|
export declare function buildAccountMetas(spec: readonly AccountSpec[], keys: PublicKey[] | Record<string, PublicKey>): AccountMeta[];
|
|
119
|
+
/**
|
|
120
|
+
* CreateInsuranceMint: 9 accounts
|
|
121
|
+
* Creates SPL mint PDA for insurance LP tokens. Admin only, once per market.
|
|
122
|
+
*/
|
|
123
|
+
export declare const ACCOUNTS_CREATE_INSURANCE_MINT: readonly AccountSpec[];
|
|
124
|
+
/**
|
|
125
|
+
* DepositInsuranceLP: 8 accounts
|
|
126
|
+
* Deposit collateral into insurance fund, receive LP tokens.
|
|
127
|
+
*/
|
|
128
|
+
export declare const ACCOUNTS_DEPOSIT_INSURANCE_LP: readonly AccountSpec[];
|
|
129
|
+
/**
|
|
130
|
+
* WithdrawInsuranceLP: 8 accounts
|
|
131
|
+
* Burn LP tokens and withdraw proportional share of insurance fund.
|
|
132
|
+
*/
|
|
133
|
+
export declare const ACCOUNTS_WITHDRAW_INSURANCE_LP: readonly AccountSpec[];
|
|
120
134
|
/**
|
|
121
135
|
* LpVaultWithdraw: 10 accounts (tag 39, PERC-627 / GH#1926 / PERC-8287)
|
|
122
136
|
*
|
|
@@ -192,11 +206,6 @@ export declare const ACCOUNTS_AUDIT_CRANK: readonly AccountSpec[];
|
|
|
192
206
|
* Permissionless — no signer required beyond fee payer.
|
|
193
207
|
*/
|
|
194
208
|
export declare const ACCOUNTS_ADVANCE_ORACLE_PHASE: readonly AccountSpec[];
|
|
195
|
-
/**
|
|
196
|
-
* TopUpKeeperFund: 3 accounts
|
|
197
|
-
* Permissionless — anyone can fund. Transfers lamports directly (no system program).
|
|
198
|
-
*/
|
|
199
|
-
export declare const ACCOUNTS_TOPUP_KEEPER_FUND: readonly AccountSpec[];
|
|
200
209
|
/**
|
|
201
210
|
* SetOiImbalanceHardBlock: 2 accounts
|
|
202
211
|
* Sets the OI imbalance hard-block threshold (admin only)
|
|
@@ -234,6 +243,12 @@ export declare const ACCOUNTS_CLEAR_PENDING_SETTLEMENT: readonly AccountSpec[];
|
|
|
234
243
|
* Sets the per-wallet position cap (admin only). capE6=0 disables.
|
|
235
244
|
*/
|
|
236
245
|
export declare const ACCOUNTS_SET_WALLET_CAP: readonly AccountSpec[];
|
|
246
|
+
/**
|
|
247
|
+
* SetDexPool: 3 accounts
|
|
248
|
+
* Admin pins the approved DEX pool address for a HYPERP market.
|
|
249
|
+
* After this call, UpdateHyperpMark rejects any pool that does not match.
|
|
250
|
+
*/
|
|
251
|
+
export declare const ACCOUNTS_SET_DEX_POOL: readonly AccountSpec[];
|
|
237
252
|
/**
|
|
238
253
|
* InitMatcherCtx: 5 accounts
|
|
239
254
|
* 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 {};
|
package/dist/abi/index.d.ts
CHANGED