@magmaprotocol/magma-clmm-sdk 0.5.76 → 0.5.78
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 +5 -1
- package/dist/index.js +44 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6661,21 +6661,45 @@ var RewarderModule = class {
|
|
|
6661
6661
|
* @param tx
|
|
6662
6662
|
* @returns
|
|
6663
6663
|
*/
|
|
6664
|
-
async batchCollectRewardePayload(params, tx) {
|
|
6664
|
+
async batchCollectRewardePayload(params, tx, inputCoinA, inputCoinB) {
|
|
6665
6665
|
if (!checkInvalidSuiAddress(this._sdk.senderAddress)) {
|
|
6666
6666
|
throw new ClmmpoolsError("this config sdk senderAddress is not set right", "InvalidSendAddress" /* InvalidSendAddress */);
|
|
6667
6667
|
}
|
|
6668
6668
|
const allCoinAsset = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress, null);
|
|
6669
6669
|
tx = tx || new Transaction6();
|
|
6670
|
-
const
|
|
6670
|
+
const coinIdMaps = {};
|
|
6671
6671
|
params.forEach((item) => {
|
|
6672
6672
|
const coinTypeA = normalizeCoinType(item.coinTypeA);
|
|
6673
6673
|
const coinTypeB = normalizeCoinType(item.coinTypeB);
|
|
6674
6674
|
if (item.collect_fee) {
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6675
|
+
let coinAInput = coinIdMaps[coinTypeA];
|
|
6676
|
+
if (coinAInput == null) {
|
|
6677
|
+
if (inputCoinA == null) {
|
|
6678
|
+
coinAInput = TransactionUtil.buildCoinForAmount(tx, allCoinAsset, BigInt(0), coinTypeA, false);
|
|
6679
|
+
} else {
|
|
6680
|
+
coinAInput = {
|
|
6681
|
+
targetCoin: inputCoinA,
|
|
6682
|
+
remainCoins: [],
|
|
6683
|
+
isMintZeroCoin: false,
|
|
6684
|
+
tragetCoinAmount: "0"
|
|
6685
|
+
};
|
|
6686
|
+
}
|
|
6687
|
+
coinIdMaps[coinTypeA] = coinAInput;
|
|
6688
|
+
}
|
|
6689
|
+
let coinBInput = coinIdMaps[coinTypeB];
|
|
6690
|
+
if (coinBInput == null) {
|
|
6691
|
+
if (inputCoinB == null) {
|
|
6692
|
+
coinBInput = TransactionUtil.buildCoinForAmount(tx, allCoinAsset, BigInt(0), coinTypeB, false);
|
|
6693
|
+
} else {
|
|
6694
|
+
coinBInput = {
|
|
6695
|
+
targetCoin: inputCoinB,
|
|
6696
|
+
remainCoins: [],
|
|
6697
|
+
isMintZeroCoin: false,
|
|
6698
|
+
tragetCoinAmount: "0"
|
|
6699
|
+
};
|
|
6700
|
+
}
|
|
6701
|
+
coinIdMaps[coinTypeB] = coinBInput;
|
|
6702
|
+
}
|
|
6679
6703
|
tx = this._sdk.Position.createCollectFeeNoSendPaylod(
|
|
6680
6704
|
{
|
|
6681
6705
|
pool_id: item.pool_id,
|
|
@@ -6691,14 +6715,20 @@ var RewarderModule = class {
|
|
|
6691
6715
|
const primaryCoinInputs = [];
|
|
6692
6716
|
item.rewarder_coin_types.forEach((type) => {
|
|
6693
6717
|
const coinType = normalizeCoinType(type);
|
|
6694
|
-
|
|
6718
|
+
let coinInput = coinIdMaps[type];
|
|
6719
|
+
if (coinInput === void 0) {
|
|
6720
|
+
coinInput = TransactionUtil.buildCoinForAmount(tx, allCoinAsset, BigInt(0), coinType, false);
|
|
6721
|
+
coinIdMaps[coinType] = coinInput;
|
|
6722
|
+
}
|
|
6695
6723
|
primaryCoinInputs.push(coinInput.targetCoin);
|
|
6696
|
-
coinIdList.push({ coin: coinInput, coin_addr: coinType });
|
|
6697
6724
|
});
|
|
6698
6725
|
tx = this.createCollectRewarderNoSendPaylod(item, tx, primaryCoinInputs);
|
|
6699
6726
|
});
|
|
6700
|
-
|
|
6701
|
-
|
|
6727
|
+
Object.keys(coinIdMaps).forEach((key) => {
|
|
6728
|
+
const value = coinIdMaps[key];
|
|
6729
|
+
if (value.isMintZeroCoin) {
|
|
6730
|
+
TransactionUtil.buildTransferCoin(this._sdk, tx, value.targetCoin, key, this._sdk.senderAddress);
|
|
6731
|
+
}
|
|
6702
6732
|
});
|
|
6703
6733
|
return tx;
|
|
6704
6734
|
}
|
|
@@ -10323,7 +10353,10 @@ var DlmmModule = class {
|
|
|
10323
10353
|
coin_b: fields.y.fields.name,
|
|
10324
10354
|
base_factor: fields.params.fields.base_factor,
|
|
10325
10355
|
base_fee: fields.params.fields.base_factor / 1e4 * (fields.bin_step / 1e4),
|
|
10326
|
-
active_index: fields.params.fields.active_index
|
|
10356
|
+
active_index: fields.params.fields.active_index,
|
|
10357
|
+
real_bin_id: get_real_id(fields.params.fields.active_index),
|
|
10358
|
+
coinAmountA: fields.reserve_x,
|
|
10359
|
+
coinAmountB: fields.reserve_y
|
|
10327
10360
|
});
|
|
10328
10361
|
});
|
|
10329
10362
|
return poolList;
|