@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.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
- /** Observed chain confirmations, or null when unavailable or not applicable. */
443
+ /** Confirmation progress while confirming, capped at the required count. */
444
444
  confirmations: number | null;
445
- /** Required confirmations, or null when unavailable or not applicable. */
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 all positions for a profile.
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 All positions currently associated with the requested profile.
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
- /** Observed chain confirmations, or null when unavailable or not applicable. */
443
+ /** Confirmation progress while confirming, capped at the required count. */
444
444
  confirmations: number | null;
445
- /** Required confirmations, or null when unavailable or not applicable. */
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 all positions for a profile.
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 All positions currently associated with the requested profile.
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
@@ -4175,6 +4175,12 @@ var SupplyFlowExecutor = class {
4175
4175
  });
4176
4176
  }
4177
4177
  case Chain.ETH: {
4178
+ if (params.amount > MAX_UINT256) {
4179
+ throw new LiquidiumError(
4180
+ LiquidiumErrorCode.VALIDATION_ERROR,
4181
+ "ETH transfer amount exceeds uint256 maximum"
4182
+ );
4183
+ }
4178
4184
  if (!params.walletAdapter.sendEthTransaction) {
4179
4185
  throw new LiquidiumError(
4180
4186
  LiquidiumErrorCode.VALIDATION_ERROR,
@@ -5469,23 +5475,38 @@ var PositionsModule = class {
5469
5475
  }
5470
5476
  }
5471
5477
  /**
5472
- * Lists all positions for a profile.
5478
+ * Lists visible positions for a profile. Supply balances below their pool's
5479
+ * same-asset dust threshold are hidden without removing active debt.
5473
5480
  *
5474
5481
  * @param profileId - The Liquidium profile principal text.
5475
- * @returns All positions currently associated with the requested profile.
5482
+ * @returns Visible positions currently associated with the requested profile.
5476
5483
  */
5477
5484
  async listPositions(profileId) {
5478
5485
  try {
5479
5486
  const actor = createFlexibleLendingActor(this.canisterContext);
5480
5487
  const profilePrincipal = Principal.fromText(profileId);
5481
- const stats = await actor.get_profile_stats(profilePrincipal);
5488
+ const [stats, pools] = await Promise.all([
5489
+ actor.get_profile_stats(profilePrincipal),
5490
+ actor.list_pools()
5491
+ ]);
5482
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
+ );
5483
5499
  const positionViews = await Promise.all(
5484
5500
  decodedStats.positions.map(
5485
5501
  (position) => actor.get_position(profilePrincipal, position.pool_id)
5486
5502
  )
5487
5503
  );
5488
- 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);
5489
5510
  } catch (error) {
5490
5511
  if (error instanceof LiquidiumError) {
5491
5512
  throw error;
@@ -5571,6 +5592,10 @@ var PositionsModule = class {
5571
5592
  * Returns the per-reserve breakdown of a profile's supplies and borrows,
5572
5593
  * joined with pool metadata, rates, and current USD prices.
5573
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
+ *
5574
5599
  * USD values are scaled to 27 decimals.
5575
5600
  *
5576
5601
  * @param profileId - The Liquidium profile principal text.
@@ -5651,6 +5676,16 @@ var PositionsModule = class {
5651
5676
  return { amount: position.deposited, decimals: position.depositedDecimals };
5652
5677
  }
5653
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
+ }
5654
5689
  function nativeAmountToUsdScaled(amount, nativeDecimals, priceUsd) {
5655
5690
  if (amount <= 0n || priceUsd <= 0) {
5656
5691
  return 0n;
@@ -6862,6 +6897,16 @@ function validateCreateRequest(request) {
6862
6897
  "Simple loan collateral amount must be greater than zero"
6863
6898
  );
6864
6899
  }
6900
+ const collateralMinimumError = getDepositAmountMinimumValidationError({
6901
+ amount: request.collateral.amount,
6902
+ asset: request.collateral.asset
6903
+ });
6904
+ if (collateralMinimumError) {
6905
+ throw new LiquidiumError(
6906
+ LiquidiumErrorCode.VALIDATION_ERROR,
6907
+ collateralMinimumError.message
6908
+ );
6909
+ }
6865
6910
  if (request.borrow.amount <= 0n) {
6866
6911
  throw new LiquidiumError(
6867
6912
  LiquidiumErrorCode.VALIDATION_ERROR,