@raydium-io/raydium-sdk-v2 0.1.5-alpha → 0.1.6-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.
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +1 -1
- package/lib/index.mjs.map +1 -1
- package/lib/raydium/account/account.d.ts +1 -1
- package/lib/raydium/clmm/clmm.d.ts +1 -1
- package/lib/raydium/clmm/index.d.ts +1 -1
- package/lib/raydium/cpmm/cpmm.d.ts +1 -1
- package/lib/raydium/cpmm/cpmm.js +1 -1
- package/lib/raydium/cpmm/cpmm.js.map +1 -1
- package/lib/raydium/cpmm/cpmm.mjs +1 -1
- package/lib/raydium/cpmm/cpmm.mjs.map +1 -1
- package/lib/raydium/cpmm/type.d.ts +2 -0
- package/lib/raydium/cpmm/type.js +1 -1
- package/lib/raydium/cpmm/type.js.map +1 -1
- package/lib/raydium/farm/farm.d.ts +1 -1
- package/lib/raydium/ido/ido.d.ts +1 -1
- package/lib/raydium/ido/index.d.ts +1 -1
- package/lib/raydium/index.d.ts +1 -1
- package/lib/raydium/index.js +1 -1
- package/lib/raydium/index.js.map +1 -1
- package/lib/raydium/index.mjs +1 -1
- package/lib/raydium/index.mjs.map +1 -1
- package/lib/raydium/liquidity/liquidity.d.ts +1 -1
- package/lib/raydium/marketV2/createMarket.d.ts +1 -1
- package/lib/raydium/marketV2/index.d.ts +1 -1
- package/lib/raydium/moduleBase.d.ts +1 -1
- package/lib/raydium/raydium.d.ts +1 -1
- package/lib/raydium/raydium.js +1 -1
- package/lib/raydium/raydium.js.map +1 -1
- package/lib/raydium/raydium.mjs +1 -1
- package/lib/raydium/raydium.mjs.map +1 -1
- package/lib/raydium/token/token.d.ts +1 -1
- package/lib/raydium/tradeV2/trade.d.ts +1 -1
- package/lib/raydium/utils1216/index.d.ts +1 -1
- package/lib/raydium/utils1216/utils1216.d.ts +1 -1
- package/lib/{raydium-e681ad95.d.ts → raydium-4f9e818a.d.ts} +1 -1
- package/package.json +1 -1
- package/src/raydium/cpmm/cpmm.ts +21 -11
- package/src/raydium/cpmm/type.ts +2 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { S as SHOW_INFO, d as canClaimErrorType, U as default } from '../../raydium-
|
|
1
|
+
export { S as SHOW_INFO, d as canClaimErrorType, U as default } from '../../raydium-4f9e818a.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-
|
|
4
|
+
export { S as SHOW_INFO, d as canClaimErrorType, U as default } from '../../raydium-4f9e818a.js';
|
|
5
5
|
import '../../marshmallow/buffer-layout.js';
|
|
6
6
|
import '../../api/api.js';
|
|
7
7
|
import 'axios';
|
|
@@ -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;
|
package/package.json
CHANGED
package/src/raydium/cpmm/cpmm.ts
CHANGED
|
@@ -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
|
-
|
|
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(),
|
|
@@ -585,7 +586,15 @@ export default class CpmmModule extends ModuleBase {
|
|
|
585
586
|
return txBuilder.versionBuild({ txVersion }) as Promise<MakeTxData<T>>;
|
|
586
587
|
}
|
|
587
588
|
|
|
588
|
-
public computePairAmount({
|
|
589
|
+
public computePairAmount({
|
|
590
|
+
poolInfo,
|
|
591
|
+
baseReserve,
|
|
592
|
+
quoteReserve,
|
|
593
|
+
amount,
|
|
594
|
+
slippage,
|
|
595
|
+
epochInfo,
|
|
596
|
+
baseIn,
|
|
597
|
+
}: ComputePairAmountParams): {
|
|
589
598
|
inputAmountFee: GetTransferAmountFee;
|
|
590
599
|
anotherAmount: GetTransferAmountFee;
|
|
591
600
|
maxAnotherAmount: GetTransferAmountFee;
|
|
@@ -606,11 +615,6 @@ export default class CpmmModule extends ModuleBase {
|
|
|
606
615
|
);
|
|
607
616
|
const _inputAmountWithoutFee = inputAmount.sub(inputAmountFee.fee ?? new BN(0));
|
|
608
617
|
|
|
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
618
|
const lpAmount = new BN(
|
|
615
619
|
new Decimal(poolInfo.lpAmount).mul(10 ** poolInfo.lpMint.decimals).toFixed(0, Decimal.ROUND_DOWN),
|
|
616
620
|
);
|
|
@@ -640,8 +644,13 @@ export default class CpmmModule extends ModuleBase {
|
|
|
640
644
|
expirationTime: undefined,
|
|
641
645
|
};
|
|
642
646
|
if (!_inputAmountWithoutFee.isZero()) {
|
|
647
|
+
const lpAmountData = lpToAmount(liquidity, baseReserve, quoteReserve, lpAmount);
|
|
648
|
+
this.logDebug("lpAmountData:", {
|
|
649
|
+
amountA: lpAmountData.amountA.toString(),
|
|
650
|
+
amountB: lpAmountData.amountB.toString(),
|
|
651
|
+
});
|
|
643
652
|
anotherAmountFee = getTransferAmountFeeV2(
|
|
644
|
-
|
|
653
|
+
lpAmountData[baseIn ? "amountB" : "amountA"],
|
|
645
654
|
poolInfo[baseIn ? "mintB" : "mintA"].extensions.feeConfig,
|
|
646
655
|
epochInfo,
|
|
647
656
|
true,
|
|
@@ -681,6 +690,7 @@ function lpToAmount(lp: BN, poolAmountA: BN, poolAmountB: BN, supply: BN): { amo
|
|
|
681
690
|
if (!amountA.isZero() && !lp.mul(poolAmountA).mod(supply).isZero()) amountA = amountA.add(new BN(1));
|
|
682
691
|
let amountB = lp.mul(poolAmountB).div(supply);
|
|
683
692
|
if (!amountB.isZero() && !lp.mul(poolAmountB).mod(supply).isZero()) amountB = amountB.add(new BN(1));
|
|
693
|
+
|
|
684
694
|
return {
|
|
685
695
|
amountA,
|
|
686
696
|
amountB,
|
package/src/raydium/cpmm/type.ts
CHANGED
|
@@ -129,6 +129,8 @@ export interface CpmmSwapParams<T = TxVersion.LEGACY> {
|
|
|
129
129
|
|
|
130
130
|
export interface ComputePairAmountParams {
|
|
131
131
|
poolInfo: ApiV3PoolInfoStandardItemCpmm;
|
|
132
|
+
baseReserve: BN;
|
|
133
|
+
quoteReserve: BN;
|
|
132
134
|
amount: string | Decimal;
|
|
133
135
|
slippage: Percent;
|
|
134
136
|
epochInfo: EpochInfo;
|