@liquidium/client 0.4.1 → 0.5.0-rc.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 +75 -48
- package/dist/index.cjs +1088 -413
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +327 -275
- package/dist/index.d.ts +327 -275
- package/dist/index.js +1087 -414
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ interface LiquidiumClientConfig {
|
|
|
25
25
|
/** Extra headers sent with every SDK API request. */
|
|
26
26
|
headers?: Record<string, string>;
|
|
27
27
|
/** Override individual canister principals for custom deployments. */
|
|
28
|
-
canisterIds?:
|
|
28
|
+
canisterIds?: CanisterIdOverrides;
|
|
29
29
|
/** Custom `fetch` implementation for SDK API requests. */
|
|
30
30
|
fetch?: typeof fetch;
|
|
31
31
|
/** Per-request timeout for SDK API calls in milliseconds. */
|
|
@@ -37,19 +37,33 @@ interface LiquidiumClientConfig {
|
|
|
37
37
|
/** Existing viem public client or compatible read client for EVM reads. */
|
|
38
38
|
evmPublicClient?: EvmReadClient;
|
|
39
39
|
}
|
|
40
|
+
/** Pool canister principal text values grouped by pool asset. */
|
|
41
|
+
interface PoolCanisterIds {
|
|
42
|
+
/** BTC pool canister principal. */
|
|
43
|
+
btc: string;
|
|
44
|
+
/** USDT pool canister principal. */
|
|
45
|
+
usdt: string;
|
|
46
|
+
/** USDC pool canister principal. */
|
|
47
|
+
usdc: string;
|
|
48
|
+
/** ICP pool canister principal. */
|
|
49
|
+
icp: string;
|
|
50
|
+
}
|
|
40
51
|
/** Principal text values for canisters used by the client. */
|
|
41
52
|
interface CanisterIds {
|
|
42
53
|
/** Liquidium lending canister principal. */
|
|
43
54
|
lending: string;
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
/** ERC-20 pool canister principal. */
|
|
47
|
-
ercPool: string;
|
|
55
|
+
/** Pool canister principals grouped by pool asset. */
|
|
56
|
+
pools: PoolCanisterIds;
|
|
48
57
|
/** ckETH minter deposit helper canister principal. */
|
|
49
58
|
ethDeposit: string;
|
|
50
59
|
/** Accountless instant-loans canister principal. */
|
|
51
60
|
instantLoans: string;
|
|
52
61
|
}
|
|
62
|
+
/** Custom canister principal overrides accepted by client configuration. */
|
|
63
|
+
type CanisterIdOverrides = Omit<Partial<CanisterIds>, "pools"> & {
|
|
64
|
+
/** Partial grouped pool canister principal overrides. */
|
|
65
|
+
pools?: Partial<PoolCanisterIds>;
|
|
66
|
+
};
|
|
53
67
|
/** Supported deployment environments with bundled canister ids. */
|
|
54
68
|
declare const Environment: {
|
|
55
69
|
readonly mainnet: "mainnet";
|
|
@@ -59,7 +73,7 @@ type Environment = (typeof Environment)[keyof typeof Environment];
|
|
|
59
73
|
/** Canonical asset symbols supported by state-mutating protocol flows. */
|
|
60
74
|
declare const Asset: {
|
|
61
75
|
readonly BTC: "BTC";
|
|
62
|
-
readonly
|
|
76
|
+
readonly ICP: "ICP";
|
|
63
77
|
readonly USDC: "USDC";
|
|
64
78
|
readonly USDT: "USDT";
|
|
65
79
|
};
|
|
@@ -69,13 +83,40 @@ type Asset = (typeof Asset)[keyof typeof Asset];
|
|
|
69
83
|
declare const Chain: {
|
|
70
84
|
readonly BTC: "BTC";
|
|
71
85
|
readonly ETH: "ETH";
|
|
86
|
+
readonly ICP: "ICP";
|
|
72
87
|
};
|
|
73
88
|
/** Canonical chain identifier used by wallet and protocol actions. */
|
|
74
89
|
type Chain = (typeof Chain)[keyof typeof Chain];
|
|
75
|
-
/**
|
|
76
|
-
type
|
|
77
|
-
/**
|
|
78
|
-
type
|
|
90
|
+
/** Chains whose wallets can authorize Liquidium protocol actions. */
|
|
91
|
+
type SigningChain = typeof Chain.BTC | typeof Chain.ETH;
|
|
92
|
+
/** Supported asset and transfer-chain combinations. */
|
|
93
|
+
type AssetIdentifier = {
|
|
94
|
+
chain: typeof Chain.BTC;
|
|
95
|
+
asset: typeof Asset.BTC;
|
|
96
|
+
} | {
|
|
97
|
+
chain: typeof Chain.ETH;
|
|
98
|
+
asset: typeof Asset.USDC;
|
|
99
|
+
} | {
|
|
100
|
+
chain: typeof Chain.ETH;
|
|
101
|
+
asset: typeof Asset.USDT;
|
|
102
|
+
} | {
|
|
103
|
+
chain: typeof Chain.ICP;
|
|
104
|
+
asset: typeof Asset.BTC;
|
|
105
|
+
} | {
|
|
106
|
+
chain: typeof Chain.ICP;
|
|
107
|
+
asset: typeof Asset.ICP;
|
|
108
|
+
} | {
|
|
109
|
+
chain: typeof Chain.ICP;
|
|
110
|
+
asset: typeof Asset.USDC;
|
|
111
|
+
} | {
|
|
112
|
+
chain: typeof Chain.ICP;
|
|
113
|
+
asset: typeof Asset.USDT;
|
|
114
|
+
};
|
|
115
|
+
/** Returns whether an asset and chain form a supported SDK identifier. */
|
|
116
|
+
declare function isAssetIdentifier(identifier: {
|
|
117
|
+
chain: string;
|
|
118
|
+
asset: string;
|
|
119
|
+
}): identifier is AssetIdentifier;
|
|
79
120
|
/** Inflow operation performed by a supply target. */
|
|
80
121
|
declare const SupplyAction: {
|
|
81
122
|
readonly deposit: "deposit";
|
|
@@ -94,7 +135,7 @@ type OutflowType = (typeof OutflowType)[keyof typeof OutflowType];
|
|
|
94
135
|
/** Wallet address and chain pair linked to a Liquidium profile. */
|
|
95
136
|
interface Wallet {
|
|
96
137
|
/** Chain where the wallet address is valid. */
|
|
97
|
-
chain:
|
|
138
|
+
chain: SigningChain;
|
|
98
139
|
/** Wallet address as stored by the protocol. */
|
|
99
140
|
address: string;
|
|
100
141
|
}
|
|
@@ -104,12 +145,59 @@ interface CanisterContext {
|
|
|
104
145
|
canisterIds: CanisterIds;
|
|
105
146
|
}
|
|
106
147
|
|
|
107
|
-
/**
|
|
108
|
-
declare const
|
|
109
|
-
readonly
|
|
148
|
+
/** Account type hint for Liquidium account inputs and normalized account responses. */
|
|
149
|
+
declare const LiquidiumAccountType: {
|
|
150
|
+
readonly ChainAddress: "ChainAddress";
|
|
151
|
+
readonly IcPrincipal: "IcPrincipal";
|
|
152
|
+
readonly IcpAccountIdentifier: "IcpAccountIdentifier";
|
|
153
|
+
readonly IcrcAccount: "IcrcAccount";
|
|
110
154
|
};
|
|
111
|
-
/**
|
|
112
|
-
type
|
|
155
|
+
/** Account type hint for Liquidium account inputs and normalized account responses. */
|
|
156
|
+
type LiquidiumAccountType = (typeof LiquidiumAccountType)[keyof typeof LiquidiumAccountType];
|
|
157
|
+
/** Chain-native destination account, such as a BTC or EVM address. */
|
|
158
|
+
interface ChainAddressAccount {
|
|
159
|
+
/** Account type. */
|
|
160
|
+
type: "ChainAddress";
|
|
161
|
+
/** Chain-native address. */
|
|
162
|
+
address: string;
|
|
163
|
+
}
|
|
164
|
+
/** IC principal account. */
|
|
165
|
+
interface IcPrincipalAccount {
|
|
166
|
+
/** Account type. */
|
|
167
|
+
type: "IcPrincipal";
|
|
168
|
+
/** Principal text. */
|
|
169
|
+
address: string;
|
|
170
|
+
}
|
|
171
|
+
/** Legacy ICP ledger account identifier. */
|
|
172
|
+
interface IcpAccountIdentifierAccount {
|
|
173
|
+
/** Account type. */
|
|
174
|
+
type: "IcpAccountIdentifier";
|
|
175
|
+
/** ICP ledger account identifier text. */
|
|
176
|
+
address: string;
|
|
177
|
+
}
|
|
178
|
+
/** ICRC account display shape shared by lending and instant-loan responses. */
|
|
179
|
+
interface IcrcAccount {
|
|
180
|
+
/** Account type. */
|
|
181
|
+
type: "IcrcAccount";
|
|
182
|
+
/** ICRC account owner principal text. */
|
|
183
|
+
owner: string;
|
|
184
|
+
/** Optional ICRC subaccount bytes. */
|
|
185
|
+
subaccount?: Uint8Array;
|
|
186
|
+
/** Text-encoded ICRC account for display. */
|
|
187
|
+
address: string;
|
|
188
|
+
}
|
|
189
|
+
/** Normalized Liquidium account returned by SDK flows. */
|
|
190
|
+
type LiquidiumAccount = ChainAddressAccount | IcPrincipalAccount | IcpAccountIdentifierAccount | IcrcAccount;
|
|
191
|
+
/** Address input with an optional account type hint. */
|
|
192
|
+
interface LiquidiumAccountReference {
|
|
193
|
+
/** Address, principal, ICRC account, or ICP account identifier. */
|
|
194
|
+
address: string;
|
|
195
|
+
/** Account type hint. Use string shorthand when the SDK should auto-detect. */
|
|
196
|
+
type: LiquidiumAccountType;
|
|
197
|
+
}
|
|
198
|
+
/** Account input accepted by SDK flows that can auto-detect string addresses. */
|
|
199
|
+
type LiquidiumAccountInput = string | LiquidiumAccountReference;
|
|
200
|
+
|
|
113
201
|
/** Wallet capability required to execute a prepared SDK action. */
|
|
114
202
|
declare const WalletExecutionKind: {
|
|
115
203
|
readonly signMessage: "sign-message";
|
|
@@ -138,33 +226,29 @@ interface EthTransactionRequest {
|
|
|
138
226
|
/** Message-signing request passed to wallet adapters. */
|
|
139
227
|
interface SignMessageRequest {
|
|
140
228
|
/** Chain for the signing wallet. */
|
|
141
|
-
chain:
|
|
229
|
+
chain: SigningChain;
|
|
142
230
|
/** Plaintext message to sign. */
|
|
143
231
|
message: string;
|
|
144
232
|
/** Optional account override for the signing wallet. */
|
|
145
233
|
account?: string;
|
|
146
234
|
/** SDK action type that produced this request. */
|
|
147
235
|
actionType: string;
|
|
148
|
-
/** Transfer path associated with the action. */
|
|
149
|
-
transferMode: TransferMode;
|
|
150
236
|
}
|
|
151
237
|
/** ETH transaction-sending request passed to wallet adapters. */
|
|
152
238
|
interface SendEthTransactionRequest {
|
|
153
239
|
/** ETH chain discriminator. */
|
|
154
|
-
chain:
|
|
240
|
+
chain: "ETH";
|
|
155
241
|
/** Transaction payload to send. */
|
|
156
242
|
transaction: EthTransactionRequest;
|
|
157
243
|
/** Optional account override for the sending wallet. */
|
|
158
244
|
account?: string;
|
|
159
245
|
/** SDK action type that produced this request. */
|
|
160
246
|
actionType: string;
|
|
161
|
-
/** Transfer path associated with the action. */
|
|
162
|
-
transferMode: TransferMode;
|
|
163
247
|
}
|
|
164
248
|
/** BTC transaction-sending request passed to wallet adapters. */
|
|
165
249
|
interface SendBtcTransactionRequest {
|
|
166
250
|
/** BTC chain discriminator. */
|
|
167
|
-
chain:
|
|
251
|
+
chain: "BTC";
|
|
168
252
|
/** Recipient BTC address. */
|
|
169
253
|
toAddress: string;
|
|
170
254
|
/** Amount in satoshis when the SDK knows the transfer amount. */
|
|
@@ -173,15 +257,40 @@ interface SendBtcTransactionRequest {
|
|
|
173
257
|
account?: string;
|
|
174
258
|
/** SDK action type that produced this request. */
|
|
175
259
|
actionType: string;
|
|
176
|
-
|
|
177
|
-
|
|
260
|
+
}
|
|
261
|
+
/** ICRC ledger transfer payload passed to wallet adapters. */
|
|
262
|
+
interface IcrcTransferDetails {
|
|
263
|
+
/** Ledger canister principal that should receive the transfer call. */
|
|
264
|
+
ledgerCanisterId: string;
|
|
265
|
+
/** Recipient ICRC account. */
|
|
266
|
+
to: IcrcAccount;
|
|
267
|
+
/** Transfer amount in ledger base units. */
|
|
268
|
+
amount: bigint;
|
|
269
|
+
/** Optional ledger fee in base units. */
|
|
270
|
+
fee?: bigint;
|
|
271
|
+
/** Optional ledger memo bytes. */
|
|
272
|
+
memo?: Uint8Array;
|
|
273
|
+
}
|
|
274
|
+
/** ICRC transaction-sending request passed to wallet adapters. */
|
|
275
|
+
interface SendIcrcTransferRequest {
|
|
276
|
+
/** ICRC transfers are submitted on the Internet Computer. */
|
|
277
|
+
chain: "ICP";
|
|
278
|
+
/** Asset represented by the target ledger transfer. */
|
|
279
|
+
asset: Asset;
|
|
280
|
+
/** Transfer details for the ledger call. */
|
|
281
|
+
transfer: IcrcTransferDetails;
|
|
282
|
+
/** Optional account override for the sending wallet. */
|
|
283
|
+
account?: string;
|
|
284
|
+
/** SDK action type that produced this request. */
|
|
285
|
+
actionType: string;
|
|
178
286
|
}
|
|
179
287
|
/**
|
|
180
288
|
* Optional wallet capabilities. Implement only what your flow uses:
|
|
181
289
|
*
|
|
182
290
|
* - `signMessage` - account creation, borrow, withdraw
|
|
183
|
-
* - `sendBtcTransaction` / `sendEthTransaction` - automated
|
|
184
|
-
* - `
|
|
291
|
+
* - `sendBtcTransaction` / `sendEthTransaction` - automated native-asset transfer supply
|
|
292
|
+
* - `sendIcrcTransfer` - automated ck-ledger and ICP ledger transfer supply
|
|
293
|
+
* - `sendEthTransaction` - contract-interaction supply and ETH native-asset sends
|
|
185
294
|
*/
|
|
186
295
|
interface WalletAdapter {
|
|
187
296
|
/** Signs an SDK plaintext message and returns the wallet signature. BTC adapters may return base64 BIP-322 or hex-encoded signature bytes. */
|
|
@@ -190,13 +299,15 @@ interface WalletAdapter {
|
|
|
190
299
|
sendEthTransaction?: (request: SendEthTransactionRequest) => Promise<string>;
|
|
191
300
|
/** Sends a BTC transaction and returns its transaction id. */
|
|
192
301
|
sendBtcTransaction?: (request: SendBtcTransactionRequest) => Promise<string>;
|
|
302
|
+
/** Sends an ICRC ledger transfer and returns the ledger transaction reference. */
|
|
303
|
+
sendIcrcTransfer?: (request: SendIcrcTransferRequest) => Promise<string>;
|
|
193
304
|
}
|
|
194
305
|
/** Signature payload submitted to a sign-message action. */
|
|
195
306
|
interface SignatureInfo {
|
|
196
307
|
/** Wallet signature over the action message. BTC signatures may be base64 BIP-322 or hex-encoded bytes. */
|
|
197
308
|
signature: string;
|
|
198
309
|
/** Chain used to produce the signature. */
|
|
199
|
-
chain:
|
|
310
|
+
chain: SigningChain;
|
|
200
311
|
/** Account that produced the signature, when different from the action default. */
|
|
201
312
|
account?: string;
|
|
202
313
|
}
|
|
@@ -208,8 +319,6 @@ interface SignMessageWalletAction<TData, TResult> {
|
|
|
208
319
|
executionKind: typeof WalletExecutionKind.signMessage;
|
|
209
320
|
/** Adapter-facing action type. */
|
|
210
321
|
actionType: string;
|
|
211
|
-
/** Transfer path associated with the action. */
|
|
212
|
-
transferMode: TransferMode;
|
|
213
322
|
/** Default account to pass to the wallet adapter. */
|
|
214
323
|
account: string;
|
|
215
324
|
/** Plaintext message that must be signed. */
|
|
@@ -232,7 +341,7 @@ interface CreateProfileParams {
|
|
|
232
341
|
/** Wallet address that will own the new profile. */
|
|
233
342
|
account: string;
|
|
234
343
|
/** Chain used to sign the profile-creation message. */
|
|
235
|
-
chain:
|
|
344
|
+
chain: SigningChain;
|
|
236
345
|
/** Wallet adapter used to sign the profile-creation message. */
|
|
237
346
|
walletAdapter: WalletAdapter;
|
|
238
347
|
}
|
|
@@ -241,11 +350,8 @@ interface CreateAccountData {
|
|
|
241
350
|
/** Unix expiry timestamp in seconds, included in the signed message. */
|
|
242
351
|
expiryTimestamp: bigint;
|
|
243
352
|
}
|
|
244
|
-
/** Sign-message action that can be submitted after wallet signing. */
|
|
245
|
-
interface SignableAction<TData, TResult> extends SignMessageWalletAction<TData, TResult> {
|
|
246
|
-
}
|
|
247
353
|
/** Prepared action for creating a Liquidium profile. */
|
|
248
|
-
interface CreateAccountAction extends
|
|
354
|
+
interface CreateAccountAction extends SignMessageWalletAction<CreateAccountData, string> {
|
|
249
355
|
/** Protocol action kind. */
|
|
250
356
|
kind: typeof WalletActionKind.createAccount;
|
|
251
357
|
/** Required wallet capability. */
|
|
@@ -571,7 +677,7 @@ declare class HistoryModule {
|
|
|
571
677
|
/** Wallet execution dependencies for borrow and withdraw convenience methods. */
|
|
572
678
|
interface WalletExecutionParams {
|
|
573
679
|
/** Chain used by the signing wallet. */
|
|
574
|
-
signerChain:
|
|
680
|
+
signerChain: SigningChain;
|
|
575
681
|
/** Wallet adapter used to execute the prepared action. */
|
|
576
682
|
signerWalletAdapter: WalletAdapter;
|
|
577
683
|
}
|
|
@@ -591,40 +697,6 @@ interface CreateTransferErc20TransactionParams {
|
|
|
591
697
|
/** Transfer amount in token base units. */
|
|
592
698
|
amount: bigint;
|
|
593
699
|
}
|
|
594
|
-
/** Destination account for a completed outflow. */
|
|
595
|
-
type OutflowReceiver = NativeOutflowReceiver | ExternalOutflowReceiver | AccountIdentifierOutflowReceiver | IcrcOutflowReceiver;
|
|
596
|
-
/** IC principal destination for a completed outflow. */
|
|
597
|
-
interface NativeOutflowReceiver {
|
|
598
|
-
/** Destination account type reported by the protocol. */
|
|
599
|
-
type: "Native";
|
|
600
|
-
/** Destination principal. */
|
|
601
|
-
account: string;
|
|
602
|
-
}
|
|
603
|
-
/** External-chain destination for a completed outflow. */
|
|
604
|
-
interface ExternalOutflowReceiver {
|
|
605
|
-
/** Destination account type reported by the protocol. */
|
|
606
|
-
type: "External";
|
|
607
|
-
/** External-chain destination address. */
|
|
608
|
-
account: string;
|
|
609
|
-
}
|
|
610
|
-
/** Legacy ICP ledger account identifier destination for a completed outflow. */
|
|
611
|
-
interface AccountIdentifierOutflowReceiver {
|
|
612
|
-
/** Destination account type reported by the protocol. */
|
|
613
|
-
type: "AccountIdentifier";
|
|
614
|
-
/** ICP ledger account identifier text, displayed as the destination address. */
|
|
615
|
-
account: string;
|
|
616
|
-
}
|
|
617
|
-
/** ICRC account destination for a completed outflow. */
|
|
618
|
-
interface IcrcOutflowReceiver {
|
|
619
|
-
/** Destination account type reported by the protocol. */
|
|
620
|
-
type: "Icrc";
|
|
621
|
-
/** ICRC account owner principal text. */
|
|
622
|
-
owner: string;
|
|
623
|
-
/** Optional ICRC subaccount bytes. */
|
|
624
|
-
subaccount?: Uint8Array;
|
|
625
|
-
/** Text-encoded ICRC account for display. */
|
|
626
|
-
account: string;
|
|
627
|
-
}
|
|
628
700
|
/**
|
|
629
701
|
* Receipt for a borrow or withdrawal outflow submitted to the lending canister.
|
|
630
702
|
*
|
|
@@ -643,7 +715,7 @@ interface OutflowDetails {
|
|
|
643
715
|
/** Outflow amount in the pool asset's base units. */
|
|
644
716
|
amount: bigint;
|
|
645
717
|
/** Outflow destination account. */
|
|
646
|
-
receiver:
|
|
718
|
+
receiver: LiquidiumAccount;
|
|
647
719
|
}
|
|
648
720
|
/** Borrow receipt. */
|
|
649
721
|
type BorrowOutflowDetails = OutflowDetails & {
|
|
@@ -657,12 +729,6 @@ type WithdrawOutflowDetails = OutflowDetails & {
|
|
|
657
729
|
/** Shared lifecycle status for the withdraw outflow receipt. */
|
|
658
730
|
status: LiquidiumStatus;
|
|
659
731
|
};
|
|
660
|
-
/** Signature payload for submitting a prepared borrow action. */
|
|
661
|
-
interface BorrowSubmitSignatureInfo extends SignatureInfo {
|
|
662
|
-
}
|
|
663
|
-
/** Signature payload for submitting a prepared withdraw action. */
|
|
664
|
-
interface WithdrawSubmitSignatureInfo extends SignatureInfo {
|
|
665
|
-
}
|
|
666
732
|
/**
|
|
667
733
|
* Fields to build a borrow request. `amount` is in the borrow pool asset's base units
|
|
668
734
|
* (e.g. satoshis, token smallest units).
|
|
@@ -674,8 +740,10 @@ interface CreateBorrowRequest {
|
|
|
674
740
|
poolId: string;
|
|
675
741
|
/** Amount to borrow in the borrow asset's base units. */
|
|
676
742
|
amount: bigint;
|
|
677
|
-
/**
|
|
678
|
-
|
|
743
|
+
/** Chain where borrowed funds should arrive. */
|
|
744
|
+
chain: Chain;
|
|
745
|
+
/** Destination that receives the borrowed asset. */
|
|
746
|
+
receiver: LiquidiumAccountInput;
|
|
679
747
|
/** Wallet address that signs the borrow authorization. */
|
|
680
748
|
signerWalletAddress: string;
|
|
681
749
|
}
|
|
@@ -704,8 +772,10 @@ interface CreateWithdrawRequest {
|
|
|
704
772
|
* at least 5,000 sats. USDC and USDT withdrawals require at least 1 token.
|
|
705
773
|
*/
|
|
706
774
|
amount: bigint;
|
|
707
|
-
/**
|
|
708
|
-
|
|
775
|
+
/** Chain where withdrawn funds should arrive. */
|
|
776
|
+
chain: Chain;
|
|
777
|
+
/** Destination that receives the withdrawn asset. */
|
|
778
|
+
receiver: LiquidiumAccountInput;
|
|
709
779
|
/** Wallet address that signs the withdraw authorization. */
|
|
710
780
|
signerWalletAddress: string;
|
|
711
781
|
}
|
|
@@ -730,64 +800,41 @@ declare const SupplyPlanType: {
|
|
|
730
800
|
};
|
|
731
801
|
/** Supply execution plan selected by the SDK. */
|
|
732
802
|
type SupplyPlanType = (typeof SupplyPlanType)[keyof typeof SupplyPlanType];
|
|
733
|
-
/**
|
|
734
|
-
|
|
735
|
-
/** Target discriminator. */
|
|
736
|
-
type: "nativeAddress";
|
|
803
|
+
/** Supply destination returned by `lending.supply(...)`. */
|
|
804
|
+
type SupplyTarget = AssetIdentifier & {
|
|
737
805
|
/** Pool principal text receiving the inflow. */
|
|
738
806
|
poolId: string;
|
|
739
|
-
/** Asset expected by the target. */
|
|
740
|
-
asset: MarketAsset;
|
|
741
|
-
/** Chain where the target address is valid. */
|
|
742
|
-
chain: MarketChain;
|
|
743
807
|
/** Deposit or repayment action for the inflow. */
|
|
744
808
|
action: SupplyAction;
|
|
745
|
-
/**
|
|
809
|
+
/** Address to use for this chain and asset pair. */
|
|
746
810
|
address: string;
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
/** Target discriminator. */
|
|
751
|
-
type: "icrcAccount";
|
|
752
|
-
/** Pool principal text receiving the inflow. */
|
|
753
|
-
poolId: string;
|
|
754
|
-
/** Asset expected by the target. */
|
|
755
|
-
asset: MarketAsset;
|
|
756
|
-
/** Chain associated with the inflow. */
|
|
757
|
-
chain: MarketChain;
|
|
758
|
-
/** Deposit or repayment action for the inflow. */
|
|
759
|
-
action: SupplyAction;
|
|
760
|
-
/** ICRC account owner principal text. */
|
|
761
|
-
owner: string;
|
|
762
|
-
/** ICRC subaccount bytes. */
|
|
763
|
-
subaccount: Uint8Array;
|
|
764
|
-
/** Text-encoded ICRC account. */
|
|
765
|
-
account: string;
|
|
766
|
-
}
|
|
767
|
-
/** Supply destination returned by `lending.supply(...)`. */
|
|
768
|
-
type SupplyTarget = NativeAddressSupplyTarget | IcrcAccountSupplyTarget;
|
|
811
|
+
/** Legacy account identifier for ICP ledger transfers. */
|
|
812
|
+
icpAccountIdentifier?: string;
|
|
813
|
+
};
|
|
769
814
|
interface BaseSupplyFlowRequest {
|
|
770
815
|
profileId: string;
|
|
771
816
|
poolId: string;
|
|
772
817
|
action: SupplyAction;
|
|
818
|
+
/** Transfer chain to use. Pass ICP for ck-ledger transfers. */
|
|
819
|
+
chain: Chain;
|
|
773
820
|
}
|
|
774
821
|
/** Manual transfer-based `lending.supply` request. */
|
|
775
822
|
interface ManualTransferSupplyFlowRequest extends BaseSupplyFlowRequest {
|
|
776
|
-
/**
|
|
777
|
-
mechanism?:
|
|
778
|
-
/**
|
|
823
|
+
/** Transfer supply uses the default mechanism and does not accept this field. */
|
|
824
|
+
mechanism?: never;
|
|
825
|
+
/** Manual supply does not broadcast through a wallet adapter. */
|
|
779
826
|
walletAdapter?: never;
|
|
780
|
-
/**
|
|
827
|
+
/** Manual supply does not accept a sender account. */
|
|
781
828
|
account?: never;
|
|
782
|
-
/**
|
|
829
|
+
/** Manual supply does not accept an execution amount. */
|
|
783
830
|
amount?: never;
|
|
784
831
|
}
|
|
785
832
|
/** Wallet-executed transfer-based `lending.supply` request. */
|
|
786
833
|
interface WalletTransferSupplyFlowRequest extends BaseSupplyFlowRequest {
|
|
787
|
-
/**
|
|
788
|
-
mechanism?:
|
|
834
|
+
/** Transfer supply uses the default mechanism and does not accept this field. */
|
|
835
|
+
mechanism?: never;
|
|
789
836
|
/** Wallet adapter used to broadcast the transfer. */
|
|
790
|
-
walletAdapter: Pick<WalletAdapter, "sendBtcTransaction" | "sendEthTransaction">;
|
|
837
|
+
walletAdapter: Pick<WalletAdapter, "sendBtcTransaction" | "sendEthTransaction" | "sendIcrcTransfer">;
|
|
791
838
|
/** Sender wallet account. */
|
|
792
839
|
account: string;
|
|
793
840
|
/** Transfer amount in the target asset's base units. */
|
|
@@ -799,6 +846,8 @@ type TransferSupplyFlowRequest = ManualTransferSupplyFlowRequest | WalletTransfe
|
|
|
799
846
|
interface ContractInteractionSupplyFlowRequest extends BaseSupplyFlowRequest {
|
|
800
847
|
/** Contract-interaction mechanism discriminator. */
|
|
801
848
|
mechanism: typeof SupplyPlanType.contractInteraction;
|
|
849
|
+
/** Contract interaction is only supported for ETH stablecoin pools. */
|
|
850
|
+
chain: typeof Chain.ETH;
|
|
802
851
|
/** ETH wallet adapter used to approve and deposit ERC-20 assets. */
|
|
803
852
|
walletAdapter: Pick<WalletAdapter, "sendEthTransaction">;
|
|
804
853
|
/** Sender EVM wallet address. */
|
|
@@ -843,7 +892,7 @@ interface SubmitSupplyFlowInflowRequest {
|
|
|
843
892
|
/** Broadcast transaction id or hash. */
|
|
844
893
|
txid: string;
|
|
845
894
|
/** Chain where the transaction was broadcast, when not implied by the flow. */
|
|
846
|
-
chain?: Chain
|
|
895
|
+
chain?: Extract<Chain, "BTC" | "ETH">;
|
|
847
896
|
}
|
|
848
897
|
/** Body for direct `lending.submitInflow`. */
|
|
849
898
|
interface SubmitInflowRequest extends SubmitSupplyFlowInflowRequest {
|
|
@@ -855,13 +904,8 @@ interface SubmitInflowResponse {
|
|
|
855
904
|
/** Transaction id accepted by the SDK API. */
|
|
856
905
|
txid: string;
|
|
857
906
|
}
|
|
858
|
-
/**
|
|
859
|
-
|
|
860
|
-
/** Asset to estimate for. */
|
|
861
|
-
asset: Asset;
|
|
862
|
-
/** Chain to estimate for. */
|
|
863
|
-
chain: Chain;
|
|
864
|
-
}
|
|
907
|
+
/** Chain and asset pair for estimating an inflow target fee. */
|
|
908
|
+
type EstimateInflowFeeRequest = AssetIdentifier;
|
|
865
909
|
/** Request for an ETH stablecoin deposit address. */
|
|
866
910
|
interface GetDepositAddressRequest {
|
|
867
911
|
/** Liquidium profile principal text. */
|
|
@@ -869,7 +913,7 @@ interface GetDepositAddressRequest {
|
|
|
869
913
|
/** Pool principal text receiving the inflow. */
|
|
870
914
|
poolId: string;
|
|
871
915
|
/** ETH stablecoin asset. */
|
|
872
|
-
asset:
|
|
916
|
+
asset: typeof Asset.USDC | typeof Asset.USDT;
|
|
873
917
|
/** Deposit or repayment action for the inflow. */
|
|
874
918
|
action: SupplyAction;
|
|
875
919
|
}
|
|
@@ -1018,12 +1062,14 @@ declare class LendingModule {
|
|
|
1018
1062
|
*
|
|
1019
1063
|
* ETH stablecoin deposit-address estimates are served by the deposit-address
|
|
1020
1064
|
* canister. BTC estimates include the ckBTC minter deposit fee and ledger fee.
|
|
1065
|
+
* ICP-chain estimates return the corresponding ICRC ledger fee.
|
|
1021
1066
|
*
|
|
1022
1067
|
* @param request - Asset and chain pair to estimate for.
|
|
1023
1068
|
* @returns Total fee estimate rounded up in the asset's base units.
|
|
1024
1069
|
*/
|
|
1025
1070
|
estimateInflowFee(request: EstimateInflowFeeRequest): Promise<InflowFeeEstimate>;
|
|
1026
1071
|
private estimateBtcInflowFee;
|
|
1072
|
+
private estimateIcrcLedgerFee;
|
|
1027
1073
|
/**
|
|
1028
1074
|
* Submits an inflow transaction id for faster indexing.
|
|
1029
1075
|
*
|
|
@@ -1041,7 +1087,6 @@ declare class LendingModule {
|
|
|
1041
1087
|
isBorrowingDisabled(): Promise<boolean>;
|
|
1042
1088
|
private requireApi;
|
|
1043
1089
|
private createSupplyFlowExecutor;
|
|
1044
|
-
private getPoolById;
|
|
1045
1090
|
}
|
|
1046
1091
|
|
|
1047
1092
|
/** Current protocol metadata and rate state for a lending pool. */
|
|
@@ -1049,9 +1094,9 @@ interface Pool {
|
|
|
1049
1094
|
/** Pool canister principal text. */
|
|
1050
1095
|
id: string;
|
|
1051
1096
|
/** Asset supplied to and borrowed from the pool. */
|
|
1052
|
-
asset:
|
|
1097
|
+
asset: Asset;
|
|
1053
1098
|
/** Chain associated with the pool asset. */
|
|
1054
|
-
chain:
|
|
1099
|
+
chain: Chain;
|
|
1055
1100
|
/** Number of base-unit decimals for pool amounts. */
|
|
1056
1101
|
decimals: bigint;
|
|
1057
1102
|
/** Whether new pool activity is currently frozen. */
|
|
@@ -1103,13 +1148,8 @@ interface Pool {
|
|
|
1103
1148
|
}
|
|
1104
1149
|
/** USD price map keyed by market asset symbol. */
|
|
1105
1150
|
type AssetPrices = Record<string, number>;
|
|
1106
|
-
/**
|
|
1107
|
-
|
|
1108
|
-
/** Asset symbol to match. */
|
|
1109
|
-
asset: MarketAsset;
|
|
1110
|
-
/** Chain name to match. */
|
|
1111
|
-
chain: MarketChain;
|
|
1112
|
-
}
|
|
1151
|
+
/** Supported Chain + Asset identifier used to find its backing lending pool. */
|
|
1152
|
+
type FindPoolQuery = AssetIdentifier;
|
|
1113
1153
|
/** Current borrow, lend, and utilization rates for a pool. */
|
|
1114
1154
|
interface PoolRate {
|
|
1115
1155
|
/** Decimal scale used by rate fields. */
|
|
@@ -1141,7 +1181,10 @@ declare class MarketModule {
|
|
|
1141
1181
|
*/
|
|
1142
1182
|
getAssetPrices(): Promise<AssetPrices>;
|
|
1143
1183
|
/**
|
|
1144
|
-
* Resolves a single pool for the given
|
|
1184
|
+
* Resolves a single backing pool for the given Chain + Asset identifier.
|
|
1185
|
+
*
|
|
1186
|
+
* Native and chain-key identifiers share a pool. For example, both
|
|
1187
|
+
* `ETH/USDT` and `ICP/USDT` resolve to the USDT lending pool.
|
|
1145
1188
|
*
|
|
1146
1189
|
* @param query - The market asset and chain pair to match.
|
|
1147
1190
|
* @returns The single pool that matches the requested asset and chain.
|
|
@@ -1171,7 +1214,7 @@ interface Position {
|
|
|
1171
1214
|
/** Pool principal text. */
|
|
1172
1215
|
poolId: string;
|
|
1173
1216
|
/** Pool asset symbol. */
|
|
1174
|
-
asset:
|
|
1217
|
+
asset: Asset;
|
|
1175
1218
|
/** Current supplied amount in base units. */
|
|
1176
1219
|
deposited: bigint;
|
|
1177
1220
|
/** Decimal scale for supplied amounts. */
|
|
@@ -1353,115 +1396,127 @@ declare class PositionsModule {
|
|
|
1353
1396
|
declare function createTransferErc20Transaction(params: CreateTransferErc20TransactionParams): EvmContractTransaction;
|
|
1354
1397
|
|
|
1355
1398
|
/** Asset symbols supported by the instant-loans canister. */
|
|
1356
|
-
type InstantLoanAsset = "
|
|
1357
|
-
/**
|
|
1358
|
-
interface
|
|
1399
|
+
type InstantLoanAsset = AssetIdentifier["asset"];
|
|
1400
|
+
/** Collateral leg used when creating an instant loan. */
|
|
1401
|
+
interface CreateInstantLoanCollateral {
|
|
1359
1402
|
/**
|
|
1360
|
-
*
|
|
1403
|
+
* Principal text of the pool that receives the user's collateral deposit.
|
|
1361
1404
|
*
|
|
1362
|
-
*
|
|
1363
|
-
*
|
|
1405
|
+
* This should be the `id` of the collateral `Pool` selected from
|
|
1406
|
+
* `client.market.listPools()`. The pool asset must match `asset`.
|
|
1364
1407
|
*/
|
|
1365
|
-
|
|
1408
|
+
poolId: string;
|
|
1366
1409
|
/**
|
|
1367
|
-
*
|
|
1410
|
+
* Asset the user will deposit as collateral.
|
|
1368
1411
|
*
|
|
1369
|
-
*
|
|
1370
|
-
*
|
|
1412
|
+
* Must match the asset for `poolId`; for example, use `"BTC"` with a BTC
|
|
1413
|
+
* collateral pool.
|
|
1371
1414
|
*/
|
|
1372
|
-
|
|
1415
|
+
asset: InstantLoanAsset;
|
|
1373
1416
|
/**
|
|
1374
|
-
*
|
|
1417
|
+
* Intended credited collateral amount, in base units.
|
|
1375
1418
|
*
|
|
1376
|
-
*
|
|
1377
|
-
*
|
|
1419
|
+
* This is used to validate LTV and initialize the loan record before
|
|
1420
|
+
* deposit/inflow fees are deducted. For BTC, pass satoshis. For token assets,
|
|
1421
|
+
* convert the UI amount using the selected pool's `decimals` value. After
|
|
1422
|
+
* creation, use one of `loan.initialDeposit.targets` as the fee-inclusive
|
|
1423
|
+
* transfer quote and destination.
|
|
1378
1424
|
*/
|
|
1379
|
-
|
|
1380
|
-
}
|
|
1381
|
-
/** IC principal account returned when a canister-native destination is used. */
|
|
1382
|
-
interface NativeAccount {
|
|
1383
|
-
/** Account kind discriminator. */
|
|
1384
|
-
type: "Native";
|
|
1385
|
-
/** Principal text for the canister-native account. */
|
|
1386
|
-
principal: string;
|
|
1387
|
-
}
|
|
1388
|
-
/** Legacy ICP ledger account identifier returned by existing canister state. */
|
|
1389
|
-
interface AccountIdentifierAccount {
|
|
1390
|
-
/** Account kind discriminator. */
|
|
1391
|
-
type: "AccountIdentifier";
|
|
1392
|
-
/** ICP ledger account identifier text, displayed as the destination address. */
|
|
1393
|
-
address: string;
|
|
1394
|
-
}
|
|
1395
|
-
/** ICRC account returned by existing or future canister state. */
|
|
1396
|
-
interface IcrcAccount {
|
|
1397
|
-
/** Account kind discriminator. */
|
|
1398
|
-
type: "Icrc";
|
|
1399
|
-
/** ICRC account owner principal text. */
|
|
1400
|
-
owner: string;
|
|
1401
|
-
/** Optional ICRC subaccount bytes. */
|
|
1402
|
-
subaccount?: Uint8Array;
|
|
1403
|
-
/** Text-encoded ICRC account for display. */
|
|
1404
|
-
address: string;
|
|
1425
|
+
amount: bigint;
|
|
1405
1426
|
}
|
|
1406
|
-
/** Borrow destination or refund account associated with an instant loan. */
|
|
1407
|
-
type InstantLoanAccount = ExternalAccount | NativeAccount | AccountIdentifierAccount | IcrcAccount;
|
|
1408
1427
|
/**
|
|
1409
|
-
*
|
|
1428
|
+
* Borrow leg used when creating an instant loan.
|
|
1410
1429
|
*
|
|
1411
|
-
*
|
|
1412
|
-
*
|
|
1413
|
-
* amount pair and choose `ltvMaxBps`.
|
|
1414
|
-
*
|
|
1415
|
-
* Amount fields are in each asset's smallest/base units. For example, BTC uses
|
|
1416
|
-
* satoshis and ERC-20 assets use token base units according to the selected
|
|
1417
|
-
* pool decimals.
|
|
1430
|
+
* `chain` and `asset` form the canonical asset identifier. For example,
|
|
1431
|
+
* `{ chain: "ICP", asset: "USDT" }` means ckUSDT.
|
|
1418
1432
|
*/
|
|
1419
|
-
|
|
1420
|
-
/**
|
|
1421
|
-
* Principal text of the pool that receives the user's collateral deposit.
|
|
1422
|
-
*
|
|
1423
|
-
* This should be the `id` of the collateral `Pool` selected from
|
|
1424
|
-
* `client.market.listPools()`. The pool asset must match `collateralAsset`.
|
|
1425
|
-
*/
|
|
1426
|
-
collateralPoolId: string;
|
|
1433
|
+
type CreateInstantLoanBorrow = AssetIdentifier & {
|
|
1427
1434
|
/**
|
|
1428
1435
|
* Principal text of the pool that funds the borrow.
|
|
1429
1436
|
*
|
|
1430
1437
|
* This should be the `id` of the borrow `Pool` selected from
|
|
1431
|
-
* `client.market.listPools()`. The pool asset must match `
|
|
1432
|
-
*/
|
|
1433
|
-
borrowPoolId: string;
|
|
1434
|
-
/**
|
|
1435
|
-
* Asset the user will deposit as collateral.
|
|
1436
|
-
*
|
|
1437
|
-
* Must match the asset for `collateralPoolId`; for example, use `"BTC"` with
|
|
1438
|
-
* a BTC collateral pool.
|
|
1438
|
+
* `client.market.listPools()`. The pool asset must match `asset`.
|
|
1439
1439
|
*/
|
|
1440
|
-
|
|
1440
|
+
poolId: string;
|
|
1441
1441
|
/**
|
|
1442
|
-
*
|
|
1442
|
+
* Amount to borrow, in the borrow asset's base units.
|
|
1443
1443
|
*
|
|
1444
|
-
*
|
|
1445
|
-
*
|
|
1444
|
+
* For USDC/USDT, convert the UI amount using the selected borrow pool's
|
|
1445
|
+
* `decimals` value before passing it here.
|
|
1446
1446
|
*/
|
|
1447
|
-
|
|
1447
|
+
amount: bigint;
|
|
1448
1448
|
/**
|
|
1449
|
-
*
|
|
1449
|
+
* Destination that receives the borrowed asset after the loan starts.
|
|
1450
1450
|
*
|
|
1451
|
-
*
|
|
1452
|
-
*
|
|
1453
|
-
*
|
|
1454
|
-
*
|
|
1455
|
-
* amount to send to `loan.initialDeposit.target`.
|
|
1451
|
+
* Pass either a string shorthand or a typed destination. For BTC/ETH chain
|
|
1452
|
+
* outflows this is usually the user's chain address. Chain-key assets on ICP
|
|
1453
|
+
* require an `IcPrincipal`; native ICP also accepts `IcpAccountIdentifier`
|
|
1454
|
+
* and `IcrcAccount` destinations.
|
|
1456
1455
|
*/
|
|
1457
|
-
|
|
1456
|
+
destination: InstantLoanDestination;
|
|
1457
|
+
};
|
|
1458
|
+
/** Refund leg used when creating an instant loan. */
|
|
1459
|
+
interface CreateInstantLoanRefund {
|
|
1460
|
+
/** Delivery chain used for collateral refunds and withdrawals. Use ICP for ck-ledger delivery. */
|
|
1461
|
+
chain: Chain;
|
|
1458
1462
|
/**
|
|
1459
|
-
*
|
|
1463
|
+
* Destination that receives collateral refunds or withdrawals.
|
|
1460
1464
|
*
|
|
1461
|
-
*
|
|
1462
|
-
*
|
|
1465
|
+
* Pass either a string shorthand or a typed destination. For BTC/ETH chain
|
|
1466
|
+
* outflows this is usually the user's chain address. Chain-key assets on ICP
|
|
1467
|
+
* require an `IcPrincipal`; native ICP also accepts `IcpAccountIdentifier`
|
|
1468
|
+
* and `IcrcAccount` destinations.
|
|
1463
1469
|
*/
|
|
1464
|
-
|
|
1470
|
+
destination: InstantLoanDestination;
|
|
1471
|
+
}
|
|
1472
|
+
/**
|
|
1473
|
+
* Borrow destination or refund account associated with an instant loan.
|
|
1474
|
+
*
|
|
1475
|
+
* @example
|
|
1476
|
+
* ```ts
|
|
1477
|
+
* const icPrincipalAccount: InstantLoanAccount = {
|
|
1478
|
+
* type: "IcPrincipal",
|
|
1479
|
+
* address: "aaaaa-aa",
|
|
1480
|
+
* };
|
|
1481
|
+
*
|
|
1482
|
+
* const chainAddressAccount: InstantLoanAccount = {
|
|
1483
|
+
* type: "ChainAddress",
|
|
1484
|
+
* address: "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
|
|
1485
|
+
* };
|
|
1486
|
+
*
|
|
1487
|
+
* const accountIdentifierAccount: InstantLoanAccount = {
|
|
1488
|
+
* type: "IcpAccountIdentifier",
|
|
1489
|
+
* address: "e2134f3f176b1429df3f92807b8f0f26a520debc313b2d6ad86a4a2e7f3d8f8d",
|
|
1490
|
+
* };
|
|
1491
|
+
*
|
|
1492
|
+
* const icrcAccount: InstantLoanAccount = {
|
|
1493
|
+
* type: "IcrcAccount",
|
|
1494
|
+
* owner: "aaaaa-aa",
|
|
1495
|
+
* address: "aaaaa-aa",
|
|
1496
|
+
* };
|
|
1497
|
+
* ```
|
|
1498
|
+
*/
|
|
1499
|
+
type InstantLoanAccount = LiquidiumAccount;
|
|
1500
|
+
/** Destination accepted when creating an instant loan. */
|
|
1501
|
+
type InstantLoanDestination = LiquidiumAccountInput;
|
|
1502
|
+
/**
|
|
1503
|
+
* Parameters for creating an accountless instant loan.
|
|
1504
|
+
*
|
|
1505
|
+
* Use market data from `client.market.listPools()` to choose the two pool ids,
|
|
1506
|
+
* and use `client.quote.calculateLtv(...)` before creation to validate the
|
|
1507
|
+
* amount pair and choose `ltvMaxBps`.
|
|
1508
|
+
*
|
|
1509
|
+
* Amount fields are in each asset's smallest/base units. For example, BTC uses
|
|
1510
|
+
* satoshis and ERC-20 assets use token base units according to the selected
|
|
1511
|
+
* pool decimals.
|
|
1512
|
+
*/
|
|
1513
|
+
interface CreateInstantLoanRequest {
|
|
1514
|
+
/** Collateral leg: pool, asset, and amount the user deposits. */
|
|
1515
|
+
collateral: CreateInstantLoanCollateral;
|
|
1516
|
+
/** Borrow leg: pool, asset, amount, delivery chain, and destination. */
|
|
1517
|
+
borrow: CreateInstantLoanBorrow;
|
|
1518
|
+
/** Refund leg: chain and destination for returned collateral. */
|
|
1519
|
+
refund: CreateInstantLoanRefund;
|
|
1465
1520
|
/**
|
|
1466
1521
|
* Maximum allowed loan-to-value ratio in basis points.
|
|
1467
1522
|
*
|
|
@@ -1479,22 +1534,6 @@ interface CreateInstantLoanRequest {
|
|
|
1479
1534
|
* `ltv_timer_s`.
|
|
1480
1535
|
*/
|
|
1481
1536
|
depositWindowSeconds: bigint;
|
|
1482
|
-
/**
|
|
1483
|
-
* External destination that receives the borrowed asset after the loan starts.
|
|
1484
|
-
*
|
|
1485
|
-
* Pass either an address string or `{ type: "External", address }`. This is
|
|
1486
|
-
* usually the user's wallet address on the borrow asset's chain, such as an
|
|
1487
|
-
* EVM address for ETH USDC/USDT outflows.
|
|
1488
|
-
*/
|
|
1489
|
-
borrowDestination: string | ExternalAccount;
|
|
1490
|
-
/**
|
|
1491
|
-
* External destination that receives collateral refunds or withdrawals.
|
|
1492
|
-
*
|
|
1493
|
-
* Pass either an address string or `{ type: "External", address }`. This
|
|
1494
|
-
* should be an address on the collateral asset's chain, such as a BTC address
|
|
1495
|
-
* when `collateralAsset` is `"BTC"`.
|
|
1496
|
-
*/
|
|
1497
|
-
refundDestination: string | ExternalAccount;
|
|
1498
1537
|
}
|
|
1499
1538
|
/** Lookup request for loading an instant loan by numeric canister id. */
|
|
1500
1539
|
interface InstantLoanGetByIdRequest {
|
|
@@ -1643,10 +1682,28 @@ interface InstantLoanDepositTimerStartedEventType {
|
|
|
1643
1682
|
}
|
|
1644
1683
|
/** Direct canister event payload returned by instant-loans event queries. */
|
|
1645
1684
|
type InstantLoanEventType = InstantLoanCreatedEventType | InstantLoanFullLendWithdrawalRequestedEventType | InstantLoanBorrowRequestedEventType | InstantLoanDepositTimerExceededEventType | InstantLoanStuckFundsWithdrawalRequestedEventType | InstantLoanProfileWarmedEventType | InstantLoanRepayCompleteEventType | InstantLoanDepositTimerStartedEventType;
|
|
1646
|
-
/**
|
|
1647
|
-
interface
|
|
1685
|
+
/** Fee-inclusive collateral deposit quote for one transfer target. */
|
|
1686
|
+
interface InstantLoanInitialDepositTargetQuote {
|
|
1687
|
+
/** Full amount to send to the collateral deposit target, including fee. */
|
|
1688
|
+
amount: bigint;
|
|
1689
|
+
/** Inflow fee amount in base units added to the transfer amount. */
|
|
1690
|
+
inflowFeeAmount: bigint;
|
|
1691
|
+
/** Address or ICRC account where the collateral should be sent. */
|
|
1692
|
+
target: SupplyTarget;
|
|
1693
|
+
}
|
|
1694
|
+
/** Fee-inclusive repayment quote for one transfer target. */
|
|
1695
|
+
interface InstantLoanRepaymentTargetQuote {
|
|
1648
1696
|
/** Full amount to send to the repayment target, including fee and interest buffer. */
|
|
1649
1697
|
amount: bigint;
|
|
1698
|
+
/** Inflow fee amount in base units added to the repayment transfer. Falls back to the protocol minimum when live estimation is unavailable. */
|
|
1699
|
+
inflowFeeAmount: bigint;
|
|
1700
|
+
/** Whether `inflowFeeAmount` came from a live fee estimate. */
|
|
1701
|
+
inflowFeeEstimateAvailable: boolean;
|
|
1702
|
+
/** Address or ICRC account where the repayment should be sent. */
|
|
1703
|
+
target: SupplyTarget;
|
|
1704
|
+
}
|
|
1705
|
+
/** Current amount to send to a repayment target to close the debt. */
|
|
1706
|
+
interface InstantLoanRepayment {
|
|
1650
1707
|
/** Decimal scale for `amount`. */
|
|
1651
1708
|
decimals: bigint;
|
|
1652
1709
|
/** Current debt in base units, before fee and interest buffer. */
|
|
@@ -1655,33 +1712,21 @@ interface InstantLoanRepayment {
|
|
|
1655
1712
|
interestBufferAmount: bigint;
|
|
1656
1713
|
/** Seconds of interest accrual included in `interestBufferAmount`. */
|
|
1657
1714
|
interestBufferSeconds: bigint;
|
|
1658
|
-
/** Inflow fee amount in base units added to the repayment transfer. Falls back to the protocol minimum when live estimation is unavailable. */
|
|
1659
|
-
inflowFeeAmount: bigint;
|
|
1660
|
-
/** Whether `inflowFeeAmount` came from a live fee estimate. */
|
|
1661
|
-
inflowFeeEstimateAvailable: boolean;
|
|
1662
1715
|
/** Asset to repay. */
|
|
1663
|
-
asset:
|
|
1664
|
-
/**
|
|
1665
|
-
|
|
1666
|
-
/** Address or ICRC account where the repayment should be sent. */
|
|
1667
|
-
target: SupplyTarget;
|
|
1716
|
+
asset: InstantLoanAsset;
|
|
1717
|
+
/** Available repayment targets keyed by the actual transfer chain. */
|
|
1718
|
+
targets: Partial<Record<Chain, InstantLoanRepaymentTargetQuote>>;
|
|
1668
1719
|
}
|
|
1669
1720
|
/** Initial collateral deposit quote returned when an instant loan is created. */
|
|
1670
1721
|
interface InstantLoanInitialDeposit {
|
|
1671
|
-
/** Full amount to send to the deposit target, including the estimated inflow fee. */
|
|
1672
|
-
amount: bigint;
|
|
1673
1722
|
/** Decimal scale for `amount`, `collateralAmount`, and `inflowFeeAmount`. */
|
|
1674
1723
|
decimals: bigint;
|
|
1675
1724
|
/** Intended credited collateral amount in base units, before inflow fees. */
|
|
1676
1725
|
collateralAmount: bigint;
|
|
1677
|
-
/** Inflow fee amount in base units added to the transfer amount. */
|
|
1678
|
-
inflowFeeAmount: bigint;
|
|
1679
1726
|
/** Collateral asset to deposit. */
|
|
1680
|
-
asset:
|
|
1681
|
-
/**
|
|
1682
|
-
|
|
1683
|
-
/** Address or ICRC account where the collateral should be sent. */
|
|
1684
|
-
target: SupplyTarget;
|
|
1727
|
+
asset: InstantLoanAsset;
|
|
1728
|
+
/** Available collateral deposit targets keyed by the actual transfer chain. */
|
|
1729
|
+
targets: Partial<Record<Chain, InstantLoanInitialDepositTargetQuote>>;
|
|
1685
1730
|
/** Unix timestamp in seconds when the collateral deposit was detected, or null before detection. */
|
|
1686
1731
|
detectedTimestamp: bigint | null;
|
|
1687
1732
|
/** Unix timestamp in seconds when the collateral deposit window expires, or null before detection when unavailable. */
|
|
@@ -1715,30 +1760,24 @@ interface InstantLoanTerms {
|
|
|
1715
1760
|
interface InstantLoanCollateral {
|
|
1716
1761
|
/** Principal text of the collateral pool. */
|
|
1717
1762
|
poolId: string;
|
|
1718
|
-
/**
|
|
1719
|
-
asset:
|
|
1720
|
-
/** Chain used for collateral deposits. */
|
|
1721
|
-
chain: MarketChain;
|
|
1763
|
+
/** Asset deposited as collateral. Transfer rails are exposed by `initialDeposit.targets`. */
|
|
1764
|
+
asset: InstantLoanAsset;
|
|
1722
1765
|
/** Decimal scale for collateral amounts. */
|
|
1723
1766
|
decimals: bigint;
|
|
1724
1767
|
/** Intended credited collateral amount in base units, before inflow fees. */
|
|
1725
1768
|
amount: bigint;
|
|
1726
1769
|
}
|
|
1727
1770
|
/** Borrow leg selected for an instant loan. */
|
|
1728
|
-
|
|
1771
|
+
type InstantLoanBorrow = AssetIdentifier & {
|
|
1729
1772
|
/** Principal text of the borrow pool. */
|
|
1730
1773
|
poolId: string;
|
|
1731
|
-
/** Borrow asset symbol. */
|
|
1732
|
-
asset: MarketAsset;
|
|
1733
|
-
/** Chain used for repayment. */
|
|
1734
|
-
chain: MarketChain;
|
|
1735
1774
|
/** Decimal scale for borrow and debt amounts. */
|
|
1736
1775
|
decimals: bigint;
|
|
1737
1776
|
/** Requested borrow amount in base units. */
|
|
1738
1777
|
amount: bigint;
|
|
1739
1778
|
/** Destination that receives the borrowed asset. */
|
|
1740
1779
|
destination: InstantLoanAccount;
|
|
1741
|
-
}
|
|
1780
|
+
};
|
|
1742
1781
|
/** Hydrated instant-loan state plus generated quote targets. */
|
|
1743
1782
|
interface InstantLoan {
|
|
1744
1783
|
/** Canister-assigned loan id. */
|
|
@@ -1751,7 +1790,7 @@ interface InstantLoan {
|
|
|
1751
1790
|
profileId: string;
|
|
1752
1791
|
/** Immutable loan terms. */
|
|
1753
1792
|
terms: InstantLoanTerms;
|
|
1754
|
-
/** Collateral-side pool, asset,
|
|
1793
|
+
/** Collateral-side pool, asset, decimals, and requested credited amount. */
|
|
1755
1794
|
collateral: InstantLoanCollateral;
|
|
1756
1795
|
/** Borrow-side pool, asset, chain, decimals, requested amount, and destination. */
|
|
1757
1796
|
borrow: InstantLoanBorrow;
|
|
@@ -1765,6 +1804,17 @@ interface InstantLoan {
|
|
|
1765
1804
|
position: InstantLoanPositionSummary;
|
|
1766
1805
|
}
|
|
1767
1806
|
|
|
1807
|
+
/**
|
|
1808
|
+
* A loan was created remotely, but the SDK could not load its enriched state.
|
|
1809
|
+
* Retry with `instantLoans.get({ loanId })`; do not create the loan again.
|
|
1810
|
+
*/
|
|
1811
|
+
declare class InstantLoanCreatedError extends Error {
|
|
1812
|
+
readonly code: "INSTANT_LOAN_HYDRATION_FAILED";
|
|
1813
|
+
readonly loanId: bigint;
|
|
1814
|
+
readonly ref: string;
|
|
1815
|
+
readonly cause: unknown;
|
|
1816
|
+
constructor(loanId: bigint, cause: unknown);
|
|
1817
|
+
}
|
|
1768
1818
|
/** Accountless instant-loan creation, lookup, recovery, and canister query helpers. */
|
|
1769
1819
|
declare class InstantLoansModule {
|
|
1770
1820
|
private readonly canisterContext;
|
|
@@ -1782,12 +1832,12 @@ declare class InstantLoansModule {
|
|
|
1782
1832
|
* selected pool decimals, and call `client.quote.calculateLtv(...)` before
|
|
1783
1833
|
* creation to block invalid LTV input.
|
|
1784
1834
|
*
|
|
1785
|
-
* `
|
|
1786
|
-
* `
|
|
1835
|
+
* `borrow.destination` receives the borrowed asset after the loan starts.
|
|
1836
|
+
* `refund.destination` receives collateral refunds or withdrawals. Use
|
|
1787
1837
|
* `depositWindowSeconds` for the user-facing collateral deposit timeout; the
|
|
1788
1838
|
* SDK maps it to the canister's internal `ltv_timer_s` field.
|
|
1789
1839
|
*
|
|
1790
|
-
* @param request -
|
|
1840
|
+
* @param request - Collateral, borrow, refund, LTV limit, timeout, and inflow options.
|
|
1791
1841
|
* @returns Hydrated loan state plus generated initial-deposit and repayment quote targets.
|
|
1792
1842
|
*/
|
|
1793
1843
|
create(request: CreateInstantLoanRequest): Promise<InstantLoan>;
|
|
@@ -1855,6 +1905,8 @@ declare class InstantLoansModule {
|
|
|
1855
1905
|
private getCollateralAmountHint;
|
|
1856
1906
|
private hydrateLoan;
|
|
1857
1907
|
private createInitialDepositQuote;
|
|
1908
|
+
private resolveInstantLoanInflowTargets;
|
|
1909
|
+
private createRepaymentTargetQuotes;
|
|
1858
1910
|
private estimateRepaymentInflowFee;
|
|
1859
1911
|
private requireApi;
|
|
1860
1912
|
private validateInstantLoanLtvPolicy;
|
|
@@ -2164,7 +2216,7 @@ interface ExecuteWithOptions {
|
|
|
2164
2216
|
/** Must expose the methods required by the action's `executionKind`. */
|
|
2165
2217
|
walletAdapter: WalletAdapter;
|
|
2166
2218
|
/** Required for `sign-message` actions; forwarded to the adapter and submit payload. */
|
|
2167
|
-
chain?:
|
|
2219
|
+
chain?: SigningChain;
|
|
2168
2220
|
/** Optional signing/sending account override. */
|
|
2169
2221
|
account?: string;
|
|
2170
2222
|
}
|
|
@@ -2178,4 +2230,4 @@ interface ExecuteWithOptions {
|
|
|
2178
2230
|
*/
|
|
2179
2231
|
declare function executeWith(options: ExecuteWithOptions): <TResult>(action: WalletAction<TResult>) => Promise<TResult>;
|
|
2180
2232
|
|
|
2181
|
-
export {
|
|
2233
|
+
export { AccountsModule, ActivitiesModule, type Activity, ActivityFilter, type ActivityStatusFoundResponse, type ActivityStatusNotFoundResponse, type ActivityTopUp, Asset, type AssetIdentifier, type AssetPrices, type BaseGetActivityStatusRequest, type BaseListActivitiesRequest, type BorrowAction, type BorrowOutflowDetails, type BorrowingPower, CK_ETH_DEPOSIT_CONTRACT_ADDRESS, type CalculateLtvRequest, type CanisterIdOverrides, type CanisterIds, Chain, type ChainAddressAccount, type ContractInteractionSupplyFlowRequest, type CreateAccountAction, type CreateAccountData, type CreateAccountRequest, type CreateBorrowData, type CreateBorrowRequest, type CreateInstantLoanBorrow, type CreateInstantLoanCollateral, type CreateInstantLoanRefund, 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 FindPoolQuery, type FullWithdrawAmount, type GetActivityStatusByProfileRequest, type GetActivityStatusByShortRefRequest, type GetActivityStatusRequest, type GetActivityStatusResponse, type GetDepositAddressRequest, type GetEvmSupplyContextRequest, type HealthFactor, HistoryModule, type IcPrincipalAccount, type IcpAccountIdentifierAccount, type IcrcAccount, type IcrcTransferDetails, type InflowActivity, type InflowActivityOperation, type InflowActivityStatus, type InflowFeeEstimate, type InflowOperation, type InstantLoan, type InstantLoanAccount, type InstantLoanAsset, type InstantLoanAuthorization, type InstantLoanBorrow, type InstantLoanBorrowRequestedEventType, type InstantLoanCollateral, type InstantLoanConfig, InstantLoanCreatedError, type InstantLoanCreatedEventType, type InstantLoanDepositTimerExceededEventType, type InstantLoanDepositTimerStartedEventType, type InstantLoanDestination, type InstantLoanEvent, type InstantLoanEventType, type InstantLoanFindBorrow, type InstantLoanFindCollateral, type InstantLoanFindResult, type InstantLoanFullLendWithdrawalRequestedEventType, type InstantLoanGetByIdRequest, type InstantLoanGetByRefRequest, type InstantLoanGetRequest, type InstantLoanInitialDeposit, type InstantLoanInitialDepositTargetQuote, type InstantLoanLeg, type InstantLoanListEventsRequest, type InstantLoanPositionSummary, type InstantLoanProfileWarmedEventType, type InstantLoanRepayCompleteEventType, type InstantLoanRepayment, type InstantLoanRepaymentTargetQuote, type InstantLoanStuckFundsWithdrawalRequestedEventType, type InstantLoanTerms, type InstantLoanWarmedProfile, InstantLoansModule, LendingModule, type LiquidiumAccount, type LiquidiumAccountInput, type LiquidiumAccountReference, LiquidiumAccountType, LiquidiumClient, type LiquidiumClientConfig, LiquidiumError, LiquidiumErrorCode, type LiquidiumErrorContext, type LiquidiumOperation, type LiquidiumState, type LiquidiumStatus, type ListActivitiesByProfileRequest, type ListActivitiesByShortRefRequest, type ListActivitiesRequest, type LtvCalculation, MIN_BORROW_AMOUNTS_BY_ASSET, MIN_WITHDRAW_AMOUNTS_BY_ASSET, type ManualTransferSupplyFlowRequest, MarketModule, type MaxRepayAmount, type MinimumBorrowAsset, type MinimumWithdrawAsset, type OutflowActivity, type OutflowActivityOperation, type OutflowActivityStatus, type OutflowDetails, OutflowType, type PaginatedResponse, type Pool, type PoolCanisterIds, 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 SendIcrcTransferRequest, type SignMessageRequest, type SignMessageWalletAction, type SignatureInfo, type SigningChain, type SubmitInflowRequest, type SubmitInflowResponse, type SubmitSupplyFlowInflowRequest, SupplyAction, type SupplyFlow, type SupplyFlowRequest, SupplyPlanType, type SupplyTarget, type TransferSupplyFlowRequest, USDC_CONTRACT_ADDRESS, USDT_CONTRACT_ADDRESS, type UserHistoryEntry, type UserHistoryEntryApiItem, type UserHistoryOperation, type UserHistoryResponse, type UserLiquidationHistoryEntry, type UserLiquidationHistoryFilters, type UserPositionSummary, type UserReserve, type UserStats, type UserTransactionHistoryEntry, type UserTransactionHistoryFilters, type UserTransactionHistoryOperation, type UserTransactionHistoryState, type Wallet, type WalletAction, WalletActionKind, type WalletAdapter, WalletExecutionKind, type WalletExecutionParams, type WalletTransferSupplyFlowRequest, type WithdrawAction, type WithdrawOutflowDetails, createTransferErc20Transaction, executeWith, getMinimumBorrowAmount, getMinimumWithdrawAmount, intFromPublicId, isAssetIdentifier, publicIdFromInt };
|