@percolatorct/sdk 1.0.0-beta.33 → 1.0.0-beta.34

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.
@@ -727,10 +727,30 @@ export interface VammMatcherParams {
727
727
  impactKBps: number;
728
728
  liquidityNotionalE6: bigint;
729
729
  }
730
- /** Magic bytes identifying a vAMM matcher context: "PERCMATC" as u64 LE */
730
+ /** Magic bytes identifying a vAMM matcher context: "PERCMATC" as u64 LE = 0x504552434d415443 */
731
731
  export declare const VAMM_MAGIC = 5784119745439683651n;
732
- /** Offset into matcher context where vAMM params start */
732
+ /** Alias matching the Rust constant name for parity tests */
733
+ export declare const MATCHER_MAGIC = 5784119745439683651n;
734
+ /** Offset where matcher return is written in the context account (always 0 per ABI) */
735
+ export declare const CTX_RETURN_OFFSET = 0;
736
+ /** Byte length of the MatcherReturn section of the context account */
737
+ export declare const MATCHER_RETURN_LEN = 64;
738
+ /** Offset into matcher context where vAMM params start (= MATCHER_RETURN_LEN) */
733
739
  export declare const CTX_VAMM_OFFSET = 64;
740
+ /** Byte length of the MatcherCtx (vAMM state) section of the context account */
741
+ export declare const CTX_VAMM_LEN = 256;
742
+ /** Total matcher context account size: MATCHER_RETURN_LEN + CTX_VAMM_LEN */
743
+ export declare const MATCHER_CONTEXT_LEN = 320;
744
+ /** Byte length of a MatcherCall instruction (tag 0 CPI payload) */
745
+ export declare const MATCHER_CALL_LEN = 67;
746
+ /**
747
+ * Byte length of an InitMatcherCtx instruction payload sent to the matcher program.
748
+ * Layout: tag(1) + kind(1) + trading_fee_bps(4) + base_spread_bps(4) +
749
+ * max_total_bps(4) + impact_k_bps(4) + liquidity_notional_e6(16) +
750
+ * max_fill_abs(16) + max_inventory_abs(16) + fee_to_insurance_bps(2) +
751
+ * skew_spread_mult_bps(2) + lp_account_id(8) = 78
752
+ */
753
+ export declare const INIT_CTX_LEN = 78;
734
754
  /**
735
755
  * Compute execution price for a given LP quote.
736
756
  * For buys (isLong=true): price above oracle.
package/dist/index.js CHANGED
@@ -560,7 +560,14 @@ function encodeAuditCrank() {
560
560
  return encU8(IX_TAG.AuditCrank);
561
561
  }
562
562
  var VAMM_MAGIC = 0x504552434d415443n;
563
+ var MATCHER_MAGIC = VAMM_MAGIC;
564
+ var CTX_RETURN_OFFSET = 0;
565
+ var MATCHER_RETURN_LEN = 64;
563
566
  var CTX_VAMM_OFFSET = 64;
567
+ var CTX_VAMM_LEN = 256;
568
+ var MATCHER_CONTEXT_LEN = 320;
569
+ var MATCHER_CALL_LEN = 67;
570
+ var INIT_CTX_LEN = 78;
564
571
  var BPS_DENOM = 10000n;
565
572
  function computeVammQuote(params, oraclePriceE6, tradeSize, isLong) {
566
573
  const absSize = tradeSize < 0n ? -tradeSize : tradeSize;
@@ -2078,6 +2085,7 @@ var V12_17_ENGINE_OFF = 592;
2078
2085
  var V12_17_ACCOUNT_SIZE = 368;
2079
2086
  var V12_17_ENGINE_BITMAP_OFF = 752;
2080
2087
  var V12_17_RISK_BUF_LEN = 160;
2088
+ var V12_17_GEN_TABLE_ENTRY = 8;
2081
2089
  var V12_17_ENGINE_OFF_SBF = 584;
2082
2090
  var V12_17_ACCOUNT_SIZE_SBF = 352;
2083
2091
  var V12_17_ENGINE_BITMAP_OFF_SBF = 712;
@@ -2213,11 +2221,11 @@ for (const n of V12_17_TIERS) {
2213
2221
  const nextFreeBytes = n * 2;
2214
2222
  const preAccNative = V12_17_ENGINE_BITMAP_OFF + bitmapBytes + postBitmap + nextFreeBytes;
2215
2223
  const accountsOffNative = Math.ceil(preAccNative / 16) * 16;
2216
- const nativeSize = V12_17_ENGINE_OFF + accountsOffNative + n * V12_17_ACCOUNT_SIZE + V12_17_RISK_BUF_LEN;
2224
+ const nativeSize = V12_17_ENGINE_OFF + accountsOffNative + n * V12_17_ACCOUNT_SIZE + V12_17_RISK_BUF_LEN + n * V12_17_GEN_TABLE_ENTRY;
2217
2225
  V12_17_SIZES.set(nativeSize, n);
2218
2226
  const preAccSbf = V12_17_ENGINE_BITMAP_OFF_SBF + bitmapBytes + postBitmap + nextFreeBytes;
2219
2227
  const accountsOffSbf = Math.ceil(preAccSbf / 8) * 8;
2220
- const sbfSize = V12_17_ENGINE_OFF_SBF + accountsOffSbf + n * V12_17_ACCOUNT_SIZE_SBF + V12_17_RISK_BUF_LEN;
2228
+ const sbfSize = V12_17_ENGINE_OFF_SBF + accountsOffSbf + n * V12_17_ACCOUNT_SIZE_SBF + V12_17_RISK_BUF_LEN + n * V12_17_GEN_TABLE_ENTRY;
2221
2229
  V12_17_SIZES.set(sbfSize, n);
2222
2230
  }
2223
2231
  var V12_1_SBF_ACCOUNT_SIZE = 280;
@@ -2712,7 +2720,7 @@ for (const [label, n] of [["Small", 256], ["Medium", 1024], ["Large", 4096]]) {
2712
2720
  const bitmapBytes = Math.ceil(n / 64) * 8;
2713
2721
  const preAcc = V12_17_ENGINE_BITMAP_OFF_SBF + bitmapBytes + 4 + n * 2;
2714
2722
  const accountsOff = Math.ceil(preAcc / 8) * 8;
2715
- const size = V12_17_ENGINE_OFF_SBF + accountsOff + n * V12_17_ACCOUNT_SIZE_SBF + V12_17_RISK_BUF_LEN;
2723
+ const size = V12_17_ENGINE_OFF_SBF + accountsOff + n * V12_17_ACCOUNT_SIZE_SBF + V12_17_RISK_BUF_LEN + n * V12_17_GEN_TABLE_ENTRY;
2716
2724
  SLAB_TIERS_V12_17[label.toLowerCase()] = { maxAccounts: n, dataSize: size, label, description: `${n} slots (v12.17)` };
2717
2725
  }
2718
2726
  function buildLayoutVSetDexPool(maxAccounts) {
@@ -3018,7 +3026,7 @@ function buildLayoutV12_17(maxAccounts, dataLen) {
3018
3026
  const bitmapBytes2 = Math.ceil(maxAccounts / 64) * 8;
3019
3027
  const preAccNative = V12_17_ENGINE_BITMAP_OFF + bitmapBytes2 + 4 + maxAccounts * 2;
3020
3028
  const accountsOffNative = Math.ceil(preAccNative / 16) * 16;
3021
- const nativeSize = V12_17_ENGINE_OFF + accountsOffNative + maxAccounts * V12_17_ACCOUNT_SIZE + V12_17_RISK_BUF_LEN;
3029
+ const nativeSize = V12_17_ENGINE_OFF + accountsOffNative + maxAccounts * V12_17_ACCOUNT_SIZE + V12_17_RISK_BUF_LEN + maxAccounts * V12_17_GEN_TABLE_ENTRY;
3022
3030
  return dataLen !== nativeSize;
3023
3031
  })();
3024
3032
  const engineOff = isSbf ? V12_17_ENGINE_OFF_SBF : V12_17_ENGINE_OFF;
@@ -5153,10 +5161,9 @@ function decodeStakePool(data) {
5153
5161
  const reservedStart = off;
5154
5162
  const marketResolved = bytes[reservedStart + 9] === 1;
5155
5163
  const hwmEnabled = bytes[reservedStart + 10] === 1;
5156
- const hwmTvlLow = readU64LE4(bytes, reservedStart + 11);
5157
- const hwmTvlHigh = readU64LE4(bytes, reservedStart + 19);
5158
- const epochHighWaterTvl = hwmTvlLow | hwmTvlHigh << 64n;
5159
- const hwmFloorBps = readU16LE3(bytes, reservedStart + 27);
5164
+ const hwmFloorBps = readU16LE3(bytes, reservedStart + 11);
5165
+ const epochHighWaterTvl = readU64LE4(bytes, reservedStart + 16);
5166
+ const hwmLastEpoch = readU64LE4(bytes, reservedStart + 24);
5160
5167
  const trancheEnabled = bytes[reservedStart + 32] === 1;
5161
5168
  const juniorBalance = readU64LE4(bytes, reservedStart + 33);
5162
5169
  const juniorTotalLp = readU64LE4(bytes, reservedStart + 41);
@@ -5187,6 +5194,7 @@ function decodeStakePool(data) {
5187
5194
  hwmEnabled,
5188
5195
  epochHighWaterTvl,
5189
5196
  hwmFloorBps,
5197
+ hwmLastEpoch,
5190
5198
  trancheEnabled,
5191
5199
  juniorBalance,
5192
5200
  juniorTotalLp,
@@ -6660,10 +6668,13 @@ export {
6660
6668
  CHAINLINK_DECIMALS_OFFSET,
6661
6669
  CHAINLINK_MIN_SIZE,
6662
6670
  CREATOR_LOCK_SEED,
6671
+ CTX_RETURN_OFFSET,
6672
+ CTX_VAMM_LEN,
6663
6673
  CTX_VAMM_OFFSET,
6664
6674
  DEFAULT_OI_RAMP_SLOTS,
6665
6675
  ENGINE_MARK_PRICE_OFF,
6666
6676
  ENGINE_OFF,
6677
+ INIT_CTX_LEN,
6667
6678
  IX_TAG,
6668
6679
  LIGHTHOUSE_CONSTRAINT_ADDRESS,
6669
6680
  LIGHTHOUSE_ERROR_CODES,
@@ -6673,6 +6684,10 @@ export {
6673
6684
  LiquidationPolicyTag,
6674
6685
  MARK_PRICE_EMA_ALPHA_E6,
6675
6686
  MARK_PRICE_EMA_WINDOW_SLOTS,
6687
+ MATCHER_CALL_LEN,
6688
+ MATCHER_CONTEXT_LEN,
6689
+ MATCHER_MAGIC,
6690
+ MATCHER_RETURN_LEN,
6676
6691
  MAX_DECIMALS,
6677
6692
  METEORA_DLMM_PROGRAM_ID,
6678
6693
  NFT_IX_TAG,