@instadapp/fluid-sui-read-sdk 0.2.0 → 0.3.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 +6 -5
- package/dist/index.d.mts +10 -7
- package/dist/index.mjs +47 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -162,18 +162,19 @@ npm run example # prints every resolver against mainnet
|
|
|
162
162
|
|
|
163
163
|
## Config
|
|
164
164
|
|
|
165
|
-
|
|
165
|
+
**There is no default network**: every client passes `network` explicitly.
|
|
166
166
|
|
|
167
|
-
|
|
167
|
+
- `network: "mainnet"` = `PROD` (alias `MAINNET`): the production deployment (2026-11-02), same ids as the write SDK and fluid-packages-sui `deployments/mainnet.json`. Day one: fUSDC and vault 1 = `VaultMarket<hBTC, USDC>` `0x1aa7…a624` on oracle nonce 1 `0x6f74…3784` (RedStone BTC main + Pyth BTC/USD guard).
|
|
168
|
+
- `network: "staging"` = `STAGING`: the staging-on-mainnet deployment (staging gist, 2026-09-30): library / liquidity / lending from 2026-09-18, oracle `0xc1e7…4814` and vaults `0x08a3…6f20` from 2026-09-30. Vaults 1 SUI/USDC + 2 SUI/USDSUI, fUSDC + fUSDSUI. `npx tsx scripts/smoke-staging.ts` checks it with zero config.
|
|
168
169
|
|
|
169
|
-
`
|
|
170
|
+
`oracle` holds the RedStone adapter and the Pyth `PriceInfoObject` per feed id.
|
|
170
171
|
|
|
171
172
|
- **Don't depend on the built-in ids:** build the config from a deployment record (fluid-packages-sui `deployments/<network>.json`, the write SDK's source) and pass it in:
|
|
172
173
|
```ts
|
|
173
174
|
import { readFileSync } from "node:fs";
|
|
174
|
-
import { Client, configFromDeployment,
|
|
175
|
+
import { Client, configFromDeployment, PROD } from "@instadapp/fluid-sui-read-sdk";
|
|
175
176
|
const rec = JSON.parse(readFileSync("deployments/mainnet.json", "utf8"));
|
|
176
|
-
const cfg = configFromDeployment(rec, { network: "mainnet", oracle:
|
|
177
|
+
const cfg = configFromDeployment(rec, { network: "mainnet", oracle: PROD.oracle });
|
|
177
178
|
const client = new Client(undefined, { network: cfg });
|
|
178
179
|
```
|
|
179
180
|
The record has no RedStone package or Pyth feed map, so `oracle` is passed in.
|
package/dist/index.d.mts
CHANGED
|
@@ -704,9 +704,12 @@ type FluidReadConfig = {
|
|
|
704
704
|
*/
|
|
705
705
|
declare const STAGING: FluidReadConfig;
|
|
706
706
|
/**
|
|
707
|
-
*
|
|
708
|
-
*
|
|
707
|
+
* PRODUCTION deployment on Sui mainnet (2026-11-02), same ids as fluid-packages-sui
|
|
708
|
+
* deployments/mainnet.json + mainnet-markets.json and the write SDK. Day one: fUSDC and
|
|
709
|
+
* vault 1 = VaultMarket<hBTC, USDC> 0x1aa7…a624 on oracle nonce 1 0x6f74…3784 (RedStone BTC
|
|
710
|
+
* main + Pyth BTC/USD guard). Audited maths. Network "mainnet".
|
|
709
711
|
*/
|
|
712
|
+
declare const PROD: FluidReadConfig;
|
|
710
713
|
declare const MAINNET: FluidReadConfig;
|
|
711
714
|
declare const CONFIGS: Record<string, FluidReadConfig>;
|
|
712
715
|
/**
|
|
@@ -1945,8 +1948,8 @@ declare class Vault {
|
|
|
1945
1948
|
declare const DEFAULT_RPC_URL = "https://fullnode.mainnet.sui.io:443";
|
|
1946
1949
|
type ClientOptions = {
|
|
1947
1950
|
/**
|
|
1948
|
-
* REQUIRED. Built-in network name ("staging") or a
|
|
1949
|
-
* full config (e.g.
|
|
1951
|
+
* REQUIRED. Built-in network name ("mainnet" = production, "staging") or a
|
|
1952
|
+
* full config (e.g. from `configFromDeployment`). No default, so nobody reads
|
|
1950
1953
|
* staging believing it is production.
|
|
1951
1954
|
*/
|
|
1952
1955
|
network: string | FluidReadConfig;
|
|
@@ -1968,8 +1971,8 @@ type ClientOptions = {
|
|
|
1968
1971
|
* `client.liquidity`, `client.lending`, `client.vault` (+ `client.oracle`, Sui-only).
|
|
1969
1972
|
*
|
|
1970
1973
|
* @example
|
|
1971
|
-
* const client = new Client(undefined, { network: "
|
|
1972
|
-
* const client = new Client("https://my-fullnode:443", { network:
|
|
1974
|
+
* const client = new Client(undefined, { network: "mainnet" }); // production deployment, Sui mainnet gRPC
|
|
1975
|
+
* const client = new Client("https://my-fullnode:443", { network: customConfig });
|
|
1973
1976
|
* const client = new Client(existingSuiGrpcClient, { network: "staging" });
|
|
1974
1977
|
* const vault = await client.vault.getVaultEntireData(1);
|
|
1975
1978
|
*/
|
|
@@ -2149,4 +2152,4 @@ declare function mulBigNumber(a: bigint, b: bigint): bigint;
|
|
|
2149
2152
|
/** `big_number::mul_div_normal`: normal * bn1 / bn2. */
|
|
2150
2153
|
declare function mulDivNormal(normal: bigint, bn1: bigint, bn2: bigint): bigint;
|
|
2151
2154
|
//#endregion
|
|
2152
|
-
export { AllEndpointsFailedError, CONFIGS, CheckpointReadError, Client, type ClientOptions, Configs, ConstantViews, CurrentBranchState, DEFAULT_RPC_URL, DecodedBranch, DecodedTick, DecodedTickIdLiquidation, type DeploymentRecord, type DiscoveryLevel, EXCHANGE_PRICES_PRECISION, EXCHANGE_PRICE_SCALE_FACTOR, ExchangePriceResult, ExchangePricesAndConfig, ExchangePricesAndRates, FOUR_DECIMALS, FTokenDetails, FTokenDetailsUserPosition, FTokenHolder, FTokenHolders, FTokenInternalData, type FailoverOptions, type FluidDerive, type FluidReadConfig, GraphQLError, type GraphQLOptions, JlTokenDetails, JlTokenDetailsUserPosition, JlTokenInternalData, Lending, LendingAccount, type LendingRecord, LendingStateData, LendingUserPosition, LimitsAndAvailability, Liquidity, LiquidityAccount, MAINNET, MAX_REWARDS_RATE, NeedsDiscoveryError, NftPosition, ORACLE_LIMITS, ORACLE_RATE_PRECISION, ObjectNotFoundError, Oracle, OracleData, OraclePrice, OracleRoute, OracleSource, OverallTokenData, POSITION_INDEX_FIX, type PackageIds, type PositionCounts, PositionIndex, type PositionIndexOptions, type PositionSource, PositionWithRiskRatio, PreviewData, RATE_OUTPUT_DECIMALS, RETURN_PERCENT_PRECISION, RateData, RateDataV1, RateDataV2, RateModelAccount, type ReadContext, type ReserveRecord, RewardsRateModelConfig, SECONDS_PER_YEAR, STAGING, SUPPLY_RATE_PRECISION, TotalAmounts, TotalSupplyAndBorrow, UserBorrowData, UserBorrowPositionAccount, UserPosition, UserPositionWithDebt, UserSupplyData, UserSupplyPositionAccount, Vault, VaultConfig, VaultEntireData, VaultEntireDataV2, type VaultReadOpts, type VaultRecord, VaultState, ViewCallError, backoffDelay, bcs_d_exports as bcsTypes, checkpointClient, checkpointTimestampSeconds, clientForEndpoint, configFromDeployment, createDerive, createFailoverClient, divCeil, fluidRead, graphqlQuery, latestCheckpoint, lending_d_exports as lendingMath, liquidity_d_exports as liquidityMath, max, min, mulDiv, mulDivCeil, nowSeconds, resolveConfig, rewardsRateToBps, scaleAndInvert, simulateView, supplyRateToBps, tick_d_exports as tickMath, vault_d_exports as vaultMath };
|
|
2155
|
+
export { AllEndpointsFailedError, CONFIGS, CheckpointReadError, Client, type ClientOptions, Configs, ConstantViews, CurrentBranchState, DEFAULT_RPC_URL, DecodedBranch, DecodedTick, DecodedTickIdLiquidation, type DeploymentRecord, type DiscoveryLevel, EXCHANGE_PRICES_PRECISION, EXCHANGE_PRICE_SCALE_FACTOR, ExchangePriceResult, ExchangePricesAndConfig, ExchangePricesAndRates, FOUR_DECIMALS, FTokenDetails, FTokenDetailsUserPosition, FTokenHolder, FTokenHolders, FTokenInternalData, type FailoverOptions, type FluidDerive, type FluidReadConfig, GraphQLError, type GraphQLOptions, JlTokenDetails, JlTokenDetailsUserPosition, JlTokenInternalData, Lending, LendingAccount, type LendingRecord, LendingStateData, LendingUserPosition, LimitsAndAvailability, Liquidity, LiquidityAccount, MAINNET, MAX_REWARDS_RATE, NeedsDiscoveryError, NftPosition, ORACLE_LIMITS, ORACLE_RATE_PRECISION, ObjectNotFoundError, Oracle, OracleData, OraclePrice, OracleRoute, OracleSource, OverallTokenData, POSITION_INDEX_FIX, PROD, type PackageIds, type PositionCounts, PositionIndex, type PositionIndexOptions, type PositionSource, PositionWithRiskRatio, PreviewData, RATE_OUTPUT_DECIMALS, RETURN_PERCENT_PRECISION, RateData, RateDataV1, RateDataV2, RateModelAccount, type ReadContext, type ReserveRecord, RewardsRateModelConfig, SECONDS_PER_YEAR, STAGING, SUPPLY_RATE_PRECISION, TotalAmounts, TotalSupplyAndBorrow, UserBorrowData, UserBorrowPositionAccount, UserPosition, UserPositionWithDebt, UserSupplyData, UserSupplyPositionAccount, Vault, VaultConfig, VaultEntireData, VaultEntireDataV2, type VaultReadOpts, type VaultRecord, VaultState, ViewCallError, backoffDelay, bcs_d_exports as bcsTypes, checkpointClient, checkpointTimestampSeconds, clientForEndpoint, configFromDeployment, createDerive, createFailoverClient, divCeil, fluidRead, graphqlQuery, latestCheckpoint, lending_d_exports as lendingMath, liquidity_d_exports as liquidityMath, max, min, mulDiv, mulDivCeil, nowSeconds, resolveConfig, rewardsRateToBps, scaleAndInvert, simulateView, supplyRateToBps, tick_d_exports as tickMath, vault_d_exports as vaultMath };
|
package/dist/index.mjs
CHANGED
|
@@ -66,12 +66,51 @@ const STAGING = {
|
|
|
66
66
|
rpcUrls: ["https://fullnode.mainnet.sui.io:443"],
|
|
67
67
|
graphqlUrl: "https://graphql.mainnet.sui.io/graphql"
|
|
68
68
|
};
|
|
69
|
+
const USDC = "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
|
|
70
|
+
const HBTC = "0xd30fb3f8914efdbeb7b8e85fae1d65dc584b44a1281f66737b92bb9f03a59d06::btc::BTC";
|
|
69
71
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
+
* PRODUCTION deployment on Sui mainnet (2026-11-02), same ids as fluid-packages-sui
|
|
73
|
+
* deployments/mainnet.json + mainnet-markets.json and the write SDK. Day one: fUSDC and
|
|
74
|
+
* vault 1 = VaultMarket<hBTC, USDC> 0x1aa7…a624 on oracle nonce 1 0x6f74…3784 (RedStone BTC
|
|
75
|
+
* main + Pyth BTC/USD guard). Audited maths. Network "mainnet".
|
|
72
76
|
*/
|
|
73
|
-
const
|
|
74
|
-
|
|
77
|
+
const PROD = {
|
|
78
|
+
network: "mainnet",
|
|
79
|
+
packages: {
|
|
80
|
+
library: same("0xdb1caa95193a0bda87e56a9aaf9878672ca8bea7039447e5c789a572a0621969"),
|
|
81
|
+
liquidity: same("0x03dbce0f4cbd6325ca81414cc63a82f35e32bb941610b9120fab0997bc70daa3"),
|
|
82
|
+
lending: same("0xc63078660d7e3ed001e565b8bd7e2e6eb7313ef809051165cda901621e1db842"),
|
|
83
|
+
lendingRewards: same("0x8269897ee68730b4bde175c883719f1fa108509113c2c177ad1b456bb3782ba2"),
|
|
84
|
+
oracle: same("0x2caaa38d2c1c424d8ec79750c110d2211f2e06d66a9a261204f721175da15bcc"),
|
|
85
|
+
vaults: same("0x937156ee38d5c0a9e061dedd549867aeee88c478fad7f3213b66ca4f95906743")
|
|
86
|
+
},
|
|
87
|
+
objects: {
|
|
88
|
+
liquidityRegistry: "0xddeb96aeff09698e7fdcdefb6923642d0e2da1febcaf656371cf7e55bb339a0a",
|
|
89
|
+
lendingRegistry: "0x98307ab7e769b60257f4b12c20e0976fb57bbe898409b568a3044cf94b3f5647",
|
|
90
|
+
oracleRegistry: "0x359f818813a10a4bc3862536dafa6bc2bef0bf3597b090539fd05a89cf8fb368",
|
|
91
|
+
vaultRegistry: "0xe598cc749e0907d6454fdf779611b2efee7fdb2d756ff2706385bfed493bc608",
|
|
92
|
+
liquidityAuth: "0x1fc3d11285cd7b7ed44bf92f5df3a856c1a45699f59168fd878dfa4eae8e459f",
|
|
93
|
+
lendingAuth: "0x6e8ca10c5e6f49984106e38a3b6ef49c05a5a5a01f77b04c754e4d6c1e0ec8f7",
|
|
94
|
+
rewardsAuth: "0xaaf5efdfa300286a719ca8131bcc5f70bc1d3b1fb18a2886f4da04072b5b3bd1",
|
|
95
|
+
oracleAuth: "0xb498982435b0fdc18126d5febf1327af5dcd02b2e3377b6e5c37ab3eddf08ca8",
|
|
96
|
+
vaultAdmin: "0x2b3d9ccfb6e1da6ff8acfcb9c56c898a06ae7f3d6f37e3e64e7df34a60ccd887"
|
|
97
|
+
},
|
|
98
|
+
oracle: {
|
|
99
|
+
redstoneAdapter: STAGING.oracle.redstoneAdapter,
|
|
100
|
+
redstonePackage: STAGING.oracle.redstonePackage,
|
|
101
|
+
pythPriceInfoObjects: { "0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43": "0xe64832d1b4c9a75139a7313aee69da891297d8397fda2863b5bdcc4af0b79758" },
|
|
102
|
+
pythStateId: STAGING.oracle.pythStateId,
|
|
103
|
+
wormholeStateId: STAGING.oracle.wormholeStateId
|
|
104
|
+
},
|
|
105
|
+
tokens: [USDC, HBTC],
|
|
106
|
+
rpcUrls: ["https://fullnode.mainnet.sui.io:443"],
|
|
107
|
+
graphqlUrl: "https://graphql.mainnet.sui.io/graphql"
|
|
108
|
+
};
|
|
109
|
+
const MAINNET = PROD;
|
|
110
|
+
const CONFIGS = {
|
|
111
|
+
mainnet: PROD,
|
|
112
|
+
staging: STAGING
|
|
113
|
+
};
|
|
75
114
|
/**
|
|
76
115
|
* Build a read config from a deployment record instead of the built-in ids, e.g.
|
|
77
116
|
* `configFromDeployment(JSON.parse(readFileSync(path, "utf8")), { network: "mainnet", oracle })`.
|
|
@@ -125,8 +164,7 @@ function configFromDeployment(rec, opts) {
|
|
|
125
164
|
return config;
|
|
126
165
|
}
|
|
127
166
|
function resolveConfig(networkOrConfig) {
|
|
128
|
-
if (networkOrConfig === void 0 || networkOrConfig === null || networkOrConfig === "") throw new Error("Fluid network required: pass { network: \"staging\" } (the
|
|
129
|
-
if (networkOrConfig === "mainnet") throw new Error("No built-in Fluid production deployment yet. \"mainnet\" used to alias the STAGING deployment; pass { network: \"staging\" } for that, or build the production config with configFromDeployment(...) once it ships.");
|
|
167
|
+
if (networkOrConfig === void 0 || networkOrConfig === null || networkOrConfig === "") throw new Error("Fluid network required: pass { network: \"mainnet\" } (production), { network: \"staging\" } (the staging-on-mainnet deployment) or a config from configFromDeployment(...). There is no default.");
|
|
130
168
|
const cfg = typeof networkOrConfig === "string" ? CONFIGS[networkOrConfig] : networkOrConfig;
|
|
131
169
|
if (!cfg) throw new Error(`no built-in Fluid config for network "${String(networkOrConfig)}"`);
|
|
132
170
|
const n = (p) => ({
|
|
@@ -3478,8 +3516,8 @@ const DEFAULT_RPC_URL = "https://fullnode.mainnet.sui.io:443";
|
|
|
3478
3516
|
* `client.liquidity`, `client.lending`, `client.vault` (+ `client.oracle`, Sui-only).
|
|
3479
3517
|
*
|
|
3480
3518
|
* @example
|
|
3481
|
-
* const client = new Client(undefined, { network: "
|
|
3482
|
-
* const client = new Client("https://my-fullnode:443", { network:
|
|
3519
|
+
* const client = new Client(undefined, { network: "mainnet" }); // production deployment, Sui mainnet gRPC
|
|
3520
|
+
* const client = new Client("https://my-fullnode:443", { network: customConfig });
|
|
3483
3521
|
* const client = new Client(existingSuiGrpcClient, { network: "staging" });
|
|
3484
3522
|
* const vault = await client.vault.getVaultEntireData(1);
|
|
3485
3523
|
*/
|
|
@@ -3538,4 +3576,4 @@ function fluidRead(opts) {
|
|
|
3538
3576
|
}
|
|
3539
3577
|
|
|
3540
3578
|
//#endregion
|
|
3541
|
-
export { AllEndpointsFailedError, CONFIGS, CheckpointReadError, Client, DEFAULT_RPC_URL, EXCHANGE_PRICES_PRECISION, EXCHANGE_PRICE_SCALE_FACTOR, FOUR_DECIMALS, GraphQLError, Lending, Liquidity, MAINNET, MAX_REWARDS_RATE, NeedsDiscoveryError, ORACLE_LIMITS, ORACLE_RATE_PRECISION, ObjectNotFoundError, Oracle, POSITION_INDEX_FIX, PositionIndex, RATE_OUTPUT_DECIMALS, RETURN_PERCENT_PRECISION, SECONDS_PER_YEAR, STAGING, SUPPLY_RATE_PRECISION, Vault, ViewCallError, backoffDelay, bcs_exports as bcsTypes, checkpointClient, checkpointTimestampSeconds, clientForEndpoint, configFromDeployment, createDerive, createFailoverClient, divCeil, fluidRead, graphqlQuery, latestCheckpoint, lending_exports as lendingMath, liquidity_exports as liquidityMath, max, min, mulDiv, mulDivCeil, nowSeconds, resolveConfig, rewardsRateToBps, scaleAndInvert, simulateView, supplyRateToBps, tick_exports as tickMath, vault_exports as vaultMath };
|
|
3579
|
+
export { AllEndpointsFailedError, CONFIGS, CheckpointReadError, Client, DEFAULT_RPC_URL, EXCHANGE_PRICES_PRECISION, EXCHANGE_PRICE_SCALE_FACTOR, FOUR_DECIMALS, GraphQLError, Lending, Liquidity, MAINNET, MAX_REWARDS_RATE, NeedsDiscoveryError, ORACLE_LIMITS, ORACLE_RATE_PRECISION, ObjectNotFoundError, Oracle, POSITION_INDEX_FIX, PROD, PositionIndex, RATE_OUTPUT_DECIMALS, RETURN_PERCENT_PRECISION, SECONDS_PER_YEAR, STAGING, SUPPLY_RATE_PRECISION, Vault, ViewCallError, backoffDelay, bcs_exports as bcsTypes, checkpointClient, checkpointTimestampSeconds, clientForEndpoint, configFromDeployment, createDerive, createFailoverClient, divCeil, fluidRead, graphqlQuery, latestCheckpoint, lending_exports as lendingMath, liquidity_exports as liquidityMath, max, min, mulDiv, mulDivCeil, nowSeconds, resolveConfig, rewardsRateToBps, scaleAndInvert, simulateView, supplyRateToBps, tick_exports as tickMath, vault_exports as vaultMath };
|