@raydium-io/raydium-sdk-v2 0.1.5-alpha → 0.1.7-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 (94) hide show
  1. package/lib/api/api.d.ts +1 -1
  2. package/lib/api/index.d.ts +1 -1
  3. package/lib/api/type.d.ts +1 -1
  4. package/lib/common/accountInfo.d.ts +1 -1
  5. package/lib/common/bignumber.d.ts +1 -1
  6. package/lib/common/fractionUtil.d.ts +1 -1
  7. package/lib/common/index.d.ts +1 -1
  8. package/lib/common/transfer.d.ts +1 -1
  9. package/lib/common/txTool/txTool.d.ts +1 -1
  10. package/lib/common/txTool/txUtils.d.ts +1 -1
  11. package/lib/common/utility.d.ts +1 -1
  12. package/lib/index.d.ts +3 -3
  13. package/lib/index.js +1 -1
  14. package/lib/index.js.map +1 -1
  15. package/lib/index.mjs +1 -1
  16. package/lib/index.mjs.map +1 -1
  17. package/lib/module/amount.d.ts +1 -1
  18. package/lib/module/fraction.d.ts +1 -1
  19. package/lib/module/index.d.ts +1 -1
  20. package/lib/module/percent.d.ts +1 -1
  21. package/lib/module/price.d.ts +1 -1
  22. package/lib/raydium/account/account.d.ts +3 -3
  23. package/lib/raydium/account/index.d.ts +1 -1
  24. package/lib/raydium/account/instruction.d.ts +1 -1
  25. package/lib/raydium/account/layout.d.ts +1 -1
  26. package/lib/raydium/account/types.d.ts +1 -1
  27. package/lib/raydium/account/util.d.ts +1 -1
  28. package/lib/raydium/clmm/clmm.d.ts +3 -3
  29. package/lib/raydium/clmm/index.d.ts +3 -3
  30. package/lib/raydium/clmm/instrument.d.ts +2 -2
  31. package/lib/raydium/clmm/layout.d.ts +3 -3
  32. package/lib/raydium/clmm/type.d.ts +2 -2
  33. package/lib/raydium/clmm/utils/math.d.ts +2 -2
  34. package/lib/raydium/clmm/utils/pool.d.ts +2 -2
  35. package/lib/raydium/clmm/utils/position.d.ts +2 -2
  36. package/lib/raydium/clmm/utils/tick.d.ts +2 -2
  37. package/lib/raydium/clmm/utils/tickQuery.d.ts +2 -2
  38. package/lib/raydium/clmm/utils/tickarrayBitmap.d.ts +2 -2
  39. package/lib/raydium/cpmm/cpmm.d.ts +3 -3
  40. package/lib/raydium/cpmm/cpmm.js +1 -1
  41. package/lib/raydium/cpmm/cpmm.js.map +1 -1
  42. package/lib/raydium/cpmm/cpmm.mjs +1 -1
  43. package/lib/raydium/cpmm/cpmm.mjs.map +1 -1
  44. package/lib/raydium/cpmm/index.d.ts +1 -1
  45. package/lib/raydium/cpmm/type.d.ts +4 -1
  46. package/lib/raydium/cpmm/type.js.map +1 -1
  47. package/lib/raydium/farm/config.d.ts +1 -1
  48. package/lib/raydium/farm/farm.d.ts +3 -3
  49. package/lib/raydium/farm/index.d.ts +1 -1
  50. package/lib/raydium/farm/instruction.d.ts +1 -1
  51. package/lib/raydium/farm/layout.d.ts +1 -1
  52. package/lib/raydium/farm/type.d.ts +1 -1
  53. package/lib/raydium/farm/util.d.ts +1 -1
  54. package/lib/raydium/ido/ido.d.ts +3 -3
  55. package/lib/raydium/ido/index.d.ts +3 -3
  56. package/lib/raydium/ido/instruction.d.ts +1 -1
  57. package/lib/raydium/ido/type.d.ts +1 -1
  58. package/lib/raydium/index.d.ts +3 -3
  59. package/lib/raydium/index.js +1 -1
  60. package/lib/raydium/index.js.map +1 -1
  61. package/lib/raydium/index.mjs +1 -1
  62. package/lib/raydium/index.mjs.map +1 -1
  63. package/lib/raydium/liquidity/index.d.ts +1 -1
  64. package/lib/raydium/liquidity/instruction.d.ts +1 -1
  65. package/lib/raydium/liquidity/layout.d.ts +2 -2
  66. package/lib/raydium/liquidity/liquidity.d.ts +3 -3
  67. package/lib/raydium/liquidity/type.d.ts +1 -1
  68. package/lib/raydium/liquidity/utils.d.ts +1 -1
  69. package/lib/raydium/marketV2/createMarket.d.ts +3 -3
  70. package/lib/raydium/marketV2/index.d.ts +3 -3
  71. package/lib/raydium/moduleBase.d.ts +3 -3
  72. package/lib/raydium/raydium.d.ts +3 -3
  73. package/lib/raydium/raydium.js +1 -1
  74. package/lib/raydium/raydium.js.map +1 -1
  75. package/lib/raydium/raydium.mjs +1 -1
  76. package/lib/raydium/raydium.mjs.map +1 -1
  77. package/lib/raydium/token/constant.d.ts +1 -1
  78. package/lib/raydium/token/index.d.ts +1 -1
  79. package/lib/raydium/token/token.d.ts +3 -3
  80. package/lib/raydium/token/type.d.ts +1 -1
  81. package/lib/raydium/token/utils.d.ts +1 -1
  82. package/lib/raydium/tradeV2/index.d.ts +2 -2
  83. package/lib/raydium/tradeV2/instrument.d.ts +2 -2
  84. package/lib/raydium/tradeV2/trade.d.ts +3 -3
  85. package/lib/raydium/tradeV2/type.d.ts +2 -2
  86. package/lib/raydium/type.d.ts +1 -1
  87. package/lib/raydium/utils1216/index.d.ts +3 -3
  88. package/lib/raydium/utils1216/utils1216.d.ts +3 -3
  89. package/lib/{raydium-e681ad95.d.ts → raydium-6c4df6ad.d.ts} +4 -4
  90. package/lib/{type-389634c9.d.ts → type-68b778f2.d.ts} +1 -1
  91. package/lib/{type-9fe71e3c.d.ts → type-bdbaf9b2.d.ts} +7 -7
  92. package/package.json +1 -1
  93. package/src/raydium/cpmm/cpmm.ts +28 -12
  94. package/src/raydium/cpmm/type.ts +3 -0
