@magmaprotocol/magma-clmm-sdk 0.5.64 → 0.5.65
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 -3
- package/dist/index.js +16 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1752,6 +1752,8 @@ type DlmmPoolInfo = {
|
|
|
1752
1752
|
base_factor: number;
|
|
1753
1753
|
base_fee: number;
|
|
1754
1754
|
active_index: number;
|
|
1755
|
+
coinAmountA: string;
|
|
1756
|
+
coinAmountB: string;
|
|
1755
1757
|
};
|
|
1756
1758
|
type DlmmAddLiquidityParams = {
|
|
1757
1759
|
pool_id: string;
|
|
@@ -3722,7 +3724,6 @@ declare class DlmmModule implements IModule {
|
|
|
3722
3724
|
get sdk(): MagmaClmmSDK;
|
|
3723
3725
|
getPoolInfo(pools: string[]): Promise<DlmmPoolInfo[]>;
|
|
3724
3726
|
fetchPairParams(params: FetchPairParams): Promise<EventPairParams>;
|
|
3725
|
-
price_to_storage_id(price: string, bin_step: number, tokenADecimal: number, tokenBDecimal: number): number;
|
|
3726
3727
|
createPairPayload(params: CreatePairParams): Promise<Transaction>;
|
|
3727
3728
|
mintPercent(params: MintPercentParams): Promise<Transaction>;
|
|
3728
3729
|
createPositionByAmount(params: MintAmountParams): Promise<Transaction>;
|
|
@@ -3731,8 +3732,9 @@ declare class DlmmModule implements IModule {
|
|
|
3731
3732
|
private _raisePositionByAmountsReward;
|
|
3732
3733
|
burnPosition(params: DlmmBurnPositionParams): Promise<Transaction>;
|
|
3733
3734
|
shrinkPosition(params: DlmmShrinkPosition): Promise<Transaction>;
|
|
3734
|
-
|
|
3735
|
-
|
|
3735
|
+
collectFeeAndReward(params: DlmmCollectRewardParams & DlmmCollectFeeParams): Promise<Transaction>;
|
|
3736
|
+
collectReward(params: DlmmCollectRewardParams, transaction?: Transaction): Promise<Transaction>;
|
|
3737
|
+
collectFees(params: DlmmCollectFeeParams, transaction?: Transaction): Promise<Transaction>;
|
|
3736
3738
|
createPairAddLiquidity(params: DlmmCreatePairAddLiquidityParams): Promise<Transaction>;
|
|
3737
3739
|
swap(params: DLMMSwapParams): Promise<Transaction>;
|
|
3738
3740
|
fetchBins(params: FetchBinsParams): Promise<EventBin[]>;
|
package/dist/index.js
CHANGED
|
@@ -10725,7 +10725,6 @@ var GaugeModule = class {
|
|
|
10725
10725
|
// src/modules/dlmm.ts
|
|
10726
10726
|
var import_transactions12 = require("@mysten/sui/transactions");
|
|
10727
10727
|
var import_calc_dlmm3 = require("@magmaprotocol/calc_dlmm");
|
|
10728
|
-
var import_decimal13 = __toESM(require("decimal.js"));
|
|
10729
10728
|
var DlmmModule = class {
|
|
10730
10729
|
_sdk;
|
|
10731
10730
|
_cache = {};
|
|
@@ -10750,7 +10749,9 @@ var DlmmModule = class {
|
|
|
10750
10749
|
coin_b: fields.y.fields.name,
|
|
10751
10750
|
base_factor: fields.params.fields.base_factor,
|
|
10752
10751
|
base_fee: fields.params.fields.base_factor / 1e4 * (fields.bin_step / 1e4),
|
|
10753
|
-
active_index: fields.params.fields.active_index
|
|
10752
|
+
active_index: fields.params.fields.active_index,
|
|
10753
|
+
coinAmountA: fields.reserve_x,
|
|
10754
|
+
coinAmountB: fields.reserve_y
|
|
10754
10755
|
});
|
|
10755
10756
|
});
|
|
10756
10757
|
return poolList;
|
|
@@ -10796,18 +10797,9 @@ var DlmmModule = class {
|
|
|
10796
10797
|
});
|
|
10797
10798
|
return res;
|
|
10798
10799
|
}
|
|
10799
|
-
// params price: input (b/(10^b_decimal))/(a/(10^a_decimal))
|
|
10800
|
-
price_to_storage_id(price, bin_step, tokenADecimal, tokenBDecimal) {
|
|
10801
|
-
const priceDec = new import_decimal13.default(price);
|
|
10802
|
-
const tenDec = new import_decimal13.default(10);
|
|
10803
|
-
const twoDec = new import_decimal13.default(2);
|
|
10804
|
-
const price_x128 = priceDec.mul(tenDec.pow(tokenBDecimal)).div(tenDec.pow(tokenADecimal)).mul(twoDec.pow(128));
|
|
10805
|
-
const active_id = (0, import_calc_dlmm3.get_real_id_from_price_x128)(price_x128.toFixed(0).toString(), bin_step);
|
|
10806
|
-
return (0, import_calc_dlmm3.get_storage_id_from_real_id)(active_id);
|
|
10807
|
-
}
|
|
10808
10800
|
// NOTE: x, y should be sorted
|
|
10809
10801
|
async createPairPayload(params) {
|
|
10810
|
-
const storage_id =
|
|
10802
|
+
const storage_id = (0, import_calc_dlmm3.get_storage_id_from_real_id)(BinMath.getBinIdFromPrice(params.priceTokenBPerTokenA, params.bin_step, params.coinADecimal, params.coinBDecimal));
|
|
10811
10803
|
const tx = new import_transactions12.Transaction();
|
|
10812
10804
|
tx.setSender(this.sdk.senderAddress);
|
|
10813
10805
|
const { clmm_pool, dlmm_pool, integrate } = this.sdk.sdkOptions;
|
|
@@ -10996,8 +10988,16 @@ var DlmmModule = class {
|
|
|
10996
10988
|
});
|
|
10997
10989
|
return tx;
|
|
10998
10990
|
}
|
|
10999
|
-
async
|
|
11000
|
-
|
|
10991
|
+
async collectFeeAndReward(params) {
|
|
10992
|
+
let tx = new import_transactions12.Transaction();
|
|
10993
|
+
tx = await this.collectFees(params);
|
|
10994
|
+
if (params.rewards_token.length > 0) {
|
|
10995
|
+
tx = await this.collectReward(params);
|
|
10996
|
+
}
|
|
10997
|
+
return tx;
|
|
10998
|
+
}
|
|
10999
|
+
async collectReward(params, transaction) {
|
|
11000
|
+
const tx = transaction || new import_transactions12.Transaction();
|
|
11001
11001
|
tx.setSender(this.sdk.senderAddress);
|
|
11002
11002
|
const { integrate, clmm_pool } = this.sdk.sdkOptions;
|
|
11003
11003
|
const clmmConfigs = getPackagerConfigs(clmm_pool);
|
|
@@ -11019,8 +11019,8 @@ var DlmmModule = class {
|
|
|
11019
11019
|
});
|
|
11020
11020
|
return tx;
|
|
11021
11021
|
}
|
|
11022
|
-
async collectFees(params) {
|
|
11023
|
-
const tx = new import_transactions12.Transaction();
|
|
11022
|
+
async collectFees(params, transaction) {
|
|
11023
|
+
const tx = transaction || new import_transactions12.Transaction();
|
|
11024
11024
|
tx.setSender(this.sdk.senderAddress);
|
|
11025
11025
|
const { integrate } = this.sdk.sdkOptions;
|
|
11026
11026
|
const typeArguments = [params.coin_a, params.coin_b];
|