@magmaprotocol/magma-clmm-sdk 0.5.111 → 0.5.112
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 +26 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -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,29 @@ 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
|
+
for (const item of ownerRes.data) {
|
|
11312
|
+
const type = extractStructTagFromType(item.data.type);
|
|
11313
|
+
if (type.full_address === this.buildPositionType()) {
|
|
11314
|
+
const position = this.buildPosition(item);
|
|
11315
|
+
const cacheKey = `${position.pos_object_id}_getPositionList`;
|
|
11316
|
+
this.updateCache(cacheKey, position, cacheTime24h);
|
|
11317
|
+
allPosition.push(position);
|
|
11318
|
+
}
|
|
11319
|
+
}
|
|
11320
|
+
return await this.getUserPositionInfo(allPosition);
|
|
11321
|
+
}
|
|
11299
11322
|
/**
|
|
11300
11323
|
* Gets a list of positions for the given account address.
|
|
11301
11324
|
* @param accountAddress The account address to get positions for.
|
|
@@ -11324,6 +11347,9 @@ var AlmmModule = class {
|
|
|
11324
11347
|
}
|
|
11325
11348
|
}
|
|
11326
11349
|
}
|
|
11350
|
+
return this.getUserPositionInfo(allPosition);
|
|
11351
|
+
}
|
|
11352
|
+
async getUserPositionInfo(allPosition) {
|
|
11327
11353
|
const poolMap = /* @__PURE__ */ new Set();
|
|
11328
11354
|
for (const item of allPosition) {
|
|
11329
11355
|
poolMap.add(item.pool);
|