@whetstone-research/doppler-sdk 1.0.13 → 1.0.14
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/README.md +48 -12
- package/dist/{chunk-AT33RY6T.cjs → chunk-3BW6IVP3.cjs} +46 -37
- package/dist/chunk-3BW6IVP3.cjs.map +1 -0
- package/dist/{chunk-ZQEEGBXT.js → chunk-NMTYI3TB.js} +23 -26
- package/dist/chunk-NMTYI3TB.js.map +1 -0
- package/dist/{chunk-2NFQKIOB.js → chunk-TVBSIQIX.js} +35 -26
- package/dist/chunk-TVBSIQIX.js.map +1 -0
- package/dist/{chunk-LL7TW3GU.cjs → chunk-W5TMS4RD.cjs} +56 -59
- package/dist/chunk-W5TMS4RD.cjs.map +1 -0
- package/dist/{oracle-CU-nZnja.d.cts → oracle-DN8BrGPh.d.cts} +28 -28
- package/dist/{oracle-CU-nZnja.d.ts → oracle-DN8BrGPh.d.ts} +28 -28
- package/dist/{pda-FLNTBIC5.js → pda-5D3GD5S6.js} +3 -3
- package/dist/pda-5D3GD5S6.js.map +1 -0
- package/dist/{pda-G25AJSXG.cjs → pda-GNZYNRUH.cjs} +17 -17
- package/dist/{pda-G25AJSXG.cjs.map → pda-GNZYNRUH.cjs.map} +1 -1
- package/dist/solana/index.cjs +875 -740
- package/dist/solana/index.cjs.map +1 -1
- package/dist/solana/index.d.cts +545 -471
- package/dist/solana/index.d.ts +545 -471
- package/dist/solana/index.js +738 -603
- package/dist/solana/index.js.map +1 -1
- package/dist/solana/react/index.cjs +57 -57
- package/dist/solana/react/index.cjs.map +1 -1
- package/dist/solana/react/index.d.cts +5 -5
- package/dist/solana/react/index.d.ts +5 -5
- package/dist/solana/react/index.js +15 -15
- package/dist/solana/react/index.js.map +1 -1
- package/package.json +4 -2
- package/dist/chunk-2NFQKIOB.js.map +0 -1
- package/dist/chunk-AT33RY6T.cjs.map +0 -1
- package/dist/chunk-LL7TW3GU.cjs.map +0 -1
- package/dist/chunk-ZQEEGBXT.js.map +0 -1
- package/dist/pda-FLNTBIC5.js.map +0 -1
|
@@ -4,7 +4,7 @@ import { ReactNode } from 'react';
|
|
|
4
4
|
import { Rpc, SolanaRpcApi, Address, TransactionSigner } from '@solana/kit';
|
|
5
5
|
import { WalletAccount, Wallet } from '@wallet-standard/base';
|
|
6
6
|
import { StandardConnectFeature, StandardDisconnectFeature } from '@wallet-standard/features';
|
|
7
|
-
import { P as Pool, m as SwapQuote, l as
|
|
7
|
+
import { P as Pool, m as SwapQuote, l as TradeDirection, o as AddLiquidityQuote, p as RemoveLiquidityQuote, a as Position, V as PositionValue, W as PositionWithAddress, O as OracleState, _ as TwapResult, J as OracleWithAddress } from '../../oracle-DN8BrGPh.cjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Configuration for the AMM provider
|
|
@@ -12,7 +12,7 @@ import { P as Pool, m as SwapQuote, l as SwapDirection, o as AddLiquidityQuote,
|
|
|
12
12
|
interface AmmConfig {
|
|
13
13
|
/** Solana RPC client */
|
|
14
14
|
rpc: Rpc<SolanaRpcApi>;
|
|
15
|
-
/** CPMM Program ID
|
|
15
|
+
/** CPMM Program ID */
|
|
16
16
|
programId?: Address;
|
|
17
17
|
/** Default commitment level for queries */
|
|
18
18
|
commitment?: 'processed' | 'confirmed' | 'finalized';
|
|
@@ -173,7 +173,7 @@ interface AmmProviderProps {
|
|
|
173
173
|
children: ReactNode;
|
|
174
174
|
/** Solana RPC endpoint URL */
|
|
175
175
|
endpoint: string;
|
|
176
|
-
/** Custom CPMM program ID (defaults to
|
|
176
|
+
/** Custom CPMM program ID (defaults to SDK CPMM_PROGRAM_ID) */
|
|
177
177
|
programId?: Address;
|
|
178
178
|
/** Default commitment level (defaults to 'confirmed') */
|
|
179
179
|
commitment?: Commitment;
|
|
@@ -480,8 +480,8 @@ interface SwapQuoteResult extends SwapQuote {
|
|
|
480
480
|
minAmountOut: bigint;
|
|
481
481
|
/** Maximum input amount (after slippage, for exact output) */
|
|
482
482
|
maxAmountIn: bigint;
|
|
483
|
-
/**
|
|
484
|
-
|
|
483
|
+
/** Trade direction (0 = token0->token1, 1 = token1->token0) */
|
|
484
|
+
tradeDirection: TradeDirection;
|
|
485
485
|
/** Whether the quote is valid */
|
|
486
486
|
isValid: boolean;
|
|
487
487
|
/** Error message if invalid */
|
|
@@ -4,7 +4,7 @@ import { ReactNode } from 'react';
|
|
|
4
4
|
import { Rpc, SolanaRpcApi, Address, TransactionSigner } from '@solana/kit';
|
|
5
5
|
import { WalletAccount, Wallet } from '@wallet-standard/base';
|
|
6
6
|
import { StandardConnectFeature, StandardDisconnectFeature } from '@wallet-standard/features';
|
|
7
|
-
import { P as Pool, m as SwapQuote, l as
|
|
7
|
+
import { P as Pool, m as SwapQuote, l as TradeDirection, o as AddLiquidityQuote, p as RemoveLiquidityQuote, a as Position, V as PositionValue, W as PositionWithAddress, O as OracleState, _ as TwapResult, J as OracleWithAddress } from '../../oracle-DN8BrGPh.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Configuration for the AMM provider
|
|
@@ -12,7 +12,7 @@ import { P as Pool, m as SwapQuote, l as SwapDirection, o as AddLiquidityQuote,
|
|
|
12
12
|
interface AmmConfig {
|
|
13
13
|
/** Solana RPC client */
|
|
14
14
|
rpc: Rpc<SolanaRpcApi>;
|
|
15
|
-
/** CPMM Program ID
|
|
15
|
+
/** CPMM Program ID */
|
|
16
16
|
programId?: Address;
|
|
17
17
|
/** Default commitment level for queries */
|
|
18
18
|
commitment?: 'processed' | 'confirmed' | 'finalized';
|
|
@@ -173,7 +173,7 @@ interface AmmProviderProps {
|
|
|
173
173
|
children: ReactNode;
|
|
174
174
|
/** Solana RPC endpoint URL */
|
|
175
175
|
endpoint: string;
|
|
176
|
-
/** Custom CPMM program ID (defaults to
|
|
176
|
+
/** Custom CPMM program ID (defaults to SDK CPMM_PROGRAM_ID) */
|
|
177
177
|
programId?: Address;
|
|
178
178
|
/** Default commitment level (defaults to 'confirmed') */
|
|
179
179
|
commitment?: Commitment;
|
|
@@ -480,8 +480,8 @@ interface SwapQuoteResult extends SwapQuote {
|
|
|
480
480
|
minAmountOut: bigint;
|
|
481
481
|
/** Maximum input amount (after slippage, for exact output) */
|
|
482
482
|
maxAmountIn: bigint;
|
|
483
|
-
/**
|
|
484
|
-
|
|
483
|
+
/** Trade direction (0 = token0->token1, 1 = token1->token0) */
|
|
484
|
+
tradeDirection: TradeDirection;
|
|
485
485
|
/** Whether the quote is valid */
|
|
486
486
|
isValid: boolean;
|
|
487
487
|
/** Error message if invalid */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { fetchPool, getSwapQuote, getSwapQuoteExactOut, ratioToNumber, getAddLiquidityQuote, getRemoveLiquidityQuote, fetchPosition, getPendingFees, getPositionValue, fetchUserPositions, fetchOracle, consultTwap, getOracleSpotPrices, getOracleDeviation, getOracleAge, isOracleStale, getOracleBufferStats, comparePoolAndOraclePrices, getOracleForPool, encodeInstructionData, collectFeesArgsCodec } from '../../chunk-
|
|
2
|
-
import { CPMM_PROGRAM_ID, BPS_DENOM, getOracleAddress, TOKEN_PROGRAM_ADDRESS, INSTRUCTION_DISCRIMINATORS } from '../../chunk-
|
|
1
|
+
import { fetchPool, getSwapQuote, getSwapQuoteExactOut, ratioToNumber, getAddLiquidityQuote, getRemoveLiquidityQuote, fetchPosition, getPendingFees, getPositionValue, fetchUserPositions, fetchOracle, consultTwap, getOracleSpotPrices, getOracleDeviation, getOracleAge, isOracleStale, getOracleBufferStats, comparePoolAndOraclePrices, getOracleForPool, encodeInstructionData, collectFeesArgsCodec } from '../../chunk-NMTYI3TB.js';
|
|
2
|
+
import { CPMM_PROGRAM_ID, BPS_DENOM, getOracleAddress, TOKEN_PROGRAM_ADDRESS, INSTRUCTION_DISCRIMINATORS } from '../../chunk-TVBSIQIX.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';
|
|
@@ -471,14 +471,14 @@ function useSwap(options) {
|
|
|
471
471
|
slippageBps: defaultSlippageBps
|
|
472
472
|
});
|
|
473
473
|
const [quoting] = useState(false);
|
|
474
|
-
const
|
|
474
|
+
const tradeDirection = useMemo(() => {
|
|
475
475
|
if (!token0Mint || !token1Mint || !state.inputToken) return null;
|
|
476
476
|
if (state.inputToken === token0Mint) return 0;
|
|
477
477
|
if (state.inputToken === token1Mint) return 1;
|
|
478
478
|
return null;
|
|
479
479
|
}, [token0Mint, token1Mint, state.inputToken]);
|
|
480
480
|
const quote = useMemo(() => {
|
|
481
|
-
if (!pool ||
|
|
481
|
+
if (!pool || tradeDirection === null) {
|
|
482
482
|
return null;
|
|
483
483
|
}
|
|
484
484
|
if (state.exactInput) {
|
|
@@ -492,20 +492,20 @@ function useSwap(options) {
|
|
|
492
492
|
executionPrice: 0,
|
|
493
493
|
minAmountOut: 0n,
|
|
494
494
|
maxAmountIn: 0n,
|
|
495
|
-
|
|
495
|
+
tradeDirection,
|
|
496
496
|
isValid: false,
|
|
497
497
|
error: null
|
|
498
498
|
};
|
|
499
499
|
}
|
|
500
500
|
try {
|
|
501
|
-
const swapQuote = getSwapQuote(pool, state.inputAmount,
|
|
501
|
+
const swapQuote = getSwapQuote(pool, state.inputAmount, tradeDirection);
|
|
502
502
|
const slippageFactor = BPS_DENOM - BigInt(state.slippageBps);
|
|
503
503
|
const minAmountOut = swapQuote.amountOut * slippageFactor / BPS_DENOM;
|
|
504
504
|
return {
|
|
505
505
|
...swapQuote,
|
|
506
506
|
minAmountOut,
|
|
507
507
|
maxAmountIn: state.inputAmount,
|
|
508
|
-
|
|
508
|
+
tradeDirection,
|
|
509
509
|
isValid: swapQuote.amountOut > 0n,
|
|
510
510
|
error: null
|
|
511
511
|
};
|
|
@@ -519,7 +519,7 @@ function useSwap(options) {
|
|
|
519
519
|
executionPrice: 0,
|
|
520
520
|
minAmountOut: 0n,
|
|
521
521
|
maxAmountIn: 0n,
|
|
522
|
-
|
|
522
|
+
tradeDirection,
|
|
523
523
|
isValid: false,
|
|
524
524
|
error: err instanceof Error ? err.message : "Failed to calculate quote"
|
|
525
525
|
};
|
|
@@ -535,7 +535,7 @@ function useSwap(options) {
|
|
|
535
535
|
executionPrice: 0,
|
|
536
536
|
minAmountOut: 0n,
|
|
537
537
|
maxAmountIn: 0n,
|
|
538
|
-
|
|
538
|
+
tradeDirection,
|
|
539
539
|
isValid: false,
|
|
540
540
|
error: null
|
|
541
541
|
};
|
|
@@ -544,11 +544,11 @@ function useSwap(options) {
|
|
|
544
544
|
const { amountIn, feeTotal } = getSwapQuoteExactOut(
|
|
545
545
|
pool,
|
|
546
546
|
state.outputAmount,
|
|
547
|
-
|
|
547
|
+
tradeDirection
|
|
548
548
|
);
|
|
549
549
|
const slippageFactor = BPS_DENOM + BigInt(state.slippageBps);
|
|
550
550
|
const maxAmountIn = amountIn * slippageFactor / BPS_DENOM;
|
|
551
|
-
const forwardQuote = getSwapQuote(pool, amountIn,
|
|
551
|
+
const forwardQuote = getSwapQuote(pool, amountIn, tradeDirection);
|
|
552
552
|
return {
|
|
553
553
|
amountOut: state.outputAmount,
|
|
554
554
|
feeTotal,
|
|
@@ -559,7 +559,7 @@ function useSwap(options) {
|
|
|
559
559
|
executionPrice: ratioToNumber(state.outputAmount, amountIn),
|
|
560
560
|
minAmountOut: state.outputAmount,
|
|
561
561
|
maxAmountIn,
|
|
562
|
-
|
|
562
|
+
tradeDirection,
|
|
563
563
|
isValid: amountIn > 0n,
|
|
564
564
|
error: null
|
|
565
565
|
};
|
|
@@ -573,7 +573,7 @@ function useSwap(options) {
|
|
|
573
573
|
executionPrice: 0,
|
|
574
574
|
minAmountOut: 0n,
|
|
575
575
|
maxAmountIn: 0n,
|
|
576
|
-
|
|
576
|
+
tradeDirection,
|
|
577
577
|
isValid: false,
|
|
578
578
|
error: err instanceof Error ? err.message : "Failed to calculate quote"
|
|
579
579
|
};
|
|
@@ -581,7 +581,7 @@ function useSwap(options) {
|
|
|
581
581
|
}
|
|
582
582
|
}, [
|
|
583
583
|
pool,
|
|
584
|
-
|
|
584
|
+
tradeDirection,
|
|
585
585
|
state.inputAmount,
|
|
586
586
|
state.outputAmount,
|
|
587
587
|
state.exactInput,
|
|
@@ -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-5D3GD5S6.js');
|
|
845
845
|
const [posAddr] = await getPositionAddress(
|
|
846
846
|
poolAddress,
|
|
847
847
|
ownerAddress,
|