@instadapp/fluid-sui-read-sdk 0.0.0-stage → 0.1.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 +56 -2
- package/dist/chunk-15K8U1wQ.mjs +18 -0
- package/dist/index.d.mts +1921 -0
- package/dist/index.mjs +3171 -0
- package/package.json +30 -4
package/README.md
CHANGED
|
@@ -1,3 +1,57 @@
|
|
|
1
|
-
#
|
|
1
|
+
# fluid-sui-read-sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Read-only TypeScript SDK for Fluid on Sui. Same shape as the Solana reader `@jup-ag/lend-read`: `client.liquidity`, `client.lending`, `client.vault`, `client.oracle`. Built on `@mysten/sui` v2.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm i @instadapp/fluid-sui-read-sdk @mysten/sui
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { Client } from "@instadapp/fluid-sui-read-sdk";
|
|
11
|
+
|
|
12
|
+
const client = new Client(); // staging deployment on Sui mainnet, pure on-chain state
|
|
13
|
+
console.log(await client.vault.getTotalVaults());
|
|
14
|
+
const vault = await client.vault.getVaultEntireData(1);
|
|
15
|
+
const fUsdc = await client.lending.getFTokenDetails(
|
|
16
|
+
"0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",
|
|
17
|
+
);
|
|
18
|
+
const price = await client.oracle.getOraclePrice(1); // { operate, liquidate, source: "v2" }
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Endpoint failover: `new Client(["https://fullnode.mainnet.sui.io:443", "jsonrpc+https://my-node.example:9000"])`.
|
|
22
|
+
|
|
23
|
+
## Positions per wallet
|
|
24
|
+
|
|
25
|
+
The default client can't enumerate a wallet's positions (`getAllUserPositions` throws `NeedsDiscoveryError`). Enable fullnode discovery:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
const client = new Client(undefined, { discovery: "fullnode" });
|
|
29
|
+
const mine = await client.vault.getAllUserPositions("0x<wallet>");
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Discovery levels: `"state"` (default, pure object reads + view simulation), `"fullnode"` (adds fullnode indexes), `"indexer"` (adds GraphQL event scans, last resort). A read that needs more throws `NeedsDiscoveryError`; it never silently falls back.
|
|
33
|
+
|
|
34
|
+
## Units
|
|
35
|
+
|
|
36
|
+
- Vault-side amounts: the vault's internal 1e9 space. Liquidity-side: token units. `Vault.unscale(x, decimals)` converts.
|
|
37
|
+
- Oracle rates: debt-per-collateral × 1e15.
|
|
38
|
+
|
|
39
|
+
## Config
|
|
40
|
+
|
|
41
|
+
**The built-in ids are the STAGING deployment on Sui mainnet, not production** and will change at launch. `"mainnet"` / `MAINNET` are deprecated aliases of it.
|
|
42
|
+
|
|
43
|
+
To use your own deployment, pass a config built from a deployment record (`packages.{library,liquidity,lending,oracle,vaults}.packageId`, plus `objects.registry` for all but `library`):
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import { Client, configFromDeployment, STAGING } from "@instadapp/fluid-sui-read-sdk";
|
|
47
|
+
|
|
48
|
+
const cfg = configFromDeployment(rec, { network: "mainnet", oracleV2: STAGING.oracleV2 });
|
|
49
|
+
const client = new Client(undefined, { network: cfg });
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Tests
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
npm test # offline
|
|
56
|
+
npm run test:live # mainnet, read-only
|
|
57
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) {
|
|
6
|
+
__defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
if (symbols) {
|
|
12
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { __exportAll as t };
|