@raydium-io/raydium-sdk-v2 0.1.8-alpha → 0.1.9-alpha

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 (46) hide show
  1. package/lib/api/api.js +1 -1
  2. package/lib/api/api.js.map +1 -1
  3. package/lib/api/api.mjs +1 -1
  4. package/lib/api/api.mjs.map +1 -1
  5. package/lib/api/index.js +1 -1
  6. package/lib/api/index.js.map +1 -1
  7. package/lib/api/index.mjs +1 -1
  8. package/lib/api/index.mjs.map +1 -1
  9. package/lib/index.d.ts +1 -1
  10. package/lib/index.js +1 -1
  11. package/lib/index.js.map +1 -1
  12. package/lib/index.mjs +1 -1
  13. package/lib/index.mjs.map +1 -1
  14. package/lib/raydium/account/account.d.ts +1 -1
  15. package/lib/raydium/clmm/clmm.d.ts +1 -1
  16. package/lib/raydium/clmm/index.d.ts +1 -1
  17. package/lib/raydium/cpmm/cpmm.d.ts +1 -1
  18. package/lib/raydium/farm/farm.d.ts +1 -1
  19. package/lib/raydium/ido/ido.d.ts +1 -1
  20. package/lib/raydium/ido/index.d.ts +1 -1
  21. package/lib/raydium/index.d.ts +1 -1
  22. package/lib/raydium/index.js +1 -1
  23. package/lib/raydium/index.js.map +1 -1
  24. package/lib/raydium/index.mjs +1 -1
  25. package/lib/raydium/index.mjs.map +1 -1
  26. package/lib/raydium/liquidity/liquidity.d.ts +1 -1
  27. package/lib/raydium/liquidity/liquidity.js +1 -1
  28. package/lib/raydium/liquidity/liquidity.js.map +1 -1
  29. package/lib/raydium/liquidity/liquidity.mjs +1 -1
  30. package/lib/raydium/liquidity/liquidity.mjs.map +1 -1
  31. package/lib/raydium/marketV2/createMarket.d.ts +1 -1
  32. package/lib/raydium/marketV2/index.d.ts +1 -1
  33. package/lib/raydium/moduleBase.d.ts +1 -1
  34. package/lib/raydium/raydium.d.ts +1 -1
  35. package/lib/raydium/raydium.js +1 -1
  36. package/lib/raydium/raydium.js.map +1 -1
  37. package/lib/raydium/raydium.mjs +1 -1
  38. package/lib/raydium/raydium.mjs.map +1 -1
  39. package/lib/raydium/token/token.d.ts +1 -1
  40. package/lib/raydium/tradeV2/trade.d.ts +1 -1
  41. package/lib/raydium/utils1216/index.d.ts +1 -1
  42. package/lib/raydium/utils1216/utils1216.d.ts +1 -1
  43. package/lib/{raydium-916014c1.d.ts → raydium-05c7eeff.d.ts} +2 -1
  44. package/package.json +1 -1
  45. package/src/api/api.ts +1 -1
  46. package/src/raydium/liquidity/liquidity.ts +31 -0
@@ -1,6 +1,6 @@
1
1
  import '@solana/web3.js';
2
2
  import '../../type-9fe71e3c.js';
3
- export { j as default } from '../../raydium-916014c1.js';
3
+ export { j as default } from '../../raydium-05c7eeff.js';
4
4
  import 'bn.js';
5
5
  import '@solana/spl-token';
6
6
  import '../../solana/type.js';
@@ -1,5 +1,5 @@
1
1
  import '@solana/web3.js';
2
- export { i as default } from '../../raydium-916014c1.js';
2
+ export { i as default } from '../../raydium-05c7eeff.js';
3
3
  import './type.js';
4
4
  import '../../type-9fe71e3c.js';
5
5
  import '../../api/api.js';
@@ -1,4 +1,4 @@
1
- export { S as SHOW_INFO, d as canClaimErrorType, U as default } from '../../raydium-916014c1.js';
1
+ export { S as SHOW_INFO, d as canClaimErrorType, U as default } from '../../raydium-05c7eeff.js';
2
2
  import '@solana/web3.js';
3
3
  import '../../api/api.js';
4
4
  import 'axios';
@@ -1,7 +1,7 @@
1
1
  import '../../marshmallow/index.js';
2
2
  import '@solana/web3.js';
3
3
  import 'bn.js';
4
- export { S as SHOW_INFO, d as canClaimErrorType, U as default } from '../../raydium-916014c1.js';
4
+ export { S as SHOW_INFO, d as canClaimErrorType, U as default } from '../../raydium-05c7eeff.js';
5
5
  import '../../marshmallow/buffer-layout.js';
6
6
  import '../../api/api.js';
7
7
  import 'axios';
