@whetstone-research/doppler-sdk 1.0.27 → 1.0.28
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-XTL2GBZ4.cjs → chunk-4WY5GNZD.cjs} +108 -60
- package/dist/chunk-4WY5GNZD.cjs.map +1 -0
- package/dist/{chunk-RVDRWCJN.js → chunk-AYVFWD5P.js} +99 -62
- package/dist/chunk-AYVFWD5P.js.map +1 -0
- package/dist/evm/index.cjs +243 -175
- package/dist/evm/index.cjs.map +1 -1
- package/dist/evm/index.d.cts +36 -60
- package/dist/evm/index.d.ts +36 -60
- package/dist/evm/index.js +244 -176
- package/dist/evm/index.js.map +1 -1
- package/dist/solana/index.cjs +1967 -651
- package/dist/solana/index.cjs.map +1 -1
- package/dist/solana/index.d.cts +1458 -786
- package/dist/solana/index.d.ts +1458 -786
- package/dist/solana/index.js +1686 -376
- package/dist/solana/index.js.map +1 -1
- package/dist/solana/react/index.cjs +29 -29
- package/dist/solana/react/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-RVDRWCJN.js.map +0 -1
- package/dist/chunk-XTL2GBZ4.cjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk4WY5GNZD_cjs = require('../../chunk-4WY5GNZD.cjs');
|
|
4
4
|
var chunkU6B52TBT_cjs = require('../../chunk-U6B52TBT.cjs');
|
|
5
5
|
require('../../chunk-Q7SFCCGT.cjs');
|
|
6
6
|
var react = require('react');
|
|
@@ -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 chunk4WY5GNZD_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) => chunk4WY5GNZD_cjs.fetchPool(rpc, addr, { programId, commitment }).then((pool) => [addr, pool]).catch(() => [addr, null])
|
|
415
415
|
)
|
|
416
416
|
);
|
|
417
417
|
if (mountedRef.current) {
|
|
@@ -500,7 +500,7 @@ function useSwap(options) {
|
|
|
500
500
|
};
|
|
501
501
|
}
|
|
502
502
|
try {
|
|
503
|
-
const swapQuote =
|
|
503
|
+
const swapQuote = chunk4WY5GNZD_cjs.getSwapQuote(pool, state.inputAmount, tradeDirection);
|
|
504
504
|
const slippageFactor = chunkU6B52TBT_cjs.BPS_DENOM - BigInt(state.slippageBps);
|
|
505
505
|
const minAmountOut = swapQuote.amountOut * slippageFactor / chunkU6B52TBT_cjs.BPS_DENOM;
|
|
506
506
|
return {
|
|
@@ -543,14 +543,14 @@ function useSwap(options) {
|
|
|
543
543
|
};
|
|
544
544
|
}
|
|
545
545
|
try {
|
|
546
|
-
const { amountIn, feeTotal } =
|
|
546
|
+
const { amountIn, feeTotal } = chunk4WY5GNZD_cjs.getSwapQuoteExactOut(
|
|
547
547
|
pool,
|
|
548
548
|
state.outputAmount,
|
|
549
549
|
tradeDirection
|
|
550
550
|
);
|
|
551
551
|
const slippageFactor = chunkU6B52TBT_cjs.BPS_DENOM + BigInt(state.slippageBps);
|
|
552
552
|
const maxAmountIn = amountIn * slippageFactor / chunkU6B52TBT_cjs.BPS_DENOM;
|
|
553
|
-
const forwardQuote =
|
|
553
|
+
const forwardQuote = chunk4WY5GNZD_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: chunk4WY5GNZD_cjs.ratioToNumber(state.outputAmount, amountIn),
|
|
562
562
|
minAmountOut: state.outputAmount,
|
|
563
563
|
maxAmountIn,
|
|
564
564
|
tradeDirection,
|
|
@@ -683,7 +683,7 @@ function useLiquidity(options) {
|
|
|
683
683
|
};
|
|
684
684
|
}
|
|
685
685
|
try {
|
|
686
|
-
const quote =
|
|
686
|
+
const quote = chunk4WY5GNZD_cjs.getAddLiquidityQuote(
|
|
687
687
|
pool,
|
|
688
688
|
addState.amount0,
|
|
689
689
|
addState.amount1
|
|
@@ -723,7 +723,7 @@ function useLiquidity(options) {
|
|
|
723
723
|
};
|
|
724
724
|
}
|
|
725
725
|
try {
|
|
726
|
-
const quote =
|
|
726
|
+
const quote = chunk4WY5GNZD_cjs.getRemoveLiquidityQuote(pool, removeState.shares);
|
|
727
727
|
const slippageFactor = chunkU6B52TBT_cjs.BPS_DENOM - BigInt(removeState.slippageBps);
|
|
728
728
|
const minAmount0Out = quote.amount0 * slippageFactor / chunkU6B52TBT_cjs.BPS_DENOM;
|
|
729
729
|
const minAmount1Out = quote.amount1 * slippageFactor / chunkU6B52TBT_cjs.BPS_DENOM;
|
|
@@ -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
|
+
chunk4WY5GNZD_cjs.fetchPosition(rpc, posAddr, { programId, commitment }),
|
|
856
|
+
providedPool ? Promise.resolve(providedPool) : chunk4WY5GNZD_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 chunk4WY5GNZD_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 chunk4WY5GNZD_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 chunk4WY5GNZD_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 } = chunk4WY5GNZD_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
|
+
chunk4WY5GNZD_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(chunk4WY5GNZD_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 = chunk4WY5GNZD_cjs.getCollectFeesInstruction(
|
|
1110
1110
|
{
|
|
1111
1111
|
pool: poolAddress,
|
|
1112
1112
|
position: positionAddress,
|
|
@@ -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 } = chunk4WY5GNZD_cjs.getPendingFees(pool, position);
|
|
1215
1215
|
return {
|
|
1216
1216
|
pending0,
|
|
1217
1217
|
pending1,
|
|
@@ -1248,7 +1248,7 @@ function useOracle(poolAddress, options = {}) {
|
|
|
1248
1248
|
try {
|
|
1249
1249
|
const [oracleAddr] = await chunkU6B52TBT_cjs.getOracleAddress(poolAddress, programId);
|
|
1250
1250
|
setOracleAddress(oracleAddr);
|
|
1251
|
-
const oracleData = await
|
|
1251
|
+
const oracleData = await chunk4WY5GNZD_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 chunk4WY5GNZD_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 = chunk4WY5GNZD_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 = chunk4WY5GNZD_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 chunk4WY5GNZD_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 chunk4WY5GNZD_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 = chunk4WY5GNZD_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 chunk4WY5GNZD_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 chunk4WY5GNZD_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 chunk4WY5GNZD_cjs.getOracleForPool(rpc, poolAddr, {
|
|
1391
1391
|
programId,
|
|
1392
1392
|
commitment
|
|
1393
1393
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { fetchPool, getSwapQuote, getSwapQuoteExactOut, ratioToNumber, getAddLiquidityQuote, getRemoveLiquidityQuote, fetchPosition, getPendingFees, getPositionValue, fetchUserPositions, getCollectFeesInstruction, fetchOracle, consultTwap, getOracleSpotPrices, getOracleDeviation, getOracleAge, isOracleStale, getOracleBufferStats, comparePoolAndOraclePrices, getOracleForPool } 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-AYVFWD5P.js';
|
|
2
2
|
import { CPMM_PROGRAM_ID, BPS_DENOM, TOKEN_PROGRAM_ADDRESS, getOracleAddress } from '../../chunk-WD5VOZGI.js';
|
|
3
3
|
import '../../chunk-PZ5AY32C.js';
|
|
4
4
|
import { createContext, useMemo, useContext, useState, useEffect, useCallback, useRef } from 'react';
|