@whetstone-research/doppler-sdk 1.0.10 → 1.0.12
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-YWZCHTXQ.js → chunk-2NFQKIOB.js} +6 -4
- package/dist/chunk-2NFQKIOB.js.map +1 -0
- package/dist/{chunk-O6FR7TXY.cjs → chunk-AT33RY6T.cjs} +7 -4
- package/dist/chunk-AT33RY6T.cjs.map +1 -0
- package/dist/{chunk-I5JME35L.cjs → chunk-LL7TW3GU.cjs} +36 -77
- package/dist/chunk-LL7TW3GU.cjs.map +1 -0
- package/dist/{chunk-RF4NM4ES.js → chunk-ZQEEGBXT.js} +5 -44
- package/dist/chunk-ZQEEGBXT.js.map +1 -0
- package/dist/{pda-NKKMVQ4N.js → pda-FLNTBIC5.js} +3 -3
- package/dist/pda-FLNTBIC5.js.map +1 -0
- package/dist/{pda-UKFLYQGA.cjs → pda-G25AJSXG.cjs} +16 -16
- package/dist/pda-G25AJSXG.cjs.map +1 -0
- package/dist/solana/index.cjs +3373 -815
- package/dist/solana/index.cjs.map +1 -1
- package/dist/solana/index.d.cts +1866 -1073
- package/dist/solana/index.d.ts +1866 -1073
- package/dist/solana/index.js +3237 -679
- package/dist/solana/index.js.map +1 -1
- package/dist/solana/react/index.cjs +84 -45
- package/dist/solana/react/index.cjs.map +1 -1
- package/dist/solana/react/index.js +43 -4
- package/dist/solana/react/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-I5JME35L.cjs.map +0 -1
- package/dist/chunk-O6FR7TXY.cjs.map +0 -1
- package/dist/chunk-RF4NM4ES.js.map +0 -1
- package/dist/chunk-YWZCHTXQ.js.map +0 -1
- package/dist/pda-NKKMVQ4N.js.map +0 -1
- package/dist/pda-UKFLYQGA.cjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkLL7TW3GU_cjs = require('../../chunk-LL7TW3GU.cjs');
|
|
4
|
+
var chunkAT33RY6T_cjs = require('../../chunk-AT33RY6T.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 = chunkAT33RY6T_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 ?? chunkAT33RY6T_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 chunkLL7TW3GU_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) => chunkLL7TW3GU_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 = 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;
|
|
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 } = chunkLL7TW3GU_cjs.getSwapQuoteExactOut(
|
|
547
547
|
pool,
|
|
548
548
|
state.outputAmount,
|
|
549
549
|
direction
|
|
550
550
|
);
|
|
551
|
-
const slippageFactor =
|
|
552
|
-
const maxAmountIn = amountIn * slippageFactor /
|
|
553
|
-
const forwardQuote =
|
|
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);
|
|
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: chunkLL7TW3GU_cjs.ratioToNumber(state.outputAmount, amountIn),
|
|
562
562
|
minAmountOut: state.outputAmount,
|
|
563
563
|
maxAmountIn,
|
|
564
564
|
direction,
|
|
@@ -683,13 +683,13 @@ function useLiquidity(options) {
|
|
|
683
683
|
};
|
|
684
684
|
}
|
|
685
685
|
try {
|
|
686
|
-
const quote =
|
|
686
|
+
const quote = chunkLL7TW3GU_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 = chunkAT33RY6T_cjs.BPS_DENOM - BigInt(addState.slippageBps);
|
|
692
|
+
const minSharesOut = quote.sharesOut * slippageFactor / chunkAT33RY6T_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 = 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;
|
|
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-G25AJSXG.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
|
+
chunkLL7TW3GU_cjs.fetchPosition(rpc, posAddr, { programId, commitment }),
|
|
856
|
+
providedPool ? Promise.resolve(providedPool) : chunkLL7TW3GU_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 chunkLL7TW3GU_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 chunkLL7TW3GU_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 chunkLL7TW3GU_cjs.fetchUserPositions(
|
|
945
945
|
rpc,
|
|
946
946
|
ownerAddress,
|
|
947
947
|
poolFilter,
|
|
@@ -986,6 +986,45 @@ function useUserPositions(poolFilter, options = {}) {
|
|
|
986
986
|
refetch: fetchPositions
|
|
987
987
|
};
|
|
988
988
|
}
|
|
989
|
+
function createCollectFeesInstruction(accounts, args, programId = chunkAT33RY6T_cjs.CPMM_PROGRAM_ID) {
|
|
990
|
+
const {
|
|
991
|
+
pool,
|
|
992
|
+
position,
|
|
993
|
+
owner,
|
|
994
|
+
authority,
|
|
995
|
+
vault0,
|
|
996
|
+
vault1,
|
|
997
|
+
token0Mint,
|
|
998
|
+
token1Mint,
|
|
999
|
+
user0,
|
|
1000
|
+
user1,
|
|
1001
|
+
tokenProgram = chunkAT33RY6T_cjs.TOKEN_PROGRAM_ADDRESS
|
|
1002
|
+
} = accounts;
|
|
1003
|
+
const keys = [
|
|
1004
|
+
{ address: pool, role: kit.AccountRole.WRITABLE },
|
|
1005
|
+
{ address: position, role: kit.AccountRole.WRITABLE },
|
|
1006
|
+
{ address: owner, role: kit.AccountRole.READONLY_SIGNER },
|
|
1007
|
+
{ address: authority, role: kit.AccountRole.READONLY },
|
|
1008
|
+
{ address: vault0, role: kit.AccountRole.WRITABLE },
|
|
1009
|
+
{ address: vault1, role: kit.AccountRole.WRITABLE },
|
|
1010
|
+
{ address: token0Mint, role: kit.AccountRole.READONLY },
|
|
1011
|
+
{ address: token1Mint, role: kit.AccountRole.READONLY },
|
|
1012
|
+
{ address: user0, role: kit.AccountRole.WRITABLE },
|
|
1013
|
+
{ address: user1, role: kit.AccountRole.WRITABLE },
|
|
1014
|
+
{ address: tokenProgram, role: kit.AccountRole.READONLY }
|
|
1015
|
+
];
|
|
1016
|
+
const data = chunkLL7TW3GU_cjs.encodeInstructionData(
|
|
1017
|
+
chunkAT33RY6T_cjs.INSTRUCTION_DISCRIMINATORS.collectFees,
|
|
1018
|
+
chunkLL7TW3GU_cjs.collectFeesArgsCodec,
|
|
1019
|
+
args
|
|
1020
|
+
);
|
|
1021
|
+
return {
|
|
1022
|
+
programAddress: programId,
|
|
1023
|
+
accounts: keys,
|
|
1024
|
+
data
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
var MAX_FEE_AMOUNT = BigInt("18446744073709551615");
|
|
989
1028
|
function useFees(positionAddress, poolAddress, options = {}) {
|
|
990
1029
|
const {
|
|
991
1030
|
rpc,
|
|
@@ -1018,7 +1057,7 @@ function useFees(positionAddress, poolAddress, options = {}) {
|
|
|
1018
1057
|
}, [providedPool, providedPosition]);
|
|
1019
1058
|
const fees = react.useMemo(() => {
|
|
1020
1059
|
if (!pool || !position) return null;
|
|
1021
|
-
const { pending0, pending1 } =
|
|
1060
|
+
const { pending0, pending1 } = chunkLL7TW3GU_cjs.getPendingFees(pool, position);
|
|
1022
1061
|
return {
|
|
1023
1062
|
pending0,
|
|
1024
1063
|
pending1,
|
|
@@ -1045,13 +1084,13 @@ function useFees(positionAddress, poolAddress, options = {}) {
|
|
|
1045
1084
|
const promises = [];
|
|
1046
1085
|
if (!providedPosition && positionAddress) {
|
|
1047
1086
|
promises.push(
|
|
1048
|
-
|
|
1087
|
+
chunkLL7TW3GU_cjs.fetchPosition(rpc, positionAddress, { programId, commitment })
|
|
1049
1088
|
);
|
|
1050
1089
|
} else {
|
|
1051
1090
|
promises.push(Promise.resolve(providedPosition));
|
|
1052
1091
|
}
|
|
1053
1092
|
if (!providedPool && poolAddress) {
|
|
1054
|
-
promises.push(
|
|
1093
|
+
promises.push(chunkLL7TW3GU_cjs.fetchPool(rpc, poolAddress, { programId, commitment }));
|
|
1055
1094
|
} else {
|
|
1056
1095
|
promises.push(Promise.resolve(providedPool));
|
|
1057
1096
|
}
|
|
@@ -1097,12 +1136,12 @@ function useFees(positionAddress, poolAddress, options = {}) {
|
|
|
1097
1136
|
setTxSignature(null);
|
|
1098
1137
|
try {
|
|
1099
1138
|
const {
|
|
1100
|
-
max0 =
|
|
1101
|
-
max1 =
|
|
1139
|
+
max0 = MAX_FEE_AMOUNT,
|
|
1140
|
+
max1 = MAX_FEE_AMOUNT,
|
|
1102
1141
|
userToken0,
|
|
1103
1142
|
userToken1
|
|
1104
1143
|
} = collectOptions;
|
|
1105
|
-
const ix =
|
|
1144
|
+
const ix = createCollectFeesInstruction(
|
|
1106
1145
|
{
|
|
1107
1146
|
pool: poolAddress,
|
|
1108
1147
|
position: positionAddress,
|
|
@@ -1204,7 +1243,7 @@ function useFees(positionAddress, poolAddress, options = {}) {
|
|
|
1204
1243
|
function useFeesFromData(pool, position) {
|
|
1205
1244
|
return react.useMemo(() => {
|
|
1206
1245
|
if (!pool || !position) return null;
|
|
1207
|
-
const { pending0, pending1 } =
|
|
1246
|
+
const { pending0, pending1 } = chunkLL7TW3GU_cjs.getPendingFees(pool, position);
|
|
1208
1247
|
return {
|
|
1209
1248
|
pending0,
|
|
1210
1249
|
pending1,
|
|
@@ -1239,9 +1278,9 @@ function useOracle(poolAddress, options = {}) {
|
|
|
1239
1278
|
setLoading(true);
|
|
1240
1279
|
setError(null);
|
|
1241
1280
|
try {
|
|
1242
|
-
const [oracleAddr] = await
|
|
1281
|
+
const [oracleAddr] = await chunkAT33RY6T_cjs.getOracleAddress(poolAddress, programId);
|
|
1243
1282
|
setOracleAddress(oracleAddr);
|
|
1244
|
-
const oracleData = await
|
|
1283
|
+
const oracleData = await chunkLL7TW3GU_cjs.fetchOracle(rpc, oracleAddr, {
|
|
1245
1284
|
programId,
|
|
1246
1285
|
commitment
|
|
1247
1286
|
});
|
|
@@ -1264,34 +1303,34 @@ function useOracle(poolAddress, options = {}) {
|
|
|
1264
1303
|
const twap = react.useCallback(
|
|
1265
1304
|
(windowSeconds) => {
|
|
1266
1305
|
if (!oracle || !oracle.initialized) return null;
|
|
1267
|
-
return
|
|
1306
|
+
return chunkLL7TW3GU_cjs.consultTwap(oracle, windowSeconds);
|
|
1268
1307
|
},
|
|
1269
1308
|
[oracle]
|
|
1270
1309
|
);
|
|
1271
1310
|
const spotPrice = react.useMemo(() => {
|
|
1272
1311
|
if (!oracle || !oracle.initialized) return null;
|
|
1273
|
-
const prices =
|
|
1312
|
+
const prices = chunkLL7TW3GU_cjs.getOracleSpotPrices(oracle);
|
|
1274
1313
|
return { price0: prices.price0, price1: prices.price1 };
|
|
1275
1314
|
}, [oracle]);
|
|
1276
1315
|
const deviation = react.useMemo(() => {
|
|
1277
1316
|
if (!oracle || !oracle.initialized) return null;
|
|
1278
|
-
const dev =
|
|
1317
|
+
const dev = chunkLL7TW3GU_cjs.getOracleDeviation(oracle);
|
|
1279
1318
|
return { deviation0: dev.deviation0, deviation1: dev.deviation1 };
|
|
1280
1319
|
}, [oracle]);
|
|
1281
1320
|
const age = react.useMemo(() => {
|
|
1282
1321
|
if (!oracle || !oracle.initialized) return null;
|
|
1283
|
-
return
|
|
1322
|
+
return chunkLL7TW3GU_cjs.getOracleAge(oracle);
|
|
1284
1323
|
}, [oracle]);
|
|
1285
1324
|
const isStaleCheck = react.useCallback(
|
|
1286
1325
|
(maxAgeSeconds) => {
|
|
1287
1326
|
if (!oracle || !oracle.initialized) return true;
|
|
1288
|
-
return
|
|
1327
|
+
return chunkLL7TW3GU_cjs.isOracleStale(oracle, maxAgeSeconds);
|
|
1289
1328
|
},
|
|
1290
1329
|
[oracle]
|
|
1291
1330
|
);
|
|
1292
1331
|
const bufferStats = react.useMemo(() => {
|
|
1293
1332
|
if (!oracle || !oracle.initialized) return null;
|
|
1294
|
-
const stats =
|
|
1333
|
+
const stats = chunkLL7TW3GU_cjs.getOracleBufferStats(oracle);
|
|
1295
1334
|
return {
|
|
1296
1335
|
capacity: stats.capacity,
|
|
1297
1336
|
filledCount: stats.filledCount,
|
|
@@ -1302,7 +1341,7 @@ function useOracle(poolAddress, options = {}) {
|
|
|
1302
1341
|
const compareWithPool = react.useCallback(
|
|
1303
1342
|
(pool) => {
|
|
1304
1343
|
if (!oracle || !oracle.initialized) return null;
|
|
1305
|
-
return
|
|
1344
|
+
return chunkLL7TW3GU_cjs.comparePoolAndOraclePrices(pool, oracle);
|
|
1306
1345
|
},
|
|
1307
1346
|
[oracle]
|
|
1308
1347
|
);
|
|
@@ -1341,7 +1380,7 @@ function useTwap(poolAddress, windowSeconds, options = {}) {
|
|
|
1341
1380
|
const { oracle, loading, error, refetch } = useOracle(poolAddress, options);
|
|
1342
1381
|
const twap = react.useMemo(() => {
|
|
1343
1382
|
if (!oracle || !oracle.initialized) return null;
|
|
1344
|
-
return
|
|
1383
|
+
return chunkLL7TW3GU_cjs.consultTwap(oracle, windowSeconds);
|
|
1345
1384
|
}, [oracle, windowSeconds]);
|
|
1346
1385
|
return {
|
|
1347
1386
|
twap,
|
|
@@ -1380,7 +1419,7 @@ function useOracles(poolAddresses, options = {}) {
|
|
|
1380
1419
|
const results = await Promise.all(
|
|
1381
1420
|
poolAddresses.map(async (poolAddr) => {
|
|
1382
1421
|
try {
|
|
1383
|
-
const result = await
|
|
1422
|
+
const result = await chunkLL7TW3GU_cjs.getOracleForPool(rpc, poolAddr, {
|
|
1384
1423
|
programId,
|
|
1385
1424
|
commitment
|
|
1386
1425
|
});
|