@whetstone-research/doppler-sdk 1.0.8 → 1.0.9

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.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkDPKVNI6Q_cjs = require('./chunk-DPKVNI6Q.cjs');
3
+ var chunkO6FR7TXY_cjs = require('./chunk-O6FR7TXY.cjs');
4
4
  var kit = require('@solana/kit');
5
5
 
6
6
  var addressCodec = kit.getAddressCodec();
@@ -52,7 +52,7 @@ var ammConfigDataCodec = kit.getStructCodec([
52
52
  ["sentinelAllowlistLen", u8Codec],
53
53
  [
54
54
  "sentinelAllowlist",
55
- kit.getArrayCodec(addressCodec, { size: chunkDPKVNI6Q_cjs.MAX_SENTINEL_ALLOWLIST })
55
+ kit.getArrayCodec(addressCodec, { size: chunkO6FR7TXY_cjs.MAX_SENTINEL_ALLOWLIST })
56
56
  ],
57
57
  ["maxSwapFeeBps", u16Codec],
58
58
  ["maxFeeSplitBps", u16Codec],
@@ -120,22 +120,22 @@ var oracleStateDataCodec = kit.getStructCodec([
120
120
  ["observationIndex", u16Codec],
121
121
  [
122
122
  "observations",
123
- kit.getArrayCodec(observationCodec, { size: chunkDPKVNI6Q_cjs.MAX_ORACLE_OBSERVATIONS })
123
+ kit.getArrayCodec(observationCodec, { size: chunkO6FR7TXY_cjs.MAX_ORACLE_OBSERVATIONS })
124
124
  ],
125
125
  ["version", u8Codec],
126
126
  ["reserved", reservedBytesCodec]
127
127
  ]);
128
128
  var ammConfigDecoder = kit.getHiddenPrefixDecoder(ammConfigDataCodec, [
129
- kit.getConstantDecoder(chunkDPKVNI6Q_cjs.ACCOUNT_DISCRIMINATORS.AmmConfig)
129
+ kit.getConstantDecoder(chunkO6FR7TXY_cjs.ACCOUNT_DISCRIMINATORS.AmmConfig)
130
130
  ]);
131
131
  var poolDecoder = kit.getHiddenPrefixDecoder(poolDataCodec, [
132
- kit.getConstantDecoder(chunkDPKVNI6Q_cjs.ACCOUNT_DISCRIMINATORS.Pool)
132
+ kit.getConstantDecoder(chunkO6FR7TXY_cjs.ACCOUNT_DISCRIMINATORS.Pool)
133
133
  ]);
134
134
  var positionDecoder = kit.getHiddenPrefixDecoder(positionDataCodec, [
135
- kit.getConstantDecoder(chunkDPKVNI6Q_cjs.ACCOUNT_DISCRIMINATORS.Position)
135
+ kit.getConstantDecoder(chunkO6FR7TXY_cjs.ACCOUNT_DISCRIMINATORS.Position)
136
136
  ]);
137
137
  var oracleStateDecoder = kit.getHiddenPrefixDecoder(oracleStateDataCodec, [
138
- kit.getConstantDecoder(chunkDPKVNI6Q_cjs.ACCOUNT_DISCRIMINATORS.OracleState)
138
+ kit.getConstantDecoder(chunkO6FR7TXY_cjs.ACCOUNT_DISCRIMINATORS.OracleState)
139
139
  ]);
140
140
  function decodeAmmConfig(data) {
141
141
  return ammConfigDecoder.decode(data);
@@ -299,12 +299,12 @@ function encodeQuoteToNumeraireArgs(args) {
299
299
  function q64ToNumber(q64) {
300
300
  const intPart = q64 >> 64n;
301
301
  const fracPart = q64 & (1n << 64n) - 1n;
302
- return Number(intPart) + Number(fracPart) / Number(chunkDPKVNI6Q_cjs.Q64_ONE);
302
+ return Number(intPart) + Number(fracPart) / Number(chunkO6FR7TXY_cjs.Q64_ONE);
303
303
  }
304
304
  function numberToQ64(n) {
305
305
  const intPart = Math.floor(n);
306
306
  const fracPart = n - intPart;
307
- return (BigInt(intPart) << 64n) + BigInt(Math.round(fracPart * Number(chunkDPKVNI6Q_cjs.Q64_ONE)));
307
+ return (BigInt(intPart) << 64n) + BigInt(Math.round(fracPart * Number(chunkO6FR7TXY_cjs.Q64_ONE)));
308
308
  }
309
309
  function q64Mul(a, b) {
310
310
  return a * b >> 64n;
@@ -360,8 +360,8 @@ function getSwapQuote(pool, amountIn, direction) {
360
360
  if (reserveIn === 0n || reserveOut === 0n) {
361
361
  throw new Error("Pool has zero liquidity");
362
362
  }
363
- const feeTotal = amountIn * BigInt(pool.swapFeeBps) / chunkDPKVNI6Q_cjs.BPS_DENOM;
364
- const feeDist = feeTotal * BigInt(pool.feeSplitBps) / chunkDPKVNI6Q_cjs.BPS_DENOM;
363
+ const feeTotal = amountIn * BigInt(pool.swapFeeBps) / chunkO6FR7TXY_cjs.BPS_DENOM;
364
+ const feeDist = feeTotal * BigInt(pool.feeSplitBps) / chunkO6FR7TXY_cjs.BPS_DENOM;
365
365
  const feeComp = feeTotal - feeDist;
366
366
  const amountInEff = amountIn - feeTotal;
367
367
  const amountOut = amountInEff * reserveOut / (reserveIn + amountInEff);
@@ -387,8 +387,8 @@ function getSwapQuoteExactOut(pool, amountOut, direction) {
387
387
  }
388
388
  const amountInEff = ceilDiv(amountOut * reserveIn, reserveOut - amountOut);
389
389
  const amountIn = ceilDiv(
390
- amountInEff * chunkDPKVNI6Q_cjs.BPS_DENOM,
391
- chunkDPKVNI6Q_cjs.BPS_DENOM - BigInt(pool.swapFeeBps)
390
+ amountInEff * chunkO6FR7TXY_cjs.BPS_DENOM,
391
+ chunkO6FR7TXY_cjs.BPS_DENOM - BigInt(pool.swapFeeBps)
392
392
  );
393
393
  const feeTotal = amountIn - amountInEff;
394
394
  return { amountIn, feeTotal };
@@ -488,7 +488,7 @@ function calculateTwapNumber(cumulativeStart, cumulativeEnd, timestampStart, tim
488
488
  );
489
489
  return q64ToNumber(twapQ64);
490
490
  }
491
- function createCollectFeesInstruction(accounts, args, programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID) {
491
+ function createCollectFeesInstruction(accounts, args, programId = chunkO6FR7TXY_cjs.CPMM_PROGRAM_ID) {
492
492
  const {
493
493
  pool,
494
494
  position,
@@ -500,7 +500,7 @@ function createCollectFeesInstruction(accounts, args, programId = chunkDPKVNI6Q_
500
500
  token1Mint,
501
501
  user0,
502
502
  user1,
503
- tokenProgram = chunkDPKVNI6Q_cjs.TOKEN_PROGRAM_ADDRESS
503
+ tokenProgram = chunkO6FR7TXY_cjs.TOKEN_PROGRAM_ADDRESS
504
504
  } = accounts;
505
505
  const keys = [
506
506
  { address: pool, role: kit.AccountRole.WRITABLE },
@@ -516,7 +516,7 @@ function createCollectFeesInstruction(accounts, args, programId = chunkDPKVNI6Q_
516
516
  { address: tokenProgram, role: kit.AccountRole.READONLY }
517
517
  ];
518
518
  const data = encodeInstructionData(
519
- chunkDPKVNI6Q_cjs.INSTRUCTION_DISCRIMINATORS.collectFees,
519
+ chunkO6FR7TXY_cjs.INSTRUCTION_DISCRIMINATORS.collectFees,
520
520
  collectFeesArgsCodec,
521
521
  args
522
522
  );
@@ -555,11 +555,11 @@ async function fetchPool(rpc, address, config) {
555
555
  return decodePool(base64ToBytes(response.value.data[0]));
556
556
  }
557
557
  async function fetchAllPools(rpc, config) {
558
- const programId = config?.programId ?? chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID;
558
+ const programId = config?.programId ?? chunkO6FR7TXY_cjs.CPMM_PROGRAM_ID;
559
559
  const discriminatorFilter = {
560
560
  memcmp: {
561
561
  offset: 0n,
562
- bytes: bytesToBase64(chunkDPKVNI6Q_cjs.ACCOUNT_DISCRIMINATORS.Pool),
562
+ bytes: bytesToBase64(chunkO6FR7TXY_cjs.ACCOUNT_DISCRIMINATORS.Pool),
563
563
  encoding: "base64"
564
564
  }
565
565
  };
@@ -584,8 +584,8 @@ async function fetchAllPools(rpc, config) {
584
584
  return pools;
585
585
  }
586
586
  async function getPoolByMints(rpc, mint0, mint1, config) {
587
- const programId = config?.programId ?? chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID;
588
- const [poolAddress] = await chunkDPKVNI6Q_cjs.getPoolAddress(mint0, mint1, programId);
587
+ const programId = config?.programId ?? chunkO6FR7TXY_cjs.CPMM_PROGRAM_ID;
588
+ const [poolAddress] = await chunkO6FR7TXY_cjs.getPoolAddress(mint0, mint1, programId);
589
589
  const pool = await fetchPool(rpc, poolAddress, config);
590
590
  if (!pool) {
591
591
  return null;
@@ -612,9 +612,9 @@ async function poolExists(rpc, mint0, mint1, config) {
612
612
  const result = await getPoolByMints(rpc, mint0, mint1, config);
613
613
  return result !== null;
614
614
  }
615
- async function getPoolAddressFromMints(mint0, mint1, programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID) {
616
- const [token0, token1] = chunkDPKVNI6Q_cjs.sortMints(mint0, mint1);
617
- const [poolAddress] = await chunkDPKVNI6Q_cjs.getPoolAddress(mint0, mint1, programId);
615
+ async function getPoolAddressFromMints(mint0, mint1, programId = chunkO6FR7TXY_cjs.CPMM_PROGRAM_ID) {
616
+ const [token0, token1] = chunkO6FR7TXY_cjs.sortMints(mint0, mint1);
617
+ const [poolAddress] = await chunkO6FR7TXY_cjs.getPoolAddress(mint0, mint1, programId);
618
618
  return {
619
619
  poolAddress,
620
620
  token0,
@@ -662,14 +662,14 @@ async function fetchPosition(rpc, address, config) {
662
662
  return decodePosition(base64ToBytes2(response.value.data[0]));
663
663
  }
664
664
  async function fetchUserPositions(rpc, owner, pool, config) {
665
- const programId = config?.programId ?? chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID;
665
+ const programId = config?.programId ?? chunkO6FR7TXY_cjs.CPMM_PROGRAM_ID;
666
666
  const filters = [
667
667
  // Discriminator filter (first 8 bytes)
668
668
  {
669
669
  memcmp: {
670
670
  offset: 0n,
671
671
  bytes: bytesToBase642(
672
- chunkDPKVNI6Q_cjs.ACCOUNT_DISCRIMINATORS.Position
672
+ chunkO6FR7TXY_cjs.ACCOUNT_DISCRIMINATORS.Position
673
673
  ),
674
674
  encoding: "base64"
675
675
  }
@@ -713,14 +713,14 @@ async function fetchUserPositions(rpc, owner, pool, config) {
713
713
  return positions;
714
714
  }
715
715
  async function fetchPoolPositions(rpc, pool, config) {
716
- const programId = config?.programId ?? chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID;
716
+ const programId = config?.programId ?? chunkO6FR7TXY_cjs.CPMM_PROGRAM_ID;
717
717
  const filters = [
718
718
  // Discriminator filter
719
719
  {
720
720
  memcmp: {
721
721
  offset: 0n,
722
722
  bytes: bytesToBase642(
723
- chunkDPKVNI6Q_cjs.ACCOUNT_DISCRIMINATORS.Position
723
+ chunkO6FR7TXY_cjs.ACCOUNT_DISCRIMINATORS.Position
724
724
  ),
725
725
  encoding: "base64"
726
726
  }
@@ -781,8 +781,8 @@ function getPositionValue(pool, position) {
781
781
  };
782
782
  }
783
783
  async function fetchPositionByParams(rpc, pool, owner, positionId, config) {
784
- const programId = config?.programId ?? chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID;
785
- const [address] = await chunkDPKVNI6Q_cjs.getPositionAddress(
784
+ const programId = config?.programId ?? chunkO6FR7TXY_cjs.CPMM_PROGRAM_ID;
785
+ const [address] = await chunkO6FR7TXY_cjs.getPositionAddress(
786
786
  pool,
787
787
  owner,
788
788
  positionId,
@@ -797,8 +797,8 @@ async function fetchPositionByParams(rpc, pool, owner, positionId, config) {
797
797
  account: position
798
798
  };
799
799
  }
800
- async function getPositionAddressFromParams(pool, owner, positionId, programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID) {
801
- const [address] = await chunkDPKVNI6Q_cjs.getPositionAddress(
800
+ async function getPositionAddressFromParams(pool, owner, positionId, programId = chunkO6FR7TXY_cjs.CPMM_PROGRAM_ID) {
801
+ const [address] = await chunkO6FR7TXY_cjs.getPositionAddress(
802
802
  pool,
803
803
  owner,
804
804
  positionId,
@@ -849,8 +849,8 @@ async function fetchOracle(rpc, address, config) {
849
849
  return decodeOracleState(base64ToBytes3(response.value.data[0]));
850
850
  }
851
851
  async function getOracleForPool(rpc, pool, config) {
852
- const programId = config?.programId ?? chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID;
853
- const [oracleAddress] = await chunkDPKVNI6Q_cjs.getOracleAddress(pool, programId);
852
+ const programId = config?.programId ?? chunkO6FR7TXY_cjs.CPMM_PROGRAM_ID;
853
+ const [oracleAddress] = await chunkO6FR7TXY_cjs.getOracleAddress(pool, programId);
854
854
  const oracle = await fetchOracle(rpc, oracleAddress, config);
855
855
  if (!oracle) {
856
856
  return null;
@@ -860,8 +860,8 @@ async function getOracleForPool(rpc, pool, config) {
860
860
  account: oracle
861
861
  };
862
862
  }
863
- async function getOracleAddressFromPool(pool, programId = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID) {
864
- const [address] = await chunkDPKVNI6Q_cjs.getOracleAddress(pool, programId);
863
+ async function getOracleAddressFromPool(pool, programId = chunkO6FR7TXY_cjs.CPMM_PROGRAM_ID) {
864
+ const [address] = await chunkO6FR7TXY_cjs.getOracleAddress(pool, programId);
865
865
  return address;
866
866
  }
867
867
  function consultTwap(oracle, windowSeconds, currentTimestamp) {
@@ -984,10 +984,10 @@ function getOracleBufferStats(oracle) {
984
984
  };
985
985
  }
986
986
  async function fetchOraclesBatch(rpc, pools, config) {
987
- const programId = config?.programId ?? chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID;
987
+ const programId = config?.programId ?? chunkO6FR7TXY_cjs.CPMM_PROGRAM_ID;
988
988
  const oracles = /* @__PURE__ */ new Map();
989
989
  const oracleAddresses = await Promise.all(
990
- pools.map((pool) => chunkDPKVNI6Q_cjs.getOracleAddress(pool, programId))
990
+ pools.map((pool) => chunkO6FR7TXY_cjs.getOracleAddress(pool, programId))
991
991
  );
992
992
  const results = await Promise.all(
993
993
  oracleAddresses.map(([addr]) => fetchOracle(rpc, addr, config))
@@ -1107,5 +1107,5 @@ exports.sortPoolsByReserves = sortPoolsByReserves;
1107
1107
  exports.sortPositionsByShares = sortPositionsByShares;
1108
1108
  exports.swapExactInArgsCodec = swapExactInArgsCodec;
1109
1109
  exports.transferAdminArgsCodec = transferAdminArgsCodec;
1110
- //# sourceMappingURL=chunk-BXATWUGJ.cjs.map
1111
- //# sourceMappingURL=chunk-BXATWUGJ.cjs.map
1110
+ //# sourceMappingURL=chunk-I5JME35L.cjs.map
1111
+ //# sourceMappingURL=chunk-I5JME35L.cjs.map