@magmaprotocol/magma-clmm-sdk 0.5.93 → 0.5.94
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 +90 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +90 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11302,44 +11302,103 @@ var DlmmModule = class {
|
|
|
11302
11302
|
});
|
|
11303
11303
|
}
|
|
11304
11304
|
const pool_reward_coins = await this.getPairRewarders(_params);
|
|
11305
|
-
const
|
|
11306
|
-
const
|
|
11307
|
-
const
|
|
11305
|
+
const positionsLiquidityRes = [];
|
|
11306
|
+
const positionsRewardsRes = [];
|
|
11307
|
+
const positionsFeesRes = [];
|
|
11308
11308
|
for (const item of allPosition) {
|
|
11309
11309
|
const pool = poolList.find((pool2) => pool2.pool_id === item.pool);
|
|
11310
|
-
|
|
11311
|
-
|
|
11312
|
-
|
|
11313
|
-
|
|
11314
|
-
|
|
11315
|
-
|
|
11316
|
-
|
|
11317
|
-
|
|
11318
|
-
|
|
11310
|
+
const tx = new import_transactions12.Transaction();
|
|
11311
|
+
this._getPositionLiquidity(
|
|
11312
|
+
{
|
|
11313
|
+
pair: item.pool,
|
|
11314
|
+
positionId: item.pos_object_id,
|
|
11315
|
+
coinTypeA: pool.coin_a,
|
|
11316
|
+
coinTypeB: pool.coin_b
|
|
11317
|
+
},
|
|
11318
|
+
tx
|
|
11319
|
+
);
|
|
11320
|
+
if (pool_reward_coins.has(item.pool) && pool_reward_coins.get(item.pool)?.length !== 0) {
|
|
11321
|
+
this._getEarnedRewards(
|
|
11322
|
+
{
|
|
11323
|
+
pool_id: item.pool,
|
|
11324
|
+
position_id: item.pos_object_id,
|
|
11325
|
+
coin_a: pool.coin_a,
|
|
11326
|
+
coin_b: pool.coin_b,
|
|
11327
|
+
rewards_token: pool_reward_coins.get(item.pool) || []
|
|
11328
|
+
},
|
|
11329
|
+
tx
|
|
11330
|
+
);
|
|
11331
|
+
}
|
|
11332
|
+
this._getEarnedFees(
|
|
11333
|
+
{
|
|
11319
11334
|
pool_id: item.pool,
|
|
11320
11335
|
position_id: item.pos_object_id,
|
|
11321
11336
|
coin_a: pool.coin_a,
|
|
11322
|
-
coin_b: pool.coin_b
|
|
11323
|
-
|
|
11324
|
-
|
|
11325
|
-
|
|
11326
|
-
|
|
11327
|
-
|
|
11328
|
-
|
|
11329
|
-
|
|
11330
|
-
|
|
11337
|
+
coin_b: pool.coin_b
|
|
11338
|
+
},
|
|
11339
|
+
tx
|
|
11340
|
+
);
|
|
11341
|
+
const { simulationAccount } = this.sdk.sdkOptions;
|
|
11342
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
11343
|
+
transactionBlock: tx,
|
|
11344
|
+
sender: simulationAccount.address
|
|
11345
|
+
});
|
|
11346
|
+
if (simulateRes.error != null) {
|
|
11347
|
+
throw new Error(`fetchPositionLiquidity error code: ${simulateRes.error ?? "unknown error"}`);
|
|
11348
|
+
}
|
|
11349
|
+
simulateRes.events?.forEach((item2) => {
|
|
11350
|
+
if (extractStructTagFromType(item2.type).name === `EventPositionLiquidity`) {
|
|
11351
|
+
positionsLiquidityRes.push({
|
|
11352
|
+
position_id: item2.parsedJson.position_id,
|
|
11353
|
+
shares: item2.parsedJson.shares,
|
|
11354
|
+
liquidity: item2.parsedJson.liquidity,
|
|
11355
|
+
x_equivalent: item2.parsedJson.x_equivalent,
|
|
11356
|
+
y_equivalent: item2.parsedJson.y_equivalent,
|
|
11357
|
+
bin_real_ids: item2.parsedJson.bin_ids.map((id) => (0, import_calc_dlmm3.get_real_id)(id)),
|
|
11358
|
+
bin_x_eq: item2.parsedJson.bin_x_eq,
|
|
11359
|
+
bin_y_eq: item2.parsedJson.bin_y_eq,
|
|
11360
|
+
bin_liquidity: item2.parsedJson.bin_liquidity
|
|
11361
|
+
});
|
|
11362
|
+
}
|
|
11363
|
+
if (extractStructTagFromType(item2.type).name === `EventEarnedFees`) {
|
|
11364
|
+
positionsFeesRes.push({
|
|
11365
|
+
position_id: item2.parsedJson.position_id,
|
|
11366
|
+
x: item2.parsedJson.x.name,
|
|
11367
|
+
y: item2.parsedJson.y.name,
|
|
11368
|
+
fee_x: item2.parsedJson.fee_x,
|
|
11369
|
+
fee_y: item2.parsedJson.fee_y
|
|
11370
|
+
});
|
|
11371
|
+
}
|
|
11372
|
+
if (extractStructTagFromType(item2.type).name === `EventEarnedRewards`) {
|
|
11373
|
+
positionsRewardsRes.push({
|
|
11374
|
+
position_id: item2.parsedJson.position_id,
|
|
11375
|
+
reward: [item2.parsedJson.reward.name],
|
|
11376
|
+
amount: [item2.parsedJson.amount]
|
|
11377
|
+
});
|
|
11378
|
+
}
|
|
11379
|
+
if (extractStructTagFromType(item2.type).name === `EventEarnedRewards2`) {
|
|
11380
|
+
positionsRewardsRes.push({
|
|
11381
|
+
position_id: item2.parsedJson.position_id,
|
|
11382
|
+
reward: [item2.parsedJson.reward1.name, item2.parsedJson.reward2.name],
|
|
11383
|
+
amount: [item2.parsedJson.amount1, item2.parsedJson.amount2]
|
|
11384
|
+
});
|
|
11385
|
+
}
|
|
11386
|
+
if (extractStructTagFromType(item2.type).name === `EventEarnedRewards3`) {
|
|
11387
|
+
positionsRewardsRes.push({
|
|
11388
|
+
position_id: item2.parsedJson.position_id,
|
|
11389
|
+
reward: [item2.parsedJson.reward1.name, item2.parsedJson.reward2.name, item2.parsedJson.reward3.name],
|
|
11390
|
+
amount: [item2.parsedJson.amount1, item2.parsedJson.amount2, item2.parsedJson.amount3]
|
|
11391
|
+
});
|
|
11392
|
+
}
|
|
11331
11393
|
});
|
|
11332
11394
|
}
|
|
11333
|
-
const positionsLiquidity = await this.getPositionsLiquidityLimit(positionLiquidityParams);
|
|
11334
|
-
const positionsRewards = await this.getEarnedRewards(dlmmRewardsParams);
|
|
11335
|
-
const positionsFees = await this.getEarnedFeesLimit(dlmmCollectFeeParams);
|
|
11336
11395
|
const out = [];
|
|
11337
11396
|
for (let i = 0; i < allPosition.length; i++) {
|
|
11338
11397
|
const item = allPosition[i];
|
|
11339
11398
|
const pool = poolList.find((pool2) => pool2.pool_id === item.pool);
|
|
11340
|
-
const positionLiquidity =
|
|
11341
|
-
const positionRewards =
|
|
11342
|
-
const positionFees =
|
|
11399
|
+
const positionLiquidity = positionsLiquidityRes.find((liquidity) => liquidity.position_id === item.pos_object_id);
|
|
11400
|
+
const positionRewards = positionsRewardsRes.find((rewards) => rewards.position_id === item.pos_object_id);
|
|
11401
|
+
const positionFees = positionsFeesRes.find((fees) => fees.position_id === item.pos_object_id);
|
|
11343
11402
|
out.push({
|
|
11344
11403
|
position: allPosition[i],
|
|
11345
11404
|
liquidity: positionLiquidity,
|
|
@@ -11495,7 +11554,6 @@ var DlmmModule = class {
|
|
|
11495
11554
|
return out;
|
|
11496
11555
|
}
|
|
11497
11556
|
async getEarnedFees(params) {
|
|
11498
|
-
console.log("############ params: ", params);
|
|
11499
11557
|
let tx = new import_transactions12.Transaction();
|
|
11500
11558
|
for (const param of params) {
|
|
11501
11559
|
tx = await this._getEarnedFees(param, tx);
|
|
@@ -11540,7 +11598,9 @@ var DlmmModule = class {
|
|
|
11540
11598
|
async getEarnedRewards(params) {
|
|
11541
11599
|
let tx = new import_transactions12.Transaction();
|
|
11542
11600
|
for (const param of params) {
|
|
11543
|
-
|
|
11601
|
+
if (param.rewards_token.length !== 0) {
|
|
11602
|
+
tx = await this._getEarnedRewards(param, tx);
|
|
11603
|
+
}
|
|
11544
11604
|
}
|
|
11545
11605
|
return this._parseEarnedRewards(tx);
|
|
11546
11606
|
}
|
|
@@ -12012,6 +12072,7 @@ var clmmMainnet = {
|
|
|
12012
12072
|
integrate: {
|
|
12013
12073
|
package_id: "0x2e704d8afc1d6d7f154dee337cc14c153f6f9ce1708213e5dc04a32afe0e45f1",
|
|
12014
12074
|
published_at: "0x2e704d8afc1d6d7f154dee337cc14c153f6f9ce1708213e5dc04a32afe0e45f1"
|
|
12075
|
+
// published_at: '0xc9f008794e70543443bb49bc9719120a6d43bb2cf6b522ec924f495a36b7e69e',
|
|
12015
12076
|
},
|
|
12016
12077
|
deepbook: {
|
|
12017
12078
|
package_id: "0x000000000000000000000000000000000000000000000000000000000000dee9",
|