@liquidium/client 0.6.0-rc.0 → 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
@@ -4177,6 +4177,12 @@ var SupplyFlowExecutor = class {
4177
4177
  });
4178
4178
  }
4179
4179
  case Chain.ETH: {
4180
+ if (params.amount > MAX_UINT256) {
4181
+ throw new LiquidiumError(
4182
+ LiquidiumErrorCode.VALIDATION_ERROR,
4183
+ "ETH transfer amount exceeds uint256 maximum"
4184
+ );
4185
+ }
4180
4186
  if (!params.walletAdapter.sendEthTransaction) {
4181
4187
  throw new LiquidiumError(
4182
4188
  LiquidiumErrorCode.VALIDATION_ERROR,
@@ -5471,23 +5477,38 @@ var PositionsModule = class {
5471
5477
  }
5472
5478
  }
5473
5479
  /**
5474
- * 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.
5475
5482
  *
5476
5483
  * @param profileId - The Liquidium profile principal text.
5477
- * @returns All positions currently associated with the requested profile.
5484
+ * @returns Visible positions currently associated with the requested profile.
5478
5485
  */
5479
5486
  async listPositions(profileId) {
5480
5487
  try {
5481
5488
  const actor = createFlexibleLendingActor(this.canisterContext);
5482
5489
  const profilePrincipal = principal.Principal.fromText(profileId);
5483
- 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
+ ]);
5484
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
+ );
5485
5501
  const positionViews = await Promise.all(
5486
5502
  decodedStats.positions.map(
5487
5503
  (position) => actor.get_position(profilePrincipal, position.pool_id)
5488
5504
  )
5489
5505
  );
5490
- 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);
5491
5512
  } catch (error) {
5492
5513
  if (error instanceof LiquidiumError) {
5493
5514
  throw error;
@@ -5573,6 +5594,10 @@ var PositionsModule = class {
5573
5594
  * Returns the per-reserve breakdown of a profile's supplies and borrows,
5574
5595
  * joined with pool metadata, rates, and current USD prices.
5575
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
+ *
5576
5601
  * USD values are scaled to 27 decimals.
5577
5602
  *
5578
5603
  * @param profileId - The Liquidium profile principal text.
@@ -5653,6 +5678,16 @@ var PositionsModule = class {
5653
5678
  return { amount: position.deposited, decimals: position.depositedDecimals };
5654
5679
  }
5655
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
+ }
5656
5691
  function nativeAmountToUsdScaled(amount, nativeDecimals, priceUsd) {
5657
5692
  if (amount <= 0n || priceUsd <= 0) {
5658
5693
  return 0n;
@@ -6864,6 +6899,16 @@ function validateCreateRequest(request) {
6864
6899
  "Simple loan collateral amount must be greater than zero"
6865
6900
  );
6866
6901
  }
6902
+ const collateralMinimumError = getDepositAmountMinimumValidationError({
6903
+ amount: request.collateral.amount,
6904
+ asset: request.collateral.asset
6905
+ });
6906
+ if (collateralMinimumError) {
6907
+ throw new LiquidiumError(
6908
+ LiquidiumErrorCode.VALIDATION_ERROR,
6909
+ collateralMinimumError.message
6910
+ );
6911
+ }
6867
6912
  if (request.borrow.amount <= 0n) {
6868
6913
  throw new LiquidiumError(
6869
6914
  LiquidiumErrorCode.VALIDATION_ERROR,