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

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.
@@ -4,21 +4,11 @@ import { PublicKey } from "@solana/web3.js";
4
4
  * Seeds: ["vault", slab_key]
5
5
  */
6
6
  export declare function deriveVaultAuthority(programId: PublicKey, slab: PublicKey): [PublicKey, number];
7
- /**
8
- * Derive insurance LP mint PDA.
9
- * Seeds: ["ins_lp", slab_key]
10
- */
11
- export declare function deriveInsuranceLpMint(programId: PublicKey, slab: PublicKey): [PublicKey, number];
12
7
  /**
13
8
  * Derive LP PDA for TradeCpi.
14
9
  * Seeds: ["lp", slab_key, lp_idx as u16 LE]
15
10
  */
16
11
  export declare function deriveLpPda(programId: PublicKey, slab: PublicKey, lpIdx: number): [PublicKey, number];
17
- /**
18
- * Derive keeper fund PDA.
19
- * Seeds: ["keeper_fund", slab_key]
20
- */
21
- export declare function deriveKeeperFund(programId: PublicKey, slab: PublicKey): [PublicKey, number];
22
12
  /** PumpSwap AMM program ID. */
23
13
  export declare const PUMPSWAP_PROGRAM_ID: PublicKey;
24
14
  /** Raydium CLMM (Concentrated Liquidity) program ID. */
@@ -130,10 +130,22 @@ export declare const SLAB_TIERS_V12_1: Record<string, {
130
130
  label: string;
131
131
  description: string;
132
132
  }>;
133
+ /**
134
+ * V12_15 slab tier sizes — percolator v12.15 (engine+prog sync).
135
+ * ENGINE_OFF=624, BITMAP_OFF=862 (relative), ACCOUNT_SIZE=4400, postBitmap=18.
136
+ * MAX_ACCOUNTS default changed from 4096 to 2048. Verified SLAB_LEN=1,128,448 for small (256).
137
+ * Account layout completely redesigned with reserve cohort arrays.
138
+ */
139
+ export declare const SLAB_TIERS_V12_15: Record<string, {
140
+ maxAccounts: number;
141
+ dataSize: number;
142
+ label: string;
143
+ description: string;
144
+ }>;
133
145
  /**
134
146
  * Detect the slab layout version from the raw account data length.
135
147
  * Returns the full SlabLayout descriptor, or null if the size is unrecognised.
136
- * Checks V12_1, V_SETDEXPOOL, V1M2, V_ADL, V1M, V0, V1D, V1D-legacy, V1, and V1-legacy sizes.
148
+ * Checks V12_15, V12_1, V_SETDEXPOOL, V1M2, V_ADL, V1M, V0, V1D, V1D-legacy, V1, and V1-legacy sizes.
137
149
  *
138
150
  * When `data` is provided and the size matches V1D, the version field at offset 8 is read
139
151
  * to disambiguate V2 slabs (which produce identical sizes to V1D with postBitmap=2).
@@ -181,10 +193,10 @@ export interface MarketConfig {
181
193
  fundingInvScaleNotionalE6: bigint;
182
194
  fundingMaxPremiumBps: bigint;
183
195
  fundingMaxBpsPerSlot: bigint;
184
- fundingPremiumWeightBps: bigint;
185
- fundingSettlementIntervalSlots: bigint;
186
- fundingPremiumDampeningE6: bigint;
187
- fundingPremiumMaxBpsPerSlot: bigint;
196
+ /** @deprecated Removed in V12_1 — always 0 */ fundingPremiumWeightBps: bigint;
197
+ /** @deprecated Removed in V12_1 — always 0 */ fundingSettlementIntervalSlots: bigint;
198
+ /** @deprecated Removed in V12_1 — always 0 */ fundingPremiumDampeningE6: bigint;
199
+ /** @deprecated Removed in V12_1 — always 0 */ fundingPremiumMaxBpsPerSlot: bigint;
188
200
  threshFloor: bigint;
189
201
  threshRiskBps: bigint;
190
202
  threshUpdateIntervalSlots: bigint;
@@ -229,6 +241,10 @@ export interface InsuranceFund {
229
241
  isolationBps: number;
230
242
  }
