@magmaprotocol/magma-clmm-sdk 0.5.93 → 0.5.95
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 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +90 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -11089,44 +11089,103 @@ var DlmmModule = class {
|
|
|
11089
11089
|
});
|
|
11090
11090
|
}
|
|
11091
11091
|
const pool_reward_coins = await this.getPairRewarders(_params);
|
|
11092
|
-
const
|
|
11093
|
-
const
|
|
11094
|
-
const
|
|
11092
|
+
const positionsLiquidityRes = [];
|
|
11093
|
+
const positionsRewardsRes = [];
|
|
11094
|
+
const positionsFeesRes = [];
|
|
11095
11095
|
for (const item of allPosition) {
|
|
11096
11096
|
const pool = poolList.find((pool2) => pool2.pool_id === item.pool);
|
|
11097
|
-
|
|
11098
|
-
|
|
11099
|
-
|
|
11100
|
-
|
|
11101
|
-
|
|
11102
|
-
|
|
11103
|
-
|
|
11104
|
-
|
|
11105
|
-
|
|
11097
|
+
const tx = new Transaction12();
|
|
11098
|
+
this._getPositionLiquidity(
|
|
11099
|
+
{
|
|
11100
|
+
pair: item.pool,
|
|
11101
|
+
positionId: item.pos_object_id,
|
|
11102
|
+
coinTypeA: pool.coin_a,
|
|
11103
|
+
coinTypeB: pool.coin_b
|
|
11104
|
+
},
|
|
11105
|
+
tx
|
|
11106
|
+
);
|
|
11107
|
+
if (pool_reward_coins.has(item.pool) && pool_reward_coins.get(item.pool)?.length !== 0) {
|
|
11108
|
+
this._getEarnedRewards(
|
|
11109
|
+
{
|
|
11110
|
+
pool_id: item.pool,
|
|
11111
|
+
position_id: item.pos_object_id,
|
|
11112
|
+
coin_a: pool.coin_a,
|
|
11113
|
+
coin_b: pool.coin_b,
|
|
11114
|
+
rewards_token: pool_reward_coins.get(item.pool) || []
|
|
11115
|
+
},
|
|
11116
|
+
tx
|
|
11117
|
+
);
|
|
11118
|
+
}
|
|
11119
|
+
this._getEarnedFees(
|
|
11120
|
+
{
|
|
11106
11121
|
pool_id: item.pool,
|
|
11107
11122
|
position_id: item.pos_object_id,
|
|
11108
11123
|
coin_a: pool.coin_a,
|
|
11109
|
-
coin_b: pool.coin_b
|
|
11110
|
-
|
|
11111
|
-
|
|
11112
|
-
|
|
11113
|
-
|
|
11114
|
-
|
|
11115
|
-
|
|
11116
|
-
|
|
11117
|
-
|
|
11124
|
+
coin_b: pool.coin_b
|
|
11125
|
+
},
|
|
11126
|
+
tx
|
|
11127
|
+
);
|
|
11128
|
+
const { simulationAccount } = this.sdk.sdkOptions;
|
|
11129
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
11130
|
+
transactionBlock: tx,
|
|
11131
|
+
sender: simulationAccount.address
|
|
11132
|
+
});
|
|
11133
|
+
if (simulateRes.error != null) {
|
|
11134
|
+
throw new Error(`fetchPositionLiquidity error code: ${simulateRes.error ?? "unknown error"}`);
|
|
11135
|
+
}
|
|
11136
|
+
simulateRes.events?.forEach((item2) => {
|
|
11137
|
+
if (extractStructTagFromType(item2.type).name === `EventPositionLiquidity`) {
|
|
11138
|
+
positionsLiquidityRes.push({
|
|
11139
|
+
position_id: item2.parsedJson.position_id,
|
|
11140
|
+
shares: item2.parsedJson.shares,
|
|
11141
|
+
liquidity: item2.parsedJson.liquidity,
|
|
11142
|
+
x_equivalent: item2.parsedJson.x_equivalent,
|
|
11143
|
+
y_equivalent: item2.parsedJson.y_equivalent,
|
|
11144
|
+
bin_real_ids: item2.parsedJson.bin_ids.map((id) => get_real_id(id)),
|
|
11145
|
+
bin_x_eq: item2.parsedJson.bin_x_eq,
|
|
11146
|
+
bin_y_eq: item2.parsedJson.bin_y_eq,
|
|
11147
|
+
bin_liquidity: item2.parsedJson.bin_liquidity
|
|
11148
|
+
});
|
|
11149
|
+
}
|
|
11150
|
+
if (extractStructTagFromType(item2.type).name === `EventEarnedFees`) {
|
|
11151
|
+
positionsFeesRes.push({
|
|
11152
|
+
position_id: item2.parsedJson.position_id,
|
|
11153
|
+
x: item2.parsedJson.x.name,
|
|
11154
|
+
y: item2.parsedJson.y.name,
|
|
11155
|
+
fee_x: item2.parsedJson.fee_x,
|
|
11156
|
+
fee_y: item2.parsedJson.fee_y
|
|
11157
|
+
});
|
|
11158
|
+
}
|
|
11159
|
+
if (extractStructTagFromType(item2.type).name === `EventEarnedRewards`) {
|
|
11160
|
+
positionsRewardsRes.push({
|
|
11161
|
+
position_id: item2.parsedJson.position_id,
|
|
11162
|
+
reward: [item2.parsedJson.reward.name],
|
|
11163
|
+
amount: [item2.parsedJson.amount]
|
|
11164
|
+
});
|
|
11165
|
+
}
|
|
11166
|
+
if (extractStructTagFromType(item2.type).name === `EventEarnedRewards2`) {
|
|
11167
|
+
positionsRewardsRes.push({
|
|
11168
|
+
position_id: item2.parsedJson.position_id,
|
|
11169
|
+
reward: [item2.parsedJson.reward1.name, item2.parsedJson.reward2.name],
|
|
11170
|
+
amount: [item2.parsedJson.amount1, item2.parsedJson.amount2]
|
|
11171
|
+
});
|
|
11172
|
+
}
|
|
11173
|
+
if (extractStructTagFromType(item2.type).name === `EventEarnedRewards3`) {
|
|
11174
|
+
positionsRewardsRes.push({
|
|
11175
|
+
position_id: item2.parsedJson.position_id,
|
|
11176
|
+
reward: [item2.parsedJson.reward1.name, item2.parsedJson.reward2.name, item2.parsedJson.reward3.name],
|
|
11177
|
+
amount: [item2.parsedJson.amount1, item2.parsedJson.amount2, item2.parsedJson.amount3]
|
|
11178
|
+
});
|
|
11179
|
+
}
|
|
11118
11180
|
});
|
|
11119
11181
|
}
|
|
11120
|
-
const positionsLiquidity = await this.getPositionsLiquidityLimit(positionLiquidityParams);
|
|
11121
|
-
const positionsRewards = await this.getEarnedRewards(dlmmRewardsParams);
|
|
11122
|
-
const positionsFees = await this.getEarnedFeesLimit(dlmmCollectFeeParams);
|
|
11123
11182
|
const out = [];
|
|
11124
11183
|
for (let i = 0; i < allPosition.length; i++) {
|
|
11125
11184
|
const item = allPosition[i];
|
|
11126
11185
|
const pool = poolList.find((pool2) => pool2.pool_id === item.pool);
|
|
11127
|
-
const positionLiquidity =
|
|
11128
|
-
const positionRewards =
|
|
11129
|
-
const positionFees =
|
|
11186
|
+
const positionLiquidity = positionsLiquidityRes.find((liquidity) => liquidity.position_id === item.pos_object_id);
|
|
11187
|
+
const positionRewards = positionsRewardsRes.find((rewards) => rewards.position_id === item.pos_object_id);
|
|
11188
|
+
const positionFees = positionsFeesRes.find((fees) => fees.position_id === item.pos_object_id);
|
|
11130
11189
|
out.push({
|
|
11131
11190
|
position: allPosition[i],
|
|
11132
11191
|
liquidity: positionLiquidity,
|
|
@@ -11282,7 +11341,6 @@ var DlmmModule = class {
|
|
|
11282
11341
|
return out;
|
|
11283
11342
|
}
|
|
11284
11343
|
async getEarnedFees(params) {
|
|
11285
|
-
console.log("############ params: ", params);
|
|
11286
11344
|
let tx = new Transaction12();
|
|
11287
11345
|
for (const param of params) {
|
|
11288
11346
|
tx = await this._getEarnedFees(param, tx);
|
|
@@ -11327,7 +11385,9 @@ var DlmmModule = class {
|
|
|
11327
11385
|
async getEarnedRewards(params) {
|
|
11328
11386
|
let tx = new Transaction12();
|
|
11329
11387
|
for (const param of params) {
|
|
11330
|
-
|
|
11388
|
+
if (param.rewards_token.length !== 0) {
|
|
11389
|
+
tx = await this._getEarnedRewards(param, tx);
|
|
11390
|
+
}
|
|
11331
11391
|
}
|
|
11332
11392
|
return this._parseEarnedRewards(tx);
|
|
11333
11393
|
}
|
|
@@ -11798,7 +11858,7 @@ var clmmMainnet = {
|
|
|
11798
11858
|
},
|
|
11799
11859
|
integrate: {
|
|
11800
11860
|
package_id: "0x2e704d8afc1d6d7f154dee337cc14c153f6f9ce1708213e5dc04a32afe0e45f1",
|
|
11801
|
-
published_at: "
|
|
11861
|
+
published_at: "0x49e9f06c58a36830fe0d83291f002012e72b00a4ec9b3a6304c40fc5712bb6e3"
|
|
11802
11862
|
},
|
|
11803
11863
|
deepbook: {
|
|
11804
11864
|
package_id: "0x000000000000000000000000000000000000000000000000000000000000dee9",
|