@liquidium/client 0.1.2 → 0.2.1
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 +33 -17
- package/dist/index.cjs +351 -115
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +244 -109
- package/dist/index.d.ts +244 -109
- package/dist/index.js +351 -117
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -226,6 +226,16 @@ interface SignatureInfo {
|
|
|
226
226
|
/** Account that produced the signature, when different from the action default. */
|
|
227
227
|
account?: string;
|
|
228
228
|
}
|
|
229
|
+
/** Request submitted after a BTC PSBT has been signed. */
|
|
230
|
+
interface SignPsbtSubmitRequest {
|
|
231
|
+
/** Base64-encoded signed PSBT. */
|
|
232
|
+
signedPsbtBase64: string;
|
|
233
|
+
}
|
|
234
|
+
/** Request submitted after an ETH transaction has been sent. */
|
|
235
|
+
interface SendEthTransactionSubmitRequest {
|
|
236
|
+
/** EVM transaction hash returned by the wallet. */
|
|
237
|
+
txHash: string;
|
|
238
|
+
}
|
|
229
239
|
/** Prepared action that requires message signing before submit. */
|
|
230
240
|
interface SignMessageWalletAction<TData, TResult> {
|
|
231
241
|
/** Protocol action kind. */
|
|
@@ -260,9 +270,7 @@ interface SignPsbtWalletAction<TResult> {
|
|
|
260
270
|
/** Base64-encoded unsigned PSBT. */
|
|
261
271
|
psbtBase64: string;
|
|
262
272
|
/** Submits the signed PSBT and resolves the protocol result. */
|
|
263
|
-
submit(request:
|
|
264
|
-
signedPsbtBase64: string;
|
|
265
|
-
}): Promise<TResult>;
|
|
273
|
+
submit(request: SignPsbtSubmitRequest): Promise<TResult>;
|
|
266
274
|
}
|
|
267
275
|
/** Prepared action that requires sending an ETH transaction before submit. */
|
|
268
276
|
interface SendEthTransactionWalletAction<TResult> {
|
|
@@ -279,13 +287,25 @@ interface SendEthTransactionWalletAction<TResult> {
|
|
|
279
287
|
/** EVM transaction request to send. */
|
|
280
288
|
transaction: EthTransactionRequest;
|
|
281
289
|
/** Submits the transaction hash and resolves the protocol result. */
|
|
282
|
-
submit(request:
|
|
283
|
-
txHash: string;
|
|
284
|
-
}): Promise<TResult>;
|
|
290
|
+
submit(request: SendEthTransactionSubmitRequest): Promise<TResult>;
|
|
285
291
|
}
|
|
286
292
|
/** Any prepared action returned by SDK methods and executable by {@link executeWith}. */
|
|
287
293
|
type WalletAction<TResult> = SignMessageWalletAction<unknown, TResult> | SignPsbtWalletAction<TResult> | SendEthTransactionWalletAction<TResult>;
|
|
288
294
|
|
|
295
|
+
/** Options for preparing a profile-creation action. */
|
|
296
|
+
interface PrepareCreateProfileOptions {
|
|
297
|
+
/** Wallet address that will own the new profile. */
|
|
298
|
+
account: string;
|
|
299
|
+
}
|
|
300
|
+
/** Parameters for creating a profile through a wallet adapter. */
|
|
301
|
+
interface CreateProfileParams {
|
|
302
|
+
/** Wallet address that will own the new profile. */
|
|
303
|
+
account: string;
|
|
304
|
+
/** Chain used to sign the profile-creation message. */
|
|
305
|
+
chain: Chain;
|
|
306
|
+
/** Wallet adapter used to sign the profile-creation message. */
|
|
307
|
+
walletAdapter: WalletAdapter;
|
|
308
|
+
}
|
|
289
309
|
/** Data embedded in a prepared profile-creation action. */
|
|
290
310
|
interface CreateAccountData {
|
|
291
311
|
/** Expiry timestamp, in protocol nanoseconds, included in the signed message. */
|
|
@@ -311,14 +331,6 @@ interface CreateAccountRequest {
|
|
|
311
331
|
signatureInfo: SignatureInfo;
|
|
312
332
|
}
|
|
313
333
|
|
|
314
|
-
type PrepareCreateProfileOptions = {
|
|
315
|
-
account: string;
|
|
316
|
-
};
|
|
317
|
-
type CreateProfileParams = {
|
|
318
|
-
account: string;
|
|
319
|
-
chain: Chain;
|
|
320
|
-
walletAdapter: WalletAdapter;
|
|
321
|
-
};
|
|
322
334
|
/** Profile lifecycle and linked-wallet helpers. */
|
|
323
335
|
declare class AccountsModule {
|
|
324
336
|
private readonly canisterContext;
|
|
@@ -464,32 +476,56 @@ interface OutflowActivity extends BaseActivity {
|
|
|
464
476
|
}
|
|
465
477
|
/** Any activity returned by `activities.list` or `activities.getStatus`. */
|
|
466
478
|
type Activity = InflowActivity | OutflowActivity;
|
|
467
|
-
/**
|
|
468
|
-
|
|
479
|
+
/** Shared request fields for listing activities. */
|
|
480
|
+
interface BaseListActivitiesRequest {
|
|
469
481
|
/** Optional state filter; defaults to `all`. */
|
|
470
482
|
filter?: ActivityFilter;
|
|
471
|
-
}
|
|
483
|
+
}
|
|
484
|
+
/** Activity list request scoped to a Liquidium profile. */
|
|
485
|
+
interface ListActivitiesByProfileRequest extends BaseListActivitiesRequest {
|
|
486
|
+
/** Profile principal text to list activities for. */
|
|
472
487
|
profileId: string;
|
|
473
|
-
}
|
|
488
|
+
}
|
|
489
|
+
/** Activity list request scoped to an instant-loan short reference. */
|
|
490
|
+
interface ListActivitiesByShortRefRequest extends BaseListActivitiesRequest {
|
|
491
|
+
/** Instant-loan short reference to list activities for. */
|
|
474
492
|
shortRef: string;
|
|
475
|
-
}
|
|
476
|
-
/** Request for
|
|
477
|
-
type
|
|
493
|
+
}
|
|
494
|
+
/** Request for listing activities by profile id or instant-loan short reference. */
|
|
495
|
+
type ListActivitiesRequest = ListActivitiesByProfileRequest | ListActivitiesByShortRefRequest;
|
|
496
|
+
/** Shared request fields for an activity status lookup. */
|
|
497
|
+
interface BaseGetActivityStatusRequest {
|
|
478
498
|
/** Activity or receipt id to look up. */
|
|
479
499
|
id: string;
|
|
480
|
-
}
|
|
500
|
+
}
|
|
501
|
+
/** Activity status lookup scoped to a Liquidium profile. */
|
|
502
|
+
interface GetActivityStatusByProfileRequest extends BaseGetActivityStatusRequest {
|
|
503
|
+
/** Profile principal text that owns the activity. */
|
|
481
504
|
profileId: string;
|
|
482
|
-
}
|
|
505
|
+
}
|
|
506
|
+
/** Activity status lookup scoped to an instant-loan short reference. */
|
|
507
|
+
interface GetActivityStatusByShortRefRequest extends BaseGetActivityStatusRequest {
|
|
508
|
+
/** Instant-loan short reference that owns the activity. */
|
|
483
509
|
shortRef: string;
|
|
484
|
-
}
|
|
485
|
-
/**
|
|
486
|
-
type
|
|
510
|
+
}
|
|
511
|
+
/** Request for fetching one activity by id and owner identifier. */
|
|
512
|
+
type GetActivityStatusRequest = GetActivityStatusByProfileRequest | GetActivityStatusByShortRefRequest;
|
|
513
|
+
/** Successful activity status lookup result. */
|
|
514
|
+
interface ActivityStatusFoundResponse {
|
|
515
|
+
/** Indicates the activity was found. */
|
|
487
516
|
found: true;
|
|
517
|
+
/** Matched activity. */
|
|
488
518
|
activity: Activity;
|
|
489
|
-
}
|
|
519
|
+
}
|
|
520
|
+
/** Missing activity status lookup result. */
|
|
521
|
+
interface ActivityStatusNotFoundResponse {
|
|
522
|
+
/** Indicates the activity was not found. */
|
|
490
523
|
found: false;
|
|
524
|
+
/** Requested activity or receipt id. */
|
|
491
525
|
id: string;
|
|
492
|
-
}
|
|
526
|
+
}
|
|
527
|
+
/** Result of an activity status lookup. */
|
|
528
|
+
type GetActivityStatusResponse = ActivityStatusFoundResponse | ActivityStatusNotFoundResponse;
|
|
493
529
|
|
|
494
530
|
/** Receipt-oriented activity list and status helpers. */
|
|
495
531
|
declare class ActivitiesModule {
|
|
@@ -774,6 +810,29 @@ declare class HistoryModule {
|
|
|
774
810
|
getLiquidationHistory(user: string, market?: string, filters?: UserLiquidationHistoryFilters): Promise<PaginatedResponse<UserLiquidationHistoryEntry>>;
|
|
775
811
|
}
|
|
776
812
|
|
|
813
|
+
/** Wallet execution dependencies for borrow and withdraw convenience methods. */
|
|
814
|
+
interface WalletExecutionParams {
|
|
815
|
+
/** Chain used by the signing wallet. */
|
|
816
|
+
signerChain: Chain;
|
|
817
|
+
/** Wallet adapter used to execute the prepared action. */
|
|
818
|
+
signerWalletAdapter: WalletAdapter;
|
|
819
|
+
}
|
|
820
|
+
/** EVM transaction payload returned by lending transaction builders. */
|
|
821
|
+
interface EvmContractTransaction {
|
|
822
|
+
/** Contract address to call. */
|
|
823
|
+
to: string;
|
|
824
|
+
/** Hex-encoded calldata. */
|
|
825
|
+
data: string;
|
|
826
|
+
}
|
|
827
|
+
/** Parameters for an ERC-20 transfer transaction. */
|
|
828
|
+
interface CreateTransferErc20TransactionParams {
|
|
829
|
+
/** ERC-20 token contract address. */
|
|
830
|
+
tokenAddress: string;
|
|
831
|
+
/** Destination EVM address. */
|
|
832
|
+
recipientAddress: string;
|
|
833
|
+
/** Transfer amount in token base units. */
|
|
834
|
+
amount: bigint;
|
|
835
|
+
}
|
|
777
836
|
/** Destination account for a completed outflow. */
|
|
778
837
|
interface OutflowReceiver {
|
|
779
838
|
/** Destination account type reported by the protocol. */
|
|
@@ -781,6 +840,13 @@ interface OutflowReceiver {
|
|
|
781
840
|
/** Destination principal or external-chain address. */
|
|
782
841
|
account: string;
|
|
783
842
|
}
|
|
843
|
+
/** External-chain destination for a completed outflow. */
|
|
844
|
+
interface ExternalOutflowReceiver {
|
|
845
|
+
/** Destination account type reported by the protocol. */
|
|
846
|
+
type: "External";
|
|
847
|
+
/** External-chain destination address. */
|
|
848
|
+
account: string;
|
|
849
|
+
}
|
|
784
850
|
/**
|
|
785
851
|
* Receipt for a borrow or withdraw submitted to the lending canister.
|
|
786
852
|
*
|
|
@@ -804,18 +870,12 @@ interface OutflowDetails {
|
|
|
804
870
|
/** Borrow receipt with an external-chain receiver. */
|
|
805
871
|
type BorrowOutflowDetails = OutflowDetails & {
|
|
806
872
|
outflowType: "borrow";
|
|
807
|
-
receiver:
|
|
808
|
-
type: "External";
|
|
809
|
-
account: string;
|
|
810
|
-
};
|
|
873
|
+
receiver: ExternalOutflowReceiver;
|
|
811
874
|
};
|
|
812
875
|
/** Withdraw receipt with an external-chain receiver. */
|
|
813
876
|
type WithdrawOutflowDetails = OutflowDetails & {
|
|
814
877
|
outflowType: "withdraw";
|
|
815
|
-
receiver:
|
|
816
|
-
type: "External";
|
|
817
|
-
account: string;
|
|
818
|
-
};
|
|
878
|
+
receiver: ExternalOutflowReceiver;
|
|
819
879
|
};
|
|
820
880
|
/** Signature payload for submitting a prepared borrow action. */
|
|
821
881
|
interface BorrowSubmitSignatureInfo extends SignatureInfo {
|
|
@@ -834,7 +894,7 @@ interface CreateBorrowRequest {
|
|
|
834
894
|
poolId: string;
|
|
835
895
|
/** Amount to borrow in the borrow asset's base units. */
|
|
836
896
|
amount: bigint;
|
|
837
|
-
/** External-chain address that receives the borrowed asset. */
|
|
897
|
+
/** External-chain address that receives the borrowed asset. Must match the borrow pool chain. */
|
|
838
898
|
receiverAddress: string;
|
|
839
899
|
/** Wallet address that signs the borrow authorization. */
|
|
840
900
|
signerWalletAddress: string;
|
|
@@ -863,7 +923,7 @@ interface CreateWithdrawRequest {
|
|
|
863
923
|
poolId: string;
|
|
864
924
|
/** Amount to withdraw in the pool asset's base units. */
|
|
865
925
|
amount: bigint;
|
|
866
|
-
/** External-chain address that receives the withdrawn asset. */
|
|
926
|
+
/** External-chain address that receives the withdrawn asset. Must match the pool chain. */
|
|
867
927
|
receiverAddress: string;
|
|
868
928
|
/** Wallet address that signs the withdraw authorization. */
|
|
869
929
|
signerWalletAddress: string;
|
|
@@ -1014,9 +1074,20 @@ interface EstimateInflowFeeRequest {
|
|
|
1014
1074
|
/** Chain to estimate for. */
|
|
1015
1075
|
chain: Chain;
|
|
1016
1076
|
}
|
|
1017
|
-
/**
|
|
1077
|
+
/** Request for an ETH stablecoin deposit address. */
|
|
1078
|
+
interface GetDepositAddressRequest {
|
|
1079
|
+
/** Liquidium profile principal text. */
|
|
1080
|
+
profileId: string;
|
|
1081
|
+
/** Pool principal text receiving the inflow. */
|
|
1082
|
+
poolId: string;
|
|
1083
|
+
/** ETH stablecoin asset. */
|
|
1084
|
+
asset: string;
|
|
1085
|
+
/** Deposit or repayment action for the inflow. */
|
|
1086
|
+
action: SupplyAction;
|
|
1087
|
+
}
|
|
1088
|
+
/** Fee estimate for an inflow target, rounded up to the asset's fee unit. */
|
|
1018
1089
|
interface InflowFeeEstimate {
|
|
1019
|
-
/** Estimated total fee in the asset's base units. */
|
|
1090
|
+
/** Estimated total fee rounded up in the asset's base units. */
|
|
1020
1091
|
totalFee: bigint;
|
|
1021
1092
|
}
|
|
1022
1093
|
/** Request for ERC-20 approval and deposit planning. */
|
|
@@ -1074,10 +1145,6 @@ interface EvmSupplyContext {
|
|
|
1074
1145
|
approvalStrategy: EvmSupplyApprovalStrategy;
|
|
1075
1146
|
}
|
|
1076
1147
|
|
|
1077
|
-
type WalletExecutionParams = {
|
|
1078
|
-
signerChain: Chain;
|
|
1079
|
-
signerWalletAdapter: WalletAdapter;
|
|
1080
|
-
};
|
|
1081
1148
|
/** Borrow, withdraw, supply, inflow reporting, and fee-estimation helpers. */
|
|
1082
1149
|
declare class LendingModule {
|
|
1083
1150
|
private readonly canisterContext;
|
|
@@ -1160,22 +1227,18 @@ declare class LendingModule {
|
|
|
1160
1227
|
* @param request - Profile, pool, asset, and supply action.
|
|
1161
1228
|
* @returns The EVM deposit address for the derived account.
|
|
1162
1229
|
*/
|
|
1163
|
-
getDepositAddress(request:
|
|
1164
|
-
profileId: string;
|
|
1165
|
-
poolId: string;
|
|
1166
|
-
asset: string;
|
|
1167
|
-
action: SupplyAction;
|
|
1168
|
-
}): Promise<string>;
|
|
1230
|
+
getDepositAddress(request: GetDepositAddressRequest): Promise<string>;
|
|
1169
1231
|
/**
|
|
1170
1232
|
* Estimates the network/deposit fee for an inflow target.
|
|
1171
1233
|
*
|
|
1172
1234
|
* ETH stablecoin deposit-address estimates are served by the deposit-address
|
|
1173
|
-
* canister. BTC estimates
|
|
1235
|
+
* canister. BTC estimates include the ckBTC minter deposit fee and ledger fee.
|
|
1174
1236
|
*
|
|
1175
1237
|
* @param request - Asset and chain pair to estimate for.
|
|
1176
|
-
* @returns Total fee estimate in the asset's base units.
|
|
1238
|
+
* @returns Total fee estimate rounded up in the asset's base units.
|
|
1177
1239
|
*/
|
|
1178
1240
|
estimateInflowFee(request: EstimateInflowFeeRequest): Promise<InflowFeeEstimate>;
|
|
1241
|
+
private estimateBtcInflowFee;
|
|
1179
1242
|
private sendAndSubmitNativeSupplyInflow;
|
|
1180
1243
|
private submitSupplyFlowInflow;
|
|
1181
1244
|
private executeContractSupply;
|
|
@@ -1199,6 +1262,7 @@ declare class LendingModule {
|
|
|
1199
1262
|
private requireApi;
|
|
1200
1263
|
private requireEvmReadClient;
|
|
1201
1264
|
private getPoolById;
|
|
1265
|
+
private normalizeOutflowReceiverAddress;
|
|
1202
1266
|
private sendEthContractTransaction;
|
|
1203
1267
|
private waitForExpectedAllowance;
|
|
1204
1268
|
}
|
|
@@ -1489,14 +1553,7 @@ declare class PositionsModule {
|
|
|
1489
1553
|
}
|
|
1490
1554
|
|
|
1491
1555
|
/** Builds calldata for an ERC-20 `transfer(recipient, amount)` transaction. */
|
|
1492
|
-
declare function createTransferErc20Transaction(params:
|
|
1493
|
-
tokenAddress: string;
|
|
1494
|
-
recipientAddress: string;
|
|
1495
|
-
amount: bigint;
|
|
1496
|
-
}): {
|
|
1497
|
-
to: string;
|
|
1498
|
-
data: string;
|
|
1499
|
-
};
|
|
1556
|
+
declare function createTransferErc20Transaction(params: CreateTransferErc20TransactionParams): EvmContractTransaction;
|
|
1500
1557
|
|
|
1501
1558
|
/** Asset symbols supported by the instant-loans canister. */
|
|
1502
1559
|
type InstantLoanAsset = "BTC" | "SOL" | "USDC" | "USDT";
|
|
@@ -1574,11 +1631,13 @@ interface CreateInstantLoanRequest {
|
|
|
1574
1631
|
*/
|
|
1575
1632
|
borrowAsset: InstantLoanAsset;
|
|
1576
1633
|
/**
|
|
1577
|
-
*
|
|
1634
|
+
* Intended credited collateral amount, in base units.
|
|
1578
1635
|
*
|
|
1579
|
-
* This is used to validate LTV and initialize the loan record
|
|
1580
|
-
*
|
|
1581
|
-
* `decimals` value.
|
|
1636
|
+
* This is used to validate LTV and initialize the loan record before
|
|
1637
|
+
* deposit/inflow fees are deducted. For BTC, pass satoshis. For token assets,
|
|
1638
|
+
* convert the UI amount using the selected pool's `decimals` value. After
|
|
1639
|
+
* creation, use `loan.initialDeposit.amount` as the fee-inclusive transfer
|
|
1640
|
+
* amount to send to `loan.initialDeposit.target`.
|
|
1582
1641
|
*/
|
|
1583
1642
|
collateralAmount: bigint;
|
|
1584
1643
|
/**
|
|
@@ -1622,12 +1681,18 @@ interface CreateInstantLoanRequest {
|
|
|
1622
1681
|
*/
|
|
1623
1682
|
refundDestination: string | ExternalAccount;
|
|
1624
1683
|
}
|
|
1625
|
-
/** Lookup request for loading
|
|
1626
|
-
|
|
1684
|
+
/** Lookup request for loading an instant loan by numeric canister id. */
|
|
1685
|
+
interface InstantLoanGetByIdRequest {
|
|
1686
|
+
/** Canister-assigned loan id. */
|
|
1627
1687
|
loanId: bigint;
|
|
1628
|
-
}
|
|
1688
|
+
}
|
|
1689
|
+
/** Lookup request for loading an instant loan by short user-facing reference. */
|
|
1690
|
+
interface InstantLoanGetByRefRequest {
|
|
1691
|
+
/** Short user-facing reference derived from `loanId`. */
|
|
1629
1692
|
ref: string;
|
|
1630
|
-
}
|
|
1693
|
+
}
|
|
1694
|
+
/** Lookup request for loading canonical instant-loan state. */
|
|
1695
|
+
type InstantLoanGetRequest = InstantLoanGetByIdRequest | InstantLoanGetByRefRequest;
|
|
1631
1696
|
/** Page request for direct instant-loan canister event queries. */
|
|
1632
1697
|
interface InstantLoanListEventsRequest {
|
|
1633
1698
|
/** Event id to start from. */
|
|
@@ -1663,8 +1728,8 @@ interface InstantLoanEvent {
|
|
|
1663
1728
|
}
|
|
1664
1729
|
/** Instant-loan leg used when stuck funds are withdrawn. */
|
|
1665
1730
|
type InstantLoanLeg = "Lend" | "Borrow";
|
|
1666
|
-
/**
|
|
1667
|
-
|
|
1731
|
+
/** Loan-created instant-loan event payload. */
|
|
1732
|
+
interface InstantLoanCreatedEventType {
|
|
1668
1733
|
type: "LoanCreated";
|
|
1669
1734
|
loanId: bigint;
|
|
1670
1735
|
borrowDestination: InstantLoanAccount;
|
|
@@ -1677,42 +1742,58 @@ type InstantLoanEventType = {
|
|
|
1677
1742
|
profileId: string;
|
|
1678
1743
|
borrowPoolId: string;
|
|
1679
1744
|
borrowAsset: InstantLoanAsset;
|
|
1680
|
-
}
|
|
1745
|
+
}
|
|
1746
|
+
/** Full collateral withdrawal request event payload. */
|
|
1747
|
+
interface InstantLoanFullLendWithdrawalRequestedEventType {
|
|
1681
1748
|
type: "FullLendWithdrawalRequested";
|
|
1682
1749
|
loanId: bigint;
|
|
1683
1750
|
account: InstantLoanAccount;
|
|
1684
1751
|
poolId: string;
|
|
1685
|
-
}
|
|
1752
|
+
}
|
|
1753
|
+
/** Borrow request event payload. */
|
|
1754
|
+
interface InstantLoanBorrowRequestedEventType {
|
|
1686
1755
|
type: "BorrowRequested";
|
|
1687
1756
|
loanId: bigint;
|
|
1688
1757
|
account: InstantLoanAccount;
|
|
1689
1758
|
poolId: string;
|
|
1690
1759
|
amount: bigint;
|
|
1691
|
-
}
|
|
1760
|
+
}
|
|
1761
|
+
/** Deposit timer exceeded event payload. */
|
|
1762
|
+
interface InstantLoanDepositTimerExceededEventType {
|
|
1692
1763
|
type: "DepositTimerExceeded";
|
|
1693
1764
|
loanId: bigint;
|
|
1694
|
-
}
|
|
1765
|
+
}
|
|
1766
|
+
/** Stuck funds withdrawal request event payload. */
|
|
1767
|
+
interface InstantLoanStuckFundsWithdrawalRequestedEventType {
|
|
1695
1768
|
type: "StuckFundsWithdrawalRequested";
|
|
1696
1769
|
leg: InstantLoanLeg;
|
|
1697
1770
|
loanId: bigint;
|
|
1698
1771
|
account: InstantLoanAccount;
|
|
1699
1772
|
poolId: string;
|
|
1700
1773
|
amount: bigint;
|
|
1701
|
-
}
|
|
1774
|
+
}
|
|
1775
|
+
/** Profile-warmed event payload. */
|
|
1776
|
+
interface InstantLoanProfileWarmedEventType {
|
|
1702
1777
|
type: "ProfileWarmed";
|
|
1703
1778
|
derivationIndex: Uint8Array;
|
|
1704
1779
|
warmedProfileId: bigint;
|
|
1705
1780
|
ethAddress: string;
|
|
1706
1781
|
profileId: string;
|
|
1707
|
-
}
|
|
1782
|
+
}
|
|
1783
|
+
/** Repay-complete event payload. */
|
|
1784
|
+
interface InstantLoanRepayCompleteEventType {
|
|
1708
1785
|
type: "RepayComplete";
|
|
1709
1786
|
loanId: bigint;
|
|
1710
1787
|
profileId: string;
|
|
1711
|
-
}
|
|
1788
|
+
}
|
|
1789
|
+
/** Deposit timer started event payload. */
|
|
1790
|
+
interface InstantLoanDepositTimerStartedEventType {
|
|
1712
1791
|
type: "DepositTimerStarted";
|
|
1713
1792
|
loanId: bigint;
|
|
1714
1793
|
timestamp: bigint;
|
|
1715
|
-
}
|
|
1794
|
+
}
|
|
1795
|
+
/** Direct canister event payload returned by instant-loans event queries. */
|
|
1796
|
+
type InstantLoanEventType = InstantLoanCreatedEventType | InstantLoanFullLendWithdrawalRequestedEventType | InstantLoanBorrowRequestedEventType | InstantLoanDepositTimerExceededEventType | InstantLoanStuckFundsWithdrawalRequestedEventType | InstantLoanProfileWarmedEventType | InstantLoanRepayCompleteEventType | InstantLoanDepositTimerStartedEventType;
|
|
1716
1797
|
/** Current amount to send to the repayment target to close the debt. */
|
|
1717
1798
|
interface InstantLoanRepayment {
|
|
1718
1799
|
/** Full amount to send to the repayment target, including fee and interest buffer. */
|
|
@@ -1736,6 +1817,23 @@ interface InstantLoanRepayment {
|
|
|
1736
1817
|
/** Address or ICRC account where the repayment should be sent. */
|
|
1737
1818
|
target: SupplyTarget;
|
|
1738
1819
|
}
|
|
1820
|
+
/** Initial collateral deposit quote returned when an instant loan is created. */
|
|
1821
|
+
interface InstantLoanInitialDeposit {
|
|
1822
|
+
/** Full amount to send to the deposit target, including the estimated inflow fee. */
|
|
1823
|
+
amount: bigint;
|
|
1824
|
+
/** Decimal scale for `amount`, `collateralAmount`, and `inflowFeeAmount`. */
|
|
1825
|
+
decimals: bigint;
|
|
1826
|
+
/** Intended credited collateral amount in base units, before inflow fees. */
|
|
1827
|
+
collateralAmount: bigint;
|
|
1828
|
+
/** Inflow fee amount in base units added to the transfer amount. */
|
|
1829
|
+
inflowFeeAmount: bigint;
|
|
1830
|
+
/** Collateral asset to deposit. */
|
|
1831
|
+
asset: MarketAsset;
|
|
1832
|
+
/** Chain used for the collateral deposit. */
|
|
1833
|
+
chain: MarketChain;
|
|
1834
|
+
/** Address or ICRC account where the collateral should be sent. */
|
|
1835
|
+
target: SupplyTarget;
|
|
1836
|
+
}
|
|
1739
1837
|
/** Current lending position backing the instant loan. */
|
|
1740
1838
|
interface InstantLoanPositionSummary {
|
|
1741
1839
|
/** Current collateral amount in the collateral asset's base units. */
|
|
@@ -1760,9 +1858,45 @@ declare const InstantLoanStatus: {
|
|
|
1760
1858
|
readonly active: "active";
|
|
1761
1859
|
readonly settling: "settling";
|
|
1762
1860
|
readonly closed: "closed";
|
|
1861
|
+
readonly expired: "expired";
|
|
1763
1862
|
};
|
|
1764
1863
|
type InstantLoanStatus = (typeof InstantLoanStatus)[keyof typeof InstantLoanStatus];
|
|
1765
|
-
/**
|
|
1864
|
+
/** Immutable terms selected for an instant loan. */
|
|
1865
|
+
interface InstantLoanTerms {
|
|
1866
|
+
/** Maximum loan-to-value ratio in basis points. */
|
|
1867
|
+
ltvMaxBps: bigint;
|
|
1868
|
+
/** Seconds allowed for the collateral deposit before timeout. */
|
|
1869
|
+
depositWindowSeconds: bigint;
|
|
1870
|
+
}
|
|
1871
|
+
/** Collateral leg selected for an instant loan. */
|
|
1872
|
+
interface InstantLoanCollateral {
|
|
1873
|
+
/** Principal text of the collateral pool. */
|
|
1874
|
+
poolId: string;
|
|
1875
|
+
/** Collateral asset symbol. */
|
|
1876
|
+
asset: MarketAsset;
|
|
1877
|
+
/** Chain used for collateral deposits. */
|
|
1878
|
+
chain: MarketChain;
|
|
1879
|
+
/** Decimal scale for collateral amounts. */
|
|
1880
|
+
decimals: bigint;
|
|
1881
|
+
/** Intended credited collateral amount in base units, before inflow fees. */
|
|
1882
|
+
amount: bigint;
|
|
1883
|
+
}
|
|
1884
|
+
/** Borrow leg selected for an instant loan. */
|
|
1885
|
+
interface InstantLoanBorrow {
|
|
1886
|
+
/** Principal text of the borrow pool. */
|
|
1887
|
+
poolId: string;
|
|
1888
|
+
/** Borrow asset symbol. */
|
|
1889
|
+
asset: MarketAsset;
|
|
1890
|
+
/** Chain used for repayment. */
|
|
1891
|
+
chain: MarketChain;
|
|
1892
|
+
/** Decimal scale for borrow and debt amounts. */
|
|
1893
|
+
decimals: bigint;
|
|
1894
|
+
/** Requested borrow amount in base units. */
|
|
1895
|
+
amount: bigint;
|
|
1896
|
+
/** Destination that receives the borrowed asset. */
|
|
1897
|
+
destination: InstantLoanAccount;
|
|
1898
|
+
}
|
|
1899
|
+
/** Hydrated instant-loan state plus generated quote targets. */
|
|
1766
1900
|
interface InstantLoan {
|
|
1767
1901
|
/** Canister-assigned loan id. */
|
|
1768
1902
|
loanId: bigint;
|
|
@@ -1772,32 +1906,17 @@ interface InstantLoan {
|
|
|
1772
1906
|
status: InstantLoanStatus;
|
|
1773
1907
|
/** Generated lending profile principal used by the instant loan. */
|
|
1774
1908
|
profileId: string;
|
|
1775
|
-
/**
|
|
1776
|
-
|
|
1777
|
-
/**
|
|
1778
|
-
|
|
1779
|
-
/**
|
|
1780
|
-
|
|
1781
|
-
poolId: string;
|
|
1782
|
-
asset: MarketAsset;
|
|
1783
|
-
chain: MarketChain;
|
|
1784
|
-
amount: bigint;
|
|
1785
|
-
};
|
|
1786
|
-
/** Borrow-side pool, asset, chain, requested amount, and destination. */
|
|
1787
|
-
borrow: {
|
|
1788
|
-
poolId: string;
|
|
1789
|
-
asset: MarketAsset;
|
|
1790
|
-
chain: MarketChain;
|
|
1791
|
-
amount: bigint;
|
|
1792
|
-
destination: InstantLoanAccount;
|
|
1793
|
-
};
|
|
1909
|
+
/** Immutable loan terms. */
|
|
1910
|
+
terms: InstantLoanTerms;
|
|
1911
|
+
/** Collateral-side pool, asset, chain, decimals, and requested credited amount. */
|
|
1912
|
+
collateral: InstantLoanCollateral;
|
|
1913
|
+
/** Borrow-side pool, asset, chain, decimals, requested amount, and destination. */
|
|
1914
|
+
borrow: InstantLoanBorrow;
|
|
1794
1915
|
/** Destination used for collateral refunds or withdrawals. */
|
|
1795
1916
|
refundDestination: InstantLoanAccount;
|
|
1796
|
-
/**
|
|
1797
|
-
|
|
1798
|
-
/**
|
|
1799
|
-
repayTarget: SupplyTarget;
|
|
1800
|
-
/** Current actionable repayment quote. */
|
|
1917
|
+
/** Current actionable initial collateral deposit quote. */
|
|
1918
|
+
initialDeposit: InstantLoanInitialDeposit;
|
|
1919
|
+
/** Current repayment quote. Amount fields are zero when the loan has no debt. */
|
|
1801
1920
|
repayment: InstantLoanRepayment;
|
|
1802
1921
|
/** Current lending position state for the generated profile. */
|
|
1803
1922
|
position: InstantLoanPositionSummary;
|
|
@@ -1825,8 +1944,8 @@ interface InstantLoanCandidate {
|
|
|
1825
1944
|
collateralAsset: MarketAsset;
|
|
1826
1945
|
/** Borrow asset symbol. */
|
|
1827
1946
|
borrowAsset: MarketAsset;
|
|
1828
|
-
/** Collateral amount
|
|
1829
|
-
|
|
1947
|
+
/** Collateral amount in base units. */
|
|
1948
|
+
collateralAmount: bigint;
|
|
1830
1949
|
}
|
|
1831
1950
|
|
|
1832
1951
|
/** Accountless instant-loan creation, lookup, recovery, and canister query helpers. */
|
|
@@ -1838,7 +1957,7 @@ declare class InstantLoansModule {
|
|
|
1838
1957
|
constructor(canisterContext: CanisterContext, apiClient: ApiClient | undefined, lending: LendingModule, positions: PositionsModule);
|
|
1839
1958
|
/**
|
|
1840
1959
|
* Creates a profileless instant loan and returns canonical canister state plus
|
|
1841
|
-
* deposit
|
|
1960
|
+
* generated initial-deposit and repayment quote targets.
|
|
1842
1961
|
*
|
|
1843
1962
|
* Choose `collateralPoolId` and `borrowPoolId` from
|
|
1844
1963
|
* `client.market.listPools()`, convert UI amounts to base units with the
|
|
@@ -1851,7 +1970,7 @@ declare class InstantLoansModule {
|
|
|
1851
1970
|
* SDK maps it to the canister's internal `ltv_timer_s` field.
|
|
1852
1971
|
*
|
|
1853
1972
|
* @param request - Pool ids, assets, base-unit amounts, LTV limit, timeout, and destinations.
|
|
1854
|
-
* @returns Hydrated loan state plus generated deposit and repayment targets.
|
|
1973
|
+
* @returns Hydrated loan state plus generated initial-deposit and repayment quote targets.
|
|
1855
1974
|
*/
|
|
1856
1975
|
create(request: CreateInstantLoanRequest): Promise<InstantLoan>;
|
|
1857
1976
|
/**
|
|
@@ -1861,7 +1980,7 @@ declare class InstantLoansModule {
|
|
|
1861
1980
|
* from the instant-loans canister.
|
|
1862
1981
|
*
|
|
1863
1982
|
* @param request - Canister loan id or short public reference.
|
|
1864
|
-
* @returns Hydrated loan state plus generated deposit and repayment targets.
|
|
1983
|
+
* @returns Hydrated loan state plus generated initial-deposit and repayment quote targets.
|
|
1865
1984
|
*/
|
|
1866
1985
|
get(request: InstantLoanGetRequest): Promise<InstantLoan>;
|
|
1867
1986
|
/**
|
|
@@ -1914,8 +2033,10 @@ declare class InstantLoansModule {
|
|
|
1914
2033
|
*/
|
|
1915
2034
|
findByAddress(address: string): Promise<InstantLoanCandidate[]>;
|
|
1916
2035
|
private mapLoanRecord;
|
|
2036
|
+
private getCollateralAmountHint;
|
|
1917
2037
|
private mapLoanWire;
|
|
1918
2038
|
private hydrateLoan;
|
|
2039
|
+
private createInitialDepositQuote;
|
|
1919
2040
|
private estimateRepaymentInflowFee;
|
|
1920
2041
|
private requireApi;
|
|
1921
2042
|
private validateInstantLoanLtvPolicy;
|
|
@@ -2102,6 +2223,20 @@ declare class LiquidiumClient {
|
|
|
2102
2223
|
constructor(config?: LiquidiumClientConfig);
|
|
2103
2224
|
}
|
|
2104
2225
|
|
|
2226
|
+
/** Minimum borrow amounts in each asset's base units. */
|
|
2227
|
+
declare const MIN_BORROW_AMOUNTS_BY_ASSET: {
|
|
2228
|
+
readonly BTC: 5100n;
|
|
2229
|
+
readonly USDC: 1000000n;
|
|
2230
|
+
readonly USDT: 1000000n;
|
|
2231
|
+
};
|
|
2232
|
+
type MinimumBorrowAsset = keyof typeof MIN_BORROW_AMOUNTS_BY_ASSET;
|
|
2233
|
+
/**
|
|
2234
|
+
* Returns the minimum borrow amount for an asset in base units.
|
|
2235
|
+
*
|
|
2236
|
+
* Assets without a configured product minimum return `0n`.
|
|
2237
|
+
*/
|
|
2238
|
+
declare function getMinimumBorrowAmount(asset: string): bigint;
|
|
2239
|
+
|
|
2105
2240
|
/**
|
|
2106
2241
|
* Stable string codes for {@link LiquidiumError}. Use for branching in application code.
|
|
2107
2242
|
*/
|
|
@@ -2213,4 +2348,4 @@ interface ExecuteWithOptions {
|
|
|
2213
2348
|
*/
|
|
2214
2349
|
declare function executeWith(options: ExecuteWithOptions): <TResult>(action: WalletAction<TResult>) => Promise<TResult>;
|
|
2215
2350
|
|
|
2216
|
-
export { AccountsModule, ActivitiesModule, type ActivitiesRequest, type Activity, ActivityDirection, ActivityFilter, ActivityKind, ActivityStatus, type ActivityTopUp, type ApySample, Asset, type AssetPrices, type BorrowAction, type BorrowApyHistoryRequest, type BorrowOutflowDetails, type BorrowSubmitSignatureInfo, type BorrowingPower, CK_ETH_DEPOSIT_CONTRACT_ADDRESS, type CalculateLtvRequest, type CanisterIds, Chain, type ContractInteractionSupplyFlowRequest, type CreateAccountAction, type CreateAccountData, type CreateAccountRequest, type CreateBorrowData, type CreateBorrowRequest, type CreateInstantLoanRequest, type CreateProfileParams, type CreateWithdrawData, type CreateWithdrawRequest, Environment, type EstimateInflowFeeRequest, type EthTransactionRequest, type EvmReadClient, EvmSupplyApprovalStrategy, type EvmSupplyContext, type ExecuteWithOptions, type ExternalAccount, type FindPoolQuery, type GetActivityStatusRequest, type GetActivityStatusResponse, type GetEvmSupplyContextRequest, type HealthFactor, type HistoryEntry, HistoryModule, type IcrcAccountSupplyTarget, type InflowActivity, type InflowActivityKind, type InflowActivityStatus, type InflowFeeEstimate, InflowSubmitType, type InstantLoan, type InstantLoanAccount, type InstantLoanAsset, type InstantLoanAuthorization, type InstantLoanCandidate, type InstantLoanConfig, type InstantLoanEvent, type InstantLoanEventType, type InstantLoanGetRequest, type InstantLoanLeg, type InstantLoanListEventsRequest, type InstantLoanPositionSummary, type InstantLoanRepayment, InstantLoanStatus, type InstantLoanWarmedProfile, InstantLoansModule, LendingModule, LiquidiumClient, type LiquidiumClientConfig, LiquidiumError, LiquidiumErrorCode, type LiquidiumErrorContext, type ListActivitiesRequest, type LtvCalculation, type ManualTransferSupplyFlowRequest, type MarketAsset, type MarketChain, MarketModule, type MaxRepayAmount, type NativeAccount, type NativeAddressSupplyTarget, type OutflowActivity, type OutflowActivityKind, type OutflowActivityStatus, type OutflowDetails, type OutflowReceiver, OutflowType, type PaginatedResponse, type Pool, type PoolConfigHistoryEntry, type PoolConfigHistoryEntryApiItem, type PoolConfigHistoryResponse, type PoolHistoryEntry, type PoolHistoryEntryApiItem, type PoolHistoryRequest, type PoolHistoryResponse, type PoolRate, type Position, PositionsModule, type PrepareCreateProfileOptions, QuoteModule, type QuoteRequest, type QuoteResult, type QuoteValidationError, QuoteValidationErrorCode, type QuoteWarning, QuoteWarningCode, RATE_DECIMALS, RATE_SCALE, type SendBtcTransactionRequest, type SendEthTransactionRequest, type SendEthTransactionWalletAction, type SignMessageRequest, type SignMessageWalletAction, type SignPsbtRequest, type SignPsbtWalletAction, type SignableAction, type SignatureInfo, type SubmitInflowRequest, type SubmitInflowResponse, SupplyAction, type SupplyFlow, type SupplyFlowRequest, SupplyPlanType, type SupplyTarget, TransferMode, type TransferSupplyFlowRequest, USDC_CONTRACT_ADDRESS, USDT_CONTRACT_ADDRESS, type UserHistoryEntry, type UserHistoryEntryApiItem, type UserHistoryResponse, UserHistoryStatus, type UserHistoryStatusApi, type UserHistoryType, type UserLiquidationHistoryEntry, type UserLiquidationHistoryFilters, type UserLiquidationHistoryType, type UserPositionSummary, type UserReserve, type UserStats, type UserTransactionHistoryEntry, type UserTransactionHistoryFilters, type UserTransactionHistoryType, type Wallet, type WalletAction, type WalletAdapter, WalletExecutionKind, type WalletExecutionParams, type WalletTransferSupplyFlowRequest, type WithdrawAction, type WithdrawOutflowDetails, type WithdrawSubmitSignatureInfo, createTransferErc20Transaction, executeWith, intFromPublicId, publicIdFromInt };
|
|
2351
|
+
export { AccountsModule, ActivitiesModule, type ActivitiesRequest, type Activity, ActivityDirection, ActivityFilter, ActivityKind, ActivityStatus, type ActivityStatusFoundResponse, type ActivityStatusNotFoundResponse, type ActivityTopUp, type ApySample, Asset, type AssetPrices, type BaseGetActivityStatusRequest, type BaseListActivitiesRequest, type BorrowAction, type BorrowApyHistoryRequest, type BorrowOutflowDetails, type BorrowSubmitSignatureInfo, type BorrowingPower, CK_ETH_DEPOSIT_CONTRACT_ADDRESS, type CalculateLtvRequest, type CanisterIds, Chain, type ContractInteractionSupplyFlowRequest, type CreateAccountAction, type CreateAccountData, type CreateAccountRequest, type CreateBorrowData, type CreateBorrowRequest, type CreateInstantLoanRequest, type CreateProfileParams, type CreateTransferErc20TransactionParams, type CreateWithdrawData, type CreateWithdrawRequest, Environment, type EstimateInflowFeeRequest, type EthTransactionRequest, type EvmContractTransaction, type EvmReadClient, EvmSupplyApprovalStrategy, type EvmSupplyContext, type ExecuteWithOptions, type ExternalAccount, type ExternalOutflowReceiver, type FindPoolQuery, type GetActivityStatusByProfileRequest, type GetActivityStatusByShortRefRequest, type GetActivityStatusRequest, type GetActivityStatusResponse, type GetDepositAddressRequest, type GetEvmSupplyContextRequest, type HealthFactor, type HistoryEntry, HistoryModule, type IcrcAccountSupplyTarget, type InflowActivity, type InflowActivityKind, type InflowActivityStatus, type InflowFeeEstimate, InflowSubmitType, type InstantLoan, type InstantLoanAccount, type InstantLoanAsset, type InstantLoanAuthorization, type InstantLoanBorrow, type InstantLoanBorrowRequestedEventType, type InstantLoanCandidate, type InstantLoanCollateral, type InstantLoanConfig, type InstantLoanCreatedEventType, type InstantLoanDepositTimerExceededEventType, type InstantLoanDepositTimerStartedEventType, type InstantLoanEvent, type InstantLoanEventType, type InstantLoanFullLendWithdrawalRequestedEventType, type InstantLoanGetByIdRequest, type InstantLoanGetByRefRequest, type InstantLoanGetRequest, type InstantLoanInitialDeposit, type InstantLoanLeg, type InstantLoanListEventsRequest, type InstantLoanPositionSummary, type InstantLoanProfileWarmedEventType, type InstantLoanRepayCompleteEventType, type InstantLoanRepayment, InstantLoanStatus, type InstantLoanStuckFundsWithdrawalRequestedEventType, type InstantLoanTerms, type InstantLoanWarmedProfile, InstantLoansModule, LendingModule, LiquidiumClient, type LiquidiumClientConfig, LiquidiumError, LiquidiumErrorCode, type LiquidiumErrorContext, type ListActivitiesByProfileRequest, type ListActivitiesByShortRefRequest, type ListActivitiesRequest, type LtvCalculation, MIN_BORROW_AMOUNTS_BY_ASSET, type ManualTransferSupplyFlowRequest, type MarketAsset, type MarketChain, MarketModule, type MaxRepayAmount, type MinimumBorrowAsset, type NativeAccount, type NativeAddressSupplyTarget, type OutflowActivity, type OutflowActivityKind, type OutflowActivityStatus, type OutflowDetails, type OutflowReceiver, OutflowType, type PaginatedResponse, type Pool, type PoolConfigHistoryEntry, type PoolConfigHistoryEntryApiItem, type PoolConfigHistoryResponse, type PoolHistoryEntry, type PoolHistoryEntryApiItem, type PoolHistoryRequest, type PoolHistoryResponse, type PoolRate, type Position, PositionsModule, type PrepareCreateProfileOptions, QuoteModule, type QuoteRequest, type QuoteResult, type QuoteValidationError, QuoteValidationErrorCode, type QuoteWarning, QuoteWarningCode, RATE_DECIMALS, RATE_SCALE, type SendBtcTransactionRequest, type SendEthTransactionRequest, type SendEthTransactionSubmitRequest, type SendEthTransactionWalletAction, type SignMessageRequest, type SignMessageWalletAction, type SignPsbtRequest, type SignPsbtSubmitRequest, type SignPsbtWalletAction, type SignableAction, type SignatureInfo, type SubmitInflowRequest, type SubmitInflowResponse, SupplyAction, type SupplyFlow, type SupplyFlowRequest, SupplyPlanType, type SupplyTarget, TransferMode, type TransferSupplyFlowRequest, USDC_CONTRACT_ADDRESS, USDT_CONTRACT_ADDRESS, type UserHistoryEntry, type UserHistoryEntryApiItem, type UserHistoryResponse, UserHistoryStatus, type UserHistoryStatusApi, type UserHistoryType, type UserLiquidationHistoryEntry, type UserLiquidationHistoryFilters, type UserLiquidationHistoryType, type UserPositionSummary, type UserReserve, type UserStats, type UserTransactionHistoryEntry, type UserTransactionHistoryFilters, type UserTransactionHistoryType, type Wallet, type WalletAction, type WalletAdapter, WalletExecutionKind, type WalletExecutionParams, type WalletTransferSupplyFlowRequest, type WithdrawAction, type WithdrawOutflowDetails, type WithdrawSubmitSignatureInfo, createTransferErc20Transaction, executeWith, getMinimumBorrowAmount, intFromPublicId, publicIdFromInt };
|