@percolatorct/sdk 2.0.1 → 2.0.2

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
- > **EXPERIMENTAL. NOT AUDITED.** `2.0.1`. v12.19 single-target. 792 tests passing. Do NOT use with real funds.
5
+ > **EXPERIMENTAL. NOT AUDITED.** `2.0.2`. v12.19 single-target. 792 tests passing. Do NOT use with real funds.
6
6
 
7
7
  ## Target wrapper
8
8
 
package/dist/index.js CHANGED
@@ -2308,52 +2308,71 @@ for (const n of V12_17_TIERS) {
2308
2308
  const sbfSize = V12_17_ENGINE_OFF_SBF + accountsOffSbf + n * V12_17_ACCOUNT_SIZE_SBF + V12_17_RISK_BUF_LEN + n * V12_17_GEN_TABLE_ENTRY;
2309
2309
  V12_17_SIZES.set(sbfSize, n);
2310
2310
  }
2311
- var V12_19_CONFIG_LEN = 528;
2312
- var V12_19_ENGINE_OFF_SBF = 600;
2313
- var V12_19_SBF_ENGINE_CURRENT_SLOT_OFF = 216;
2314
- var V12_19_SBF_ENGINE_MARKET_MODE_OFF = 224;
2315
- var V12_19_SBF_ENGINE_RESOLVED_LIVE_PRICE_OFF = 320;
2316
- var V12_19_SBF_ENGINE_C_TOT_OFF = 328;
2317
- var V12_19_SBF_ENGINE_PNL_POS_TOT_OFF = 344;
2318
- var V12_19_SBF_ENGINE_PNL_MATURED_POS_TOT_OFF = 360;
2319
- var V12_19_SBF_ENGINE_OI_EFF_LONG_OFF = 488;
2320
- var V12_19_SBF_ENGINE_OI_EFF_SHORT_OFF = 504;
2321
- var V12_19_SBF_ENGINE_NEG_PNL_COUNT_OFF = 608;
2322
- var V12_19_SBF_ENGINE_RR_CURSOR_OFF = 616;
2323
- var V12_19_SBF_ENGINE_LAST_ORACLE_PRICE_OFF = 640;
2324
- var V12_19_SBF_ENGINE_FUND_PX_LAST_OFF = 648;
2325
- var V12_19_SBF_ENGINE_LAST_MARKET_SLOT_OFF = 656;
2326
- var V12_19_SBF_ENGINE_F_LONG_NUM_OFF = 664;
2327
- var V12_19_SBF_ENGINE_F_SHORT_NUM_OFF = 680;
2311
+ var V12_19_HEADER_LEN_SBF = 136;
2312
+ var V12_19_CONFIG_LEN = 480;
2313
+ var V12_19_ENGINE_OFF_SBF = 616;
2314
+ var V12_19_ACCOUNT_SIZE_SBF = 360;
2315
+ var V12_19_SBF_ENGINE_BITMAP_OFF = 712;
2316
+ var V12_19_SBF_ENGINE_CURRENT_SLOT_OFF = 200;
2317
+ var V12_19_SBF_ENGINE_MARKET_MODE_OFF = 208;
2318
+ var V12_19_SBF_ENGINE_RESOLVED_LIVE_PRICE_OFF = 304;
2319
+ var V12_19_SBF_ENGINE_C_TOT_OFF = 312;
2320
+ var V12_19_SBF_ENGINE_PNL_POS_TOT_OFF = 328;
2321
+ var V12_19_SBF_ENGINE_PNL_MATURED_POS_TOT_OFF = 344;
2322
+ var V12_19_SBF_ENGINE_OI_EFF_LONG_OFF = 472;
2323
+ var V12_19_SBF_ENGINE_OI_EFF_SHORT_OFF = 488;
2324
+ var V12_19_SBF_ENGINE_NEG_PNL_COUNT_OFF = 584;
2325
+ var V12_19_SBF_ENGINE_RR_CURSOR_OFF = 592;
2326
+ var V12_19_SBF_ENGINE_LAST_ORACLE_PRICE_OFF = 624;
2327
+ var V12_19_SBF_ENGINE_FUND_PX_LAST_OFF = 632;
2328
+ var V12_19_SBF_ENGINE_LAST_MARKET_SLOT_OFF = 640;
2329
+ var V12_19_SBF_ENGINE_F_LONG_NUM_OFF = 648;
2330
+ var V12_19_SBF_ENGINE_F_SHORT_NUM_OFF = 664;
2328
2331
  var V12_19_SIZES = /* @__PURE__ */ new Map([
2329
- [19640, 64],
2330
- // --features micro
2331
- [94168, 256],
2332
- // --features small (deployed mainnet ESa89R5...)
2333
- [372280, 1024],
2334
- // --features medium
2335
- [1484728, 4096]
2336
- // default features (large)
2332
+ [26848, 64],
2333
+ // --features micro (derived)
2334
+ [96760, 256],
2335
+ // --features small (probe-confirmed; deployed mainnet ESa89R5...)
2336
+ [376408, 1024],
2337
+ // --features medium (derived)
2338
+ [1495e3, 4096]
2339
+ // default features / large (derived)
2337
2340
  ]);
