@liquidium/client 0.5.0-rc.0 → 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 CHANGED
@@ -8,12 +8,12 @@
8
8
  <h1 align="center">Liquidium SDK</h1>
9
9
 
10
10
  <p align="center">
11
- Use the Liquidium SDK from TypeScript apps. Start with accountless instant loans.
11
+ Use the Liquidium SDK from TypeScript apps. Start with accountless Simple Loans.
12
12
  </p>
13
13
 
14
14
  <p align="center">
15
15
  <a href="https://liquidium-inc.github.io/liquidium-sdk/"><b>SDK Docs</b></a> ·
16
- <a href="https://github.com/Liquidium-Inc/liquidium-sdk/tree/main/examples/instant-loans-flow"><b>Instant Loan Example</b></a> ·
16
+ <a href="https://github.com/Liquidium-Inc/liquidium-sdk/tree/main/examples/simple-loans-flow"><b>Simple Loans Example</b></a> ·
17
17
  <a href="https://github.com/Liquidium-Inc/liquidium-sdk/tree/main/examples/sdk-method-query"><b>SDK Method Query Example</b></a> ·
18
18
  <a href="#core-api"><b>Core API</b></a>
19
19
  </p>
@@ -24,9 +24,9 @@ Use the SDK docs for setup, guides, API reference, and examples.
24
24
 
