@liquidium/client 0.8.2 → 0.9.0

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/README.md CHANGED
@@ -75,7 +75,7 @@ See the [quick start](https://liquidium-inc.github.io/liquidium-sdk/getting-star
75
75
 
76
76
  ## Development
77
77
 
78
- Requires Node.js 20+ and pnpm 11+.
78
+ Requires Node.js 22.12+ in the 22.x line, 24.x, or 26+, and pnpm 11+.
79
79
 
80
80
  ```bash
81
81
  pnpm install
package/dist/index.cjs CHANGED
@@ -1265,6 +1265,8 @@ var AccountsModule = class {
1265
1265
  *
1266
1266
  * @param options - `account` is the wallet address that will own the new profile.
1267
1267
  * @returns A signable {@link CreateAccountAction} with `submit` wired to the canister.
1268
+ * @throws {@link LiquidiumError} If account validation or protocol
1269
+ * preparation fails.
1268
1270
  */
1269
1271
  async prepareCreateProfile(options) {
1270
1272
  return await this.buildCreateProfileAction(options.account);
@@ -1276,6 +1278,9 @@ var AccountsModule = class {
1276
1278
  *
1277
1279
  * @param params - Wallet `account`, signing `chain`, and `walletAdapter` with `signMessage`.
1278
1280
  * @returns The new profile principal as text.
1281
+ * @throws {@link LiquidiumError} If SDK validation or protocol submission
1282
+ * fails.
1283
+ * @throws `Error` If the wallet adapter rejects message signing.
1279
1284
  */
1280
1285
  async createProfile(params) {
1281
1286
  const account = normalizeProfileAccount(params.account);
@@ -1560,6 +1565,7 @@ var flexibleSimpleLoansIdlFactory = ({ IDL }) => {
1560
1565
  });
1561
1566
  const SimpleLoansError = IDL.Variant({
1562
1567
  BorrowAmountRequired: IDL.Null,
1568
+ AnonymousPrincipalNotAllowed: IDL.Null,
1563
1569
  NoCollateralPosition: IDL.Record({ loan_id: IDL.Nat }),
1564
1570
  LtvTimerOutOfRange: IDL.Record({ max: IDL.Nat64 }),
1565
1571
  LtvMaxExceeded: IDL.Record({
@@ -1573,6 +1579,11 @@ var flexibleSimpleLoansIdlFactory = ({ IDL }) => {
1573
1579
  CallRejected: IDL.Record({ method: IDL.Text, reason: IDL.Text }),
1574
1580
  DecodeFailed: IDL.Record({ method: IDL.Text, reason: IDL.Text })
1575
1581
  }),
1582
+ PoolNotFound: IDL.Record({ pool_id: IDL.Principal }),
1583
+ LendingCanisterImmutable: IDL.Record({
1584
+ requested: IDL.Principal,
1585
+ configured: IDL.Principal
1586
+ }),
1576
1587
  LtvMaxOutOfRange: IDL.Record({ max: IDL.Nat64 }),
1577
1588
  AccountRequired: IDL.Record({ label: IDL.Text }),
1578
1589
  DepositTimerExceeded: IDL.Record({ loan_id: IDL.Nat }),
@@ -1585,8 +1596,14 @@ var flexibleSimpleLoansIdlFactory = ({ IDL }) => {
1585
1596
  DepositAlreadyProcessed: IDL.Record({ loan_id: IDL.Nat }),
1586
1597
  MissingPrice: IDL.Record({ symbol: IDL.Text }),
1587
1598
  InvalidLtvTimerS: IDL.Null,
1599
+ PoolLendingDisabled: IDL.Record({ pool_id: IDL.Principal }),
1588
1600
  DebtNotFullyRepaid: IDL.Record({ loan_id: IDL.Nat }),
1589
1601
  EmptyCollateralPosition: IDL.Null,
1602
+ PoolAssetMismatch: IDL.Record({
1603
+ configured_asset: IDL.Unknown,
1604
+ requested_asset: IDL.Unknown,
1605
+ pool_id: IDL.Principal
1606
+ }),
1590
1607
  SigningFailed: IDL.Record({ reason: IDL.Text })
1591
1608
  });
1592
1609
  const CreateLoanRequest = IDL.Record({
@@ -3192,7 +3209,8 @@ var flexibleLendingIdlFactory = ({ IDL }) => {
3192
3209
  same_asset_borrowing: IDL.Opt(IDL.Bool),
3193
3210
  same_asset_borrowing_dust_threshold: IDL.Nat,
3194
3211
  frozen: IDL.Bool,
3195
- last_updated: IDL.Opt(IDL.Nat64)
3212
+ last_updated: IDL.Opt(IDL.Nat64),
3213
+ activation_fee: IDL.Opt(IDL.Nat64)
3196
3214
  });
3197
3215
  const BorrowingPowerRecord = IDL.Record({
3198
3216
  max_borrowable_usd: IDL.Nat,
@@ -3298,7 +3316,8 @@ function decodeFlexiblePool(pool) {
3298
3316
  same_asset_borrowing: pool.same_asset_borrowing,
3299
3317
  same_asset_borrowing_dust_threshold: pool.same_asset_borrowing_dust_threshold,
3300
3318
  frozen: pool.frozen,
3301
- last_updated: pool.last_updated
3319
+ last_updated: pool.last_updated,
3320
+ activation_fee: pool.activation_fee ?? []
3302
3321
  };
3303
3322
  }
3304
3323
  function decodeFlexiblePosition(position) {
@@ -4793,6 +4812,8 @@ var LendingModule = class {
4793
4812
  * Use this when you need explicit control over signing and submission.
4794
4813
  * @param request - Profile, pool, amount (pool asset base units), outflow address, and signer wallet.
4795
4814
  * @returns A signable {@link WithdrawAction} with `submit` wired to the canister.
4815
+ * @throws {@link LiquidiumError} If request validation, destination
4816
+ * validation, or protocol preparation fails.
4796
4817
  */
4797
4818
  async prepareWithdraw(request) {
4798
4819
  const destination = resolveOutflowDestinationInput({
@@ -4945,6 +4966,9 @@ var LendingModule = class {
4945
4966
  *
4946
4967
  * @param params - Withdraw request fields plus `signerChain` and `signerWalletAdapter`.
4947
4968
  * @returns The canister {@link OutflowDetails} for the completed withdraw.
4969
+ * @throws {@link LiquidiumError} If SDK validation or protocol submission
4970
+ * fails.
4971
+ * @throws `Error` If the wallet adapter rejects message signing.
4948
4972
  */
4949
4973
  async withdraw(params) {
4950
4974
  const action = await this.prepareWithdraw(params);
@@ -4963,6 +4987,8 @@ var LendingModule = class {
4963
4987
  *
4964
4988
  * @param request - Profile, pool, amount (borrow asset base units), outflow address, and signer wallet.
4965
4989
  * @returns A signable {@link BorrowAction} with `submit` wired to the canister.
4990
+ * @throws {@link LiquidiumError} If request validation, destination
4991
+ * validation, or protocol preparation fails.
4966
4992
  */
4967
4993
  async prepareBorrow(request) {
4968
4994
  const destination = resolveOutflowDestinationInput({
@@ -5116,6 +5142,9 @@ var LendingModule = class {
5116
5142
  *
5117
5143
  * @param params - Borrow request fields plus `signerChain` and `signerWalletAdapter`.
5118
5144
  * @returns The lending canister receipt as {@link OutflowDetails}.
5145
+ * @throws {@link LiquidiumError} If SDK validation or protocol submission
5146
+ * fails.
5147
+ * @throws `Error` If the wallet adapter rejects message signing.
5119
5148
  *
5120
5149
  * @remarks
5121
5150
  * `id` is always present. `txid` may be missing on the first response; the SDK does not
@@ -5141,6 +5170,10 @@ var LendingModule = class {
5141
5170
  *
5142
5171
  * @returns A {@link SupplyFlow} receipt with `type`, `target`, `submit`, and
5143
5172
  * an optional `txid` present when the SDK broadcast for you.
5173
+ * @throws {@link LiquidiumError} If validation, transfer planning, or
5174
+ * protocol submission fails.
5175
+ * @throws `Error` If the wallet adapter rejects or fails to broadcast a
5176
+ * transaction.
5144
5177
  */
5145
5178
  async supply(request) {
5146
5179
  return await this.createSupplyFlowExecutor().create(request);
@@ -5265,6 +5298,8 @@ var LendingModule = class {
5265
5298
  *
5266
5299
  * @param request - Broadcast `txid` plus inflow `operation` and optional `chain`.
5267
5300
  * @returns Acknowledgement including the submitted `txid`.
5301
+ * @throws {@link LiquidiumError} If the chain is unsupported or the API
5302
+ * request fails.
5268
5303
  */
5269
5304
  async submitInflow(request) {
5270
5305
  if (request.chain !== void 0 && request.chain !== Chain.BTC && request.chain !== Chain.ETH) {
@@ -5510,6 +5545,7 @@ function mapDecodedPoolToPool(pool, rate) {
5510
5545
  liquidationBonus: pool.liquidation_bonus,
5511
5546
  protocolLiquidationFee: pool.protocol_liquidation_fee,
5512
5547
  reserveFactor: pool.reserve_factor,
5548
+ activationFee: pool.activation_fee[0] ?? 0n,
5513
5549
  rateDecimals: RATE_DECIMALS,
5514
5550
  lendingRate: rate[1],
5515
5551
  estimatedLendingApy: estimateSupplyApy(rate[1]),
@@ -6156,7 +6192,7 @@ var QuoteModule = class {
6156
6192
  });
6157
6193
  }
6158
6194
  const borrowUsd = computeUsdInternalFromBaseUnits({
6159
- amountBaseUnits: request.borrowAmount,
6195
+ amountBaseUnits: getOpeningDebt(request.borrowAmount, borrowPool),
6160
6196
  priceScaled: scalePriceUsdToBigint(borrowPrice),
6161
6197
  assetDecimalPlaces: getPoolDecimalPlaces(borrowPool)
6162
6198
  });
@@ -6313,7 +6349,7 @@ var QuoteModule = class {
6313
6349
  collateralPrice
6314
6350
  );
6315
6351
  const borrowUsdInternal = computeUsdInternalFromBaseUnits({
6316
- amountBaseUnits: borrowAmount,
6352
+ amountBaseUnits: getOpeningDebt(borrowAmount, borrowPool),
6317
6353
  priceScaled: borrowPriceScaled,
6318
6354
  assetDecimalPlaces: borrowAssetDecimals
6319
6355
  });
@@ -6361,6 +6397,9 @@ var QuoteModule = class {
6361
6397
  });
6362
6398
  }
6363
6399
  };
6400
+ function getOpeningDebt(borrowAmount, borrowPool) {
6401
+ return borrowAmount + borrowAmount * borrowPool.activationFee / BASIS_POINTS_DENOMINATOR;
6402
+ }
6364
6403
  function createLtvCalculation(params) {
6365
6404
  return {
6366
6405
  borrowAmount: params.request.borrowAmount,
@@ -6571,6 +6610,10 @@ var SimpleLoansModule = class {
6571
6610
  *
6572
6611
  * @param request - Collateral, borrow, refund, LTV limit, timeout, and inflow options.
6573
6612
  * @returns Hydrated loan state plus generated initial-deposit and repayment quote targets.
6613
+ * @throws {@link LiquidiumError} If request validation, API transport, or
6614
+ * protocol validation fails before creation.
6615
+ * @throws {@link SimpleLoanCreatedError} If the remote loan is created but
6616
+ * the SDK cannot load its hydrated state.
6574
6617
  */
6575
6618
  async create(request) {
6576
6619
  validateCreateRequest(request);