@magmaprotocol/magma-clmm-sdk 0.5.62 → 0.5.63
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 +7 -0
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3736,6 +3736,13 @@ declare class DlmmModule implements IModule {
|
|
|
3736
3736
|
createPairAddLiquidity(params: DlmmCreatePairAddLiquidityParams): Promise<Transaction>;
|
|
3737
3737
|
swap(params: DLMMSwapParams): Promise<Transaction>;
|
|
3738
3738
|
fetchBins(params: FetchBinsParams): Promise<EventBin[]>;
|
|
3739
|
+
/**
|
|
3740
|
+
* Gets a list of positions for the given account address.
|
|
3741
|
+
* @param accountAddress The account address to get positions for.
|
|
3742
|
+
* @param assignPoolIds An array of pool IDs to filter the positions by.
|
|
3743
|
+
* @returns array of Position objects.
|
|
3744
|
+
*/
|
|
3745
|
+
getUserPositionById(positionId: string, showDisplay?: boolean): Promise<DlmmPositionInfo>;
|
|
3739
3746
|
/**
|
|
3740
3747
|
* Gets a list of positions for the given account address.
|
|
3741
3748
|
* @param accountAddress The account address to get positions for.
|
package/dist/index.js
CHANGED
|
@@ -11115,6 +11115,65 @@ var DlmmModule = class {
|
|
|
11115
11115
|
});
|
|
11116
11116
|
return res;
|
|
11117
11117
|
}
|
|
11118
|
+
/**
|
|
11119
|
+
* Gets a list of positions for the given account address.
|
|
11120
|
+
* @param accountAddress The account address to get positions for.
|
|
11121
|
+
* @param assignPoolIds An array of pool IDs to filter the positions by.
|
|
11122
|
+
* @returns array of Position objects.
|
|
11123
|
+
*/
|
|
11124
|
+
async getUserPositionById(positionId, showDisplay = true) {
|
|
11125
|
+
let position;
|
|
11126
|
+
const ownerRes = await this._sdk.fullClient.getObject({
|
|
11127
|
+
id: positionId,
|
|
11128
|
+
options: { showContent: true, showType: true, showDisplay, showOwner: true }
|
|
11129
|
+
});
|
|
11130
|
+
const type = extractStructTagFromType(ownerRes.data.type);
|
|
11131
|
+
if (type.full_address === this.buildPositionType()) {
|
|
11132
|
+
position = this.buildPosition(ownerRes.data);
|
|
11133
|
+
} else {
|
|
11134
|
+
throw new ClmmpoolsError(`Dlmm Position not exists. Get Position error:${ownerRes.error}`, "InvalidPositionObject" /* InvalidPositionObject */);
|
|
11135
|
+
}
|
|
11136
|
+
const poolMap = /* @__PURE__ */ new Set();
|
|
11137
|
+
poolMap.add(position.pool);
|
|
11138
|
+
const pool = (await this.getPoolInfo(Array.from(poolMap)))[0];
|
|
11139
|
+
const _params = [];
|
|
11140
|
+
_params.push({
|
|
11141
|
+
pool_id: pool.pool_id,
|
|
11142
|
+
coin_a: pool.coin_a,
|
|
11143
|
+
coin_b: pool.coin_b
|
|
11144
|
+
});
|
|
11145
|
+
const pool_reward_coins = await this.getPairRewarders(_params);
|
|
11146
|
+
const positionLiquidity = await this.getPositionLiquidity({
|
|
11147
|
+
pair: position.pool,
|
|
11148
|
+
positionId: position.pos_object_id,
|
|
11149
|
+
coinTypeA: pool?.coin_a,
|
|
11150
|
+
coinTypeB: pool?.coin_b
|
|
11151
|
+
});
|
|
11152
|
+
const rewards_token = pool_reward_coins.get(position.pool) || [];
|
|
11153
|
+
let positionRewards = { position_id: position.pos_object_id, reward: [], amount: [] };
|
|
11154
|
+
if (rewards_token.length > 0) {
|
|
11155
|
+
positionRewards = await this.getEarnedRewards({
|
|
11156
|
+
pool_id: position.pool,
|
|
11157
|
+
position_id: position.pos_object_id,
|
|
11158
|
+
coin_a: pool?.coin_a,
|
|
11159
|
+
coin_b: pool?.coin_b,
|
|
11160
|
+
rewards_token: pool_reward_coins.get(position.pool) || []
|
|
11161
|
+
});
|
|
11162
|
+
}
|
|
11163
|
+
const positionFees = await this.getEarnedFees({
|
|
11164
|
+
pool_id: position.pool,
|
|
11165
|
+
position_id: position.pos_object_id,
|
|
11166
|
+
coin_a: pool?.coin_a,
|
|
11167
|
+
coin_b: pool?.coin_b
|
|
11168
|
+
});
|
|
11169
|
+
return {
|
|
11170
|
+
position,
|
|
11171
|
+
liquidity: positionLiquidity,
|
|
11172
|
+
rewards: positionRewards,
|
|
11173
|
+
fees: positionFees,
|
|
11174
|
+
contractPool: pool
|
|
11175
|
+
};
|
|
11176
|
+
}
|
|
11118
11177
|
/**
|
|
11119
11178
|
* Gets a list of positions for the given account address.
|
|
11120
11179
|
* @param accountAddress The account address to get positions for.
|