@liquidium/client 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -13
- package/dist/index.cjs +264 -98
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +85 -41
- package/dist/index.d.ts +85 -41
- package/dist/index.js +265 -99
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -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
|
|
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
|
|
|
@@ -147,11 +149,11 @@ Instant-loan integrations use this sequence:
|
|
|
147
149
|
| --- | --- | --- |
|
|
148
150
|
| Load market data | `client.market.listPools()` and `client.market.getAssetPrices()` | Show supported collateral and borrow assets |
|
|
149
151
|
| 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.
|
|
151
|
-
| Track loan | `client.instantLoans.get({ ref })` and `client.activities.list({ shortRef: ref })` | Reload loan state
|
|
152
|
-
| Repay loan | Read `loan.repayment` | Ask the user to send `loan.repayment.amount` to `loan.repayment.target` |
|
|
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(...)`
|
|
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,7 +167,7 @@ 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` |
|
|
170
|
+
| `collateralAmount` | Intended credited collateral amount in base units, before deposit/inflow fees |
|
|
169
171
|
| `borrowAmount` | Borrow amount in base units |
|
|
170
172
|
| `ltvMaxBps` | Maximum LTV in basis points, where `6_000n` is 60% |
|
|
171
173
|
| `depositWindowSeconds` | How long the user has to send collateral |
|
|
@@ -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
|
|
|
@@ -205,9 +207,11 @@ Most instant-loan UIs show or store these fields:
|
|
|
205
207
|
| Field | Use |
|
|
206
208
|
| --- | --- |
|
|
207
209
|
| `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 `
|
|
209
|
-
| `loan.
|
|
210
|
-
| `loan.
|
|
210
|
+
| `loan.status` | Show the lifecycle: `awaiting_deposit`, `deposit_detected`, `active`, `settling`, `closed`, or `expired` |
|
|
211
|
+
| `loan.initialDeposit.amount` | Fee-inclusive collateral amount to send after creation or restore |
|
|
212
|
+
| `loan.initialDeposit.collateralAmount` | Intended credited collateral target used for LTV |
|
|
213
|
+
| `loan.initialDeposit.target` | Address or ICRC account where the user sends collateral |
|
|
214
|
+
| `loan.repayment.amount` | Full amount to repay, including fee and interest buffer. Zero when no repayment is due |
|
|
211
215
|
| `loan.repayment.target` | Address or ICRC account where the user sends repayment |
|
|
212
216
|
| `loan.position` | Current collateral, debt, and interest state for the generated profile |
|
|
213
217
|
|
|
@@ -220,7 +224,7 @@ The SDK returns amount fields as `bigint` values in the asset's smallest unit.
|
|
|
220
224
|
| BTC | Satoshis |
|
|
221
225
|
| USDC / USDT | Token base units using the pool decimals |
|
|
222
226
|
|
|
223
|
-
Use `Pool.decimals` from `client.market.listPools()` when converting user-entered decimals to base units.
|
|
227
|
+
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
228
|
|
|
225
229
|
## Status And Activity Tracking
|
|
226
230
|
|
|
@@ -250,7 +254,7 @@ Start browser integrations with the examples.
|
|
|
250
254
|
|
|
251
255
|
| Example | What it shows |
|
|
252
256
|
| --- | --- |
|
|
253
|
-
| [`examples/instant-loans-flow`](https://github.com/Liquidium-Inc/liquidium-sdk/tree/main/examples/instant-loans-flow) |
|
|
257
|
+
| [`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 |
|
|
254
258
|
| [`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 |
|
|
255
259
|
|
|
256
260
|
Run the instant loan example:
|
|
@@ -274,7 +278,7 @@ Use the SDK in browser apps and modern TypeScript runtimes.
|
|
|
274
278
|
| Node.js | 20+ for this repository |
|
|
275
279
|
| Package manager | pnpm 9+ for local development |
|
|
276
280
|
| Browser APIs | `fetch`, `BigInt`, and standard ESM support |
|
|
277
|
-
| Wallet UI | Bring your own wallet provider;
|
|
281
|
+
| Wallet UI | Bring your own wallet provider; wallet-backed examples use Dynamic |
|
|
278
282
|
|
|
279
283
|
## Development
|
|
280
284
|
|