@percolatorct/sdk 2.0.0 → 2.0.1

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.0`. v12.19 single-target. 792 tests passing. Do NOT use with real funds.
5
+ > **EXPERIMENTAL. NOT AUDITED.** `2.0.1`. 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
@@ -2310,6 +2310,21 @@ for (const n of V12_17_TIERS) {
2310
2310
  }
2311
2311
  var V12_19_CONFIG_LEN = 528;
2312
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;
2313
2328
  var V12_19_SIZES = /* @__PURE__ */ new Map([
2314
2329
  [19640, 64],
2315
2330
  // --features micro
@@ -2326,7 +2341,20 @@ function buildLayoutV12_19(maxAccounts, dataLen) {
2326
2341
  ...base,
2327
2342
  configLen: V12_19_CONFIG_LEN,
2328
2343
  engineOff: V12_19_ENGINE_OFF_SBF,
2329
- accountsOff: V12_19_ENGINE_OFF_SBF + (base.accountsOff - base.engineOff)
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.
2349
+ engineCurrentSlotOff: V12_19_SBF_ENGINE_CURRENT_SLOT_OFF,
2350
+ engineCTotOff: V12_19_SBF_ENGINE_C_TOT_OFF,
2351
+ enginePnlPosTotOff: V12_19_SBF_ENGINE_PNL_POS_TOT_OFF,
2352
+ engineLongOiOff: V12_19_SBF_ENGINE_OI_EFF_LONG_OFF,
2353
+ engineShortOiOff: V12_19_SBF_ENGINE_OI_EFF_SHORT_OFF,
2354
+ // V12_19 last_market_slot replaces V12_17 last_crank_slot semantics.
2355
+ engineLastCrankSlotOff: V12_19_SBF_ENGINE_LAST_MARKET_SLOT_OFF,
2356
+ // V12_19 rr_cursor_position replaces V12_17 gc_cursor semantics.
2357
+ engineGcCursorOff: V12_19_SBF_ENGINE_RR_CURSOR_OFF
2330
2358
  };
2331
2359
  }
2332
2360
  var V12_1_SBF_ACCOUNT_SIZE = 280;
@@ -3675,24 +3703,25 @@ function parseEngine(data) {
3675
3703
  const isV12_17 = layout.accountSize === V12_17_ACCOUNT_SIZE || layout.accountSize === V12_17_ACCOUNT_SIZE_SBF;
3676
3704
  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);
3677
3705
  if (isV12_17) {
3678
- const isSbf = layout.engineOff === V12_17_ENGINE_OFF_SBF || layout.engineOff === V12_19_ENGINE_OFF_SBF;
3679
- const currentSlotOff = isSbf ? V12_17_SBF_ENGINE_CURRENT_SLOT_OFF : V12_17_ENGINE_CURRENT_SLOT_OFF;
3680
- const marketModeOff = isSbf ? V12_17_SBF_ENGINE_MARKET_MODE_OFF : V12_17_ENGINE_MARKET_MODE_OFF;
3681
- const cTotOff = isSbf ? V12_17_SBF_ENGINE_C_TOT_OFF : V12_17_ENGINE_C_TOT_OFF;
3682
- const pnlPosTotOff = isSbf ? V12_17_SBF_ENGINE_PNL_POS_TOT_OFF : V12_17_ENGINE_PNL_POS_TOT_OFF;
3683
- const pnlMaturedOff = isSbf ? V12_17_SBF_ENGINE_PNL_MATURED_POS_TOT_OFF : V12_17_ENGINE_PNL_MATURED_POS_TOT_OFF;
3684
- const negPnlOff = isSbf ? V12_17_SBF_ENGINE_NEG_PNL_COUNT_OFF : V12_17_ENGINE_NEG_PNL_COUNT_OFF;
3685
- const oraclePriceOff = isSbf ? V12_17_SBF_ENGINE_LAST_ORACLE_PRICE_OFF : V12_17_ENGINE_LAST_ORACLE_PRICE_OFF;
3686
- const fundPxLastOff = isSbf ? V12_17_SBF_ENGINE_FUND_PX_LAST_OFF : V12_17_ENGINE_FUND_PX_LAST_OFF;
3687
- const fLongNumOff = isSbf ? V12_17_SBF_ENGINE_F_LONG_NUM_OFF : V12_17_ENGINE_F_LONG_NUM_OFF;
3688
- const fShortNumOff = isSbf ? V12_17_SBF_ENGINE_F_SHORT_NUM_OFF : V12_17_ENGINE_F_SHORT_NUM_OFF;
3689
- const resolvedKLongOff = isSbf ? 288 : V12_17_ENGINE_RESOLVED_K_LONG_OFF;
3690
- const resolvedKShortOff = isSbf ? 304 : V12_17_ENGINE_RESOLVED_K_SHORT_OFF;
3691
- const resolvedLivePriceOff = isSbf ? 320 : V12_17_ENGINE_RESOLVED_LIVE_PRICE_OFF;
3692
- const lastCrankSlotOff = isSbf ? V12_17_SBF_ENGINE_LAST_CRANK_SLOT_OFF : V12_17_ENGINE_LAST_CRANK_SLOT_OFF;
3693
- const gcCursorOff = isSbf ? V12_17_SBF_ENGINE_GC_CURSOR_OFF : V12_17_ENGINE_GC_CURSOR_OFF;
3694
- const oiEffLongOff = isSbf ? V12_17_SBF_ENGINE_OI_EFF_LONG_OFF : V12_17_ENGINE_OI_EFF_LONG_OFF;
3695
- const oiEffShortOff = isSbf ? V12_17_SBF_ENGINE_OI_EFF_SHORT_OFF : V12_17_ENGINE_OI_EFF_SHORT_OFF;
3706
+ const isV12_19 = layout.engineOff === V12_19_ENGINE_OFF_SBF;
3707
+ const isSbf = layout.engineOff === V12_17_ENGINE_OFF_SBF || isV12_19;
3708
+ 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
+ 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;
3710
+ const cTotOff = isV12_19 ? V12_19_SBF_ENGINE_C_TOT_OFF : isSbf ? V12_17_SBF_ENGINE_C_TOT_OFF : V12_17_ENGINE_C_TOT_OFF;
3711
+ const pnlPosTotOff = isV12_19 ? V12_19_SBF_ENGINE_PNL_POS_TOT_OFF : isSbf ? V12_17_SBF_ENGINE_PNL_POS_TOT_OFF : V12_17_ENGINE_PNL_POS_TOT_OFF;
3712
+ const pnlMaturedOff = isV12_19 ? V12_19_SBF_ENGINE_PNL_MATURED_POS_TOT_OFF : isSbf ? V12_17_SBF_ENGINE_PNL_MATURED_POS_TOT_OFF : V12_17_ENGINE_PNL_MATURED_POS_TOT_OFF;
3713
+ const negPnlOff = isV12_19 ? V12_19_SBF_ENGINE_NEG_PNL_COUNT_OFF : isSbf ? V12_17_SBF_ENGINE_NEG_PNL_COUNT_OFF : V12_17_ENGINE_NEG_PNL_COUNT_OFF;
3714
+ const oraclePriceOff = isV12_19 ? V12_19_SBF_ENGINE_LAST_ORACLE_PRICE_OFF : isSbf ? V12_17_SBF_ENGINE_LAST_ORACLE_PRICE_OFF : V12_17_ENGINE_LAST_ORACLE_PRICE_OFF;
3715
+ const fundPxLastOff = isV12_19 ? V12_19_SBF_ENGINE_FUND_PX_LAST_OFF : isSbf ? V12_17_SBF_ENGINE_FUND_PX_LAST_OFF : V12_17_ENGINE_FUND_PX_LAST_OFF;
3716
+ const fLongNumOff = isV12_19 ? V12_19_SBF_ENGINE_F_LONG_NUM_OFF : isSbf ? V12_17_SBF_ENGINE_F_LONG_NUM_OFF : V12_17_ENGINE_F_LONG_NUM_OFF;
3717
+ const fShortNumOff = isV12_19 ? V12_19_SBF_ENGINE_F_SHORT_NUM_OFF : isSbf ? V12_17_SBF_ENGINE_F_SHORT_NUM_OFF : V12_17_ENGINE_F_SHORT_NUM_OFF;
3718
+ const resolvedKLongOff = isV12_19 ? 288 : isSbf ? 288 : V12_17_ENGINE_RESOLVED_K_LONG_OFF;
3719
+ const resolvedKShortOff = isV12_19 ? 304 : isSbf ? 304 : V12_17_ENGINE_RESOLVED_K_SHORT_OFF;
3720
+ const resolvedLivePriceOff = isV12_19 ? V12_19_SBF_ENGINE_RESOLVED_LIVE_PRICE_OFF : isSbf ? 320 : V12_17_ENGINE_RESOLVED_LIVE_PRICE_OFF;
3721
+ const lastCrankSlotOff = isV12_19 ? V12_19_SBF_ENGINE_LAST_MARKET_SLOT_OFF : isSbf ? V12_17_SBF_ENGINE_LAST_CRANK_SLOT_OFF : V12_17_ENGINE_LAST_CRANK_SLOT_OFF;
3722
+ const gcCursorOff = isV12_19 ? V12_19_SBF_ENGINE_RR_CURSOR_OFF : isSbf ? V12_17_SBF_ENGINE_GC_CURSOR_OFF : V12_17_ENGINE_GC_CURSOR_OFF;
3723
+ const oiEffLongOff = isV12_19 ? V12_19_SBF_ENGINE_OI_EFF_LONG_OFF : isSbf ? V12_17_SBF_ENGINE_OI_EFF_LONG_OFF : V12_17_ENGINE_OI_EFF_LONG_OFF;
3724
+ const oiEffShortOff = isV12_19 ? V12_19_SBF_ENGINE_OI_EFF_SHORT_OFF : isSbf ? V12_17_SBF_ENGINE_OI_EFF_SHORT_OFF : V12_17_ENGINE_OI_EFF_SHORT_OFF;
3696
3725
  const longOi = readU128LE(data, base + oiEffLongOff);
3697
3726
  const shortOi = readU128LE(data, base + oiEffShortOff);
3698
3727
  const bitmapEnd = layout.engineBitmapOff + layout.bitmapWords * 8;