@liquidium/client 0.1.1 → 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 +26 -15
- package/dist/index.cjs +273 -99
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +100 -56
- package/dist/index.d.ts +100 -56
- package/dist/index.js +267 -101
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|

|
|
3
3
|
|
|
4
4
|
<p align="center">
|
|
5
|
-
<img src="https://raw.githubusercontent.com/Liquidium-Inc/liquidium-sdk/main/
|
|
5
|
+
<img src="https://raw.githubusercontent.com/Liquidium-Inc/liquidium-sdk/main/sdk.svg" alt="Liquidium SDK illustration" width="700" />
|
|
6
6
|
</p>
|
|
7
7
|
|
|
8
8
|
<h1 align="center">Liquidium SDK</h1>
|
|
@@ -12,11 +12,18 @@
|
|
|
12
12
|
</p>
|
|
13
13
|
|
|
14
14
|
<p align="center">
|
|
15
|
+
<a href="https://liquidium-inc.github.io/liquidium-sdk/"><b>SDK Docs</b></a> ·
|
|
15
16
|
<a href="https://github.com/Liquidium-Inc/liquidium-sdk/tree/main/examples/instant-loans-flow"><b>Instant Loan Example</b></a> ·
|
|
16
17
|
<a href="https://github.com/Liquidium-Inc/liquidium-sdk/tree/main/examples/vite-react-dynamic"><b>SDK Method Query Example</b></a> ·
|
|
17
18
|
<a href="#core-api"><b>Core API</b></a>
|
|
18
19
|
</p>
|
|
19
20
|
|
|
21
|
+
## Documentation
|
|
22
|
+
|
|
23
|
+
Use the SDK docs for setup, guides, API reference, and examples.
|
|
24
|
+
|
|
25
|
+
[Open the Liquidium SDK docs](https://liquidium-inc.github.io/liquidium-sdk/)
|
|
26
|
+
|
|
20
27
|
## Why Start With Instant Loans
|
|
21
28
|
|
|
22
29
|
- **Accountless loan creation**: create instant loans without requiring a Liquidium profile.
|
|
@@ -27,7 +34,7 @@
|
|
|
27
34
|
|
|
28
35
|
## Integration Paths
|
|
29
36
|
|
|
30
|
-
Liquidium supports two lending integration paths:
|
|
37
|
+
Liquidium supports two borrowing and lending integration paths:
|
|
31
38
|
|
|
32
39
|
| Path | Use when | Main SDK calls |
|
|
33
40
|
| --- | --- | --- |
|
|
@@ -97,11 +104,13 @@ const loan = await client.instantLoans.create({
|
|
|
97
104
|
});
|
|
98
105
|
|
|
99
106
|
console.log("Save this loan reference:", loan.ref);
|
|
100
|
-
console.log("Send
|
|
107
|
+
console.log("Send initial deposit amount:", loan.initialDeposit.amount.toString());
|
|
108
|
+
console.log("Send collateral to:", formatSupplyTarget(loan.initialDeposit.target));
|
|
101
109
|
|
|
102
110
|
const restoredLoan = await client.instantLoans.get({ ref: loan.ref });
|
|
103
111
|
|
|
104
112
|
console.log("Loan status:", restoredLoan.status);
|
|
113
|
+
console.log("Restored initial deposit amount:", restoredLoan.initialDeposit.amount.toString());
|
|
105
114
|
console.log("Repay amount:", restoredLoan.repayment.amount.toString());
|
|
106
115
|
console.log("Repay target:", formatSupplyTarget(restoredLoan.repayment.target));
|
|
107
116
|
|
|
@@ -140,11 +149,11 @@ Instant-loan integrations use this sequence:
|
|
|
140
149
|
| --- | --- | --- |
|
|
141
150
|
| Load market data | `client.market.listPools()` and `client.market.getAssetPrices()` | Show supported collateral and borrow assets |
|
|
142
151
|
| Validate amounts | `client.quote.calculateLtv(...)` | Block invalid LTV or frozen-pool input before creating a loan |
|
|
143
|
-
| Create loan | `client.instantLoans.create(...)` | Store `loan.ref` and show `loan.
|
|
144
|
-
| Track loan | `client.instantLoans.get({ ref })` and `client.activities.list({ shortRef: ref })` | Reload loan state
|
|
145
|
-
| 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 |
|
|
146
155
|
|
|
147
|
-
`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.
|
|
148
157
|
|
|
149
158
|
## Core API
|
|
150
159
|
|
|
@@ -158,7 +167,7 @@ Creates an accountless instant loan and returns generated transfer targets.
|
|
|
158
167
|
| `borrowPoolId` | Pool the loan borrows from |
|
|
159
168
|
| `collateralAsset` | Collateral asset symbol, for example `"BTC"` |
|
|
160
169
|
| `borrowAsset` | Borrow asset symbol, for example `"USDC"` |
|
|
161
|
-
| `collateralAmount` |
|
|
170
|
+
| `collateralAmount` | Intended credited collateral amount in base units, before deposit/inflow fees |
|
|
162
171
|
| `borrowAmount` | Borrow amount in base units |
|
|
163
172
|
| `ltvMaxBps` | Maximum LTV in basis points, where `6_000n` is 60% |
|
|
164
173
|
| `depositWindowSeconds` | How long the user has to send collateral |
|
|
@@ -171,7 +180,7 @@ Creates an accountless instant loan and returns generated transfer targets.
|
|
|
171
180
|
|
|
172
181
|
Loads loan state from a saved user-facing reference.
|
|
173
182
|
|
|
174
|
-
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.
|
|
175
184
|
|
|
176
185
|
### `client.instantLoans.get({ loanId })`
|
|
177
186
|
|
|
@@ -198,9 +207,11 @@ Most instant-loan UIs show or store these fields:
|
|
|
198
207
|
| Field | Use |
|
|
199
208
|
| --- | --- |
|
|
200
209
|
| `loan.ref` | Save and show this reference so the loan can be restored later |
|
|
201
|
-
| `loan.status` | Show the lifecycle: `awaiting_deposit`, `deposit_detected`, `active`, `settling`, or `
|
|
202
|
-
| `loan.
|
|
203
|
-
| `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 |
|
|
204
215
|
| `loan.repayment.target` | Address or ICRC account where the user sends repayment |
|
|
205
216
|
| `loan.position` | Current collateral, debt, and interest state for the generated profile |
|
|
206
217
|
|
|
@@ -213,7 +224,7 @@ The SDK returns amount fields as `bigint` values in the asset's smallest unit.
|
|
|
213
224
|
| BTC | Satoshis |
|
|
214
225
|
| USDC / USDT | Token base units using the pool decimals |
|
|
215
226
|
|
|
216
|
-
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.
|
|
217
228
|
|
|
218
229
|
## Status And Activity Tracking
|
|
219
230
|
|
|
@@ -243,7 +254,7 @@ Start browser integrations with the examples.
|
|
|
243
254
|
|
|
244
255
|
| Example | What it shows |
|
|
245
256
|
| --- | --- |
|
|
246
|
-
| [`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 |
|
|
247
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 |
|
|
248
259
|
|
|
249
260
|
Run the instant loan example:
|
|
@@ -267,7 +278,7 @@ Use the SDK in browser apps and modern TypeScript runtimes.
|
|
|
267
278
|
| Node.js | 20+ for this repository |
|
|
268
279
|
| Package manager | pnpm 9+ for local development |
|
|
269
280
|
| Browser APIs | `fetch`, `BigInt`, and standard ESM support |
|
|
270
|
-
| Wallet UI | Bring your own wallet provider;
|
|
281
|
+
| Wallet UI | Bring your own wallet provider; wallet-backed examples use Dynamic |
|
|
271
282
|
|
|
272
283
|
## Development
|
|
273
284
|
|