@whetstone-research/doppler-sdk 1.0.19 → 1.0.20

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.
Files changed (35) hide show
  1. package/dist/chunk-BESE77DM.js +3840 -0
  2. package/dist/chunk-BESE77DM.js.map +1 -0
  3. package/dist/chunk-KJ6W44WF.cjs +4089 -0
  4. package/dist/chunk-KJ6W44WF.cjs.map +1 -0
  5. package/dist/{chunk-AKLS6T3R.cjs → chunk-Y6TJIH33.cjs} +36 -24
  6. package/dist/chunk-Y6TJIH33.cjs.map +1 -0
  7. package/dist/{chunk-6TOPYGOG.js → chunk-ZUJKBFXW.js} +35 -24
  8. package/dist/chunk-ZUJKBFXW.js.map +1 -0
  9. package/dist/{oracle-7PmpwwPx.d.ts → oracle-D1wPWydZ.d.cts} +1 -33
  10. package/dist/{oracle-7PmpwwPx.d.cts → oracle-D1wPWydZ.d.ts} +1 -33
  11. package/dist/{pda-PZRHQJMK.cjs → pda-A4PIAS5Y.cjs} +20 -16
  12. package/dist/pda-A4PIAS5Y.cjs.map +1 -0
  13. package/dist/{pda-N6ULJYLG.js → pda-JVAD45XJ.js} +3 -3
  14. package/dist/pda-JVAD45XJ.js.map +1 -0
  15. package/dist/solana/index.cjs +391 -3247
  16. package/dist/solana/index.cjs.map +1 -1
  17. package/dist/solana/index.d.cts +176 -207
  18. package/dist/solana/index.d.ts +176 -207
  19. package/dist/solana/index.js +67 -2923
  20. package/dist/solana/index.js.map +1 -1
  21. package/dist/solana/react/index.cjs +53 -85
  22. package/dist/solana/react/index.cjs.map +1 -1
  23. package/dist/solana/react/index.d.cts +7 -1
  24. package/dist/solana/react/index.d.ts +7 -1
  25. package/dist/solana/react/index.js +15 -47
  26. package/dist/solana/react/index.js.map +1 -1
  27. package/package.json +1 -1
  28. package/dist/chunk-6TOPYGOG.js.map +0 -1
  29. package/dist/chunk-AKLS6T3R.cjs.map +0 -1
  30. package/dist/chunk-C2D7CIXP.js +0 -977
  31. package/dist/chunk-C2D7CIXP.js.map +0 -1
  32. package/dist/chunk-GUGN3EYX.cjs +0 -1069
  33. package/dist/chunk-GUGN3EYX.cjs.map +0 -1
  34. package/dist/pda-N6ULJYLG.js.map +0 -1
  35. package/dist/pda-PZRHQJMK.cjs.map +0 -1
@@ -28,7 +28,7 @@ var SEED_VAULT0 = "vault0";
28
28
  var SEED_VAULT1 = "vault1";
29
29
  var SEED_POSITION = "position";
30
30
  var SEED_ORACLE = "oracle";
31
- var SEED_PROTOCOL_FEE_POSITION = "protocol_position";
31
+ var SEED_PROTOCOL_FEE_OWNER = "protocol_fee_owner";
32
32
  var HF_BEFORE_SWAP = 1 << 0;
33
33
  var HF_AFTER_SWAP = 1 << 1;
34
34
  var HF_BEFORE_ADD_LIQ = 1 << 2;
@@ -153,23 +153,10 @@ var INSTRUCTION_DISCRIMINATORS = {
153
153
  96,
154
154
  175
155
155
  ]),
156
- // SHA256("global:quote_to_numeraire")[0:8]
157
- quoteToNumeraire: new Uint8Array([
158
- 4,
159
- 142,
160
- 249,
161
- 240,
162
- 129,
163
- 15,
164
- 143,
165
- 57
166
- ]),
167
156
  // SHA256("global:set_hook")[0:8]
168
157
  setHook: new Uint8Array([175, 16, 187, 252, 19, 54, 111, 221]),
169
158
  // SHA256("global:set_fees")[0:8]
170
159
  setFees: new Uint8Array([137, 178, 49, 58, 0, 245, 242, 190]),
171
- // SHA256("global:set_route")[0:8]
172
- setRoute: new Uint8Array([244, 231, 3, 84, 233, 61, 146, 149]),
173
160
  // SHA256("global:transfer_admin")[0:8]
174
161
  transferAdmin: new Uint8Array([
175
162
  42,
@@ -288,27 +275,37 @@ async function getOracleAddress(pool, programId = CPMM_PROGRAM_ID) {
288
275
  seeds: [textEncoder.encode(SEED_ORACLE), addressCodec.encode(pool)]
289
276
  });
290
277
  }
