@whetstone-research/doppler-sdk 1.0.13 → 1.0.15

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.
Files changed (33) hide show
  1. package/README.md +48 -12
  2. package/dist/{chunk-AT33RY6T.cjs → chunk-3BW6IVP3.cjs} +46 -37
  3. package/dist/chunk-3BW6IVP3.cjs.map +1 -0
  4. package/dist/{chunk-ZQEEGBXT.js → chunk-NMTYI3TB.js} +23 -26
  5. package/dist/chunk-NMTYI3TB.js.map +1 -0
  6. package/dist/{chunk-2NFQKIOB.js → chunk-TVBSIQIX.js} +35 -26
  7. package/dist/chunk-TVBSIQIX.js.map +1 -0
  8. package/dist/{chunk-LL7TW3GU.cjs → chunk-W5TMS4RD.cjs} +56 -59
  9. package/dist/chunk-W5TMS4RD.cjs.map +1 -0
  10. package/dist/{oracle-CU-nZnja.d.cts → oracle-DN8BrGPh.d.cts} +28 -28
  11. package/dist/{oracle-CU-nZnja.d.ts → oracle-DN8BrGPh.d.ts} +28 -28
  12. package/dist/{pda-FLNTBIC5.js → pda-5D3GD5S6.js} +3 -3
  13. package/dist/pda-5D3GD5S6.js.map +1 -0
  14. package/dist/{pda-G25AJSXG.cjs → pda-GNZYNRUH.cjs} +17 -17
  15. package/dist/{pda-G25AJSXG.cjs.map → pda-GNZYNRUH.cjs.map} +1 -1
  16. package/dist/solana/index.cjs +910 -743
  17. package/dist/solana/index.cjs.map +1 -1
  18. package/dist/solana/index.d.cts +560 -472
  19. package/dist/solana/index.d.ts +560 -472
  20. package/dist/solana/index.js +772 -607
  21. package/dist/solana/index.js.map +1 -1
  22. package/dist/solana/react/index.cjs +57 -57
  23. package/dist/solana/react/index.cjs.map +1 -1
  24. package/dist/solana/react/index.d.cts +5 -5
  25. package/dist/solana/react/index.d.ts +5 -5
  26. package/dist/solana/react/index.js +15 -15
  27. package/dist/solana/react/index.js.map +1 -1
  28. package/package.json +4 -2
  29. package/dist/chunk-2NFQKIOB.js.map +0 -1
  30. package/dist/chunk-AT33RY6T.cjs.map +0 -1
  31. package/dist/chunk-LL7TW3GU.cjs.map +0 -1
  32. package/dist/chunk-ZQEEGBXT.js.map +0 -1
  33. package/dist/pda-FLNTBIC5.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkLL7TW3GU_cjs = require('../../chunk-LL7TW3GU.cjs');
4
- var chunkAT33RY6T_cjs = require('../../chunk-AT33RY6T.cjs');
3
+ var chunkW5TMS4RD_cjs = require('../../chunk-W5TMS4RD.cjs');
4
+ var chunk3BW6IVP3_cjs = require('../../chunk-3BW6IVP3.cjs');
5
5
  require('../../chunk-Q7SFCCGT.cjs');
6
6
  var react = require('react');
7
7
  var jsxRuntime = require('react/jsx-runtime');
@@ -10,7 +10,7 @@ var kit = require('@solana/kit');
10
10
  var AmmContext = react.createContext(null);
