@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 CHANGED
@@ -5477,23 +5477,38 @@ var PositionsModule = class {
5477
5477
  }
5478
5478
  }
5479
5479
  /**
5480
- * Lists all positions for a profile.
5480
+ * Lists visible positions for a profile. Supply balances below their pool's
5481
+ * same-asset dust threshold are hidden without removing active debt.
5481
5482
  *
5482
5483
  * @param profileId - The Liquidium profile principal text.
5483
- * @returns All positions currently associated with the requested profile.
5484
+ * @returns Visible positions currently associated with the requested profile.
5484
5485
  */
5485
5486
  async listPositions(profileId) {
5486
5487
  try {
5487
5488
  const actor = createFlexibleLendingActor(this.canisterContext);
5488
5489
  const profilePrincipal = principal.Principal.fromText(profileId);
5489
- const stats = await actor.get_profile_stats(profilePrincipal);
5490
+ const [stats, pools] = await Promise.all([
5491
+ actor.get_profile_stats(profilePrincipal),
5492
+ actor.list_pools()
5493
+ ]);
5490
5494
  const decodedStats = decodeFlexibleUserStats(stats);
5495
+ const dustThresholdsByPoolId = new Map(
5496
+ pools.map((pool) => [
5497
+ pool.principal.toText(),
5498
+ pool.same_asset_borrowing_dust_threshold
5499
+ ])
5500
+ );
5491
5501
  const positionViews = await Promise.all(
5492
5502
  decodedStats.positions.map(
5493
5503
  (position) => actor.get_position(profilePrincipal, position.pool_id)
5494
5504
  )
5495
5505
  );
5496
- return positionViews.map((result) => result[0]).filter((view) => view !== void 0).map(decodeFlexiblePositionView).filter((view) => view !== null).map(mapDecodedPositionViewToPosition);
5506
+ return positionViews.map((result) => result[0]).filter((view) => view !== void 0).map(decodeFlexiblePositionView).filter((view) => view !== null).map(mapDecodedPositionViewToPosition).map(
5507
+ (position) => getPositionWithSuppliedDustHidden(
5508
+ position,
5509
+ dustThresholdsByPoolId.get(position.poolId)
5510
+ )
5511
+ ).filter((position) => position !== null);
5497
5512
  } catch (error) {
5498
5513
  if (error instanceof LiquidiumError) {
5499
5514
  throw error;
@@ -5579,6 +5594,10 @@ var PositionsModule = class {
5579
5594
  * Returns the per-reserve breakdown of a profile's supplies and borrows,
5580
5595
  * joined with pool metadata, rates, and current USD prices.
5581
5596
  *
5597
+ * Supplied-only reserves below their pool's same-asset dust threshold are
5598
+ * omitted. Reserves with active debt remain, with their supplied amount and
5599
+ * earned interest set to zero when the supplied balance is below the threshold.
5600
+ *
5582
5601
  * USD values are scaled to 27 decimals.
5583
5602
  *
5584
5603
  * @param profileId - The Liquidium profile principal text.
@@ -5659,6 +5678,16 @@ var PositionsModule = class {
5659
5678
  return { amount: position.deposited, decimals: position.depositedDecimals };
5660
5679
  }
5661
5680
  };
5681
+ function getPositionWithSuppliedDustHidden(position, dustThreshold) {
5682
+ if (dustThreshold === void 0 || position.deposited >= dustThreshold) {
5683
+ return position;
5684
+ }
5685
+ const hasDebt = position.borrowed > 0n || position.debtInterest > 0n;
5686
+ if (!hasDebt) {
5687
+ return null;
5688
+ }
5689
+ return { ...position, deposited: 0n, earnedInterest: 0n };
5690
+ }
5662
5691
  function nativeAmountToUsdScaled(amount, nativeDecimals, priceUsd) {
5663
5692
  if (amount <= 0n || priceUsd <= 0) {
5664
5693
  return 0n;