2338
- function buildLayoutV12_19(maxAccounts, dataLen) {
2339
- const base = buildLayoutV12_17(maxAccounts, dataLen);
2341
+ function buildLayoutV12_19(maxAccounts, _dataLen) {
2342
+ const bitmapWords = Math.ceil(maxAccounts / 64);
2343
+ const bitmapBytes = bitmapWords * 8;
2344
+ const numUsedOff = V12_19_SBF_ENGINE_BITMAP_OFF + bitmapBytes;
2345
+ const freeHeadOff = numUsedOff + 2;
2346
+ const nextFreeOff = freeHeadOff + 2;
2347
+ const prevFreeOff = nextFreeOff + maxAccounts * 2;
2348
+ const accountsRelEnd = prevFreeOff + maxAccounts * 2;
2349
+ const accountsOffRel = Math.ceil(accountsRelEnd / 8) * 8;
2350
+ const accountsOff = V12_19_ENGINE_OFF_SBF + accountsOffRel;
2351
+ const base = buildLayoutV12_17(
2352
+ maxAccounts,
2353
+ /* synthetic V12_17 SBF size */
2354
+ 94168
2355
+ );
2340
2356
  return {
2341
2357
  ...base,
2358
+ headerLen: V12_19_HEADER_LEN_SBF,
2342
2359
  configLen: V12_19_CONFIG_LEN,
2360
+ configOffset: V12_19_HEADER_LEN_SBF,
2361
+ // header runs 0..136 in v12.19
2343
2362
  engineOff: V12_19_ENGINE_OFF_SBF,
2344
- accountsOff: V12_19_ENGINE_OFF_SBF + (base.accountsOff - base.engineOff),
2345
- // V12_19 engine field offsets (only the fields exposed in SlabLayout).
2346
- // Other engine fields (negPnlCount, fundPxLast, fLongNum, fShortNum,
2347
- // lastOraclePrice, marketMode, pnlMaturedPosTot) are read by parseEngine
2348
- // via its own version-aware switch keyed on engineOff === 600.
2363
+ accountSize: V12_19_ACCOUNT_SIZE_SBF,
2364
+ accountsOff,
2365
+ bitmapWords,
2366
+ engineBitmapOff: V12_19_SBF_ENGINE_BITMAP_OFF,
2367
+ // V12_19-specific engine field offsets (probe-confirmed):
2349
2368
  engineCurrentSlotOff: V12_19_SBF_ENGINE_CURRENT_SLOT_OFF,
2350
2369
  engineCTotOff: V12_19_SBF_ENGINE_C_TOT_OFF,
2351
2370
  enginePnlPosTotOff: V12_19_SBF_ENGINE_PNL_POS_TOT_OFF,
2352
2371
  engineLongOiOff: V12_19_SBF_ENGINE_OI_EFF_LONG_OFF,
2353
2372
  engineShortOiOff: V12_19_SBF_ENGINE_OI_EFF_SHORT_OFF,
2354
- // V12_19 last_market_slot replaces V12_17 last_crank_slot semantics.
2373
+ // last_market_slot replaces V12_17 last_crank_slot semantics.
2355
2374
  engineLastCrankSlotOff: V12_19_SBF_ENGINE_LAST_MARKET_SLOT_OFF,
2356
- // V12_19 rr_cursor_position replaces V12_17 gc_cursor semantics.
2375
+ // rr_cursor_position replaces V12_17 gc_cursor semantics.
2357
2376
  engineGcCursorOff: V12_19_SBF_ENGINE_RR_CURSOR_OFF
2358
2377
  };
2359
2378
  }
@@ -3702,8 +3721,8 @@ function parseEngine(data) {
3702
3721
  const base = layout.engineOff;
3703
3722
  const isV12_17 = layout.accountSize === V12_17_ACCOUNT_SIZE || layout.accountSize === V12_17_ACCOUNT_SIZE_SBF;
3704
3723
  const isV12_15 = !isV12_17 && (layout.accountSize === V12_15_ACCOUNT_SIZE || layout.accountSize === V12_15_ACCOUNT_SIZE_SMALL) && (layout.engineOff === V12_15_ENGINE_OFF || layout.engineOff === V12_15_ENGINE_OFF_SBF);
3705
- if (isV12_17) {
3706
- const isV12_19 = layout.engineOff === V12_19_ENGINE_OFF_SBF;
3724
+ const isV12_19 = layout.accountSize === V12_19_ACCOUNT_SIZE_SBF;
3725
+ if (isV12_17 || isV12_19) {
3707
3726
  const isSbf = layout.engineOff === V12_17_ENGINE_OFF_SBF || isV12_19;
3708
3727
  const currentSlotOff = isV12_19 ? V12_19_SBF_ENGINE_CURRENT_SLOT_OFF : isSbf ? V12_17_SBF_ENGINE_CURRENT_SLOT_OFF : V12_17_ENGINE_CURRENT_SLOT_OFF;
3709
3728
  const marketModeOff = isV12_19 ? V12_19_SBF_ENGINE_MARKET_MODE_OFF : isSbf ? V12_17_SBF_ENGINE_MARKET_MODE_OFF : V12_17_ENGINE_MARKET_MODE_OFF;