@@ -1,4 +1,4 @@
1
- import { bz as TokenInfo } from '../../type-9fe71e3c.js';
1
+ import { bz as TokenInfo } from '../../type-bdbaf9b2.js';
2
2
  import '@solana/web3.js';
3
3
  import 'bn.js';
4
4
  import '@solana/spl-token';
@@ -1,6 +1,6 @@
1
1
  export { SOL_INFO, TOKEN_WSOL } from './constant.js';
2
2
  export { SPL_MINT_LAYOUT, SplMintLayout } from './layout.js';
3
- export { bC as LpToken, bB as SplToken, bz as TokenInfo, bA as TokenJson } from '../../type-9fe71e3c.js';
3
+ export { bC as LpToken, bB as SplToken, bz as TokenInfo, bA as TokenJson } from '../../type-bdbaf9b2.js';
4
4
  export { parseTokenInfo, solToWSolToken, toToken, toTokenAmount, toTokenInfo, wSolToSolToken } from './utils.js';
5
5
  import '@solana/web3.js';
6
6
  import 'bn.js';
@@ -1,6 +1,6 @@
1
1
  import '@solana/web3.js';
2
- import '../../type-9fe71e3c.js';
3
- export { j as default } from '../../raydium-e681ad95.js';
2
+ import '../../type-bdbaf9b2.js';
3
+ export { j as default } from '../../raydium-6c4df6ad.js';
4
4
  import 'bn.js';
5
5
  import '@solana/spl-token';
6
6
  import '../../solana/type.js';
@@ -21,7 +21,7 @@ import '../account/types.js';
21
21
  import '../account/layout.js';
22
22
  import '../liquidity/type.js';
23
23
  import '../liquidity/layout.js';
24
- import '../../type-389634c9.js';
24
+ import '../../type-68b778f2.js';
25
25
  import '../clmm/layout.js';
26
26
  import '../cpmm/type.js';
27
27
  import '../cpmm/curve/calculator.js';
@@ -1,4 +1,4 @@
1
- export { bC as LpToken, bB as SplToken, bz as TokenInfo, bA as TokenJson } from '../../type-9fe71e3c.js';
1
+ export { bC as LpToken, bB as SplToken, bz as TokenInfo, bA as TokenJson } from '../../type-bdbaf9b2.js';
2
2
  import '../../module/token.js';
3
3
  import '@solana/web3.js';
4
4
  import 'bn.js';
@@ -1,6 +1,6 @@
1
1
  import { Connection, PublicKey } from '@solana/web3.js';
2
2
  import { RawMint } from '@solana/spl-token';