25
25
  [Open the Liquidium SDK docs](https://liquidium-inc.github.io/liquidium-sdk/)
26
26
 
27
- ## Why Start With Instant Loans
27
+ ## Why Start With Simple Loans
28
28
 
29
- - **Accountless loan creation**: create instant loans without requiring a Liquidium profile.
29
+ - **Accountless loan creation**: create simple loans without requiring a Liquidium profile.
30
30
  - **Generated transfer targets**: get collateral deposit and repayment targets from the SDK response.
31
31
  - **Reference-based restore**: save `loan.ref` and reload loan state from any browser session or support link.
32
32
  - **LTV checks**: use market pools and prices to validate collateral and borrow amounts before loan creation.
@@ -38,10 +38,10 @@ Liquidium supports two borrowing and lending integration paths:
38
38
 
39
39
  | Path | Use when | Main SDK calls |
40
40
  | --- | --- | --- |
41
- | Recommended: accountless instant loans | You want a short checkout-style flow where users borrow against collateral without creating a Liquidium profile first | `client.instantLoans.create(...)`, `client.instantLoans.get(...)`, `client.instantLoans.find(...)`, `client.activities.list(...)` |
41
+ | Recommended: accountless Simple Loans | You want a short checkout-style flow where users borrow against collateral without creating a Liquidium profile first | `client.simpleLoans.create(...)`, `client.simpleLoans.get(...)`, `client.simpleLoans.find(...)`, `client.activities.list(...)` |
42
42
  | Account-based profile flows | You want users to keep a Liquidium profile, manage positions across sessions, supply funds, borrow, withdraw, or use ETH contract-interaction deposits | `client.accounts.createProfile(...)`, `client.lending.supply(...)`, `client.lending.borrow(...)`, `client.lending.withdraw(...)`, `client.positions.listPositions(...)` |
43
43
 
44
- Use accountless instant loans for new borrow flows unless you need profile-level position management. Use account-based flows when your app owns the full lending dashboard experience.
44
+ Use accountless Simple Loans for new borrow flows unless you need profile-level position management. Use account-based flows when your app owns the full lending dashboard experience.
45
45
 
46
46
  ## Quick Start
47
47
 
@@ -51,7 +51,7 @@ Install the client package:
51
51
  npm install @liquidium/client
52
52
  ```
53
53
 
54
- Create an instant loan, display the deposit target, and restore the loan by reference:
54
+ Create a simple loan, display the deposit target, and restore the loan by reference:
55
55
 
56
56
  ```ts
57
57
  import {
@@ -90,7 +90,7 @@ if (ltv.validationErrors.length > 0) {
90
90
  throw new Error(ltv.validationErrors.map((error) => error.message).join(" "));
91
91
  }
92
92
 
93
- const loan = await client.instantLoans.create({
93
+ const loan = await client.simpleLoans.create({
94
94
  collateral: {
95
95
  poolId: collateralPool.id,
96
96
  asset: Asset.BTC,
@@ -120,7 +120,7 @@ console.log("Save this loan reference:", loan.ref);
120
120
  console.log("Send initial deposit amount:", initialDeposit.amount.toString());
121
121
  console.log("Send collateral to:", formatSupplyTarget(initialDeposit.target));
122
122
 
123
- const restoredLoan = await client.instantLoans.get({ ref: loan.ref });
123
+ const restoredLoan = await client.simpleLoans.get({ ref: loan.ref });
124
124
  const repayment = restoredLoan.repayment.targets[Chain.ETH];
125
125
 
126
126
  console.log("Loan status:", restoredLoan.status);
@@ -134,7 +134,7 @@ const activities = await client.activities.list({ shortRef: loan.ref });
134
134
 
135
135
  console.log("Loan activities:", activities);
136
136
 
137
- const foundLoans = await client.instantLoans.find(loan.ref);
137
+ const foundLoans = await client.simpleLoans.find(loan.ref);
138
138
 
139
139
  console.log("Found loan reference:", foundLoans[0]?.ref);
140
140
  console.log("Found loan collateral:", foundLoans[0]?.collateral.amount.toString());
@@ -164,19 +164,19 @@ function formatSupplyTarget(target: SupplyTarget): string {
164
164
  }
165
165
  ```
166
166
 
167
- ## Instant Loan Flow
167
+ ## Simple Loans Flow
168
168
 
169
- Instant-loan integrations use this sequence:
169
+ Simple Loans integrations use this sequence:
170
170
 
171
171
  | Step | SDK call | What your app does |
172
172
  | --- | --- | --- |
173
173
  | Load market data | `client.market.listPools()` and `client.market.getAssetPrices()` | Show supported collateral and borrow assets |
174
174
  | Validate amounts | `client.quote.calculateLtv(...)` | Block too-small borrow amounts, invalid LTV, or frozen-pool input before creating a loan |
175
- | Create loan | `client.instantLoans.create(...)` | Store `loan.ref` and show the quote in `loan.initialDeposit.targets[chain]` |
176
- | Track loan | `client.instantLoans.get({ ref })`, `client.instantLoans.find(...)`, and `client.activities.list({ shortRef: ref })` | Reload loan state, initial deposit quote, and repayment activity |
175
+ | Create loan | `client.simpleLoans.create(...)` | Store `loan.ref` and show the quote in `loan.initialDeposit.targets[chain]` |
176
+ | Track loan | `client.simpleLoans.get({ ref })`, `client.simpleLoans.find(...)`, and `client.activities.list({ shortRef: ref })` | Reload loan state, initial deposit quote, and repayment activity |
177
177
  | Repay loan | Read `loan.repayment.targets[chain]` | Ask the user to send the quote amount to its target; no quote means no repayment is due on that chain |
178
178
 
179
- `client.instantLoans.create(...)` and `client.instantLoans.get(...)` return the generated Liquidium profile, current position state, and transfer quotes keyed by the chain the user will send on. Users do not manage the generated profile.
179
+ `client.simpleLoans.create(...)` and `client.simpleLoans.get(...)` return the generated Liquidium profile, current position state, and transfer quotes keyed by the chain the user will send on. Users do not manage the generated profile.
180
180
 
181
181
  `client.market.listPools()` returns only pools whose asset and chain variants are supported by this SDK version. BTC, USDC, USDT, and ICP lending pools are returned. Future unsupported variants such as `SOL` are omitted from the returned list.
182
182
 
@@ -184,9 +184,9 @@ Instant-loan integrations use this sequence:
184
184
 
185
185
  ## Core API
186
186
 
187
- ### `client.instantLoans.create(request)`
187
+ ### `client.simpleLoans.create(request)`
188
188
 
189
- Creates an accountless instant loan and returns generated transfer targets.
189
+ Creates an accountless simple loan and returns generated transfer targets.
190
190
 
191
191
  | Field | Description |
192
192
  | --- | --- |
@@ -209,30 +209,30 @@ Destination validation is chain-specific and runs before loan creation:
209
209
 
210
210
  The SDK rejects mismatched L1-vs-IC destination families, such as an ETH address for a ck-ledger delivery or a BTC/EVM address for an ICP destination.
211
211
 
212
- If creation succeeds remotely but response hydration fails, the SDK throws `InstantLoanCreatedError`. The error includes `loanId` and `ref`; recover with `instantLoans.get(...)` and do not submit `create(...)` again.
212
+ If creation succeeds remotely but response hydration fails, the SDK throws `SimpleLoanCreatedError`. The error includes `loanId` and `ref`; recover with `simpleLoans.get(...)` and do not submit `create(...)` again.
213
213
 
214
- ### `client.instantLoans.get({ ref })`
214
+ ### `client.simpleLoans.get({ ref })`
215
215
 
216
216
  Loads loan state from a saved user-facing reference.
217
217
 
218
218
  Use this for status pages, refreshes, and support links. The SDK combines canister state with the Liquidium SDK API lookup so the restored loan includes the original collateral deposit hint.
219
219
 
220
- ### `client.instantLoans.get({ loanId })`
220
+ ### `client.simpleLoans.get({ loanId })`
221
221
 
222
222
  Loads loan state by numeric canister loan id.
223
223
 
224
224
  Use this when your backend stores the numeric id instead of the short reference.
225
225
 
226
- ### `client.instantLoans.find(query)`
226
+ ### `client.simpleLoans.find(query)`
227
227
 
228
- Finds instant loans by short reference, numeric canister loan id string, generated deposit or repayment address, borrow or refund destination address, or indexed transaction id/hash through the SDK API search index.
228
+ Finds simple loans by short reference, numeric canister loan id string, generated deposit or repayment address, borrow or refund destination address, or indexed transaction id/hash through the SDK API search index.
229
229
 
230
- Use this for recovery and manage pages where the user may paste any loan identifier. The method returns lightweight matches because address and transaction-id lookups can match many loans. Use `client.instantLoans.get(...)` after the user selects a match.
230
+ Use this for recovery and manage pages where the user may paste any loan identifier. The method returns lightweight matches because address and transaction-id lookups can match many loans. Use `client.simpleLoans.get(...)` after the user selects a match.
231
231
 
232
232
  ```ts
233
- const results = await client.instantLoans.find("bc1q...");
234
- const byRef = await client.instantLoans.find("ABC123");
235
- const byLoanId = await client.instantLoans.find("42");
233
+ const results = await client.simpleLoans.find("bc1q...");
234
+ const byRef = await client.simpleLoans.find("ABC123");
235
+ const byLoanId = await client.simpleLoans.find("42");
236
236
 
237
237
  for (const result of results) {
238
238
  console.log(result.ref);
@@ -241,21 +241,21 @@ for (const result of results) {
241
241
  console.log(result.collateral.amount);
242
242
  }
243
243
 
244
- const selectedLoan = await client.instantLoans.get({ loanId: results[0].loanId });
244
+ const selectedLoan = await client.simpleLoans.get({ loanId: results[0].loanId });
245
245
  ```
246
246
 
247
247
  Call `get(...)` when you already have an exact canister identifier and want direct canister lookup without an array:
248
248
 
249
249
  ```ts
250
- const loanById = await client.instantLoans.get({ loanId: 123n });
251
- const loanByRef = await client.instantLoans.get({ ref: "ABC123" });
250
+ const loanById = await client.simpleLoans.get({ loanId: 123n });
251
+ const loanByRef = await client.simpleLoans.get({ ref: "ABC123" });
252
252
  ```
253
253
 
254
254
  ### `client.quote.calculateLtv(request, pools, prices)`
255
255
 
256
256
  Calculates implied LTV from selected pools, prices, borrow amount, and collateral amount.
257
257
 
258
- Use this before `client.instantLoans.create(...)` so your app can block invalid input and choose a safe `ltvMaxBps`.
258
+ Use this before `client.simpleLoans.create(...)` so your app can block invalid input and choose a safe `ltvMaxBps`.
259
259
 
260
260
  ### Borrow minimums
261
261
 
@@ -267,7 +267,11 @@ The SDK enforces product minimums before borrow creation:
267
267
  | USDC | `1_000_000n` base units |
268
268
  | USDT | `1_000_000n` base units |
269
269
 
270
- Use `getMinimumBorrowAmount(asset)` to display the same minimum that `client.quote.calculateLtv(...)`, `client.quote.getQuote(...)`, `client.instantLoans.create(...)`, and `client.lending.prepareBorrow(...)` enforce.
270
+ Use `getMinimumBorrowAmount(asset)` to display the same minimum that `client.quote.calculateLtv(...)`, `client.quote.getQuote(...)`, `client.simpleLoans.create(...)`, and `client.lending.prepareBorrow(...)` enforce.
271
+
272
+ ### Same-asset borrowing
273
+
274
+ Pools expose `sameAssetBorrowing` and `sameAssetBorrowingDustThreshold`. When the flag is disabled, same-asset collateral must be strictly below the base-unit dust threshold; equality is rejected. `client.quote.calculateLtv(...)`, `client.quote.getQuote(...)`, and `client.simpleLoans.create(...)` validate the requested collateral amount, while `client.lending.prepareBorrow(...)` validates the profile's current supplied balance before fetching a nonce or asking the wallet to sign.
271
275
 
272
276
  ### Withdraw minimums
273
277
 
@@ -287,7 +291,7 @@ For profile-based withdraw flows, call `client.positions.getFullWithdrawAmount(p
287
291
 
288
292
  ## Response Fields
289
293
 
290
- Most instant-loan UIs show or store these fields:
294
+ Most Simple Loans UIs show or store these fields:
291
295
 
292
296
  | Field | Use |
293
297
  | --- | --- |
@@ -300,7 +304,7 @@ Most instant-loan UIs show or store these fields:
300
304
  | `loan.repayment.targets[chain]` | Full repayment quote and destination for that transfer chain |
301
305
  | `loan.position` | Current collateral, debt, and interest state for the generated profile |
302
306
 
303
- `client.instantLoans.find(...)` returns lightweight search matches with `loanId`, `ref`, `createdAt`, `profileId`, `collateral`, and `borrow`. Use `client.instantLoans.get(...)` to load full loan fields, and use `client.activities.list(...)` separately when you need deposit, borrow, repayment, or withdrawal activity.
307
+ `client.simpleLoans.find(...)` returns lightweight search matches with `loanId`, `ref`, `createdAt`, `profileId`, `collateral`, and `borrow`. Use `client.simpleLoans.get(...)` to load full loan fields, and use `client.activities.list(...)` separately when you need deposit, borrow, repayment, or withdrawal activity.
304
308
 
305
309
  ## Amounts
306
310
 
@@ -312,11 +316,11 @@ The SDK returns amount fields as `bigint` values in the asset's smallest unit.
312
316
  | ICP | e8s |
313
317
  | USDC / USDT | Token base units using the pool decimals |
314
318
 
315
- Use `Pool.decimals` from `client.market.listPools()` when converting user-entered decimals to base units. Hydrated instant loans also include `loan.collateral.decimals`, `loan.borrow.decimals`, and `loan.initialDeposit.decimals` for display.
319
+ Use `Pool.decimals` from `client.market.listPools()` when converting user-entered decimals to base units. Hydrated simple loans also include `loan.collateral.decimals`, `loan.borrow.decimals`, and `loan.initialDeposit.decimals` for display.
316
320
 
317
321
  ## Status And Activity Tracking
318
322
 
319
- Reload loans with `client.instantLoans.get({ ref })` when you need current state, transfer targets, or the latest repayment quote.
323
+ Reload loans with `client.simpleLoans.get({ ref })` when you need current state, transfer targets, or the latest repayment quote.
320
324
 
321
325
  Status-returning methods use the same `LiquidiumStatus` shape:
322
326
 
@@ -331,7 +335,7 @@ type LiquidiumStatus = {
331
335
 
332
336
  `action_required` means the user or app must do something, such as sending funds. `confirming` means a tx is known but still needs confirmations. `processing` means confirmations are sufficient and Liquidium or the protocol is still processing. `active` means the loan is live and waiting for the next repayment action.
333
337
 
334
- Use activities to track collateral deposits, borrow outflows, repayment deposits, confirmations, and fee top-ups. Activity confirmations are exposed on `activity.status`. Activity lists default to active items; pass `filter: "all"` when you need completed activity too. The activities module accepts the saved instant-loan reference and resolves the generated profile for you:
338
+ Use activities to track collateral deposits, borrow outflows, repayment deposits, confirmations, and fee top-ups. Activity confirmations are exposed on `activity.status`. Activity lists default to active items; pass `filter: "all"` when you need completed activity too. The activities module accepts the saved simple loan reference and resolves the generated profile for you:
335
339
 
336
340
  Activities expose chain transaction ids on `activity.txids` when ids are available.
337
341
 
@@ -357,16 +361,16 @@ Start browser integrations with the examples.
357
361
 
358
362
  | Example | What it shows |
359
363
  | --- | --- |
360
- | [`examples/instant-loans-flow`](https://github.com/Liquidium-Inc/liquidium-sdk/tree/main/examples/instant-loans-flow) | Accountless instant loan UX with manual destination addresses, pool selection, LTV preview, loan creation, status reload, activity status, and loan recovery |
361
- | [`examples/sdk-method-query`](https://github.com/Liquidium-Inc/liquidium-sdk/tree/main/examples/sdk-method-query) | Developer tool for calling SDK methods, including instant loan method templates |
364
+ | [`examples/simple-loans-flow`](https://github.com/Liquidium-Inc/liquidium-sdk/tree/main/examples/simple-loans-flow) | Accountless Simple Loans UX with manual destination addresses, pool selection, LTV preview, loan creation, status reload, activity status, and loan recovery |
365
+ | [`examples/sdk-method-query`](https://github.com/Liquidium-Inc/liquidium-sdk/tree/main/examples/sdk-method-query) | Developer tool for calling SDK methods, including Simple Loans method templates |
362
366
 
363
- Run the instant loan example:
367
+ Run the Simple Loans example:
364
368
 
365
369
  ```bash
366
370
  git clone https://github.com/Liquidium-Inc/liquidium-sdk.git
367
371
  cd liquidium-sdk
368
372
  pnpm install
369
- pnpm --filter @liquidium/example-instant-loans-flow dev
373
+ pnpm --filter @liquidium/example-simple-loans-flow dev
370
374
  ```
371
375
 
372
376
  ## Browser And Runtime Support
@@ -393,7 +397,7 @@ pnpm run test
393
397
 
394
398
  ## More API Details
395
399
 
396
- This README covers `@liquidium/client`. Start new integrations with `client.instantLoans`; profile-based deposit-address flows and ETH contract-interaction flows are advanced paths.
400
+ This README covers `@liquidium/client`. Start new integrations with `client.simpleLoans`; profile-based deposit-address flows and ETH contract-interaction flows are advanced paths.
397
401
 
398
402
  ## License
399
403