@percolatorct/sdk 2.0.2 → 2.0.4
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 +1 -1
- package/dist/index.js +76 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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.
|
|
5
|
+
> **EXPERIMENTAL. NOT AUDITED.** `2.0.4`. 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
|
@@ -3482,10 +3482,85 @@ function parseConfigV12_17(data, configOff) {
|
|
|
3482
3482
|
dexPool
|
|
3483
3483
|
};
|
|
3484
3484
|
}
|
|
3485
|
+
function parseConfigV12_19(data, configOff) {
|
|
3486
|
+
const MIN_V12_19_BYTES = 480;
|
|
3487
|
+
if (data.length < configOff + MIN_V12_19_BYTES) {
|
|
3488
|
+
throw new Error(`Slab data too short for V12_19 config: ${data.length} < ${configOff + MIN_V12_19_BYTES}`);
|
|
3489
|
+
}
|
|
3490
|
+
const b = configOff;
|
|
3491
|
+
const collateralMint = new PublicKey5(data.subarray(b + 0, b + 32));
|
|
3492
|
+
const vaultPubkey = new PublicKey5(data.subarray(b + 32, b + 64));
|
|
3493
|
+
const indexFeedId = new PublicKey5(data.subarray(b + 64, b + 96));
|
|
3494
|
+
const maxStalenessSlots = readU64LE(data, b + 96);
|
|
3495
|
+
const confFilterBps = readU16LE(data, b + 104);
|
|
3496
|
+
const vaultAuthorityBump = readU8(data, b + 106);
|
|
3497
|
+
const invert = readU8(data, b + 107);
|
|
3498
|
+
const unitScale = readU32LE(data, b + 108);
|
|
3499
|
+
const fundingHorizonSlots = readU64LE(data, b + 112);
|
|
3500
|
+
const fundingKBps = readU64LE(data, b + 120);
|
|
3501
|
+
const fundingMaxPremiumBps = readI64LE(data, b + 128);
|
|
3502
|
+
const fundingMaxBpsPerSlot = readI64LE(data, b + 136);
|
|
3503
|
+
const oracleAuthority = new PublicKey5(data.subarray(b + 144, b + 176));
|
|
3504
|
+
const authorityPriceE6 = readU64LE(data, b + 176);
|
|
3505
|
+
const authorityTimestamp = readI64LE(data, b + 184);
|
|
3506
|
+
const lastEffectivePriceE6 = readU64LE(data, b + 192);
|
|
3507
|
+
const oraclePriceCapE2bps = readU64LE(data, b + 216);
|
|
3508
|
+
const dexPoolBytes = data.subarray(b + 368, b + 400);
|
|
3509
|
+
const dexPool = dexPoolBytes.some((x) => x !== 0) ? new PublicKey5(dexPoolBytes) : null;
|
|
3510
|
+
return {
|
|
3511
|
+
collateralMint,
|
|
3512
|
+
vaultPubkey,
|
|
3513
|
+
indexFeedId,
|
|
3514
|
+
maxStalenessSlots,
|
|
3515
|
+
confFilterBps,
|
|
3516
|
+
vaultAuthorityBump,
|
|
3517
|
+
invert,
|
|
3518
|
+
unitScale,
|
|
3519
|
+
fundingHorizonSlots,
|
|
3520
|
+
fundingKBps,
|
|
3521
|
+
fundingInvScaleNotionalE6: 0n,
|
|
3522
|
+
fundingMaxPremiumBps,
|
|
3523
|
+
fundingMaxBpsPerSlot,
|
|
3524
|
+
fundingPremiumWeightBps: 0n,
|
|
3525
|
+
fundingSettlementIntervalSlots: 0n,
|
|
3526
|
+
fundingPremiumDampeningE6: 0n,
|
|
3527
|
+
fundingPremiumMaxBpsPerSlot: 0n,
|
|
3528
|
+
threshFloor: 0n,
|
|
3529
|
+
threshRiskBps: 0n,
|
|
3530
|
+
threshUpdateIntervalSlots: 0n,
|
|
3531
|
+
threshStepBps: 0n,
|
|
3532
|
+
threshAlphaBps: 0n,
|
|
3533
|
+
threshMin: 0n,
|
|
3534
|
+
threshMax: 0n,
|
|
3535
|
+
threshMinStep: 0n,
|
|
3536
|
+
oracleAuthority,
|
|
3537
|
+
authorityPriceE6,
|
|
3538
|
+
authorityTimestamp,
|
|
3539
|
+
oraclePriceCapE2bps,
|
|
3540
|
+
lastEffectivePriceE6,
|
|
3541
|
+
oiCapMultiplierBps: readU64LE(data, b + 416),
|
|
3542
|
+
maxPnlCap: readU64LE(data, b + 400),
|
|
3543
|
+
adaptiveFundingEnabled: false,
|
|
3544
|
+
adaptiveScaleBps: 0,
|
|
3545
|
+
adaptiveMaxFundingBps: 0n,
|
|
3546
|
+
marketCreatedSlot: 0n,
|
|
3547
|
+
oiRampSlots: 0n,
|
|
3548
|
+
resolvedSlot: 0n,
|
|
3549
|
+
insuranceIsolationBps: 0,
|
|
3550
|
+
oraclePhase: 0,
|
|
3551
|
+
cumulativeVolumeE6: 0n,
|
|
3552
|
+
phase2DeltaSlots: 0,
|
|
3553
|
+
dexPool
|
|
3554
|
+
};
|
|
3555
|
+
}
|
|
3485
3556
|
function parseConfig(data, layoutHint) {
|
|
3486
3557
|
const layout = layoutHint !== void 0 ? layoutHint : detectSlabLayout(data.length, data);
|
|
3487
3558
|
const configOff = layout ? layout.configOffset : V0_HEADER_LEN;
|
|
3488
3559
|
const configLen = layout ? layout.configLen : V0_CONFIG_LEN;
|
|
3560
|
+
const isV12_19 = layout && layout.accountSize === V12_19_ACCOUNT_SIZE_SBF;
|
|
3561
|
+
if (isV12_19) {
|
|
3562
|
+
return parseConfigV12_19(data, configOff);
|
|
3563
|
+
}
|
|
3489
3564
|
const isV12_17 = layout && (layout.accountSize === V12_17_ACCOUNT_SIZE || layout.accountSize === V12_17_ACCOUNT_SIZE_SBF);
|
|
3490
3565
|
if (isV12_17) {
|
|
3491
3566
|
return parseConfigV12_17(data, configOff);
|
|
@@ -3910,7 +3985,7 @@ function parseAccount(data, idx) {
|
|
|
3910
3985
|
if (data.length < base + layout.accountSize) {
|
|
3911
3986
|
throw new Error("Slab data too short for account");
|
|
3912
3987
|
}
|
|
3913
|
-
const isV12_17 = layout.accountSize === V12_17_ACCOUNT_SIZE || layout.accountSize === V12_17_ACCOUNT_SIZE_SBF;
|
|
3988
|
+
const isV12_17 = layout.accountSize === V12_17_ACCOUNT_SIZE || layout.accountSize === V12_17_ACCOUNT_SIZE_SBF || layout.accountSize === V12_19_ACCOUNT_SIZE_SBF;
|
|
3914
3989
|
const isV12_15 = !isV12_17 && (layout.accountSize === V12_15_ACCOUNT_SIZE || layout.accountSize === V12_15_ACCOUNT_SIZE_SMALL);
|
|
3915
3990
|
const isV12_1EP = !isV12_17 && !isV12_15 && layout.accountSize === V12_1_EP_SBF_ACCOUNT_SIZE && layout.engineOff === V12_1_SBF_ENGINE_OFF;
|
|
3916
3991
|
const isV12_1 = !isV12_17 && !isV12_15 && !isV12_1EP && (layout.engineOff === V12_1_ENGINE_OFF || layout.engineOff === V12_1_SBF_ENGINE_OFF) && (layout.accountSize === V12_1_ACCOUNT_SIZE || layout.accountSize === V12_1_ACCOUNT_SIZE_SBF);
|