@magmaprotocol/magma-clmm-sdk 0.5.117 → 0.5.118
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.mjs
CHANGED
|
@@ -3364,6 +3364,72 @@ var _TransactionUtil = class {
|
|
|
3364
3364
|
});
|
|
3365
3365
|
return tx;
|
|
3366
3366
|
}
|
|
3367
|
+
static async buildAddLiquidityWithProtectionFixTokenForGas(sdk, allCoins, params, gasEstimateArg, tx, inputCoinA, inputCoinB) {
|
|
3368
|
+
tx = await _TransactionUtil.buildAddLiquidityFixToken(sdk, allCoins, params, tx, inputCoinA, inputCoinB);
|
|
3369
|
+
const { isAdjustCoinA } = findAdjustCoin(params);
|
|
3370
|
+
const suiAmount = isAdjustCoinA ? params.amount_a : params.amount_b;
|
|
3371
|
+
const newResult = await _TransactionUtil.adjustTransactionForGas(
|
|
3372
|
+
sdk,
|
|
3373
|
+
CoinAssist.getCoinAssets(isAdjustCoinA ? params.coinTypeA : params.coinTypeB, allCoins),
|
|
3374
|
+
BigInt(suiAmount),
|
|
3375
|
+
tx
|
|
3376
|
+
);
|
|
3377
|
+
const { fixAmount } = newResult;
|
|
3378
|
+
const { newTx } = newResult;
|
|
3379
|
+
if (newTx != null) {
|
|
3380
|
+
let primaryCoinAInputs;
|
|
3381
|
+
let primaryCoinBInputs;
|
|
3382
|
+
if (isAdjustCoinA) {
|
|
3383
|
+
params.amount_a = Number(fixAmount);
|
|
3384
|
+
primaryCoinAInputs = _TransactionUtil.buildAddLiquidityFixTokenCoinInput(
|
|
3385
|
+
newTx,
|
|
3386
|
+
!params.fix_amount_a,
|
|
3387
|
+
fixAmount.toString(),
|
|
3388
|
+
params.slippage,
|
|
3389
|
+
params.coinTypeA,
|
|
3390
|
+
allCoins,
|
|
3391
|
+
false,
|
|
3392
|
+
true
|
|
3393
|
+
);
|
|
3394
|
+
primaryCoinBInputs = _TransactionUtil.buildAddLiquidityFixTokenCoinInput(
|
|
3395
|
+
newTx,
|
|
3396
|
+
params.fix_amount_a,
|
|
3397
|
+
params.amount_b,
|
|
3398
|
+
params.slippage,
|
|
3399
|
+
params.coinTypeB,
|
|
3400
|
+
allCoins,
|
|
3401
|
+
false,
|
|
3402
|
+
true
|
|
3403
|
+
);
|
|
3404
|
+
} else {
|
|
3405
|
+
params.amount_b = Number(fixAmount);
|
|
3406
|
+
primaryCoinAInputs = _TransactionUtil.buildAddLiquidityFixTokenCoinInput(
|
|
3407
|
+
newTx,
|
|
3408
|
+
!params.fix_amount_a,
|
|
3409
|
+
params.amount_a,
|
|
3410
|
+
params.slippage,
|
|
3411
|
+
params.coinTypeA,
|
|
3412
|
+
allCoins,
|
|
3413
|
+
false,
|
|
3414
|
+
true
|
|
3415
|
+
);
|
|
3416
|
+
primaryCoinBInputs = _TransactionUtil.buildAddLiquidityFixTokenCoinInput(
|
|
3417
|
+
newTx,
|
|
3418
|
+
params.fix_amount_a,
|
|
3419
|
+
fixAmount.toString(),
|
|
3420
|
+
params.slippage,
|
|
3421
|
+
params.coinTypeB,
|
|
3422
|
+
allCoins,
|
|
3423
|
+
false,
|
|
3424
|
+
true
|
|
3425
|
+
);
|
|
3426
|
+
params = _TransactionUtil.fixAddLiquidityFixTokenParams(params, gasEstimateArg.slippage, gasEstimateArg.curSqrtPrice);
|
|
3427
|
+
tx = _TransactionUtil.buildAddLiquidityWithProtectionFixTokenArgs(newTx, sdk, allCoins, params, primaryCoinAInputs, primaryCoinBInputs);
|
|
3428
|
+
return tx;
|
|
3429
|
+
}
|
|
3430
|
+
}
|
|
3431
|
+
return tx;
|
|
3432
|
+
}
|
|
3367
3433
|
static buildAddLiquidityWithProtectionFixTokenArgs(tx, sdk, allCoinAsset, params, primaryCoinAInputs, primaryCoinBInputs) {
|
|
3368
3434
|
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
3369
3435
|
const functionName = params.is_open ? "open_position_with_liquidity_by_fix_coin_with_protection" : "add_liquidity_by_fix_coin_with_protection";
|
|
@@ -6101,7 +6167,7 @@ var PositionModule = class {
|
|
|
6101
6167
|
const { isAdjustCoinA, isAdjustCoinB } = findAdjustCoin(params);
|
|
6102
6168
|
params = params;
|
|
6103
6169
|
if (params.fix_amount_a && isAdjustCoinA || !params.fix_amount_a && isAdjustCoinB) {
|
|
6104
|
-
tx = await TransactionUtil.
|
|
6170
|
+
tx = await TransactionUtil.buildAddLiquidityWithProtectionFixTokenForGas(
|
|
6105
6171
|
this._sdk,
|
|
6106
6172
|
allCoinAsset,
|
|
6107
6173
|
params,
|