@whetstone-research/doppler-sdk 1.0.8 → 1.0.10

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.
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkBXATWUGJ_cjs = require('../../chunk-BXATWUGJ.cjs');
4
- var chunkDPKVNI6Q_cjs = require('../../chunk-DPKVNI6Q.cjs');
3
+ var chunkI5JME35L_cjs = require('../../chunk-I5JME35L.cjs');
4
+ var chunkO6FR7TXY_cjs = require('../../chunk-O6FR7TXY.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 = chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID,
13
+ programId = chunkO6FR7TXY_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 ?? chunkDPKVNI6Q_cjs.CPMM_PROGRAM_ID,
94
+ programId: programId ?? chunkO6FR7TXY_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 chunkBXATWUGJ_cjs.fetchPool(rpc, poolAddress, {
336
+ const poolData = await chunkI5JME35L_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) => chunkBXATWUGJ_cjs.fetchPool(rpc, addr, { programId, commitment }).then((pool) => [addr, pool]).catch(() => [addr, null])
414
+ (addr) => chunkI5JME35L_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 = chunkBXATWUGJ_cjs.getSwapQuote(pool, state.inputAmount, direction);
504
- const slippageFactor = chunkDPKVNI6Q_cjs.BPS_DENOM - BigInt(state.slippageBps);
505
- const minAmountOut = swapQuote.amountOut * slippageFactor / chunkDPKVNI6Q_cjs.BPS_DENOM;
503
+ const swapQuote = chunkI5JME35L_cjs.getSwapQuote(pool, state.inputAmount, direction);
504
+ const slippageFactor = chunkO6FR7TXY_cjs.BPS_DENOM - BigInt(state.slippageBps);
505
+ const minAmountOut = swapQuote.amountOut * slippageFactor / chunkO6FR7TXY_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 } = chunkBXATWUGJ_cjs.getSwapQuoteExactOut(
546
+ const { amountIn, feeTotal } = chunkI5JME35L_cjs.getSwapQuoteExactOut(
547
547
  pool,
548
548
  state.outputAmount,
549
549
  direction
550
550
  );
551
- const slippageFactor = chunkDPKVNI6Q_cjs.BPS_DENOM + BigInt(state.slippageBps);
552
- const maxAmountIn = amountIn * slippageFactor / chunkDPKVNI6Q_cjs.BPS_DENOM;
553
- const forwardQuote = chunkBXATWUGJ_cjs.getSwapQuote(pool, amountIn, direction);
551
+ const slippageFactor = chunkO6FR7TXY_cjs.BPS_DENOM + BigInt(state.slippageBps);
552
+ const maxAmountIn = amountIn * slippageFactor / chunkO6FR7TXY_cjs.BPS_DENOM;
553
+ const forwardQuote = chunkI5JME35L_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: chunkBXATWUGJ_cjs.ratioToNumber(state.outputAmount, amountIn),
561
+ executionPrice: chunkI5JME35L_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 = chunkBXATWUGJ_cjs.getAddLiquidityQuote(
686
+ const quote = chunkI5JME35L_cjs.getAddLiquidityQuote(
687
687
  pool,
688
688
  addState.amount0,
689
689
  addState.amount1
690
690
  );
691
- const slippageFactor = chunkDPKVNI6Q_cjs.BPS_DENOM - BigInt(addState.slippageBps);
692
- const minSharesOut = quote.sharesOut * slippageFactor / chunkDPKVNI6Q_cjs.BPS_DENOM;
691
+ const slippageFactor = chunkO6FR7TXY_cjs.BPS_DENOM - BigInt(addState.slippageBps);
692
+ const minSharesOut = quote.sharesOut * slippageFactor / chunkO6FR7TXY_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 = chunkBXATWUGJ_cjs.getRemoveLiquidityQuote(pool, removeState.shares);
727
- const slippageFactor = chunkDPKVNI6Q_cjs.BPS_DENOM - BigInt(removeState.slippageBps);
728
- const minAmount0Out = quote.amount0 * slippageFactor / chunkDPKVNI6Q_cjs.BPS_DENOM;
729
- const minAmount1Out = quote.amount1 * slippageFactor / chunkDPKVNI6Q_cjs.BPS_DENOM;
726
+ const quote = chunkI5JME35L_cjs.getRemoveLiquidityQuote(pool, removeState.shares);
727
+ const slippageFactor = chunkO6FR7TXY_cjs.BPS_DENOM - BigInt(removeState.slippageBps);
728
+ const minAmount0Out = quote.amount0 * slippageFactor / chunkO6FR7TXY_cjs.BPS_DENOM;
729
+ const minAmount1Out = quote.amount1 * slippageFactor / chunkO6FR7TXY_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-ZZMBZSFU.cjs');
846
+ const { getPositionAddress } = await import('../../pda-UKFLYQGA.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
- chunkBXATWUGJ_cjs.fetchPosition(rpc, posAddr, { programId, commitment }),
856
- providedPool ? Promise.resolve(providedPool) : chunkBXATWUGJ_cjs.fetchPool(rpc, poolAddress, { programId, commitment })
855
+ chunkI5JME35L_cjs.fetchPosition(rpc, posAddr, { programId, commitment }),
856
+ providedPool ? Promise.resolve(providedPool) : chunkI5JME35L_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 chunkBXATWUGJ_cjs.getPendingFees(pool, position);
885
+ return chunkI5JME35L_cjs.getPendingFees(pool, position);
886
886
  }, [pool, position]);
887
887
  const value = react.useMemo(() => {
888
888
  if (!pool || !position) return null;
889
- return chunkBXATWUGJ_cjs.getPositionValue(pool, position);
889
+ return chunkI5JME35L_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 chunkBXATWUGJ_cjs.fetchUserPositions(
944
+ const positionsData = await chunkI5JME35L_cjs.fetchUserPositions(
945
945
  rpc,
946
946
  ownerAddress,
947
947
  poolFilter,
@@ -1018,7 +1018,7 @@ function useFees(positionAddress, poolAddress, options = {}) {
1018
1018
  }, [providedPool, providedPosition]);
1019
1019
  const fees = react.useMemo(() => {
1020
1020
  if (!pool || !position) return null;
1021
- const { pending0, pending1 } = chunkBXATWUGJ_cjs.getPendingFees(pool, position);
1021
+ const { pending0, pending1 } = chunkI5JME35L_cjs.getPendingFees(pool, position);
1022
1022
  return {
1023
1023
  pending0,
1024
1024
  pending1,
@@ -1045,13 +1045,13 @@ function useFees(positionAddress, poolAddress, options = {}) {
1045
1045
  const promises = [];
1046
1046
  if (!providedPosition && positionAddress) {
1047
1047
  promises.push(
1048
- chunkBXATWUGJ_cjs.fetchPosition(rpc, positionAddress, { programId, commitment })
1048
+ chunkI5JME35L_cjs.fetchPosition(rpc, positionAddress, { programId, commitment })
1049
1049
  );
1050
1050
  } else {
1051
1051
  promises.push(Promise.resolve(providedPosition));
1052
1052
  }
1053
1053
  if (!providedPool && poolAddress) {
1054
- promises.push(chunkBXATWUGJ_cjs.fetchPool(rpc, poolAddress, { programId, commitment }));
1054
+ promises.push(chunkI5JME35L_cjs.fetchPool(rpc, poolAddress, { programId, commitment }));
1055
1055
  } else {
1056
1056
  promises.push(Promise.resolve(providedPool));
1057
1057
  }
@@ -1097,12 +1097,12 @@ function useFees(positionAddress, poolAddress, options = {}) {
1097
1097
  setTxSignature(null);
1098
1098
  try {
1099
1099
  const {
1100
- max0 = chunkBXATWUGJ_cjs.MAX_FEE_AMOUNT,
1101
- max1 = chunkBXATWUGJ_cjs.MAX_FEE_AMOUNT,
1100
+ max0 = chunkI5JME35L_cjs.MAX_FEE_AMOUNT,
1101
+ max1 = chunkI5JME35L_cjs.MAX_FEE_AMOUNT,
1102
1102
  userToken0,
1103
1103
  userToken1
1104
1104
  } = collectOptions;
1105
- const ix = chunkBXATWUGJ_cjs.createCollectFeesInstruction(
1105
+ const ix = chunkI5JME35L_cjs.createCollectFeesInstruction(
1106
1106
  {
1107
1107
  pool: poolAddress,
1108
1108
  position: positionAddress,
@@ -1204,7 +1204,7 @@ function useFees(positionAddress, poolAddress, options = {}) {
1204
1204
  function useFeesFromData(pool, position) {
1205
1205
  return react.useMemo(() => {
1206
1206
  if (!pool || !position) return null;
1207
- const { pending0, pending1 } = chunkBXATWUGJ_cjs.getPendingFees(pool, position);
1207
+ const { pending0, pending1 } = chunkI5JME35L_cjs.getPendingFees(pool, position);
1208
1208
  return {
1209
1209
  pending0,
1210
1210
  pending1,
@@ -1239,9 +1239,9 @@ function useOracle(poolAddress, options = {}) {
1239
1239
  setLoading(true);
1240
1240
  setError(null);
1241
1241
  try {
1242
- const [oracleAddr] = await chunkDPKVNI6Q_cjs.getOracleAddress(poolAddress, programId);
1242
+ const [oracleAddr] = await chunkO6FR7TXY_cjs.getOracleAddress(poolAddress, programId);
1243
1243
  setOracleAddress(oracleAddr);
1244
- const oracleData = await chunkBXATWUGJ_cjs.fetchOracle(rpc, oracleAddr, {
1244
+ const oracleData = await chunkI5JME35L_cjs.fetchOracle(rpc, oracleAddr, {
1245
1245
  programId,
1246
1246
  commitment
1247
1247
  });
@@ -1264,34 +1264,34 @@ function useOracle(poolAddress, options = {}) {
1264
1264
  const twap = react.useCallback(
1265
1265
  (windowSeconds) => {
1266
1266
  if (!oracle || !oracle.initialized) return null;
1267
- return chunkBXATWUGJ_cjs.consultTwap(oracle, windowSeconds);
1267
+ return chunkI5JME35L_cjs.consultTwap(oracle, windowSeconds);
1268
1268
  },
1269
1269
  [oracle]
1270
1270
  );
1271
1271
  const spotPrice = react.useMemo(() => {
1272
1272
  if (!oracle || !oracle.initialized) return null;
1273
- const prices = chunkBXATWUGJ_cjs.getOracleSpotPrices(oracle);
1273
+ const prices = chunkI5JME35L_cjs.getOracleSpotPrices(oracle);
1274
1274
  return { price0: prices.price0, price1: prices.price1 };
1275
1275
  }, [oracle]);
1276
1276
  const deviation = react.useMemo(() => {
1277
1277
  if (!oracle || !oracle.initialized) return null;
1278
- const dev = chunkBXATWUGJ_cjs.getOracleDeviation(oracle);
1278
+ const dev = chunkI5JME35L_cjs.getOracleDeviation(oracle);
1279
1279
  return { deviation0: dev.deviation0, deviation1: dev.deviation1 };
1280
1280
  }, [oracle]);
1281
1281
  const age = react.useMemo(() => {
1282
1282
  if (!oracle || !oracle.initialized) return null;
1283
- return chunkBXATWUGJ_cjs.getOracleAge(oracle);
1283
+ return chunkI5JME35L_cjs.getOracleAge(oracle);
1284
1284
  }, [oracle]);
1285
1285
  const isStaleCheck = react.useCallback(
1286
1286
  (maxAgeSeconds) => {
1287
1287
  if (!oracle || !oracle.initialized) return true;
1288
- return chunkBXATWUGJ_cjs.isOracleStale(oracle, maxAgeSeconds);
1288
+ return chunkI5JME35L_cjs.isOracleStale(oracle, maxAgeSeconds);
1289
1289
  },
1290
1290
  [oracle]
1291
1291
  );
1292
1292
  const bufferStats = react.useMemo(() => {
1293
1293
  if (!oracle || !oracle.initialized) return null;
1294
- const stats = chunkBXATWUGJ_cjs.getOracleBufferStats(oracle);
1294
+ const stats = chunkI5JME35L_cjs.getOracleBufferStats(oracle);
1295
1295
  return {
1296
1296
  capacity: stats.capacity,
1297
1297
  filledCount: stats.filledCount,
@@ -1302,7 +1302,7 @@ function useOracle(poolAddress, options = {}) {
1302
1302
  const compareWithPool = react.useCallback(
1303
1303
  (pool) => {
1304
1304
  if (!oracle || !oracle.initialized) return null;
1305
- return chunkBXATWUGJ_cjs.comparePoolAndOraclePrices(pool, oracle);
1305
+ return chunkI5JME35L_cjs.comparePoolAndOraclePrices(pool, oracle);
1306
1306
  },
1307
1307
  [oracle]
1308
1308
  );
@@ -1341,7 +1341,7 @@ function useTwap(poolAddress, windowSeconds, options = {}) {
1341
1341
  const { oracle, loading, error, refetch } = useOracle(poolAddress, options);
1342
1342
  const twap = react.useMemo(() => {
1343
1343
  if (!oracle || !oracle.initialized) return null;
1344
- return chunkBXATWUGJ_cjs.consultTwap(oracle, windowSeconds);
1344
+ return chunkI5JME35L_cjs.consultTwap(oracle, windowSeconds);
1345
1345
  }, [oracle, windowSeconds]);
1346
1346
  return {
1347
1347
  twap,
@@ -1380,7 +1380,7 @@ function useOracles(poolAddresses, options = {}) {
1380
1380
  const results = await Promise.all(
1381
1381
  poolAddresses.map(async (poolAddr) => {
1382
1382
  try {
1383
- const result = await chunkBXATWUGJ_cjs.getOracleForPool(rpc, poolAddr, {
1383
+ const result = await chunkI5JME35L_cjs.getOracleForPool(rpc, poolAddr, {
1384
1384
  programId,
1385
1385
  commitment
1386
1386
  });
@@ -1,5 +1,5 @@
1
- import { fetchPool, getSwapQuote, getSwapQuoteExactOut, ratioToNumber, getAddLiquidityQuote, getRemoveLiquidityQuote, fetchPosition, getPendingFees, getPositionValue, fetchUserPositions, MAX_FEE_AMOUNT, createCollectFeesInstruction, fetchOracle, consultTwap, getOracleSpotPrices, getOracleDeviation, getOracleAge, isOracleStale, getOracleBufferStats, comparePoolAndOraclePrices, getOracleForPool } from '../../chunk-BSHIMMA4.js';
2
- import { CPMM_PROGRAM_ID, BPS_DENOM, getOracleAddress } from '../../chunk-J57ROY36.js';
1
+ import { fetchPool, getSwapQuote, getSwapQuoteExactOut, ratioToNumber, getAddLiquidityQuote, getRemoveLiquidityQuote, fetchPosition, getPendingFees, getPositionValue, fetchUserPositions, MAX_FEE_AMOUNT, createCollectFeesInstruction, fetchOracle, consultTwap, getOracleSpotPrices, getOracleDeviation, getOracleAge, isOracleStale, getOracleBufferStats, comparePoolAndOraclePrices, getOracleForPool } from '../../chunk-RF4NM4ES.js';
2
+ import { CPMM_PROGRAM_ID, BPS_DENOM, getOracleAddress } from '../../chunk-YWZCHTXQ.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-TXZDXZZ4.js');
844
+ const { getPositionAddress } = await import('../../pda-NKKMVQ4N.js');
845
845
  const [posAddr] = await getPositionAddress(
846
846
  poolAddress,
847
847
  ownerAddress,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@whetstone-research/doppler-sdk",
3
3
  "author": "Whetstone Research",
4
- "version": "1.0.8",
4
+ "version": "1.0.10",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "repository": {
@@ -34,6 +34,7 @@
34
34
  "test:unit": "vitest run --config vitest.unit.config.ts",
35
35
  "test:fork": "ANVIL_FORK_ENABLED=true vitest run --config vitest.fork.config.ts",
36
36
  "test:live": "LIVE_TEST_ENABLED=true vitest run --config vitest.live.config.ts",
37
+ "test:whitelisting": "LIVE_TEST_ENABLED=true vitest run --config vitest.live.config.ts test/evm/e2e/whitelisting.test.ts",
37
38
  "test:solana": "vitest run --config vitest.solana.config.ts",
38
39
  "test:watch": "vitest watch --config vitest.unit.config.ts",
39
40
  "test:coverage": "vitest run --coverage --config vitest.unit.config.ts",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/solana/core/constants.ts","../src/solana/core/pda.ts"],"names":["address","getAddressCodec","getProgramDerivedAddress"],"mappings":";;;;;;;;AAWO,IAAM,eAAA,GAA2BA,WAAA;AAAA,EACtC;AACF;AAKO,IAAM,yBAAA,GAAqCA,WAAA;AAAA,EAChD;AACF;AAOO,IAAM,SAAA,GAAY;AAGlB,IAAM,UAAU,EAAA,IAAM;AAGtB,IAAM,eAAA,GAAkB;AAOxB,IAAM,sBAAA,GAAyB;AAG/B,IAAM,uBAAA,GAA0B;AAOhC,IAAM,WAAA,GAAc;AAGpB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,MAAA,EAAQ,SAAA,EAAW,MAAM,CAAA,GAAI,MAAM,QAAQ,GAAA,CAAI;AAAA,IACpD,iBAAiB,SAAS,CAAA;AAAA,IAC1B,uBAAA,CAAwB,MAAM,SAAS,CAAA;AAAA,IACvC,gBAAA,CAAiB,MAAM,SAAS;AAAA,GACjC,CAAA;AAED,EAAA,OAAO,EAAE,MAAA,EAAQ,SAAA,EAAW,MAAA,EAAO;AACrC;AAKA,eAAsB,qBAAA,CACpB,IAAA,EACA,KAAA,EACA,UAAA,EACA,YAAqB,eAAA,EAOpB;AACD,EAAA,MAAM,CAAC,QAAQ,SAAA,EAAW,QAAA,EAAU,kBAAkB,MAAM,CAAA,GAC1D,MAAM,OAAA,CAAQ,GAAA,CAAI;AAAA,IAChB,iBAAiB,SAAS,CAAA;AAAA,IAC1B,uBAAA,CAAwB,MAAM,SAAS,CAAA;AAAA,IACvC,kBAAA,CAAmB,IAAA,EAAM,KAAA,EAAO,UAAA,EAAY,SAAS,CAAA;AAAA,IACrD,0BAAA,CAA2B,MAAM,SAAS,CAAA;AAAA,IAC1C,gBAAA,CAAiB,MAAM,SAAS;AAAA,GACjC,CAAA;AAEH,EAAA,OAAO,EAAE,MAAA,EAAQ,SAAA,EAAW,QAAA,EAAU,kBAAkB,MAAA,EAAO;AACjE","file":"chunk-DPKVNI6Q.cjs","sourcesContent":["import { address, type Address } from '@solana/kit';\nexport {\n TOKEN_PROGRAM_ADDRESS,\n ASSOCIATED_TOKEN_PROGRAM_ADDRESS,\n} from '@solana-program/token';\nexport { SYSTEM_PROGRAM_ADDRESS } from '@solana-program/system';\nexport { SYSVAR_RENT_ADDRESS } from '@solana/sysvars';\n\n/**\n * CPMM AMM program ID (devnet)\n */\nexport const CPMM_PROGRAM_ID: Address = address(\n '9PSxVPoPfnbZ8Q1uQhgS6ZxvBjFboZtebNsu34umxkgQ',\n);\n\n/**\n * Metaplex Token Metadata Program ID\n */\nexport const TOKEN_METADATA_PROGRAM_ID: Address = address(\n 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s',\n);\n\n// ============================================================================\n// Math Constants\n// ============================================================================\n\n/** Basis points denominator (10,000 = 100%) */\nexport const BPS_DENOM = 10_000n;\n\n/** Q64.64 fixed-point representation of 1.0 (2^64) */\nexport const Q64_ONE = 1n << 64n;\n\n/** Current account version */\nexport const ACCOUNT_VERSION = 1;\n\n// ============================================================================\n// Array Size Constants\n// ============================================================================\n\n/** Maximum number of programs in sentinel allowlist */\nexport const MAX_SENTINEL_ALLOWLIST = 32;\n\n/** Maximum number of oracle observations (TWAP buffer size) */\nexport const MAX_ORACLE_OBSERVATIONS = 64;\n\n// ============================================================================\n// PDA Seeds\n// ============================================================================\n\n/** Seed for AmmConfig PDA: ['config'] */\nexport const SEED_CONFIG = 'config';\n\n/** Seed prefix for Pool PDA: ['pool', token0_mint, token1_mint] */\nexport const SEED_POOL = 'pool';\n\n/** Seed prefix for pool authority PDA: ['authority', pool] */\nexport const SEED_AUTHORITY = 'authority';\n\n/** Seed prefix for Position PDA: ['position', pool, owner, position_id] */\nexport const SEED_POSITION = 'position';\n\n/** Seed prefix for OracleState PDA: ['oracle', pool] */\nexport const SEED_ORACLE = 'oracle';\n\n/** Seed prefix for protocol position PDA: ['protocol_position', pool] */\nexport const SEED_PROTOCOL_POSITION = 'protocol_position';\n\n// ============================================================================\n// Sentinel Flags\n// ============================================================================\n\n/** Sentinel hook: called before swap */\nexport const SF_BEFORE_SWAP = 1 << 0;\n\n/** Sentinel hook: called after swap */\nexport const SF_AFTER_SWAP = 1 << 1;\n\n/** Sentinel hook: called before add liquidity */\nexport const SF_BEFORE_ADD_LIQ = 1 << 2;\n\n/** Sentinel hook: called after add liquidity */\nexport const SF_AFTER_ADD_LIQ = 1 << 3;\n\n/** Sentinel hook: called before remove liquidity */\nexport const SF_BEFORE_REMOVE_LIQ = 1 << 4;\n\n/** Sentinel hook: called after remove liquidity */\nexport const SF_AFTER_REMOVE_LIQ = 1 << 5;\n\n/** Sentinel return value indicating \"no change\" to fee parameter */\nexport const SENTINEL_NO_CHANGE = 0xffff;\n\n// ============================================================================\n// Instruction Discriminators (Anchor 8-byte hashes)\n// ============================================================================\n\n/**\n * Anchor instruction discriminator (first 8 bytes of SHA256(\"global:<instruction_name>\"))\n * These are computed at build time from the instruction names.\n */\nexport const INSTRUCTION_DISCRIMINATORS = {\n // SHA256(\"global:initialize_config\")[0:8]\n initializeConfig: new Uint8Array([\n 0xd0, 0x7f, 0x15, 0x01, 0xc2, 0xbe, 0xc4, 0x46,\n ]),\n // SHA256(\"global:initialize_pool\")[0:8]\n initializePool: new Uint8Array([\n 0x5f, 0xb4, 0x0a, 0xac, 0x54, 0xae, 0xe8, 0x28,\n ]),\n // SHA256(\"global:initialize_oracle\")[0:8]\n initializeOracle: new Uint8Array([\n 0x90, 0xdf, 0x83, 0x78, 0xc4, 0xfd, 0xb5, 0x63,\n ]),\n // SHA256(\"global:create_position\")[0:8]\n createPosition: new Uint8Array([\n 0x30, 0xd7, 0xc5, 0x99, 0x60, 0xcb, 0xb4, 0x85,\n ]),\n // SHA256(\"global:add_liquidity\")[0:8]\n addLiquidity: new Uint8Array([\n 0xb5, 0x9d, 0x59, 0x43, 0x8f, 0xb6, 0x34, 0x48,\n ]),\n // SHA256(\"global:remove_liquidity\")[0:8]\n removeLiquidity: new Uint8Array([\n 0x50, 0x55, 0xd1, 0x48, 0x18, 0xce, 0xb1, 0x6c,\n ]),\n // SHA256(\"global:swap_exact_in\")[0:8]\n swapExactIn: new Uint8Array([0x68, 0x68, 0x83, 0x56, 0xa1, 0xbd, 0xb4, 0xd8]),\n // SHA256(\"global:collect_fees\")[0:8]\n collectFees: new Uint8Array([0xa4, 0x98, 0xcf, 0x63, 0x1e, 0xba, 0x13, 0xb6]),\n // SHA256(\"global:collect_protocol_fees\")[0:8]\n collectProtocolFees: new Uint8Array([\n 0x16, 0x43, 0x17, 0x62, 0x96, 0xb2, 0x46, 0xdc,\n ]),\n // SHA256(\"global:close_position\")[0:8]\n closePosition: new Uint8Array([\n 0x7b, 0x86, 0x51, 0x00, 0x31, 0x44, 0x62, 0x62,\n ]),\n // SHA256(\"global:oracle_update\")[0:8]\n oracleUpdate: new Uint8Array([\n 0x55, 0xd1, 0xf8, 0x8e, 0xba, 0xf9, 0x78, 0xef,\n ]),\n // SHA256(\"global:oracle_consult\")[0:8]\n oracleConsult: new Uint8Array([\n 0xef, 0xed, 0xff, 0xb1, 0x8e, 0x48, 0x60, 0xaf,\n ]),\n // SHA256(\"global:quote_to_numeraire\")[0:8]\n quoteToNumeraire: new Uint8Array([\n 0x04, 0x8e, 0xf9, 0xf0, 0x81, 0x0f, 0x8f, 0x39,\n ]),\n // SHA256(\"global:set_sentinel\")[0:8]\n setSentinel: new Uint8Array([0x5e, 0xc8, 0x52, 0x81, 0x35, 0x95, 0xe8, 0x71]),\n // SHA256(\"global:set_fees\")[0:8]\n setFees: new Uint8Array([0x89, 0xb2, 0x31, 0x3a, 0x00, 0xf5, 0xf2, 0xbe]),\n // SHA256(\"global:set_route\")[0:8]\n setRoute: new Uint8Array([0xf4, 0xe7, 0x03, 0x54, 0xe9, 0x3d, 0x92, 0x95]),\n // SHA256(\"global:transfer_admin\")[0:8]\n transferAdmin: new Uint8Array([\n 0x2a, 0xf2, 0x42, 0x6a, 0xe4, 0x0a, 0x6f, 0x9c,\n ]),\n // SHA256(\"global:pause\")[0:8]\n pause: new Uint8Array([0xd3, 0x16, 0xdd, 0xfb, 0x4a, 0x79, 0xc1, 0x2f]),\n // SHA256(\"global:unpause\")[0:8]\n unpause: new Uint8Array([0xa9, 0x90, 0x04, 0x26, 0x0a, 0x8d, 0xbc, 0xff]),\n // SHA256(\"global:skim\")[0:8]\n skim: new Uint8Array([0xee, 0x78, 0xdd, 0x8a, 0x52, 0x3c, 0x64, 0xda]),\n} as const;\n\n// ============================================================================\n// Account Discriminators (Anchor 8-byte hashes)\n// ============================================================================\n\n/**\n * Anchor account discriminator (first 8 bytes of SHA256(\"account:<AccountName>\"))\n */\nexport const ACCOUNT_DISCRIMINATORS = {\n // SHA256(\"account:AmmConfig\")[0:8]\n AmmConfig: new Uint8Array([0xda, 0xf4, 0x21, 0x68, 0xcb, 0xcb, 0x2b, 0x6f]),\n // SHA256(\"account:Pool\")[0:8]\n Pool: new Uint8Array([0xf1, 0x9a, 0x6d, 0x04, 0x11, 0xb1, 0x6d, 0xbc]),\n // SHA256(\"account:Position\")[0:8]\n Position: new Uint8Array([0xaa, 0xbc, 0x8f, 0xe4, 0x7a, 0x40, 0xf7, 0xd0]),\n // SHA256(\"account:OracleState\")[0:8]\n OracleState: new Uint8Array([0x61, 0x9c, 0x9d, 0xbd, 0xc2, 0x49, 0x08, 0x0f]),\n} as const;\n","import {\n type Address,\n type ProgramDerivedAddress,\n getAddressCodec,\n getProgramDerivedAddress,\n} from '@solana/kit';\nimport {\n CPMM_PROGRAM_ID,\n SEED_CONFIG,\n SEED_POOL,\n SEED_AUTHORITY,\n SEED_POSITION,\n SEED_ORACLE,\n SEED_PROTOCOL_POSITION,\n} from './constants.js';\n\nconst addressCodec = getAddressCodec();\nconst textEncoder = new TextEncoder();\n\n// ============================================================================\n// Token Sorting\n// ============================================================================\n\n/**\n * Sort two mints into canonical order (token0 < token1 by bytes)\n * This is required for Pool PDA derivation and instruction ordering.\n *\n * @param mint0 - First mint address\n * @param mint1 - Second mint address\n * @returns Tuple of [token0, token1] in canonical order\n * @throws Error if mints are equal\n */\nexport function sortMints(mint0: Address, mint1: Address): [Address, Address] {\n const bytesA = addressCodec.encode(mint0);\n const bytesB = addressCodec.encode(mint1);\n\n for (let i = 0; i < 32; i++) {\n if (bytesA[i] < bytesB[i]) {\n return [mint0, mint1];\n }\n if (bytesA[i] > bytesB[i]) {\n return [mint1, mint0];\n }\n }\n\n throw new Error('Mints are equal - cannot create pool with identical tokens');\n}\n\n/**\n * Check if mints are in canonical order\n */\nexport function areMintsOrdered(mint0: Address, mint1: Address): boolean {\n const bytes0 = addressCodec.encode(mint0);\n const bytes1 = addressCodec.encode(mint1);\n\n for (let i = 0; i < 32; i++) {\n if (bytes0[i] < bytes1[i]) return true;\n if (bytes0[i] > bytes1[i]) return false;\n }\n return false; // equal\n}\n\n// ============================================================================\n// PDA Derivation Functions\n// ============================================================================\n\n/**\n * Derive the AmmConfig PDA address\n * Seeds: ['config']\n */\nexport async function getConfigAddress(\n programId: Address = CPMM_PROGRAM_ID,\n): Promise<ProgramDerivedAddress> {\n return getProgramDerivedAddress({\n programAddress: programId,\n seeds: [textEncoder.encode(SEED_CONFIG)],\n });\n}\n\n/**\n * Derive the Pool PDA address for a token pair\n * Seeds: ['pool', token0_mint, token1_mint]\n *\n * Note: Mints will be automatically sorted if not in canonical order.\n */\nexport async function getPoolAddress(\n mint0: Address,\n mint1: Address,\n programId: Address = CPMM_PROGRAM_ID,\n): Promise<ProgramDerivedAddress> {\n const [token0, token1] = sortMints(mint0, mint1);\n return getProgramDerivedAddress({\n programAddress: programId,\n seeds: [\n textEncoder.encode(SEED_POOL),\n addressCodec.encode(token0),\n addressCodec.encode(token1),\n ],\n });\n}\n\n/**\n * Derive the Pool authority PDA (vault owner)\n * Seeds: ['authority', pool]\n */\nexport async function getPoolAuthorityAddress(\n pool: Address,\n programId: Address = CPMM_PROGRAM_ID,\n): Promise<ProgramDerivedAddress> {\n return getProgramDerivedAddress({\n programAddress: programId,\n seeds: [textEncoder.encode(SEED_AUTHORITY), addressCodec.encode(pool)],\n });\n}\n\n/**\n * Derive the Position PDA address\n * Seeds: ['position', pool, owner, position_id_le_bytes]\n */\nexport async function getPositionAddress(\n pool: Address,\n owner: Address,\n positionId: bigint,\n programId: Address = CPMM_PROGRAM_ID,\n): Promise<ProgramDerivedAddress> {\n const positionIdBytes = new Uint8Array(8);\n const view = new DataView(positionIdBytes.buffer);\n view.setBigUint64(0, positionId, true); // little-endian\n\n return getProgramDerivedAddress({\n programAddress: programId,\n seeds: [\n textEncoder.encode(SEED_POSITION),\n addressCodec.encode(pool),\n addressCodec.encode(owner),\n positionIdBytes,\n ],\n });\n}\n\n/**\n * Derive the OracleState PDA address\n * Seeds: ['oracle', pool]\n */\nexport async function getOracleAddress(\n pool: Address,\n programId: Address = CPMM_PROGRAM_ID,\n): Promise<ProgramDerivedAddress> {\n return getProgramDerivedAddress({\n programAddress: programId,\n seeds: [textEncoder.encode(SEED_ORACLE), addressCodec.encode(pool)],\n });\n}\n\n/**\n * Derive the Protocol Position PDA address\n * Seeds: ['protocol_position', pool]\n */\nexport async function getProtocolPositionAddress(\n pool: Address,\n programId: Address = CPMM_PROGRAM_ID,\n): Promise<ProgramDerivedAddress> {\n return getProgramDerivedAddress({\n programAddress: programId,\n seeds: [\n textEncoder.encode(SEED_PROTOCOL_POSITION),\n addressCodec.encode(pool),\n ],\n });\n}\n\n// ============================================================================\n// Batch PDA Derivation\n// ============================================================================\n\n/**\n * Derive all PDAs needed for pool initialization\n */\nexport async function getPoolInitAddresses(\n mint0: Address,\n mint1: Address,\n programId: Address = CPMM_PROGRAM_ID,\n): Promise<{\n token0: Address;\n token1: Address;\n pool: ProgramDerivedAddress;\n authority: ProgramDerivedAddress;\n config: ProgramDerivedAddress;\n protocolPosition: ProgramDerivedAddress;\n}> {\n const [token0, token1] = sortMints(mint0, mint1);\n const [config, pool] = await Promise.all([\n getConfigAddress(programId),\n getPoolAddress(token0, token1, programId),\n ]);\n const [authority, protocolPosition] = await Promise.all([\n getPoolAuthorityAddress(pool[0], programId),\n getProtocolPositionAddress(pool[0], programId),\n ]);\n\n return {\n token0,\n token1,\n pool,\n authority,\n config,\n protocolPosition,\n };\n}\n\n/**\n * Derive all PDAs needed for swap operation\n */\nexport async function getSwapAddresses(\n pool: Address,\n programId: Address = CPMM_PROGRAM_ID,\n): Promise<{\n config: ProgramDerivedAddress;\n authority: ProgramDerivedAddress;\n oracle: ProgramDerivedAddress;\n}> {\n const [config, authority, oracle] = await Promise.all([\n getConfigAddress(programId),\n getPoolAuthorityAddress(pool, programId),\n getOracleAddress(pool, programId),\n ]);\n\n return { config, authority, oracle };\n}\n\n/**\n * Derive all PDAs needed for liquidity operations\n */\nexport async function getLiquidityAddresses(\n pool: Address,\n owner: Address,\n positionId: bigint,\n programId: Address = CPMM_PROGRAM_ID,\n): Promise<{\n config: ProgramDerivedAddress;\n authority: ProgramDerivedAddress;\n position: ProgramDerivedAddress;\n protocolPosition: ProgramDerivedAddress;\n oracle: ProgramDerivedAddress;\n}> {\n const [config, authority, position, protocolPosition, oracle] =\n await Promise.all([\n getConfigAddress(programId),\n getPoolAuthorityAddress(pool, programId),\n getPositionAddress(pool, owner, positionId, programId),\n getProtocolPositionAddress(pool, programId),\n getOracleAddress(pool, programId),\n ]);\n\n return { config, authority, position, protocolPosition, oracle };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/solana/core/constants.ts","../src/solana/core/pda.ts"],"names":[],"mappings":";;;;;;AAWO,IAAM,eAAA,GAA2B,OAAA;AAAA,EACtC;AACF;AAKO,IAAM,yBAAA,GAAqC,OAAA;AAAA,EAChD;AACF;AAOO,IAAM,SAAA,GAAY;AAGlB,IAAM,UAAU,EAAA,IAAM;AAGtB,IAAM,eAAA,GAAkB;AAOxB,IAAM,sBAAA,GAAyB;AAG/B,IAAM,uBAAA,GAA0B;AAOhC,IAAM,WAAA,GAAc;AAGpB,IAAM,SAAA,GAAY;AAGlB,IAAM,cAAA,GAAiB;AAGvB,IAAM,aAAA,GAAgB;AAGtB,IAAM,WAAA,GAAc;AAGpB,IAAM,sBAAA,GAAyB;AAO/B,IAAM,iBAAiB,CAAA,IAAK;AAG5B,IAAM,gBAAgB,CAAA,IAAK;AAG3B,IAAM,oBAAoB,CAAA,IAAK;AAG/B,IAAM,mBAAmB,CAAA,IAAK;AAG9B,IAAM,uBAAuB,CAAA,IAAK;AAGlC,IAAM,sBAAsB,CAAA,IAAK;AAGjC,IAAM,kBAAA,GAAqB;AAU3B,IAAM,0BAAA,GAA6B;AAAA;AAAA,EAExC,gBAAA,EAAkB,IAAI,UAAA,CAA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AA,CAAQ,GAAA,CAAI;AAAA,IAChB,iBAAiB,SAAS,CAAA;AAAA,IAC1B,uBAAA,CAAwB,MAAM,SAAS,CAAA;AAAA,IACvC,kBAAA,CAAmB,IAAA,EAAM,KAAA,EAAO,UAAA,EAAY,SAAS,CAAA;AAAA,IACrD,0BAAA,CAA2B,MAAM,SAAS,CAAA;AAAA,IAC1C,gBAAA,CAAiB,MAAM,SAAS;AAAA,GACjC,CAAA;AAEH,EAAA,OAAO,EAAE,MAAA,EAAQ,SAAA,EAAW,QAAA,EAAU,kBAAkB,MAAA,EAAO;AACjE","file":"chunk-J57ROY36.js","sourcesContent":["import { address, type Address } from '@solana/kit';\nexport {\n TOKEN_PROGRAM_ADDRESS,\n ASSOCIATED_TOKEN_PROGRAM_ADDRESS,\n} from '@solana-program/token';\nexport { SYSTEM_PROGRAM_ADDRESS } from '@solana-program/system';\nexport { SYSVAR_RENT_ADDRESS } from '@solana/sysvars';\n\n/**\n * CPMM AMM program ID (devnet)\n */\nexport const CPMM_PROGRAM_ID: Address = address(\n '9PSxVPoPfnbZ8Q1uQhgS6ZxvBjFboZtebNsu34umxkgQ',\n);\n\n/**\n * Metaplex Token Metadata Program ID\n */\nexport const TOKEN_METADATA_PROGRAM_ID: Address = address(\n 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s',\n);\n\n// ============================================================================\n// Math Constants\n// ============================================================================\n\n/** Basis points denominator (10,000 = 100%) */\nexport const BPS_DENOM = 10_000n;\n\n/** Q64.64 fixed-point representation of 1.0 (2^64) */\nexport const Q64_ONE = 1n << 64n;\n\n/** Current account version */\nexport const ACCOUNT_VERSION = 1;\n\n// ============================================================================\n// Array Size Constants\n// ============================================================================\n\n/** Maximum number of programs in sentinel allowlist */\nexport const MAX_SENTINEL_ALLOWLIST = 32;\n\n/** Maximum number of oracle observations (TWAP buffer size) */\nexport const MAX_ORACLE_OBSERVATIONS = 64;\n\n// ============================================================================\n// PDA Seeds\n// ============================================================================\n\n/** Seed for AmmConfig PDA: ['config'] */\nexport const SEED_CONFIG = 'config';\n\n/** Seed prefix for Pool PDA: ['pool', token0_mint, token1_mint] */\nexport const SEED_POOL = 'pool';\n\n/** Seed prefix for pool authority PDA: ['authority', pool] */\nexport const SEED_AUTHORITY = 'authority';\n\n/** Seed prefix for Position PDA: ['position', pool, owner, position_id] */\nexport const SEED_POSITION = 'position';\n\n/** Seed prefix for OracleState PDA: ['oracle', pool] */\nexport const SEED_ORACLE = 'oracle';\n\n/** Seed prefix for protocol position PDA: ['protocol_position', pool] */\nexport const SEED_PROTOCOL_POSITION = 'protocol_position';\n\n// ============================================================================\n// Sentinel Flags\n// ============================================================================\n\n/** Sentinel hook: called before swap */\nexport const SF_BEFORE_SWAP = 1 << 0;\n\n/** Sentinel hook: called after swap */\nexport const SF_AFTER_SWAP = 1 << 1;\n\n/** Sentinel hook: called before add liquidity */\nexport const SF_BEFORE_ADD_LIQ = 1 << 2;\n\n/** Sentinel hook: called after add liquidity */\nexport const SF_AFTER_ADD_LIQ = 1 << 3;\n\n/** Sentinel hook: called before remove liquidity */\nexport const SF_BEFORE_REMOVE_LIQ = 1 << 4;\n\n/** Sentinel hook: called after remove liquidity */\nexport const SF_AFTER_REMOVE_LIQ = 1 << 5;\n\n/** Sentinel return value indicating \"no change\" to fee parameter */\nexport const SENTINEL_NO_CHANGE = 0xffff;\n\n// ============================================================================\n// Instruction Discriminators (Anchor 8-byte hashes)\n// ============================================================================\n\n/**\n * Anchor instruction discriminator (first 8 bytes of SHA256(\"global:<instruction_name>\"))\n * These are computed at build time from the instruction names.\n */\nexport const INSTRUCTION_DISCRIMINATORS = {\n // SHA256(\"global:initialize_config\")[0:8]\n initializeConfig: new Uint8Array([\n 0xd0, 0x7f, 0x15, 0x01, 0xc2, 0xbe, 0xc4, 0x46,\n ]),\n // SHA256(\"global:initialize_pool\")[0:8]\n initializePool: new Uint8Array([\n 0x5f, 0xb4, 0x0a, 0xac, 0x54, 0xae, 0xe8, 0x28,\n ]),\n // SHA256(\"global:initialize_oracle\")[0:8]\n initializeOracle: new Uint8Array([\n 0x90, 0xdf, 0x83, 0x78, 0xc4, 0xfd, 0xb5, 0x63,\n ]),\n // SHA256(\"global:create_position\")[0:8]\n createPosition: new Uint8Array([\n 0x30, 0xd7, 0xc5, 0x99, 0x60, 0xcb, 0xb4, 0x85,\n ]),\n // SHA256(\"global:add_liquidity\")[0:8]\n addLiquidity: new Uint8Array([\n 0xb5, 0x9d, 0x59, 0x43, 0x8f, 0xb6, 0x34, 0x48,\n ]),\n // SHA256(\"global:remove_liquidity\")[0:8]\n removeLiquidity: new Uint8Array([\n 0x50, 0x55, 0xd1, 0x48, 0x18, 0xce, 0xb1, 0x6c,\n ]),\n // SHA256(\"global:swap_exact_in\")[0:8]\n swapExactIn: new Uint8Array([0x68, 0x68, 0x83, 0x56, 0xa1, 0xbd, 0xb4, 0xd8]),\n // SHA256(\"global:collect_fees\")[0:8]\n collectFees: new Uint8Array([0xa4, 0x98, 0xcf, 0x63, 0x1e, 0xba, 0x13, 0xb6]),\n // SHA256(\"global:collect_protocol_fees\")[0:8]\n collectProtocolFees: new Uint8Array([\n 0x16, 0x43, 0x17, 0x62, 0x96, 0xb2, 0x46, 0xdc,\n ]),\n // SHA256(\"global:close_position\")[0:8]\n closePosition: new Uint8Array([\n 0x7b, 0x86, 0x51, 0x00, 0x31, 0x44, 0x62, 0x62,\n ]),\n // SHA256(\"global:oracle_update\")[0:8]\n oracleUpdate: new Uint8Array([\n 0x55, 0xd1, 0xf8, 0x8e, 0xba, 0xf9, 0x78, 0xef,\n ]),\n // SHA256(\"global:oracle_consult\")[0:8]\n oracleConsult: new Uint8Array([\n 0xef, 0xed, 0xff, 0xb1, 0x8e, 0x48, 0x60, 0xaf,\n ]),\n // SHA256(\"global:quote_to_numeraire\")[0:8]\n quoteToNumeraire: new Uint8Array([\n 0x04, 0x8e, 0xf9, 0xf0, 0x81, 0x0f, 0x8f, 0x39,\n ]),\n // SHA256(\"global:set_sentinel\")[0:8]\n setSentinel: new Uint8Array([0x5e, 0xc8, 0x52, 0x81, 0x35, 0x95, 0xe8, 0x71]),\n // SHA256(\"global:set_fees\")[0:8]\n setFees: new Uint8Array([0x89, 0xb2, 0x31, 0x3a, 0x00, 0xf5, 0xf2, 0xbe]),\n // SHA256(\"global:set_route\")[0:8]\n setRoute: new Uint8Array([0xf4, 0xe7, 0x03, 0x54, 0xe9, 0x3d, 0x92, 0x95]),\n // SHA256(\"global:transfer_admin\")[0:8]\n transferAdmin: new Uint8Array([\n 0x2a, 0xf2, 0x42, 0x6a, 0xe4, 0x0a, 0x6f, 0x9c,\n ]),\n // SHA256(\"global:pause\")[0:8]\n pause: new Uint8Array([0xd3, 0x16, 0xdd, 0xfb, 0x4a, 0x79, 0xc1, 0x2f]),\n // SHA256(\"global:unpause\")[0:8]\n unpause: new Uint8Array([0xa9, 0x90, 0x04, 0x26, 0x0a, 0x8d, 0xbc, 0xff]),\n // SHA256(\"global:skim\")[0:8]\n skim: new Uint8Array([0xee, 0x78, 0xdd, 0x8a, 0x52, 0x3c, 0x64, 0xda]),\n} as const;\n\n// ============================================================================\n// Account Discriminators (Anchor 8-byte hashes)\n// ============================================================================\n\n/**\n * Anchor account discriminator (first 8 bytes of SHA256(\"account:<AccountName>\"))\n */\nexport const ACCOUNT_DISCRIMINATORS = {\n // SHA256(\"account:AmmConfig\")[0:8]\n AmmConfig: new Uint8Array([0xda, 0xf4, 0x21, 0x68, 0xcb, 0xcb, 0x2b, 0x6f]),\n // SHA256(\"account:Pool\")[0:8]\n Pool: new Uint8Array([0xf1, 0x9a, 0x6d, 0x04, 0x11, 0xb1, 0x6d, 0xbc]),\n // SHA256(\"account:Position\")[0:8]\n Position: new Uint8Array([0xaa, 0xbc, 0x8f, 0xe4, 0x7a, 0x40, 0xf7, 0xd0]),\n // SHA256(\"account:OracleState\")[0:8]\n OracleState: new Uint8Array([0x61, 0x9c, 0x9d, 0xbd, 0xc2, 0x49, 0x08, 0x0f]),\n} as const;\n","import {\n type Address,\n type ProgramDerivedAddress,\n getAddressCodec,\n getProgramDerivedAddress,\n} from '@solana/kit';\nimport {\n CPMM_PROGRAM_ID,\n SEED_CONFIG,\n SEED_POOL,\n SEED_AUTHORITY,\n SEED_POSITION,\n SEED_ORACLE,\n SEED_PROTOCOL_POSITION,\n} from './constants.js';\n\nconst addressCodec = getAddressCodec();\nconst textEncoder = new TextEncoder();\n\n// ============================================================================\n// Token Sorting\n// ============================================================================\n\n/**\n * Sort two mints into canonical order (token0 < token1 by bytes)\n * This is required for Pool PDA derivation and instruction ordering.\n *\n * @param mint0 - First mint address\n * @param mint1 - Second mint address\n * @returns Tuple of [token0, token1] in canonical order\n * @throws Error if mints are equal\n */\nexport function sortMints(mint0: Address, mint1: Address): [Address, Address] {\n const bytesA = addressCodec.encode(mint0);\n const bytesB = addressCodec.encode(mint1);\n\n for (let i = 0; i < 32; i++) {\n if (bytesA[i] < bytesB[i]) {\n return [mint0, mint1];\n }\n if (bytesA[i] > bytesB[i]) {\n return [mint1, mint0];\n }\n }\n\n throw new Error('Mints are equal - cannot create pool with identical tokens');\n}\n\n/**\n * Check if mints are in canonical order\n */\nexport function areMintsOrdered(mint0: Address, mint1: Address): boolean {\n const bytes0 = addressCodec.encode(mint0);\n const bytes1 = addressCodec.encode(mint1);\n\n for (let i = 0; i < 32; i++) {\n if (bytes0[i] < bytes1[i]) return true;\n if (bytes0[i] > bytes1[i]) return false;\n }\n return false; // equal\n}\n\n// ============================================================================\n// PDA Derivation Functions\n// ============================================================================\n\n/**\n * Derive the AmmConfig PDA address\n * Seeds: ['config']\n */\nexport async function getConfigAddress(\n programId: Address = CPMM_PROGRAM_ID,\n): Promise<ProgramDerivedAddress> {\n return getProgramDerivedAddress({\n programAddress: programId,\n seeds: [textEncoder.encode(SEED_CONFIG)],\n });\n}\n\n/**\n * Derive the Pool PDA address for a token pair\n * Seeds: ['pool', token0_mint, token1_mint]\n *\n * Note: Mints will be automatically sorted if not in canonical order.\n */\nexport async function getPoolAddress(\n mint0: Address,\n mint1: Address,\n programId: Address = CPMM_PROGRAM_ID,\n): Promise<ProgramDerivedAddress> {\n const [token0, token1] = sortMints(mint0, mint1);\n return getProgramDerivedAddress({\n programAddress: programId,\n seeds: [\n textEncoder.encode(SEED_POOL),\n addressCodec.encode(token0),\n addressCodec.encode(token1),\n ],\n });\n}\n\n/**\n * Derive the Pool authority PDA (vault owner)\n * Seeds: ['authority', pool]\n */\nexport async function getPoolAuthorityAddress(\n pool: Address,\n programId: Address = CPMM_PROGRAM_ID,\n): Promise<ProgramDerivedAddress> {\n return getProgramDerivedAddress({\n programAddress: programId,\n seeds: [textEncoder.encode(SEED_AUTHORITY), addressCodec.encode(pool)],\n });\n}\n\n/**\n * Derive the Position PDA address\n * Seeds: ['position', pool, owner, position_id_le_bytes]\n */\nexport async function getPositionAddress(\n pool: Address,\n owner: Address,\n positionId: bigint,\n programId: Address = CPMM_PROGRAM_ID,\n): Promise<ProgramDerivedAddress> {\n const positionIdBytes = new Uint8Array(8);\n const view = new DataView(positionIdBytes.buffer);\n view.setBigUint64(0, positionId, true); // little-endian\n\n return getProgramDerivedAddress({\n programAddress: programId,\n seeds: [\n textEncoder.encode(SEED_POSITION),\n addressCodec.encode(pool),\n addressCodec.encode(owner),\n positionIdBytes,\n ],\n });\n}\n\n/**\n * Derive the OracleState PDA address\n * Seeds: ['oracle', pool]\n */\nexport async function getOracleAddress(\n pool: Address,\n programId: Address = CPMM_PROGRAM_ID,\n): Promise<ProgramDerivedAddress> {\n return getProgramDerivedAddress({\n programAddress: programId,\n seeds: [textEncoder.encode(SEED_ORACLE), addressCodec.encode(pool)],\n });\n}\n\n/**\n * Derive the Protocol Position PDA address\n * Seeds: ['protocol_position', pool]\n */\nexport async function getProtocolPositionAddress(\n pool: Address,\n programId: Address = CPMM_PROGRAM_ID,\n): Promise<ProgramDerivedAddress> {\n return getProgramDerivedAddress({\n programAddress: programId,\n seeds: [\n textEncoder.encode(SEED_PROTOCOL_POSITION),\n addressCodec.encode(pool),\n ],\n });\n}\n\n// ============================================================================\n// Batch PDA Derivation\n// ============================================================================\n\n/**\n * Derive all PDAs needed for pool initialization\n */\nexport async function getPoolInitAddresses(\n mint0: Address,\n mint1: Address,\n programId: Address = CPMM_PROGRAM_ID,\n): Promise<{\n token0: Address;\n token1: Address;\n pool: ProgramDerivedAddress;\n authority: ProgramDerivedAddress;\n config: ProgramDerivedAddress;\n protocolPosition: ProgramDerivedAddress;\n}> {\n const [token0, token1] = sortMints(mint0, mint1);\n const [config, pool] = await Promise.all([\n getConfigAddress(programId),\n getPoolAddress(token0, token1, programId),\n ]);\n const [authority, protocolPosition] = await Promise.all([\n getPoolAuthorityAddress(pool[0], programId),\n getProtocolPositionAddress(pool[0], programId),\n ]);\n\n return {\n token0,\n token1,\n pool,\n authority,\n config,\n protocolPosition,\n };\n}\n\n/**\n * Derive all PDAs needed for swap operation\n */\nexport async function getSwapAddresses(\n pool: Address,\n programId: Address = CPMM_PROGRAM_ID,\n): Promise<{\n config: ProgramDerivedAddress;\n authority: ProgramDerivedAddress;\n oracle: ProgramDerivedAddress;\n}> {\n const [config, authority, oracle] = await Promise.all([\n getConfigAddress(programId),\n getPoolAuthorityAddress(pool, programId),\n getOracleAddress(pool, programId),\n ]);\n\n return { config, authority, oracle };\n}\n\n/**\n * Derive all PDAs needed for liquidity operations\n */\nexport async function getLiquidityAddresses(\n pool: Address,\n owner: Address,\n positionId: bigint,\n programId: Address = CPMM_PROGRAM_ID,\n): Promise<{\n config: ProgramDerivedAddress;\n authority: ProgramDerivedAddress;\n position: ProgramDerivedAddress;\n protocolPosition: ProgramDerivedAddress;\n oracle: ProgramDerivedAddress;\n}> {\n const [config, authority, position, protocolPosition, oracle] =\n await Promise.all([\n getConfigAddress(programId),\n getPoolAuthorityAddress(pool, programId),\n getPositionAddress(pool, owner, positionId, programId),\n getProtocolPositionAddress(pool, programId),\n getOracleAddress(pool, programId),\n ]);\n\n return { config, authority, position, protocolPosition, oracle };\n}\n"]}
@@ -1,4 +0,0 @@
1
- export { areMintsOrdered, getConfigAddress, getLiquidityAddresses, getOracleAddress, getPoolAddress, getPoolAuthorityAddress, getPoolInitAddresses, getPositionAddress, getProtocolPositionAddress, getSwapAddresses, sortMints } from './chunk-J57ROY36.js';
2
- import './chunk-PZ5AY32C.js';
3
- //# sourceMappingURL=pda-TXZDXZZ4.js.map
4
- //# sourceMappingURL=pda-TXZDXZZ4.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"pda-TXZDXZZ4.js"}
@@ -1,53 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkDPKVNI6Q_cjs = require('./chunk-DPKVNI6Q.cjs');
4
- require('./chunk-Q7SFCCGT.cjs');
5
-
6
-
7
-
8
- Object.defineProperty(exports, "areMintsOrdered", {
9
- enumerable: true,
10
- get: function () { return chunkDPKVNI6Q_cjs.areMintsOrdered; }
11
- });
12
- Object.defineProperty(exports, "getConfigAddress", {
13
- enumerable: true,
14
- get: function () { return chunkDPKVNI6Q_cjs.getConfigAddress; }
15
- });
16
- Object.defineProperty(exports, "getLiquidityAddresses", {
17
- enumerable: true,
18
- get: function () { return chunkDPKVNI6Q_cjs.getLiquidityAddresses; }
19
- });
20
- Object.defineProperty(exports, "getOracleAddress", {
21
- enumerable: true,
22
- get: function () { return chunkDPKVNI6Q_cjs.getOracleAddress; }
23
- });
24
- Object.defineProperty(exports, "getPoolAddress", {
25
- enumerable: true,
26
- get: function () { return chunkDPKVNI6Q_cjs.getPoolAddress; }
27
- });
28
- Object.defineProperty(exports, "getPoolAuthorityAddress", {
29
- enumerable: true,
30
- get: function () { return chunkDPKVNI6Q_cjs.getPoolAuthorityAddress; }
31
- });
32
- Object.defineProperty(exports, "getPoolInitAddresses", {
33
- enumerable: true,
34
- get: function () { return chunkDPKVNI6Q_cjs.getPoolInitAddresses; }
35
- });
36
- Object.defineProperty(exports, "getPositionAddress", {
37
- enumerable: true,
38
- get: function () { return chunkDPKVNI6Q_cjs.getPositionAddress; }
39
- });
40
- Object.defineProperty(exports, "getProtocolPositionAddress", {
41
- enumerable: true,
42
- get: function () { return chunkDPKVNI6Q_cjs.getProtocolPositionAddress; }
43
- });
44
- Object.defineProperty(exports, "getSwapAddresses", {
45
- enumerable: true,
46
- get: function () { return chunkDPKVNI6Q_cjs.getSwapAddresses; }
47
- });
48
- Object.defineProperty(exports, "sortMints", {
49
- enumerable: true,
50
- get: function () { return chunkDPKVNI6Q_cjs.sortMints; }
51
- });
52
- //# sourceMappingURL=pda-ZZMBZSFU.cjs.map
53
- //# sourceMappingURL=pda-ZZMBZSFU.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"pda-ZZMBZSFU.cjs"}