@magmaprotocol/magma-clmm-sdk 0.5.71 → 0.5.73

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.js CHANGED
@@ -6887,27 +6887,24 @@ var RewarderModule = class {
6887
6887
  }
6888
6888
  const allCoinAsset = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress, null);
6889
6889
  tx = tx || new import_transactions6.Transaction();
6890
- const coinIdMaps = {};
6891
- const coinIdMaps2 = {};
6890
+ const coinIdMaps = [];
6892
6891
  params.forEach((item) => {
6893
6892
  const coinTypeA = normalizeCoinType(item.coinTypeA);
6894
6893
  const coinTypeB = normalizeCoinType(item.coinTypeB);
6895
6894
  if (item.collect_fee) {
6896
- let coinAInput = coinIdMaps[coinTypeA];
6897
- if (coinAInput == null) {
6898
- if (inputCoinA == null) {
6899
- coinAInput = TransactionUtil.buildCoinForAmount(tx, allCoinAsset, BigInt(0), coinTypeA, false, true);
6900
- } else {
6901
- coinAInput = {
6902
- targetCoin: inputCoinA,
6903
- remainCoins: [],
6904
- isMintZeroCoin: false,
6905
- tragetCoinAmount: "0"
6906
- };
6907
- }
6908
- coinIdMaps[coinTypeA] = coinAInput;
6895
+ let coinAInput = null;
6896
+ if (inputCoinA == null) {
6897
+ coinAInput = TransactionUtil.buildCoinForAmount(tx, allCoinAsset, BigInt(0), coinTypeA, false, true);
6898
+ } else {
6899
+ coinAInput = {
6900
+ targetCoin: inputCoinA,
6901
+ remainCoins: [],
6902
+ isMintZeroCoin: false,
6903
+ tragetCoinAmount: "0"
6904
+ };
6905
+ coinIdMaps.push({ coin: coinAInput, coin_addr: coinTypeA });
6909
6906
  }
6910
- let coinBInput = coinIdMaps[coinTypeB];
6907
+ let coinBInput = null;
6911
6908
  if (coinBInput == null) {
6912
6909
  if (inputCoinB == null) {
6913
6910
  coinBInput = TransactionUtil.buildCoinForAmount(tx, allCoinAsset, BigInt(0), coinTypeB, false, true);
@@ -6919,7 +6916,7 @@ var RewarderModule = class {
6919
6916
  tragetCoinAmount: "0"
6920
6917
  };
6921
6918
  }
6922
- coinIdMaps[coinTypeB] = coinBInput;
6919
+ coinIdMaps.push({ coin: coinBInput, coin_addr: coinTypeB });
6923
6920
  }
6924
6921
  tx = this._sdk.Position.createCollectFeeNoSendPaylod(
6925
6922
  {
@@ -6936,26 +6933,17 @@ var RewarderModule = class {
6936
6933
  const primaryCoinInputs = [];
6937
6934
  item.rewarder_coin_types.forEach((type) => {
6938
6935
  const coinType = normalizeCoinType(type);
6939
- let coinInput = coinIdMaps2[type];
6936
+ let coinInput;
6940
6937
  if (coinInput === void 0) {
6941
6938
  coinInput = TransactionUtil.buildCoinForAmount(tx, allCoinAsset, BigInt(0), coinType, false, true);
6942
- coinIdMaps2[coinType] = coinInput;
6939
+ coinIdMaps.push({ coin: coinInput, coin_addr: coinType });
6943
6940
  }
6944
6941
  primaryCoinInputs.push(coinInput.targetCoin);
6945
6942
  });
6946
6943
  tx = this.createCollectRewarderNoSendPaylod(item, tx, primaryCoinInputs);
6947
6944
  });
6948
- Object.keys(coinIdMaps).forEach((key) => {
6949
- const value = coinIdMaps[key];
6950
- if (value.isMintZeroCoin) {
6951
- TransactionUtil.buildTransferCoin(this._sdk, tx, value.targetCoin, key, this._sdk.senderAddress);
6952
- }
6953
- });
6954
- Object.keys(coinIdMaps2).forEach((key) => {
6955
- const value = coinIdMaps2[key];
6956
- if (value.isMintZeroCoin) {
6957
- TransactionUtil.buildTransferCoin(this._sdk, tx, value.targetCoin, key, this._sdk.senderAddress);
6958
- }
6945
+ coinIdMaps.forEach((item) => {
6946
+ TransactionUtil.buildTransferCoin(this._sdk, tx, item.coin.targetCoin, item.coin_addr, this._sdk.senderAddress);
6959
6947
  });
6960
6948
  return tx;
6961
6949
  }