@liquidium/client 0.1.2 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,7 +14,7 @@
14
14
  <p align="center">
15
15
  <a href="https://liquidium-inc.github.io/liquidium-sdk/"><b>SDK Docs</b></a> ·
16
16
  <a href="https://github.com/Liquidium-Inc/liquidium-sdk/tree/main/examples/instant-loans-flow"><b>Instant Loan Example</b></a> ·
17
- <a href="https://github.com/Liquidium-Inc/liquidium-sdk/tree/main/examples/vite-react-dynamic"><b>SDK Method Query Example</b></a> ·
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>
20
20
 
@@ -104,11 +104,13 @@ const loan = await client.instantLoans.create({
104
104
  });
105
105
 
106
106
  console.log("Save this loan reference:", loan.ref);
107
- console.log("Send collateral to:", formatSupplyTarget(loan.depositTarget));
107
+ console.log("Send initial deposit amount:", loan.initialDeposit.amount.toString());
108
+ console.log("Send collateral to:", formatSupplyTarget(loan.initialDeposit.target));
108
109
 
109
110
  const restoredLoan = await client.instantLoans.get({ ref: loan.ref });
110
111
 
111
112
  console.log("Loan status:", restoredLoan.status);
113
+ console.log("Restored initial deposit amount:", restoredLoan.initialDeposit.amount.toString());
112
114
  console.log("Repay amount:", restoredLoan.repayment.amount.toString());
113
115
  console.log("Repay target:", formatSupplyTarget(restoredLoan.repayment.target));
114
116
 
@@ -146,12 +148,12 @@ Instant-loan integrations use this sequence:
146
148
  | Step | SDK call | What your app does |
147
149
  | --- | --- | --- |
148
150
  | Load market data | `client.market.listPools()` and `client.market.getAssetPrices()` | Show supported collateral and borrow assets |
149
- | Validate amounts | `client.quote.calculateLtv(...)` | Block invalid LTV or frozen-pool input before creating a loan |
150
- | Create loan | `client.instantLoans.create(...)` | Store `loan.ref` and show `loan.depositTarget` |
151
- | Track loan | `client.instantLoans.get({ ref })` and `client.activities.list({ shortRef: ref })` | Reload loan state and monitor deposit, borrow, and repayment activity |
152
- | Repay loan | Read `loan.repayment` | Ask the user to send `loan.repayment.amount` to `loan.repayment.target` |
151
+ | Validate amounts | `client.quote.calculateLtv(...)` | Block too-small borrow amounts, invalid LTV, or frozen-pool input before creating a loan |
152
+ | Create loan | `client.instantLoans.create(...)` | Store `loan.ref` and show `loan.initialDeposit.amount` plus `loan.initialDeposit.target` |
153
+ | Track loan | `client.instantLoans.get({ ref })` and `client.activities.list({ shortRef: ref })` | Reload loan state, initial deposit quote, and repayment activity |
154
+ | Repay loan | Read `loan.repayment` | Ask the user to send `loan.repayment.amount` to `loan.repayment.target`; amount is `0n` when no repayment is due |
153
155
 
154
- `client.instantLoans.create(...)` returns the generated Liquidium profile, transfer targets, current position state, and repayment quote. Users do not manage the generated profile.
156
+ `client.instantLoans.create(...)` and `client.instantLoans.get(...)` return the generated Liquidium profile, current position state, an initial deposit quote with its transfer target, and a repayment quote with its transfer target. Repayment amount fields are zero when the loan has no debt. Users do not manage the generated profile.
155
157
 
156
158
  ## Core API
157
159
 
@@ -165,8 +167,8 @@ Creates an accountless instant loan and returns generated transfer targets.
165
167
  | `borrowPoolId` | Pool the loan borrows from |
166
168
  | `collateralAsset` | Collateral asset symbol, for example `"BTC"` |
167
169
  | `borrowAsset` | Borrow asset symbol, for example `"USDC"` |
168
- | `collateralAmount` | Collateral amount in base units |
169
- | `borrowAmount` | Borrow amount in base units |
170
+ | `collateralAmount` | Intended credited collateral amount in base units, before deposit/inflow fees |
171
+ | `borrowAmount` | Borrow amount in base units. The SDK rejects values below the asset minimum. |
170
172
  | `ltvMaxBps` | Maximum LTV in basis points, where `6_000n` is 60% |
171
173
  | `depositWindowSeconds` | How long the user has to send collateral |