11
11
  function AmmProvider({
12
12
  rpc,
13
- programId = chunkAT33RY6T_cjs.CPMM_PROGRAM_ID,
13
+ programId = chunk3BW6IVP3_cjs.CPMM_PROGRAM_ID,
14
14
  commitment = "confirmed",
15
15
  refreshInterval = 3e4,
16
16
  defaultSlippageBps = 50,
@@ -91,7 +91,7 @@ function createAmmContextValue(config) {
91
91
  return {
92
92
  rpc,
93
93
  endpoint,
94
- programId: programId ?? chunkAT33RY6T_cjs.CPMM_PROGRAM_ID,
94
+ programId: programId ?? chunk3BW6IVP3_cjs.CPMM_PROGRAM_ID,
95
95
  commitment,
96
96
  refreshInterval,
97
97
  defaultSlippageBps
@@ -333,7 +333,7 @@ function usePool(poolAddress, options = {}) {
333
333
  }
334
334
  setError(null);
335
335
  try {
336
- const poolData = await chunkLL7TW3GU_cjs.fetchPool(rpc, poolAddress, {
336
+ const poolData = await chunkW5TMS4RD_cjs.fetchPool(rpc, poolAddress, {
337
337
  programId,
338
338
  commitment
339
339
  });
@@ -411,7 +411,7 @@ function usePools(poolAddresses, options = {}) {
411
411
  try {
412
412
  const results = await Promise.all(
413
413
  poolAddresses.map(
414
- (addr) => chunkLL7TW3GU_cjs.fetchPool(rpc, addr, { programId, commitment }).then((pool) => [addr, pool]).catch(() => [addr, null])
414
+ (addr) => chunkW5TMS4RD_cjs.fetchPool(rpc, addr, { programId, commitment }).then((pool) => [addr, pool]).catch(() => [addr, null])
415
415
  )
416
416
  );
417
417
  if (mountedRef.current) {
@@ -473,14 +473,14 @@ function useSwap(options) {
473
473
  slippageBps: defaultSlippageBps
474
474
  });
475
475
  const [quoting] = react.useState(false);
476
- const direction = react.useMemo(() => {
476
+ const tradeDirection = react.useMemo(() => {
477
477
  if (!token0Mint || !token1Mint || !state.inputToken) return null;
478
478
  if (state.inputToken === token0Mint) return 0;
479
479
  if (state.inputToken === token1Mint) return 1;
480
480
  return null;
481
481
  }, [token0Mint, token1Mint, state.inputToken]);
482
482
  const quote = react.useMemo(() => {
483
- if (!pool || direction === null) {
483
+ if (!pool || tradeDirection === null) {
484
484
  return null;
485
485
  }
486
486
  if (state.exactInput) {
@@ -494,20 +494,20 @@ function useSwap(options) {
494
494
  executionPrice: 0,
495
495
  minAmountOut: 0n,
496
496
  maxAmountIn: 0n,
497
- direction,
497
+ tradeDirection,
498
498
  isValid: false,
499
499
  error: null
500
500
  };
501
501
  }
502
502
  try {
503
- const swapQuote = chunkLL7TW3GU_cjs.getSwapQuote(pool, state.inputAmount, direction);
504
- const slippageFactor = chunkAT33RY6T_cjs.BPS_DENOM - BigInt(state.slippageBps);
505
- const minAmountOut = swapQuote.amountOut * slippageFactor / chunkAT33RY6T_cjs.BPS_DENOM;
503
+ const swapQuote = chunkW5TMS4RD_cjs.getSwapQuote(pool, state.inputAmount, tradeDirection);
504
+ const slippageFactor = chunk3BW6IVP3_cjs.BPS_DENOM - BigInt(state.slippageBps);
505
+ const minAmountOut = swapQuote.amountOut * slippageFactor / chunk3BW6IVP3_cjs.BPS_DENOM;
506
506
  return {
507
507
  ...swapQuote,
508
508
  minAmountOut,
509
509
  maxAmountIn: state.inputAmount,
510
- direction,
510
+ tradeDirection,
511
511
  isValid: swapQuote.amountOut > 0n,
512
512
  error: null
513
513
  };
@@ -521,7 +521,7 @@ function useSwap(options) {
521
521
  executionPrice: 0,
522
522
  minAmountOut: 0n,
523
523
  maxAmountIn: 0n,
524
- direction,
524
+ tradeDirection,
525
525
  isValid: false,
526
526
  error: err instanceof Error ? err.message : "Failed to calculate quote"
527
527
  };
@@ -537,20 +537,20 @@ function useSwap(options) {
537
537
  executionPrice: 0,
538
538
  minAmountOut: 0n,
539
539
  maxAmountIn: 0n,
540
- direction,
540
+ tradeDirection,
541
541
  isValid: false,
542
542
  error: null
543
543
  };
544
544
  }
545
545
  try {
546
- const { amountIn, feeTotal } = chunkLL7TW3GU_cjs.getSwapQuoteExactOut(
546
+ const { amountIn, feeTotal } = chunkW5TMS4RD_cjs.getSwapQuoteExactOut(
547
547
  pool,
548
548
  state.outputAmount,
549
- direction
549
+ tradeDirection
550
550
  );
551
- const slippageFactor = chunkAT33RY6T_cjs.BPS_DENOM + BigInt(state.slippageBps);
552
- const maxAmountIn = amountIn * slippageFactor / chunkAT33RY6T_cjs.BPS_DENOM;
553
- const forwardQuote = chunkLL7TW3GU_cjs.getSwapQuote(pool, amountIn, direction);
551
+ const slippageFactor = chunk3BW6IVP3_cjs.BPS_DENOM + BigInt(state.slippageBps);
552
+ const maxAmountIn = amountIn * slippageFactor / chunk3BW6IVP3_cjs.BPS_DENOM;
553
+ const forwardQuote = chunkW5TMS4RD_cjs.getSwapQuote(pool, amountIn, tradeDirection);
554
554
  return {
555
555
  amountOut: state.outputAmount,
556
556
  feeTotal,
@@ -558,10 +558,10 @@ function useSwap(options) {
558
558
  // Not calculated for exact out
559
559
  feeComp: 0n,
560
560
  priceImpact: forwardQuote.priceImpact,
561
- executionPrice: chunkLL7TW3GU_cjs.ratioToNumber(state.outputAmount, amountIn),
561
+ executionPrice: chunkW5TMS4RD_cjs.ratioToNumber(state.outputAmount, amountIn),
562
562
  minAmountOut: state.outputAmount,
563
563
  maxAmountIn,
564
- direction,
564
+ tradeDirection,
565
565
  isValid: amountIn > 0n,
566
566
  error: null
567
567
  };
@@ -575,7 +575,7 @@ function useSwap(options) {
575
575
  executionPrice: 0,
576
576
  minAmountOut: 0n,
577
577
  maxAmountIn: 0n,
578
- direction,
578
+ tradeDirection,
579
579
  isValid: false,
580
580
  error: err instanceof Error ? err.message : "Failed to calculate quote"
581
581
  };
@@ -583,7 +583,7 @@ function useSwap(options) {
583
583
  }
584
584
  }, [
585
585
  pool,
586
- direction,
586
+ tradeDirection,
587
587
  state.inputAmount,
588
588
  state.outputAmount,
589
589
  state.exactInput,
@@ -683,13 +683,13 @@ function useLiquidity(options) {
683
683
  };
684
684
  }
685
685
  try {
686
- const quote = chunkLL7TW3GU_cjs.getAddLiquidityQuote(
686
+ const quote = chunkW5TMS4RD_cjs.getAddLiquidityQuote(
687
687
  pool,
688
688
  addState.amount0,
689
689
  addState.amount1
690
690
  );
691
- const slippageFactor = chunkAT33RY6T_cjs.BPS_DENOM - BigInt(addState.slippageBps);
692
- const minSharesOut = quote.sharesOut * slippageFactor / chunkAT33RY6T_cjs.BPS_DENOM;
691
+ const slippageFactor = chunk3BW6IVP3_cjs.BPS_DENOM - BigInt(addState.slippageBps);
692
+ const minSharesOut = quote.sharesOut * slippageFactor / chunk3BW6IVP3_cjs.BPS_DENOM;
693
693
  return {
694
694
  ...quote,
695
695
  minSharesOut,
@@ -723,10 +723,10 @@ function useLiquidity(options) {
723
723
  };
724
724
  }
725
725
  try {
726
- const quote = chunkLL7TW3GU_cjs.getRemoveLiquidityQuote(pool, removeState.shares);
727
- const slippageFactor = chunkAT33RY6T_cjs.BPS_DENOM - BigInt(removeState.slippageBps);
728
- const minAmount0Out = quote.amount0 * slippageFactor / chunkAT33RY6T_cjs.BPS_DENOM;
729
- const minAmount1Out = quote.amount1 * slippageFactor / chunkAT33RY6T_cjs.BPS_DENOM;
726
+ const quote = chunkW5TMS4RD_cjs.getRemoveLiquidityQuote(pool, removeState.shares);
727
+ const slippageFactor = chunk3BW6IVP3_cjs.BPS_DENOM - BigInt(removeState.slippageBps);
728
+ const minAmount0Out = quote.amount0 * slippageFactor / chunk3BW6IVP3_cjs.BPS_DENOM;
729
+ const minAmount1Out = quote.amount1 * slippageFactor / chunk3BW6IVP3_cjs.BPS_DENOM;
730
730
  return {
731
731
  ...quote,
732
732
  minAmount0Out,
@@ -843,7 +843,7 @@ function usePosition(poolAddress, positionId = 0n, options = {}) {
843
843
  setLoading(true);
844
844
  setError(null);
845
845
  try {
846
- const { getPositionAddress } = await import('../../pda-G25AJSXG.cjs');
846
+ const { getPositionAddress } = await import('../../pda-GNZYNRUH.cjs');
847
847
  const [posAddr] = await getPositionAddress(
848
848
  poolAddress,
849
849
  ownerAddress,
@@ -852,8 +852,8 @@ function usePosition(poolAddress, positionId = 0n, options = {}) {
852
852
  );
853
853
  setPositionAddress(posAddr);
854
854
  const [positionData, poolData] = await Promise.all([
855
- chunkLL7TW3GU_cjs.fetchPosition(rpc, posAddr, { programId, commitment }),
856
- providedPool ? Promise.resolve(providedPool) : chunkLL7TW3GU_cjs.fetchPool(rpc, poolAddress, { programId, commitment })
855
+ chunkW5TMS4RD_cjs.fetchPosition(rpc, posAddr, { programId, commitment }),
856
+ providedPool ? Promise.resolve(providedPool) : chunkW5TMS4RD_cjs.fetchPool(rpc, poolAddress, { programId, commitment })
857
857
  ]);
858
858
  if (mountedRef.current) {
859
859
  setPosition(positionData);
@@ -882,11 +882,11 @@ function usePosition(poolAddress, positionId = 0n, options = {}) {
882
882
  }, [fetchPositionData]);
883
883
  const pendingFees = react.useMemo(() => {
884
884
  if (!pool || !position) return null;
885
- return chunkLL7TW3GU_cjs.getPendingFees(pool, position);
885
+ return chunkW5TMS4RD_cjs.getPendingFees(pool, position);
886
886
  }, [pool, position]);
887
887
  const value = react.useMemo(() => {
888
888
  if (!pool || !position) return null;
889
- return chunkLL7TW3GU_cjs.getPositionValue(pool, position);
889
+ return chunkW5TMS4RD_cjs.getPositionValue(pool, position);
890
890
  }, [pool, position]);
891
891
  react.useEffect(() => {
892
892
  mountedRef.current = true;
@@ -941,7 +941,7 @@ function useUserPositions(poolFilter, options = {}) {
941
941
  setLoading(true);
942
942
  setError(null);
943
943
  try {
944
- const positionsData = await chunkLL7TW3GU_cjs.fetchUserPositions(
944
+ const positionsData = await chunkW5TMS4RD_cjs.fetchUserPositions(
945
945
  rpc,
946
946
  ownerAddress,
947
947
  poolFilter,
@@ -986,7 +986,7 @@ function useUserPositions(poolFilter, options = {}) {
986
986
  refetch: fetchPositions
987
987
  };
988
988
  }
989
- function createCollectFeesInstruction(accounts, args, programId = chunkAT33RY6T_cjs.CPMM_PROGRAM_ID) {
989
+ function createCollectFeesInstruction(accounts, args, programId = chunk3BW6IVP3_cjs.CPMM_PROGRAM_ID) {
990
990
  const {
991
991
  pool,
992
992
  position,
@@ -998,7 +998,7 @@ function createCollectFeesInstruction(accounts, args, programId = chunkAT33RY6T_
998
998
  token1Mint,
999
999
  user0,
1000
1000
  user1,
1001
- tokenProgram = chunkAT33RY6T_cjs.TOKEN_PROGRAM_ADDRESS
1001
+ tokenProgram = chunk3BW6IVP3_cjs.TOKEN_PROGRAM_ADDRESS
1002
1002
  } = accounts;
1003
1003
  const keys = [
1004
1004
  { address: pool, role: kit.AccountRole.WRITABLE },
@@ -1013,9 +1013,9 @@ function createCollectFeesInstruction(accounts, args, programId = chunkAT33RY6T_
1013
1013
  { address: user1, role: kit.AccountRole.WRITABLE },
1014
1014
  { address: tokenProgram, role: kit.AccountRole.READONLY }
1015
1015
  ];
1016
- const data = chunkLL7TW3GU_cjs.encodeInstructionData(
1017
- chunkAT33RY6T_cjs.INSTRUCTION_DISCRIMINATORS.collectFees,
1018
- chunkLL7TW3GU_cjs.collectFeesArgsCodec,
1016
+ const data = chunkW5TMS4RD_cjs.encodeInstructionData(
1017
+ chunk3BW6IVP3_cjs.INSTRUCTION_DISCRIMINATORS.collectFees,
1018
+ chunkW5TMS4RD_cjs.collectFeesArgsCodec,
1019
1019
  args
1020
1020
  );
1021
1021
  return {
@@ -1057,7 +1057,7 @@ function useFees(positionAddress, poolAddress, options = {}) {
1057
1057
  }, [providedPool, providedPosition]);
1058
1058
  const fees = react.useMemo(() => {
1059
1059
  if (!pool || !position) return null;
1060
- const { pending0, pending1 } = chunkLL7TW3GU_cjs.getPendingFees(pool, position);
1060
+ const { pending0, pending1 } = chunkW5TMS4RD_cjs.getPendingFees(pool, position);
1061
1061
  return {
1062
1062
  pending0,
1063
1063
  pending1,
@@ -1084,13 +1084,13 @@ function useFees(positionAddress, poolAddress, options = {}) {
1084
1084
  const promises = [];
1085
1085
  if (!providedPosition && positionAddress) {
1086
1086
  promises.push(
1087
- chunkLL7TW3GU_cjs.fetchPosition(rpc, positionAddress, { programId, commitment })
1087
+ chunkW5TMS4RD_cjs.fetchPosition(rpc, positionAddress, { programId, commitment })
1088
1088
  );
1089
1089
  } else {
1090
1090
  promises.push(Promise.resolve(providedPosition));
1091
1091
  }
1092
1092
  if (!providedPool && poolAddress) {
1093
- promises.push(chunkLL7TW3GU_cjs.fetchPool(rpc, poolAddress, { programId, commitment }));
1093
+ promises.push(chunkW5TMS4RD_cjs.fetchPool(rpc, poolAddress, { programId, commitment }));
1094
1094
  } else {
1095
1095
  promises.push(Promise.resolve(providedPool));
1096
1096
  }
@@ -1243,7 +1243,7 @@ function useFees(positionAddress, poolAddress, options = {}) {
1243
1243
  function useFeesFromData(pool, position) {
1244
1244
  return react.useMemo(() => {
1245
1245
  if (!pool || !position) return null;
1246
- const { pending0, pending1 } = chunkLL7TW3GU_cjs.getPendingFees(pool, position);
1246
+ const { pending0, pending1 } = chunkW5TMS4RD_cjs.getPendingFees(pool, position);
1247
1247
  return {
1248
1248
  pending0,
1249
1249
  pending1,
@@ -1278,9 +1278,9 @@ function useOracle(poolAddress, options = {}) {
1278
1278
  setLoading(true);
1279
1279
  setError(null);
1280
1280
  try {
1281
- const [oracleAddr] = await chunkAT33RY6T_cjs.getOracleAddress(poolAddress, programId);
1281
+ const [oracleAddr] = await chunk3BW6IVP3_cjs.getOracleAddress(poolAddress, programId);
1282
1282
  setOracleAddress(oracleAddr);
1283
- const oracleData = await chunkLL7TW3GU_cjs.fetchOracle(rpc, oracleAddr, {
1283
+ const oracleData = await chunkW5TMS4RD_cjs.fetchOracle(rpc, oracleAddr, {
1284
1284
  programId,
1285
1285
  commitment
1286
1286
  });
@@ -1303,34 +1303,34 @@ function useOracle(poolAddress, options = {}) {
1303
1303
  const twap = react.useCallback(
1304
1304
  (windowSeconds) => {
1305
1305
  if (!oracle || !oracle.initialized) return null;
1306
- return chunkLL7TW3GU_cjs.consultTwap(oracle, windowSeconds);
1306
+ return chunkW5TMS4RD_cjs.consultTwap(oracle, windowSeconds);
1307
1307
  },
1308
1308
  [oracle]
1309
1309
  );
1310
1310
  const spotPrice = react.useMemo(() => {
1311
1311
  if (!oracle || !oracle.initialized) return null;
1312
- const prices = chunkLL7TW3GU_cjs.getOracleSpotPrices(oracle);
1312
+ const prices = chunkW5TMS4RD_cjs.getOracleSpotPrices(oracle);
1313
1313
  return { price0: prices.price0, price1: prices.price1 };
1314
1314
  }, [oracle]);
1315
1315
  const deviation = react.useMemo(() => {
1316
1316
  if (!oracle || !oracle.initialized) return null;
1317
- const dev = chunkLL7TW3GU_cjs.getOracleDeviation(oracle);
1317
+ const dev = chunkW5TMS4RD_cjs.getOracleDeviation(oracle);
1318
1318
  return { deviation0: dev.deviation0, deviation1: dev.deviation1 };
1319
1319
  }, [oracle]);
1320
1320
  const age = react.useMemo(() => {
1321
1321
  if (!oracle || !oracle.initialized) return null;
1322
- return chunkLL7TW3GU_cjs.getOracleAge(oracle);
1322
+ return chunkW5TMS4RD_cjs.getOracleAge(oracle);
1323
1323
  }, [oracle]);
1324
1324
  const isStaleCheck = react.useCallback(
1325
1325
  (maxAgeSeconds) => {
1326
1326
  if (!oracle || !oracle.initialized) return true;
1327
- return chunkLL7TW3GU_cjs.isOracleStale(oracle, maxAgeSeconds);
1327
+ return chunkW5TMS4RD_cjs.isOracleStale(oracle, maxAgeSeconds);
1328
1328
  },
1329
1329
  [oracle]
1330
1330
  );
1331
1331
  const bufferStats = react.useMemo(() => {
1332
1332
  if (!oracle || !oracle.initialized) return null;
1333
- const stats = chunkLL7TW3GU_cjs.getOracleBufferStats(oracle);
1333
+ const stats = chunkW5TMS4RD_cjs.getOracleBufferStats(oracle);
1334
1334
  return {
1335
1335
  capacity: stats.capacity,
1336
1336
  filledCount: stats.filledCount,
@@ -1341,7 +1341,7 @@ function useOracle(poolAddress, options = {}) {
1341
1341
  const compareWithPool = react.useCallback(
1342
1342
  (pool) => {
1343
1343
  if (!oracle || !oracle.initialized) return null;
1344
- return chunkLL7TW3GU_cjs.comparePoolAndOraclePrices(pool, oracle);
1344
+ return chunkW5TMS4RD_cjs.comparePoolAndOraclePrices(pool, oracle);
1345
1345
  },
1346
1346
  [oracle]
1347
1347
  );
@@ -1380,7 +1380,7 @@ function useTwap(poolAddress, windowSeconds, options = {}) {
1380
1380
  const { oracle, loading, error, refetch } = useOracle(poolAddress, options);
1381
1381
  const twap = react.useMemo(() => {
1382
1382
  if (!oracle || !oracle.initialized) return null;
1383
- return chunkLL7TW3GU_cjs.consultTwap(oracle, windowSeconds);
1383
+ return chunkW5TMS4RD_cjs.consultTwap(oracle, windowSeconds);
1384
1384
  }, [oracle, windowSeconds]);
1385
1385
  return {
1386
1386
  twap,
@@ -1419,7 +1419,7 @@ function useOracles(poolAddresses, options = {}) {
1419
1419
  const results = await Promise.all(
1420
1420
  poolAddresses.map(async (poolAddr) => {
1421
1421
  try {
1422
- const result = await chunkLL7TW3GU_cjs.getOracleForPool(rpc, poolAddr, {
1422
+ const result = await chunkW5TMS4RD_cjs.getOracleForPool(rpc, poolAddr, {
1423
1423
  programId,
1424
1424
  commitment
1425
1425
  });