@magmaprotocol/magma-clmm-sdk 0.5.111 → 0.5.113
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 +8 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3790,6 +3790,13 @@ declare class AlmmModule implements IModule {
|
|
|
3790
3790
|
createPairAddLiquidity(params: AlmmCreatePairAddLiquidityParams): Promise<Transaction>;
|
|
3791
3791
|
swap(params: ALMMSwapParams): Promise<Transaction>;
|
|
3792
3792
|
fetchBins(params: FetchBinsParams): Promise<EventBin[]>;
|
|
3793
|
+
/**
|
|
3794
|
+
* Gets a list of positions for the given account address.
|
|
3795
|
+
* @param positionId The account address to get positions for.
|
|
3796
|
+
* @param assignPoolIds An array of pool IDs to filter the positions by.
|
|
3797
|
+
* @returns array of Position objects.
|
|
3798
|
+
*/
|
|
3799
|
+
getUserPositionById(positionId: string, showDisplay?: boolean): Promise<AlmmPositionInfo[]>;
|
|
3793
3800
|
/**
|
|
3794
3801
|
* Gets a list of positions for the given account address.
|
|
3795
3802
|
* @param accountAddress The account address to get positions for.
|
|
@@ -3797,6 +3804,7 @@ declare class AlmmModule implements IModule {
|
|
|
3797
3804
|
* @returns array of Position objects.
|
|
3798
3805
|
*/
|
|
3799
3806
|
getUserPositions(accountAddress: string, assignPoolIds?: string[], showDisplay?: boolean): Promise<AlmmPositionInfo[]>;
|
|
3807
|
+
private getUserPositionInfo;
|
|
3800
3808
|
private buildPosition;
|
|
3801
3809
|
private getPoolCoins;
|
|
3802
3810
|
private buildPositionType;
|
package/dist/index.js
CHANGED
|
@@ -11296,6 +11296,27 @@ var AlmmModule = class {
|
|
|
11296
11296
|
// contractPool: pool,
|
|
11297
11297
|
// }
|
|
11298
11298
|
// }
|
|
11299
|
+
/**
|
|
11300
|
+
* Gets a list of positions for the given account address.
|
|
11301
|
+
* @param positionId The account address to get positions for.
|
|
11302
|
+
* @param assignPoolIds An array of pool IDs to filter the positions by.
|
|
11303
|
+
* @returns array of Position objects.
|
|
11304
|
+
*/
|
|
11305
|
+
async getUserPositionById(positionId, showDisplay = true) {
|
|
11306
|
+
let allPosition = [];
|
|
11307
|
+
const ownerRes = await this._sdk.fullClient.getObject({
|
|
11308
|
+
id: positionId,
|
|
11309
|
+
options: { showContent: true, showType: true, showDisplay, showOwner: true }
|
|
11310
|
+
});
|
|
11311
|
+
const type = extractStructTagFromType(ownerRes.data.type);
|
|
11312
|
+
if (type.full_address === this.buildPositionType()) {
|
|
11313
|
+
const position = this.buildPosition(ownerRes.data);
|
|
11314
|
+
const cacheKey = `${position.pos_object_id}_getPositionList`;
|
|
11315
|
+
this.updateCache(cacheKey, position, cacheTime24h);
|
|
11316
|
+
allPosition.push(position);
|
|
11317
|
+
}
|
|
11318
|
+
return await this.getUserPositionInfo(allPosition);
|
|
11319
|
+
}
|
|
11299
11320
|
/**
|
|
11300
11321
|
* Gets a list of positions for the given account address.
|
|
11301
11322
|
* @param accountAddress The account address to get positions for.
|
|
@@ -11324,6 +11345,9 @@ var AlmmModule = class {
|
|
|
11324
11345
|
}
|
|
11325
11346
|
}
|
|
11326
11347
|
}
|
|
11348
|
+
return this.getUserPositionInfo(allPosition);
|
|
11349
|
+
}
|
|
11350
|
+
async getUserPositionInfo(allPosition) {
|
|
11327
11351
|
const poolMap = /* @__PURE__ */ new Set();
|
|
11328
11352
|
for (const item of allPosition) {
|
|
11329
11353
|
poolMap.add(item.pool);
|