172
174
  | `borrowDestination` | External address that receives borrowed funds |
@@ -178,7 +180,7 @@ Creates an accountless instant loan and returns generated transfer targets.
178
180
 
179
181
  Loads loan state from a saved user-facing reference.
180
182
 
181
- Use this for status pages, refreshes, and support links.
183
+ 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.
182
184
 
183
185
  ### `client.instantLoans.get({ loanId })`
184
186
 
@@ -198,6 +200,18 @@ Calculates implied LTV from selected pools, prices, borrow amount, and collatera
198
200
 
199
201
  Use this before `client.instantLoans.create(...)` so your app can block invalid input and choose a safe `ltvMaxBps`.
200
202
 
203
+ ### Borrow minimums
204
+
205
+ The SDK enforces product minimums before borrow creation:
206
+
207
+ | Asset | Minimum borrow amount |
208
+ | --- | --- |
209
+ | BTC | `5_100n` sats |
210
+ | USDC | `1_000_000n` base units |
211
+ | USDT | `1_000_000n` base units |
212
+
213
+ Use `getMinimumBorrowAmount(asset)` to display the same minimum that `client.quote.calculateLtv(...)`, `client.quote.getQuote(...)`, `client.instantLoans.create(...)`, and `client.lending.prepareBorrow(...)` enforce.
214
+
201
215
  ## Response Fields
202
216
 
203
217
  Most instant-loan UIs show or store these fields:
@@ -205,9 +219,11 @@ Most instant-loan UIs show or store these fields:
205
219
  | Field | Use |
206
220
  | --- | --- |
207
221
  | `loan.ref` | Save and show this reference so the loan can be restored later |
208
- | `loan.status` | Show the lifecycle: `awaiting_deposit`, `deposit_detected`, `active`, `settling`, or `closed` |
209
- | `loan.depositTarget` | Address or ICRC account where the user sends collateral |
210
- | `loan.repayment.amount` | Full amount to repay, including fee and interest buffer |
222
+ | `loan.status` | Show the lifecycle: `awaiting_deposit`, `deposit_detected`, `active`, `settling`, `closed`, or `expired` |
223
+ | `loan.initialDeposit.amount` | Fee-inclusive collateral amount to send after creation or restore |
224
+ | `loan.initialDeposit.collateralAmount` | Intended credited collateral target used for LTV |
225
+ | `loan.initialDeposit.target` | Address or ICRC account where the user sends collateral |
226
+ | `loan.repayment.amount` | Full amount to repay, including fee and interest buffer. Zero when no repayment is due |
211
227
  | `loan.repayment.target` | Address or ICRC account where the user sends repayment |
212
228
  | `loan.position` | Current collateral, debt, and interest state for the generated profile |
213
229
 
@@ -220,7 +236,7 @@ The SDK returns amount fields as `bigint` values in the asset's smallest unit.
220
236
  | BTC | Satoshis |
221
237
  | USDC / USDT | Token base units using the pool decimals |
222
238
 
223
- Use `Pool.decimals` from `client.market.listPools()` when converting user-entered decimals to base units.
239
+ 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.
224
240
 
225
241
  ## Status And Activity Tracking
226
242
 
@@ -250,8 +266,8 @@ Start browser integrations with the examples.
250
266
 
251
267
  | Example | What it shows |
252
268
  | --- | --- |
253
- | [`examples/instant-loans-flow`](https://github.com/Liquidium-Inc/liquidium-sdk/tree/main/examples/instant-loans-flow) | Instant loan UX with Dynamic wallet connection, pool selection, LTV preview, loan creation, status reload, activity status, and address recovery |
254
- | [`examples/vite-react-dynamic`](https://github.com/Liquidium-Inc/liquidium-sdk/tree/main/examples/vite-react-dynamic) | Developer tool for calling SDK methods, including instant loan method templates |
269
+ | [`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 address recovery |
270
+ | [`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 |
255
271
 
256
272
  Run the instant loan example:
257
273
 
@@ -274,7 +290,7 @@ Use the SDK in browser apps and modern TypeScript runtimes.
274
290
  | Node.js | 20+ for this repository |
275
291
  | Package manager | pnpm 9+ for local development |
276
292
  | Browser APIs | `fetch`, `BigInt`, and standard ESM support |
277
- | Wallet UI | Bring your own wallet provider; the example apps use Dynamic |
293
+ | Wallet UI | Bring your own wallet provider; wallet-backed examples use Dynamic |
278
294
 
279
295
  ## Development
280
296