@liquidium/client 0.8.1 → 0.8.3

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
@@ -352,7 +352,14 @@ var idlFactory = ({ IDL }) => {
352
352
  "chain": Chains,
353
353
  "account": IDL.Text
354
354
  });
355
- const SignatureScheme = IDL.Variant({ "Wallet": SignatureInfo });
355
+ const IcpCallerAuth = IDL.Record({
356
+ "principal": IDL.Principal,
357
+ "subaccount": IDL.Opt(IDL.Vec(IDL.Nat8))
358
+ });
359
+ const SignatureScheme = IDL.Variant({
360
+ "Wallet": SignatureInfo,
361
+ "IcpCaller": IcpCallerAuth
362
+ });
356
363
  const AddAccountRequest = IDL.Record({
357
364
  "target_principal": IDL.Principal,
358
365
  "chain": WalletType,
@@ -365,12 +372,15 @@ var idlFactory = ({ IDL }) => {
365
372
  });
366
373
  const SignatureVerificationError = IDL.Variant({
367
374
  "InvalidEthSignature": IDL.Null,
375
+ "IcpCallerMismatch": IDL.Null,
368
376
  "UnsupportedChain": IDL.Null,
369
377
  "InvalidSolSignature": IDL.Null,
370
378
  "InvalidEthAddress": IDL.Null,
371
379
  "CouldNotDecode": IDL.Text,
372
380
  "ProfileNotFound": IDL.Null,
373
- "InvalidBtcSignature": IDL.Null
381
+ "InvalidBtcSignature": IDL.Null,
382
+ "AnonymousIcpCaller": IDL.Null,
383
+ "InvalidIcpSubaccount": IDL.Null
374
384
  });
375
385
  const ProtocolError = IDL.Variant({
376
386
  "PositionNotFound": IDL.Null,
@@ -938,6 +948,18 @@ var LENDING_CANISTER_SIGNATURE_VERIFICATION_ERROR_MAP = {
938
948
  InvalidBtcSignature: { code: LiquidiumErrorCode.INVALID_BTC_SIGNATURE },
939
949
  InvalidEthAddress: { code: LiquidiumErrorCode.INVALID_ETH_ADDRESS },
940
950
  UnsupportedChain: { code: LiquidiumErrorCode.UNSUPPORTED_CHAIN },
951
+ AnonymousIcpCaller: {
952
+ code: LiquidiumErrorCode.SIGNATURE_ERROR,
953
+ fallbackMessage: "Anonymous ICP caller"
954
+ },
955
+ InvalidIcpSubaccount: {
956
+ code: LiquidiumErrorCode.SIGNATURE_ERROR,
957
+ fallbackMessage: "Invalid ICP subaccount"
958
+ },
959
+ IcpCallerMismatch: {
960
+ code: LiquidiumErrorCode.SIGNATURE_ERROR,
961
+ fallbackMessage: "ICP caller mismatch"
962
+ },
941
963
  ProfileNotFound: { code: LiquidiumErrorCode.PROFILE_NOT_FOUND },
942
964
  CouldNotDecode: {
943
965
  code: LiquidiumErrorCode.SIGNATURE_ERROR,
@@ -1243,6 +1265,8 @@ var AccountsModule = class {
1243
1265
  *
1244
1266
  * @param options - `account` is the wallet address that will own the new profile.
1245
1267
  * @returns A signable {@link CreateAccountAction} with `submit` wired to the canister.
1268
+ * @throws {@link LiquidiumError} If account validation or protocol
1269
+ * preparation fails.
1246
1270
  */
1247
1271
  async prepareCreateProfile(options) {
1248
1272
  return await this.buildCreateProfileAction(options.account);
@@ -1254,6 +1278,9 @@ var AccountsModule = class {
1254
1278
  *
1255
1279
  * @param params - Wallet `account`, signing `chain`, and `walletAdapter` with `signMessage`.
1256
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.
1257
1284
  */
1258
1285
  async createProfile(params) {
1259
1286
  const account = normalizeProfileAccount(params.account);
@@ -1505,7 +1532,8 @@ var flexibleSimpleLoansIdlFactory = ({ IDL }) => {
1505
1532
  ProfileNotFound: IDL.Null,
1506
1533
  InvalidBtcSignature: IDL.Null,
1507
1534
  AnonymousIcpCaller: IDL.Null,
1508
- InvalidIcpSubaccount: IDL.Null
1535
+ InvalidIcpSubaccount: IDL.Null,
1536
+ IcpCallerMismatch: IDL.Null
1509
1537
  });
1510
1538
  const ProtocolError = IDL.Variant({
1511
1539
  PositionNotFound: IDL.Null,
@@ -1537,6 +1565,7 @@ var flexibleSimpleLoansIdlFactory = ({ IDL }) => {
1537
1565
  });
1538
1566
  const SimpleLoansError = IDL.Variant({
1539
1567
  BorrowAmountRequired: IDL.Null,
1568
+ AnonymousPrincipalNotAllowed: IDL.Null,
1540
1569
  NoCollateralPosition: IDL.Record({ loan_id: IDL.Nat }),
1541
1570
  LtvTimerOutOfRange: IDL.Record({ max: IDL.Nat64 }),
1542
1571
  LtvMaxExceeded: IDL.Record({
@@ -1550,6 +1579,11 @@ var flexibleSimpleLoansIdlFactory = ({ IDL }) => {
1550
1579
  CallRejected: IDL.Record({ method: IDL.Text, reason: IDL.Text }),
1551
1580
  DecodeFailed: IDL.Record({ method: IDL.Text, reason: IDL.Text })
1552
1581
  }),
1582
+ PoolNotFound: IDL.Record({ pool_id: IDL.Principal }),
1583
+ LendingCanisterImmutable: IDL.Record({
1584
+ requested: IDL.Principal,
1585
+ configured: IDL.Principal
1586
+ }),
1553
1587
  LtvMaxOutOfRange: IDL.Record({ max: IDL.Nat64 }),
1554
1588
  AccountRequired: IDL.Record({ label: IDL.Text }),
1555
1589
  DepositTimerExceeded: IDL.Record({ loan_id: IDL.Nat }),
@@ -1562,8 +1596,14 @@ var flexibleSimpleLoansIdlFactory = ({ IDL }) => {
1562
1596
  DepositAlreadyProcessed: IDL.Record({ loan_id: IDL.Nat }),
1563
1597
  MissingPrice: IDL.Record({ symbol: IDL.Text }),
1564
1598
  InvalidLtvTimerS: IDL.Null,
1599
+ PoolLendingDisabled: IDL.Record({ pool_id: IDL.Principal }),
1565
1600
  DebtNotFullyRepaid: IDL.Record({ loan_id: IDL.Nat }),
1566
1601
  EmptyCollateralPosition: IDL.Null,
1602
+ PoolAssetMismatch: IDL.Record({
1603
+ configured_asset: IDL.Unknown,
1604
+ requested_asset: IDL.Unknown,
1605
+ pool_id: IDL.Principal
1606
+ }),
1567
1607
  SigningFailed: IDL.Record({ reason: IDL.Text })
1568
1608
  });
1569
1609
  const CreateLoanRequest = IDL.Record({
@@ -4770,6 +4810,8 @@ var LendingModule = class {
4770
4810
  * Use this when you need explicit control over signing and submission.
4771
4811
  * @param request - Profile, pool, amount (pool asset base units), outflow address, and signer wallet.
4772
4812
  * @returns A signable {@link WithdrawAction} with `submit` wired to the canister.
4813
+ * @throws {@link LiquidiumError} If request validation, destination
4814
+ * validation, or protocol preparation fails.
4773
4815
  */
4774
4816
  async prepareWithdraw(request) {
4775
4817
  const destination = resolveOutflowDestinationInput({
@@ -4922,6 +4964,9 @@ var LendingModule = class {
4922
4964
  *
4923
4965
  * @param params - Withdraw request fields plus `signerChain` and `signerWalletAdapter`.
4924
4966
  * @returns The canister {@link OutflowDetails} for the completed withdraw.
4967
+ * @throws {@link LiquidiumError} If SDK validation or protocol submission
4968
+ * fails.
4969
+ * @throws `Error` If the wallet adapter rejects message signing.
4925
4970
  */
4926
4971
  async withdraw(params) {
4927
4972
  const action = await this.prepareWithdraw(params);
@@ -4940,6 +4985,8 @@ var LendingModule = class {
4940
4985
  *
4941
4986
  * @param request - Profile, pool, amount (borrow asset base units), outflow address, and signer wallet.
4942
4987
  * @returns A signable {@link BorrowAction} with `submit` wired to the canister.
4988
+ * @throws {@link LiquidiumError} If request validation, destination
4989
+ * validation, or protocol preparation fails.
4943
4990
  */
4944
4991
  async prepareBorrow(request) {
4945
4992
  const destination = resolveOutflowDestinationInput({
@@ -5093,6 +5140,9 @@ var LendingModule = class {
5093
5140
  *
5094
5141
  * @param params - Borrow request fields plus `signerChain` and `signerWalletAdapter`.
5095
5142
  * @returns The lending canister receipt as {@link OutflowDetails}.
5143
+ * @throws {@link LiquidiumError} If SDK validation or protocol submission
5144
+ * fails.
5145
+ * @throws `Error` If the wallet adapter rejects message signing.
5096
5146
  *
5097
5147
  * @remarks
5098
5148
  * `id` is always present. `txid` may be missing on the first response; the SDK does not
@@ -5118,6 +5168,10 @@ var LendingModule = class {
5118
5168
  *
5119
5169
  * @returns A {@link SupplyFlow} receipt with `type`, `target`, `submit`, and
5120
5170
  * an optional `txid` present when the SDK broadcast for you.
5171
+ * @throws {@link LiquidiumError} If validation, transfer planning, or
5172
+ * protocol submission fails.
5173
+ * @throws `Error` If the wallet adapter rejects or fails to broadcast a
5174
+ * transaction.
5121
5175
  */
5122
5176
  async supply(request) {
5123
5177
  return await this.createSupplyFlowExecutor().create(request);
@@ -5242,6 +5296,8 @@ var LendingModule = class {
5242
5296
  *
5243
5297
  * @param request - Broadcast `txid` plus inflow `operation` and optional `chain`.
5244
5298
  * @returns Acknowledgement including the submitted `txid`.
5299
+ * @throws {@link LiquidiumError} If the chain is unsupported or the API
5300
+ * request fails.
5245
5301
  */
5246
5302
  async submitInflow(request) {
5247
5303
  if (request.chain !== void 0 && request.chain !== Chain.BTC && request.chain !== Chain.ETH) {
@@ -6548,6 +6604,10 @@ var SimpleLoansModule = class {
6548
6604
  *
6549
6605
  * @param request - Collateral, borrow, refund, LTV limit, timeout, and inflow options.
6550
6606
  * @returns Hydrated loan state plus generated initial-deposit and repayment quote targets.
6607
+ * @throws {@link LiquidiumError} If request validation, API transport, or
6608
+ * protocol validation fails before creation.
6609
+ * @throws {@link SimpleLoanCreatedError} If the remote loan is created but
6610
+ * the SDK cannot load its hydrated state.
6551
6611
  */
6552
6612
  async create(request) {
6553
6613
  validateCreateRequest(request);