3
- import { bz as TokenInfo, a9 as BigNumberish, c1 as TokenAmount, e as ApiV3Token } from '../../type-9fe71e3c.js';
3
+ import { bz as TokenInfo, a9 as BigNumberish, c1 as TokenAmount, e as ApiV3Token } from '../../type-bdbaf9b2.js';
4
4
  import { Token } from '../../module/token.js';
5
5
  import 'bn.js';
6
6
  import '../../solana/type.js';
@@ -2,7 +2,7 @@ export { makeSwapInstruction, route1Instruction, route2Instruction, routeInstruc
2
2
  export { ComputeAmountOutAmmLayout, ComputeAmountOutLayout, ComputeAmountOutRouteLayout, MakeSwapInstructionParam, PoolAccountInfoV4, ReturnTypeFetchMultipleInfo, ReturnTypeGetAddLiquidityDefaultPool, ReturnTypeGetAllRoute, ReturnTypeMakeSwapInstruction, ReturnTypeMakeSwapTransaction, RoutePathType } from './type.js';
3
3
  import '@solana/web3.js';
4
4
  import 'bn.js';
5
- import '../../type-9fe71e3c.js';
5
+ import '../../type-bdbaf9b2.js';
6
6
  import '@solana/spl-token';
7
7
  import '../../solana/type.js';
8
8
  import '../../common/txTool/txType.js';
@@ -15,5 +15,5 @@ import '../../marshmallow/index.js';
15
15
  import '../../marshmallow/buffer-layout.js';
16
16
  import '../../common/logger.js';
17
17
  import '../../module/currency.js';
18
- import '../../type-389634c9.js';
18
+ import '../../type-68b778f2.js';
19
19
  import '../clmm/layout.js';
@@ -1,6 +1,6 @@
1
1
  import { PublicKey, TransactionInstruction } from '@solana/web3.js';
2
2
  import BN__default from 'bn.js';
3
- import { n as ApiV3PoolInfoItem, w as PoolKeys } from '../../type-9fe71e3c.js';
3
+ import { n as ApiV3PoolInfoItem, w as PoolKeys } from '../../type-bdbaf9b2.js';
4
4
  import { ReturnTypeMakeSwapInstruction, ComputeAmountOutLayout } from './type.js';
5
5
  import '@solana/spl-token';
6
6
  import '../../solana/type.js';
@@ -14,7 +14,7 @@ import '../../marshmallow/index.js';
14
14
  import '../../marshmallow/buffer-layout.js';
15
15
  import '../../common/logger.js';
16
16
  import '../../module/currency.js';
17
- import '../../type-389634c9.js';
17
+ import '../../type-68b778f2.js';
18
18
  import '../clmm/layout.js';
19
19
 
20
20
  declare function route1Instruction(programId: PublicKey, poolInfoA: ApiV3PoolInfoItem, poolKeyA: PoolKeys, poolKeyB: PoolKeys, userSourceToken: PublicKey, userRouteToken: PublicKey, userPdaAccount: PublicKey, ownerWallet: PublicKey, inputMint: PublicKey, amountIn: BN__default, amountOut: BN__default, tickArrayA?: PublicKey[]): TransactionInstruction;
@@ -1,7 +1,7 @@
1
1
  import '@solana/web3.js';
2
- export { i as default } from '../../raydium-e681ad95.js';
2
+ export { i as default } from '../../raydium-6c4df6ad.js';
3
3
  import './type.js';
4
- import '../../type-9fe71e3c.js';
4
+ import '../../type-bdbaf9b2.js';
5
5
  import '../../api/api.js';
6
6
  import 'axios';
7
7
  import '../../solana/type.js';
@@ -22,7 +22,7 @@ import '../account/types.js';
22
22
  import '../account/layout.js';
23
23
  import '../liquidity/type.js';
24
24
  import '../liquidity/layout.js';
25
- import '../../type-389634c9.js';
25
+ import '../../type-68b778f2.js';
26
26
  import '../clmm/layout.js';
27
27
  import '../cpmm/type.js';
28
28
  import '../cpmm/curve/calculator.js';
@@ -1,8 +1,8 @@
1
1
  import { PublicKey, Keypair, Signer, TransactionInstruction, Transaction } from '@solana/web3.js';
2
2
  import BN__default from 'bn.js';
3
- import { bK as TransferAmountFee, c6 as Price, c5 as Percent, c1 as TokenAmount, n as ApiV3PoolInfoItem, w as PoolKeys } from '../../type-9fe71e3c.js';
3
+ import { bK as TransferAmountFee, c6 as Price, c5 as Percent, c1 as TokenAmount, n as ApiV3PoolInfoItem, w as PoolKeys } from '../../type-bdbaf9b2.js';
4
4
  import { Token } from '../../module/token.js';
5
- import { c as ClmmPoolInfo } from '../../type-389634c9.js';
5
+ import { c as ClmmPoolInfo } from '../../type-68b778f2.js';
6
6
  import '@solana/spl-token';
7
7
  import '../../solana/type.js';
8
8
  import '../../common/txTool/txType.js';
@@ -1,6 +1,6 @@
1
1
  import '@solana/web3.js';
2
2
  import '@solana/spl-token';
3
- export { bS as ArrayItem, bI as ComputeBudgetConfig, bZ as Cover, bT as ExactPartial, bU as ExactRequired, bY as Fallback, bL as GetTransferAmountFee, bW as GetValue, bH as InstructionReturn, bJ as LoadParams, bG as MakeMultiTransaction, bE as MakeTransaction, bF as MakeV0Transaction, bP as MayArray, bQ as MayDeepArray, bR as MayFunction, bO as ReplaceType, bM as ReturnTypeFetchMultipleMintInfo, bN as ReturnTypeFetchMultipleMintInfos, bV as SKeyof, bX as SOR, bD as SignAllTransactions, bK as TransferAmountFee, b_ as UnionCover, b$ as unionArr } from '../type-9fe71e3c.js';
3
+ export { bS as ArrayItem, bI as ComputeBudgetConfig, bZ as Cover, bT as ExactPartial, bU as ExactRequired, bY as Fallback, bL as GetTransferAmountFee, bW as GetValue, bH as InstructionReturn, bJ as LoadParams, bG as MakeMultiTransaction, bE as MakeTransaction, bF as MakeV0Transaction, bP as MayArray, bQ as MayDeepArray, bR as MayFunction, bO as ReplaceType, bM as ReturnTypeFetchMultipleMintInfo, bN as ReturnTypeFetchMultipleMintInfos, bV as SKeyof, bX as SOR, bD as SignAllTransactions, bK as TransferAmountFee, b_ as UnionCover, b$ as unionArr } from '../type-bdbaf9b2.js';
4
4
  import 'bn.js';
5
5
  import '../solana/type.js';
6
6
  import '../common/txTool/txType.js';
@@ -1,9 +1,9 @@
1
- export { S as SHOW_INFO, d as canClaimErrorType, U as default } from '../../raydium-e681ad95.js';
1
+ export { S as SHOW_INFO, d as canClaimErrorType, U as default } from '../../raydium-6c4df6ad.js';
2
2
  import '@solana/web3.js';
3
3
  import '../../api/api.js';
4
4
  import 'axios';
5
5
  import '../../solana/type.js';
6
- import '../../type-9fe71e3c.js';
6
+ import '../../type-bdbaf9b2.js';
7
7
  import 'bn.js';
8
8
  import '@solana/spl-token';
9
9
  import '../../common/txTool/txType.js';
@@ -21,7 +21,7 @@ import '../account/types.js';
21
21
  import '../account/layout.js';
22
22
  import '../liquidity/type.js';
23
23
  import '../liquidity/layout.js';
24
- import '../../type-389634c9.js';
24
+ import '../../type-68b778f2.js';
25
25
  import '../clmm/layout.js';
26
26
  import '../cpmm/type.js';
27
27
  import '../cpmm/curve/calculator.js';
@@ -1,12 +1,12 @@
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-e681ad95.js';
4
+ export { S as SHOW_INFO, d as canClaimErrorType, U as default } from '../../raydium-6c4df6ad.js';
5
5
  import '../../marshmallow/buffer-layout.js';
6
6
  import '../../api/api.js';
7
7
  import 'axios';
8
8
  import '../../solana/type.js';
9
- import '../../type-9fe71e3c.js';
9
+ import '../../type-bdbaf9b2.js';
10
10
  import '@solana/spl-token';
11
11
  import '../../common/txTool/txType.js';
12
12
  import '../../common/owner.js';
@@ -21,7 +21,7 @@ import '../account/types.js';
21
21
  import '../account/layout.js';
22
22
  import '../liquidity/type.js';
23
23
  import '../liquidity/layout.js';
24
- import '../../type-389634c9.js';
24
+ import '../../type-68b778f2.js';
25
25
  import '../clmm/layout.js';
26
26
  import '../cpmm/type.js';
27
27
  import '../cpmm/curve/calculator.js';
@@ -1,6 +1,6 @@
1
1
  import { PublicKey, Commitment, Connection, Transaction, Signer, TransactionInstruction, Keypair, EpochInfo } from '@solana/web3.js';
2
2
  import { Api } from './api/api.js';
3
- import { ax as TxBuilder, ap as AddInstructionParam, a9 as BigNumberish, bk as CreateFarm, aw as MakeTxData, bl as CreateFarmExtInfo, bm as UpdateFarmReward, bn as UpdateFarmRewards, bo as FarmDWParam, U as FormatFarmInfoOut, bI as ComputeBudgetConfig, av as MakeMultiTxData, l as ApiV3PoolInfoStandardItem, c5 as Percent, c1 as TokenAmount, s as AmmV4Keys, t as AmmV5Keys, k as ApiV3PoolInfoConcentratedItem, S as FormatFarmInfoOutV6, v as ClmmKeys, bE as MakeTransaction, C as CpmmKeys, bL as GetTransferAmountFee, X as OwnerIdoInfo, Y as IdoKeysData, bJ as LoadParams, J as JupTokenType, bz as TokenInfo, e as ApiV3Token, bD as SignAllTransactions, V as AvailabilityCheckAPI3, f as ApiV3TokenRes } from './type-9fe71e3c.js';
3
+ import { ax as TxBuilder, ap as AddInstructionParam, a9 as BigNumberish, bk as CreateFarm, aw as MakeTxData, bl as CreateFarmExtInfo, bm as UpdateFarmReward, bn as UpdateFarmRewards, bo as FarmDWParam, U as FormatFarmInfoOut, bI as ComputeBudgetConfig, av as MakeMultiTxData, l as ApiV3PoolInfoStandardItem, c5 as Percent, c1 as TokenAmount, s as AmmV4Keys, t as AmmV5Keys, k as ApiV3PoolInfoConcentratedItem, S as FormatFarmInfoOutV6, v as ClmmKeys, bE as MakeTransaction, C as CpmmKeys, bL as GetTransferAmountFee, X as OwnerIdoInfo, Y as IdoKeysData, bJ as LoadParams, J as JupTokenType, bz as TokenInfo, e as ApiV3Token, bD as SignAllTransactions, V as AvailabilityCheckAPI3, f as ApiV3TokenRes } from './type-bdbaf9b2.js';
4
4
  import { API_URL_CONFIG } from './api/url.js';
5
5
  import { Owner } from './common/owner.js';
6
6
  import { Cluster } from './solana/type.js';
@@ -11,7 +11,7 @@ import BN__default from 'bn.js';
11
11
  import Decimal from 'decimal.js';
12
12
  import { AddLiquidityParams, RemoveParams, CreatePoolParam, CreatePoolAddress, ComputeAmountOutParam, SwapParam } from './raydium/liquidity/type.js';
13
13
  import { liquidityStateV4Layout } from './raydium/liquidity/layout.js';
14
- import { m as CreateConcentratedPool, O as OpenPositionFromBase, p as OpenPositionFromBaseExtInfo, q as OpenPositionFromLiquidity, r as OpenPositionFromLiquidityExtInfo, I as IncreasePositionFromLiquidity, M as ManipulateLiquidityExtInfo, n as IncreasePositionFromBase, D as DecreaseLiquidity, B as ClosePositionExtInfo, s as InitRewardParams, E as InitRewardExtInfo, t as InitRewardsParams, u as SetRewardParams, v as SetRewardsParams, w as CollectRewardParams, x as CollectRewardsParams, H as HarvestAllRewardsParams } from './type-389634c9.js';
14
+ import { m as CreateConcentratedPool, O as OpenPositionFromBase, p as OpenPositionFromBaseExtInfo, q as OpenPositionFromLiquidity, r as OpenPositionFromLiquidityExtInfo, I as IncreasePositionFromLiquidity, M as ManipulateLiquidityExtInfo, n as IncreasePositionFromBase, D as DecreaseLiquidity, B as ClosePositionExtInfo, s as InitRewardParams, E as InitRewardExtInfo, t as InitRewardsParams, u as SetRewardParams, v as SetRewardsParams, w as CollectRewardParams, x as CollectRewardsParams, H as HarvestAllRewardsParams } from './type-68b778f2.js';
15
15
  import { ClmmPositionLayout, PositionInfoLayout, PoolInfoLayout } from './raydium/clmm/layout.js';
16
16
  import { CpmmConfigInfoInterface, CreateCpmmPoolParam, CreateCpmmPoolAddress, AddCpmmLiquidityParams, WithdrawCpmmLiquidityParams, CpmmSwapParams, ComputePairAmountParams } from './raydium/cpmm/type.js';
17
17
  import { CpmmPoolInfoLayout } from './raydium/cpmm/layout.js';
@@ -273,7 +273,7 @@ declare class CpmmModule extends ModuleBase {
273
273
  addLiquidity<T extends TxVersion>(params: AddCpmmLiquidityParams<T>): Promise<MakeTxData<T>>;
274
274
  withdrawLiquidity<T extends TxVersion>(params: WithdrawCpmmLiquidityParams<T>): Promise<MakeTxData<T>>;
275
275
  swap<T extends TxVersion>(params: CpmmSwapParams): Promise<MakeTxData<T>>;
276
- computePairAmount({ poolInfo, amount, slippage, epochInfo, baseIn }: ComputePairAmountParams): {
276
+ computePairAmount({ poolInfo, baseReserve, quoteReserve, amount, slippage, epochInfo, baseIn, }: ComputePairAmountParams): {
277
277
  inputAmountFee: GetTransferAmountFee;
278
278
  anotherAmount: GetTransferAmountFee;
279
279
  maxAnotherAmount: GetTransferAmountFee;
@@ -348,8 +348,8 @@ declare class Utils1216 extends ModuleBase {
348
348
  debtAmount: BN__default;
349
349
  claimedAmount: BN__default;
350
350
  }[], "", {
351
- padding: BN__default[];
352
351
  owner: PublicKey;
352
+ padding: BN__default[];
353
353
  version: number;
354
354
  bump: number;
355
355
  poolId: PublicKey;
@@ -1,7 +1,7 @@
1
1
  import { PublicKey, Transaction, Signer, Keypair, TransactionInstruction, EpochInfo } from '@solana/web3.js';
2
2
  import BN__default from 'bn.js';
3
3
  import Decimal from 'decimal.js';
4
- import { k as ApiV3PoolInfoConcentratedItem, b as ApiClmmConfigInfo, e as ApiV3Token, bL as GetTransferAmountFee, bK as TransferAmountFee, c6 as Price, c5 as Percent, c1 as TokenAmount, bI as ComputeBudgetConfig, c3 as Fraction, bz as TokenInfo, v as ClmmKeys } from './type-9fe71e3c.js';
4
+ import { k as ApiV3PoolInfoConcentratedItem, b as ApiClmmConfigInfo, e as ApiV3Token, bL as GetTransferAmountFee, bK as TransferAmountFee, c6 as Price, c5 as Percent, c1 as TokenAmount, bI as ComputeBudgetConfig, c3 as Fraction, bz as TokenInfo, v as ClmmKeys } from './type-bdbaf9b2.js';
5
5
  import { TxVersion } from './common/txTool/txType.js';
6
6
  import { ClmmPositionLayout } from './raydium/clmm/layout.js';
7
7
 
@@ -850,38 +850,38 @@ declare type FarmStateV6 = GetStructureSchema<FarmStateLayoutV6>;
850
850
  declare type FarmState = FarmStateV3 | FarmStateV5 | FarmStateV6;
851
851
  declare type FarmStateLayout = FarmStateLayoutV3 | FarmStateLayoutV5 | FarmStateLayoutV6;
852
852
  declare const farmLedgerLayoutV3_1: Structure<PublicKey | BN__default | BN__default[], "", {
853
+ owner: PublicKey;
853
854
  state: BN__default;
854
855
  id: PublicKey;
855
- owner: PublicKey;
856
856
  deposited: BN__default;
857
857
  rewardDebts: BN__default[];
858
858
  }>;
859
859
  declare const farmLedgerLayoutV3_2: Structure<PublicKey | BN__default | BN__default[], "", {
860
+ owner: PublicKey;
860
861
  state: BN__default;
861
862
  id: PublicKey;
862
- owner: PublicKey;
863
863
  deposited: BN__default;
864
864
  rewardDebts: BN__default[];
865
865
  voteLockedBalance: BN__default;
866
866
  }>;
867
867
  declare const farmLedgerLayoutV5_1: Structure<PublicKey | BN__default | BN__default[], "", {
868
+ owner: PublicKey;
868
869
  state: BN__default;
869
870
  id: PublicKey;
870
- owner: PublicKey;
871
871
  deposited: BN__default;
872
872
  rewardDebts: BN__default[];
873
873
  }>;
874
874
  declare const farmLedgerLayoutV5_2: Structure<PublicKey | BN__default | BN__default[], "", {
875
+ owner: PublicKey;
875
876
  state: BN__default;
876
877
  id: PublicKey;
877
- owner: PublicKey;
878
878
  deposited: BN__default;
879
879
  rewardDebts: BN__default[];
880
880
  }>;
881
881
  declare const farmLedgerLayoutV6_1: Structure<PublicKey | BN__default | BN__default[], "", {
882
+ owner: PublicKey;
882
883
  state: BN__default;
883
884
  id: PublicKey;
884
- owner: PublicKey;
885
885
  deposited: BN__default;
886
886
  rewardDebts: BN__default[];
887
887
  }>;
@@ -911,7 +911,7 @@ declare const VoterVotingMintConfig: Structure<PublicKey | number[] | BN__defaul
911
911
  reserved1: number[];
912
912
  reserved2: BN__default[];
913
913
  }>;
914
- declare const VoterRegistrar: Structure<number | PublicKey | number[] | Buffer | BN__default | BN__default[] | {
914
+ declare const VoterRegistrar: Structure<number | PublicKey | Buffer | number[] | BN__default | BN__default[] | {
915
915
  mint: PublicKey;
916
916
  grantAuthority: PublicKey;
917
917
  baselineVoteWeightScaledFactor: BN__default;
@@ -966,7 +966,7 @@ declare const VoterDepositEntry: Structure<number | boolean | number[] | BN__def
966
966
  allowClawback: boolean;
967
967
  votingMintConfigIdx: number;
968
968
  }>;
969
- declare const Voter: Structure<number | PublicKey | number[] | Buffer | {
969
+ declare const Voter: Structure<number | PublicKey | Buffer | number[] | {
970
970
  reserved: number[];
971
971
  lockup: {
972
972
  startTime: BN__default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raydium-io/raydium-sdk-v2",
3
- "version": "0.1.5-alpha",
3
+ "version": "0.1.7-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",
@@ -263,7 +263,8 @@ export default class CpmmModule extends ModuleBase {
263
263
  // custom
264
264
  ...config,
265
265
  };
266
- const rpcPoolData = await this.getRpcPoolInfo(poolInfo.id);
266
+ const rpcPoolData = computeResult ? undefined : await this.getRpcPoolInfo(poolInfo.id);
267
+
267
268
  const {
268
269
  liquidity,
269
270
  inputAmountFee,
@@ -272,10 +273,10 @@ export default class CpmmModule extends ModuleBase {
272
273
  this.computePairAmount({
273
274
  poolInfo: {
274
275
  ...poolInfo,
275
- mintAmountA: new Decimal(rpcPoolData.baseReserve.toString()).div(10 ** poolInfo.mintA.decimals).toNumber(),
276
- mintAmountB: new Decimal(rpcPoolData.quoteReserve.toString()).div(10 ** poolInfo.mintB.decimals).toNumber(),
277
- lpAmount: new Decimal(rpcPoolData.lpAmount.toString()).div(10 ** poolInfo.lpMint.decimals).toNumber(),
276
+ lpAmount: new Decimal(rpcPoolData!.lpAmount.toString()).div(10 ** poolInfo.lpMint.decimals).toNumber(),
278
277
  },
278
+ baseReserve: rpcPoolData!.baseReserve,
279
+ quoteReserve: rpcPoolData!.quoteReserve,
279
280
  slippage: new Percent(0),
280
281
  baseIn,
281
282
  epochInfo: await this.scope.fetchEpochInfo(),
@@ -480,7 +481,7 @@ export default class CpmmModule extends ModuleBase {
480
481
  }
481
482
 
482
483
  public async swap<T extends TxVersion>(params: CpmmSwapParams): Promise<MakeTxData<T>> {
483
- const { poolInfo, baseIn, swapResult, config, computeBudgetConfig, txVersion } = params;
484
+ const { poolInfo, baseIn, swapResult, slippage = 0, config, computeBudgetConfig, txVersion } = params;
484
485
 
485
486
  const { bypassAssociatedCheck, checkCreateATAOwner } = {
486
487
  // default
@@ -505,9 +506,14 @@ export default class CpmmModule extends ModuleBase {
505
506
  associatedOnly: false,
506
507
  });
507
508
 
509
+ swapResult.destinationAmountSwapped = swapResult.destinationAmountSwapped
510
+ .mul(new BN((1 - slippage) * 10000))
511
+ .div(new BN(10000));
512
+
508
513
  const { tokenAccount: _mintATokenAcc, ...mintATokenAccInstruction } = await this.scope.account.handleTokenAccount({
509
514
  side: baseIn ? "in" : "out",
510
515
  amount: baseIn ? swapResult.sourceAmountSwapped : swapResult.destinationAmountSwapped,
516
+ programId: new PublicKey(poolInfo.mintA.programId),
511
517
  mint: mintA,
512
518
  tokenAccount: mintATokenAcc,
513
519
  bypassAssociatedCheck,
@@ -518,6 +524,7 @@ export default class CpmmModule extends ModuleBase {
518
524
  const { tokenAccount: _mintBTokenAcc, ...mintBTokenAccInstruction } = await this.scope.account.handleTokenAccount({
519
525
  side: baseIn ? "out" : "in",
520
526
  amount: baseIn ? swapResult.destinationAmountSwapped : swapResult.sourceAmountSwapped,
527
+ programId: new PublicKey(poolInfo.mintB.programId),
521
528
  mint: mintB,
522
529
  tokenAccount: mintBTokenAcc,
523
530
  bypassAssociatedCheck,
@@ -585,7 +592,15 @@ export default class CpmmModule extends ModuleBase {
585
592
  return txBuilder.versionBuild({ txVersion }) as Promise<MakeTxData<T>>;
586
593
  }
587
594
 
588
- public computePairAmount({ poolInfo, amount, slippage, epochInfo, baseIn }: ComputePairAmountParams): {
595
+ public computePairAmount({
596
+ poolInfo,
597
+ baseReserve,
598
+ quoteReserve,
599
+ amount,
600
+ slippage,
601
+ epochInfo,
602
+ baseIn,
603
+ }: ComputePairAmountParams): {
589
604
  inputAmountFee: GetTransferAmountFee;
590
605
  anotherAmount: GetTransferAmountFee;
591
606
  maxAnotherAmount: GetTransferAmountFee;
@@ -606,11 +621,6 @@ export default class CpmmModule extends ModuleBase {
606
621
  );
607
622
  const _inputAmountWithoutFee = inputAmount.sub(inputAmountFee.fee ?? new BN(0));
608
623
 
609
- const [baseReserve, quoteReserve] = [
610
- new BN(new Decimal(poolInfo.mintAmountA).mul(10 ** poolInfo.mintA.decimals).toString()),
611
- new BN(new Decimal(poolInfo.mintAmountB).mul(10 ** poolInfo.mintB.decimals).toString()),
612
- ];
613
-
614
624
  const lpAmount = new BN(
615
625
  new Decimal(poolInfo.lpAmount).mul(10 ** poolInfo.lpMint.decimals).toFixed(0, Decimal.ROUND_DOWN),
616
626
  );
@@ -640,8 +650,13 @@ export default class CpmmModule extends ModuleBase {
640
650
  expirationTime: undefined,
641
651
  };
642
652
  if (!_inputAmountWithoutFee.isZero()) {
653
+ const lpAmountData = lpToAmount(liquidity, baseReserve, quoteReserve, lpAmount);
654
+ this.logDebug("lpAmountData:", {
655
+ amountA: lpAmountData.amountA.toString(),
656
+ amountB: lpAmountData.amountB.toString(),
657
+ });
643
658
  anotherAmountFee = getTransferAmountFeeV2(
644
- lpToAmount(liquidity, baseReserve, quoteReserve, lpAmount)[baseIn ? "amountB" : "amountA"],
659
+ lpAmountData[baseIn ? "amountB" : "amountA"],
645
660
  poolInfo[baseIn ? "mintB" : "mintA"].extensions.feeConfig,
646
661
  epochInfo,
647
662
  true,
@@ -681,6 +696,7 @@ function lpToAmount(lp: BN, poolAmountA: BN, poolAmountB: BN, supply: BN): { amo
681
696
  if (!amountA.isZero() && !lp.mul(poolAmountA).mod(supply).isZero()) amountA = amountA.add(new BN(1));
682
697
  let amountB = lp.mul(poolAmountB).div(supply);
683
698
  if (!amountB.isZero() && !lp.mul(poolAmountB).mod(supply).isZero()) amountB = amountB.add(new BN(1));
699
+
684
700
  return {
685
701
  amountA,
686
702
  amountB,
@@ -117,6 +117,7 @@ export interface CpmmSwapParams<T = TxVersion.LEGACY> {
117
117
  poolInfo: ApiV3PoolInfoStandardItemCpmm;
118
118
  payer?: PublicKey;
119
119
  baseIn: boolean;
120
+ slippage?: number;
120
121
  swapResult: SwapResult;
121
122
 
122
123
  config?: {
@@ -129,6 +130,8 @@ export interface CpmmSwapParams<T = TxVersion.LEGACY> {
129
130
 
130
131
  export interface ComputePairAmountParams {
131
132
  poolInfo: ApiV3PoolInfoStandardItemCpmm;
133
+ baseReserve: BN;
134
+ quoteReserve: BN;
132
135
  amount: string | Decimal;
133
136
  slippage: Percent;
134
137
  epochInfo: EpochInfo;