@@ -134,7 +134,7 @@ declare class LiquidityModule extends ModuleBase {
134
134
  getAmmPoolKeys(poolId: string): Promise<AmmV4Keys | AmmV5Keys>;
135
135
  addLiquidity<T extends TxVersion>(params: AddLiquidityParams<T>): Promise<MakeTxData<T>>;
136
136
  removeLiquidity<T extends TxVersion>(params: RemoveParams<T>): Promise<Promise<MakeTxData<T>>>;
137
- removeAllLpAndCreateClmmPosition<T extends TxVersion>({ poolInfo, clmmPoolInfo, removeLpAmount, createPositionInfo, farmInfo, userFarmLpAmount, base, computeBudgetConfig, payer, tokenProgram, checkCreateATAOwner, getEphemeralSigners, txVersion, }: {
137
+ removeAllLpAndCreateClmmPosition<T extends TxVersion>({ poolInfo, clmmPoolInfo, removeLpAmount, createPositionInfo, farmInfo, userFarmLpAmount, base, computeBudgetConfig, payer, userAuxiliaryLedgers, tokenProgram, checkCreateATAOwner, getEphemeralSigners, txVersion, }: {
138
138
  poolInfo: ApiV3PoolInfoStandardItem;
139
139
  clmmPoolInfo: ApiV3PoolInfoConcentratedItem;
140
140
  removeLpAmount: BN__default;
@@ -146,6 +146,7 @@ declare class LiquidityModule extends ModuleBase {
146
146
  };
147
147
  farmInfo?: FormatFarmInfoOutV6;
148
148
  userFarmLpAmount?: BN__default;
149
+ userAuxiliaryLedgers?: PublicKey[];
149
150
  base: "MintA" | "MintB";
150
151
  payer?: PublicKey;
151
152
  computeBudgetConfig?: ComputeBudgetConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raydium-io/raydium-sdk-v2",
3
- "version": "0.1.8-alpha",
3
+ "version": "0.1.9-alpha",
4
4
  "description": "An SDK for building applications on top of Raydium.",
5
5
  "license": "GPL-3.0",
6
6
  "main": "./lib/index.js",
package/src/api/api.ts CHANGED
@@ -141,7 +141,7 @@ export class Api {
141
141
  id: string;
142
142
  jsonrpc: string;
143
143
  result: { numSlots: number; numTransactions: number; samplePeriodSecs: number; slot: number }[];
144
- } = await this.api.post(endpointUrl, {
144
+ } = await axios.post(endpointUrl, {
145
145
  id: "getRecentPerformanceSamples",
146
146
  jsonrpc: "2.0",
147
147
  method: "getRecentPerformanceSamples",
@@ -38,9 +38,13 @@ import { getAssociatedPoolKeys, getAssociatedConfigId } from "./utils";
38
38
  import { createPoolFeeLayout, liquidityStateV4Layout } from "./layout";
39
39
  import {
40
40
  FARM_PROGRAM_TO_VERSION,
41
+ FarmLedger,
41
42
  makeWithdrawInstructionV3,
42
43
  makeWithdrawInstructionV5,
43
44
  makeWithdrawInstructionV6,
45
+ createAssociatedLedgerAccountInstruction,
46
+ getAssociatedLedgerAccount,
47
+ getFarmLedgerLayout,
44
48
  } from "@/raydium/farm";
45
49
  import { StableLayout, getStablePrice, getDyByDxBaseIn, getDxByDyBaseIn } from "./stable";
46
50
  import { LIQUIDITY_FEES_NUMERATOR, LIQUIDITY_FEES_DENOMINATOR } from "./constant";
@@ -345,6 +349,7 @@ export default class LiquidityModule extends ModuleBase {
345
349
  base,
346
350
  computeBudgetConfig,
347
351
  payer,
352
+ userAuxiliaryLedgers,
348
353
  tokenProgram = TOKEN_PROGRAM_ID,
349
354
  checkCreateATAOwner = true,
350
355
  getEphemeralSigners,
@@ -361,6 +366,7 @@ export default class LiquidityModule extends ModuleBase {
361
366
  };
362
367
  farmInfo?: FormatFarmInfoOutV6;
363
368
  userFarmLpAmount?: BN;
369
+ userAuxiliaryLedgers?: PublicKey[];
364
370
  base: "MintA" | "MintB";
365
371
  payer?: PublicKey;
366
372
  computeBudgetConfig?: ComputeBudgetConfig;
@@ -445,6 +451,30 @@ export default class LiquidityModule extends ModuleBase {
445
451
  mintToAccount[poolInfo.mintB.address] = quoteTokenAccount;
446
452
 
447
453
  if (farmInfo !== undefined && !userFarmLpAmount?.isZero()) {
454
+ const farmVersion = FARM_PROGRAM_TO_VERSION[farmInfo.programId];
455
+ const ledger = getAssociatedLedgerAccount({
456
+ programId: new PublicKey(farmInfo.programId),
457
+ poolId: new PublicKey(farmInfo.id),
458
+ owner: this.scope.ownerPubKey,
459
+ version: farmVersion,
460
+ });
461
+ let ledgerInfo: FarmLedger | undefined = undefined;
462
+ const ledgerData = await this.scope.connection.getAccountInfo(ledger);
463
+ if (ledgerData) {
464
+ const ledgerLayout = getFarmLedgerLayout(farmVersion)!;
465
+ ledgerInfo = ledgerLayout.decode(ledgerData.data);
466
+ }
467
+ if (farmVersion !== 6 && !ledgerInfo) {
468
+ const { instruction, instructionType } = createAssociatedLedgerAccountInstruction({
469
+ id: new PublicKey(farmInfo.id),
470
+ programId: new PublicKey(farmInfo.programId),
471
+ version: farmVersion,
472
+ ledger,
473
+ owner: this.scope.ownerPubKey,
474
+ });
475
+ txBuilder.addInstruction({ instructions: [instruction], instructionTypes: [instructionType] });
476
+ }
477
+
448
478
  const rewardTokenAccounts: PublicKey[] = [];
449
479
  for (const item of farmInfo.rewardInfos) {
450
480
  const rewardIsWsol = item.mint.address === Token.WSOL.mint.toString();
@@ -469,6 +499,7 @@ export default class LiquidityModule extends ModuleBase {
469
499
  }
470
500
  const farmKeys = (await this.scope.api.fetchFarmKeysById({ ids: farmInfo.id }))[0];
471
501
  const insParams = {
502
+ userAuxiliaryLedgers,
472
503
  amount: userFarmLpAmount!,
473
504
  owner: this.scope.ownerPubKey,
474
505
  farmInfo,