@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.d.cts CHANGED
@@ -417,6 +417,8 @@ declare class AccountsModule {
417
417
  *
418
418
  * @param options - `account` is the wallet address that will own the new profile.
419
419
  * @returns A signable {@link CreateAccountAction} with `submit` wired to the canister.
420
+ * @throws {@link LiquidiumError} If account validation or protocol
421
+ * preparation fails.
420
422
  */
421
423
  prepareCreateProfile(options: PrepareCreateProfileOptions): Promise<CreateAccountAction>;
422
424
  /**
@@ -426,6 +428,9 @@ declare class AccountsModule {
426
428
  *
427
429
  * @param params - Wallet `account`, signing `chain`, and `walletAdapter` with `signMessage`.
428
430
  * @returns The new profile principal as text.
431
+ * @throws {@link LiquidiumError} If SDK validation or protocol submission
432
+ * fails.
433
+ * @throws `Error` If the wallet adapter rejects message signing.
429
434
  */
430
435
  createProfile(params: CreateProfileParams): Promise<string>;
431
436
  /**
@@ -1087,6 +1092,8 @@ declare class LendingModule {
1087
1092
  * Use this when you need explicit control over signing and submission.
1088
1093
  * @param request - Profile, pool, amount (pool asset base units), outflow address, and signer wallet.
1089
1094
  * @returns A signable {@link WithdrawAction} with `submit` wired to the canister.
1095
+ * @throws {@link LiquidiumError} If request validation, destination
1096
+ * validation, or protocol preparation fails.
1090
1097
  */
1091
1098
  prepareWithdraw(request: CreateWithdrawRequest): Promise<WithdrawAction>;
1092
1099
  private submitWithdraw;
@@ -1097,6 +1104,9 @@ declare class LendingModule {
1097
1104
  *
1098
1105
  * @param params - Withdraw request fields plus `signerChain` and `signerWalletAdapter`.
1099
1106
  * @returns The canister {@link OutflowDetails} for the completed withdraw.
1107
+ * @throws {@link LiquidiumError} If SDK validation or protocol submission
1108
+ * fails.
1109
+ * @throws `Error` If the wallet adapter rejects message signing.
1100
1110
  */
1101
1111
  withdraw(params: CreateWithdrawRequest & WalletExecutionParams): Promise<WithdrawOutflowDetails>;
1102
1112
  /**
@@ -1108,6 +1118,8 @@ declare class LendingModule {
1108
1118
  *
1109
1119
  * @param request - Profile, pool, amount (borrow asset base units), outflow address, and signer wallet.
1110
1120
  * @returns A signable {@link BorrowAction} with `submit` wired to the canister.
1121
+ * @throws {@link LiquidiumError} If request validation, destination
1122
+ * validation, or protocol preparation fails.
1111
1123
  */
1112
1124
  prepareBorrow(request: CreateBorrowRequest): Promise<BorrowAction>;
1113
1125
  private submitBorrow;
@@ -1119,6 +1131,9 @@ declare class LendingModule {
1119
1131
  *
1120
1132
  * @param params - Borrow request fields plus `signerChain` and `signerWalletAdapter`.
1121
1133
  * @returns The lending canister receipt as {@link OutflowDetails}.
1134
+ * @throws {@link LiquidiumError} If SDK validation or protocol submission
1135
+ * fails.
1136
+ * @throws `Error` If the wallet adapter rejects message signing.
1122
1137
  *
1123
1138
  * @remarks
1124
1139
  * `id` is always present. `txid` may be missing on the first response; the SDK does not
@@ -1137,6 +1152,10 @@ declare class LendingModule {
1137
1152
  *
1138
1153
  * @returns A {@link SupplyFlow} receipt with `type`, `target`, `submit`, and
1139
1154
  * an optional `txid` present when the SDK broadcast for you.
1155
+ * @throws {@link LiquidiumError} If validation, transfer planning, or
1156
+ * protocol submission fails.
1157
+ * @throws `Error` If the wallet adapter rejects or fails to broadcast a
1158
+ * transaction.
1140
1159
  */
1141
1160
  supply(request: SupplyFlowRequest): Promise<SupplyFlow>;
1142
1161
  /**
@@ -1179,6 +1198,8 @@ declare class LendingModule {
1179
1198
  *
1180
1199
  * @param request - Broadcast `txid` plus inflow `operation` and optional `chain`.
1181
1200
  * @returns Acknowledgement including the submitted `txid`.
1201
+ * @throws {@link LiquidiumError} If the chain is unsupported or the API
1202
+ * request fails.
1182
1203
  */
1183
1204
  submitInflow(request: SubmitInflowRequest): Promise<SubmitInflowResponse>;
1184
1205
  /**
@@ -2156,6 +2177,10 @@ declare class SimpleLoansModule {
2156
2177
  *
2157
2178
  * @param request - Collateral, borrow, refund, LTV limit, timeout, and inflow options.
2158
2179
  * @returns Hydrated loan state plus generated initial-deposit and repayment quote targets.
2180
+ * @throws {@link LiquidiumError} If request validation, API transport, or
2181
+ * protocol validation fails before creation.
2182
+ * @throws {@link SimpleLoanCreatedError} If the remote loan is created but
2183
+ * the SDK cannot load its hydrated state.
2159
2184
  */
2160
2185
  create(request: CreateSimpleLoanRequest): Promise<SimpleLoan>;
2161
2186
  /**
@@ -2449,6 +2474,10 @@ interface ExecuteWithOptions {
2449
2474
  *
2450
2475
  * @param options - Adapter and optional chain/account overrides.
2451
2476
  * @returns A function that accepts a `WalletAction` and resolves with its submit result.
2477
+ * @throws {@link LiquidiumError} with code `LiquidiumErrorCode.VALIDATION_ERROR`
2478
+ * if a required wallet capability or signing chain is missing, or if
2479
+ * `action.executionKind` is unsupported.
2480
+ * @throws `Error` If the wallet adapter or action submission fails.
2452
2481
  */
2453
2482
  declare function executeWith(options: ExecuteWithOptions): <TResult>(action: WalletAction<TResult>) => Promise<TResult>;
2454
2483
 
package/dist/index.d.ts CHANGED
@@ -417,6 +417,8 @@ declare class AccountsModule {
417
417
  *
418
418
  * @param options - `account` is the wallet address that will own the new profile.
419
419
  * @returns A signable {@link CreateAccountAction} with `submit` wired to the canister.
420
+ * @throws {@link LiquidiumError} If account validation or protocol
421
+ * preparation fails.
420
422
  */
421
423
  prepareCreateProfile(options: PrepareCreateProfileOptions): Promise<CreateAccountAction>;
422
424
  /**
@@ -426,6 +428,9 @@ declare class AccountsModule {
426
428
  *
427
429
  * @param params - Wallet `account`, signing `chain`, and `walletAdapter` with `signMessage`.
428
430
  * @returns The new profile principal as text.
431
+ * @throws {@link LiquidiumError} If SDK validation or protocol submission
432
+ * fails.
433
+ * @throws `Error` If the wallet adapter rejects message signing.
429
434
  */
430
435
  createProfile(params: CreateProfileParams): Promise<string>;
431
436
  /**
@@ -1087,6 +1092,8 @@ declare class LendingModule {
1087
1092
  * Use this when you need explicit control over signing and submission.
1088
1093
  * @param request - Profile, pool, amount (pool asset base units), outflow address, and signer wallet.
1089
1094
  * @returns A signable {@link WithdrawAction} with `submit` wired to the canister.
1095
+ * @throws {@link LiquidiumError} If request validation, destination
1096
+ * validation, or protocol preparation fails.
1090
1097
  */
1091
1098
  prepareWithdraw(request: CreateWithdrawRequest): Promise<WithdrawAction>;
1092
1099
  private submitWithdraw;
@@ -1097,6 +1104,9 @@ declare class LendingModule {
1097
1104
  *
1098
1105
  * @param params - Withdraw request fields plus `signerChain` and `signerWalletAdapter`.
1099
1106
  * @returns The canister {@link OutflowDetails} for the completed withdraw.
1107
+ * @throws {@link LiquidiumError} If SDK validation or protocol submission
1108
+ * fails.
1109
+ * @throws `Error` If the wallet adapter rejects message signing.
1100
1110
  */
1101
1111
  withdraw(params: CreateWithdrawRequest & WalletExecutionParams): Promise<WithdrawOutflowDetails>;
1102
1112
  /**
@@ -1108,6 +1118,8 @@ declare class LendingModule {
1108
1118
  *
1109
1119
  * @param request - Profile, pool, amount (borrow asset base units), outflow address, and signer wallet.
1110
1120
  * @returns A signable {@link BorrowAction} with `submit` wired to the canister.
1121
+ * @throws {@link LiquidiumError} If request validation, destination
1122
+ * validation, or protocol preparation fails.
1111
1123
  */
1112
1124
  prepareBorrow(request: CreateBorrowRequest): Promise<BorrowAction>;
1113
1125
  private submitBorrow;
@@ -1119,6 +1131,9 @@ declare class LendingModule {
1119
1131
  *
1120
1132
  * @param params - Borrow request fields plus `signerChain` and `signerWalletAdapter`.
1121
1133
  * @returns The lending canister receipt as {@link OutflowDetails}.
1134
+ * @throws {@link LiquidiumError} If SDK validation or protocol submission
1135
+ * fails.
1136
+ * @throws `Error` If the wallet adapter rejects message signing.
1122
1137
  *
1123
1138
  * @remarks
1124
1139
  * `id` is always present. `txid` may be missing on the first response; the SDK does not
@@ -1137,6 +1152,10 @@ declare class LendingModule {
1137
1152
  *
1138
1153
  * @returns A {@link SupplyFlow} receipt with `type`, `target`, `submit`, and
1139
1154
  * an optional `txid` present when the SDK broadcast for you.
1155
+ * @throws {@link LiquidiumError} If validation, transfer planning, or
1156
+ * protocol submission fails.
1157
+ * @throws `Error` If the wallet adapter rejects or fails to broadcast a
1158
+ * transaction.
1140
1159
  */
1141
1160
  supply(request: SupplyFlowRequest): Promise<SupplyFlow>;
1142
1161
  /**
@@ -1179,6 +1198,8 @@ declare class LendingModule {
1179
1198
  *
1180
1199
  * @param request - Broadcast `txid` plus inflow `operation` and optional `chain`.
1181
1200
  * @returns Acknowledgement including the submitted `txid`.
1201
+ * @throws {@link LiquidiumError} If the chain is unsupported or the API
1202
+ * request fails.
1182
1203
  */
1183
1204
  submitInflow(request: SubmitInflowRequest): Promise<SubmitInflowResponse>;
1184
1205
  /**
@@ -2156,6 +2177,10 @@ declare class SimpleLoansModule {
2156
2177
  *
2157
2178
  * @param request - Collateral, borrow, refund, LTV limit, timeout, and inflow options.
2158
2179
  * @returns Hydrated loan state plus generated initial-deposit and repayment quote targets.
2180
+ * @throws {@link LiquidiumError} If request validation, API transport, or
2181
+ * protocol validation fails before creation.
2182
+ * @throws {@link SimpleLoanCreatedError} If the remote loan is created but
2183
+ * the SDK cannot load its hydrated state.
2159
2184
  */
2160
2185
  create(request: CreateSimpleLoanRequest): Promise<SimpleLoan>;
2161
2186
  /**
@@ -2449,6 +2474,10 @@ interface ExecuteWithOptions {
2449
2474
  *
2450
2475
  * @param options - Adapter and optional chain/account overrides.
2451
2476
  * @returns A function that accepts a `WalletAction` and resolves with its submit result.
2477
+ * @throws {@link LiquidiumError} with code `LiquidiumErrorCode.VALIDATION_ERROR`
2478
+ * if a required wallet capability or signing chain is missing, or if
2479
+ * `action.executionKind` is unsupported.
2480
+ * @throws `Error` If the wallet adapter or action submission fails.
2452
2481
  */
2453
2482
  declare function executeWith(options: ExecuteWithOptions): <TResult>(action: WalletAction<TResult>) => Promise<TResult>;
2454
2483
 
package/dist/index.js CHANGED
@@ -350,7 +350,14 @@ var idlFactory = ({ IDL }) => {
350
350
  "chain": Chains,
351
351
  "account": IDL.Text
352
352
  });
353
- const SignatureScheme = IDL.Variant({ "Wallet": SignatureInfo });
353
+ const IcpCallerAuth = IDL.Record({
354
+ "principal": IDL.Principal,
355
+ "subaccount": IDL.Opt(IDL.Vec(IDL.Nat8))
356
+ });
357
+ const SignatureScheme = IDL.Variant({
358
+ "Wallet": SignatureInfo,
359
+ "IcpCaller": IcpCallerAuth
360
+ });
354
361
  const AddAccountRequest = IDL.Record({
355
362
  "target_principal": IDL.Principal,
356
363
  "chain": WalletType,
@@ -363,12 +370,15 @@ var idlFactory = ({ IDL }) => {
363
370
  });
364
371
  const SignatureVerificationError = IDL.Variant({
365
372
  "InvalidEthSignature": IDL.Null,
373
+ "IcpCallerMismatch": IDL.Null,
366
374
  "UnsupportedChain": IDL.Null,
367
375
  "InvalidSolSignature": IDL.Null,
368
376
  "InvalidEthAddress": IDL.Null,
369
377
  "CouldNotDecode": IDL.Text,
370
378
  "ProfileNotFound": IDL.Null,
371
- "InvalidBtcSignature": IDL.Null
379
+ "InvalidBtcSignature": IDL.Null,
380
+ "AnonymousIcpCaller": IDL.Null,
381
+ "InvalidIcpSubaccount": IDL.Null
372
382
  });
373
383
  const ProtocolError = IDL.Variant({
374
384
  "PositionNotFound": IDL.Null,
@@ -936,6 +946,18 @@ var LENDING_CANISTER_SIGNATURE_VERIFICATION_ERROR_MAP = {
936
946
  InvalidBtcSignature: { code: LiquidiumErrorCode.INVALID_BTC_SIGNATURE },
937
947
  InvalidEthAddress: { code: LiquidiumErrorCode.INVALID_ETH_ADDRESS },
938
948
  UnsupportedChain: { code: LiquidiumErrorCode.UNSUPPORTED_CHAIN },
949
+ AnonymousIcpCaller: {
950
+ code: LiquidiumErrorCode.SIGNATURE_ERROR,
951
+ fallbackMessage: "Anonymous ICP caller"
952
+ },
953
+ InvalidIcpSubaccount: {
954
+ code: LiquidiumErrorCode.SIGNATURE_ERROR,
955
+ fallbackMessage: "Invalid ICP subaccount"
956
+ },
957
+ IcpCallerMismatch: {
958
+ code: LiquidiumErrorCode.SIGNATURE_ERROR,
959
+ fallbackMessage: "ICP caller mismatch"
960
+ },
939
961
  ProfileNotFound: { code: LiquidiumErrorCode.PROFILE_NOT_FOUND },
940
962
  CouldNotDecode: {
941
963
  code: LiquidiumErrorCode.SIGNATURE_ERROR,
@@ -1241,6 +1263,8 @@ var AccountsModule = class {
1241
1263
  *
1242
1264
  * @param options - `account` is the wallet address that will own the new profile.
1243
1265
  * @returns A signable {@link CreateAccountAction} with `submit` wired to the canister.
1266
+ * @throws {@link LiquidiumError} If account validation or protocol
1267
+ * preparation fails.
1244
1268
  */
1245
1269
  async prepareCreateProfile(options) {
1246
1270
  return await this.buildCreateProfileAction(options.account);
@@ -1252,6 +1276,9 @@ var AccountsModule = class {
1252
1276
  *
1253
1277
  * @param params - Wallet `account`, signing `chain`, and `walletAdapter` with `signMessage`.
1254
1278
  * @returns The new profile principal as text.
1279
+ * @throws {@link LiquidiumError} If SDK validation or protocol submission
1280
+ * fails.
1281
+ * @throws `Error` If the wallet adapter rejects message signing.
1255
1282
  */
1256
1283
  async createProfile(params) {
1257
1284
  const account = normalizeProfileAccount(params.account);
@@ -1503,7 +1530,8 @@ var flexibleSimpleLoansIdlFactory = ({ IDL }) => {
1503
1530
  ProfileNotFound: IDL.Null,
1504
1531
  InvalidBtcSignature: IDL.Null,
1505
1532
  AnonymousIcpCaller: IDL.Null,
1506
- InvalidIcpSubaccount: IDL.Null
1533
+ InvalidIcpSubaccount: IDL.Null,
1534
+ IcpCallerMismatch: IDL.Null
1507
1535
  });
1508
1536
  const ProtocolError = IDL.Variant({
1509
1537
  PositionNotFound: IDL.Null,
@@ -1535,6 +1563,7 @@ var flexibleSimpleLoansIdlFactory = ({ IDL }) => {
1535
1563
  });
1536
1564
  const SimpleLoansError = IDL.Variant({
1537
1565
  BorrowAmountRequired: IDL.Null,
1566
+ AnonymousPrincipalNotAllowed: IDL.Null,
1538
1567
  NoCollateralPosition: IDL.Record({ loan_id: IDL.Nat }),
1539
1568
  LtvTimerOutOfRange: IDL.Record({ max: IDL.Nat64 }),
1540
1569
  LtvMaxExceeded: IDL.Record({
@@ -1548,6 +1577,11 @@ var flexibleSimpleLoansIdlFactory = ({ IDL }) => {
1548
1577
  CallRejected: IDL.Record({ method: IDL.Text, reason: IDL.Text }),
1549
1578
  DecodeFailed: IDL.Record({ method: IDL.Text, reason: IDL.Text })
1550
1579
  }),
1580
+ PoolNotFound: IDL.Record({ pool_id: IDL.Principal }),
1581
+ LendingCanisterImmutable: IDL.Record({
1582
+ requested: IDL.Principal,
1583
+ configured: IDL.Principal
1584
+ }),
1551
1585
  LtvMaxOutOfRange: IDL.Record({ max: IDL.Nat64 }),
1552
1586
  AccountRequired: IDL.Record({ label: IDL.Text }),
1553
1587
  DepositTimerExceeded: IDL.Record({ loan_id: IDL.Nat }),
@@ -1560,8 +1594,14 @@ var flexibleSimpleLoansIdlFactory = ({ IDL }) => {
1560
1594
  DepositAlreadyProcessed: IDL.Record({ loan_id: IDL.Nat }),
1561
1595
  MissingPrice: IDL.Record({ symbol: IDL.Text }),
1562
1596
  InvalidLtvTimerS: IDL.Null,
1597
+ PoolLendingDisabled: IDL.Record({ pool_id: IDL.Principal }),
1563
1598
  DebtNotFullyRepaid: IDL.Record({ loan_id: IDL.Nat }),
1564
1599
  EmptyCollateralPosition: IDL.Null,
1600
+ PoolAssetMismatch: IDL.Record({
1601
+ configured_asset: IDL.Unknown,
1602
+ requested_asset: IDL.Unknown,
1603
+ pool_id: IDL.Principal
1604
+ }),
1565
1605
  SigningFailed: IDL.Record({ reason: IDL.Text })
1566
1606
  });
1567
1607
  const CreateLoanRequest = IDL.Record({
@@ -4768,6 +4808,8 @@ var LendingModule = class {
4768
4808
  * Use this when you need explicit control over signing and submission.
4769
4809
  * @param request - Profile, pool, amount (pool asset base units), outflow address, and signer wallet.
4770
4810
  * @returns A signable {@link WithdrawAction} with `submit` wired to the canister.
4811
+ * @throws {@link LiquidiumError} If request validation, destination
4812
+ * validation, or protocol preparation fails.
4771
4813
  */
4772
4814
  async prepareWithdraw(request) {
4773
4815
  const destination = resolveOutflowDestinationInput({
@@ -4920,6 +4962,9 @@ var LendingModule = class {
4920
4962
  *
4921
4963
  * @param params - Withdraw request fields plus `signerChain` and `signerWalletAdapter`.
4922
4964
  * @returns The canister {@link OutflowDetails} for the completed withdraw.
4965
+ * @throws {@link LiquidiumError} If SDK validation or protocol submission
4966
+ * fails.
4967
+ * @throws `Error` If the wallet adapter rejects message signing.
4923
4968
  */
4924
4969
  async withdraw(params) {
4925
4970
  const action = await this.prepareWithdraw(params);
@@ -4938,6 +4983,8 @@ var LendingModule = class {
4938
4983
  *
4939
4984
  * @param request - Profile, pool, amount (borrow asset base units), outflow address, and signer wallet.
4940
4985
  * @returns A signable {@link BorrowAction} with `submit` wired to the canister.
4986
+ * @throws {@link LiquidiumError} If request validation, destination
4987
+ * validation, or protocol preparation fails.
4941
4988
  */
4942
4989
  async prepareBorrow(request) {
4943
4990
  const destination = resolveOutflowDestinationInput({
@@ -5091,6 +5138,9 @@ var LendingModule = class {
5091
5138
  *
5092
5139
  * @param params - Borrow request fields plus `signerChain` and `signerWalletAdapter`.
5093
5140
  * @returns The lending canister receipt as {@link OutflowDetails}.
5141
+ * @throws {@link LiquidiumError} If SDK validation or protocol submission
5142
+ * fails.
5143
+ * @throws `Error` If the wallet adapter rejects message signing.
5094
5144
  *
5095
5145
  * @remarks
5096
5146
  * `id` is always present. `txid` may be missing on the first response; the SDK does not
@@ -5116,6 +5166,10 @@ var LendingModule = class {
5116
5166
  *
5117
5167
  * @returns A {@link SupplyFlow} receipt with `type`, `target`, `submit`, and
5118
5168
  * an optional `txid` present when the SDK broadcast for you.
5169
+ * @throws {@link LiquidiumError} If validation, transfer planning, or
5170
+ * protocol submission fails.
5171
+ * @throws `Error` If the wallet adapter rejects or fails to broadcast a
5172
+ * transaction.
5119
5173
  */
5120
5174
  async supply(request) {
5121
5175
  return await this.createSupplyFlowExecutor().create(request);
@@ -5240,6 +5294,8 @@ var LendingModule = class {
5240
5294
  *
5241
5295
  * @param request - Broadcast `txid` plus inflow `operation` and optional `chain`.
5242
5296
  * @returns Acknowledgement including the submitted `txid`.
5297
+ * @throws {@link LiquidiumError} If the chain is unsupported or the API
5298
+ * request fails.
5243
5299
  */
5244
5300
  async submitInflow(request) {
5245
5301
  if (request.chain !== void 0 && request.chain !== Chain.BTC && request.chain !== Chain.ETH) {
@@ -6546,6 +6602,10 @@ var SimpleLoansModule = class {
6546
6602
  *
6547
6603
  * @param request - Collateral, borrow, refund, LTV limit, timeout, and inflow options.
6548
6604
  * @returns Hydrated loan state plus generated initial-deposit and repayment quote targets.
6605
+ * @throws {@link LiquidiumError} If request validation, API transport, or
6606
+ * protocol validation fails before creation.
6607
+ * @throws {@link SimpleLoanCreatedError} If the remote loan is created but
6608
+ * the SDK cannot load its hydrated state.
6549
6609
  */
6550
6610
  async create(request) {
6551
6611
  validateCreateRequest(request);