291
- async function getProtocolFeePositionAddress(pool, programId = CPMM_PROGRAM_ID) {
278
+ async function getProtocolFeeOwnerAddress(pool, programId = CPMM_PROGRAM_ID) {
292
279
  return kit.getProgramDerivedAddress({
293
280
  programAddress: programId,
294
281
  seeds: [
295
- textEncoder.encode(SEED_PROTOCOL_FEE_POSITION),
282
+ textEncoder.encode(SEED_PROTOCOL_FEE_OWNER),
296
283
  addressCodec.encode(pool)
297
284
  ]
298
285
  });
299
286
  }
287
+ async function getProtocolFeePositionAddress(pool, programId = CPMM_PROGRAM_ID) {
288
+ const [protocolFeeOwner] = await getProtocolFeeOwnerAddress(pool, programId);
289
+ return getPositionAddress(pool, protocolFeeOwner, 0n, programId);
290
+ }
300
291
  async function getPoolInitAddresses(mint0, mint1, programId = CPMM_PROGRAM_ID) {
301
292
  const [token0, token1] = sortMints(mint0, mint1);
302
293
  const [config, pool] = await Promise.all([
303
294
  getConfigAddress(programId),
304
295
  getPoolAddress(token0, token1, programId)
305
296
  ]);
306
- const [authority, vault0, vault1, protocolFeePosition] = await Promise.all([
297
+ const [authority, vault0, vault1, protocolFeeOwner] = await Promise.all([
307
298
  getPoolAuthorityAddress(pool[0], programId),
308
299
  getPoolVault0Address(pool[0], programId),
309
300
  getPoolVault1Address(pool[0], programId),
310
- getProtocolFeePositionAddress(pool[0], programId)
301
+ getProtocolFeeOwnerAddress(pool[0], programId)
311
302
  ]);
303
+ const protocolFeePosition = await getPositionAddress(
304
+ pool[0],
305
+ protocolFeeOwner[0],
306
+ 0n,
307
+ programId
308
+ );
312
309
  return {
313
310
  token0,
314
311
  token1,
@@ -317,6 +314,7 @@ async function getPoolInitAddresses(mint0, mint1, programId = CPMM_PROGRAM_ID) {
317
314
  vault0,
318
315
  vault1,
319
316
  config,
317
+ protocolFeeOwner,
320
318
  protocolFeePosition
321
319
  };
322
320
  }
@@ -329,14 +327,27 @@ async function getSwapAddresses(pool, programId = CPMM_PROGRAM_ID) {
329
327
  return { config, authority, oracle };
330
328
  }
331
329
  async function getLiquidityAddresses(pool, owner, positionId, programId = CPMM_PROGRAM_ID) {
332
- const [config, authority, position, protocolFeePosition, oracle] = await Promise.all([
330
+ const [config, authority, position, protocolFeeOwner, oracle] = await Promise.all([
333
331
  getConfigAddress(programId),
334
332
  getPoolAuthorityAddress(pool, programId),
335
333
  getPositionAddress(pool, owner, positionId, programId),
336
- getProtocolFeePositionAddress(pool, programId),
334
+ getProtocolFeeOwnerAddress(pool, programId),
337
335
  getOracleAddress(pool, programId)
338
336
  ]);
339
- return { config, authority, position, protocolFeePosition, oracle };
337
+ const protocolFeePosition = await getPositionAddress(
338
+ pool,
339
+ protocolFeeOwner[0],
340
+ 0n,
341
+ programId
342
+ );
343
+ return {
344
+ config,
345
+ authority,
346
+ position,
347
+ protocolFeeOwner,
348
+ protocolFeePosition,
349
+ oracle
350
+ };
340
351
  }
341
352
 
342
353
  Object.defineProperty(exports, "TOKEN_PROGRAM_ADDRESS", {
@@ -369,7 +380,7 @@ exports.SEED_CONFIG = SEED_CONFIG;
369
380
  exports.SEED_ORACLE = SEED_ORACLE;
370
381
  exports.SEED_POOL = SEED_POOL;
371
382
  exports.SEED_POSITION = SEED_POSITION;
372
- exports.SEED_PROTOCOL_FEE_POSITION = SEED_PROTOCOL_FEE_POSITION;
383
+ exports.SEED_PROTOCOL_FEE_OWNER = SEED_PROTOCOL_FEE_OWNER;
373
384
  exports.TOKEN_METADATA_PROGRAM_ID = TOKEN_METADATA_PROGRAM_ID;
374
385
  exports.areMintsOrdered = areMintsOrdered;
375
386
  exports.getConfigAddress = getConfigAddress;
@@ -381,8 +392,9 @@ exports.getPoolInitAddresses = getPoolInitAddresses;
381
392
  exports.getPoolVault0Address = getPoolVault0Address;
382
393
  exports.getPoolVault1Address = getPoolVault1Address;
383
394
  exports.getPositionAddress = getPositionAddress;
395
+ exports.getProtocolFeeOwnerAddress = getProtocolFeeOwnerAddress;
384
396
  exports.getProtocolFeePositionAddress = getProtocolFeePositionAddress;
385
397
  exports.getSwapAddresses = getSwapAddresses;
386
398
  exports.sortMints = sortMints;
387
- //# sourceMappingURL=chunk-AKLS6T3R.cjs.map
388
- //# sourceMappingURL=chunk-AKLS6T3R.cjs.map
399
+ //# sourceMappingURL=chunk-Y6TJIH33.cjs.map
400
+ //# sourceMappingURL=chunk-Y6TJIH33.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/solana/core/constants.ts","../src/solana/core/pda.ts"],"names":["address","getAddressCodec","getProgramDerivedAddress"],"mappings":";;;;;;;;AAOoDA,WAAA;AAAA,EAClD;AACF;AAKO,IAAM,sBAAA,GAAkCA,WAAA;AAAA,EAC7C;AACF,CAAA;AAKO,IAAM,eAAA,GAAkB;AAKxB,IAAM,yBAAA,GAAqCA,WAAA;AAAA,EAChD;AACF;AAOO,IAAM,SAAA,GAAY;AAGlB,IAAM,UAAU,EAAA,IAAM;AAGtB,IAAM,eAAA,GAAkB;AAOxB,IAAM,kBAAA,GAAqB;AAG3B,IAAM,uBAAA,GAA0B;AAOhC,IAAM,WAAA,GAAc;AAGpB,IAAM,SAAA,GAAY;AAGlB,IAAM,cAAA,GAAiB;AAGvB,IAAM,WAAA,GAAc,QAAA;AAGpB,IAAM,WAAA,GAAc,QAAA;AAGpB,IAAM,aAAA,GAAgB;AAGtB,IAAM,WAAA,GAAc;AAGpB,IAAM,uBAAA,GAA0B;AAOhC,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,oBAAoB,CAAA,IAAK;AAG/B,IAAM,8BAA8B,CAAA,IAAK;AAGzC,IAAM,cAAA,GAAiB;AAUvB,IAAM,0BAAA,GAA6B;AAAA;AAAA,EAExC,gBAAA,EAAkB,IAAI,UAAA,CAAW;AAAA,IAC/B,GAAA;AAAA,IAAM,GAAA;AAAA,IAAM,EAAA;AAAA,IAAM,CAAA;AAAA,IAAM,GAAA;AAAA,IAAM,GAAA;AAAA,IA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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';\nexport const SYSVAR_INSTRUCTIONS_ADDRESS: Address = address(\n 'Sysvar1nstructions1111111111111111111111111',\n);\n\n/**\n * CPMM AMM program ID for the default devnet deployment.\n */\nexport const DEVNET_CPMM_PROGRAM_ID: Address = address(\n '9PSxVPoPfnbZ8Q1uQhgS6ZxvBjFboZtebNsu34umxkgQ',\n);\n\n/**\n * @deprecated Use DEVNET_CPMM_PROGRAM_ID or pass an explicit deployment.\n */\nexport const CPMM_PROGRAM_ID = DEVNET_CPMM_PROGRAM_ID;\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 hook allowlist */\nexport const MAX_HOOK_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 token0 vault PDA: ['vault0', pool] */\nexport const SEED_VAULT0 = 'vault0';\n\n/** Seed prefix for token1 vault PDA: ['vault1', pool] */\nexport const SEED_VAULT1 = 'vault1';\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 fee owner PDA: ['protocol_fee_owner', pool] */\nexport const SEED_PROTOCOL_FEE_OWNER = 'protocol_fee_owner';\n\n// ============================================================================\n// Hook Flags\n// ============================================================================\n\n/** Hook: called before swap */\nexport const HF_BEFORE_SWAP = 1 << 0;\n\n/** Hook: called after swap */\nexport const HF_AFTER_SWAP = 1 << 1;\n\n/** Hook: called before add liquidity */\nexport const HF_BEFORE_ADD_LIQ = 1 << 2;\n\n/** Hook: called after add liquidity */\nexport const HF_AFTER_ADD_LIQ = 1 << 3;\n\n/** Hook: called before remove liquidity */\nexport const HF_BEFORE_REMOVE_LIQ = 1 << 4;\n\n/** Hook: called after remove liquidity */\nexport const HF_AFTER_REMOVE_LIQ = 1 << 5;\n\n/** Require an oracle account when invoking hooks */\nexport const HF_REQUIRE_ORACLE = 1 << 6;\n\n/** Preserve readonly signer metas when forwarding remaining accounts to hooks */\nexport const HF_FORWARD_READONLY_SIGNERS = 1 << 7;\n\n/** Hook return value indicating \"no change\" to fee parameter */\nexport const HOOK_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:set_hook\")[0:8]\n setHook: new Uint8Array([0xaf, 0x10, 0xbb, 0xfc, 0x13, 0x36, 0x6f, 0xdd]),\n // SHA256(\"global:set_fees\")[0:8]\n setFees: new Uint8Array([0x89, 0xb2, 0x31, 0x3a, 0x00, 0xf5, 0xf2, 0xbe]),\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:withdraw_vault_excess\")[0:8]\n withdrawVaultExcess: new Uint8Array([\n 0xeb, 0xc5, 0xf7, 0xb1, 0x89, 0x48, 0x87, 0x71,\n ]),\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_VAULT0,\n SEED_VAULT1,\n SEED_POSITION,\n SEED_ORACLE,\n SEED_PROTOCOL_FEE_OWNER,\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 token0 vault PDA.\n * Seeds: ['vault0', pool]\n */\nexport async function getPoolVault0Address(\n pool: Address,\n programId: Address = CPMM_PROGRAM_ID,\n): Promise<ProgramDerivedAddress> {\n return getProgramDerivedAddress({\n programAddress: programId,\n seeds: [textEncoder.encode(SEED_VAULT0), addressCodec.encode(pool)],\n });\n}\n\n/**\n * Derive the token1 vault PDA.\n * Seeds: ['vault1', pool]\n */\nexport async function getPoolVault1Address(\n pool: Address,\n programId: Address = CPMM_PROGRAM_ID,\n): Promise<ProgramDerivedAddress> {\n return getProgramDerivedAddress({\n programAddress: programId,\n seeds: [textEncoder.encode(SEED_VAULT1), 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 fee owner PDA address\n * Seeds: ['protocol_fee_owner', pool]\n */\nexport async function getProtocolFeeOwnerAddress(\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_FEE_OWNER),\n addressCodec.encode(pool),\n ],\n });\n}\n\n/**\n * Derive the protocol fee position PDA address.\n * Seeds: ['position', pool, protocol_fee_owner, 0]\n */\nexport async function getProtocolFeePositionAddress(\n pool: Address,\n programId: Address = CPMM_PROGRAM_ID,\n): Promise<ProgramDerivedAddress> {\n const [protocolFeeOwner] = await getProtocolFeeOwnerAddress(pool, programId);\n return getPositionAddress(pool, protocolFeeOwner, 0n, programId);\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 vault0: ProgramDerivedAddress;\n vault1: ProgramDerivedAddress;\n config: ProgramDerivedAddress;\n protocolFeeOwner: ProgramDerivedAddress;\n protocolFeePosition: 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, vault0, vault1, protocolFeeOwner] = await Promise.all([\n getPoolAuthorityAddress(pool[0], programId),\n getPoolVault0Address(pool[0], programId),\n getPoolVault1Address(pool[0], programId),\n getProtocolFeeOwnerAddress(pool[0], programId),\n ]);\n const protocolFeePosition = await getPositionAddress(\n pool[0],\n protocolFeeOwner[0],\n 0n,\n programId,\n );\n\n return {\n token0,\n token1,\n pool,\n authority,\n vault0,\n vault1,\n config,\n protocolFeeOwner,\n protocolFeePosition,\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 protocolFeeOwner: ProgramDerivedAddress;\n protocolFeePosition: ProgramDerivedAddress;\n oracle: ProgramDerivedAddress;\n}> {\n const [config, authority, position, protocolFeeOwner, oracle] =\n await Promise.all([\n getConfigAddress(programId),\n getPoolAuthorityAddress(pool, programId),\n getPositionAddress(pool, owner, positionId, programId),\n getProtocolFeeOwnerAddress(pool, programId),\n getOracleAddress(pool, programId),\n ]);\n const protocolFeePosition = await getPositionAddress(\n pool,\n protocolFeeOwner[0],\n 0n,\n programId,\n );\n\n return {\n config,\n authority,\n position,\n protocolFeeOwner,\n protocolFeePosition,\n oracle,\n };\n}\n"]}
@@ -26,7 +26,7 @@ var SEED_VAULT0 = "vault0";
26
26
  var SEED_VAULT1 = "vault1";
27
27
  var SEED_POSITION = "position";
28
28
  var SEED_ORACLE = "oracle";
29
- var SEED_PROTOCOL_FEE_POSITION = "protocol_position";
29
+ var SEED_PROTOCOL_FEE_OWNER = "protocol_fee_owner";
30
30
  var HF_BEFORE_SWAP = 1 << 0;
31
31
  var HF_AFTER_SWAP = 1 << 1;
32
32
  var HF_BEFORE_ADD_LIQ = 1 << 2;
@@ -151,23 +151,10 @@ var INSTRUCTION_DISCRIMINATORS = {
151
151
  96,
152
152
  175
153
153
  ]),
154
- // SHA256("global:quote_to_numeraire")[0:8]
155
- quoteToNumeraire: new Uint8Array([
156
- 4,
157
- 142,
158
- 249,
159
- 240,
160
- 129,
161
- 15,
162
- 143,
163
- 57
164
- ]),
165
154
  // SHA256("global:set_hook")[0:8]
166
155
  setHook: new Uint8Array([175, 16, 187, 252, 19, 54, 111, 221]),
167
156
  // SHA256("global:set_fees")[0:8]
168
157
  setFees: new Uint8Array([137, 178, 49, 58, 0, 245, 242, 190]),
169
- // SHA256("global:set_route")[0:8]
170
- setRoute: new Uint8Array([244, 231, 3, 84, 233, 61, 146, 149]),
171
158
  // SHA256("global:transfer_admin")[0:8]
172
159
  transferAdmin: new Uint8Array([
173
160
  42,
@@ -286,27 +273,37 @@ async function getOracleAddress(pool, programId = CPMM_PROGRAM_ID) {
286
273
  seeds: [textEncoder.encode(SEED_ORACLE), addressCodec.encode(pool)]
287
274
  });
288
275
  }
289
- async function getProtocolFeePositionAddress(pool, programId = CPMM_PROGRAM_ID) {
276
+ async function getProtocolFeeOwnerAddress(pool, programId = CPMM_PROGRAM_ID) {
290
277
  return getProgramDerivedAddress({
291
278
  programAddress: programId,
292
279
  seeds: [
293
- textEncoder.encode(SEED_PROTOCOL_FEE_POSITION),
280
+ textEncoder.encode(SEED_PROTOCOL_FEE_OWNER),
294
281
  addressCodec.encode(pool)
295
282
  ]
296
283
  });
297
284
  }
285
+ async function getProtocolFeePositionAddress(pool, programId = CPMM_PROGRAM_ID) {
286
+ const [protocolFeeOwner] = await getProtocolFeeOwnerAddress(pool, programId);
287
+ return getPositionAddress(pool, protocolFeeOwner, 0n, programId);
288
+ }
298
289
  async function getPoolInitAddresses(mint0, mint1, programId = CPMM_PROGRAM_ID) {
299
290
  const [token0, token1] = sortMints(mint0, mint1);
300
291
  const [config, pool] = await Promise.all([
301
292
  getConfigAddress(programId),
302
293
  getPoolAddress(token0, token1, programId)
303
294
  ]);
304
- const [authority, vault0, vault1, protocolFeePosition] = await Promise.all([
295
+ const [authority, vault0, vault1, protocolFeeOwner] = await Promise.all([
305
296
  getPoolAuthorityAddress(pool[0], programId),
306
297
  getPoolVault0Address(pool[0], programId),
307
298
  getPoolVault1Address(pool[0], programId),
308
- getProtocolFeePositionAddress(pool[0], programId)
299
+ getProtocolFeeOwnerAddress(pool[0], programId)
309
300
  ]);
301
+ const protocolFeePosition = await getPositionAddress(
302
+ pool[0],
303
+ protocolFeeOwner[0],
304
+ 0n,
305
+ programId
306
+ );
310
307
  return {
311
308
  token0,
312
309
  token1,
@@ -315,6 +312,7 @@ async function getPoolInitAddresses(mint0, mint1, programId = CPMM_PROGRAM_ID) {
315
312
  vault0,
316
313
  vault1,
317
314
  config,
315
+ protocolFeeOwner,
318
316
  protocolFeePosition
319
317
  };
320
318
  }
@@ -327,16 +325,29 @@ async function getSwapAddresses(pool, programId = CPMM_PROGRAM_ID) {
327
325
  return { config, authority, oracle };
328
326
  }
329
327
  async function getLiquidityAddresses(pool, owner, positionId, programId = CPMM_PROGRAM_ID) {
330
- const [config, authority, position, protocolFeePosition, oracle] = await Promise.all([
328
+ const [config, authority, position, protocolFeeOwner, oracle] = await Promise.all([
331
329
  getConfigAddress(programId),
332
330
  getPoolAuthorityAddress(pool, programId),
333
331
  getPositionAddress(pool, owner, positionId, programId),
334
- getProtocolFeePositionAddress(pool, programId),
332
+ getProtocolFeeOwnerAddress(pool, programId),
335
333
  getOracleAddress(pool, programId)
336
334
  ]);
337
- return { config, authority, position, protocolFeePosition, oracle };
335
+ const protocolFeePosition = await getPositionAddress(
336
+ pool,
337
+ protocolFeeOwner[0],
338
+ 0n,
339
+ programId
340
+ );
341
+ return {
342
+ config,
343
+ authority,
344
+ position,
345
+ protocolFeeOwner,
346
+ protocolFeePosition,
347
+ oracle
348
+ };
338
349
  }
339
350
 
340
- export { ACCOUNT_DISCRIMINATORS, ACCOUNT_VERSION, BPS_DENOM, CPMM_PROGRAM_ID, HF_AFTER_ADD_LIQ, HF_AFTER_REMOVE_LIQ, HF_AFTER_SWAP, HF_BEFORE_ADD_LIQ, HF_BEFORE_REMOVE_LIQ, HF_BEFORE_SWAP, HF_FORWARD_READONLY_SIGNERS, HF_REQUIRE_ORACLE, HOOK_NO_CHANGE, INSTRUCTION_DISCRIMINATORS, MAX_HOOK_ALLOWLIST, MAX_ORACLE_OBSERVATIONS, Q64_ONE, SEED_AUTHORITY, SEED_CONFIG, SEED_ORACLE, SEED_POOL, SEED_POSITION, SEED_PROTOCOL_FEE_POSITION, TOKEN_METADATA_PROGRAM_ID, areMintsOrdered, getConfigAddress, getLiquidityAddresses, getOracleAddress, getPoolAddress, getPoolAuthorityAddress, getPoolInitAddresses, getPoolVault0Address, getPoolVault1Address, getPositionAddress, getProtocolFeePositionAddress, getSwapAddresses, sortMints };
341
- //# sourceMappingURL=chunk-6TOPYGOG.js.map
342
- //# sourceMappingURL=chunk-6TOPYGOG.js.map
351
+ export { ACCOUNT_DISCRIMINATORS, ACCOUNT_VERSION, BPS_DENOM, CPMM_PROGRAM_ID, HF_AFTER_ADD_LIQ, HF_AFTER_REMOVE_LIQ, HF_AFTER_SWAP, HF_BEFORE_ADD_LIQ, HF_BEFORE_REMOVE_LIQ, HF_BEFORE_SWAP, HF_FORWARD_READONLY_SIGNERS, HF_REQUIRE_ORACLE, HOOK_NO_CHANGE, INSTRUCTION_DISCRIMINATORS, MAX_HOOK_ALLOWLIST, MAX_ORACLE_OBSERVATIONS, Q64_ONE, SEED_AUTHORITY, SEED_CONFIG, SEED_ORACLE, SEED_POOL, SEED_POSITION, SEED_PROTOCOL_FEE_OWNER, TOKEN_METADATA_PROGRAM_ID, areMintsOrdered, getConfigAddress, getLiquidityAddresses, getOracleAddress, getPoolAddress, getPoolAuthorityAddress, getPoolInitAddresses, getPoolVault0Address, getPoolVault1Address, getPositionAddress, getProtocolFeeOwnerAddress, getProtocolFeePositionAddress, getSwapAddresses, sortMints };
352
+ //# sourceMappingURL=chunk-ZUJKBFXW.js.map
353
+ //# sourceMappingURL=chunk-ZUJKBFXW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/solana/core/constants.ts","../src/solana/core/pda.ts"],"names":[],"mappings":";;;;;;AAOoD,OAAA;AAAA,EAClD;AACF;AAKO,IAAM,sBAAA,GAAkC,OAAA;AAAA,EAC7C;AACF,CAAA;AAKO,IAAM,eAAA,GAAkB;AAKxB,IAAM,yBAAA,GAAqC,OAAA;AAAA,EAChD;AACF;AAOO,IAAM,SAAA,GAAY;AAGlB,IAAM,UAAU,EAAA,IAAM;AAGtB,IAAM,eAAA,GAAkB;AAOxB,IAAM,kBAAA,GAAqB;AAG3B,IAAM,uBAAA,GAA0B;AAOhC,IAAM,WAAA,GAAc;AAGpB,IAAM,SAAA,GAAY;AAGlB,IAAM,cAAA,GAAiB;AAGvB,IAAM,WAAA,GAAc,QAAA;AAGpB,IAAM,WAAA,GAAc,QAAA;AAGpB,IAAM,aAAA,GAAgB;AAGtB,IAAM,WAAA,GAAc;AAGpB,IAAM,uBAAA,GAA0B;AAOhC,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,oBAAoB,CAAA,IAAK;AAG/B,IAAM,8BAA8B,CAAA,IAAK;AAGzC,IAAM,cAAA,GAAiB;AAUvB,IAAM,0BAAA,GAA6B;AAAA;AAAA,EAExC,gBAAA,EAAkB,IAAI,UAAA,CAAW;AAAA,IAC/B,GAAA;AAAA,IAAM,GAAA;AAAA,IAAM,EAAA;AAAA,IAAM,CAAA;AAAA,IAAM,GAAA;AAAA,IAAM,GAAA;AAAA,IAAM,GAAA;AAAA,IA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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';\nexport const SYSVAR_INSTRUCTIONS_ADDRESS: Address = address(\n 'Sysvar1nstructions1111111111111111111111111',\n);\n\n/**\n * CPMM AMM program ID for the default devnet deployment.\n */\nexport const DEVNET_CPMM_PROGRAM_ID: Address = address(\n '9PSxVPoPfnbZ8Q1uQhgS6ZxvBjFboZtebNsu34umxkgQ',\n);\n\n/**\n * @deprecated Use DEVNET_CPMM_PROGRAM_ID or pass an explicit deployment.\n */\nexport const CPMM_PROGRAM_ID = DEVNET_CPMM_PROGRAM_ID;\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 hook allowlist */\nexport const MAX_HOOK_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 token0 vault PDA: ['vault0', pool] */\nexport const SEED_VAULT0 = 'vault0';\n\n/** Seed prefix for token1 vault PDA: ['vault1', pool] */\nexport const SEED_VAULT1 = 'vault1';\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 fee owner PDA: ['protocol_fee_owner', pool] */\nexport const SEED_PROTOCOL_FEE_OWNER = 'protocol_fee_owner';\n\n// ============================================================================\n// Hook Flags\n// ============================================================================\n\n/** Hook: called before swap */\nexport const HF_BEFORE_SWAP = 1 << 0;\n\n/** Hook: called after swap */\nexport const HF_AFTER_SWAP = 1 << 1;\n\n/** Hook: called before add liquidity */\nexport const HF_BEFORE_ADD_LIQ = 1 << 2;\n\n/** Hook: called after add liquidity */\nexport const HF_AFTER_ADD_LIQ = 1 << 3;\n\n/** Hook: called before remove liquidity */\nexport const HF_BEFORE_REMOVE_LIQ = 1 << 4;\n\n/** Hook: called after remove liquidity */\nexport const HF_AFTER_REMOVE_LIQ = 1 << 5;\n\n/** Require an oracle account when invoking hooks */\nexport const HF_REQUIRE_ORACLE = 1 << 6;\n\n/** Preserve readonly signer metas when forwarding remaining accounts to hooks */\nexport const HF_FORWARD_READONLY_SIGNERS = 1 << 7;\n\n/** Hook return value indicating \"no change\" to fee parameter */\nexport const HOOK_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:set_hook\")[0:8]\n setHook: new Uint8Array([0xaf, 0x10, 0xbb, 0xfc, 0x13, 0x36, 0x6f, 0xdd]),\n // SHA256(\"global:set_fees\")[0:8]\n setFees: new Uint8Array([0x89, 0xb2, 0x31, 0x3a, 0x00, 0xf5, 0xf2, 0xbe]),\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:withdraw_vault_excess\")[0:8]\n withdrawVaultExcess: new Uint8Array([\n 0xeb, 0xc5, 0xf7, 0xb1, 0x89, 0x48, 0x87, 0x71,\n ]),\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_VAULT0,\n SEED_VAULT1,\n SEED_POSITION,\n SEED_ORACLE,\n SEED_PROTOCOL_FEE_OWNER,\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 token0 vault PDA.\n * Seeds: ['vault0', pool]\n */\nexport async function getPoolVault0Address(\n pool: Address,\n programId: Address = CPMM_PROGRAM_ID,\n): Promise<ProgramDerivedAddress> {\n return getProgramDerivedAddress({\n programAddress: programId,\n seeds: [textEncoder.encode(SEED_VAULT0), addressCodec.encode(pool)],\n });\n}\n\n/**\n * Derive the token1 vault PDA.\n * Seeds: ['vault1', pool]\n */\nexport async function getPoolVault1Address(\n pool: Address,\n programId: Address = CPMM_PROGRAM_ID,\n): Promise<ProgramDerivedAddress> {\n return getProgramDerivedAddress({\n programAddress: programId,\n seeds: [textEncoder.encode(SEED_VAULT1), 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 fee owner PDA address\n * Seeds: ['protocol_fee_owner', pool]\n */\nexport async function getProtocolFeeOwnerAddress(\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_FEE_OWNER),\n addressCodec.encode(pool),\n ],\n });\n}\n\n/**\n * Derive the protocol fee position PDA address.\n * Seeds: ['position', pool, protocol_fee_owner, 0]\n */\nexport async function getProtocolFeePositionAddress(\n pool: Address,\n programId: Address = CPMM_PROGRAM_ID,\n): Promise<ProgramDerivedAddress> {\n const [protocolFeeOwner] = await getProtocolFeeOwnerAddress(pool, programId);\n return getPositionAddress(pool, protocolFeeOwner, 0n, programId);\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 vault0: ProgramDerivedAddress;\n vault1: ProgramDerivedAddress;\n config: ProgramDerivedAddress;\n protocolFeeOwner: ProgramDerivedAddress;\n protocolFeePosition: 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, vault0, vault1, protocolFeeOwner] = await Promise.all([\n getPoolAuthorityAddress(pool[0], programId),\n getPoolVault0Address(pool[0], programId),\n getPoolVault1Address(pool[0], programId),\n getProtocolFeeOwnerAddress(pool[0], programId),\n ]);\n const protocolFeePosition = await getPositionAddress(\n pool[0],\n protocolFeeOwner[0],\n 0n,\n programId,\n );\n\n return {\n token0,\n token1,\n pool,\n authority,\n vault0,\n vault1,\n config,\n protocolFeeOwner,\n protocolFeePosition,\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 protocolFeeOwner: ProgramDerivedAddress;\n protocolFeePosition: ProgramDerivedAddress;\n oracle: ProgramDerivedAddress;\n}> {\n const [config, authority, position, protocolFeeOwner, oracle] =\n await Promise.all([\n getConfigAddress(programId),\n getPoolAuthorityAddress(pool, programId),\n getPositionAddress(pool, owner, positionId, programId),\n getProtocolFeeOwnerAddress(pool, programId),\n getOracleAddress(pool, programId),\n ]);\n const protocolFeePosition = await getPositionAddress(\n pool,\n protocolFeeOwner[0],\n 0n,\n programId,\n );\n\n return {\n config,\n authority,\n position,\n protocolFeeOwner,\n protocolFeePosition,\n oracle,\n };\n}\n"]}
@@ -15,8 +15,6 @@ interface AmmConfig {
15
15
  admin: Address;
16
16
  /** Whether all pool operations are paused */
17
17
  paused: boolean;
18
- /** Default numeraire mint for pricing */
19
- numeraireMint: Address;
20
18
  /** Number of programs in hook allowlist */
21
19
  hookAllowlistLen: number;
22
20
  /** Allowlist of hook programs (fixed size: 32) */
@@ -25,8 +23,6 @@ interface AmmConfig {
25
23
  maxSwapFeeBps: number;
26
24
  /** Maximum allowed fee split in basis points */
27
25
  maxFeeSplitBps: number;
28
- /** Maximum number of hops for routing */
29
- maxRouteHops: number;
30
26
  /** Whether protocol fees are enabled */
31
27
  protocolFeeEnabled: boolean;
32
28
  /** Protocol fee in basis points (share of LP fees) */
@@ -77,14 +73,8 @@ interface Pool {
77
73
  hookProgram: Address;
78
74
  /** Bitflags for enabled hooks */
79
75
  hookFlags: number;
80
- /** Override numeraire mint for this pool */
81
- numeraireMint: Address;
82
76
  /** Which token to use for liquidity measure (0 or 1) */
83
77
  liquidityMeasureTokenIndex: number;
84
- /** Next pool in routing chain (default = none) */
85
- routeNextPool: Address;
86
- /** Bridge mint for routing (must be token0 or token1) */
87
- routeBridgeMint: Address;
88
78
  /** Last k value for protocol fee calculation (u128) */
89
79
  kLast: bigint;
90
80
  /** Protocol fee position for protocol fee shares */
@@ -175,10 +165,8 @@ interface OracleState {
175
165
  }
176
166
  interface InitializeConfigArgs {
177
167
  admin: Address;
178
- numeraireMint: Address;
179
168
  maxSwapFeeBps: number;
180
169
  maxFeeSplitBps: number;
181
- maxRouteHops: number;
182
170
  protocolFeeEnabled: boolean;
183
171
  protocolFeeBps: number;
184
172
  hookAllowlist: Address[];
@@ -189,7 +177,6 @@ interface InitializePoolArgs {
189
177
  initialSwapFeeBps: number;
190
178
  initialFeeSplitBps: number;
191
179
  liquidityMeasureTokenIndex: number;
192
- numeraireMintOverride: Address | null;
193
180
  hookProgram: Address;
194
181
  hookFlags: number;
195
182
  }
@@ -235,25 +222,12 @@ interface SetFeesArgs {
235
222
  swapFeeBps: number;
236
223
  feeSplitBps: number;
237
224
  }
238
- interface SetRouteArgs {
239
- routeNextPool: Address;
240
- routeBridgeMint: Address;
241
- }
242
225
  interface TransferAdminArgs {
243
226
  newAdmin: Address;
244
227
  }
245
228
  interface OracleConsultArgs {
246
229
  windowSeconds: number;
247
230
  }
248
- interface QuoteToNumeraireArgs {
249
- amount: bigint;
250
- inputTokenIndex: number;
251
- maxHops: number;
252
- /** Must be false in v0.1 (spot-only) */
253
- useTwap: boolean;
254
- /** Must be 0 in v0.1 (spot-only) */
255
- windowSeconds: number;
256
- }
257
231
  interface SwapQuote {
258
232
  /** Expected output amount */
259
233
  amountOut: bigint;
@@ -394,12 +368,6 @@ interface OracleUpdatedEvent {
394
368
  deviation0Q64: bigint;
395
369
  deviation1Q64: bigint;
396
370
  }
397
- interface RouteUpdatedEvent {
398
- pool: Address;
399
- routeNextPool: Address;
400
- routeBridgeMint: Address;
401
- admin: Address;
402
- }
403
371
  interface AdminTransferredEvent {
404
372
  oldAdmin: Address;
405
373
  newAdmin: Address;
@@ -825,4 +793,4 @@ declare function comparePoolAndOraclePrices(pool: Pool, oracle: OracleState): {
825
793
  divergencePct: number;
826
794
  };
827
795
 
828
- export { type UnpausedEvent as $, type AmmConfig as A, type HookUpdatedEvent as B, type CollectFeesArgs as C, type OracleInitializedEvent as D, type OracleUpdatedEvent as E, type FeesUpdatedEvent as F, type GetProgramAccountsRpc as G, type HookErrorEvent as H, type InitializeConfigArgs as I, type OracleWithAddress as J, type PausedEvent as K, type PoolInitializedEvent as L, type MarketCapValidationResult as M, type PositionClosedEvent as N, type OracleState as O, type Pool as P, type QuoteToNumeraireArgs as Q, type RemoveLiquidityArgs as R, type SwapExactInArgs as S, type TransferAdminArgs as T, type PositionCreatedEvent as U, type PositionValue as V, type PositionWithAddress as W, type RemoveLiquidityEvent as X, type RouteUpdatedEvent as Y, type SwapEvent as Z, type TwapResult as _, type Position as a, type VaultExcessWithdrawnEvent as a0, comparePoolAndOraclePrices as a1, consultTwap as a2, fetchOracle as a3, fetchOraclesBatch as a4, fetchPoolPositions as a5, fetchPosition as a6, fetchPositionByParams as a7, fetchPositionsBatch as a8, fetchUserPositions as a9, filterActivePositions as aa, getOracleAddressFromPool as ab, getOracleAge as ac, getOracleBufferStats as ad, getOracleDeviation as ae, getOracleForPool as af, getOracleSpotPrices as ag, getPositionAddressFromParams as ah, getPositionValue as ai, isOracleStale as aj, sortPositionsByShares as ak, type AddLiquidityArgs as b, type CollectProtocolFeesArgs as c, type CreatePositionArgs as d, type InitializePoolArgs as e, type InitializeOracleArgs as f, type SetHookArgs as g, type SetFeesArgs as h, type SetRouteArgs as i, type OracleConsultArgs as j, type Observation as k, type TradeDirection as l, type SwapQuote as m, type SwapQuoteExactOut as n, type AddLiquidityQuote as o, type RemoveLiquidityQuote as p, type MarketCapToCurveParamsInput as q, type CurveParams as r, type CurveParamsToMarketCapInput as s, type AddLiquidityEvent as t, type AdminTransferredEvent as u, type CollectFeesEvent as v, type CollectProtocolFeesEvent as w, type FetchOracleConfig as x, type FetchPositionsConfig as y, type HookInvokedEvent as z };
796
+ export { consultTwap as $, type AmmConfig as A, type OracleInitializedEvent as B, type CollectFeesArgs as C, type OracleUpdatedEvent as D, type OracleWithAddress as E, type FeesUpdatedEvent as F, type GetProgramAccountsRpc as G, type HookErrorEvent as H, type InitializeConfigArgs as I, type PausedEvent as J, type PoolInitializedEvent as K, type PositionClosedEvent as L, type MarketCapValidationResult as M, type PositionCreatedEvent as N, type OracleState as O, type Pool as P, type PositionValue as Q, type RemoveLiquidityArgs as R, type SwapExactInArgs as S, type TransferAdminArgs as T, type PositionWithAddress as U, type RemoveLiquidityEvent as V, type SwapEvent as W, type TwapResult as X, type UnpausedEvent as Y, type VaultExcessWithdrawnEvent as Z, comparePoolAndOraclePrices as _, type Position as a, fetchOracle as a0, fetchOraclesBatch as a1, fetchPoolPositions as a2, fetchPosition as a3, fetchPositionByParams as a4, fetchPositionsBatch as a5, fetchUserPositions as a6, filterActivePositions as a7, getOracleAddressFromPool as a8, getOracleAge as a9, getOracleBufferStats as aa, getOracleDeviation as ab, getOracleForPool as ac, getOracleSpotPrices as ad, getPositionAddressFromParams as ae, getPositionValue as af, isOracleStale as ag, sortPositionsByShares as ah, type AddLiquidityArgs as b, type CollectProtocolFeesArgs as c, type CreatePositionArgs as d, type InitializePoolArgs as e, type InitializeOracleArgs as f, type SetHookArgs as g, type SetFeesArgs as h, type OracleConsultArgs as i, type Observation as j, type TradeDirection as k, type SwapQuote as l, type SwapQuoteExactOut as m, type AddLiquidityQuote as n, type RemoveLiquidityQuote as o, type MarketCapToCurveParamsInput as p, type CurveParams as q, type CurveParamsToMarketCapInput as r, type AddLiquidityEvent as s, type AdminTransferredEvent as t, type CollectFeesEvent as u, type CollectProtocolFeesEvent as v, type FetchOracleConfig as w, type FetchPositionsConfig as x, type HookInvokedEvent as y, type HookUpdatedEvent as z };
@@ -15,8 +15,6 @@ interface AmmConfig {
15
15
  admin: Address;
16
16
  /** Whether all pool operations are paused */
17
17
  paused: boolean;
18
- /** Default numeraire mint for pricing */
19
- numeraireMint: Address;
20
18
  /** Number of programs in hook allowlist */
21
19
  hookAllowlistLen: number;
22
20
  /** Allowlist of hook programs (fixed size: 32) */
@@ -25,8 +23,6 @@ interface AmmConfig {
25
23
  maxSwapFeeBps: number;
26
24
  /** Maximum allowed fee split in basis points */
27
25
  maxFeeSplitBps: number;
28
- /** Maximum number of hops for routing */
29
- maxRouteHops: number;
30
26
  /** Whether protocol fees are enabled */
31
27
  protocolFeeEnabled: boolean;
32
28
  /** Protocol fee in basis points (share of LP fees) */
@@ -77,14 +73,8 @@ interface Pool {
77
73
  hookProgram: Address;
78
74
  /** Bitflags for enabled hooks */
79
75
  hookFlags: number;
80
- /** Override numeraire mint for this pool */
81
- numeraireMint: Address;
82
76
  /** Which token to use for liquidity measure (0 or 1) */
83
77
  liquidityMeasureTokenIndex: number;
84
- /** Next pool in routing chain (default = none) */
85
- routeNextPool: Address;
86
- /** Bridge mint for routing (must be token0 or token1) */
87
- routeBridgeMint: Address;
88
78
  /** Last k value for protocol fee calculation (u128) */
89
79
  kLast: bigint;
90
80
  /** Protocol fee position for protocol fee shares */
@@ -175,10 +165,8 @@ interface OracleState {
175
165
  }
176
166
  interface InitializeConfigArgs {
177
167
  admin: Address;
178
- numeraireMint: Address;
179
168
  maxSwapFeeBps: number;
180
169
  maxFeeSplitBps: number;
181
- maxRouteHops: number;
182
170
  protocolFeeEnabled: boolean;
183
171
  protocolFeeBps: number;
184
172
  hookAllowlist: Address[];
@@ -189,7 +177,6 @@ interface InitializePoolArgs {
189
177
  initialSwapFeeBps: number;
190
178
  initialFeeSplitBps: number;
191
179
  liquidityMeasureTokenIndex: number;
192
- numeraireMintOverride: Address | null;
193
180
  hookProgram: Address;
194
181
  hookFlags: number;
195
182
  }
@@ -235,25 +222,12 @@ interface SetFeesArgs {
235
222
  swapFeeBps: number;
236
223
  feeSplitBps: number;
237
224
  }
238
- interface SetRouteArgs {
239
- routeNextPool: Address;
240
- routeBridgeMint: Address;
241
- }
242
225
  interface TransferAdminArgs {
243
226
  newAdmin: Address;
244
227
  }
245
228
  interface OracleConsultArgs {
246
229
  windowSeconds: number;
247
230
  }
248
- interface QuoteToNumeraireArgs {
249
- amount: bigint;
250
- inputTokenIndex: number;
251
- maxHops: number;
252
- /** Must be false in v0.1 (spot-only) */
253
- useTwap: boolean;
254
- /** Must be 0 in v0.1 (spot-only) */
255
- windowSeconds: number;
256
- }
257
231
  interface SwapQuote {
258
232
  /** Expected output amount */
259
233
  amountOut: bigint;
@@ -394,12 +368,6 @@ interface OracleUpdatedEvent {
394
368
  deviation0Q64: bigint;
395
369
  deviation1Q64: bigint;
396
370
  }
397
- interface RouteUpdatedEvent {
398
- pool: Address;
399
- routeNextPool: Address;
400
- routeBridgeMint: Address;
401
- admin: Address;
402
- }
403
371
  interface AdminTransferredEvent {
404
372
  oldAdmin: Address;
405
373
  newAdmin: Address;
@@ -825,4 +793,4 @@ declare function comparePoolAndOraclePrices(pool: Pool, oracle: OracleState): {
825
793
  divergencePct: number;
826
794
  };
827
795
 
828
- export { type UnpausedEvent as $, type AmmConfig as A, type HookUpdatedEvent as B, type CollectFeesArgs as C, type OracleInitializedEvent as D, type OracleUpdatedEvent as E, type FeesUpdatedEvent as F, type GetProgramAccountsRpc as G, type HookErrorEvent as H, type InitializeConfigArgs as I, type OracleWithAddress as J, type PausedEvent as K, type PoolInitializedEvent as L, type MarketCapValidationResult as M, type PositionClosedEvent as N, type OracleState as O, type Pool as P, type QuoteToNumeraireArgs as Q, type RemoveLiquidityArgs as R, type SwapExactInArgs as S, type TransferAdminArgs as T, type PositionCreatedEvent as U, type PositionValue as V, type PositionWithAddress as W, type RemoveLiquidityEvent as X, type RouteUpdatedEvent as Y, type SwapEvent as Z, type TwapResult as _, type Position as a, type VaultExcessWithdrawnEvent as a0, comparePoolAndOraclePrices as a1, consultTwap as a2, fetchOracle as a3, fetchOraclesBatch as a4, fetchPoolPositions as a5, fetchPosition as a6, fetchPositionByParams as a7, fetchPositionsBatch as a8, fetchUserPositions as a9, filterActivePositions as aa, getOracleAddressFromPool as ab, getOracleAge as ac, getOracleBufferStats as ad, getOracleDeviation as ae, getOracleForPool as af, getOracleSpotPrices as ag, getPositionAddressFromParams as ah, getPositionValue as ai, isOracleStale as aj, sortPositionsByShares as ak, type AddLiquidityArgs as b, type CollectProtocolFeesArgs as c, type CreatePositionArgs as d, type InitializePoolArgs as e, type InitializeOracleArgs as f, type SetHookArgs as g, type SetFeesArgs as h, type SetRouteArgs as i, type OracleConsultArgs as j, type Observation as k, type TradeDirection as l, type SwapQuote as m, type SwapQuoteExactOut as n, type AddLiquidityQuote as o, type RemoveLiquidityQuote as p, type MarketCapToCurveParamsInput as q, type CurveParams as r, type CurveParamsToMarketCapInput as s, type AddLiquidityEvent as t, type AdminTransferredEvent as u, type CollectFeesEvent as v, type CollectProtocolFeesEvent as w, type FetchOracleConfig as x, type FetchPositionsConfig as y, type HookInvokedEvent as z };
796
+ export { consultTwap as $, type AmmConfig as A, type OracleInitializedEvent as B, type CollectFeesArgs as C, type OracleUpdatedEvent as D, type OracleWithAddress as E, type FeesUpdatedEvent as F, type GetProgramAccountsRpc as G, type HookErrorEvent as H, type InitializeConfigArgs as I, type PausedEvent as J, type PoolInitializedEvent as K, type PositionClosedEvent as L, type MarketCapValidationResult as M, type PositionCreatedEvent as N, type OracleState as O, type Pool as P, type PositionValue as Q, type RemoveLiquidityArgs as R, type SwapExactInArgs as S, type TransferAdminArgs as T, type PositionWithAddress as U, type RemoveLiquidityEvent as V, type SwapEvent as W, type TwapResult as X, type UnpausedEvent as Y, type VaultExcessWithdrawnEvent as Z, comparePoolAndOraclePrices as _, type Position as a, fetchOracle as a0, fetchOraclesBatch as a1, fetchPoolPositions as a2, fetchPosition as a3, fetchPositionByParams as a4, fetchPositionsBatch as a5, fetchUserPositions as a6, filterActivePositions as a7, getOracleAddressFromPool as a8, getOracleAge as a9, getOracleBufferStats as aa, getOracleDeviation as ab, getOracleForPool as ac, getOracleSpotPrices as ad, getPositionAddressFromParams as ae, getPositionValue as af, isOracleStale as ag, sortPositionsByShares as ah, type AddLiquidityArgs as b, type CollectProtocolFeesArgs as c, type CreatePositionArgs as d, type InitializePoolArgs as e, type InitializeOracleArgs as f, type SetHookArgs as g, type SetFeesArgs as h, type OracleConsultArgs as i, type Observation as j, type TradeDirection as k, type SwapQuote as l, type SwapQuoteExactOut as m, type AddLiquidityQuote as n, type RemoveLiquidityQuote as o, type MarketCapToCurveParamsInput as p, type CurveParams as q, type CurveParamsToMarketCapInput as r, type AddLiquidityEvent as s, type AdminTransferredEvent as t, type CollectFeesEvent as u, type CollectProtocolFeesEvent as v, type FetchOracleConfig as w, type FetchPositionsConfig as x, type HookInvokedEvent as y, type HookUpdatedEvent as z };