@percolatorct/sdk 1.0.0-beta.35 → 1.0.0-beta.37
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 +85 -1
- package/dist/index.js.map +1 -1
- package/dist/solana/slab.d.ts +1 -8
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -3108,7 +3108,13 @@ function buildLayoutV12_17(maxAccounts, dataLen) {
|
|
|
3108
3108
|
// SBF=192, native=200
|
|
3109
3109
|
hasInsuranceIsolation: false,
|
|
3110
3110
|
engineInsuranceIsolatedOff: -1,
|
|
3111
|
-
engineInsuranceIsolationBpsOff: -1
|
|
3111
|
+
engineInsuranceIsolationBpsOff: -1,
|
|
3112
|
+
// v12.17 dropped the engine.mark_price field (see engineMarkPriceOff above).
|
|
3113
|
+
// The EWMA-smoothed mark that the matcher actually quotes against lives in
|
|
3114
|
+
// MarketConfig.mark_ewma_e6 at offset 304 within the config struct.
|
|
3115
|
+
// Layout is identical on SBF and native. configOffset is V0_HEADER_LEN = 72,
|
|
3116
|
+
// so absolute offset in the slab is 72 + 304 = 376.
|
|
3117
|
+
configMarkEwmaOff: V0_HEADER_LEN + 304
|
|
3112
3118
|
};
|
|
3113
3119
|
}
|
|
3114
3120
|
function detectSlabLayout(dataLen, data) {
|
|
@@ -3260,10 +3266,88 @@ function parseHeader(data) {
|
|
|
3260
3266
|
lastThrUpdateSlot
|
|
3261
3267
|
};
|
|
3262
3268
|
}
|
|
3269
|
+
function parseConfigV12_17(data, configOff) {
|
|
3270
|
+
const MIN_V12_17_BYTES = 512;
|
|
3271
|
+
if (data.length < configOff + MIN_V12_17_BYTES) {
|
|
3272
|
+
throw new Error(`Slab data too short for V12_17 config: ${data.length} < ${configOff + MIN_V12_17_BYTES}`);
|
|
3273
|
+
}
|
|
3274
|
+
const b = configOff;
|
|
3275
|
+
const collateralMint = new PublicKey5(data.subarray(b + 0, b + 32));
|
|
3276
|
+
const vaultPubkey = new PublicKey5(data.subarray(b + 32, b + 64));
|
|
3277
|
+
const indexFeedId = new PublicKey5(data.subarray(b + 64, b + 96));
|
|
3278
|
+
const maxStalenessSlots = readU64LE(data, b + 96);
|
|
3279
|
+
const confFilterBps = readU16LE(data, b + 104);
|
|
3280
|
+
const vaultAuthorityBump = readU8(data, b + 106);
|
|
3281
|
+
const invert = readU8(data, b + 107);
|
|
3282
|
+
const unitScale = readU32LE(data, b + 108);
|
|
3283
|
+
const fundingHorizonSlots = readU64LE(data, b + 112);
|
|
3284
|
+
const fundingKBps = readU64LE(data, b + 120);
|
|
3285
|
+
const fundingMaxPremiumBps = readI64LE(data, b + 128);
|
|
3286
|
+
const fundingMaxBpsPerSlot = readI64LE(data, b + 136);
|
|
3287
|
+
const oracleAuthority = new PublicKey5(data.subarray(b + 144, b + 176));
|
|
3288
|
+
const authorityPriceE6 = readU64LE(data, b + 176);
|
|
3289
|
+
const authorityTimestamp = readI64LE(data, b + 184);
|
|
3290
|
+
const oraclePriceCapE2bps = readU64LE(data, b + 192);
|
|
3291
|
+
const lastEffectivePriceE6 = readU64LE(data, b + 200);
|
|
3292
|
+
const dexPoolBytes = data.subarray(b + 400, b + 432);
|
|
3293
|
+
const dexPool = dexPoolBytes.some((x) => x !== 0) ? new PublicKey5(dexPoolBytes) : null;
|
|
3294
|
+
return {
|
|
3295
|
+
collateralMint,
|
|
3296
|
+
vaultPubkey,
|
|
3297
|
+
indexFeedId,
|
|
3298
|
+
maxStalenessSlots,
|
|
3299
|
+
confFilterBps,
|
|
3300
|
+
vaultAuthorityBump,
|
|
3301
|
+
invert,
|
|
3302
|
+
unitScale,
|
|
3303
|
+
fundingHorizonSlots,
|
|
3304
|
+
fundingKBps,
|
|
3305
|
+
fundingInvScaleNotionalE6: 0n,
|
|
3306
|
+
// removed in v12.17
|
|
3307
|
+
fundingMaxPremiumBps,
|
|
3308
|
+
fundingMaxBpsPerSlot,
|
|
3309
|
+
fundingPremiumWeightBps: 0n,
|
|
3310
|
+
fundingSettlementIntervalSlots: 0n,
|
|
3311
|
+
fundingPremiumDampeningE6: 0n,
|
|
3312
|
+
fundingPremiumMaxBpsPerSlot: 0n,
|
|
3313
|
+
threshFloor: 0n,
|
|
3314
|
+
// removed in v12.17
|
|
3315
|
+
threshRiskBps: 0n,
|
|
3316
|
+
threshUpdateIntervalSlots: 0n,
|
|
3317
|
+
threshStepBps: 0n,
|
|
3318
|
+
threshAlphaBps: 0n,
|
|
3319
|
+
threshMin: 0n,
|
|
3320
|
+
threshMax: 0n,
|
|
3321
|
+
threshMinStep: 0n,
|
|
3322
|
+
oracleAuthority,
|
|
3323
|
+
authorityPriceE6,
|
|
3324
|
+
authorityTimestamp,
|
|
3325
|
+
oraclePriceCapE2bps,
|
|
3326
|
+
lastEffectivePriceE6,
|
|
3327
|
+
oiCapMultiplierBps: readU64LE(data, b + 448),
|
|
3328
|
+
maxPnlCap: readU64LE(data, b + 432),
|
|
3329
|
+
adaptiveFundingEnabled: false,
|
|
3330
|
+
// removed in v12.17
|
|
3331
|
+
adaptiveScaleBps: 0,
|
|
3332
|
+
adaptiveMaxFundingBps: 0n,
|
|
3333
|
+
marketCreatedSlot: 0n,
|
|
3334
|
+
oiRampSlots: 0n,
|
|
3335
|
+
resolvedSlot: 0n,
|
|
3336
|
+
insuranceIsolationBps: 0,
|
|
3337
|
+
oraclePhase: 0,
|
|
3338
|
+
cumulativeVolumeE6: 0n,
|
|
3339
|
+
phase2DeltaSlots: 0,
|
|
3340
|
+
dexPool
|
|
3341
|
+
};
|
|
3342
|
+
}
|
|
3263
3343
|
function parseConfig(data, layoutHint) {
|
|
3264
3344
|
const layout = layoutHint !== void 0 ? layoutHint : detectSlabLayout(data.length, data);
|
|
3265
3345
|
const configOff = layout ? layout.configOffset : V0_HEADER_LEN;
|
|
3266
3346
|
const configLen = layout ? layout.configLen : V0_CONFIG_LEN;
|
|
3347
|
+
const isV12_17 = layout && (layout.accountSize === V12_17_ACCOUNT_SIZE || layout.accountSize === V12_17_ACCOUNT_SIZE_SBF);
|
|
3348
|
+
if (isV12_17) {
|
|
3349
|
+
return parseConfigV12_17(data, configOff);
|
|
3350
|
+
}
|
|
3267
3351
|
const MIN_CONFIG_BYTES = 376;
|
|
3268
3352
|
const minLen = configOff + Math.min(configLen, MIN_CONFIG_BYTES);
|
|
3269
3353
|
if (data.length < minLen) {
|