@liquidium/client 0.4.1 → 0.5.0-rc.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 +117 -86
- package/dist/index.cjs +3833 -3048
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +576 -518
- package/dist/index.d.ts +576 -518
- package/dist/index.js +3830 -3047
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
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
|
-
/** Accountless
|
|
51
|
-
|
|
59
|
+
/** Accountless Simple Loans canister principal. */
|
|
60
|
+
simpleLoans: 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 Simple Loans 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. */
|
|
@@ -396,12 +502,12 @@ interface ListActivitiesByProfileRequest extends BaseListActivitiesRequest {
|
|
|
396
502
|
/** Profile principal text to list activities for. */
|
|
397
503
|
profileId: string;
|
|
398
504
|
}
|
|
399
|
-
/** Activity list request scoped to
|
|
505
|
+
/** Activity list request scoped to a simple loan short reference. */
|
|
400
506
|
interface ListActivitiesByShortRefRequest extends BaseListActivitiesRequest {
|
|
401
|
-
/**
|
|
507
|
+
/** Simple loan short reference to list activities for. */
|
|
402
508
|
shortRef: string;
|
|
403
509
|
}
|
|
404
|
-
/** Request for listing activities by profile id or
|
|
510
|
+
/** Request for listing activities by profile id or simple loan short reference. */
|
|
405
511
|
type ListActivitiesRequest = ListActivitiesByProfileRequest | ListActivitiesByShortRefRequest;
|
|
406
512
|
/** Shared request fields for an activity status lookup. */
|
|
407
513
|
interface BaseGetActivityStatusRequest {
|
|
@@ -413,9 +519,9 @@ interface GetActivityStatusByProfileRequest extends BaseGetActivityStatusRequest
|
|
|
413
519
|
/** Profile principal text that owns the activity. */
|
|
414
520
|
profileId: string;
|
|
415
521
|
}
|
|
416
|
-
/** Activity status lookup scoped to
|
|
522
|
+
/** Activity status lookup scoped to a simple loan short reference. */
|
|
417
523
|
interface GetActivityStatusByShortRefRequest extends BaseGetActivityStatusRequest {
|
|
418
|
-
/**
|
|
524
|
+
/** Simple loan short reference that owns the activity. */
|
|
419
525
|
shortRef: string;
|
|
420
526
|
}
|
|
421
527
|
/** Request for fetching one activity by id and owner identifier. */
|
|
@@ -447,7 +553,7 @@ declare class ActivitiesModule {
|
|
|
447
553
|
*
|
|
448
554
|
* Uses the Liquidium SDK API.
|
|
449
555
|
*
|
|
450
|
-
* @param request - Profile id or
|
|
556
|
+
* @param request - Profile id or simple loan short reference plus optional lifecycle filter.
|
|
451
557
|
* @returns Activities owned by the resolved profile.
|
|
452
558
|
*/
|
|
453
559
|
list(request: ListActivitiesRequest): Promise<Activity[]>;
|
|
@@ -456,7 +562,7 @@ declare class ActivitiesModule {
|
|
|
456
562
|
*
|
|
457
563
|
* Uses the Liquidium SDK API.
|
|
458
564
|
*
|
|
459
|
-
* @param request - Activity id plus profile id or
|
|
565
|
+
* @param request - Activity id plus profile id or simple loan short reference.
|
|
460
566
|
* @returns The activity when found, otherwise `{ found: false }` with the requested id.
|
|
461
567
|
*/
|
|
462
568
|
getStatus(request: GetActivityStatusRequest): Promise<GetActivityStatusResponse>;
|
|
@@ -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
|
}
|
|
@@ -931,6 +975,9 @@ interface EvmSupplyContext {
|
|
|
931
975
|
approvalStrategy: EvmSupplyApprovalStrategy;
|
|
932
976
|
}
|
|
933
977
|
|
|
978
|
+
/** Builds calldata for an ERC-20 `transfer(recipient, amount)` transaction. */
|
|
979
|
+
declare function createTransferErc20Transaction(params: CreateTransferErc20TransactionParams): EvmContractTransaction;
|
|
980
|
+
|
|
934
981
|
/** Borrow, withdraw, supply, inflow reporting, and fee-estimation helpers. */
|
|
935
982
|
declare class LendingModule {
|
|
936
983
|
private readonly canisterContext;
|
|
@@ -941,7 +988,6 @@ declare class LendingModule {
|
|
|
941
988
|
* Prepares a withdraw action that can be signed and submitted later.
|
|
942
989
|
*
|
|
943
990
|
* Use this when you need explicit control over signing and submission.
|
|
944
|
-
*
|
|
945
991
|
* @param request - Profile, pool, amount (pool asset base units), outflow address, and signer wallet.
|
|
946
992
|
* @returns A signable {@link WithdrawAction} with `submit` wired to the canister.
|
|
947
993
|
*/
|
|
@@ -960,6 +1006,8 @@ declare class LendingModule {
|
|
|
960
1006
|
* Prepares a borrow action that can be signed and submitted later.
|
|
961
1007
|
*
|
|
962
1008
|
* Use this when you need explicit control over signing and submission.
|
|
1009
|
+
* When the selected pool disables same-asset borrowing, preparation rejects
|
|
1010
|
+
* profiles whose supplied balance in that pool is at or above its dust threshold.
|
|
963
1011
|
*
|
|
964
1012
|
* @param request - Profile, pool, amount (borrow asset base units), outflow address, and signer wallet.
|
|
965
1013
|
* @returns A signable {@link BorrowAction} with `submit` wired to the canister.
|
|
@@ -970,6 +1018,7 @@ declare class LendingModule {
|
|
|
970
1018
|
* Creates a borrow outflow using the provided wallet adapter.
|
|
971
1019
|
*
|
|
972
1020
|
* This is the convenience form of `prepareBorrow(...)` plus execution.
|
|
1021
|
+
* Same-asset policy validation runs before the wallet is asked to sign.
|
|
973
1022
|
*
|
|
974
1023
|
* @param params - Borrow request fields plus `signerChain` and `signerWalletAdapter`.
|
|
975
1024
|
* @returns The lending canister receipt as {@link OutflowDetails}.
|
|
@@ -1018,12 +1067,14 @@ declare class LendingModule {
|
|
|
1018
1067
|
*
|
|
1019
1068
|
* ETH stablecoin deposit-address estimates are served by the deposit-address
|
|
1020
1069
|
* canister. BTC estimates include the ckBTC minter deposit fee and ledger fee.
|
|
1070
|
+
* ICP-chain estimates return the corresponding ICRC ledger fee.
|
|
1021
1071
|
*
|
|
1022
1072
|
* @param request - Asset and chain pair to estimate for.
|
|
1023
1073
|
* @returns Total fee estimate rounded up in the asset's base units.
|
|
1024
1074
|
*/
|
|
1025
1075
|
estimateInflowFee(request: EstimateInflowFeeRequest): Promise<InflowFeeEstimate>;
|
|
1026
1076
|
private estimateBtcInflowFee;
|
|
1077
|
+
private estimateIcrcLedgerFee;
|
|
1027
1078
|
/**
|
|
1028
1079
|
* Submits an inflow transaction id for faster indexing.
|
|
1029
1080
|
*
|
|
@@ -1041,7 +1092,7 @@ declare class LendingModule {
|
|
|
1041
1092
|
isBorrowingDisabled(): Promise<boolean>;
|
|
1042
1093
|
private requireApi;
|
|
1043
1094
|
private createSupplyFlowExecutor;
|
|
1044
|
-
private
|
|
1095
|
+
private guardBorrowSameAssetPolicy;
|
|
1045
1096
|
}
|
|
1046
1097
|
|
|
1047
1098
|
/** Current protocol metadata and rate state for a lending pool. */
|
|
@@ -1049,9 +1100,9 @@ interface Pool {
|
|
|
1049
1100
|
/** Pool canister principal text. */
|
|
1050
1101
|
id: string;
|
|
1051
1102
|
/** Asset supplied to and borrowed from the pool. */
|
|
1052
|
-
asset:
|
|
1103
|
+
asset: Asset;
|
|
1053
1104
|
/** Chain associated with the pool asset. */
|
|
1054
|
-
chain:
|
|
1105
|
+
chain: Chain;
|
|
1055
1106
|
/** Number of base-unit decimals for pool amounts. */
|
|
1056
1107
|
decimals: bigint;
|
|
1057
1108
|
/** Whether new pool activity is currently frozen. */
|
|
@@ -1098,18 +1149,15 @@ interface Pool {
|
|
|
1098
1149
|
borrowIndex: bigint;
|
|
1099
1150
|
/** Whether borrowing the same asset as collateral is allowed. */
|
|
1100
1151
|
sameAssetBorrowing: boolean;
|
|
1152
|
+
/** Same-asset collateral below this base-unit amount is treated as dust. */
|
|
1153
|
+
sameAssetBorrowingDustThreshold: bigint;
|
|
1101
1154
|
/** Unix timestamp in seconds of the last pool update when available. */
|
|
1102
1155
|
lastUpdated?: bigint;
|
|
1103
1156
|
}
|
|
1104
1157
|
/** USD price map keyed by market asset symbol. */
|
|
1105
1158
|
type AssetPrices = Record<string, number>;
|
|
1106
|
-
/**
|
|
1107
|
-
|
|
1108
|
-
/** Asset symbol to match. */
|
|
1109
|
-
asset: MarketAsset;
|
|
1110
|
-
/** Chain name to match. */
|
|
1111
|
-
chain: MarketChain;
|
|
1112
|
-
}
|
|
1159
|
+
/** Supported Chain + Asset identifier used to find its backing lending pool. */
|
|
1160
|
+
type FindPoolQuery = AssetIdentifier;
|
|
1113
1161
|
/** Current borrow, lend, and utilization rates for a pool. */
|
|
1114
1162
|
interface PoolRate {
|
|
1115
1163
|
/** Decimal scale used by rate fields. */
|
|
@@ -1141,7 +1189,10 @@ declare class MarketModule {
|
|
|
1141
1189
|
*/
|
|
1142
1190
|
getAssetPrices(): Promise<AssetPrices>;
|
|
1143
1191
|
/**
|
|
1144
|
-
* Resolves a single pool for the given
|
|
1192
|
+
* Resolves a single backing pool for the given Chain + Asset identifier.
|
|
1193
|
+
*
|
|
1194
|
+
* Native and chain-key identifiers share a pool. For example, both
|
|
1195
|
+
* `ETH/USDT` and `ICP/USDT` resolve to the USDT lending pool.
|
|
1145
1196
|
*
|
|
1146
1197
|
* @param query - The market asset and chain pair to match.
|
|
1147
1198
|
* @returns The single pool that matches the requested asset and chain.
|
|
@@ -1171,7 +1222,7 @@ interface Position {
|
|
|
1171
1222
|
/** Pool principal text. */
|
|
1172
1223
|
poolId: string;
|
|
1173
1224
|
/** Pool asset symbol. */
|
|
1174
|
-
asset:
|
|
1225
|
+
asset: Asset;
|
|
1175
1226
|
/** Current supplied amount in base units. */
|
|
1176
1227
|
deposited: bigint;
|
|
1177
1228
|
/** Decimal scale for supplied amounts. */
|
|
@@ -1349,119 +1400,275 @@ declare class PositionsModule {
|
|
|
1349
1400
|
getFullWithdrawAmount(profileId: string, poolId: string): Promise<FullWithdrawAmount>;
|
|
1350
1401
|
}
|
|
1351
1402
|
|
|
1352
|
-
/**
|
|
1353
|
-
|
|
1403
|
+
/** Input for calculating required collateral from a target LTV. */
|
|
1404
|
+
interface QuoteRequest {
|
|
1405
|
+
/** Requested borrow amount in borrow asset base units. */
|
|
1406
|
+
borrowAmount: bigint;
|
|
1407
|
+
/** Pool principal text for the borrow side. */
|
|
1408
|
+
borrowPoolId: string;
|
|
1409
|
+
/** Pool principal text for the collateral side. */
|
|
1410
|
+
collateralPoolId: string;
|
|
1411
|
+
/** Target loan-to-value ratio in basis points. */
|
|
1412
|
+
targetLtvBps: bigint;
|
|
1413
|
+
}
|
|
1414
|
+
/** Input for calculating LTV from explicit borrow and collateral amounts. */
|
|
1415
|
+
interface CalculateLtvRequest {
|
|
1416
|
+
/** Requested borrow amount in borrow asset base units. */
|
|
1417
|
+
borrowAmount: bigint;
|
|
1418
|
+
/** Pool principal text for the borrow side. */
|
|
1419
|
+
borrowPoolId: string;
|
|
1420
|
+
/** Collateral amount in collateral asset base units. */
|
|
1421
|
+
collateralAmount: bigint;
|
|
1422
|
+
/** Pool principal text for the collateral side. */
|
|
1423
|
+
collateralPoolId: string;
|
|
1424
|
+
}
|
|
1425
|
+
/** Validation error produced by quote helpers. */
|
|
1426
|
+
interface QuoteValidationError {
|
|
1427
|
+
/** Stable machine-readable validation code. */
|
|
1428
|
+
code: QuoteValidationErrorCode;
|
|
1429
|
+
/** Human-readable validation message. */
|
|
1430
|
+
message: string;
|
|
1431
|
+
}
|
|
1432
|
+
/** Stable validation codes produced by quote helpers. */
|
|
1433
|
+
declare enum QuoteValidationErrorCode {
|
|
1434
|
+
INVALID_LTV = "INVALID_LTV",
|
|
1435
|
+
LTV_EXCEEDS_MAX = "LTV_EXCEEDS_MAX",
|
|
1436
|
+
SAME_ASSET_NOT_ALLOWED = "SAME_ASSET_NOT_ALLOWED",
|
|
1437
|
+
BORROW_AMOUNT_TOO_LOW = "BORROW_AMOUNT_TOO_LOW",
|
|
1438
|
+
PRICE_NOT_AVAILABLE = "PRICE_NOT_AVAILABLE",
|
|
1439
|
+
POOL_NOT_FOUND = "POOL_NOT_FOUND",
|
|
1440
|
+
UNKNOWN = "UNKNOWN"
|
|
1441
|
+
}
|
|
1442
|
+
/** Non-blocking warning produced by quote helpers. */
|
|
1443
|
+
interface QuoteWarning {
|
|
1444
|
+
/** Stable machine-readable warning code. */
|
|
1445
|
+
code: QuoteWarningCode;
|
|
1446
|
+
/** Human-readable warning message. */
|
|
1447
|
+
message: string;
|
|
1448
|
+
}
|
|
1449
|
+
/** Stable warning codes produced by quote helpers. */
|
|
1450
|
+
declare enum QuoteWarningCode {
|
|
1451
|
+
HIGH_LTV = "HIGH_LTV",
|
|
1452
|
+
SAME_ASSET_BORROWING = "SAME_ASSET_BORROWING"
|
|
1453
|
+
}
|
|
1454
|
+
/** Quote result for a requested borrow amount and target LTV. */
|
|
1455
|
+
interface QuoteResult {
|
|
1456
|
+
/** Requested borrow amount in borrow asset base units. */
|
|
1457
|
+
borrowAmount: bigint;
|
|
1458
|
+
/** Borrow value in internal USD units. */
|
|
1459
|
+
borrowUsd: bigint;
|
|
1460
|
+
/** Required collateral amount in collateral asset base units. */
|
|
1461
|
+
requiredCollateralAmount: bigint;
|
|
1462
|
+
/** Required collateral value in internal USD units. */
|
|
1463
|
+
requiredCollateralUsd: bigint;
|
|
1464
|
+
/** Maximum allowed LTV in basis points for the collateral pool. */
|
|
1465
|
+
maxAllowedLtvBps: bigint;
|
|
1466
|
+
/** Requested target LTV in basis points. */
|
|
1467
|
+
targetLtvBps: bigint;
|
|
1468
|
+
/** Pool principal text for the borrow side. */
|
|
1469
|
+
borrowPoolId: string;
|
|
1470
|
+
/** Pool principal text for the collateral side. */
|
|
1471
|
+
collateralPoolId: string;
|
|
1472
|
+
/** Borrow asset symbol. */
|
|
1473
|
+
borrowAsset: string;
|
|
1474
|
+
/** Collateral asset symbol. */
|
|
1475
|
+
collateralAsset: string;
|
|
1476
|
+
/** Blocking validation errors. Empty when the quote is usable. */
|
|
1477
|
+
validationErrors: QuoteValidationError[];
|
|
1478
|
+
/** Non-blocking quote warnings. */
|
|
1479
|
+
warnings: QuoteWarning[];
|
|
1480
|
+
}
|
|
1481
|
+
/** LTV calculation result for explicit borrow and collateral amounts. */
|
|
1482
|
+
interface LtvCalculation {
|
|
1483
|
+
/** Requested borrow amount in borrow asset base units. */
|
|
1484
|
+
borrowAmount: bigint;
|
|
1485
|
+
/** Collateral amount in collateral asset base units. */
|
|
1486
|
+
collateralAmount: bigint;
|
|
1487
|
+
/** Borrow value in internal USD units. */
|
|
1488
|
+
borrowUsd: bigint;
|
|
1489
|
+
/** Collateral value in internal USD units. */
|
|
1490
|
+
collateralUsd: bigint;
|
|
1491
|
+
/** Computed LTV in basis points. */
|
|
1492
|
+
ltvBps: bigint;
|
|
1493
|
+
/** Maximum allowed LTV in basis points for the collateral pool. */
|
|
1494
|
+
maxAllowedLtvBps: bigint;
|
|
1495
|
+
/** Pool principal text for the borrow side. */
|
|
1496
|
+
borrowPoolId: string;
|
|
1497
|
+
/** Pool principal text for the collateral side. */
|
|
1498
|
+
collateralPoolId: string;
|
|
1499
|
+
/** Borrow asset symbol. */
|
|
1500
|
+
borrowAsset: string;
|
|
1501
|
+
/** Collateral asset symbol. */
|
|
1502
|
+
collateralAsset: string;
|
|
1503
|
+
/** Blocking validation errors. Empty when the calculation is usable. */
|
|
1504
|
+
validationErrors: QuoteValidationError[];
|
|
1505
|
+
}
|
|
1354
1506
|
|
|
1355
|
-
/**
|
|
1356
|
-
|
|
1357
|
-
/** External chain account used for borrow delivery or collateral refunds. */
|
|
1358
|
-
interface ExternalAccount {
|
|
1507
|
+
/** Pure quote helpers for LTV and required-collateral calculations. */
|
|
1508
|
+
declare class QuoteModule {
|
|
1359
1509
|
/**
|
|
1360
|
-
*
|
|
1510
|
+
* Calculates current LTV from caller-supplied borrow and collateral amounts.
|
|
1361
1511
|
*
|
|
1362
|
-
*
|
|
1363
|
-
* addresses. Instant-loan creation currently accepts external destinations.
|
|
1364
|
-
*/
|
|
1365
|
-
type: "External";
|
|
1366
|
-
/**
|
|
1367
|
-
* Optional chain metadata for display and caller-side validation.
|
|
1512
|
+
* Amount fields are base units. USD fields are scaled to 8 decimal places.
|
|
1368
1513
|
*
|
|
1369
|
-
*
|
|
1370
|
-
*
|
|
1514
|
+
* @param request - Borrow and collateral pool ids plus base-unit amounts.
|
|
1515
|
+
* @param pools - Available pools, usually from `client.market.listPools()`.
|
|
1516
|
+
* @param prices - USD price map, usually from `client.market.getAssetPrices()`.
|
|
1517
|
+
* @returns LTV calculation plus validation errors when inputs are unusable.
|
|
1371
1518
|
*/
|
|
1372
|
-
|
|
1519
|
+
calculateLtv(request: CalculateLtvRequest, pools: Pool[], prices: AssetPrices): LtvCalculation;
|
|
1373
1520
|
/**
|
|
1374
|
-
*
|
|
1521
|
+
* Calculates a loan quote based on borrow amount, LTV, and pool selections.
|
|
1375
1522
|
*
|
|
1376
|
-
*
|
|
1377
|
-
* `
|
|
1523
|
+
* All arithmetic is performed in bigint. `requiredCollateralAmount` and
|
|
1524
|
+
* `requiredCollateralUsd` are rounded UP so the caller never under-collateralizes
|
|
1525
|
+
* due to integer truncation. `borrowUsd` is floored for display.
|
|
1526
|
+
*
|
|
1527
|
+
* @param request - Quote request parameters.
|
|
1528
|
+
* @param pools - All available pools (use MarketModule.listPools() to fetch).
|
|
1529
|
+
* @param prices - Asset prices in USD (use MarketModule.getAssetPrices() to fetch).
|
|
1530
|
+
* @returns Quote result with required collateral and validation state.
|
|
1378
1531
|
*/
|
|
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;
|
|
1532
|
+
getQuote(request: QuoteRequest, pools: Pool[], prices: AssetPrices): QuoteResult;
|
|
1405
1533
|
}
|
|
1406
|
-
|
|
1407
|
-
type InstantLoanAccount = ExternalAccount | NativeAccount | AccountIdentifierAccount | IcrcAccount;
|
|
1534
|
+
|
|
1408
1535
|
/**
|
|
1409
|
-
*
|
|
1536
|
+
* Converts a canister loan id into a short user-facing reference.
|
|
1410
1537
|
*
|
|
1411
|
-
*
|
|
1412
|
-
*
|
|
1413
|
-
|
|
1538
|
+
* @param id - Canister loan id in the supported public-reference range.
|
|
1539
|
+
* @returns Fixed-length public reference string.
|
|
1540
|
+
*/
|
|
1541
|
+
declare function publicIdFromInt(id: bigint): string;
|
|
1542
|
+
/**
|
|
1543
|
+
* Decodes a short user-facing reference back into the canister loan id.
|
|
1414
1544
|
*
|
|
1415
|
-
*
|
|
1416
|
-
*
|
|
1417
|
-
* pool decimals.
|
|
1545
|
+
* @param ref - Fixed-length public reference string.
|
|
1546
|
+
* @returns Canister loan id represented by the reference.
|
|
1418
1547
|
*/
|
|
1419
|
-
|
|
1548
|
+
declare function intFromPublicId(ref: string): bigint;
|
|
1549
|
+
|
|
1550
|
+
/** Asset symbols supported by the Simple Loans canister. */
|
|
1551
|
+
type SimpleLoanAsset = AssetIdentifier["asset"];
|
|
1552
|
+
/** Collateral leg used when creating a simple loan. */
|
|
1553
|
+
interface CreateSimpleLoanCollateral {
|
|
1420
1554
|
/**
|
|
1421
1555
|
* Principal text of the pool that receives the user's collateral deposit.
|
|
1422
1556
|
*
|
|
1423
1557
|
* This should be the `id` of the collateral `Pool` selected from
|
|
1424
|
-
* `client.market.listPools()`. The pool asset must match `
|
|
1425
|
-
*/
|
|
1426
|
-
collateralPoolId: string;
|
|
1427
|
-
/**
|
|
1428
|
-
* Principal text of the pool that funds the borrow.
|
|
1429
|
-
*
|
|
1430
|
-
* This should be the `id` of the borrow `Pool` selected from
|
|
1431
|
-
* `client.market.listPools()`. The pool asset must match `borrowAsset`.
|
|
1558
|
+
* `client.market.listPools()`. The pool asset must match `asset`.
|
|
1432
1559
|
*/
|
|
1433
|
-
|
|
1560
|
+
poolId: string;
|
|
1434
1561
|
/**
|
|
1435
1562
|
* Asset the user will deposit as collateral.
|
|
1436
1563
|
*
|
|
1437
|
-
* Must match the asset for `
|
|
1438
|
-
*
|
|
1564
|
+
* Must match the asset for `poolId`; for example, use `"BTC"` with a BTC
|
|
1565
|
+
* collateral pool.
|
|
1439
1566
|
*/
|
|
1440
|
-
|
|
1441
|
-
/**
|
|
1442
|
-
* Asset the user wants to borrow from the borrow pool.
|
|
1443
|
-
*
|
|
1444
|
-
* Must match the asset for `borrowPoolId`; for example, use `"USDC"` with a
|
|
1445
|
-
* USDC borrow pool.
|
|
1446
|
-
*/
|
|
1447
|
-
borrowAsset: InstantLoanAsset;
|
|
1567
|
+
asset: SimpleLoanAsset;
|
|
1448
1568
|
/**
|
|
1449
1569
|
* Intended credited collateral amount, in base units.
|
|
1450
1570
|
*
|
|
1451
1571
|
* This is used to validate LTV and initialize the loan record before
|
|
1452
1572
|
* deposit/inflow fees are deducted. For BTC, pass satoshis. For token assets,
|
|
1453
1573
|
* convert the UI amount using the selected pool's `decimals` value. After
|
|
1454
|
-
* creation, use `loan.initialDeposit.
|
|
1455
|
-
*
|
|
1574
|
+
* creation, use one of `loan.initialDeposit.targets` as the fee-inclusive
|
|
1575
|
+
* transfer quote and destination.
|
|
1456
1576
|
*/
|
|
1457
|
-
|
|
1577
|
+
amount: bigint;
|
|
1578
|
+
}
|
|
1579
|
+
/**
|
|
1580
|
+
* Borrow leg used when creating a simple loan.
|
|
1581
|
+
*
|
|
1582
|
+
* `chain` and `asset` form the canonical asset identifier. For example,
|
|
1583
|
+
* `{ chain: "ICP", asset: "USDT" }` means ckUSDT.
|
|
1584
|
+
*/
|
|
1585
|
+
type CreateSimpleLoanBorrow = AssetIdentifier & {
|
|
1586
|
+
/**
|
|
1587
|
+
* Principal text of the pool that funds the borrow.
|
|
1588
|
+
*
|
|
1589
|
+
* This should be the `id` of the borrow `Pool` selected from
|
|
1590
|
+
* `client.market.listPools()`. The pool asset must match `asset`.
|
|
1591
|
+
*/
|
|
1592
|
+
poolId: string;
|
|
1458
1593
|
/**
|
|
1459
1594
|
* Amount to borrow, in the borrow asset's base units.
|
|
1460
1595
|
*
|
|
1461
1596
|
* For USDC/USDT, convert the UI amount using the selected borrow pool's
|
|
1462
1597
|
* `decimals` value before passing it here.
|
|
1463
1598
|
*/
|
|
1464
|
-
|
|
1599
|
+
amount: bigint;
|
|
1600
|
+
/**
|
|
1601
|
+
* Destination that receives the borrowed asset after the loan starts.
|
|
1602
|
+
*
|
|
1603
|
+
* Pass either a string shorthand or a typed destination. For BTC/ETH chain
|
|
1604
|
+
* outflows this is usually the user's chain address. Chain-key assets on ICP
|
|
1605
|
+
* require an `IcPrincipal`; native ICP also accepts `IcpAccountIdentifier`
|
|
1606
|
+
* and `IcrcAccount` destinations.
|
|
1607
|
+
*/
|
|
1608
|
+
destination: SimpleLoanDestination;
|
|
1609
|
+
};
|
|
1610
|
+
/** Refund leg used when creating a simple loan. */
|
|
1611
|
+
interface CreateSimpleLoanRefund {
|
|
1612
|
+
/** Delivery chain used for collateral refunds and withdrawals. Use ICP for ck-ledger delivery. */
|
|
1613
|
+
chain: Chain;
|
|
1614
|
+
/**
|
|
1615
|
+
* Destination that receives collateral refunds or withdrawals.
|
|
1616
|
+
*
|
|
1617
|
+
* Pass either a string shorthand or a typed destination. For BTC/ETH chain
|
|
1618
|
+
* outflows this is usually the user's chain address. Chain-key assets on ICP
|
|
1619
|
+
* require an `IcPrincipal`; native ICP also accepts `IcpAccountIdentifier`
|
|
1620
|
+
* and `IcrcAccount` destinations.
|
|
1621
|
+
*/
|
|
1622
|
+
destination: SimpleLoanDestination;
|
|
1623
|
+
}
|
|
1624
|
+
/**
|
|
1625
|
+
* Borrow destination or refund account associated with a simple loan.
|
|
1626
|
+
*
|
|
1627
|
+
* @example
|
|
1628
|
+
* ```ts
|
|
1629
|
+
* const icPrincipalAccount: SimpleLoanAccount = {
|
|
1630
|
+
* type: "IcPrincipal",
|
|
1631
|
+
* address: "aaaaa-aa",
|
|
1632
|
+
* };
|
|
1633
|
+
*
|
|
1634
|
+
* const chainAddressAccount: SimpleLoanAccount = {
|
|
1635
|
+
* type: "ChainAddress",
|
|
1636
|
+
* address: "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
|
|
1637
|
+
* };
|
|
1638
|
+
*
|
|
1639
|
+
* const accountIdentifierAccount: SimpleLoanAccount = {
|
|
1640
|
+
* type: "IcpAccountIdentifier",
|
|
1641
|
+
* address: "e2134f3f176b1429df3f92807b8f0f26a520debc313b2d6ad86a4a2e7f3d8f8d",
|
|
1642
|
+
* };
|
|
1643
|
+
*
|
|
1644
|
+
* const icrcAccount: SimpleLoanAccount = {
|
|
1645
|
+
* type: "IcrcAccount",
|
|
1646
|
+
* owner: "aaaaa-aa",
|
|
1647
|
+
* address: "aaaaa-aa",
|
|
1648
|
+
* };
|
|
1649
|
+
* ```
|
|
1650
|
+
*/
|
|
1651
|
+
type SimpleLoanAccount = LiquidiumAccount;
|
|
1652
|
+
/** Destination accepted when creating a simple loan. */
|
|
1653
|
+
type SimpleLoanDestination = LiquidiumAccountInput;
|
|
1654
|
+
/**
|
|
1655
|
+
* Parameters for creating an accountless simple loan.
|
|
1656
|
+
*
|
|
1657
|
+
* Use market data from `client.market.listPools()` to choose the two pool ids,
|
|
1658
|
+
* and use `client.quote.calculateLtv(...)` before creation to validate the
|
|
1659
|
+
* amount pair and choose `ltvMaxBps`.
|
|
1660
|
+
*
|
|
1661
|
+
* Amount fields are in each asset's smallest/base units. For example, BTC uses
|
|
1662
|
+
* satoshis and ERC-20 assets use token base units according to the selected
|
|
1663
|
+
* pool decimals.
|
|
1664
|
+
*/
|
|
1665
|
+
interface CreateSimpleLoanRequest {
|
|
1666
|
+
/** Collateral leg: pool, asset, and amount the user deposits. */
|
|
1667
|
+
collateral: CreateSimpleLoanCollateral;
|
|
1668
|
+
/** Borrow leg: pool, asset, amount, delivery chain, and destination. */
|
|
1669
|
+
borrow: CreateSimpleLoanBorrow;
|
|
1670
|
+
/** Refund leg: chain and destination for returned collateral. */
|
|
1671
|
+
refund: CreateSimpleLoanRefund;
|
|
1465
1672
|
/**
|
|
1466
1673
|
* Maximum allowed loan-to-value ratio in basis points.
|
|
1467
1674
|
*
|
|
@@ -1475,153 +1682,137 @@ interface CreateInstantLoanRequest {
|
|
|
1475
1682
|
* Seconds allowed for the user to send collateral after loan creation.
|
|
1476
1683
|
*
|
|
1477
1684
|
* If the collateral deposit is not detected before this window expires, the
|
|
1478
|
-
*
|
|
1685
|
+
* simple loan flow can time out. Internally this is sent to the canister as
|
|
1479
1686
|
* `ltv_timer_s`.
|
|
1480
1687
|
*/
|
|
1481
1688
|
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
1689
|
}
|
|
1499
|
-
/** Lookup request for loading
|
|
1500
|
-
interface
|
|
1690
|
+
/** Lookup request for loading a simple loan by numeric canister id. */
|
|
1691
|
+
interface SimpleLoanGetByIdRequest {
|
|
1501
1692
|
/** Canister-assigned loan id. */
|
|
1502
1693
|
loanId: bigint;
|
|
1503
1694
|
}
|
|
1504
|
-
/** Lookup request for loading
|
|
1505
|
-
interface
|
|
1695
|
+
/** Lookup request for loading a simple loan by short user-facing reference. */
|
|
1696
|
+
interface SimpleLoanGetByRefRequest {
|
|
1506
1697
|
/** Short user-facing reference derived from `loanId`. */
|
|
1507
1698
|
ref: string;
|
|
1508
1699
|
}
|
|
1509
|
-
/** Lookup request for loading canonical
|
|
1510
|
-
type
|
|
1511
|
-
/** Collateral leg returned by
|
|
1512
|
-
interface
|
|
1700
|
+
/** Lookup request for loading canonical simple loan state. */
|
|
1701
|
+
type SimpleLoanGetRequest = SimpleLoanGetByIdRequest | SimpleLoanGetByRefRequest;
|
|
1702
|
+
/** Collateral leg returned by Simple Loans search. */
|
|
1703
|
+
interface SimpleLoanFindCollateral {
|
|
1513
1704
|
/** Principal text of the collateral pool. */
|
|
1514
1705
|
poolId: string;
|
|
1515
1706
|
/** Asset the user deposits as collateral. */
|
|
1516
|
-
asset:
|
|
1707
|
+
asset: SimpleLoanAsset;
|
|
1517
1708
|
/** Intended credited collateral amount in base units, before inflow fees. */
|
|
1518
1709
|
amount: bigint;
|
|
1519
1710
|
}
|
|
1520
|
-
/** Borrow leg returned by
|
|
1521
|
-
interface
|
|
1711
|
+
/** Borrow leg returned by Simple Loans search. */
|
|
1712
|
+
interface SimpleLoanFindBorrow {
|
|
1522
1713
|
/** Principal text of the borrow pool. */
|
|
1523
1714
|
poolId: string;
|
|
1524
1715
|
/** Asset the user borrows. */
|
|
1525
|
-
asset:
|
|
1716
|
+
asset: SimpleLoanAsset;
|
|
1526
1717
|
}
|
|
1527
|
-
/** Lightweight search result for
|
|
1528
|
-
interface
|
|
1529
|
-
/** Canister-assigned loan id. Use this with `client.
|
|
1718
|
+
/** Lightweight search result for a simple loan match. */
|
|
1719
|
+
interface SimpleLoanFindResult {
|
|
1720
|
+
/** Canister-assigned loan id. Use this with `client.simpleLoans.get({ loanId })` to load full loan state. */
|
|
1530
1721
|
loanId: bigint;
|
|
1531
1722
|
/** Short user-facing reference derived from `loanId`. */
|
|
1532
1723
|
ref: string;
|
|
1533
1724
|
/** Unix creation timestamp in seconds. */
|
|
1534
1725
|
createdAt: bigint;
|
|
1535
1726
|
/** Collateral-side pool, asset, and requested credited amount. */
|
|
1536
|
-
collateral:
|
|
1727
|
+
collateral: SimpleLoanFindCollateral;
|
|
1537
1728
|
/** Borrow-side pool and asset. */
|
|
1538
|
-
borrow:
|
|
1729
|
+
borrow: SimpleLoanFindBorrow;
|
|
1539
1730
|
/** Generated profile principal from the search index. */
|
|
1540
1731
|
profileId: string;
|
|
1541
1732
|
}
|
|
1542
|
-
/** Page request for direct
|
|
1543
|
-
interface
|
|
1733
|
+
/** Page request for direct Simple Loans canister event queries. */
|
|
1734
|
+
interface SimpleLoanListEventsRequest {
|
|
1544
1735
|
/** Event id to start from. */
|
|
1545
1736
|
start: bigint;
|
|
1546
1737
|
/** Maximum number of events to return. */
|
|
1547
1738
|
limit: bigint;
|
|
1548
1739
|
}
|
|
1549
|
-
/** Active
|
|
1550
|
-
interface
|
|
1551
|
-
/** Principal text of the lending canister used by
|
|
1740
|
+
/** Active Simple Loans canister config. */
|
|
1741
|
+
interface SimpleLoanConfig {
|
|
1742
|
+
/** Principal text of the lending canister used by Simple Loans. */
|
|
1552
1743
|
lendingCanisterId: string;
|
|
1553
1744
|
}
|
|
1554
|
-
/** Authentication metadata for warmed
|
|
1555
|
-
interface
|
|
1745
|
+
/** Authentication metadata for warmed Simple Loans profiles. */
|
|
1746
|
+
interface SimpleLoanAuthorization {
|
|
1556
1747
|
type: "EthSignature";
|
|
1557
1748
|
derivationIndex: Uint8Array;
|
|
1558
1749
|
publicKey: Uint8Array;
|
|
1559
1750
|
address: string;
|
|
1560
1751
|
}
|
|
1561
|
-
/** Warmed profile available for a future
|
|
1562
|
-
interface
|
|
1752
|
+
/** Warmed profile available for a future simple loan. */
|
|
1753
|
+
interface SimpleLoanWarmedProfile {
|
|
1563
1754
|
id: bigint;
|
|
1564
|
-
authorization:
|
|
1755
|
+
authorization: SimpleLoanAuthorization;
|
|
1565
1756
|
/** Unix creation timestamp in seconds. */
|
|
1566
1757
|
createdAt: bigint;
|
|
1567
1758
|
profileId: string;
|
|
1568
1759
|
}
|
|
1569
|
-
/** Direct canister event returned by the
|
|
1570
|
-
interface
|
|
1760
|
+
/** Direct canister event returned by the Simple Loans query API. */
|
|
1761
|
+
interface SimpleLoanEvent {
|
|
1571
1762
|
id: bigint;
|
|
1572
1763
|
schemaVersion: number;
|
|
1573
1764
|
/** Unix event timestamp in seconds. */
|
|
1574
1765
|
timestamp: bigint;
|
|
1575
|
-
eventType:
|
|
1766
|
+
eventType: SimpleLoanEventType;
|
|
1576
1767
|
}
|
|
1577
|
-
/**
|
|
1578
|
-
type
|
|
1579
|
-
/**
|
|
1580
|
-
interface
|
|
1768
|
+
/** Simple loan leg used when stuck funds are withdrawn. */
|
|
1769
|
+
type SimpleLoanLeg = "Lend" | "Borrow";
|
|
1770
|
+
/** Simple-loan-created event payload. */
|
|
1771
|
+
interface SimpleLoanCreatedEventType {
|
|
1581
1772
|
type: "LoanCreated";
|
|
1582
1773
|
loanId: bigint;
|
|
1583
|
-
borrowDestination:
|
|
1584
|
-
collateralAsset:
|
|
1774
|
+
borrowDestination: SimpleLoanAccount;
|
|
1775
|
+
collateralAsset: SimpleLoanAsset;
|
|
1585
1776
|
borrowAmount: bigint;
|
|
1586
1777
|
collateralPoolId: string;
|
|
1587
|
-
refundDestination:
|
|
1778
|
+
refundDestination: SimpleLoanAccount;
|
|
1588
1779
|
ltvMaxBps: bigint;
|
|
1589
1780
|
depositWindowSeconds: bigint;
|
|
1590
1781
|
profileId: string;
|
|
1591
1782
|
borrowPoolId: string;
|
|
1592
|
-
borrowAsset:
|
|
1783
|
+
borrowAsset: SimpleLoanAsset;
|
|
1593
1784
|
}
|
|
1594
1785
|
/** Full collateral withdrawal request event payload. */
|
|
1595
|
-
interface
|
|
1786
|
+
interface SimpleLoanFullLendWithdrawalRequestedEventType {
|
|
1596
1787
|
type: "FullLendWithdrawalRequested";
|
|
1597
1788
|
loanId: bigint;
|
|
1598
|
-
account:
|
|
1789
|
+
account: SimpleLoanAccount;
|
|
1599
1790
|
poolId: string;
|
|
1600
1791
|
}
|
|
1601
1792
|
/** Borrow request event payload. */
|
|
1602
|
-
interface
|
|
1793
|
+
interface SimpleLoanBorrowRequestedEventType {
|
|
1603
1794
|
type: "BorrowRequested";
|
|
1604
1795
|
loanId: bigint;
|
|
1605
|
-
account:
|
|
1796
|
+
account: SimpleLoanAccount;
|
|
1606
1797
|
poolId: string;
|
|
1607
1798
|
amount: bigint;
|
|
1608
1799
|
}
|
|
1609
1800
|
/** Deposit timer exceeded event payload. */
|
|
1610
|
-
interface
|
|
1801
|
+
interface SimpleLoanDepositTimerExceededEventType {
|
|
1611
1802
|
type: "DepositTimerExceeded";
|
|
1612
1803
|
loanId: bigint;
|
|
1613
1804
|
}
|
|
1614
1805
|
/** Stuck funds withdrawal request event payload. */
|
|
1615
|
-
interface
|
|
1806
|
+
interface SimpleLoanStuckFundsWithdrawalRequestedEventType {
|
|
1616
1807
|
type: "StuckFundsWithdrawalRequested";
|
|
1617
|
-
leg:
|
|
1808
|
+
leg: SimpleLoanLeg;
|
|
1618
1809
|
loanId: bigint;
|
|
1619
|
-
account:
|
|
1810
|
+
account: SimpleLoanAccount;
|
|
1620
1811
|
poolId: string;
|
|
1621
1812
|
amount: bigint;
|
|
1622
1813
|
}
|
|
1623
1814
|
/** Profile-warmed event payload. */
|
|
1624
|
-
interface
|
|
1815
|
+
interface SimpleLoanProfileWarmedEventType {
|
|
1625
1816
|
type: "ProfileWarmed";
|
|
1626
1817
|
derivationIndex: Uint8Array;
|
|
1627
1818
|
warmedProfileId: bigint;
|
|
@@ -1629,24 +1820,42 @@ interface InstantLoanProfileWarmedEventType {
|
|
|
1629
1820
|
profileId: string;
|
|
1630
1821
|
}
|
|
1631
1822
|
/** Repay-complete event payload. */
|
|
1632
|
-
interface
|
|
1823
|
+
interface SimpleLoanRepayCompleteEventType {
|
|
1633
1824
|
type: "RepayComplete";
|
|
1634
1825
|
loanId: bigint;
|
|
1635
1826
|
profileId: string;
|
|
1636
1827
|
}
|
|
1637
1828
|
/** Deposit timer started event payload. */
|
|
1638
|
-
interface
|
|
1829
|
+
interface SimpleLoanDepositTimerStartedEventType {
|
|
1639
1830
|
type: "DepositTimerStarted";
|
|
1640
1831
|
loanId: bigint;
|
|
1641
1832
|
/** Unix timestamp in seconds when the deposit timer started. */
|
|
1642
1833
|
timestamp: bigint;
|
|
1643
1834
|
}
|
|
1644
|
-
/** Direct canister event payload returned by
|
|
1645
|
-
type
|
|
1646
|
-
/**
|
|
1647
|
-
interface
|
|
1835
|
+
/** Direct canister event payload returned by Simple Loans event queries. */
|
|
1836
|
+
type SimpleLoanEventType = SimpleLoanCreatedEventType | SimpleLoanFullLendWithdrawalRequestedEventType | SimpleLoanBorrowRequestedEventType | SimpleLoanDepositTimerExceededEventType | SimpleLoanStuckFundsWithdrawalRequestedEventType | SimpleLoanProfileWarmedEventType | SimpleLoanRepayCompleteEventType | SimpleLoanDepositTimerStartedEventType;
|
|
1837
|
+
/** Fee-inclusive collateral deposit quote for one transfer target. */
|
|
1838
|
+
interface SimpleLoanInitialDepositTargetQuote {
|
|
1839
|
+
/** Full amount to send to the collateral deposit target, including fee. */
|
|
1840
|
+
amount: bigint;
|
|
1841
|
+
/** Inflow fee amount in base units added to the transfer amount. */
|
|
1842
|
+
inflowFeeAmount: bigint;
|
|
1843
|
+
/** Address or ICRC account where the collateral should be sent. */
|
|
1844
|
+
target: SupplyTarget;
|
|
1845
|
+
}
|
|
1846
|
+
/** Fee-inclusive repayment quote for one transfer target. */
|
|
1847
|
+
interface SimpleLoanRepaymentTargetQuote {
|
|
1648
1848
|
/** Full amount to send to the repayment target, including fee and interest buffer. */
|
|
1649
1849
|
amount: bigint;
|
|
1850
|
+
/** Inflow fee amount in base units added to the repayment transfer. Falls back to the protocol minimum when live estimation is unavailable. */
|
|
1851
|
+
inflowFeeAmount: bigint;
|
|
1852
|
+
/** Whether `inflowFeeAmount` came from a live fee estimate. */
|
|
1853
|
+
inflowFeeEstimateAvailable: boolean;
|
|
1854
|
+
/** Address or ICRC account where the repayment should be sent. */
|
|
1855
|
+
target: SupplyTarget;
|
|
1856
|
+
}
|
|
1857
|
+
/** Current amount to send to a repayment target to close the debt. */
|
|
1858
|
+
interface SimpleLoanRepayment {
|
|
1650
1859
|
/** Decimal scale for `amount`. */
|
|
1651
1860
|
decimals: bigint;
|
|
1652
1861
|
/** Current debt in base units, before fee and interest buffer. */
|
|
@@ -1655,40 +1864,28 @@ interface InstantLoanRepayment {
|
|
|
1655
1864
|
interestBufferAmount: bigint;
|
|
1656
1865
|
/** Seconds of interest accrual included in `interestBufferAmount`. */
|
|
1657
1866
|
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
1867
|
/** Asset to repay. */
|
|
1663
|
-
asset:
|
|
1664
|
-
/**
|
|
1665
|
-
|
|
1666
|
-
/** Address or ICRC account where the repayment should be sent. */
|
|
1667
|
-
target: SupplyTarget;
|
|
1868
|
+
asset: SimpleLoanAsset;
|
|
1869
|
+
/** Available repayment targets keyed by the actual transfer chain. */
|
|
1870
|
+
targets: Partial<Record<Chain, SimpleLoanRepaymentTargetQuote>>;
|
|
1668
1871
|
}
|
|
1669
|
-
/** Initial collateral deposit quote returned when
|
|
1670
|
-
interface
|
|
1671
|
-
/** Full amount to send to the deposit target, including the estimated inflow fee. */
|
|
1672
|
-
amount: bigint;
|
|
1872
|
+
/** Initial collateral deposit quote returned when a simple loan is created. */
|
|
1873
|
+
interface SimpleLoanInitialDeposit {
|
|
1673
1874
|
/** Decimal scale for `amount`, `collateralAmount`, and `inflowFeeAmount`. */
|
|
1674
1875
|
decimals: bigint;
|
|
1675
1876
|
/** Intended credited collateral amount in base units, before inflow fees. */
|
|
1676
1877
|
collateralAmount: bigint;
|
|
1677
|
-
/** Inflow fee amount in base units added to the transfer amount. */
|
|
1678
|
-
inflowFeeAmount: bigint;
|
|
1679
1878
|
/** Collateral asset to deposit. */
|
|
1680
|
-
asset:
|
|
1681
|
-
/**
|
|
1682
|
-
|
|
1683
|
-
/** Address or ICRC account where the collateral should be sent. */
|
|
1684
|
-
target: SupplyTarget;
|
|
1879
|
+
asset: SimpleLoanAsset;
|
|
1880
|
+
/** Available collateral deposit targets keyed by the actual transfer chain. */
|
|
1881
|
+
targets: Partial<Record<Chain, SimpleLoanInitialDepositTargetQuote>>;
|
|
1685
1882
|
/** Unix timestamp in seconds when the collateral deposit was detected, or null before detection. */
|
|
1686
1883
|
detectedTimestamp: bigint | null;
|
|
1687
1884
|
/** Unix timestamp in seconds when the collateral deposit window expires, or null before detection when unavailable. */
|
|
1688
1885
|
expiryTimestamp: bigint | null;
|
|
1689
1886
|
}
|
|
1690
|
-
/** Current lending position backing the
|
|
1691
|
-
interface
|
|
1887
|
+
/** Current lending position backing the simple loan. */
|
|
1888
|
+
interface SimpleLoanPositionSummary {
|
|
1692
1889
|
/** Current collateral amount in the collateral asset's base units. */
|
|
1693
1890
|
collateralAmount: bigint;
|
|
1694
1891
|
/** Decimal scale for `collateralAmount`. */
|
|
@@ -1704,69 +1901,74 @@ interface InstantLoanPositionSummary {
|
|
|
1704
1901
|
/** Borrowed principal plus accrued interest in base units, before repayment buffer. */
|
|
1705
1902
|
totalDebtAmount: bigint;
|
|
1706
1903
|
}
|
|
1707
|
-
/** Immutable terms selected for
|
|
1708
|
-
interface
|
|
1904
|
+
/** Immutable terms selected for a simple loan. */
|
|
1905
|
+
interface SimpleLoanTerms {
|
|
1709
1906
|
/** Maximum loan-to-value ratio in basis points. */
|
|
1710
1907
|
ltvMaxBps: bigint;
|
|
1711
1908
|
/** Seconds allowed for the collateral deposit before timeout. */
|
|
1712
1909
|
depositWindowSeconds: bigint;
|
|
1713
1910
|
}
|
|
1714
|
-
/** Collateral leg selected for
|
|
1715
|
-
interface
|
|
1911
|
+
/** Collateral leg selected for a simple loan. */
|
|
1912
|
+
interface SimpleLoanCollateral {
|
|
1716
1913
|
/** Principal text of the collateral pool. */
|
|
1717
1914
|
poolId: string;
|
|
1718
|
-
/**
|
|
1719
|
-
asset:
|
|
1720
|
-
/** Chain used for collateral deposits. */
|
|
1721
|
-
chain: MarketChain;
|
|
1915
|
+
/** Asset deposited as collateral. Transfer rails are exposed by `initialDeposit.targets`. */
|
|
1916
|
+
asset: SimpleLoanAsset;
|
|
1722
1917
|
/** Decimal scale for collateral amounts. */
|
|
1723
1918
|
decimals: bigint;
|
|
1724
1919
|
/** Intended credited collateral amount in base units, before inflow fees. */
|
|
1725
1920
|
amount: bigint;
|
|
1726
1921
|
}
|
|
1727
|
-
/** Borrow leg selected for
|
|
1728
|
-
|
|
1922
|
+
/** Borrow leg selected for a simple loan. */
|
|
1923
|
+
type SimpleLoanBorrow = AssetIdentifier & {
|
|
1729
1924
|
/** Principal text of the borrow pool. */
|
|
1730
1925
|
poolId: string;
|
|
1731
|
-
/** Borrow asset symbol. */
|
|
1732
|
-
asset: MarketAsset;
|
|
1733
|
-
/** Chain used for repayment. */
|
|
1734
|
-
chain: MarketChain;
|
|
1735
1926
|
/** Decimal scale for borrow and debt amounts. */
|
|
1736
1927
|
decimals: bigint;
|
|
1737
1928
|
/** Requested borrow amount in base units. */
|
|
1738
1929
|
amount: bigint;
|
|
1739
1930
|
/** Destination that receives the borrowed asset. */
|
|
1740
|
-
destination:
|
|
1741
|
-
}
|
|
1742
|
-
/** Hydrated
|
|
1743
|
-
interface
|
|
1931
|
+
destination: SimpleLoanAccount;
|
|
1932
|
+
};
|
|
1933
|
+
/** Hydrated simple loan state plus generated quote targets. */
|
|
1934
|
+
interface SimpleLoan {
|
|
1744
1935
|
/** Canister-assigned loan id. */
|
|
1745
1936
|
loanId: bigint;
|
|
1746
1937
|
/** Short user-facing reference derived from `loanId`. */
|
|
1747
1938
|
ref: string;
|
|
1748
1939
|
/** Shared lifecycle status for display and flow control. */
|
|
1749
1940
|
status: LiquidiumStatus;
|
|
1750
|
-
/** Generated profile principal used by the
|
|
1941
|
+
/** Generated profile principal used by the simple loan. */
|
|
1751
1942
|
profileId: string;
|
|
1752
1943
|
/** Immutable loan terms. */
|
|
1753
|
-
terms:
|
|
1754
|
-
/** Collateral-side pool, asset,
|
|
1755
|
-
collateral:
|
|
1944
|
+
terms: SimpleLoanTerms;
|
|
1945
|
+
/** Collateral-side pool, asset, decimals, and requested credited amount. */
|
|
1946
|
+
collateral: SimpleLoanCollateral;
|
|
1756
1947
|
/** Borrow-side pool, asset, chain, decimals, requested amount, and destination. */
|
|
1757
|
-
borrow:
|
|
1948
|
+
borrow: SimpleLoanBorrow;
|
|
1758
1949
|
/** Destination used for collateral refunds or withdrawals. */
|
|
1759
|
-
refundDestination:
|
|
1950
|
+
refundDestination: SimpleLoanAccount;
|
|
1760
1951
|
/** Current actionable initial collateral deposit quote. */
|
|
1761
|
-
initialDeposit:
|
|
1952
|
+
initialDeposit: SimpleLoanInitialDeposit;
|
|
1762
1953
|
/** Current repayment quote. Amount fields are zero when the loan has no debt. */
|
|
1763
|
-
repayment:
|
|
1954
|
+
repayment: SimpleLoanRepayment;
|
|
1764
1955
|
/** Current lending position state for the generated profile. */
|
|
1765
|
-
position:
|
|
1956
|
+
position: SimpleLoanPositionSummary;
|
|
1766
1957
|
}
|
|
1767
1958
|
|
|
1768
|
-
/**
|
|
1769
|
-
|
|
1959
|
+
/**
|
|
1960
|
+
* A loan was created remotely, but the SDK could not load its enriched state.
|
|
1961
|
+
* Retry with `simpleLoans.get({ loanId })`; do not create the loan again.
|
|
1962
|
+
*/
|
|
1963
|
+
declare class SimpleLoanCreatedError extends Error {
|
|
1964
|
+
readonly code: "SIMPLE_LOAN_HYDRATION_FAILED";
|
|
1965
|
+
readonly loanId: bigint;
|
|
1966
|
+
readonly ref: string;
|
|
1967
|
+
readonly cause: unknown;
|
|
1968
|
+
constructor(loanId: bigint, cause: unknown);
|
|
1969
|
+
}
|
|
1970
|
+
/** Accountless Simple Loans creation, lookup, recovery, and canister query helpers. */
|
|
1971
|
+
declare class SimpleLoansModule {
|
|
1770
1972
|
private readonly canisterContext;
|
|
1771
1973
|
private readonly apiClient;
|
|
1772
1974
|
private readonly activities;
|
|
@@ -1774,7 +1976,7 @@ declare class InstantLoansModule {
|
|
|
1774
1976
|
private readonly positions;
|
|
1775
1977
|
constructor(canisterContext: CanisterContext, apiClient: ApiClient | undefined, activities: ActivitiesModule, lending: LendingModule, positions: PositionsModule);
|
|
1776
1978
|
/**
|
|
1777
|
-
* Creates a profileless
|
|
1979
|
+
* Creates a profileless simple loan and returns canonical canister state plus
|
|
1778
1980
|
* generated initial-deposit and repayment quote targets.
|
|
1779
1981
|
*
|
|
1780
1982
|
* Choose `collateralPoolId` and `borrowPoolId` from
|
|
@@ -1782,27 +1984,28 @@ declare class InstantLoansModule {
|
|
|
1782
1984
|
* selected pool decimals, and call `client.quote.calculateLtv(...)` before
|
|
1783
1985
|
* creation to block invalid LTV input.
|
|
1784
1986
|
*
|
|
1785
|
-
* `
|
|
1786
|
-
* `
|
|
1987
|
+
* `borrow.destination` receives the borrowed asset after the loan starts.
|
|
1988
|
+
* `refund.destination` receives collateral refunds or withdrawals. Use
|
|
1787
1989
|
* `depositWindowSeconds` for the user-facing collateral deposit timeout; the
|
|
1788
1990
|
* SDK maps it to the canister's internal `ltv_timer_s` field.
|
|
1991
|
+
* Pool assets and same-asset borrowing policy are validated before creation.
|
|
1789
1992
|
*
|
|
1790
|
-
* @param request -
|
|
1993
|
+
* @param request - Collateral, borrow, refund, LTV limit, timeout, and inflow options.
|
|
1791
1994
|
* @returns Hydrated loan state plus generated initial-deposit and repayment quote targets.
|
|
1792
1995
|
*/
|
|
1793
|
-
create(request:
|
|
1996
|
+
create(request: CreateSimpleLoanRequest): Promise<SimpleLoan>;
|
|
1794
1997
|
/**
|
|
1795
1998
|
* Resolves canonical canister state by loan id or short reference.
|
|
1796
1999
|
*
|
|
1797
2000
|
* References are decoded locally, then the corresponding loan id is loaded
|
|
1798
|
-
* from the
|
|
2001
|
+
* from the Simple Loans canister.
|
|
1799
2002
|
*
|
|
1800
2003
|
* @param request - Canister loan id or short public reference.
|
|
1801
2004
|
* @returns Hydrated loan state plus generated initial-deposit and repayment quote targets.
|
|
1802
2005
|
*/
|
|
1803
|
-
get(request:
|
|
2006
|
+
get(request: SimpleLoanGetRequest): Promise<SimpleLoan>;
|
|
1804
2007
|
/**
|
|
1805
|
-
* Finds
|
|
2008
|
+
* Finds simple loans by short reference, numeric loan id string, address, or transaction id.
|
|
1806
2009
|
*
|
|
1807
2010
|
* Search returns lightweight matches. Call `get({ loanId })` or `get({ ref })`
|
|
1808
2011
|
* when the user selects a match and you need hydrated loan state.
|
|
@@ -1810,27 +2013,27 @@ declare class InstantLoansModule {
|
|
|
1810
2013
|
* @param query - Short reference, address, transaction id/hash, or numeric loan id string.
|
|
1811
2014
|
* @returns Matching loan ids and references from the search index.
|
|
1812
2015
|
*/
|
|
1813
|
-
find(query: string): Promise<
|
|
2016
|
+
find(query: string): Promise<SimpleLoanFindResult[]>;
|
|
1814
2017
|
/**
|
|
1815
|
-
* Returns the active
|
|
2018
|
+
* Returns the active Simple Loans canister config via direct query.
|
|
1816
2019
|
*
|
|
1817
2020
|
* @returns Active canister configuration.
|
|
1818
2021
|
*/
|
|
1819
|
-
getConfig(): Promise<
|
|
2022
|
+
getConfig(): Promise<SimpleLoanConfig>;
|
|
1820
2023
|
/**
|
|
1821
2024
|
* Returns a single canister event by id via direct query.
|
|
1822
2025
|
*
|
|
1823
2026
|
* @param eventId - Event id to load.
|
|
1824
2027
|
* @returns The event when found, otherwise `null`.
|
|
1825
2028
|
*/
|
|
1826
|
-
getEvent(eventId: bigint): Promise<
|
|
2029
|
+
getEvent(eventId: bigint): Promise<SimpleLoanEvent | null>;
|
|
1827
2030
|
/**
|
|
1828
2031
|
* Returns a page of canister events via direct query.
|
|
1829
2032
|
*
|
|
1830
2033
|
* @param request - Start event id and maximum number of events to return.
|
|
1831
2034
|
* @returns Canister events in ascending id order.
|
|
1832
2035
|
*/
|
|
1833
|
-
listEvents(request:
|
|
2036
|
+
listEvents(request: SimpleLoanListEventsRequest): Promise<SimpleLoanEvent[]>;
|
|
1834
2037
|
/**
|
|
1835
2038
|
* Returns principals authorized for protected update callbacks.
|
|
1836
2039
|
*
|
|
@@ -1844,168 +2047,23 @@ declare class InstantLoansModule {
|
|
|
1844
2047
|
*/
|
|
1845
2048
|
countWarmedProfiles(): Promise<bigint>;
|
|
1846
2049
|
/**
|
|
1847
|
-
* Returns warmed profiles currently available for future
|
|
2050
|
+
* Returns warmed profiles currently available for future simple loans.
|
|
1848
2051
|
*
|
|
1849
2052
|
* @returns Warmed profile records available for assignment.
|
|
1850
2053
|
*/
|
|
1851
|
-
listWarmedProfiles(): Promise<
|
|
2054
|
+
listWarmedProfiles(): Promise<SimpleLoanWarmedProfile[]>;
|
|
1852
2055
|
private findCandidateLoansByQuery;
|
|
1853
2056
|
private getLoanRecord;
|
|
1854
2057
|
private mapLoanRecord;
|
|
1855
2058
|
private getCollateralAmountHint;
|
|
1856
2059
|
private hydrateLoan;
|
|
1857
2060
|
private createInitialDepositQuote;
|
|
2061
|
+
private resolveSimpleLoanInflowTargets;
|
|
2062
|
+
private createRepaymentTargetQuotes;
|
|
1858
2063
|
private estimateRepaymentInflowFee;
|
|
1859
2064
|
private requireApi;
|
|
1860
|
-
private
|
|
1861
|
-
private
|
|
1862
|
-
}
|
|
1863
|
-
|
|
1864
|
-
/**
|
|
1865
|
-
* Converts a canister loan id into a short user-facing reference.
|
|
1866
|
-
*
|
|
1867
|
-
* @param id - Canister loan id in the supported public-reference range.
|
|
1868
|
-
* @returns Fixed-length public reference string.
|
|
1869
|
-
*/
|
|
1870
|
-
declare function publicIdFromInt(id: bigint): string;
|
|
1871
|
-
/**
|
|
1872
|
-
* Decodes a short user-facing reference back into the canister loan id.
|
|
1873
|
-
*
|
|
1874
|
-
* @param ref - Fixed-length public reference string.
|
|
1875
|
-
* @returns Canister loan id represented by the reference.
|
|
1876
|
-
*/
|
|
1877
|
-
declare function intFromPublicId(ref: string): bigint;
|
|
1878
|
-
|
|
1879
|
-
/** Input for calculating required collateral from a target LTV. */
|
|
1880
|
-
interface QuoteRequest {
|
|
1881
|
-
/** Requested borrow amount in borrow asset base units. */
|
|
1882
|
-
borrowAmount: bigint;
|
|
1883
|
-
/** Pool principal text for the borrow side. */
|
|
1884
|
-
borrowPoolId: string;
|
|
1885
|
-
/** Pool principal text for the collateral side. */
|
|
1886
|
-
collateralPoolId: string;
|
|
1887
|
-
/** Target loan-to-value ratio in basis points. */
|
|
1888
|
-
targetLtvBps: bigint;
|
|
1889
|
-
}
|
|
1890
|
-
/** Input for calculating LTV from explicit borrow and collateral amounts. */
|
|
1891
|
-
interface CalculateLtvRequest {
|
|
1892
|
-
/** Requested borrow amount in borrow asset base units. */
|
|
1893
|
-
borrowAmount: bigint;
|
|
1894
|
-
/** Pool principal text for the borrow side. */
|
|
1895
|
-
borrowPoolId: string;
|
|
1896
|
-
/** Collateral amount in collateral asset base units. */
|
|
1897
|
-
collateralAmount: bigint;
|
|
1898
|
-
/** Pool principal text for the collateral side. */
|
|
1899
|
-
collateralPoolId: string;
|
|
1900
|
-
}
|
|
1901
|
-
/** Validation error produced by quote helpers. */
|
|
1902
|
-
interface QuoteValidationError {
|
|
1903
|
-
/** Stable machine-readable validation code. */
|
|
1904
|
-
code: QuoteValidationErrorCode;
|
|
1905
|
-
/** Human-readable validation message. */
|
|
1906
|
-
message: string;
|
|
1907
|
-
}
|
|
1908
|
-
/** Stable validation codes produced by quote helpers. */
|
|
1909
|
-
declare enum QuoteValidationErrorCode {
|
|
1910
|
-
INVALID_LTV = "INVALID_LTV",
|
|
1911
|
-
LTV_EXCEEDS_MAX = "LTV_EXCEEDS_MAX",
|
|
1912
|
-
SAME_ASSET_NOT_ALLOWED = "SAME_ASSET_NOT_ALLOWED",
|
|
1913
|
-
BORROW_AMOUNT_TOO_LOW = "BORROW_AMOUNT_TOO_LOW",
|
|
1914
|
-
PRICE_NOT_AVAILABLE = "PRICE_NOT_AVAILABLE",
|
|
1915
|
-
POOL_NOT_FOUND = "POOL_NOT_FOUND",
|
|
1916
|
-
UNKNOWN = "UNKNOWN"
|
|
1917
|
-
}
|
|
1918
|
-
/** Non-blocking warning produced by quote helpers. */
|
|
1919
|
-
interface QuoteWarning {
|
|
1920
|
-
/** Stable machine-readable warning code. */
|
|
1921
|
-
code: QuoteWarningCode;
|
|
1922
|
-
/** Human-readable warning message. */
|
|
1923
|
-
message: string;
|
|
1924
|
-
}
|
|
1925
|
-
/** Stable warning codes produced by quote helpers. */
|
|
1926
|
-
declare enum QuoteWarningCode {
|
|
1927
|
-
HIGH_LTV = "HIGH_LTV",
|
|
1928
|
-
SAME_ASSET_BORROWING = "SAME_ASSET_BORROWING"
|
|
1929
|
-
}
|
|
1930
|
-
/** Quote result for a requested borrow amount and target LTV. */
|
|
1931
|
-
interface QuoteResult {
|
|
1932
|
-
/** Requested borrow amount in borrow asset base units. */
|
|
1933
|
-
borrowAmount: bigint;
|
|
1934
|
-
/** Borrow value in internal USD units. */
|
|
1935
|
-
borrowUsd: bigint;
|
|
1936
|
-
/** Required collateral amount in collateral asset base units. */
|
|
1937
|
-
requiredCollateralAmount: bigint;
|
|
1938
|
-
/** Required collateral value in internal USD units. */
|
|
1939
|
-
requiredCollateralUsd: bigint;
|
|
1940
|
-
/** Maximum allowed LTV in basis points for the collateral pool. */
|
|
1941
|
-
maxAllowedLtvBps: bigint;
|
|
1942
|
-
/** Requested target LTV in basis points. */
|
|
1943
|
-
targetLtvBps: bigint;
|
|
1944
|
-
/** Pool principal text for the borrow side. */
|
|
1945
|
-
borrowPoolId: string;
|
|
1946
|
-
/** Pool principal text for the collateral side. */
|
|
1947
|
-
collateralPoolId: string;
|
|
1948
|
-
/** Borrow asset symbol. */
|
|
1949
|
-
borrowAsset: string;
|
|
1950
|
-
/** Collateral asset symbol. */
|
|
1951
|
-
collateralAsset: string;
|
|
1952
|
-
/** Blocking validation errors. Empty when the quote is usable. */
|
|
1953
|
-
validationErrors: QuoteValidationError[];
|
|
1954
|
-
/** Non-blocking quote warnings. */
|
|
1955
|
-
warnings: QuoteWarning[];
|
|
1956
|
-
}
|
|
1957
|
-
/** LTV calculation result for explicit borrow and collateral amounts. */
|
|
1958
|
-
interface LtvCalculation {
|
|
1959
|
-
/** Requested borrow amount in borrow asset base units. */
|
|
1960
|
-
borrowAmount: bigint;
|
|
1961
|
-
/** Collateral amount in collateral asset base units. */
|
|
1962
|
-
collateralAmount: bigint;
|
|
1963
|
-
/** Borrow value in internal USD units. */
|
|
1964
|
-
borrowUsd: bigint;
|
|
1965
|
-
/** Collateral value in internal USD units. */
|
|
1966
|
-
collateralUsd: bigint;
|
|
1967
|
-
/** Computed LTV in basis points. */
|
|
1968
|
-
ltvBps: bigint;
|
|
1969
|
-
/** Maximum allowed LTV in basis points for the collateral pool. */
|
|
1970
|
-
maxAllowedLtvBps: bigint;
|
|
1971
|
-
/** Pool principal text for the borrow side. */
|
|
1972
|
-
borrowPoolId: string;
|
|
1973
|
-
/** Pool principal text for the collateral side. */
|
|
1974
|
-
collateralPoolId: string;
|
|
1975
|
-
/** Borrow asset symbol. */
|
|
1976
|
-
borrowAsset: string;
|
|
1977
|
-
/** Collateral asset symbol. */
|
|
1978
|
-
collateralAsset: string;
|
|
1979
|
-
/** Blocking validation errors. Empty when the calculation is usable. */
|
|
1980
|
-
validationErrors: QuoteValidationError[];
|
|
1981
|
-
}
|
|
1982
|
-
|
|
1983
|
-
/** Pure quote helpers for LTV and required-collateral calculations. */
|
|
1984
|
-
declare class QuoteModule {
|
|
1985
|
-
/**
|
|
1986
|
-
* Calculates current LTV from caller-supplied borrow and collateral amounts.
|
|
1987
|
-
*
|
|
1988
|
-
* Amount fields are base units. USD fields are scaled to 8 decimal places.
|
|
1989
|
-
*
|
|
1990
|
-
* @param request - Borrow and collateral pool ids plus base-unit amounts.
|
|
1991
|
-
* @param pools - Available pools, usually from `client.market.listPools()`.
|
|
1992
|
-
* @param prices - USD price map, usually from `client.market.getAssetPrices()`.
|
|
1993
|
-
* @returns LTV calculation plus validation errors when inputs are unusable.
|
|
1994
|
-
*/
|
|
1995
|
-
calculateLtv(request: CalculateLtvRequest, pools: Pool[], prices: AssetPrices): LtvCalculation;
|
|
1996
|
-
/**
|
|
1997
|
-
* Calculates a loan quote based on borrow amount, LTV, and pool selections.
|
|
1998
|
-
*
|
|
1999
|
-
* All arithmetic is performed in bigint. `requiredCollateralAmount` and
|
|
2000
|
-
* `requiredCollateralUsd` are rounded UP so the caller never under-collateralizes
|
|
2001
|
-
* due to integer truncation. `borrowUsd` is floored for display.
|
|
2002
|
-
*
|
|
2003
|
-
* @param request - Quote request parameters.
|
|
2004
|
-
* @param pools - All available pools (use MarketModule.listPools() to fetch).
|
|
2005
|
-
* @param prices - Asset prices in USD (use MarketModule.getAssetPrices() to fetch).
|
|
2006
|
-
* @returns Quote result with required collateral and validation state.
|
|
2007
|
-
*/
|
|
2008
|
-
getQuote(request: QuoteRequest, pools: Pool[], prices: AssetPrices): QuoteResult;
|
|
2065
|
+
private validateSimpleLoanLtvPolicy;
|
|
2066
|
+
private calculateSimpleLoanLtv;
|
|
2009
2067
|
}
|
|
2010
2068
|
|
|
2011
2069
|
/**
|
|
@@ -2026,8 +2084,8 @@ declare class LiquidiumClient {
|
|
|
2026
2084
|
readonly activities: ActivitiesModule;
|
|
2027
2085
|
/** Pool and user history through the Liquidium SDK API. */
|
|
2028
2086
|
readonly history: HistoryModule;
|
|
2029
|
-
/** Accountless
|
|
2030
|
-
readonly
|
|
2087
|
+
/** Accountless Simple Loans backed by generated deposit/repay targets. */
|
|
2088
|
+
readonly simpleLoans: SimpleLoansModule;
|
|
2031
2089
|
/** Pure quote helpers from market inputs. */
|
|
2032
2090
|
readonly quote: QuoteModule;
|
|
2033
2091
|
private readonly canisterContext;
|
|
@@ -2164,7 +2222,7 @@ interface ExecuteWithOptions {
|
|
|
2164
2222
|
/** Must expose the methods required by the action's `executionKind`. */
|
|
2165
2223
|
walletAdapter: WalletAdapter;
|
|
2166
2224
|
/** Required for `sign-message` actions; forwarded to the adapter and submit payload. */
|
|
2167
|
-
chain?:
|
|
2225
|
+
chain?: SigningChain;
|
|
2168
2226
|
/** Optional signing/sending account override. */
|
|
2169
2227
|
account?: string;
|
|
2170
2228
|
}
|
|
@@ -2178,4 +2236,4 @@ interface ExecuteWithOptions {
|
|
|
2178
2236
|
*/
|
|
2179
2237
|
declare function executeWith(options: ExecuteWithOptions): <TResult>(action: WalletAction<TResult>) => Promise<TResult>;
|
|
2180
2238
|
|
|
2181
|
-
export {
|
|
2239
|
+
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 CreateProfileParams, type CreateSimpleLoanBorrow, type CreateSimpleLoanCollateral, type CreateSimpleLoanRefund, type CreateSimpleLoanRequest, 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, 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 SimpleLoan, type SimpleLoanAccount, type SimpleLoanAsset, type SimpleLoanAuthorization, type SimpleLoanBorrow, type SimpleLoanBorrowRequestedEventType, type SimpleLoanCollateral, type SimpleLoanConfig, SimpleLoanCreatedError, type SimpleLoanCreatedEventType, type SimpleLoanDepositTimerExceededEventType, type SimpleLoanDepositTimerStartedEventType, type SimpleLoanDestination, type SimpleLoanEvent, type SimpleLoanEventType, type SimpleLoanFindBorrow, type SimpleLoanFindCollateral, type SimpleLoanFindResult, type SimpleLoanFullLendWithdrawalRequestedEventType, type SimpleLoanGetByIdRequest, type SimpleLoanGetByRefRequest, type SimpleLoanGetRequest, type SimpleLoanInitialDeposit, type SimpleLoanInitialDepositTargetQuote, type SimpleLoanLeg, type SimpleLoanListEventsRequest, type SimpleLoanPositionSummary, type SimpleLoanProfileWarmedEventType, type SimpleLoanRepayCompleteEventType, type SimpleLoanRepayment, type SimpleLoanRepaymentTargetQuote, type SimpleLoanStuckFundsWithdrawalRequestedEventType, type SimpleLoanTerms, type SimpleLoanWarmedProfile, SimpleLoansModule, 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 };
|