@magmaprotocol/magma-clmm-sdk 0.5.117 → 0.5.119
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/dist/index.d.ts +4 -0
- package/dist/index.js +67 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +67 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -4320,6 +4320,10 @@ declare class TransactionUtil {
|
|
|
4320
4320
|
*/
|
|
4321
4321
|
static fixAddLiquidityFixTokenParams(params: AddLiquidityFixTokenParams, slippage: number, curSqrtPrice: BN): AddLiquidityFixTokenParams;
|
|
4322
4322
|
private static buildAddLiquidityFixTokenArgs;
|
|
4323
|
+
static buildAddLiquidityWithProtectionFixTokenForGas(sdk: MagmaClmmSDK, allCoins: CoinAsset[], params: AddLiquidityFixTokenParams, gasEstimateArg: {
|
|
4324
|
+
slippage: number;
|
|
4325
|
+
curSqrtPrice: BN;
|
|
4326
|
+
}, tx?: Transaction, inputCoinA?: TransactionObjectArgument, inputCoinB?: TransactionObjectArgument): Promise<Transaction>;
|
|
4323
4327
|
private static buildAddLiquidityWithProtectionFixTokenArgs;
|
|
4324
4328
|
/**
|
|
4325
4329
|
* build add liquidity transaction
|
package/dist/index.js
CHANGED
|
@@ -3584,6 +3584,72 @@ var _TransactionUtil = class {
|
|
|
3584
3584
|
});
|
|
3585
3585
|
return tx;
|
|
3586
3586
|
}
|
|
3587
|
+
static async buildAddLiquidityWithProtectionFixTokenForGas(sdk, allCoins, params, gasEstimateArg, tx, inputCoinA, inputCoinB) {
|
|
3588
|
+
tx = await _TransactionUtil.buildAddLiquidityWithProtectionFixToken(sdk, allCoins, params, tx, inputCoinA, inputCoinB);
|
|
3589
|
+
const { isAdjustCoinA } = findAdjustCoin(params);
|
|
3590
|
+
const suiAmount = isAdjustCoinA ? params.amount_a : params.amount_b;
|
|
3591
|
+
const newResult = await _TransactionUtil.adjustTransactionForGas(
|
|
3592
|
+
sdk,
|
|
3593
|
+
CoinAssist.getCoinAssets(isAdjustCoinA ? params.coinTypeA : params.coinTypeB, allCoins),
|
|
3594
|
+
BigInt(suiAmount),
|
|
3595
|
+
tx
|
|
3596
|
+
);
|
|
3597
|
+
const { fixAmount } = newResult;
|
|
3598
|
+
const { newTx } = newResult;
|
|
3599
|
+
if (newTx != null) {
|
|
3600
|
+
let primaryCoinAInputs;
|
|
3601
|
+
let primaryCoinBInputs;
|
|
3602
|
+
if (isAdjustCoinA) {
|
|
3603
|
+
params.amount_a = Number(fixAmount);
|
|
3604
|
+
primaryCoinAInputs = _TransactionUtil.buildAddLiquidityFixTokenCoinInput(
|
|
3605
|
+
newTx,
|
|
3606
|
+
!params.fix_amount_a,
|
|
3607
|
+
fixAmount.toString(),
|
|
3608
|
+
params.slippage,
|
|
3609
|
+
params.coinTypeA,
|
|
3610
|
+
allCoins,
|
|
3611
|
+
false,
|
|
3612
|
+
true
|
|
3613
|
+
);
|
|
3614
|
+
primaryCoinBInputs = _TransactionUtil.buildAddLiquidityFixTokenCoinInput(
|
|
3615
|
+
newTx,
|
|
3616
|
+
params.fix_amount_a,
|
|
3617
|
+
params.amount_b,
|
|
3618
|
+
params.slippage,
|
|
3619
|
+
params.coinTypeB,
|
|
3620
|
+
allCoins,
|
|
3621
|
+
false,
|
|
3622
|
+
true
|
|
3623
|
+
);
|
|
3624
|
+
} else {
|
|
3625
|
+
params.amount_b = Number(fixAmount);
|
|
3626
|
+
primaryCoinAInputs = _TransactionUtil.buildAddLiquidityFixTokenCoinInput(
|
|
3627
|
+
newTx,
|
|
3628
|
+
!params.fix_amount_a,
|
|
3629
|
+
params.amount_a,
|
|
3630
|
+
params.slippage,
|
|
3631
|
+
params.coinTypeA,
|
|
3632
|
+
allCoins,
|
|
3633
|
+
false,
|
|
3634
|
+
true
|
|
3635
|
+
);
|
|
3636
|
+
primaryCoinBInputs = _TransactionUtil.buildAddLiquidityFixTokenCoinInput(
|
|
3637
|
+
newTx,
|
|
3638
|
+
params.fix_amount_a,
|
|
3639
|
+
fixAmount.toString(),
|
|
3640
|
+
params.slippage,
|
|
3641
|
+
params.coinTypeB,
|
|
3642
|
+
allCoins,
|
|
3643
|
+
false,
|
|
3644
|
+
true
|
|
3645
|
+
);
|
|
3646
|
+
params = _TransactionUtil.fixAddLiquidityFixTokenParams(params, gasEstimateArg.slippage, gasEstimateArg.curSqrtPrice);
|
|
3647
|
+
tx = _TransactionUtil.buildAddLiquidityWithProtectionFixTokenArgs(newTx, sdk, allCoins, params, primaryCoinAInputs, primaryCoinBInputs);
|
|
3648
|
+
return tx;
|
|
3649
|
+
}
|
|
3650
|
+
}
|
|
3651
|
+
return tx;
|
|
3652
|
+
}
|
|
3587
3653
|
static buildAddLiquidityWithProtectionFixTokenArgs(tx, sdk, allCoinAsset, params, primaryCoinAInputs, primaryCoinBInputs) {
|
|
3588
3654
|
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
3589
3655
|
const functionName = params.is_open ? "open_position_with_liquidity_by_fix_coin_with_protection" : "add_liquidity_by_fix_coin_with_protection";
|
|
@@ -6321,7 +6387,7 @@ var PositionModule = class {
|
|
|
6321
6387
|
const { isAdjustCoinA, isAdjustCoinB } = findAdjustCoin(params);
|
|
6322
6388
|
params = params;
|
|
6323
6389
|
if (params.fix_amount_a && isAdjustCoinA || !params.fix_amount_a && isAdjustCoinB) {
|
|
6324
|
-
tx = await TransactionUtil.
|
|
6390
|
+
tx = await TransactionUtil.buildAddLiquidityWithProtectionFixTokenForGas(
|
|
6325
6391
|
this._sdk,
|
|
6326
6392
|
allCoinAsset,
|
|
6327
6393
|
params,
|