@whetstone-research/doppler-sdk 1.0.7 → 1.0.9
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-BXATWUGJ.cjs → chunk-I5JME35L.cjs} +39 -39
- package/dist/{chunk-BXATWUGJ.cjs.map → chunk-I5JME35L.cjs.map} +1 -1
- package/dist/{chunk-DPKVNI6Q.cjs → chunk-O6FR7TXY.cjs} +27 -3
- package/dist/chunk-O6FR7TXY.cjs.map +1 -0
- package/dist/{chunk-BSHIMMA4.js → chunk-RF4NM4ES.js} +3 -3
- package/dist/{chunk-BSHIMMA4.js.map → chunk-RF4NM4ES.js.map} +1 -1
- package/dist/{chunk-J57ROY36.js → chunk-YWZCHTXQ.js} +25 -4
- package/dist/chunk-YWZCHTXQ.js.map +1 -0
- package/dist/evm/index.cjs +15 -14
- package/dist/evm/index.cjs.map +1 -1
- package/dist/evm/index.js +15 -14
- package/dist/evm/index.js.map +1 -1
- package/dist/pda-NKKMVQ4N.js +4 -0
- package/dist/pda-NKKMVQ4N.js.map +1 -0
- package/dist/pda-UKFLYQGA.cjs +61 -0
- package/dist/pda-UKFLYQGA.cjs.map +1 -0
- package/dist/solana/index.cjs +428 -332
- package/dist/solana/index.cjs.map +1 -1
- package/dist/solana/index.d.cts +160 -118
- package/dist/solana/index.d.ts +160 -118
- package/dist/solana/index.js +208 -112
- 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-DPKVNI6Q.cjs.map +0 -1
- package/dist/chunk-J57ROY36.js.map +0 -1
- package/dist/pda-TXZDXZZ4.js +0 -4
- package/dist/pda-TXZDXZZ4.js.map +0 -1
- package/dist/pda-ZZMBZSFU.cjs +0 -53
- package/dist/pda-ZZMBZSFU.cjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkO6FR7TXY_cjs = require('./chunk-O6FR7TXY.cjs');
|
|
4
4
|
var kit = require('@solana/kit');
|
|
5
5
|
|
|
6
6
|
var addressCodec = kit.getAddressCodec();
|
|
@@ -52,7 +52,7 @@ var ammConfigDataCodec = kit.getStructCodec([
|
|
|
52
52
|
["sentinelAllowlistLen", u8Codec],
|
|
53
53
|
[
|
|
54
54
|
"sentinelAllowlist",
|
|
55
|
-
kit.getArrayCodec(addressCodec, { size:
|
|
55
|
+
kit.getArrayCodec(addressCodec, { size: chunkO6FR7TXY_cjs.MAX_SENTINEL_ALLOWLIST })
|
|
56
56
|
],
|
|
57
57
|
["maxSwapFeeBps", u16Codec],
|
|
58
58
|
["maxFeeSplitBps", u16Codec],
|
|
@@ -120,22 +120,22 @@ var oracleStateDataCodec = kit.getStructCodec([
|
|
|
120
120
|
["observationIndex", u16Codec],
|
|
121
121
|
[
|
|
122
122
|
"observations",
|
|
123
|
-
kit.getArrayCodec(observationCodec, { size:
|
|
123
|
+
kit.getArrayCodec(observationCodec, { size: chunkO6FR7TXY_cjs.MAX_ORACLE_OBSERVATIONS })
|
|
124
124
|
],
|
|
125
125
|
["version", u8Codec],
|
|
126
126
|
["reserved", reservedBytesCodec]
|
|
127
127
|
]);
|
|
128
128
|
var ammConfigDecoder = kit.getHiddenPrefixDecoder(ammConfigDataCodec, [
|
|
129
|
-
kit.getConstantDecoder(
|
|
129
|
+
kit.getConstantDecoder(chunkO6FR7TXY_cjs.ACCOUNT_DISCRIMINATORS.AmmConfig)
|
|
130
130
|
]);
|
|
131
131
|
var poolDecoder = kit.getHiddenPrefixDecoder(poolDataCodec, [
|
|
132
|
-
kit.getConstantDecoder(
|
|
132
|
+
kit.getConstantDecoder(chunkO6FR7TXY_cjs.ACCOUNT_DISCRIMINATORS.Pool)
|
|
133
133
|
]);
|
|
134
134
|
var positionDecoder = kit.getHiddenPrefixDecoder(positionDataCodec, [
|
|
135
|
-
kit.getConstantDecoder(
|
|
135
|
+
kit.getConstantDecoder(chunkO6FR7TXY_cjs.ACCOUNT_DISCRIMINATORS.Position)
|
|
136
136
|
]);
|
|
137
137
|
var oracleStateDecoder = kit.getHiddenPrefixDecoder(oracleStateDataCodec, [
|
|
138
|
-
kit.getConstantDecoder(
|
|
138
|
+
kit.getConstantDecoder(chunkO6FR7TXY_cjs.ACCOUNT_DISCRIMINATORS.OracleState)
|
|
139
139
|
]);
|
|
140
140
|
function decodeAmmConfig(data) {
|
|
141
141
|
return ammConfigDecoder.decode(data);
|
|
@@ -299,12 +299,12 @@ function encodeQuoteToNumeraireArgs(args) {
|
|
|
299
299
|
function q64ToNumber(q64) {
|
|
300
300
|
const intPart = q64 >> 64n;
|
|
301
301
|
const fracPart = q64 & (1n << 64n) - 1n;
|
|
302
|
-
return Number(intPart) + Number(fracPart) / Number(
|
|
302
|
+
return Number(intPart) + Number(fracPart) / Number(chunkO6FR7TXY_cjs.Q64_ONE);
|
|
303
303
|
}
|
|
304
304
|
function numberToQ64(n) {
|
|
305
305
|
const intPart = Math.floor(n);
|
|
306
306
|
const fracPart = n - intPart;
|
|
307
|
-
return (BigInt(intPart) << 64n) + BigInt(Math.round(fracPart * Number(
|
|
307
|
+
return (BigInt(intPart) << 64n) + BigInt(Math.round(fracPart * Number(chunkO6FR7TXY_cjs.Q64_ONE)));
|
|
308
308
|
}
|
|
309
309
|
function q64Mul(a, b) {
|
|
310
310
|
return a * b >> 64n;
|
|
@@ -360,8 +360,8 @@ function getSwapQuote(pool, amountIn, direction) {
|
|
|
360
360
|
if (reserveIn === 0n || reserveOut === 0n) {
|
|
361
361
|
throw new Error("Pool has zero liquidity");
|
|
362
362
|
}
|
|
363
|
-
const feeTotal = amountIn * BigInt(pool.swapFeeBps) /
|
|
364
|
-
const feeDist = feeTotal * BigInt(pool.feeSplitBps) /
|
|
363
|
+
const feeTotal = amountIn * BigInt(pool.swapFeeBps) / chunkO6FR7TXY_cjs.BPS_DENOM;
|
|
364
|
+
const feeDist = feeTotal * BigInt(pool.feeSplitBps) / chunkO6FR7TXY_cjs.BPS_DENOM;
|
|
365
365
|
const feeComp = feeTotal - feeDist;
|
|
366
366
|
const amountInEff = amountIn - feeTotal;
|
|
367
367
|
const amountOut = amountInEff * reserveOut / (reserveIn + amountInEff);
|
|
@@ -387,8 +387,8 @@ function getSwapQuoteExactOut(pool, amountOut, direction) {
|
|
|
387
387
|
}
|
|
388
388
|
const amountInEff = ceilDiv(amountOut * reserveIn, reserveOut - amountOut);
|
|
389
389
|
const amountIn = ceilDiv(
|
|
390
|
-
amountInEff *
|
|
391
|
-
|
|
390
|
+
amountInEff * chunkO6FR7TXY_cjs.BPS_DENOM,
|
|
391
|
+
chunkO6FR7TXY_cjs.BPS_DENOM - BigInt(pool.swapFeeBps)
|
|
392
392
|
);
|
|
393
393
|
const feeTotal = amountIn - amountInEff;
|
|
394
394
|
return { amountIn, feeTotal };
|
|
@@ -488,7 +488,7 @@ function calculateTwapNumber(cumulativeStart, cumulativeEnd, timestampStart, tim
|
|
|
488
488
|
);
|
|
489
489
|
return q64ToNumber(twapQ64);
|
|
490
490
|
}
|
|
491
|
-
function createCollectFeesInstruction(accounts, args, programId =
|
|
491
|
+
function createCollectFeesInstruction(accounts, args, programId = chunkO6FR7TXY_cjs.CPMM_PROGRAM_ID) {
|
|
492
492
|
const {
|
|
493
493
|
pool,
|
|
494
494
|
position,
|
|
@@ -500,7 +500,7 @@ function createCollectFeesInstruction(accounts, args, programId = chunkDPKVNI6Q_
|
|
|
500
500
|
token1Mint,
|
|
501
501
|
user0,
|
|
502
502
|
user1,
|
|
503
|
-
tokenProgram =
|
|
503
|
+
tokenProgram = chunkO6FR7TXY_cjs.TOKEN_PROGRAM_ADDRESS
|
|
504
504
|
} = accounts;
|
|
505
505
|
const keys = [
|
|
506
506
|
{ address: pool, role: kit.AccountRole.WRITABLE },
|
|
@@ -516,7 +516,7 @@ function createCollectFeesInstruction(accounts, args, programId = chunkDPKVNI6Q_
|
|
|
516
516
|
{ address: tokenProgram, role: kit.AccountRole.READONLY }
|
|
517
517
|
];
|
|
518
518
|
const data = encodeInstructionData(
|
|
519
|
-
|
|
519
|
+
chunkO6FR7TXY_cjs.INSTRUCTION_DISCRIMINATORS.collectFees,
|
|
520
520
|
collectFeesArgsCodec,
|
|
521
521
|
args
|
|
522
522
|
);
|
|
@@ -555,11 +555,11 @@ async function fetchPool(rpc, address, config) {
|
|
|
555
555
|
return decodePool(base64ToBytes(response.value.data[0]));
|
|
556
556
|
}
|
|
557
557
|
async function fetchAllPools(rpc, config) {
|
|
558
|
-
const programId = config?.programId ??
|
|
558
|
+
const programId = config?.programId ?? chunkO6FR7TXY_cjs.CPMM_PROGRAM_ID;
|
|
559
559
|
const discriminatorFilter = {
|
|
560
560
|
memcmp: {
|
|
561
561
|
offset: 0n,
|
|
562
|
-
bytes: bytesToBase64(
|
|
562
|
+
bytes: bytesToBase64(chunkO6FR7TXY_cjs.ACCOUNT_DISCRIMINATORS.Pool),
|
|
563
563
|
encoding: "base64"
|
|
564
564
|
}
|
|
565
565
|
};
|
|
@@ -584,8 +584,8 @@ async function fetchAllPools(rpc, config) {
|
|
|
584
584
|
return pools;
|
|
585
585
|
}
|
|
586
586
|
async function getPoolByMints(rpc, mint0, mint1, config) {
|
|
587
|
-
const programId = config?.programId ??
|
|
588
|
-
const [poolAddress] = await
|
|
587
|
+
const programId = config?.programId ?? chunkO6FR7TXY_cjs.CPMM_PROGRAM_ID;
|
|
588
|
+
const [poolAddress] = await chunkO6FR7TXY_cjs.getPoolAddress(mint0, mint1, programId);
|
|
589
589
|
const pool = await fetchPool(rpc, poolAddress, config);
|
|
590
590
|
if (!pool) {
|
|
591
591
|
return null;
|
|
@@ -612,9 +612,9 @@ async function poolExists(rpc, mint0, mint1, config) {
|
|
|
612
612
|
const result = await getPoolByMints(rpc, mint0, mint1, config);
|
|
613
613
|
return result !== null;
|
|
614
614
|
}
|
|
615
|
-
async function getPoolAddressFromMints(mint0, mint1, programId =
|
|
616
|
-
const [token0, token1] =
|
|
617
|
-
const [poolAddress] = await
|
|
615
|
+
async function getPoolAddressFromMints(mint0, mint1, programId = chunkO6FR7TXY_cjs.CPMM_PROGRAM_ID) {
|
|
616
|
+
const [token0, token1] = chunkO6FR7TXY_cjs.sortMints(mint0, mint1);
|
|
617
|
+
const [poolAddress] = await chunkO6FR7TXY_cjs.getPoolAddress(mint0, mint1, programId);
|
|
618
618
|
return {
|
|
619
619
|
poolAddress,
|
|
620
620
|
token0,
|
|
@@ -662,14 +662,14 @@ async function fetchPosition(rpc, address, config) {
|
|
|
662
662
|
return decodePosition(base64ToBytes2(response.value.data[0]));
|
|
663
663
|
}
|
|
664
664
|
async function fetchUserPositions(rpc, owner, pool, config) {
|
|
665
|
-
const programId = config?.programId ??
|
|
665
|
+
const programId = config?.programId ?? chunkO6FR7TXY_cjs.CPMM_PROGRAM_ID;
|
|
666
666
|
const filters = [
|
|
667
667
|
// Discriminator filter (first 8 bytes)
|
|
668
668
|
{
|
|
669
669
|
memcmp: {
|
|
670
670
|
offset: 0n,
|
|
671
671
|
bytes: bytesToBase642(
|
|
672
|
-
|
|
672
|
+
chunkO6FR7TXY_cjs.ACCOUNT_DISCRIMINATORS.Position
|
|
673
673
|
),
|
|
674
674
|
encoding: "base64"
|
|
675
675
|
}
|
|
@@ -713,14 +713,14 @@ async function fetchUserPositions(rpc, owner, pool, config) {
|
|
|
713
713
|
return positions;
|
|
714
714
|
}
|
|
715
715
|
async function fetchPoolPositions(rpc, pool, config) {
|
|
716
|
-
const programId = config?.programId ??
|
|
716
|
+
const programId = config?.programId ?? chunkO6FR7TXY_cjs.CPMM_PROGRAM_ID;
|
|
717
717
|
const filters = [
|
|
718
718
|
// Discriminator filter
|
|
719
719
|
{
|
|
720
720
|
memcmp: {
|
|
721
721
|
offset: 0n,
|
|
722
722
|
bytes: bytesToBase642(
|
|
723
|
-
|
|
723
|
+
chunkO6FR7TXY_cjs.ACCOUNT_DISCRIMINATORS.Position
|
|
724
724
|
),
|
|
725
725
|
encoding: "base64"
|
|
726
726
|
}
|
|
@@ -781,8 +781,8 @@ function getPositionValue(pool, position) {
|
|
|
781
781
|
};
|
|
782
782
|
}
|
|
783
783
|
async function fetchPositionByParams(rpc, pool, owner, positionId, config) {
|
|
784
|
-
const programId = config?.programId ??
|
|
785
|
-
const [address] = await
|
|
784
|
+
const programId = config?.programId ?? chunkO6FR7TXY_cjs.CPMM_PROGRAM_ID;
|
|
785
|
+
const [address] = await chunkO6FR7TXY_cjs.getPositionAddress(
|
|
786
786
|
pool,
|
|
787
787
|
owner,
|
|
788
788
|
positionId,
|
|
@@ -797,8 +797,8 @@ async function fetchPositionByParams(rpc, pool, owner, positionId, config) {
|
|
|
797
797
|
account: position
|
|
798
798
|
};
|
|
799
799
|
}
|
|
800
|
-
async function getPositionAddressFromParams(pool, owner, positionId, programId =
|
|
801
|
-
const [address] = await
|
|
800
|
+
async function getPositionAddressFromParams(pool, owner, positionId, programId = chunkO6FR7TXY_cjs.CPMM_PROGRAM_ID) {
|
|
801
|
+
const [address] = await chunkO6FR7TXY_cjs.getPositionAddress(
|
|
802
802
|
pool,
|
|
803
803
|
owner,
|
|
804
804
|
positionId,
|
|
@@ -849,8 +849,8 @@ async function fetchOracle(rpc, address, config) {
|
|
|
849
849
|
return decodeOracleState(base64ToBytes3(response.value.data[0]));
|
|
850
850
|
}
|
|
851
851
|
async function getOracleForPool(rpc, pool, config) {
|
|
852
|
-
const programId = config?.programId ??
|
|
853
|
-
const [oracleAddress] = await
|
|
852
|
+
const programId = config?.programId ?? chunkO6FR7TXY_cjs.CPMM_PROGRAM_ID;
|
|
853
|
+
const [oracleAddress] = await chunkO6FR7TXY_cjs.getOracleAddress(pool, programId);
|
|
854
854
|
const oracle = await fetchOracle(rpc, oracleAddress, config);
|
|
855
855
|
if (!oracle) {
|
|
856
856
|
return null;
|
|
@@ -860,8 +860,8 @@ async function getOracleForPool(rpc, pool, config) {
|
|
|
860
860
|
account: oracle
|
|
861
861
|
};
|
|
862
862
|
}
|
|
863
|
-
async function getOracleAddressFromPool(pool, programId =
|
|
864
|
-
const [address] = await
|
|
863
|
+
async function getOracleAddressFromPool(pool, programId = chunkO6FR7TXY_cjs.CPMM_PROGRAM_ID) {
|
|
864
|
+
const [address] = await chunkO6FR7TXY_cjs.getOracleAddress(pool, programId);
|
|
865
865
|
return address;
|
|
866
866
|
}
|
|
867
867
|
function consultTwap(oracle, windowSeconds, currentTimestamp) {
|
|
@@ -984,10 +984,10 @@ function getOracleBufferStats(oracle) {
|
|
|
984
984
|
};
|
|
985
985
|
}
|
|
986
986
|
async function fetchOraclesBatch(rpc, pools, config) {
|
|
987
|
-
const programId = config?.programId ??
|
|
987
|
+
const programId = config?.programId ?? chunkO6FR7TXY_cjs.CPMM_PROGRAM_ID;
|
|
988
988
|
const oracles = /* @__PURE__ */ new Map();
|
|
989
989
|
const oracleAddresses = await Promise.all(
|
|
990
|
-
pools.map((pool) =>
|
|
990
|
+
pools.map((pool) => chunkO6FR7TXY_cjs.getOracleAddress(pool, programId))
|
|
991
991
|
);
|
|
992
992
|
const results = await Promise.all(
|
|
993
993
|
oracleAddresses.map(([addr]) => fetchOracle(rpc, addr, config))
|
|
@@ -1107,5 +1107,5 @@ exports.sortPoolsByReserves = sortPoolsByReserves;
|
|
|
1107
1107
|
exports.sortPositionsByShares = sortPositionsByShares;
|
|
1108
1108
|
exports.swapExactInArgsCodec = swapExactInArgsCodec;
|
|
1109
1109
|
exports.transferAdminArgsCodec = transferAdminArgsCodec;
|
|
1110
|
-
//# sourceMappingURL=chunk-
|
|
1111
|
-
//# sourceMappingURL=chunk-
|
|
1110
|
+
//# sourceMappingURL=chunk-I5JME35L.cjs.map
|
|
1111
|
+
//# sourceMappingURL=chunk-I5JME35L.cjs.map
|