@liquidium/client 0.6.0-rc.1 → 0.6.0-rc.2
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.cjs +33 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -4
- package/dist/index.d.ts +9 -4
- package/dist/index.js +33 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -440,9 +440,9 @@ interface LiquidiumStatus {
|
|
|
440
440
|
operation: LiquidiumOperation;
|
|
441
441
|
/** Current lifecycle state for the operation. */
|
|
442
442
|
state: LiquidiumState;
|
|
443
|
-
/**
|
|
443
|
+
/** Confirmation progress while confirming, capped at the required count. */
|
|
444
444
|
confirmations: number | null;
|
|
445
|
-
/** Required confirmations,
|
|
445
|
+
/** Required confirmations while confirming, otherwise null. */
|
|
446
446
|
requiredConfirmations: number | null;
|
|
447
447
|
}
|
|
448
448
|
|
|
@@ -1346,10 +1346,11 @@ declare class PositionsModule {
|
|
|
1346
1346
|
*/
|
|
1347
1347
|
getPosition(profileId: string, poolId: string): Promise<Position | null>;
|
|
1348
1348
|
/**
|
|
1349
|
-
* Lists
|
|
1349
|
+
* Lists visible positions for a profile. Supply balances below their pool's
|
|
1350
|
+
* same-asset dust threshold are hidden without removing active debt.
|
|
1350
1351
|
*
|
|
1351
1352
|
* @param profileId - The Liquidium profile principal text.
|
|
1352
|
-
* @returns
|
|
1353
|
+
* @returns Visible positions currently associated with the requested profile.
|
|
1353
1354
|
*/
|
|
1354
1355
|
listPositions(profileId: string): Promise<Position[]>;
|
|
1355
1356
|
/**
|
|
@@ -1382,6 +1383,10 @@ declare class PositionsModule {
|
|
|
1382
1383
|
* Returns the per-reserve breakdown of a profile's supplies and borrows,
|
|
1383
1384
|
* joined with pool metadata, rates, and current USD prices.
|
|
1384
1385
|
*
|
|
1386
|
+
* Supplied-only reserves below their pool's same-asset dust threshold are
|
|
1387
|
+
* omitted. Reserves with active debt remain, with their supplied amount and
|
|
1388
|
+
* earned interest set to zero when the supplied balance is below the threshold.
|
|
1389
|
+
*
|
|
1385
1390
|
* USD values are scaled to 27 decimals.
|
|
1386
1391
|
*
|
|
1387
1392
|
* @param profileId - The Liquidium profile principal text.
|
package/dist/index.d.ts
CHANGED
|
@@ -440,9 +440,9 @@ interface LiquidiumStatus {
|
|
|
440
440
|
operation: LiquidiumOperation;
|
|
441
441
|
/** Current lifecycle state for the operation. */
|
|
442
442
|
state: LiquidiumState;
|
|
443
|
-
/**
|
|
443
|
+
/** Confirmation progress while confirming, capped at the required count. */
|
|
444
444
|
confirmations: number | null;
|
|
445
|
-
/** Required confirmations,
|
|
445
|
+
/** Required confirmations while confirming, otherwise null. */
|
|
446
446
|
requiredConfirmations: number | null;
|
|
447
447
|
}
|
|
448
448
|
|
|
@@ -1346,10 +1346,11 @@ declare class PositionsModule {
|
|
|
1346
1346
|
*/
|
|
1347
1347
|
getPosition(profileId: string, poolId: string): Promise<Position | null>;
|
|
1348
1348
|
/**
|
|
1349
|
-
* Lists
|
|
1349
|
+
* Lists visible positions for a profile. Supply balances below their pool's
|
|
1350
|
+
* same-asset dust threshold are hidden without removing active debt.
|
|
1350
1351
|
*
|
|
1351
1352
|
* @param profileId - The Liquidium profile principal text.
|
|
1352
|
-
* @returns
|
|
1353
|
+
* @returns Visible positions currently associated with the requested profile.
|
|
1353
1354
|
*/
|
|
1354
1355
|
listPositions(profileId: string): Promise<Position[]>;
|
|
1355
1356
|
/**
|
|
@@ -1382,6 +1383,10 @@ declare class PositionsModule {
|
|
|
1382
1383
|
* Returns the per-reserve breakdown of a profile's supplies and borrows,
|
|
1383
1384
|
* joined with pool metadata, rates, and current USD prices.
|
|
1384
1385
|
*
|
|
1386
|
+
* Supplied-only reserves below their pool's same-asset dust threshold are
|
|
1387
|
+
* omitted. Reserves with active debt remain, with their supplied amount and
|
|
1388
|
+
* earned interest set to zero when the supplied balance is below the threshold.
|
|
1389
|
+
*
|
|
1385
1390
|
* USD values are scaled to 27 decimals.
|
|
1386
1391
|
*
|
|
1387
1392
|
* @param profileId - The Liquidium profile principal text.
|
package/dist/index.js
CHANGED
|
@@ -5475,23 +5475,38 @@ var PositionsModule = class {
|
|
|
5475
5475
|
}
|
|
5476
5476
|
}
|
|
5477
5477
|
/**
|
|
5478
|
-
* Lists
|
|
5478
|
+
* Lists visible positions for a profile. Supply balances below their pool's
|
|
5479
|
+
* same-asset dust threshold are hidden without removing active debt.
|
|
5479
5480
|
*
|
|
5480
5481
|
* @param profileId - The Liquidium profile principal text.
|
|
5481
|
-
* @returns
|
|
5482
|
+
* @returns Visible positions currently associated with the requested profile.
|
|
5482
5483
|
*/
|
|
5483
5484
|
async listPositions(profileId) {
|
|
5484
5485
|
try {
|
|
5485
5486
|
const actor = createFlexibleLendingActor(this.canisterContext);
|
|
5486
5487
|
const profilePrincipal = Principal.fromText(profileId);
|
|
5487
|
-
const stats = await
|
|
5488
|
+
const [stats, pools] = await Promise.all([
|
|
5489
|
+
actor.get_profile_stats(profilePrincipal),
|
|
5490
|
+
actor.list_pools()
|
|
5491
|
+
]);
|
|
5488
5492
|
const decodedStats = decodeFlexibleUserStats(stats);
|
|
5493
|
+
const dustThresholdsByPoolId = new Map(
|
|
5494
|
+
pools.map((pool) => [
|
|
5495
|
+
pool.principal.toText(),
|
|
5496
|
+
pool.same_asset_borrowing_dust_threshold
|
|
5497
|
+
])
|
|
5498
|
+
);
|
|
5489
5499
|
const positionViews = await Promise.all(
|
|
5490
5500
|
decodedStats.positions.map(
|
|
5491
5501
|
(position) => actor.get_position(profilePrincipal, position.pool_id)
|
|
5492
5502
|
)
|
|
5493
5503
|
);
|
|
5494
|
-
return positionViews.map((result) => result[0]).filter((view) => view !== void 0).map(decodeFlexiblePositionView).filter((view) => view !== null).map(mapDecodedPositionViewToPosition)
|
|
5504
|
+
return positionViews.map((result) => result[0]).filter((view) => view !== void 0).map(decodeFlexiblePositionView).filter((view) => view !== null).map(mapDecodedPositionViewToPosition).map(
|
|
5505
|
+
(position) => getPositionWithSuppliedDustHidden(
|
|
5506
|
+
position,
|
|
5507
|
+
dustThresholdsByPoolId.get(position.poolId)
|
|
5508
|
+
)
|
|
5509
|
+
).filter((position) => position !== null);
|
|
5495
5510
|
} catch (error) {
|
|
5496
5511
|
if (error instanceof LiquidiumError) {
|
|
5497
5512
|
throw error;
|
|
@@ -5577,6 +5592,10 @@ var PositionsModule = class {
|
|
|
5577
5592
|
* Returns the per-reserve breakdown of a profile's supplies and borrows,
|
|
5578
5593
|
* joined with pool metadata, rates, and current USD prices.
|
|
5579
5594
|
*
|
|
5595
|
+
* Supplied-only reserves below their pool's same-asset dust threshold are
|
|
5596
|
+
* omitted. Reserves with active debt remain, with their supplied amount and
|
|
5597
|
+
* earned interest set to zero when the supplied balance is below the threshold.
|
|
5598
|
+
*
|
|
5580
5599
|
* USD values are scaled to 27 decimals.
|
|
5581
5600
|
*
|
|
5582
5601
|
* @param profileId - The Liquidium profile principal text.
|
|
@@ -5657,6 +5676,16 @@ var PositionsModule = class {
|
|
|
5657
5676
|
return { amount: position.deposited, decimals: position.depositedDecimals };
|
|
5658
5677
|
}
|
|
5659
5678
|
};
|
|
5679
|
+
function getPositionWithSuppliedDustHidden(position, dustThreshold) {
|
|
5680
|
+
if (dustThreshold === void 0 || position.deposited >= dustThreshold) {
|
|
5681
|
+
return position;
|
|
5682
|
+
}
|
|
5683
|
+
const hasDebt = position.borrowed > 0n || position.debtInterest > 0n;
|
|
5684
|
+
if (!hasDebt) {
|
|
5685
|
+
return null;
|
|
5686
|
+
}
|
|
5687
|
+
return { ...position, deposited: 0n, earnedInterest: 0n };
|
|
5688
|
+
}
|
|
5660
5689
|
function nativeAmountToUsdScaled(amount, nativeDecimals, priceUsd) {
|
|
5661
5690
|
if (amount <= 0n || priceUsd <= 0) {
|
|
5662
5691
|
return 0n;
|