@percolatorct/sdk 1.0.0-beta.35 → 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 +78 -0
- 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
|
@@ -3260,10 +3260,88 @@ function parseHeader(data) {
|
|
|
3260
3260
|
lastThrUpdateSlot
|
|
3261
3261
|
};
|
|
3262
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
|
+
}
|
|
3263
3337
|
function parseConfig(data, layoutHint) {
|
|
3264
3338
|
const layout = layoutHint !== void 0 ? layoutHint : detectSlabLayout(data.length, data);
|
|
3265
3339
|
const configOff = layout ? layout.configOffset : V0_HEADER_LEN;
|
|
3266
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
|
+
}
|
|
3267
3345
|
const MIN_CONFIG_BYTES = 376;
|
|
3268
3346
|
const minLen = configOff + Math.min(configLen, MIN_CONFIG_BYTES);
|
|
3269
3347
|
if (data.length < minLen) {
|