231
243
  export interface RiskParams {
244
+ /**
245
+ * @deprecated Split into hMin/hMax in v12.15 RiskParams. On V12_15 slabs this field returns
246
+ * hMin for backwards compatibility. On pre-v12.15 slabs hMin/hMax both mirror this value.
247
+ */
232
248
  warmupPeriodSlots: bigint;
233
249
  maintenanceMarginBps: bigint;
234
250
  initialMarginBps: bigint;
@@ -242,6 +258,10 @@ export interface RiskParams {
242
258
  liquidationFeeCap: bigint;
243
259
  liquidationBufferBps: bigint;
244
260
  minLiquidationAbs: bigint;
261
+ /** Minimum horizon slots (v12.15+). Replaces warmupPeriodSlots. 0n on pre-v12.15 slabs. */
262
+ hMin: bigint;
263
+ /** Maximum horizon slots (v12.15+). 0n on pre-v12.15 slabs. */
264
+ hMax: bigint;
245
265
  }
246
266
  export interface EngineState {
247
267
  vault: bigint;
@@ -249,7 +269,22 @@ export interface EngineState {
249
269
  currentSlot: bigint;
250
270
  fundingIndexQpbE6: bigint;
251
271
  lastFundingSlot: bigint;
272
+ /**
273
+ * Funding rate per slot. On pre-v12.15 slabs: i64 in BPS units.
274
+ * On v12.15+ slabs: i128 in e9 units (field renamed `funding_rate_e9` on-chain).
275
+ * Use `fundingRateE9` for v12.15-aware code.
276
+ */
252
277
  fundingRateBpsPerSlotLast: bigint;
278
+ /**
279
+ * Funding rate in e9 units (i128). v12.15+ only.
280
+ * 0n on pre-v12.15 slabs (use `fundingRateBpsPerSlotLast` instead).
281
+ */
282
+ fundingRateE9: bigint;
283
+ /**
284
+ * Market mode. v12.15+ only.
285
+ * 0 = Live, 1 = Resolved. null on pre-v12.15 slabs.
286
+ */
287
+ marketMode: 0 | 1 | null;
253
288
  lastCrankSlot: bigint;
254
289
  maxCrankStalenessSlots: bigint;
255
290
  totalOpenInterest: bigint;
@@ -257,6 +292,11 @@ export interface EngineState {
257
292
  shortOi: bigint;
258
293
  cTot: bigint;
259
294
  pnlPosTot: bigint;
295
+ /**
296
+ * Matured (settled) positive PnL total (u128). v12.15+ only.
297
+ * 0n on pre-v12.15 slabs.
298
+ */
299
+ pnlMaturedPosTot: bigint;
260
300
  liqCursor: number;
261
301
  gcCursor: number;
262
302
  lastSweepStartSlot: bigint;
@@ -280,22 +320,45 @@ export declare enum AccountKind {
280
320
  User = 0,
281
321
  LP = 1
282
322
  }
323
+ /** Parsed reserve cohort (64 bytes on-chain). Raw bytes; structure is program-internal. */
324
+ export type ReserveCohortBytes = Uint8Array;
283
325
  export interface Account {
284
326
  kind: AccountKind;
285
327
  accountId: bigint;
286
328
  capital: bigint;
287
329
  pnl: bigint;
288
330
  reservedPnl: bigint;
331
+ /** @deprecated Removed in v12.15. Always 0n on V12_15 slabs. */
289
332
  warmupStartedAtSlot: bigint;
333
+ /** @deprecated Removed in v12.15. Always 0n on V12_15 slabs. */
290
334
  warmupSlopePerStep: bigint;
291
335
  positionSize: bigint;
336
+ /** Entry price in e6 units. Present in V12_15 (offset 120) and V_ADL/V12_1_EP. -1 signals absent. */
292
337
  entryPrice: bigint;
293
338
  fundingIndex: bigint;
294
339
  matcherProgram: PublicKey;
295
340
  matcherContext: PublicKey;
296
341
  owner: PublicKey;
297
342
  feeCredits: bigint;
343
+ /** @deprecated Removed in v12.15. Always 0n on V12_15 slabs. */
298
344
  lastFeeSlot: bigint;
345
+ /** Total fees earned over account lifetime (u128). Present from v12.15. 0n on older layouts. */
346
+ feesEarnedTotal: bigint;
347
+ /**
348
+ * Reserve cohorts array (v12.15+). Up to 62 cohorts of 64 bytes each.
349
+ * `null` on pre-v12.15 slabs. Parse the raw bytes according to the on-chain ReserveCohort struct.
350
+ */
351
+ exactReserveCohorts: ReserveCohortBytes[] | null;
352
+ /** Number of active reserve cohorts (0–62). null on pre-v12.15 slabs. */
353
+ exactCohortCount: number | null;
354
+ /** Overflow (oldest) cohort raw bytes. null on pre-v12.15 slabs or when not present. */
355
+ overflowOlder: ReserveCohortBytes | null;
356
+ /** True if overflowOlder contains valid data. null on pre-v12.15 slabs. */
357
+ overflowOlderPresent: boolean | null;
358
+ /** Overflow (newest) cohort raw bytes. null on pre-v12.15 slabs or when not present. */
359
+ overflowNewest: ReserveCohortBytes | null;
360
+ /** True if overflowNewest contains valid data. null on pre-v12.15 slabs. */
361
+ overflowNewestPresent: boolean | null;
299
362
  }
300
363
  export declare function fetchSlab(connection: Connection, slabPubkey: PublicKey): Promise<Uint8Array>;
301
364
  export declare const RAMP_START_BPS = 1000n;
@@ -7,10 +7,10 @@
7
7
  * Deployed mainnet: (pending deployment — DevOps must set STAKE_PROGRAM_ID env var or deploy and update STAKE_PROGRAM_IDS.mainnet)
8
8
  */
9
9
  import { PublicKey } from '@solana/web3.js';
10
- /** Known stake program addresses per network. Mainnet is empty until deployed. */
10
+ /** Known stake program addresses per network. */
11
11
  export declare const STAKE_PROGRAM_IDS: {
12
12
  readonly devnet: "6aJb1F9CDCVWCNYFwj8aQsVb696YnW6J1FznteHq4Q6k";
13
- readonly mainnet: "";
13
+ readonly mainnet: "DC5fovFQD5SZYsetwvEqd4Wi4PFY1Yfnc669VMe6oa7F";
14
14
  };
15
15
  /**
16
16
  * Resolve the stake program ID for the given network.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percolatorct/sdk",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.20",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "engines": {
@@ -31,6 +31,7 @@
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "^20.17.10",
34
+ "dotenv": "^17.4.1",
34
35
  "tsup": "^8.3.5",
35
36
  "tsx": "^4.21.0",
36
37
  "typescript": "^5.7.2",