@whetstone-research/doppler-sdk 1.0.28 → 1.0.30
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/{chunk-U6B52TBT.cjs → chunk-4CI2M2F6.cjs} +27 -2
- package/dist/chunk-4CI2M2F6.cjs.map +1 -0
- package/dist/{chunk-4WY5GNZD.cjs → chunk-7PXLEMBJ.cjs} +336 -36
- package/dist/chunk-7PXLEMBJ.cjs.map +1 -0
- package/dist/{chunk-WD5VOZGI.js → chunk-AFXFT3BD.js} +24 -3
- package/dist/chunk-AFXFT3BD.js.map +1 -0
- package/dist/{chunk-AYVFWD5P.js → chunk-PSLY7M7C.js} +296 -4
- package/dist/chunk-PSLY7M7C.js.map +1 -0
- package/dist/{pda-H6VMGONM.cjs → pda-44IHEORD.cjs} +21 -17
- package/dist/pda-44IHEORD.cjs.map +1 -0
- package/dist/{pda-UJLXCO6I.js → pda-WJVDXQPW.js} +3 -3
- package/dist/pda-WJVDXQPW.js.map +1 -0
- package/dist/solana/index.cjs +1408 -1963
- package/dist/solana/index.cjs.map +1 -1
- package/dist/solana/index.d.cts +1294 -1376
- package/dist/solana/index.d.ts +1294 -1376
- package/dist/solana/index.js +1008 -1562
- package/dist/solana/index.js.map +1 -1
- package/dist/solana/react/index.cjs +45 -45
- package/dist/solana/react/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-4WY5GNZD.cjs.map +0 -1
- package/dist/chunk-AYVFWD5P.js.map +0 -1
- package/dist/chunk-U6B52TBT.cjs.map +0 -1
- package/dist/chunk-WD5VOZGI.js.map +0 -1
- package/dist/pda-H6VMGONM.cjs.map +0 -1
- package/dist/pda-UJLXCO6I.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunk7PXLEMBJ_cjs = require('../../chunk-7PXLEMBJ.cjs');
|
|
4
|
+
var chunk4CI2M2F6_cjs = require('../../chunk-4CI2M2F6.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 =
|
|
13
|
+
programId = chunk4CI2M2F6_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 ??
|
|
94
|
+
programId: programId ?? chunk4CI2M2F6_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
|
|
336
|
+
const poolData = await chunk7PXLEMBJ_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) =>
|
|
414
|
+
(addr) => chunk7PXLEMBJ_cjs.fetchPool(rpc, addr, { programId, commitment }).then((pool) => [addr, pool]).catch(() => [addr, null])
|
|
415
415
|
)
|
|
416
416
|
);
|
|
417
417
|
if (mountedRef.current) {
|
|
@@ -500,9 +500,9 @@ function useSwap(options) {
|
|
|
500
500
|
};
|
|
501
501
|
}
|
|
502
502
|
try {
|
|
503
|
-
const swapQuote =
|
|
504
|
-
const slippageFactor =
|
|
505
|
-
const minAmountOut = swapQuote.amountOut * slippageFactor /
|
|
503
|
+
const swapQuote = chunk7PXLEMBJ_cjs.getSwapQuote(pool, state.inputAmount, tradeDirection);
|
|
504
|
+
const slippageFactor = chunk4CI2M2F6_cjs.BPS_DENOM - BigInt(state.slippageBps);
|
|
505
|
+
const minAmountOut = swapQuote.amountOut * slippageFactor / chunk4CI2M2F6_cjs.BPS_DENOM;
|
|
506
506
|
return {
|
|
507
507
|
...swapQuote,
|
|
508
508
|
minAmountOut,
|
|
@@ -543,14 +543,14 @@ function useSwap(options) {
|
|
|
543
543
|
};
|
|
544
544
|
}
|
|
545
545
|
try {
|
|
546
|
-
const { amountIn, feeTotal } =
|
|
546
|
+
const { amountIn, feeTotal } = chunk7PXLEMBJ_cjs.getSwapQuoteExactOut(
|
|
547
547
|
pool,
|
|
548
548
|
state.outputAmount,
|
|
549
549
|
tradeDirection
|
|
550
550
|
);
|
|
551
|
-
const slippageFactor =
|
|
552
|
-
const maxAmountIn = amountIn * slippageFactor /
|
|
553
|
-
const forwardQuote =
|
|
551
|
+
const slippageFactor = chunk4CI2M2F6_cjs.BPS_DENOM + BigInt(state.slippageBps);
|
|
552
|
+
const maxAmountIn = amountIn * slippageFactor / chunk4CI2M2F6_cjs.BPS_DENOM;
|
|
553
|
+
const forwardQuote = chunk7PXLEMBJ_cjs.getSwapQuote(pool, amountIn, tradeDirection);
|
|
554
554
|
return {
|
|
555
555
|
amountOut: state.outputAmount,
|
|
556
556
|
feeTotal,
|
|
@@ -558,7 +558,7 @@ function useSwap(options) {
|
|
|
558
558
|
// Not calculated for exact out
|
|
559
559
|
feeComp: 0n,
|
|
560
560
|
priceImpact: forwardQuote.priceImpact,
|
|
561
|
-
executionPrice:
|
|
561
|
+
executionPrice: chunk7PXLEMBJ_cjs.ratioToNumber(state.outputAmount, amountIn),
|
|
562
562
|
minAmountOut: state.outputAmount,
|
|
563
563
|
maxAmountIn,
|
|
564
564
|
tradeDirection,
|
|
@@ -683,13 +683,13 @@ function useLiquidity(options) {
|
|
|
683
683
|
};
|
|
684
684
|
}
|
|
685
685
|
try {
|
|
686
|
-
const quote =
|
|
686
|
+
const quote = chunk7PXLEMBJ_cjs.getAddLiquidityQuote(
|
|
687
687
|
pool,
|
|
688
688
|
addState.amount0,
|
|
689
689
|
addState.amount1
|
|
690
690
|
);
|
|
691
|
-
const slippageFactor =
|
|
692
|
-
const minSharesOut = quote.sharesOut * slippageFactor /
|
|
691
|
+
const slippageFactor = chunk4CI2M2F6_cjs.BPS_DENOM - BigInt(addState.slippageBps);
|
|
692
|
+
const minSharesOut = quote.sharesOut * slippageFactor / chunk4CI2M2F6_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 =
|
|
727
|
-
const slippageFactor =
|
|
728
|
-
const minAmount0Out = quote.amount0 * slippageFactor /
|
|
729
|
-
const minAmount1Out = quote.amount1 * slippageFactor /
|
|
726
|
+
const quote = chunk7PXLEMBJ_cjs.getRemoveLiquidityQuote(pool, removeState.shares);
|
|
727
|
+
const slippageFactor = chunk4CI2M2F6_cjs.BPS_DENOM - BigInt(removeState.slippageBps);
|
|
728
|
+
const minAmount0Out = quote.amount0 * slippageFactor / chunk4CI2M2F6_cjs.BPS_DENOM;
|
|
729
|
+
const minAmount1Out = quote.amount1 * slippageFactor / chunk4CI2M2F6_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-
|
|
846
|
+
const { getPositionAddress } = await import('../../pda-44IHEORD.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
|
-
|
|
856
|
-
providedPool ? Promise.resolve(providedPool) :
|
|
855
|
+
chunk7PXLEMBJ_cjs.fetchPosition(rpc, posAddr, { programId, commitment }),
|
|
856
|
+
providedPool ? Promise.resolve(providedPool) : chunk7PXLEMBJ_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
|
|
885
|
+
return chunk7PXLEMBJ_cjs.getPendingFees(pool, position);
|
|
886
886
|
}, [pool, position]);
|
|
887
887
|
const value = react.useMemo(() => {
|
|
888
888
|
if (!pool || !position) return null;
|
|
889
|
-
return
|
|
889
|
+
return chunk7PXLEMBJ_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
|
|
944
|
+
const positionsData = await chunk7PXLEMBJ_cjs.fetchUserPositions(
|
|
945
945
|
rpc,
|
|
946
946
|
ownerAddress,
|
|
947
947
|
poolFilter,
|
|
@@ -1019,7 +1019,7 @@ function useFees(positionAddress, poolAddress, options = {}) {
|
|
|
1019
1019
|
}, [providedPool, providedPosition]);
|
|
1020
1020
|
const fees = react.useMemo(() => {
|
|
1021
1021
|
if (!pool || !position) return null;
|
|
1022
|
-
const { pending0, pending1 } =
|
|
1022
|
+
const { pending0, pending1 } = chunk7PXLEMBJ_cjs.getPendingFees(pool, position);
|
|
1023
1023
|
return {
|
|
1024
1024
|
pending0,
|
|
1025
1025
|
pending1,
|
|
@@ -1046,13 +1046,13 @@ function useFees(positionAddress, poolAddress, options = {}) {
|
|
|
1046
1046
|
const promises = [];
|
|
1047
1047
|
if (!providedPosition && positionAddress) {
|
|
1048
1048
|
promises.push(
|
|
1049
|
-
|
|
1049
|
+
chunk7PXLEMBJ_cjs.fetchPosition(rpc, positionAddress, { programId, commitment })
|
|
1050
1050
|
);
|
|
1051
1051
|
} else {
|
|
1052
1052
|
promises.push(Promise.resolve(providedPosition));
|
|
1053
1053
|
}
|
|
1054
1054
|
if (!providedPool && poolAddress) {
|
|
1055
|
-
promises.push(
|
|
1055
|
+
promises.push(chunk7PXLEMBJ_cjs.fetchPool(rpc, poolAddress, { programId, commitment }));
|
|
1056
1056
|
} else {
|
|
1057
1057
|
promises.push(Promise.resolve(providedPool));
|
|
1058
1058
|
}
|
|
@@ -1106,7 +1106,7 @@ function useFees(positionAddress, poolAddress, options = {}) {
|
|
|
1106
1106
|
userToken0,
|
|
1107
1107
|
userToken1
|
|
1108
1108
|
} = collectOptions;
|
|
1109
|
-
const ix =
|
|
1109
|
+
const ix = chunk7PXLEMBJ_cjs.getCollectFeesInstruction(
|
|
1110
1110
|
{
|
|
1111
1111
|
pool: poolAddress,
|
|
1112
1112
|
position: positionAddress,
|
|
@@ -1118,8 +1118,8 @@ function useFees(positionAddress, poolAddress, options = {}) {
|
|
|
1118
1118
|
token1Mint: pool.token1Mint,
|
|
1119
1119
|
user0: userToken0,
|
|
1120
1120
|
user1: userToken1,
|
|
1121
|
-
token0Program: token0Program ?? tokenProgram ??
|
|
1122
|
-
token1Program: token1Program ?? tokenProgram ??
|
|
1121
|
+
token0Program: token0Program ?? tokenProgram ?? chunk4CI2M2F6_cjs.TOKEN_PROGRAM_ADDRESS,
|
|
1122
|
+
token1Program: token1Program ?? tokenProgram ?? chunk4CI2M2F6_cjs.TOKEN_PROGRAM_ADDRESS,
|
|
1123
1123
|
max0,
|
|
1124
1124
|
max1
|
|
1125
1125
|
},
|
|
@@ -1211,7 +1211,7 @@ function useFees(positionAddress, poolAddress, options = {}) {
|
|
|
1211
1211
|
function useFeesFromData(pool, position) {
|
|
1212
1212
|
return react.useMemo(() => {
|
|
1213
1213
|
if (!pool || !position) return null;
|
|
1214
|
-
const { pending0, pending1 } =
|
|
1214
|
+
const { pending0, pending1 } = chunk7PXLEMBJ_cjs.getPendingFees(pool, position);
|
|
1215
1215
|
return {
|
|
1216
1216
|
pending0,
|
|
1217
1217
|
pending1,
|
|
@@ -1246,9 +1246,9 @@ function useOracle(poolAddress, options = {}) {
|
|
|
1246
1246
|
setLoading(true);
|
|
1247
1247
|
setError(null);
|
|
1248
1248
|
try {
|
|
1249
|
-
const [oracleAddr] = await
|
|
1249
|
+
const [oracleAddr] = await chunk4CI2M2F6_cjs.getOracleAddress(poolAddress, programId);
|
|
1250
1250
|
setOracleAddress(oracleAddr);
|
|
1251
|
-
const oracleData = await
|
|
1251
|
+
const oracleData = await chunk7PXLEMBJ_cjs.fetchOracle(rpc, oracleAddr, {
|
|
1252
1252
|
programId,
|
|
1253
1253
|
commitment
|
|
1254
1254
|
});
|
|
@@ -1271,34 +1271,34 @@ function useOracle(poolAddress, options = {}) {
|
|
|
1271
1271
|
const twap = react.useCallback(
|
|
1272
1272
|
(windowSeconds) => {
|
|
1273
1273
|
if (!oracle || !oracle.initialized) return null;
|
|
1274
|
-
return
|
|
1274
|
+
return chunk7PXLEMBJ_cjs.consultTwap(oracle, windowSeconds);
|
|
1275
1275
|
},
|
|
1276
1276
|
[oracle]
|
|
1277
1277
|
);
|
|
1278
1278
|
const spotPrice = react.useMemo(() => {
|
|
1279
1279
|
if (!oracle || !oracle.initialized) return null;
|
|
1280
|
-
const prices =
|
|
1280
|
+
const prices = chunk7PXLEMBJ_cjs.getOracleSpotPrices(oracle);
|
|
1281
1281
|
return { price0: prices.price0, price1: prices.price1 };
|
|
1282
1282
|
}, [oracle]);
|
|
1283
1283
|
const deviation = react.useMemo(() => {
|
|
1284
1284
|
if (!oracle || !oracle.initialized) return null;
|
|
1285
|
-
const dev =
|
|
1285
|
+
const dev = chunk7PXLEMBJ_cjs.getOracleDeviation(oracle);
|
|
1286
1286
|
return { deviation0: dev.deviation0, deviation1: dev.deviation1 };
|
|
1287
1287
|
}, [oracle]);
|
|
1288
1288
|
const age = react.useMemo(() => {
|
|
1289
1289
|
if (!oracle || !oracle.initialized) return null;
|
|
1290
|
-
return
|
|
1290
|
+
return chunk7PXLEMBJ_cjs.getOracleAge(oracle);
|
|
1291
1291
|
}, [oracle]);
|
|
1292
1292
|
const isStaleCheck = react.useCallback(
|
|
1293
1293
|
(maxAgeSeconds) => {
|
|
1294
1294
|
if (!oracle || !oracle.initialized) return true;
|
|
1295
|
-
return
|
|
1295
|
+
return chunk7PXLEMBJ_cjs.isOracleStale(oracle, maxAgeSeconds);
|
|
1296
1296
|
},
|
|
1297
1297
|
[oracle]
|
|
1298
1298
|
);
|
|
1299
1299
|
const bufferStats = react.useMemo(() => {
|
|
1300
1300
|
if (!oracle || !oracle.initialized) return null;
|
|
1301
|
-
const stats =
|
|
1301
|
+
const stats = chunk7PXLEMBJ_cjs.getOracleBufferStats(oracle);
|
|
1302
1302
|
return {
|
|
1303
1303
|
capacity: stats.capacity,
|
|
1304
1304
|
filledCount: stats.filledCount,
|
|
@@ -1309,7 +1309,7 @@ function useOracle(poolAddress, options = {}) {
|
|
|
1309
1309
|
const compareWithPool = react.useCallback(
|
|
1310
1310
|
(pool) => {
|
|
1311
1311
|
if (!oracle || !oracle.initialized) return null;
|
|
1312
|
-
return
|
|
1312
|
+
return chunk7PXLEMBJ_cjs.comparePoolAndOraclePrices(pool, oracle);
|
|
1313
1313
|
},
|
|
1314
1314
|
[oracle]
|
|
1315
1315
|
);
|
|
@@ -1348,7 +1348,7 @@ function useTwap(poolAddress, windowSeconds, options = {}) {
|
|
|
1348
1348
|
const { oracle, loading, error, refetch } = useOracle(poolAddress, options);
|
|
1349
1349
|
const twap = react.useMemo(() => {
|
|
1350
1350
|
if (!oracle || !oracle.initialized) return null;
|
|
1351
|
-
return
|
|
1351
|
+
return chunk7PXLEMBJ_cjs.consultTwap(oracle, windowSeconds);
|
|
1352
1352
|
}, [oracle, windowSeconds]);
|
|
1353
1353
|
return {
|
|
1354
1354
|
twap,
|
|
@@ -1387,7 +1387,7 @@ function useOracles(poolAddresses, options = {}) {
|
|
|
1387
1387
|
const results = await Promise.all(
|
|
1388
1388
|
poolAddresses.map(async (poolAddr) => {
|
|
1389
1389
|
try {
|
|
1390
|
-
const result = await
|
|
1390
|
+
const result = await chunk7PXLEMBJ_cjs.getOracleForPool(rpc, poolAddr, {
|
|
1391
1391
|
programId,
|
|
1392
1392
|
commitment
|
|
1393
1393
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { fetchPool, getSwapQuote, getSwapQuoteExactOut, ratioToNumber, getAddLiquidityQuote, getRemoveLiquidityQuote, fetchPosition, getPendingFees, getPositionValue, fetchUserPositions, getCollectFeesInstruction, fetchOracle, consultTwap, getOracleSpotPrices, getOracleDeviation, getOracleAge, isOracleStale, getOracleBufferStats, comparePoolAndOraclePrices, getOracleForPool } from '../../chunk-
|
|
2
|
-
import { CPMM_PROGRAM_ID, BPS_DENOM, TOKEN_PROGRAM_ADDRESS, getOracleAddress } from '../../chunk-
|
|
1
|
+
import { fetchPool, getSwapQuote, getSwapQuoteExactOut, ratioToNumber, getAddLiquidityQuote, getRemoveLiquidityQuote, fetchPosition, getPendingFees, getPositionValue, fetchUserPositions, getCollectFeesInstruction, fetchOracle, consultTwap, getOracleSpotPrices, getOracleDeviation, getOracleAge, isOracleStale, getOracleBufferStats, comparePoolAndOraclePrices, getOracleForPool } from '../../chunk-PSLY7M7C.js';
|
|
2
|
+
import { CPMM_PROGRAM_ID, BPS_DENOM, TOKEN_PROGRAM_ADDRESS, getOracleAddress } from '../../chunk-AFXFT3BD.js';
|
|
3
3
|
import '../../chunk-PZ5AY32C.js';
|
|
4
4
|
import { createContext, useMemo, useContext, useState, useEffect, useCallback, useRef } from 'react';
|
|
5
5
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -841,7 +841,7 @@ function usePosition(poolAddress, positionId = 0n, options = {}) {
|
|
|
841
841
|
setLoading(true);
|
|
842
842
|
setError(null);
|
|
843
843
|
try {
|
|
844
|
-
const { getPositionAddress } = await import('../../pda-
|
|
844
|
+
const { getPositionAddress } = await import('../../pda-WJVDXQPW.js');
|
|
845
845
|
const [posAddr] = await getPositionAddress(
|
|
846
846
|
poolAddress,
|
|
847
847
|
ownerAddress,
|