@magmaprotocol/magma-clmm-sdk 0.4.3 → 0.5.1

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 CHANGED
@@ -965,6 +965,27 @@ type RewarderAmountOwed = {
965
965
  * @returns {T} The retrieved configuration.
966
966
  */
967
967
  declare function getPackagerConfigs<T>(packageObj: Package<T>): T & ({} | null);
968
+ type OpenPositionAddLiquidityWithProtectionParams = {
969
+ pool: SuiAddressType;
970
+ tick_lower: number;
971
+ tick_upper: number;
972
+ coin_a: number | string;
973
+ coin_b: number | string;
974
+ /**
975
+ * The address type of the coin A.
976
+ */
977
+ coinAType: SuiAddressType;
978
+ /**
979
+ * The address type of the coin A.
980
+ */
981
+ coinBType: SuiAddressType;
982
+ max_amount_a: number;
983
+ max_amount_b: number;
984
+ min_amount_a: number;
985
+ min_amount_b: number;
986
+ by_amount_a: boolean;
987
+ };
988
+ type AddLiquidityWithProtectionParams = AddLiquidityFixTokenParams & {};
968
989
 
969
990
  /**
970
991
  * Represents tick data for a liquidity pool.
@@ -2593,6 +2614,17 @@ declare class PositionModule implements IModule {
2593
2614
  slippage: number;
2594
2615
  curSqrtPrice: BN;
2595
2616
  }, tx?: Transaction, inputCoinA?: TransactionObjectArgument, inputCoinB?: TransactionObjectArgument): Promise<Transaction>;
2617
+ /**
2618
+ * create add liquidity transaction payload with fix token
2619
+ * @param {AddLiquidityFixTokenParams} params
2620
+ * @param gasEstimateArg : When the fix input amount is SUI, gasEstimateArg can control whether to recalculate the number of SUI to prevent insufficient gas.
2621
+ * If this parameter is not passed, gas estimation is not performed
2622
+ * @returns {Promise<TransactionBlock>}
2623
+ */
2624
+ createAddLiquidityFixTokenWithProtectionPayload(params: AddLiquidityWithProtectionParams, gasEstimateArg?: {
2625
+ slippage: number;
2626
+ curSqrtPrice: BN;
2627
+ }, tx?: Transaction, inputCoinA?: TransactionObjectArgument, inputCoinB?: TransactionObjectArgument): Promise<Transaction>;
2596
2628
  /**
2597
2629
  * create add liquidity transaction payload
2598
2630
  * @param {AddLiquidityParams} params
@@ -3683,6 +3715,13 @@ declare class TransactionUtil {
3683
3715
  * @returns
3684
3716
  */
3685
3717
  static buildAddLiquidityFixToken(sdk: MagmaClmmSDK, allCoinAsset: CoinAsset[], params: AddLiquidityFixTokenParams, tx?: Transaction, inputCoinA?: TransactionObjectArgument, inputCoinB?: TransactionObjectArgument): Promise<Transaction>;
3718
+ /**
3719
+ * build add liquidity with protection transaction
3720
+ * @param params
3721
+ * @param packageId
3722
+ * @returns
3723
+ */
3724
+ static buildAddLiquidityWithProtectionFixToken(sdk: MagmaClmmSDK, allCoinAsset: CoinAsset[], params: AddLiquidityFixTokenParams, tx?: Transaction, inputCoinA?: TransactionObjectArgument, inputCoinB?: TransactionObjectArgument): Promise<Transaction>;
3686
3725
  static buildAddLiquidityFixTokenCoinInput(tx: Transaction, need_interval_amount: boolean, amount: number | string, slippage: number, coinType: string, allCoinAsset: CoinAsset[], buildVector?: boolean): BuildCoinResult;
3687
3726
  /**
3688
3727
  * fix add liquidity fix token for coin amount
@@ -3693,6 +3732,7 @@ declare class TransactionUtil {
3693
3732
  */
3694
3733
  static fixAddLiquidityFixTokenParams(params: AddLiquidityFixTokenParams, slippage: number, curSqrtPrice: BN): AddLiquidityFixTokenParams;
3695
3734
  private static buildAddLiquidityFixTokenArgs;
3735
+ private static buildAddLiquidityWithProtectionFixTokenArgs;
3696
3736
  /**
3697
3737
  * build add liquidity transaction
3698
3738
  * @param params
@@ -3959,4 +3999,4 @@ interface InitMagmaSDKOptions {
3959
3999
  */
3960
4000
  declare function initMagmaSDK(options: InitMagmaSDKOptions): MagmaClmmSDK;
3961
4001
 
3962
- export { AMM_SWAP_MODULE, AddLiquidityCommonParams, AddLiquidityFixTokenParams, AddLiquidityParams, AddressAndDirection, AdjustResult, AggregatorResult, AmountSpecified, BasePath, BigNumber, Bits, BuildCoinResult, CLOCK_ADDRESS, CachedContent, CalculateRatesParams, CalculateRatesResult, ClaimAndLockParams, ClaimFeesParams, ClaimFeesPoolsParams, ClmmConfig, ClmmExpectSwapModule, ClmmFetcherModule, ClmmIntegratePoolModule, ClmmIntegratePoolV2Module, ClmmIntegratePoolV3Module, ClmmIntegrateRouterModule, ClmmIntegrateRouterWithPartnerModule, ClmmIntegrateUtilsModule, ClmmPartnerModule, ClmmPoolConfig, ClmmPoolUtil, ClmmPositionStatus, ClmmpoolData, ClosePositionParams, CoinAmounts, CoinAsset, CoinAssist, CoinConfig, CoinInfoAddress, CoinNode, CoinPairType, CoinProvider, CoinStoreAddress, CollectFeeParams, CollectFeesQuote, CollectFeesQuoteParam, CollectRewarderParams, ConfigModule, CreateLockParams, CreatePartnerEvent, CreatePoolAddLiquidityParams, CreatePoolParams, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, DataPage, DeepbookClobV2Moudle, DeepbookCustodianV2Moudle, DeepbookEndpointsV2Moudle, DeepbookPool, DeepbookUtils, FEE_RATE_DENOMINATOR, FaucetCoin, FetchParams, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, IncreaseLockAmountParams, IncreaseUnlockTimeParams, LaunchpadPoolConfig, LiquidityInput, LockModule, LockPermanentParams, MAX_SQRT_PRICE, MAX_TICK_INDEX, MIN_SQRT_PRICE, MIN_TICK_INDEX, MagmaClmmSDK, MagmaConfigs, MathUtil, MergeLockParams, NFT, ONE, OnePath, OpenPositionParams, Order, POOL_STRUCT, Package, PageQuery, PaginationArgs, PathLink, PathProvider, Percentage, PokeParams, Pool, PoolImmutables, PoolInfo, PoolModule, Position, PositionModule, PositionReward, PositionStatus, PositionUtil, PreRouterSwapParams, PreSwapLpChangeParams, PreSwapParams, PreSwapResult, PreSwapWithMultiPoolParams, PriceResult, RemoveLiquidityParams, RewardDistributor, Rewarder, RewarderAmountOwed, RouterModule, RouterModuleV2, RpcModule, SUI_SYSTEM_STATE_OBJECT_ID, SdkOptions, SplitPath, SplitSwap, SplitSwapResult, SplitUnit, SuiAddressType, SuiBasicTypes, SuiInputTypes, SuiObjectDataWithContent, SuiObjectIdType, SuiResource, SuiStructTag, SuiTxArg, SwapDirection, SwapModule, SwapParams, SwapResult, SwapStepResult, SwapUtils, SwapWithRouterParams, TICK_ARRAY_SIZE, TWO, Tick, TickData, TickMath, TickUtil, TokenConfig, TokenConfigEvent, TokenInfo, TokenModule, TransPreSwapWithMultiPoolParams, TransactionUtil, TransferLockParams, TxBlock, U128, U128_MAX, U64_MAX, VoteParams, Voter, VotingEscrow, ZERO, addHexPrefix, adjustForCoinSlippage, adjustForSlippage, asIntN, asUintN, bufferToHex, buildClmmPositionName, buildNFT, buildPool, buildPosition, buildPositionReward, buildTickData, buildTickDataByEvent, cacheTime24h, cacheTime5min, checkAddress, checkInvalidSuiAddress, clmmMainnet, clmmTestnet, collectFeesQuote, composeType, computeSwap, computeSwapStep, createSplitAmountArray, createSplitArray, createTestTransferTxPayloadParams, d, decimalsMultiplier, MagmaClmmSDK as default, estPoolAPR, estPosAPRResult, estPositionAPRWithDeltaMethod, estPositionAPRWithMultiMethod, estimateLiquidityForCoinA, estimateLiquidityForCoinB, extractAddressFromType, extractStructTagFromType, findAdjustCoin, fixCoinType, fixSuiObjectId, fromDecimalsAmount, getAmountFixedDelta, getAmountUnfixedDelta, getCoinAFromLiquidity, getCoinBFromLiquidity, getDefaultSuiInputType, getDeltaA, getDeltaB, getDeltaDownFromOutput, getDeltaUpFromInput, getFutureTime, getLiquidityFromCoinA, getLiquidityFromCoinB, getLowerSqrtPriceFromCoinA, getLowerSqrtPriceFromCoinB, getMoveObject, getMoveObjectType, getMovePackageContent, getNearestTickByTick, getNextSqrtPriceAUp, getNextSqrtPriceBDown, getNextSqrtPriceFromInput, getNextSqrtPriceFromOutput, getObjectDeletedResponse, getObjectDisplay, getObjectFields, getObjectId, getObjectNotExistsResponse, getObjectOwner, getObjectPreviousTransactionDigest, getObjectReference, getObjectType, getObjectVersion, getPackagerConfigs, getRewardInTickRange, getSuiObjectData, getTickDataFromUrlData, getUpperSqrtPriceFromCoinA, getUpperSqrtPriceFromCoinB, hasPublicTransfer, hexToNumber, hexToString, initMagmaSDK, initMainnetSDK, initTestnetSDK, isSortedSymbols, isSuiObjectResponse, newBits, normalizeCoinType, patchFixSuiObjectId, printTransaction, removeHexPrefix, secretKeyToEd25519Keypair, secretKeyToSecp256k1Keypair, shortAddress, shortString, tickScore, toBuffer, toCoinAmount, toDecimalsAmount, transClmmpoolDataWithoutTicks, utf8to16 };
4002
+ export { AMM_SWAP_MODULE, AddLiquidityCommonParams, AddLiquidityFixTokenParams, AddLiquidityParams, AddLiquidityWithProtectionParams, AddressAndDirection, AdjustResult, AggregatorResult, AmountSpecified, BasePath, BigNumber, Bits, BuildCoinResult, CLOCK_ADDRESS, CachedContent, CalculateRatesParams, CalculateRatesResult, ClaimAndLockParams, ClaimFeesParams, ClaimFeesPoolsParams, ClmmConfig, ClmmExpectSwapModule, ClmmFetcherModule, ClmmIntegratePoolModule, ClmmIntegratePoolV2Module, ClmmIntegratePoolV3Module, ClmmIntegrateRouterModule, ClmmIntegrateRouterWithPartnerModule, ClmmIntegrateUtilsModule, ClmmPartnerModule, ClmmPoolConfig, ClmmPoolUtil, ClmmPositionStatus, ClmmpoolData, ClosePositionParams, CoinAmounts, CoinAsset, CoinAssist, CoinConfig, CoinInfoAddress, CoinNode, CoinPairType, CoinProvider, CoinStoreAddress, CollectFeeParams, CollectFeesQuote, CollectFeesQuoteParam, CollectRewarderParams, ConfigModule, CreateLockParams, CreatePartnerEvent, CreatePoolAddLiquidityParams, CreatePoolParams, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, DataPage, DeepbookClobV2Moudle, DeepbookCustodianV2Moudle, DeepbookEndpointsV2Moudle, DeepbookPool, DeepbookUtils, FEE_RATE_DENOMINATOR, FaucetCoin, FetchParams, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, IncreaseLockAmountParams, IncreaseUnlockTimeParams, LaunchpadPoolConfig, LiquidityInput, LockModule, LockPermanentParams, MAX_SQRT_PRICE, MAX_TICK_INDEX, MIN_SQRT_PRICE, MIN_TICK_INDEX, MagmaClmmSDK, MagmaConfigs, MathUtil, MergeLockParams, NFT, ONE, OnePath, OpenPositionAddLiquidityWithProtectionParams, OpenPositionParams, Order, POOL_STRUCT, Package, PageQuery, PaginationArgs, PathLink, PathProvider, Percentage, PokeParams, Pool, PoolImmutables, PoolInfo, PoolModule, Position, PositionModule, PositionReward, PositionStatus, PositionUtil, PreRouterSwapParams, PreSwapLpChangeParams, PreSwapParams, PreSwapResult, PreSwapWithMultiPoolParams, PriceResult, RemoveLiquidityParams, RewardDistributor, Rewarder, RewarderAmountOwed, RouterModule, RouterModuleV2, RpcModule, SUI_SYSTEM_STATE_OBJECT_ID, SdkOptions, SplitPath, SplitSwap, SplitSwapResult, SplitUnit, SuiAddressType, SuiBasicTypes, SuiInputTypes, SuiObjectDataWithContent, SuiObjectIdType, SuiResource, SuiStructTag, SuiTxArg, SwapDirection, SwapModule, SwapParams, SwapResult, SwapStepResult, SwapUtils, SwapWithRouterParams, TICK_ARRAY_SIZE, TWO, Tick, TickData, TickMath, TickUtil, TokenConfig, TokenConfigEvent, TokenInfo, TokenModule, TransPreSwapWithMultiPoolParams, TransactionUtil, TransferLockParams, TxBlock, U128, U128_MAX, U64_MAX, VoteParams, Voter, VotingEscrow, ZERO, addHexPrefix, adjustForCoinSlippage, adjustForSlippage, asIntN, asUintN, bufferToHex, buildClmmPositionName, buildNFT, buildPool, buildPosition, buildPositionReward, buildTickData, buildTickDataByEvent, cacheTime24h, cacheTime5min, checkAddress, checkInvalidSuiAddress, clmmMainnet, clmmTestnet, collectFeesQuote, composeType, computeSwap, computeSwapStep, createSplitAmountArray, createSplitArray, createTestTransferTxPayloadParams, d, decimalsMultiplier, MagmaClmmSDK as default, estPoolAPR, estPosAPRResult, estPositionAPRWithDeltaMethod, estPositionAPRWithMultiMethod, estimateLiquidityForCoinA, estimateLiquidityForCoinB, extractAddressFromType, extractStructTagFromType, findAdjustCoin, fixCoinType, fixSuiObjectId, fromDecimalsAmount, getAmountFixedDelta, getAmountUnfixedDelta, getCoinAFromLiquidity, getCoinBFromLiquidity, getDefaultSuiInputType, getDeltaA, getDeltaB, getDeltaDownFromOutput, getDeltaUpFromInput, getFutureTime, getLiquidityFromCoinA, getLiquidityFromCoinB, getLowerSqrtPriceFromCoinA, getLowerSqrtPriceFromCoinB, getMoveObject, getMoveObjectType, getMovePackageContent, getNearestTickByTick, getNextSqrtPriceAUp, getNextSqrtPriceBDown, getNextSqrtPriceFromInput, getNextSqrtPriceFromOutput, getObjectDeletedResponse, getObjectDisplay, getObjectFields, getObjectId, getObjectNotExistsResponse, getObjectOwner, getObjectPreviousTransactionDigest, getObjectReference, getObjectType, getObjectVersion, getPackagerConfigs, getRewardInTickRange, getSuiObjectData, getTickDataFromUrlData, getUpperSqrtPriceFromCoinA, getUpperSqrtPriceFromCoinB, hasPublicTransfer, hexToNumber, hexToString, initMagmaSDK, initMainnetSDK, initTestnetSDK, isSortedSymbols, isSuiObjectResponse, newBits, normalizeCoinType, patchFixSuiObjectId, printTransaction, removeHexPrefix, secretKeyToEd25519Keypair, secretKeyToSecp256k1Keypair, shortAddress, shortString, tickScore, toBuffer, toCoinAmount, toDecimalsAmount, transClmmpoolDataWithoutTicks, utf8to16 };
package/dist/index.js CHANGED
@@ -1186,11 +1186,7 @@ var ClmmPoolUtil = class {
1186
1186
  coinB = new decimal_default(0);
1187
1187
  } else if (curSqrtPrice.lt(upperSqrtPrice)) {
1188
1188
  coinA = MathUtil.toX64_Decimal(liq).mul(upperPriceStr.sub(curSqrtPriceStr)).div(curSqrtPriceStr.mul(upperPriceStr));
1189
- const a = curSqrtPriceStr.sub(lowerPriceStr);
1190
- const b = liq.mul(a);
1191
- const c = MathUtil.fromX64_Decimal(b);
1192
- coinB = c;
1193
- console.log("########## a, b, c", a, b, c);
1189
+ coinB = MathUtil.fromX64_Decimal(liq.mul(curSqrtPriceStr.sub(lowerPriceStr)));
1194
1190
  } else {
1195
1191
  coinA = new decimal_default(0);
1196
1192
  coinB = MathUtil.fromX64_Decimal(liq.mul(upperPriceStr.sub(lowerPriceStr)));
@@ -1239,8 +1235,8 @@ var ClmmPoolUtil = class {
1239
1235
  liquidity = estimateLiquidityForCoinB(curSqrtPrice, lowerSqrtPrice, coinAmount);
1240
1236
  }
1241
1237
  const coinAmounts = ClmmPoolUtil.getCoinAmountFromLiquidity(liquidity, curSqrtPrice, lowerSqrtPrice, upperSqrtPrice, roundUp);
1242
- const tokenLimitA = roundUp ? d(coinAmounts.coinA.toString()).mul(1 + slippage).toString() : d(coinAmounts.coinA.toString()).mul(1 - slippage).toString();
1243
- const tokenLimitB = roundUp ? d(coinAmounts.coinB.toString()).mul(1 + slippage).toString() : d(coinAmounts.coinB.toString()).mul(1 - slippage).toString();
1238
+ const tokenLimitA = iscoinA ? d(coinAmounts.coinA.toString()).mul(1 + slippage).toString() : d(coinAmounts.coinA.toString()).mul(1 - slippage).toString();
1239
+ const tokenLimitB = iscoinA ? d(coinAmounts.coinB.toString()).mul(1 + slippage).toString() : d(coinAmounts.coinB.toString()).mul(1 - slippage).toString();
1244
1240
  return {
1245
1241
  coinAmountA: coinAmounts.coinA,
1246
1242
  coinAmountB: coinAmounts.coinB,
@@ -2821,6 +2817,62 @@ var _TransactionUtil = class {
2821
2817
  );
2822
2818
  return tx;
2823
2819
  }
2820
+ /**
2821
+ * build add liquidity with protection transaction
2822
+ * @param params
2823
+ * @param packageId
2824
+ * @returns
2825
+ */
2826
+ static async buildAddLiquidityWithProtectionFixToken(sdk, allCoinAsset, params, tx, inputCoinA, inputCoinB) {
2827
+ if (sdk.senderAddress.length === 0) {
2828
+ throw Error("this config sdk senderAddress is empty");
2829
+ }
2830
+ tx = tx || new import_transactions.Transaction();
2831
+ let primaryCoinAInputs;
2832
+ let primaryCoinBInputs;
2833
+ if (inputCoinA == null || inputCoinB == null) {
2834
+ primaryCoinAInputs = _TransactionUtil.buildAddLiquidityFixTokenCoinInput(
2835
+ tx,
2836
+ !params.fix_amount_a,
2837
+ params.amount_a,
2838
+ params.slippage,
2839
+ params.coinTypeA,
2840
+ allCoinAsset,
2841
+ false
2842
+ );
2843
+ primaryCoinBInputs = _TransactionUtil.buildAddLiquidityFixTokenCoinInput(
2844
+ tx,
2845
+ params.fix_amount_a,
2846
+ params.amount_b,
2847
+ params.slippage,
2848
+ params.coinTypeB,
2849
+ allCoinAsset,
2850
+ false
2851
+ );
2852
+ } else {
2853
+ primaryCoinAInputs = {
2854
+ targetCoin: inputCoinA,
2855
+ remainCoins: [],
2856
+ isMintZeroCoin: false,
2857
+ tragetCoinAmount: "0"
2858
+ };
2859
+ primaryCoinBInputs = {
2860
+ targetCoin: inputCoinB,
2861
+ remainCoins: [],
2862
+ isMintZeroCoin: false,
2863
+ tragetCoinAmount: "0"
2864
+ };
2865
+ }
2866
+ tx = _TransactionUtil.buildAddLiquidityWithProtectionFixTokenArgs(
2867
+ tx,
2868
+ sdk,
2869
+ allCoinAsset,
2870
+ params,
2871
+ primaryCoinAInputs,
2872
+ primaryCoinBInputs
2873
+ );
2874
+ return tx;
2875
+ }
2824
2876
  static buildAddLiquidityFixTokenCoinInput(tx, need_interval_amount, amount, slippage, coinType, allCoinAsset, buildVector = true) {
2825
2877
  return need_interval_amount ? _TransactionUtil.buildCoinForAmountInterval(
2826
2878
  tx,
@@ -2896,6 +2948,67 @@ var _TransactionUtil = class {
2896
2948
  });
2897
2949
  return tx;
2898
2950
  }
2951
+ static buildAddLiquidityWithProtectionFixTokenArgs(tx, sdk, allCoinAsset, params, primaryCoinAInputs, primaryCoinBInputs) {
2952
+ const typeArguments = [params.coinTypeA, params.coinTypeB];
2953
+ const functionName = params.is_open ? "open_position_with_liquidity_by_fix_coin_with_protection" : "add_liquidity_by_fix_coin_with_protection";
2954
+ const { clmm_pool, integrate } = sdk.sdkOptions;
2955
+ if (!params.is_open) {
2956
+ tx = _TransactionUtil.createCollectRewarderAndFeeParams(
2957
+ sdk,
2958
+ tx,
2959
+ params,
2960
+ allCoinAsset,
2961
+ primaryCoinAInputs.remainCoins,
2962
+ primaryCoinBInputs.remainCoins
2963
+ );
2964
+ }
2965
+ const clmmConfig = getPackagerConfigs(clmm_pool);
2966
+ let min_amount_a, max_amount_a, min_amount_b, max_amount_b;
2967
+ if (params.fix_amount_a) {
2968
+ max_amount_a = params.amount_a;
2969
+ min_amount_a = params.amount_a;
2970
+ max_amount_b = params.amount_b;
2971
+ min_amount_b = new import_decimal7.default(params.amount_b).div(new import_decimal7.default(1).plus(new import_decimal7.default(params.slippage))).mul(new import_decimal7.default(1).minus(new import_decimal7.default(params.slippage))).toNumber();
2972
+ } else {
2973
+ max_amount_b = params.amount_b;
2974
+ min_amount_b = params.amount_b;
2975
+ max_amount_a = params.amount_a;
2976
+ min_amount_a = new import_decimal7.default(params.amount_a).div(new import_decimal7.default(1).plus(new import_decimal7.default(params.slippage))).mul(new import_decimal7.default(1).minus(new import_decimal7.default(params.slippage))).toNumber();
2977
+ }
2978
+ const args = params.is_open ? [
2979
+ tx.object(clmmConfig.global_config_id),
2980
+ tx.object(params.pool_id),
2981
+ tx.pure.u32(Number(asUintN(BigInt(params.tick_lower)).toString())),
2982
+ tx.pure.u32(Number(asUintN(BigInt(params.tick_upper)).toString())),
2983
+ primaryCoinAInputs.targetCoin,
2984
+ primaryCoinBInputs.targetCoin,
2985
+ tx.pure.u64(max_amount_a),
2986
+ tx.pure.u64(max_amount_b),
2987
+ tx.pure.u64(min_amount_a),
2988
+ tx.pure.u64(min_amount_b),
2989
+ tx.pure.bool(params.fix_amount_a),
2990
+ tx.object(CLOCK_ADDRESS)
2991
+ ] : [
2992
+ tx.object(clmmConfig.global_config_id),
2993
+ tx.object(params.pool_id),
2994
+ tx.object(params.pos_id),
2995
+ primaryCoinAInputs.targetCoin,
2996
+ primaryCoinBInputs.targetCoin,
2997
+ tx.pure.u64(max_amount_a),
2998
+ tx.pure.u64(max_amount_b),
2999
+ tx.pure.u64(min_amount_a),
3000
+ tx.pure.u64(min_amount_b),
3001
+ tx.pure.bool(params.fix_amount_a),
3002
+ tx.object(CLOCK_ADDRESS),
3003
+ tx.object(CLOCK_ADDRESS)
3004
+ ];
3005
+ tx.moveCall({
3006
+ target: `${integrate.published_at}::${ClmmIntegratePoolV2Module}::${functionName}`,
3007
+ typeArguments,
3008
+ arguments: args
3009
+ });
3010
+ return tx;
3011
+ }
2899
3012
  // -------------------------------------------swap--------------------------------------------------//
2900
3013
  /**
2901
3014
  * build add liquidity transaction
@@ -5454,6 +5567,36 @@ var PositionModule = class {
5454
5567
  }
5455
5568
  return TransactionUtil.buildAddLiquidityFixToken(this._sdk, allCoinAsset, params, tx, inputCoinA, inputCoinB);
5456
5569
  }
5570
+ /**
5571
+ * create add liquidity transaction payload with fix token
5572
+ * @param {AddLiquidityFixTokenParams} params
5573
+ * @param gasEstimateArg : When the fix input amount is SUI, gasEstimateArg can control whether to recalculate the number of SUI to prevent insufficient gas.
5574
+ * If this parameter is not passed, gas estimation is not performed
5575
+ * @returns {Promise<TransactionBlock>}
5576
+ */
5577
+ async createAddLiquidityFixTokenWithProtectionPayload(params, gasEstimateArg, tx, inputCoinA, inputCoinB) {
5578
+ if (!checkInvalidSuiAddress(this._sdk.senderAddress)) {
5579
+ throw new ClmmpoolsError("this config sdk senderAddress is not set right", "InvalidSendAddress" /* InvalidSendAddress */);
5580
+ }
5581
+ const allCoinAsset = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
5582
+ if (gasEstimateArg) {
5583
+ const { isAdjustCoinA, isAdjustCoinB } = findAdjustCoin(params);
5584
+ params = params;
5585
+ if (params.fix_amount_a && isAdjustCoinA || !params.fix_amount_a && isAdjustCoinB) {
5586
+ tx = await TransactionUtil.buildAddLiquidityFixTokenForGas(
5587
+ this._sdk,
5588
+ allCoinAsset,
5589
+ params,
5590
+ gasEstimateArg,
5591
+ tx,
5592
+ inputCoinA,
5593
+ inputCoinB
5594
+ );
5595
+ return tx;
5596
+ }
5597
+ }
5598
+ return TransactionUtil.buildAddLiquidityWithProtectionFixToken(this._sdk, allCoinAsset, params, tx, inputCoinA, inputCoinB);
5599
+ }
5457
5600
  /**
5458
5601
  * create add liquidity transaction payload
5459
5602
  * @param {AddLiquidityParams} params