@magmaprotocol/magma-clmm-sdk 0.5.90 → 0.5.92
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 -2
- package/dist/index.js +39 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -10471,7 +10471,7 @@ var DlmmModule = class {
|
|
|
10471
10471
|
sender: simulationAccount.address
|
|
10472
10472
|
});
|
|
10473
10473
|
if (simulateRes.error != null) {
|
|
10474
|
-
throw new Error(`
|
|
10474
|
+
throw new Error(`fetchPairParams error code: ${simulateRes.error ?? "unknown error"}`);
|
|
10475
10475
|
}
|
|
10476
10476
|
let res = {
|
|
10477
10477
|
base_factor: 0,
|
|
@@ -10970,7 +10970,7 @@ var DlmmModule = class {
|
|
|
10970
10970
|
sender: simulationAccount.address
|
|
10971
10971
|
});
|
|
10972
10972
|
if (simulateRes.error != null) {
|
|
10973
|
-
throw new Error(`
|
|
10973
|
+
throw new Error(`swap code: ${simulateRes.error ?? "unknown error"}`);
|
|
10974
10974
|
}
|
|
10975
10975
|
let res = [];
|
|
10976
10976
|
simulateRes.events?.forEach((item) => {
|
|
@@ -11066,7 +11066,7 @@ var DlmmModule = class {
|
|
|
11066
11066
|
const cacheKey = `${position.pos_object_id}_getPositionList`;
|
|
11067
11067
|
this.updateCache(cacheKey, position, cacheTime24h);
|
|
11068
11068
|
if (hasAssignPoolIds) {
|
|
11069
|
-
if (assignPoolIds.includes(position.
|
|
11069
|
+
if (assignPoolIds.includes(position.pos_object_id)) {
|
|
11070
11070
|
allPosition.push(position);
|
|
11071
11071
|
}
|
|
11072
11072
|
} else {
|
|
@@ -11117,9 +11117,9 @@ var DlmmModule = class {
|
|
|
11117
11117
|
coin_b: pool.coin_b
|
|
11118
11118
|
});
|
|
11119
11119
|
}
|
|
11120
|
-
const positionsLiquidity = await this.
|
|
11120
|
+
const positionsLiquidity = await this.getPositionsLiquidityLimit(positionLiquidityParams);
|
|
11121
11121
|
const positionsRewards = await this.getEarnedRewards(dlmmRewardsParams);
|
|
11122
|
-
const positionsFees = await this.
|
|
11122
|
+
const positionsFees = await this.getEarnedFeesLimit(dlmmCollectFeeParams);
|
|
11123
11123
|
const out = [];
|
|
11124
11124
|
for (let i = 0; i < allPosition.length; i++) {
|
|
11125
11125
|
const item = allPosition[i];
|
|
@@ -11168,7 +11168,21 @@ var DlmmModule = class {
|
|
|
11168
11168
|
buildPositionType() {
|
|
11169
11169
|
return `${this._sdk.sdkOptions.dlmm_pool.package_id}::dlmm_position::Position`;
|
|
11170
11170
|
}
|
|
11171
|
-
async
|
|
11171
|
+
async getPositionsLiquidityLimit(params) {
|
|
11172
|
+
const out = [];
|
|
11173
|
+
const limit = 2;
|
|
11174
|
+
for (let i = 0; i < params.length; i += limit) {
|
|
11175
|
+
if (i + limit >= params.length) {
|
|
11176
|
+
const res2 = await this.getPositionsLiquidity(params.slice(i, params.length));
|
|
11177
|
+
out.push(...res2);
|
|
11178
|
+
return out;
|
|
11179
|
+
}
|
|
11180
|
+
const res = await this.getPositionsLiquidity(params.slice(i, i + limit));
|
|
11181
|
+
out.push(...res);
|
|
11182
|
+
}
|
|
11183
|
+
return out;
|
|
11184
|
+
}
|
|
11185
|
+
async getPositionsLiquidity(params) {
|
|
11172
11186
|
let tx = new Transaction12();
|
|
11173
11187
|
for (const param of params) {
|
|
11174
11188
|
tx = await this._getPositionLiquidity(param, tx);
|
|
@@ -11194,7 +11208,7 @@ var DlmmModule = class {
|
|
|
11194
11208
|
sender: simulationAccount.address
|
|
11195
11209
|
});
|
|
11196
11210
|
if (simulateRes.error != null) {
|
|
11197
|
-
throw new Error(`
|
|
11211
|
+
throw new Error(`fetchPositionLiquidity error code: ${simulateRes.error ?? "unknown error"}`);
|
|
11198
11212
|
}
|
|
11199
11213
|
const out = [];
|
|
11200
11214
|
simulateRes.events?.forEach((item) => {
|
|
@@ -11229,7 +11243,7 @@ var DlmmModule = class {
|
|
|
11229
11243
|
sender: simulationAccount.address
|
|
11230
11244
|
});
|
|
11231
11245
|
if (simulateRes.error != null) {
|
|
11232
|
-
throw new Error(`
|
|
11246
|
+
throw new Error(`getPairLiquidity error code: ${simulateRes.error ?? "unknown error"}`);
|
|
11233
11247
|
}
|
|
11234
11248
|
const out = {
|
|
11235
11249
|
shares: 0,
|
|
@@ -11253,7 +11267,22 @@ var DlmmModule = class {
|
|
|
11253
11267
|
});
|
|
11254
11268
|
return out;
|
|
11255
11269
|
}
|
|
11270
|
+
async getEarnedFeesLimit(params) {
|
|
11271
|
+
const out = [];
|
|
11272
|
+
const limit = 2;
|
|
11273
|
+
for (let i = 0; i < params.length; i += limit) {
|
|
11274
|
+
if (i + limit >= params.length) {
|
|
11275
|
+
const res2 = await this.getEarnedFees(params.slice(i, params.length));
|
|
11276
|
+
out.push(...res2);
|
|
11277
|
+
return out;
|
|
11278
|
+
}
|
|
11279
|
+
const res = await this.getEarnedFees(params.slice(i, i + limit));
|
|
11280
|
+
out.push(...res);
|
|
11281
|
+
}
|
|
11282
|
+
return out;
|
|
11283
|
+
}
|
|
11256
11284
|
async getEarnedFees(params) {
|
|
11285
|
+
console.log("############ params: ", params);
|
|
11257
11286
|
let tx = new Transaction12();
|
|
11258
11287
|
for (const param of params) {
|
|
11259
11288
|
tx = await this._getEarnedFees(param, tx);
|
|
@@ -11353,6 +11382,7 @@ var DlmmModule = class {
|
|
|
11353
11382
|
}
|
|
11354
11383
|
// return pool_id => reward_tokens
|
|
11355
11384
|
async getPairRewarders(params) {
|
|
11385
|
+
params = [params[0]];
|
|
11356
11386
|
let tx = new Transaction12();
|
|
11357
11387
|
for (const param of params) {
|
|
11358
11388
|
tx = await this._getPairRewarders(param, tx);
|
|
@@ -11379,7 +11409,7 @@ var DlmmModule = class {
|
|
|
11379
11409
|
});
|
|
11380
11410
|
const out = /* @__PURE__ */ new Map();
|
|
11381
11411
|
if (simulateRes.error != null) {
|
|
11382
|
-
throw new Error(`
|
|
11412
|
+
throw new Error(`getPairReward error code: ${simulateRes.error ?? "unknown error"}`);
|
|
11383
11413
|
}
|
|
11384
11414
|
simulateRes.events?.forEach((item) => {
|
|
11385
11415
|
if (extractStructTagFromType(item.type).name === `EventPairRewardTypes`) {
|