@percolatorct/sdk 1.0.0-beta.34 → 1.0.0-beta.36
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/index.js +104 -9
- package/dist/index.js.map +1 -1
- package/dist/solana/slab.d.ts +0 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2118,9 +2118,13 @@ var V12_17_ENGINE_MARKET_MODE_OFF = 232;
|
|
|
2118
2118
|
var V12_17_ENGINE_RESOLVED_K_LONG_OFF = 304;
|
|
2119
2119
|
var V12_17_ENGINE_RESOLVED_K_SHORT_OFF = 320;
|
|
2120
2120
|
var V12_17_ENGINE_RESOLVED_LIVE_PRICE_OFF = 336;
|
|
2121
|
+
var V12_17_ENGINE_LAST_CRANK_SLOT_OFF = 344;
|
|
2121
2122
|
var V12_17_ENGINE_C_TOT_OFF = 352;
|
|
2122
2123
|
var V12_17_ENGINE_PNL_POS_TOT_OFF = 368;
|
|
2123
2124
|
var V12_17_ENGINE_PNL_MATURED_POS_TOT_OFF = 384;
|
|
2125
|
+
var V12_17_ENGINE_GC_CURSOR_OFF = 400;
|
|
2126
|
+
var V12_17_ENGINE_OI_EFF_LONG_OFF = 528;
|
|
2127
|
+
var V12_17_ENGINE_OI_EFF_SHORT_OFF = 544;
|
|
2124
2128
|
var V12_17_ENGINE_NEG_PNL_COUNT_OFF = 648;
|
|
2125
2129
|
var V12_17_ENGINE_LAST_ORACLE_PRICE_OFF = 656;
|
|
2126
2130
|
var V12_17_ENGINE_FUND_PX_LAST_OFF = 664;
|
|
@@ -2128,9 +2132,13 @@ var V12_17_ENGINE_F_LONG_NUM_OFF = 688;
|
|
|
2128
2132
|
var V12_17_ENGINE_F_SHORT_NUM_OFF = 704;
|
|
2129
2133
|
var V12_17_SBF_ENGINE_CURRENT_SLOT_OFF = 216;
|
|
2130
2134
|
var V12_17_SBF_ENGINE_MARKET_MODE_OFF = 224;
|
|
2135
|
+
var V12_17_SBF_ENGINE_LAST_CRANK_SLOT_OFF = 328;
|
|
2131
2136
|
var V12_17_SBF_ENGINE_C_TOT_OFF = 336;
|
|
2132
2137
|
var V12_17_SBF_ENGINE_PNL_POS_TOT_OFF = 352;
|
|
2133
2138
|
var V12_17_SBF_ENGINE_PNL_MATURED_POS_TOT_OFF = 368;
|
|
2139
|
+
var V12_17_SBF_ENGINE_GC_CURSOR_OFF = 384;
|
|
2140
|
+
var V12_17_SBF_ENGINE_OI_EFF_LONG_OFF = 504;
|
|
2141
|
+
var V12_17_SBF_ENGINE_OI_EFF_SHORT_OFF = 520;
|
|
2134
2142
|
var V12_17_SBF_ENGINE_NEG_PNL_COUNT_OFF = 616;
|
|
2135
2143
|
var V12_17_SBF_ENGINE_LAST_ORACLE_PRICE_OFF = 624;
|
|
2136
2144
|
var V12_17_SBF_ENGINE_FUND_PX_LAST_OFF = 632;
|
|
@@ -3069,15 +3077,18 @@ function buildLayoutV12_17(maxAccounts, dataLen) {
|
|
|
3069
3077
|
engineFundingRateBpsOff: -1,
|
|
3070
3078
|
// no stored funding rate in v12.17
|
|
3071
3079
|
engineMarkPriceOff: -1,
|
|
3072
|
-
|
|
3080
|
+
// v12.17 computes mark from state; no stored field
|
|
3081
|
+
engineLastCrankSlotOff: isSbf ? V12_17_SBF_ENGINE_LAST_CRANK_SLOT_OFF : V12_17_ENGINE_LAST_CRANK_SLOT_OFF,
|
|
3073
3082
|
engineMaxCrankStalenessOff: -1,
|
|
3074
3083
|
engineTotalOiOff: -1,
|
|
3075
|
-
|
|
3076
|
-
|
|
3084
|
+
// parseEngine sums long + short when total offset is -1
|
|
3085
|
+
engineLongOiOff: isSbf ? V12_17_SBF_ENGINE_OI_EFF_LONG_OFF : V12_17_ENGINE_OI_EFF_LONG_OFF,
|
|
3086
|
+
engineShortOiOff: isSbf ? V12_17_SBF_ENGINE_OI_EFF_SHORT_OFF : V12_17_ENGINE_OI_EFF_SHORT_OFF,
|
|
3077
3087
|
engineCTotOff: isSbf ? V12_17_SBF_ENGINE_C_TOT_OFF : V12_17_ENGINE_C_TOT_OFF,
|
|
3078
3088
|
enginePnlPosTotOff: isSbf ? V12_17_SBF_ENGINE_PNL_POS_TOT_OFF : V12_17_ENGINE_PNL_POS_TOT_OFF,
|
|
3079
3089
|
engineLiqCursorOff: -1,
|
|
3080
|
-
|
|
3090
|
+
// removed in v12.17
|
|
3091
|
+
engineGcCursorOff: isSbf ? V12_17_SBF_ENGINE_GC_CURSOR_OFF : V12_17_ENGINE_GC_CURSOR_OFF,
|
|
3081
3092
|
engineLastSweepStartOff: -1,
|
|
3082
3093
|
engineLastSweepCompleteOff: -1,
|
|
3083
3094
|
engineCrankCursorOff: -1,
|
|
@@ -3249,10 +3260,88 @@ function parseHeader(data) {
|
|
|
3249
3260
|
lastThrUpdateSlot
|
|
3250
3261
|
};
|
|
3251
3262
|
}
|
|
3263
|
+
function parseConfigV12_17(data, configOff) {
|
|
3264
|
+
const MIN_V12_17_BYTES = 512;
|
|
3265
|
+
if (data.length < configOff + MIN_V12_17_BYTES) {
|
|
3266
|
+
throw new Error(`Slab data too short for V12_17 config: ${data.length} < ${configOff + MIN_V12_17_BYTES}`);
|
|
3267
|
+
}
|
|
3268
|
+
const b = configOff;
|
|
3269
|
+
const collateralMint = new PublicKey5(data.subarray(b + 0, b + 32));
|
|
3270
|
+
const vaultPubkey = new PublicKey5(data.subarray(b + 32, b + 64));
|
|
3271
|
+
const indexFeedId = new PublicKey5(data.subarray(b + 64, b + 96));
|
|
3272
|
+
const maxStalenessSlots = readU64LE(data, b + 96);
|
|
3273
|
+
const confFilterBps = readU16LE(data, b + 104);
|
|
3274
|
+
const vaultAuthorityBump = readU8(data, b + 106);
|
|
3275
|
+
const invert = readU8(data, b + 107);
|
|
3276
|
+
const unitScale = readU32LE(data, b + 108);
|
|
3277
|
+
const fundingHorizonSlots = readU64LE(data, b + 112);
|
|
3278
|
+
const fundingKBps = readU64LE(data, b + 120);
|
|
3279
|
+
const fundingMaxPremiumBps = readI64LE(data, b + 128);
|
|
3280
|
+
const fundingMaxBpsPerSlot = readI64LE(data, b + 136);
|
|
3281
|
+
const oracleAuthority = new PublicKey5(data.subarray(b + 144, b + 176));
|
|
3282
|
+
const authorityPriceE6 = readU64LE(data, b + 176);
|
|
3283
|
+
const authorityTimestamp = readI64LE(data, b + 184);
|
|
3284
|
+
const oraclePriceCapE2bps = readU64LE(data, b + 192);
|
|
3285
|
+
const lastEffectivePriceE6 = readU64LE(data, b + 200);
|
|
3286
|
+
const dexPoolBytes = data.subarray(b + 400, b + 432);
|
|
3287
|
+
const dexPool = dexPoolBytes.some((x) => x !== 0) ? new PublicKey5(dexPoolBytes) : null;
|
|
3288
|
+
return {
|
|
3289
|
+
collateralMint,
|
|
3290
|
+
vaultPubkey,
|
|
3291
|
+
indexFeedId,
|
|
3292
|
+
maxStalenessSlots,
|
|
3293
|
+
confFilterBps,
|
|
3294
|
+
vaultAuthorityBump,
|
|
3295
|
+
invert,
|
|
3296
|
+
unitScale,
|
|
3297
|
+
fundingHorizonSlots,
|
|
3298
|
+
fundingKBps,
|
|
3299
|
+
fundingInvScaleNotionalE6: 0n,
|
|
3300
|
+
// removed in v12.17
|
|
3301
|
+
fundingMaxPremiumBps,
|
|
3302
|
+
fundingMaxBpsPerSlot,
|
|
3303
|
+
fundingPremiumWeightBps: 0n,
|
|
3304
|
+
fundingSettlementIntervalSlots: 0n,
|
|
3305
|
+
fundingPremiumDampeningE6: 0n,
|
|
3306
|
+
fundingPremiumMaxBpsPerSlot: 0n,
|
|
3307
|
+
threshFloor: 0n,
|
|
3308
|
+
// removed in v12.17
|
|
3309
|
+
threshRiskBps: 0n,
|
|
3310
|
+
threshUpdateIntervalSlots: 0n,
|
|
3311
|
+
threshStepBps: 0n,
|
|
3312
|
+
threshAlphaBps: 0n,
|
|
3313
|
+
threshMin: 0n,
|
|
3314
|
+
threshMax: 0n,
|
|
3315
|
+
threshMinStep: 0n,
|
|
3316
|
+
oracleAuthority,
|
|
3317
|
+
authorityPriceE6,
|
|
3318
|
+
authorityTimestamp,
|
|
3319
|
+
oraclePriceCapE2bps,
|
|
3320
|
+
lastEffectivePriceE6,
|
|
3321
|
+
oiCapMultiplierBps: readU64LE(data, b + 448),
|
|
3322
|
+
maxPnlCap: readU64LE(data, b + 432),
|
|
3323
|
+
adaptiveFundingEnabled: false,
|
|
3324
|
+
// removed in v12.17
|
|
3325
|
+
adaptiveScaleBps: 0,
|
|
3326
|
+
adaptiveMaxFundingBps: 0n,
|
|
3327
|
+
marketCreatedSlot: 0n,
|
|
3328
|
+
oiRampSlots: 0n,
|
|
3329
|
+
resolvedSlot: 0n,
|
|
3330
|
+
insuranceIsolationBps: 0,
|
|
3331
|
+
oraclePhase: 0,
|
|
3332
|
+
cumulativeVolumeE6: 0n,
|
|
3333
|
+
phase2DeltaSlots: 0,
|
|
3334
|
+
dexPool
|
|
3335
|
+
};
|
|
3336
|
+
}
|
|
3252
3337
|
function parseConfig(data, layoutHint) {
|
|
3253
3338
|
const layout = layoutHint !== void 0 ? layoutHint : detectSlabLayout(data.length, data);
|
|
3254
3339
|
const configOff = layout ? layout.configOffset : V0_HEADER_LEN;
|
|
3255
3340
|
const configLen = layout ? layout.configLen : V0_CONFIG_LEN;
|
|
3341
|
+
const isV12_17 = layout && (layout.accountSize === V12_17_ACCOUNT_SIZE || layout.accountSize === V12_17_ACCOUNT_SIZE_SBF);
|
|
3342
|
+
if (isV12_17) {
|
|
3343
|
+
return parseConfigV12_17(data, configOff);
|
|
3344
|
+
}
|
|
3256
3345
|
const MIN_CONFIG_BYTES = 376;
|
|
3257
3346
|
const minLen = configOff + Math.min(configLen, MIN_CONFIG_BYTES);
|
|
3258
3347
|
if (data.length < minLen) {
|
|
@@ -3499,6 +3588,12 @@ function parseEngine(data) {
|
|
|
3499
3588
|
const resolvedKLongOff = isSbf ? 288 : V12_17_ENGINE_RESOLVED_K_LONG_OFF;
|
|
3500
3589
|
const resolvedKShortOff = isSbf ? 304 : V12_17_ENGINE_RESOLVED_K_SHORT_OFF;
|
|
3501
3590
|
const resolvedLivePriceOff = isSbf ? 320 : V12_17_ENGINE_RESOLVED_LIVE_PRICE_OFF;
|
|
3591
|
+
const lastCrankSlotOff = isSbf ? V12_17_SBF_ENGINE_LAST_CRANK_SLOT_OFF : V12_17_ENGINE_LAST_CRANK_SLOT_OFF;
|
|
3592
|
+
const gcCursorOff = isSbf ? V12_17_SBF_ENGINE_GC_CURSOR_OFF : V12_17_ENGINE_GC_CURSOR_OFF;
|
|
3593
|
+
const oiEffLongOff = isSbf ? V12_17_SBF_ENGINE_OI_EFF_LONG_OFF : V12_17_ENGINE_OI_EFF_LONG_OFF;
|
|
3594
|
+
const oiEffShortOff = isSbf ? V12_17_SBF_ENGINE_OI_EFF_SHORT_OFF : V12_17_ENGINE_OI_EFF_SHORT_OFF;
|
|
3595
|
+
const longOi = readU128LE(data, base + oiEffLongOff);
|
|
3596
|
+
const shortOi = readU128LE(data, base + oiEffShortOff);
|
|
3502
3597
|
const bitmapEnd = layout.engineBitmapOff + layout.bitmapWords * 8;
|
|
3503
3598
|
return {
|
|
3504
3599
|
vault: readU128LE(data, base),
|
|
@@ -3517,16 +3612,16 @@ function parseEngine(data) {
|
|
|
3517
3612
|
fundingRateE9: 0n,
|
|
3518
3613
|
// no stored funding rate in v12.17
|
|
3519
3614
|
marketMode: readU8(data, base + marketModeOff) === 1 ? 1 : 0,
|
|
3520
|
-
lastCrankSlot:
|
|
3615
|
+
lastCrankSlot: readU64LE(data, base + lastCrankSlotOff),
|
|
3521
3616
|
maxCrankStalenessSlots: 0n,
|
|
3522
|
-
totalOpenInterest:
|
|
3523
|
-
longOi
|
|
3524
|
-
shortOi
|
|
3617
|
+
totalOpenInterest: longOi + shortOi,
|
|
3618
|
+
longOi,
|
|
3619
|
+
shortOi,
|
|
3525
3620
|
cTot: readU128LE(data, base + cTotOff),
|
|
3526
3621
|
pnlPosTot: readU128LE(data, base + pnlPosTotOff),
|
|
3527
3622
|
pnlMaturedPosTot: readU128LE(data, base + pnlMaturedOff),
|
|
3528
3623
|
liqCursor: 0,
|
|
3529
|
-
gcCursor:
|
|
3624
|
+
gcCursor: readU16LE(data, base + gcCursorOff),
|
|
3530
3625
|
lastSweepStartSlot: 0n,
|
|
3531
3626
|
lastSweepCompleteSlot: 0n,
|
|
3532
3627
|
crankCursor: 0,
|