@kamino-finance/kliquidity-sdk 7.0.1 → 7.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/Kamino.ts CHANGED
@@ -64,7 +64,7 @@ import {
64
64
  TotalStrategyVaultTokens,
65
65
  TreasuryFeeVault,
66
66
  } from './models';
67
- import { PROGRAM_ID_CLI as WHIRLPOOL_PROGRAM_ID, setWhirlpoolsProgramId } from './whirlpools-client/programId';
67
+ import { setWhirlpoolsProgramId } from './whirlpools-client/programId';
68
68
  import { OraclePrices, Scope } from '@kamino-finance/scope-sdk';
69
69
  import {
70
70
  batchFetch,
@@ -179,7 +179,7 @@ import {
179
179
  StrategyStatusKind,
180
180
  } from './kamino-client/types';
181
181
  import { AmmConfig, PersonalPositionState, PoolState } from './raydium_client';
182
- import { PROGRAM_ID as RAYDIUM_PROGRAM_ID, setRaydiumProgramId } from './raydium_client/programId';
182
+ import { setRaydiumProgramId } from './raydium_client/programId';
183
183
  import {
184
184
  getPdaProtocolPositionAddress,
185
185
  i32ToBytes,
@@ -330,7 +330,7 @@ import {
330
330
  } from './rebalance_methods/autodriftRebalance';
331
331
  import { KaminoPrices, OraclePricesAndCollateralInfos } from './models';
332
332
  import { getRemoveLiquidityQuote } from './whirlpools-client/shim/remove-liquidity';
333
- import { METEORA_PROGRAM_ID, setMeteoraProgramId } from './meteora_client/programId';
333
+ import { setMeteoraProgramId } from './meteora_client/programId';
334
334
  import { computeMeteoraFee, MeteoraPool, MeteoraService } from './services/MeteoraService';
335
335
  import {
336
336
  binIdToBinArrayIndex,
@@ -401,19 +401,17 @@ export class Kamino {
401
401
  setWhirlpoolsProgramId(whirlpoolProgramId);
402
402
  }
403
403
 
404
- if (cluster === 'localnet') {
405
- if (raydiumProgramId) {
406
- setRaydiumProgramId(raydiumProgramId);
407
- }
404
+ if (raydiumProgramId) {
405
+ setRaydiumProgramId(raydiumProgramId);
408
406
  }
409
407
 
410
408
  if (meteoraProgramId) {
411
409
  setMeteoraProgramId(meteoraProgramId);
412
410
  }
413
411
 
414
- this._orcaService = new OrcaService(connection, cluster, this._globalConfig, this._kaminoProgramId);
415
- this._raydiumService = new RaydiumService(connection, cluster);
416
- this._meteoraService = new MeteoraService(connection, this._globalConfig);
412
+ this._orcaService = new OrcaService(connection, cluster, whirlpoolProgramId);
413
+ this._raydiumService = new RaydiumService(connection, raydiumProgramId);
414
+ this._meteoraService = new MeteoraService(connection, meteoraProgramId);
417
415
  }
418
416
 
419
417
  getConnection = () => this._connection;
@@ -2332,7 +2330,7 @@ export class Kamino {
2332
2330
  if (positionPk.equals(PublicKey.default)) {
2333
2331
  return { lowerPrice: ZERO, upperPrice: ZERO };
2334
2332
  }
2335
- const position = await Position.fetch(this._connection, positionPk);
2333
+ const position = await Position.fetch(this._connection, positionPk, this._orcaService.getWhirlpoolProgramId());
2336
2334
  if (!position) {
2337
2335
  return { lowerPrice: ZERO, upperPrice: ZERO };
2338
2336
  }
@@ -2352,7 +2350,11 @@ export class Kamino {
2352
2350
  if (positionPk.equals(PublicKey.default)) {
2353
2351
  return { lowerPrice: ZERO, upperPrice: ZERO };
2354
2352
  }
2355
- const position = await PersonalPositionState.fetch(this._connection, positionPk);
2353
+ const position = await PersonalPositionState.fetch(
2354
+ this._connection,
2355
+ positionPk,
2356
+ this._raydiumService.getRaydiumProgramId()
2357
+ );
2356
2358
  if (!position) {
2357
2359
  return { lowerPrice: ZERO, upperPrice: ZERO };
2358
2360
  }
@@ -2381,7 +2383,7 @@ export class Kamino {
2381
2383
  if (positionPk.equals(PublicKey.default)) {
2382
2384
  return { lowerPrice: ZERO, upperPrice: ZERO };
2383
2385
  }
2384
- const position = await PositionV2.fetch(this._connection, positionPk);
2386
+ const position = await PositionV2.fetch(this._connection, positionPk, this._meteoraService.getMeteoraProgramId());
2385
2387
  if (!position) {
2386
2388
  return { lowerPrice: ZERO, upperPrice: ZERO };
2387
2389
  }
@@ -2431,7 +2433,9 @@ export class Kamino {
2431
2433
  whirlpoolMap.set(whirlpools[0], whirlpool);
2432
2434
  return whirlpoolMap;
2433
2435
  }
2434
- const fetched = await batchFetch(uniqueWhirlpools, (chunk) => Whirlpool.fetchMultiple(this._connection, chunk));
2436
+ const fetched = await batchFetch(uniqueWhirlpools, (chunk) =>
2437
+ Whirlpool.fetchMultiple(this._connection, chunk, this._orcaService.getWhirlpoolProgramId())
2438
+ );
2435
2439
  fetched.reduce((map: Record<string, Whirlpool | null>, whirlpool, i) => {
2436
2440
  whirlpoolMap.set(uniqueWhirlpools[i], whirlpool);
2437
2441
  map[uniqueWhirlpools[i].toBase58()] = whirlpool;
@@ -2446,7 +2450,9 @@ export class Kamino {
2446
2450
  */
2447
2451
  getOrcaPositions = async (positions: PublicKey[]): Promise<(Position | null)[]> => {
2448
2452
  const nonDefaults = positions.filter((value) => value.toBase58() !== PublicKey.default.toBase58());
2449
- const fetched = await batchFetch(nonDefaults, (chunk) => Position.fetchMultiple(this._connection, chunk));
2453
+ const fetched = await batchFetch(nonDefaults, (chunk) =>
2454
+ Position.fetchMultiple(this._connection, chunk, this._orcaService.getWhirlpoolProgramId())
2455
+ );
2450
2456
  const fetchedMap: Record<string, Position | null> = fetched.reduce(
2451
2457
  (map: Record<string, Position | null>, position, i) => {
2452
2458
  map[nonDefaults[i].toBase58()] = position;
@@ -2464,7 +2470,7 @@ export class Kamino {
2464
2470
  getRaydiumPositions = async (positions: PublicKey[]): Promise<(PersonalPositionState | null)[]> => {
2465
2471
  const nonDefaults = positions.filter((value) => value.toBase58() !== PublicKey.default.toBase58());
2466
2472
  const fetched = await batchFetch(nonDefaults, (chunk) =>
2467
- PersonalPositionState.fetchMultiple(this._connection, chunk)
2473
+ PersonalPositionState.fetchMultiple(this._connection, chunk, this._raydiumService.getRaydiumProgramId())
2468
2474
  );
2469
2475
  const fetchedMap: Record<string, PersonalPositionState | null> = fetched.reduce(
2470
2476
  (map: Record<string, PersonalPositionState | null>, position, i) => {
@@ -2478,7 +2484,9 @@ export class Kamino {
2478
2484
 
2479
2485
  getMeteoraPositions = async (positions: PublicKey[]): Promise<(PositionV2 | null)[]> => {
2480
2486
  const nonDefaults = positions.filter((value) => !value.equals(PublicKey.default));
2481
- const fetched = await batchFetch(nonDefaults, (chunk) => PositionV2.fetchMultiple(this._connection, chunk));
2487
+ const fetched = await batchFetch(nonDefaults, (chunk) =>
2488
+ PositionV2.fetchMultiple(this._connection, chunk, this._meteoraService.getMeteoraProgramId())
2489
+ );
2482
2490
  const fetchedMap: Record<string, PositionV2 | null> = fetched.reduce(
2483
2491
  (map: Record<string, PositionV2 | null>, position, i) => {
2484
2492
  map[nonDefaults[i].toBase58()] = position;
@@ -2493,7 +2501,8 @@ export class Kamino {
2493
2501
  * Get whirlpool from public key
2494
2502
  * @param whirlpool pubkey of the orca whirlpool
2495
2503
  */
2496
- getWhirlpoolByAddress = (whirlpool: PublicKey) => Whirlpool.fetch(this._connection, whirlpool);
2504
+ getWhirlpoolByAddress = (whirlpool: PublicKey) =>
2505
+ Whirlpool.fetch(this._connection, whirlpool, this._orcaService.getWhirlpoolProgramId());
2497
2506
 
2498
2507
  /**
2499
2508
  * Get a list of Raydium pools from public keys
@@ -2509,7 +2518,9 @@ export class Kamino {
2509
2518
  const pool = await this.getRaydiumPoolByAddress(pools[0]);
2510
2519
  poolsMap.set(pools[0], pool);
2511
2520
  }
2512
- const fetched = await batchFetch(uniquePools, (chunk) => PoolState.fetchMultiple(this._connection, chunk));
2521
+ const fetched = await batchFetch(uniquePools, (chunk) =>
2522
+ PoolState.fetchMultiple(this._connection, chunk, this._raydiumService.getRaydiumProgramId())
2523
+ );
2513
2524
  fetched.reduce((map, whirlpool, i) => {
2514
2525
  poolsMap.set(uniquePools[i], whirlpool);
2515
2526
  return map;
@@ -2527,7 +2538,9 @@ export class Kamino {
2527
2538
  const pool = await this.getMeteoraPoolByAddress(pools[0]);
2528
2539
  poolsMap.set(pools[0], pool);
2529
2540
  }
2530
- const fetched = await batchFetch(uniquePools, (chunk) => LbPair.fetchMultiple(this._connection, chunk));
2541
+ const fetched = await batchFetch(uniquePools, (chunk) =>
2542
+ LbPair.fetchMultiple(this._connection, chunk, this._meteoraService.getMeteoraProgramId())
2543
+ );
2531
2544
  fetched.reduce((map, whirlpool, i) => {
2532
2545
  poolsMap.set(uniquePools[i], whirlpool);
2533
2546
  return map;
@@ -2535,15 +2548,18 @@ export class Kamino {
2535
2548
  return poolsMap;
2536
2549
  };
2537
2550
 
2538
- getRaydiumAmmConfig = (config: PublicKey) => AmmConfig.fetch(this._connection, config);
2551
+ getRaydiumAmmConfig = (config: PublicKey) =>
2552
+ AmmConfig.fetch(this._connection, config, this._raydiumService.getRaydiumProgramId());
2539
2553
 
2540
2554
  /**
2541
2555
  * Get Raydium pool from public key
2542
2556
  * @param pool pubkey of the orca whirlpool
2543
2557
  */
2544
- getRaydiumPoolByAddress = (pool: PublicKey) => PoolState.fetch(this._connection, pool);
2558
+ getRaydiumPoolByAddress = (pool: PublicKey) =>
2559
+ PoolState.fetch(this._connection, pool, this._raydiumService.getRaydiumProgramId());
2545
2560
 
2546
- getMeteoraPoolByAddress = (pool: PublicKey) => LbPair.fetch(this._connection, pool);
2561
+ getMeteoraPoolByAddress = (pool: PublicKey) =>
2562
+ LbPair.fetch(this._connection, pool, this._raydiumService.getRaydiumProgramId());
2547
2563
 
2548
2564
  getEventAuthorityPDA = (dex: BN): PublicKey => {
2549
2565
  if (dex.toNumber() == dexToNumber('ORCA') || dex.toNumber() == dexToNumber('RAYDIUM')) {
@@ -2551,7 +2567,10 @@ export class Kamino {
2551
2567
  }
2552
2568
 
2553
2569
  if (dex.toNumber() == dexToNumber('METEORA')) {
2554
- const [key, _] = PublicKey.findProgramAddressSync([Buffer.from('__event_authority')], METEORA_PROGRAM_ID);
2570
+ const [key, _] = PublicKey.findProgramAddressSync(
2571
+ [Buffer.from('__event_authority')],
2572
+ this._meteoraService.getMeteoraProgramId()
2573
+ );
2555
2574
  return key;
2556
2575
  }
2557
2576
  throw new Error('Invalid dex');
@@ -2643,7 +2662,11 @@ export class Kamino {
2643
2662
  // add rewards vaults accounts to withdraw
2644
2663
  const isRaydium = strategyState.strategy.strategyDex.toNumber() == dexToNumber('RAYDIUM');
2645
2664
  if (isRaydium) {
2646
- const raydiumPosition = await PersonalPositionState.fetch(this._connection, strategyState.strategy.position);
2665
+ const raydiumPosition = await PersonalPositionState.fetch(
2666
+ this._connection,
2667
+ strategyState.strategy.position,
2668
+ this._raydiumService.getRaydiumProgramId()
2669
+ );
2647
2670
  if (!raydiumPosition) {
2648
2671
  throw new Error('Position is not found');
2649
2672
  }
@@ -2870,7 +2893,11 @@ export class Kamino {
2870
2893
  getAllDepositAccounts = async (strategy: PublicKey | StrategyWithAddress, owner: PublicKey): Promise<PublicKey[]> => {
2871
2894
  const strategyState = await this.getStrategyStateIfNotFetched(strategy);
2872
2895
 
2873
- const globalConfig = await GlobalConfig.fetch(this._connection, strategyState.strategy.globalConfig);
2896
+ const globalConfig = await GlobalConfig.fetch(
2897
+ this._connection,
2898
+ strategyState.strategy.globalConfig,
2899
+ this._kaminoProgram.programId
2900
+ );
2874
2901
  if (!globalConfig) {
2875
2902
  throw Error(`Could not fetch global config with pubkey ${strategyState.strategy.globalConfig.toString()}`);
2876
2903
  }
@@ -3751,21 +3778,25 @@ export class Kamino {
3751
3778
  let tokenAMint = PublicKey.default;
3752
3779
  let tokenBMint = PublicKey.default;
3753
3780
  if (dex == 'ORCA') {
3754
- const whirlpoolState = await Whirlpool.fetch(this._connection, pool);
3781
+ const whirlpoolState = await Whirlpool.fetch(this._connection, pool, this._orcaService.getWhirlpoolProgramId());
3755
3782
  if (!whirlpoolState) {
3756
3783
  throw Error(`Could not fetch whirlpool state with pubkey ${pool.toString()}`);
3757
3784
  }
3758
3785
  tokenAMint = whirlpoolState.tokenMintA;
3759
3786
  tokenBMint = whirlpoolState.tokenMintB;
3760
3787
  } else if (dex == 'RAYDIUM') {
3761
- const raydiumPoolState = await PoolState.fetch(this._connection, pool);
3788
+ const raydiumPoolState = await PoolState.fetch(
3789
+ this._connection,
3790
+ pool,
3791
+ this._raydiumService.getRaydiumProgramId()
3792
+ );
3762
3793
  if (!raydiumPoolState) {
3763
3794
  throw Error(`Could not fetch Raydium pool state with pubkey ${pool.toString()}`);
3764
3795
  }
3765
3796
  tokenAMint = raydiumPoolState.tokenMint0;
3766
3797
  tokenBMint = raydiumPoolState.tokenMint1;
3767
3798
  } else if (dex == 'METEORA') {
3768
- const meteoraPoolState = await LbPair.fetch(this._connection, pool);
3799
+ const meteoraPoolState = await LbPair.fetch(this._connection, pool, this._meteoraService.getMeteoraProgramId());
3769
3800
  if (!meteoraPoolState) {
3770
3801
  throw Error(`Could not fetch Meteora pool state with pubkey ${pool.toString()}`);
3771
3802
  }
@@ -4111,7 +4142,7 @@ export class Kamino {
4111
4142
  strategyState.tokenBMint
4112
4143
  );
4113
4144
 
4114
- let programId = WHIRLPOOL_PROGRAM_ID;
4145
+ let programId = this._orcaService.getWhirlpoolProgramId();
4115
4146
 
4116
4147
  let poolRewardVault0 = PublicKey.default;
4117
4148
  let poolRewardVault1 = PublicKey.default;
@@ -4119,8 +4150,12 @@ export class Kamino {
4119
4150
  let rewardMint0 = PublicKey.default;
4120
4151
  let rewardMint1 = PublicKey.default;
4121
4152
  let rewardMint2 = PublicKey.default;
4122
- if (strategyState.strategyDex.toNumber() == dexToNumber('ORCA')) {
4123
- const whirlpool = await Whirlpool.fetch(this._connection, strategyState.pool);
4153
+ if (strategyState.strategyDex.toNumber() === dexToNumber('ORCA')) {
4154
+ const whirlpool = await Whirlpool.fetch(
4155
+ this._connection,
4156
+ strategyState.pool,
4157
+ this._orcaService.getWhirlpoolProgramId()
4158
+ );
4124
4159
  if (!whirlpool) {
4125
4160
  throw Error(`Could not fetch whirlpool state with pubkey ${strategyState.pool.toString()}`);
4126
4161
  }
@@ -4131,10 +4166,14 @@ export class Kamino {
4131
4166
  rewardMint0 = whirlpool.rewardInfos[0].mint;
4132
4167
  rewardMint1 = whirlpool.rewardInfos[1].mint;
4133
4168
  rewardMint2 = whirlpool.rewardInfos[2].mint;
4134
- } else if (strategyState.strategyDex.toNumber() == dexToNumber('RAYDIUM')) {
4135
- programId = RAYDIUM_PROGRAM_ID;
4169
+ } else if (strategyState.strategyDex.toNumber() === dexToNumber('RAYDIUM')) {
4170
+ programId = this._raydiumService.getRaydiumProgramId();
4136
4171
 
4137
- const poolState = await PoolState.fetch(this._connection, strategyState.pool);
4172
+ const poolState = await PoolState.fetch(
4173
+ this._connection,
4174
+ strategyState.pool,
4175
+ this._raydiumService.getRaydiumProgramId()
4176
+ );
4138
4177
  if (!poolState) {
4139
4178
  throw Error(`Could not fetch Raydium pool state with pubkey ${strategyState.pool.toString()}`);
4140
4179
  }
@@ -4145,9 +4184,13 @@ export class Kamino {
4145
4184
  rewardMint1 = poolState.rewardInfos[1].tokenMint;
4146
4185
  rewardMint2 = poolState.rewardInfos[2].tokenMint;
4147
4186
  } else if (strategyState.strategyDex.toNumber() == dexToNumber('METEORA')) {
4148
- programId = METEORA_PROGRAM_ID;
4187
+ programId = this._meteoraService.getMeteoraProgramId();
4149
4188
 
4150
- const poolState = await LbPair.fetch(this._connection, strategyState.pool);
4189
+ const poolState = await LbPair.fetch(
4190
+ this._connection,
4191
+ strategyState.pool,
4192
+ this._meteoraService.getMeteoraProgramId()
4193
+ );
4151
4194
  if (!poolState) {
4152
4195
  throw Error(`Could not fetch Meteora pool state with pubkey ${strategyState.pool.toString()}`);
4153
4196
  }
@@ -4215,7 +4258,7 @@ export class Kamino {
4215
4258
  if (strategyState.strategyDex.toNumber() == dexToNumber('RAYDIUM')) {
4216
4259
  const [poolTickArrayBitmap, _poolTickArrayBitmapBump] = PublicKey.findProgramAddressSync(
4217
4260
  [Buffer.from('pool_tick_array_bitmap_extension'), strategyState.pool.toBuffer()],
4218
- RAYDIUM_PROGRAM_ID
4261
+ this._raydiumService.getRaydiumProgramId()
4219
4262
  );
4220
4263
 
4221
4264
  ixn.keys.push({ pubkey: poolTickArrayBitmap, isSigner: false, isWritable: true });
@@ -4231,7 +4274,7 @@ export class Kamino {
4231
4274
  getMetadataProgramAddressesOrca = (positionMint: PublicKey): MetadataProgramAddressesOrca => {
4232
4275
  const [position, positionBump] = PublicKey.findProgramAddressSync(
4233
4276
  [Buffer.from('position'), positionMint.toBuffer()],
4234
- WHIRLPOOL_PROGRAM_ID
4277
+ this._orcaService.getWhirlpoolProgramId()
4235
4278
  );
4236
4279
 
4237
4280
  const [positionMetadata, positionMetadataBump] = PublicKey.findProgramAddressSync(
@@ -4254,7 +4297,7 @@ export class Kamino {
4254
4297
  tickUpperIndex: number
4255
4298
  ): MetadataProgramAddressesRaydium => {
4256
4299
  const { publicKey: protocolPosition, nonce: protocolPositionBump } = getPdaProtocolPositionAddress(
4257
- RAYDIUM_PROGRAM_ID,
4300
+ this._raydiumService.getRaydiumProgramId(),
4258
4301
  pool,
4259
4302
  tickLowerIndex,
4260
4303
  tickUpperIndex
@@ -4262,7 +4305,7 @@ export class Kamino {
4262
4305
 
4263
4306
  const [position, positionBump] = PublicKey.findProgramAddressSync(
4264
4307
  [Buffer.from('position'), positionMint.toBuffer()],
4265
- RAYDIUM_PROGRAM_ID
4308
+ this._raydiumService.getRaydiumProgramId()
4266
4309
  );
4267
4310
 
4268
4311
  const [positionMetadata, positionMetadataBump] = PublicKey.findProgramAddressSync(
@@ -4291,11 +4334,11 @@ export class Kamino {
4291
4334
 
4292
4335
  const [lowerTickPubkey, lowerTickBump] = PublicKey.findProgramAddressSync(
4293
4336
  [Buffer.from('tick_array'), whirlpool.toBuffer(), Buffer.from(startTickIndex.toString())],
4294
- WHIRLPOOL_PROGRAM_ID
4337
+ this._orcaService.getWhirlpoolProgramId()
4295
4338
  );
4296
4339
  const [upperTickPubkey, upperTickBump] = PublicKey.findProgramAddressSync(
4297
4340
  [Buffer.from('tick_array'), whirlpool.toBuffer(), Buffer.from(endTickIndex.toString())],
4298
- WHIRLPOOL_PROGRAM_ID
4341
+ this._orcaService.getWhirlpoolProgramId()
4299
4342
  );
4300
4343
  return {
4301
4344
  lowerTick: lowerTickPubkey,
@@ -4316,11 +4359,11 @@ export class Kamino {
4316
4359
 
4317
4360
  const [lowerTickPubkey, lowerTickBump] = PublicKey.findProgramAddressSync(
4318
4361
  [Buffer.from('tick_array'), pool.toBuffer(), i32ToBytes(startTickIndex)],
4319
- RAYDIUM_PROGRAM_ID
4362
+ this._raydiumService.getRaydiumProgramId()
4320
4363
  );
4321
4364
  const [upperTickPubkey, upperTickBump] = PublicKey.findProgramAddressSync(
4322
4365
  [Buffer.from('tick_array'), pool.toBuffer(), i32ToBytes(endTickIndex)],
4323
- RAYDIUM_PROGRAM_ID
4366
+ this._raydiumService.getRaydiumProgramId()
4324
4367
  );
4325
4368
  return {
4326
4369
  lowerTick: lowerTickPubkey,
@@ -4331,8 +4374,8 @@ export class Kamino {
4331
4374
  };
4332
4375
 
4333
4376
  private readMeteoraPosition = async (poolPk: PublicKey, positionPk: PublicKey): Promise<MeteoraPosition> => {
4334
- const pool = await LbPair.fetch(this._connection, poolPk);
4335
- const position = await PositionV2.fetch(this._connection, positionPk);
4377
+ const pool = await LbPair.fetch(this._connection, poolPk, this._meteoraService.getMeteoraProgramId());
4378
+ const position = await PositionV2.fetch(this._connection, positionPk, this._meteoraService.getMeteoraProgramId());
4336
4379
  if (!pool || !position) {
4337
4380
  return {
4338
4381
  publicKey: positionPk,
@@ -4345,8 +4388,16 @@ export class Kamino {
4345
4388
  poolPk,
4346
4389
  position.lowerBinId
4347
4390
  );
4348
- const lowerBinArray = await BinArray.fetch(this._connection, lowerTickPk);
4349
- const upperBinArray = await BinArray.fetch(this._connection, upperTickPk);
4391
+ const lowerBinArray = await BinArray.fetch(
4392
+ this._connection,
4393
+ lowerTickPk,
4394
+ this._meteoraService.getMeteoraProgramId()
4395
+ );
4396
+ const upperBinArray = await BinArray.fetch(
4397
+ this._connection,
4398
+ upperTickPk,
4399
+ this._meteoraService.getMeteoraProgramId()
4400
+ );
4350
4401
  if (!lowerBinArray || !upperBinArray) {
4351
4402
  return {
4352
4403
  publicKey: positionPk,
@@ -4385,7 +4436,7 @@ export class Kamino {
4385
4436
  pool: PublicKey,
4386
4437
  tickLowerIndex: number
4387
4438
  ): LowerAndUpperTickPubkeys => {
4388
- const meteoraProgramId = METEORA_PROGRAM_ID;
4439
+ const meteoraProgramId = this._meteoraService.getMeteoraProgramId();
4389
4440
 
4390
4441
  const lowerBinArrayIndex = binIdToBinArrayIndex(new BN(tickLowerIndex));
4391
4442
  const [lowerTick, lowerTickBump] = deriveBinArray(pool, lowerBinArrayIndex, meteoraProgramId);
@@ -4543,7 +4594,7 @@ export class Kamino {
4543
4594
  eventAuthority: PublicKey,
4544
4595
  status: StrategyStatusKind = new Uninitialized()
4545
4596
  ): Promise<TransactionInstruction> => {
4546
- const whirlpool = await Whirlpool.fetch(this._connection, pool);
4597
+ const whirlpool = await Whirlpool.fetch(this._connection, pool, this._orcaService.getWhirlpoolProgramId());
4547
4598
  if (!whirlpool) {
4548
4599
  throw Error(`Could not fetch whirlpool state with pubkey ${pool.toString()}`);
4549
4600
  }
@@ -4599,7 +4650,7 @@ export class Kamino {
4599
4650
  tokenProgram: TOKEN_PROGRAM_ID,
4600
4651
  tokenProgram2022: TOKEN_2022_PROGRAM_ID,
4601
4652
  associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
4602
- poolProgram: WHIRLPOOL_PROGRAM_ID,
4653
+ poolProgram: this._orcaService.getWhirlpoolProgramId(),
4603
4654
  oldPositionOrBaseVaultAuthority: isRebalancing ? oldPositionOrBaseVaultAuthority : baseVaultAuthority,
4604
4655
  oldPositionMintOrBaseVaultAuthority: isRebalancing ? oldPositionMintOrBaseVaultAuthority : positionMint,
4605
4656
  oldPositionTokenAccountOrBaseVaultAuthority: isRebalancing
@@ -4663,7 +4714,7 @@ export class Kamino {
4663
4714
  strategyReward1Vault?: PublicKey,
4664
4715
  strategyReward2Vault?: PublicKey
4665
4716
  ): Promise<TransactionInstruction> => {
4666
- const poolState = await PoolState.fetch(this._connection, pool);
4717
+ const poolState = await PoolState.fetch(this._connection, pool, this._raydiumService.getRaydiumProgramId());
4667
4718
  if (!poolState) {
4668
4719
  throw Error(`Could not fetch Raydium pool state with pubkey ${pool.toString()}`);
4669
4720
  }
@@ -4729,7 +4780,7 @@ export class Kamino {
4729
4780
  tokenProgram: TOKEN_PROGRAM_ID,
4730
4781
  tokenProgram2022: TOKEN_2022_PROGRAM_ID,
4731
4782
  associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
4732
- poolProgram: RAYDIUM_PROGRAM_ID,
4783
+ poolProgram: this._raydiumService.getRaydiumProgramId(),
4733
4784
  oldPositionOrBaseVaultAuthority: isRebalancing ? oldPositionOrBaseVaultAuthority : baseVaultAuthority,
4734
4785
  oldPositionMintOrBaseVaultAuthority: isRebalancing ? oldPositionMintOrBaseVaultAuthority : positionMint,
4735
4786
  oldPositionTokenAccountOrBaseVaultAuthority: isRebalancing
@@ -4754,7 +4805,7 @@ export class Kamino {
4754
4805
  };
4755
4806
  const [poolTickArrayBitmap, _poolTickArrayBitmapBump] = PublicKey.findProgramAddressSync(
4756
4807
  [Buffer.from('pool_tick_array_bitmap_extension'), pool.toBuffer()],
4757
- RAYDIUM_PROGRAM_ID
4808
+ this._raydiumService.getRaydiumProgramId()
4758
4809
  );
4759
4810
 
4760
4811
  const ix = openLiquidityPosition(args, accounts);
@@ -4821,7 +4872,7 @@ export class Kamino {
4821
4872
  eventAuthority: PublicKey,
4822
4873
  status: StrategyStatusKind = new Uninitialized()
4823
4874
  ): Promise<TransactionInstruction> => {
4824
- const lbPair = await LbPair.fetch(this._connection, pool);
4875
+ const lbPair = await LbPair.fetch(this._connection, pool, this._meteoraService.getMeteoraProgramId());
4825
4876
  if (!lbPair) {
4826
4877
  throw Error(`Could not fetch meteora lbpair state with pubkey ${pool.toString()}`);
4827
4878
  }
@@ -4869,7 +4920,7 @@ export class Kamino {
4869
4920
  tokenProgram: TOKEN_PROGRAM_ID,
4870
4921
  tokenProgram2022: TOKEN_2022_PROGRAM_ID,
4871
4922
  associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
4872
- poolProgram: WHIRLPOOL_PROGRAM_ID,
4923
+ poolProgram: this._orcaService.getWhirlpoolProgramId(),
4873
4924
  oldPositionOrBaseVaultAuthority: isRebalancing ? oldPositionOrBaseVaultAuthority : baseVaultAuthority,
4874
4925
  oldPositionMintOrBaseVaultAuthority: isRebalancing ? oldPositionMintOrBaseVaultAuthority : positionMint,
4875
4926
  oldPositionTokenAccountOrBaseVaultAuthority: isRebalancing
@@ -5323,7 +5374,7 @@ export class Kamino {
5323
5374
  let tokenMintB: PublicKey;
5324
5375
  let tickSpacing: number;
5325
5376
  if (dex == 'ORCA') {
5326
- const whirlpoolState = await Whirlpool.fetch(this._connection, pool);
5377
+ const whirlpoolState = await Whirlpool.fetch(this._connection, pool, this._orcaService.getWhirlpoolProgramId());
5327
5378
  if (!whirlpoolState) {
5328
5379
  throw Error(`Could not fetch whirlpool state with pubkey ${pool.toString()}`);
5329
5380
  }
@@ -5331,7 +5382,11 @@ export class Kamino {
5331
5382
  tokenMintB = whirlpoolState.tokenMintB;
5332
5383
  tickSpacing = whirlpoolState.tickSpacing;
5333
5384
  } else if (dex == 'RAYDIUM') {
5334
- const raydiumPoolState = await PoolState.fetch(this._connection, pool);
5385
+ const raydiumPoolState = await PoolState.fetch(
5386
+ this._connection,
5387
+ pool,
5388
+ this._raydiumService.getRaydiumProgramId()
5389
+ );
5335
5390
  if (!raydiumPoolState) {
5336
5391
  throw Error(`Could not fetch Raydium pool state with pubkey ${pool.toString()}`);
5337
5392
  }
@@ -5339,7 +5394,7 @@ export class Kamino {
5339
5394
  tokenMintB = raydiumPoolState.tokenMint1;
5340
5395
  tickSpacing = raydiumPoolState.tickSpacing;
5341
5396
  } else if (dex == 'METEORA') {
5342
- const meteoraPoolState = await LbPair.fetch(this._connection, pool);
5397
+ const meteoraPoolState = await LbPair.fetch(this._connection, pool, this._meteoraService.getMeteoraProgramId());
5343
5398
  if (!meteoraPoolState) {
5344
5399
  throw Error(`Could not fetch Meteora pool state with pubkey ${pool.toString()}`);
5345
5400
  }
@@ -5604,19 +5659,23 @@ export class Kamino {
5604
5659
 
5605
5660
  async getPoolTickSpacing(dex: Dex, pool: PublicKey): Promise<number> {
5606
5661
  if (dex == 'ORCA') {
5607
- const whirlpoolState = await Whirlpool.fetch(this._connection, pool);
5662
+ const whirlpoolState = await Whirlpool.fetch(this._connection, pool, this._orcaService.getWhirlpoolProgramId());
5608
5663
  if (!whirlpoolState) {
5609
5664
  throw Error(`Could not fetch whirlpool state with pubkey ${pool.toString()}`);
5610
5665
  }
5611
5666
  return whirlpoolState.tickSpacing;
5612
5667
  } else if (dex == 'RAYDIUM') {
5613
- const raydiumPoolState = await PoolState.fetch(this._connection, pool);
5668
+ const raydiumPoolState = await PoolState.fetch(
5669
+ this._connection,
5670
+ pool,
5671
+ this._raydiumService.getRaydiumProgramId()
5672
+ );
5614
5673
  if (!raydiumPoolState) {
5615
5674
  throw Error(`Could not fetch Raydium pool state with pubkey ${pool.toString()}`);
5616
5675
  }
5617
5676
  return raydiumPoolState.tickSpacing;
5618
5677
  } else if (dex == 'METEORA') {
5619
- const meteoraPoolState = await LbPair.fetch(this._connection, pool);
5678
+ const meteoraPoolState = await LbPair.fetch(this._connection, pool, this._meteoraService.getMeteoraProgramId());
5620
5679
  if (!meteoraPoolState) {
5621
5680
  throw Error(`Could not fetch Meteora pool state with pubkey ${pool.toString()}`);
5622
5681
  }
@@ -5939,7 +5998,7 @@ export class Kamino {
5939
5998
  }
5940
5999
 
5941
6000
  async getRaydiumPoolPrice(pool: PublicKey): Promise<Decimal> {
5942
- const poolState = await PoolState.fetch(this._connection, pool);
6001
+ const poolState = await PoolState.fetch(this._connection, pool, this._raydiumService.getRaydiumProgramId());
5943
6002
  if (!poolState) {
5944
6003
  throw new Error(`Raydium poolState ${pool.toString()} is not found`);
5945
6004
  }
@@ -5953,7 +6012,7 @@ export class Kamino {
5953
6012
  }
5954
6013
 
5955
6014
  async getMeteoraPoolPrice(pool: PublicKey): Promise<Decimal> {
5956
- const poolState = await LbPair.fetch(this._connection, pool);
6015
+ const poolState = await LbPair.fetch(this._connection, pool, this._meteoraService.getMeteoraProgramId());
5957
6016
  if (!poolState) {
5958
6017
  throw new Error(`Meteora poolState ${pool.toString()} is not found`);
5959
6018
  }
@@ -6672,7 +6731,7 @@ export class Kamino {
6672
6731
  const tokenAAmountToDeposit = new Decimal(100.0);
6673
6732
 
6674
6733
  if (dex == 'RAYDIUM') {
6675
- const poolState = await PoolState.fetch(this._connection, pool);
6734
+ const poolState = await PoolState.fetch(this._connection, pool, this._raydiumService.getRaydiumProgramId());
6676
6735
  if (!poolState) {
6677
6736
  throw new Error(`Raydium poolState ${pool.toString()} is not found`);
6678
6737
  }
@@ -6691,7 +6750,7 @@ export class Kamino {
6691
6750
  const amountBDecimal = new Decimal(amountB.toString());
6692
6751
  return [lamportsToNumberDecimal(amountADecimal, decimalsA), lamportsToNumberDecimal(amountBDecimal, decimalsB)];
6693
6752
  } else if (dex == 'ORCA') {
6694
- const whirlpoolState = await Whirlpool.fetch(this._connection, pool);
6753
+ const whirlpoolState = await Whirlpool.fetch(this._connection, pool, this._orcaService.getWhirlpoolProgramId());
6695
6754
  if (!whirlpoolState) {
6696
6755
  throw new Error(`Raydium poolState ${pool.toString()} is not found`);
6697
6756
  }
@@ -6727,7 +6786,7 @@ export class Kamino {
6727
6786
  lamportsToNumberDecimal(addLiqResult.estTokenB.toNumber(), decimalsB),
6728
6787
  ];
6729
6788
  } else if (dex == 'METEORA') {
6730
- const poolState = await LbPair.fetch(this._connection, pool);
6789
+ const poolState = await LbPair.fetch(this._connection, pool, this._meteoraService.getMeteoraProgramId());
6731
6790
  if (!poolState) {
6732
6791
  throw new Error(`Meteora poolState ${pool.toString()} is not found`);
6733
6792
  }
@@ -6840,7 +6899,11 @@ export class Kamino {
6840
6899
  const isRaydium = dexToNumber('RAYDIUM') === dex;
6841
6900
  const isMeteora = dexToNumber('METEORA') === dex;
6842
6901
  if (isOrca) {
6843
- const whirlpool = await Whirlpool.fetch(this._connection, strategyState.pool);
6902
+ const whirlpool = await Whirlpool.fetch(
6903
+ this._connection,
6904
+ strategyState.pool,
6905
+ this._orcaService.getWhirlpoolProgramId()
6906
+ );
6844
6907
  if (!whirlpool) {
6845
6908
  throw new Error(`Unable to get Orca whirlpool for pubkey ${strategyState.pool}`);
6846
6909
  }
@@ -6881,7 +6944,7 @@ export class Kamino {
6881
6944
  return [new Decimal(0), new Decimal(0)];
6882
6945
  }
6883
6946
  // Given A in ATA, calc how much A and B
6884
- const accessor = new OrcaDAL(whirlpoolConfig, WHIRLPOOL_PROGRAM_ID, this._connection);
6947
+ const accessor = new OrcaDAL(whirlpoolConfig, this._orcaService.getWhirlpoolProgramId(), this._connection);
6885
6948
  const orcaPosition = new OrcaPosition(accessor);
6886
6949
  const defaultSlippagePercentage = Percentage.fromFraction(1, 1000); // 0.1%
6887
6950
 
@@ -6936,8 +6999,16 @@ export class Kamino {
6936
6999
  return [new Decimal(0), new Decimal(0)];
6937
7000
  }
6938
7001
 
6939
- const poolState = await PoolState.fetch(this._connection, strategyState.pool);
6940
- const position = await PersonalPositionState.fetch(this._connection, strategyState.position);
7002
+ const poolState = await PoolState.fetch(
7003
+ this._connection,
7004
+ strategyState.pool,
7005
+ this._raydiumService.getRaydiumProgramId()
7006
+ );
7007
+ const position = await PersonalPositionState.fetch(
7008
+ this._connection,
7009
+ strategyState.position,
7010
+ this._raydiumService.getRaydiumProgramId()
7011
+ );
6941
7012
 
6942
7013
  if (!position) {
6943
7014
  throw new Error(`position ${strategyState.position.toString()} is not found`);
@@ -7007,7 +7078,11 @@ export class Kamino {
7007
7078
  return [new Decimal(0), new Decimal(0)];
7008
7079
  }
7009
7080
 
7010
- const poolState = await LbPair.fetch(this._connection, strategyState.pool);
7081
+ const poolState = await LbPair.fetch(
7082
+ this._connection,
7083
+ strategyState.pool,
7084
+ this._meteoraService.getMeteoraProgramId()
7085
+ );
7011
7086
  if (!poolState) {
7012
7087
  throw new Error(`poolState ${strategyState.pool.toString()} is not found`);
7013
7088
  }
@@ -7018,8 +7093,12 @@ export class Kamino {
7018
7093
  return [tokenAAmount, tokenBAmount];
7019
7094
  } else {
7020
7095
  const binArrayIndex = binIdToBinArrayIndex(new BN(poolState.activeId));
7021
- const [binArrayPk] = deriveBinArray(strategyState.pool, binArrayIndex, METEORA_PROGRAM_ID);
7022
- const binArray = await BinArray.fetch(this._connection, binArrayPk);
7096
+ const [binArrayPk] = deriveBinArray(
7097
+ strategyState.pool,
7098
+ binArrayIndex,
7099
+ this._meteoraService.getMeteoraProgramId()
7100
+ );
7101
+ const binArray = await BinArray.fetch(this._connection, binArrayPk, this._meteoraService.getMeteoraProgramId());
7023
7102
  if (!binArray) {
7024
7103
  throw new Error(`bin array ${binArrayPk.toString()} is not found`);
7025
7104
  }
@@ -7160,12 +7239,20 @@ export class Kamino {
7160
7239
  ): Promise<{ amountSlippageA: BN; amountSlippageB: BN }> {
7161
7240
  const { strategy: strategyState } = await this.getStrategyStateIfNotFetched(strategy);
7162
7241
 
7163
- const whirlpool = await Whirlpool.fetch(this._connection, strategyState.pool);
7242
+ const whirlpool = await Whirlpool.fetch(
7243
+ this._connection,
7244
+ strategyState.pool,
7245
+ this._orcaService.getWhirlpoolProgramId()
7246
+ );
7164
7247
  if (!whirlpool) {
7165
7248
  throw Error(`Could not fetch whirlpool state with pubkey ${strategyState.pool.toString()}`);
7166
7249
  }
7167
7250
 
7168
- const position = await Position.fetch(this._connection, strategyState.position);
7251
+ const position = await Position.fetch(
7252
+ this._connection,
7253
+ strategyState.position,
7254
+ this._orcaService.getWhirlpoolProgramId()
7255
+ );
7169
7256
  if (!position) {
7170
7257
  throw new Error(`Whirlpool position ${strategyState.position} does not exist`);
7171
7258
  }
@@ -7192,8 +7279,16 @@ export class Kamino {
7192
7279
  ): Promise<{ amountSlippageA: BN; amountSlippageB: BN }> {
7193
7280
  const { strategy: strategyState } = await this.getStrategyStateIfNotFetched(strategy);
7194
7281
 
7195
- const poolStatePromise = LbPair.fetch(this._connection, strategyState.pool);
7196
- const positionPromise = PositionV2.fetch(this._connection, strategyState.position);
7282
+ const poolStatePromise = LbPair.fetch(
7283
+ this._connection,
7284
+ strategyState.pool,
7285
+ this._meteoraService.getMeteoraProgramId()
7286
+ );
7287
+ const positionPromise = PositionV2.fetch(
7288
+ this._connection,
7289
+ strategyState.position,
7290
+ this._meteoraService.getMeteoraProgramId()
7291
+ );
7197
7292
 
7198
7293
  const [poolState, _position] = await Promise.all([poolStatePromise, positionPromise]);
7199
7294
  if (!poolState) {
@@ -7208,9 +7303,10 @@ export class Kamino {
7208
7303
  ): Promise<{ amountSlippageA: BN; amountSlippageB: BN }> {
7209
7304
  const { strategy: strategyState } = await this.getStrategyStateIfNotFetched(strategy);
7210
7305
 
7211
- const poolStatePromise = await LbPair.fetch(this._connection, strategyState.pool);
7212
- const positionPromise = await PositionV2.fetch(this._connection, strategyState.position);
7213
- const [poolState, _position] = await Promise.all([poolStatePromise, positionPromise]);
7306
+ const [poolState, _position] = await Promise.all([
7307
+ LbPair.fetch(this._connection, strategyState.pool, this._meteoraService.getMeteoraProgramId()),
7308
+ PositionV2.fetch(this._connection, strategyState.position, this._meteoraService.getMeteoraProgramId()),
7309
+ ]);
7214
7310
 
7215
7311
  if (!poolState) {
7216
7312
  throw Error(`Could not fetch lb pair state with pubkey ${strategyState.pool.toString()}`);
@@ -7225,12 +7321,20 @@ export class Kamino {
7225
7321
  ): Promise<{ amountSlippageA: BN; amountSlippageB: BN }> => {
7226
7322
  const { strategy: strategyState } = await this.getStrategyStateIfNotFetched(strategy);
7227
7323
 
7228
- const whirlpool = await Whirlpool.fetch(this._connection, strategyState.pool);
7324
+ const whirlpool = await Whirlpool.fetch(
7325
+ this._connection,
7326
+ strategyState.pool,
7327
+ this._orcaService.getWhirlpoolProgramId()
7328
+ );
7229
7329
  if (!whirlpool) {
7230
7330
  throw Error(`Could not fetch whirlpool state with pubkey ${strategyState.pool.toString()}`);
7231
7331
  }
7232
7332
 
7233
- const position = await Position.fetch(this._connection, strategyState.position);
7333
+ const position = await Position.fetch(
7334
+ this._connection,
7335
+ strategyState.position,
7336
+ this._orcaService.getWhirlpoolProgramId()
7337
+ );
7234
7338
  if (!position) {
7235
7339
  throw new Error(`Whirlpool position ${strategyState.position} does not exist`);
7236
7340
  }
@@ -7258,8 +7362,16 @@ export class Kamino {
7258
7362
  ): Promise<{ amountSlippageA: BN; amountSlippageB: BN }> => {
7259
7363
  const { strategy: strategyState } = await this.getStrategyStateIfNotFetched(strategy);
7260
7364
 
7261
- const poolState = await PoolState.fetch(this._connection, strategyState.pool);
7262
- const positionState = await PersonalPositionState.fetch(this._connection, strategyState.position);
7365
+ const poolState = await PoolState.fetch(
7366
+ this._connection,
7367
+ strategyState.pool,
7368
+ this._raydiumService.getRaydiumProgramId()
7369
+ );
7370
+ const positionState = await PersonalPositionState.fetch(
7371
+ this._connection,
7372
+ strategyState.position,
7373
+ this._raydiumService.getRaydiumProgramId()
7374
+ );
7263
7375
 
7264
7376
  if (!positionState) {
7265
7377
  throw new Error(`Raydium position ${strategyState.position.toString()} could not be found.`);
@@ -7291,8 +7403,16 @@ export class Kamino {
7291
7403
  ): Promise<{ amountSlippageA: BN; amountSlippageB: BN }> => {
7292
7404
  const { strategy: strategyState } = await this.getStrategyStateIfNotFetched(strategy);
7293
7405
 
7294
- const poolState = await PoolState.fetch(this._connection, strategyState.pool);
7295
- const positionState = await PersonalPositionState.fetch(this._connection, strategyState.position);
7406
+ const poolState = await PoolState.fetch(
7407
+ this._connection,
7408
+ strategyState.pool,
7409
+ this._raydiumService.getRaydiumProgramId()
7410
+ );
7411
+ const positionState = await PersonalPositionState.fetch(
7412
+ this._connection,
7413
+ strategyState.position,
7414
+ this._raydiumService.getRaydiumProgramId()
7415
+ );
7296
7416
 
7297
7417
  if (!positionState) {
7298
7418
  throw new Error(`Raydium position ${strategyState.position.toString()} could not be found.`);
@@ -7430,7 +7550,11 @@ export class Kamino {
7430
7550
  const collateralInfos = await this.getCollateralInfo(globalConfig.tokenInfos);
7431
7551
  const result: [TransactionInstruction, Keypair][] = [];
7432
7552
  if (strategyState.strategyDex.toNumber() == dexToNumber('ORCA')) {
7433
- const whirlpool = await Whirlpool.fetch(this._connection, strategyState.pool);
7553
+ const whirlpool = await Whirlpool.fetch(
7554
+ this._connection,
7555
+ strategyState.pool,
7556
+ this._orcaService.getWhirlpoolProgramId()
7557
+ );
7434
7558
  if (!whirlpool) {
7435
7559
  throw Error(`Could not fetch whirlpool state with pubkey ${strategyState.pool.toString()}`);
7436
7560
  }
@@ -7468,7 +7592,11 @@ export class Kamino {
7468
7592
  }
7469
7593
  return result;
7470
7594
  } else if (strategyState.strategyDex.toNumber() == dexToNumber('RAYDIUM')) {
7471
- const poolState = await PoolState.fetch(this._connection, strategyState.pool);
7595
+ const poolState = await PoolState.fetch(
7596
+ this._connection,
7597
+ strategyState.pool,
7598
+ this._raydiumService.getRaydiumProgramId()
7599
+ );
7472
7600
  if (!poolState) {
7473
7601
  throw new Error(`Could not fetch whirlpool state with pubkey ${strategyState.pool.toString()}`);
7474
7602
  }
@@ -7506,7 +7634,11 @@ export class Kamino {
7506
7634
  }
7507
7635
  return result;
7508
7636
  } else if (strategyState.strategyDex.toNumber() == dexToNumber('METEORA')) {
7509
- const poolState = await LbPair.fetch(this._connection, strategyState.pool);
7637
+ const poolState = await LbPair.fetch(
7638
+ this._connection,
7639
+ strategyState.pool,
7640
+ this._meteoraService.getMeteoraProgramId()
7641
+ );
7510
7642
  if (!poolState) {
7511
7643
  throw new Error(`Could not fetch meteora state with pubkey ${strategyState.pool.toString()}`);
7512
7644
  }
@@ -7567,8 +7699,12 @@ export class Kamino {
7567
7699
  const tickIndex = getNextValidTickIndex(priceToTickIndex(price, decimalsA, decimalsB), whilrpoolState.tickSpacing);
7568
7700
  const startTickIndex = getStartTickIndex(tickIndex, whilrpoolState.tickSpacing);
7569
7701
 
7570
- const [startTickIndexPk, _startTickIndexBump] = getTickArray(WHIRLPOOL_PROGRAM_ID, poolAddress, startTickIndex);
7571
- const tick = await TickArray.fetch(this._connection, startTickIndexPk);
7702
+ const [startTickIndexPk, _startTickIndexBump] = getTickArray(
7703
+ this._orcaService.getWhirlpoolProgramId(),
7704
+ poolAddress,
7705
+ startTickIndex
7706
+ );
7707
+ const tick = await TickArray.fetch(this._connection, startTickIndexPk, this._orcaService.getWhirlpoolProgramId());
7572
7708
  // initialize tick if it doesn't exist
7573
7709
  if (!tick) {
7574
7710
  const initTickArrayArgs: InitializeTickArrayArgs = {
@@ -7603,8 +7739,12 @@ export class Kamino {
7603
7739
  const binArray = getBinIdFromPriceWithDecimals(price, poolState.binStep, true, decimalsA, decimalsB);
7604
7740
  const binArrayIndex = binIdToBinArrayIndex(new BN(binArray));
7605
7741
 
7606
- const [startTickIndexPk, _startTickIndexBump] = deriveBinArray(poolAddress, binArrayIndex, METEORA_PROGRAM_ID);
7607
- const tick = await TickArray.fetch(this._connection, startTickIndexPk);
7742
+ const [startTickIndexPk, _startTickIndexBump] = deriveBinArray(
7743
+ poolAddress,
7744
+ binArrayIndex,
7745
+ this._meteoraService.getMeteoraProgramId()
7746
+ );
7747
+ const tick = await TickArray.fetch(this._connection, startTickIndexPk, this._meteoraService.getMeteoraProgramId());
7608
7748
  // initialize tick if it doesn't exist
7609
7749
  if (!tick) {
7610
7750
  const initTickArrayArgs: InitializeBinArrayArgs = {