@instadapp/fluid-sui-read-sdk 0.1.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.
Files changed (4) hide show
  1. package/README.md +148 -21
  2. package/dist/index.d.mts +1229 -995
  3. package/dist/index.mjs +719 -311
  4. package/package.json +1 -1
package/dist/index.d.mts CHANGED
@@ -1,850 +1,273 @@
1
- import { BcsType } from "@mysten/sui/bcs";
2
1
  import { ClientWithCoreApi } from "@mysten/sui/client";
2
+ import { BcsType } from "@mysten/sui/bcs";
3
3
  import { Transaction, TransactionResult } from "@mysten/sui/transactions";
4
4
  import * as _mysten_bcs0 from "@mysten/bcs";
5
5
 
6
- //#region src/config.d.ts
7
- type PackageIds = {
8
- /** Latest version: target of move calls (views). */
9
- packageId: string;
10
- /** First version: address used in type tags and derived-object keys. */
11
- originalId: string;
6
+ //#region src/types.d.ts
7
+ /**
8
+ * Public types. Field names match `@jup-ag/lend-read` one-for-one wherever the protocol
9
+ * concept is the same; differences:
10
+ * - `PublicKey` → `string` (a Sui object id, or a coin type for tokens)
11
+ * - `BN` → `bigint`
12
+ * - Solana `nftId: number` → Sui `positionId: string` (+ `capId`, the PositionOwnerCap)
13
+ */
14
+ type RateDataV1 = {
15
+ token: string;
16
+ rateAtUtilizationZero: bigint;
17
+ kink: bigint;
18
+ rateAtUtilizationKink: bigint;
19
+ rateAtUtilizationMax: bigint;
12
20
  };
13
- type FluidReadConfig = {
14
- network: string;
15
- packages: {
16
- library: PackageIds;
17
- liquidity: PackageIds;
18
- lending: PackageIds;
19
- /** Optional: lending rewards package (write-SDK parity; no read views depend on it yet). */
20
- lendingRewards?: PackageIds;
21
- oracle: PackageIds;
22
- vaults: PackageIds;
23
- };
24
- objects: {
25
- liquidityRegistry: string;
26
- lendingRegistry: string;
27
- oracleRegistry: string;
28
- vaultRegistry: string;
29
- liquidityAuth?: string;
30
- lendingAuth?: string;
31
- rewardsAuth?: string;
32
- oracleAuth?: string;
33
- vaultAdmin?: string;
34
- };
35
- /**
36
- * "v2": RedStone main + optional Pyth guard (`view::get_*_exchange_rate(&Oracle, &PriceAdapter,
37
- * &PriceInfoObject, &Clock)`), live on mainnet since 2026-09-30.
38
- * "admin": the interim admin-set oracle (`view::quote(&Oracle)`), 2026-09-18 deployment only.
39
- */
40
- oracleVariant: "admin" | "v2";
41
- /** v2 only: provider objects the quote needs. Pyth PriceInfoObjects keyed by 0x-hex feed id. */
42
- oracleV2?: {
43
- /** RedStone adapter used when an oracle has no RedStone route (the call still takes one). */
44
- redstoneAdapter: string;
45
- /** Package to call RedStone views on (route transparency only). */
46
- redstonePackage: string;
47
- pythPriceInfoObjects: Record<string, string>;
48
- /** Pyth State + Wormhole State (write-SDK parity, needed only to build a Pyth price update). */
49
- pythStateId?: string;
50
- wormholeStateId?: string;
21
+ type RateDataV2 = {
22
+ token: string;
23
+ rateAtUtilizationZero: bigint;
24
+ kink1: bigint;
25
+ rateAtUtilizationKink1: bigint;
26
+ kink2: bigint;
27
+ rateAtUtilizationKink2: bigint;
28
+ rateAtUtilizationMax: bigint;
29
+ };
30
+ type RateData = {
31
+ token: string;
32
+ /** 0 = unset, 1 = V1, 2 = V2 (`TokenReserve.rate_data_version`). */
33
+ version: number;
34
+ rateDataV1: RateDataV1;
35
+ rateDataV2: RateDataV2;
36
+ };
37
+ type RateModelAccount = {
38
+ mint: string;
39
+ version: number;
40
+ rateAtUtilizationZero: bigint;
41
+ kink?: bigint;
42
+ rateAtUtilizationKink?: bigint;
43
+ kink1?: bigint;
44
+ rateAtUtilizationKink1?: bigint;
45
+ kink2?: bigint;
46
+ rateAtUtilizationKink2?: bigint;
47
+ rateAtUtilizationMax: bigint;
48
+ };
49
+ type ExchangePricesAndConfig = {
50
+ supplyExchangePrice: bigint;
51
+ borrowExchangePrice: bigint;
52
+ borrowRate: bigint;
53
+ fee: bigint;
54
+ lastStoredUtilization: bigint;
55
+ lastUpdateTimestamp: bigint;
56
+ maxUtilization: bigint;
57
+ };
58
+ type TotalAmounts = {
59
+ supplyRawInterest: bigint;
60
+ supplyInterestFree: bigint;
61
+ borrowRawInterest: bigint;
62
+ borrowInterestFree: bigint;
63
+ /** Solana-only concept (claim accounts); always 0 on Sui. */
64
+ totalClaimAmount: bigint;
65
+ };
66
+ type ExchangePriceResult = {
67
+ supplyExchangePrice: bigint;
68
+ borrowExchangePrice: bigint;
69
+ };
70
+ type OverallTokenData = {
71
+ rateData: RateData;
72
+ supplyExchangePrice: bigint;
73
+ borrowExchangePrice: bigint;
74
+ borrowRate: bigint;
75
+ fee: bigint;
76
+ lastStoredUtilization: bigint;
77
+ lastUpdateTimestamp: bigint;
78
+ maxUtilization: bigint;
79
+ supplyRawInterest: bigint;
80
+ supplyInterestFree: bigint;
81
+ borrowRawInterest: bigint;
82
+ borrowInterestFree: bigint;
83
+ totalSupply: bigint;
84
+ totalBorrow: bigint;
85
+ revenue: bigint;
86
+ supplyRate: bigint;
87
+ };
88
+ type UserSupplyPositionAccount = {
89
+ user: string;
90
+ mint: string;
91
+ amount: bigint;
92
+ withdrawalLimit: bigint;
93
+ baseWithdrawalLimit: bigint;
94
+ lastUpdateTimestamp: bigint;
95
+ expandPercent: bigint;
96
+ expandDuration: bigint;
97
+ modeWithInterest: boolean;
98
+ decayAmount: bigint;
99
+ decayDuration: bigint;
100
+ /** Sui extras. */
101
+ configured: boolean;
102
+ pausedSupply: boolean;
103
+ pausedWithdraw: boolean;
104
+ };
105
+ type UserBorrowPositionAccount = {
106
+ user: string;
107
+ mint: string;
108
+ amount: bigint;
109
+ borrowLimit: bigint;
110
+ baseBorrowLimit: bigint;
111
+ maxBorrowLimit: bigint;
112
+ lastUpdateTimestamp: bigint;
113
+ expandPercent: bigint;
114
+ expandDuration: bigint;
115
+ modeWithInterest: boolean;
116
+ /** Sui extras. */
117
+ configured: boolean;
118
+ pausedBorrow: boolean;
119
+ pausedPayback: boolean;
120
+ };
121
+ type UserSupplyData = {
122
+ modeWithInterest: boolean;
123
+ supply: bigint;
124
+ withdrawalLimit: bigint;
125
+ lastUpdateTimestamp: bigint;
126
+ expandPercent: bigint;
127
+ expandDuration: bigint;
128
+ baseWithdrawalLimit: bigint;
129
+ withdrawableUntilLimit: bigint;
130
+ withdrawable: bigint;
131
+ decayAmount: bigint;
132
+ decayEndTimestamp: bigint;
133
+ };
134
+ type UserBorrowData = {
135
+ modeWithInterest: boolean;
136
+ borrow: bigint;
137
+ borrowLimit: bigint;
138
+ lastUpdateTimestamp: bigint;
139
+ expandPercent: bigint;
140
+ expandDuration: bigint;
141
+ baseBorrowLimit: bigint;
142
+ maxBorrowLimit: bigint;
143
+ borrowLimitUtilization: bigint;
144
+ borrowableUntilLimit: bigint;
145
+ borrowable: bigint;
146
+ };
147
+ type LiquidityAccount = {
148
+ id: string;
149
+ version: bigint;
150
+ revenueCollector: string;
151
+ /** Global pause flags (true = paused). */
152
+ status: {
153
+ supply: boolean;
154
+ borrow: boolean;
155
+ payback: boolean;
156
+ withdraw: boolean;
51
157
  };
158
+ activeCapsTableId: string;
159
+ activeCapsCount: bigint;
160
+ };
161
+ /** fToken = the lending (share) token on Sui, `Coin<FToken<T>>` (Solana calls it jlToken). */
162
+ type FTokenDetails = {
163
+ /** Sui: `FToken<T>` coin type. */
164
+ tokenAddress: string;
165
+ /** Sui: the `LendingState<T>` object id. */
166
+ lendingStateId: string;
167
+ name: string;
168
+ symbol: string;
169
+ decimals: number;
170
+ underlyingAddress: string;
171
+ totalAssets: bigint;
172
+ totalSupply: bigint;
173
+ conversionRateToShares: bigint;
174
+ conversionRateToAssets: bigint;
52
175
  /**
53
- * Coin types seeded into token discovery. Token discovery is pure state: these, plus the
54
- * collateral/debt types of every VaultMarket (vault ids 1..total_vaults from the registry).
55
- * Coverage is checked against `Registry.active_caps.size`; see `Liquidity.discoverTokens`.
56
- */
57
- tokens?: string[];
58
- /** Fullnode endpoints, tried in order with failover. "jsonrpc+https://..." selects JSON-RPC. */
59
- rpcUrls?: string[];
60
- /**
61
- * Type of the proposed on-chain position-index key (docs/onchain-position-index.md). A struct
62
- * added in a package upgrade is defined at the upgraded package id, so set this to
63
- * `<upgraded vaults package>::position_index::PositionIndexKey` once it ships. Default assumes
64
- * `<vaults originalId>::position_index::PositionIndexKey`.
176
+ * RATES: every rate field is bps (1e4 = 100% per year), floored. Raw 1e12 values:
177
+ * `liquidityMath.supplyRateAt` / `lendingMath.currentRewardsRate`.
65
178
  */
66
- positionIndexKeyType?: string;
67
- /** GraphQL indexer endpoint. Used ONLY with `discovery: "indexer"`. */
68
- graphqlUrl?: string;
179
+ /** Rewards rate from the active schedule, priced on the pre-accrual TVL. bps. */
180
+ rewardsRate: bigint;
181
+ /** Organic (liquidity-layer) supply rate, exact on-chain formula. bps. */
182
+ supplyRate: bigint;
183
+ /** `supplyRate + rewardsRate`. bps. */
184
+ totalRate: bigint;
185
+ rebalanceDifference: bigint;
186
+ userSupplyData: UserSupplyData;
69
187
  };
188
+ /** @deprecated Solana name; use `FTokenDetails`. */
189
+ type JlTokenDetails = FTokenDetails;
70
190
  /**
71
- * STAGING deployment on Sui mainnet (staging deployment gist, 2026-09-30). NOT a final production
72
- * deployment: ids change at the production launch. Build
73
- * your own config from a deployment record with `configFromDeployment`.
74
- *
75
- * Fluid Sui staging-on-mainnet: library / liquidity / lending
76
- * from 2026-09-18; oracle (RedStone main + Pyth guard) and vaults redeployed 2026-09-30.
77
- * Vault 1 = VaultMarket<SUI, USDC> 0x3ba55ebc…72b8 on oracle nonce 1 (0x1a690d20…b279).
78
- * Vault 2 = VaultMarket<SUI, USDSUI> 0x5120…0efa. fTokens: fUSDC, fUSDSUI.
79
- * Ids match the write SDK (fluid-packages-sui deployments/mainnet.json @ 06828ff, 2026-10-01) and
80
- * the live staging deployment (re-read on chain 2026-10-10). Alias: network "staging".
81
- */
82
- declare const STAGING: FluidReadConfig;
83
- /**
84
- * SUPERSEDED. 2026-09-18 deployment: interim admin oracle (`view::quote`, vault 1 on
85
- * 0xf36d0d95…651f) + the vaults package built on it. Objects still exist on chain; kept only to
86
- * read historical state.
87
- */
88
- declare const STAGING_LEGACY: FluidReadConfig;
89
- /**
90
- * @deprecated Misleading name kept for compatibility: this is the STAGING deployment
91
- * (`STAGING`), not production. Use `STAGING` / network "staging".
92
- */
93
- declare const MAINNET: FluidReadConfig;
94
- /** Default built-in network. Points at the current staging deployment until production ships. */
95
- declare const DEFAULT_NETWORK = "staging";
96
- declare const CONFIGS: Record<string, FluidReadConfig>;
97
- /**
98
- * Deployment record: per-package ids plus the shared object ids the SDK reads. The ids alone are
99
- * not enough: `liquidity`, `lending`, `oracle` and `vaults` must each carry `objects.registry`
100
- * (see "Deployment record shape" in the README).
191
+ * Generic per-fToken lending state (`lending.getLendingStateData`). Exchange prices are 1e12;
192
+ * amounts are in underlying token units (no USD: every lending token is USD-pegged); every rate
193
+ * is bps (1e4 = 100% per year).
101
194
  */
102
- type DeploymentRecord = {
103
- packages: Record<"library" | "liquidity" | "lending" | "oracle" | "vaults" | "lending_rewards", {
104
- packageId: string;
105
- originalId?: string;
106
- objects?: Record<string, string>;
107
- } | undefined>;
108
- };
109
- /**
110
- * Build a read config from a deployment record instead of the built-in ids, e.g.
111
- * `configFromDeployment(JSON.parse(readFileSync(path, "utf8")), { network: "mainnet", oracleV2 })`.
112
- * The record has no RedStone package or Pyth feed map, so `oracleV2` comes from the caller.
113
- * Throws once, listing every required field the record is missing.
114
- */
115
- declare function configFromDeployment(rec: DeploymentRecord, opts: Pick<FluidReadConfig, "network" | "oracleV2"> & Partial<Pick<FluidReadConfig, "tokens" | "rpcUrls" | "graphqlUrl">>): FluidReadConfig;
116
- declare function resolveConfig(networkOrConfig: string | FluidReadConfig): FluidReadConfig;
117
- //#endregion
118
- //#region src/derive.d.ts
119
- declare function createDerive(cfg: FluidReadConfig): {
120
- /** `TokenReserve<T>`: derived from the liquidity Registry, key `ReserveKey<T>`. */
121
- tokenReserveId: (coinType: string) => string;
122
- /** `LendingState<T>`: derived from the LendingRegistry, key `LendingStateKey<T>`. */
123
- lendingStateId: (coinType: string) => string;
124
- /** `VaultMarket<Col, Debt>`: derived from the VaultRegistry, key `VaultKey(u64)`. */
125
- vaultMarketId: (vaultId: number | bigint) => string;
126
- /** `Position`: derived from its VaultMarket, key `PositionKey(cap id)`. */
127
- positionId: (vaultMarketId: string, capId: string) => string;
128
- holderKeyType: string;
129
- /** Entry of `TokenReserve.supply_positions` / `borrow_positions` for `Holder::Object(id)`. */
130
- holderEntryId: (tableId: string, holderObjectId: string) => string;
131
- /** `RateDataKey` dynamic field on a TokenReserve. */
132
- rateDataId: (reserveId: string) => string;
133
- /** `RewardsKey` dynamic field on a LendingState. */
134
- rewardsId: (lendingStateId: string) => string;
135
- /** `VaultMarket.ticks` entry. */
136
- tickEntryId: (ticksTableId: string, tick: number) => string;
137
- /** `VaultMarket.branches` entry. */
138
- branchEntryId: (branchesTableId: string, branchId: number | bigint | string) => string;
139
- /** `VaultMarket.liq_snaps` entry. */
140
- liqSnapEntryId: (snapsTableId: string, tick: number, tickId: number) => string;
141
- /** `VaultMarket.tick_bitmap` word. */
142
- bitmapWordId: (bitmapTableId: string, word: number) => string;
143
- /**
144
- * Proposed on-chain position index (docs/onchain-position-index.md): dynamic field
145
- * `PositionIndexKey()` on the VaultMarket. Returns null-safe ids; absent until shipped.
146
- */
147
- positionIndexKeyType: string;
148
- positionIndexId: (vaultMarketId: string) => string;
149
- /** Entry `n` (1-based ordinal) of the index's `caps: Table<u64, ID>`. */
150
- positionIndexEntryId: (capsTableId: string, n: number | bigint) => string;
151
- /** v2 `Oracle`: derived from the OracleRegistry, key `OracleKey(nonce: u16)`; nonces 1..total_oracles. */
152
- oracleId: (nonce: number) => string;
153
- fTokenType: (coinType: string) => string;
154
- positionCapType: string;
195
+ type LendingStateData = {
196
+ /** `FToken<T>` coin type (the share coin is `Coin<FToken<T>>`). */
197
+ fTokenType: string;
198
+ /** Underlying coin type `T`. */
199
+ asset: string;
200
+ decimals: number;
201
+ lendingStateId: string;
202
+ /** Chain time (unix s, on-chain Clock) every "accrued" value below is computed at. */
203
+ timestamp: bigint;
204
+ /** fToken -> underlying, rewards INCLUDED, accrued to `timestamp`. */
205
+ tokenExchangePrice: bigint;
206
+ /** The underlying's liquidity-layer supply exchange price, rewards EXCLUDED, accrued to `timestamp`. */
207
+ liquidityExchangePrice: bigint;
208
+ /** As stored on LendingState at its last update (no accrual). */
209
+ storedTokenExchangePrice: bigint;
210
+ storedLiquidityExchangePrice: bigint;
211
+ /** LendingState last update; `timestamp - lastUpdateS` = how stale the stored prices are. */
212
+ lastUpdateS: bigint;
213
+ /** TokenReserve (liquidity layer) last update. */
214
+ liquidityLastUpdateS: bigint;
215
+ /** fToken shares outstanding. */
216
+ totalShares: bigint;
217
+ /** `totalShares` at the accrued `tokenExchangePrice`, token units (floor, = accounting::total_assets). */
218
+ totalAssets: bigint;
219
+ /** Organic liquidity supply rate (exact on-chain formula). */
220
+ supplyRate: bigint;
221
+ /** Rewards rate from the active window, priced on the pre-accrual TVL as the contract does. */
222
+ rewardsRate: bigint;
223
+ /** `supplyRate + rewardsRate`. */
224
+ totalRate: bigint;
225
+ /** Rewards schedule as stored; `null` when the pool has none. Times are unix seconds. */
226
+ rewards: {
227
+ startTvl: bigint;
228
+ startS: bigint;
229
+ endS: bigint;
230
+ yearlyReward: bigint;
231
+ nextStartS: bigint;
232
+ nextEndS: bigint;
233
+ nextYearlyReward: bigint;
234
+ } | null;
235
+ };
236
+ /** One wallet holding `Coin<FToken<T>>` objects. */
237
+ type FTokenHolder = {
238
+ /** Wallet address (AddressOwner or ConsensusAddressOwner). */
239
+ owner: string;
240
+ /** Sum of the wallet's Coin<FToken<T>> objects at `checkpoint` (shares). */
241
+ balance: bigint;
242
+ /** Number of coin objects summed. */
243
+ coins: number;
244
+ /** Cross-check via fullnode `getBalance` (live, after the checkpoint). Present when `verify`. */
245
+ rpc?: {
246
+ balance: bigint;
247
+ coinBalance: bigint;
248
+ addressBalance: bigint;
249
+ };
250
+ /** `rpc.coinBalance === balance && rpc.addressBalance === 0n`. A mismatch means the wallet moved
251
+ * shares after `checkpoint` or holds an address balance (credited without a coin object). */
252
+ agrees?: boolean;
253
+ };
254
+ type FTokenHolders = {
255
+ fTokenType: string;
256
+ asset: string;
257
+ /** Checkpoint the coin listing and `totalSupply` were read at. */
258
+ checkpoint: bigint;
259
+ /** Wallets, largest first. */
260
+ holders: FTokenHolder[];
261
+ /** Sum of `holders[].balance`. */
262
+ countedTotal: bigint;
263
+ /** LendingState total shares at `checkpoint`. */
264
+ totalSupply: bigint;
155
265
  };
156
- type FluidDerive = ReturnType<typeof createDerive>;
157
- //#endregion
158
- //#region src/context.d.ts
159
- /**
160
- * How far the SDK may go beyond pure object state when it has to ENUMERATE something.
161
- *
162
- * - "state" (default): only reads of objects by derived id (`getObjects`) and Move view
163
- * simulation. No list/scan queries of any kind. Anything that cannot be resolved this way
164
- * throws `NeedsDiscoveryError` naming the on-chain change that would make it pure.
165
- * - "fullnode": also the fullnode's own secondary indexes (`listDynamicFields`,
166
- * `listOwnedObjects`). Same endpoint(s) as state reads, so failover covers them, but the
167
- * node must run with indexing enabled.
168
- * - "indexer": also the external GraphQL indexer (event scans). Last resort.
169
- */
170
- type DiscoveryLevel = "state" | "fullnode" | "indexer";
171
- declare class NeedsDiscoveryError extends Error {
172
- readonly what: string;
173
- readonly needed: DiscoveryLevel;
174
- readonly onchainFix: string;
175
- constructor(what: string, needed: DiscoveryLevel, onchainFix: string);
176
- }
177
- /** Shared state every module reads through. */
178
- type ReadContext = {
179
- client: ClientWithCoreApi;
180
- config: FluidReadConfig;
181
- derive: FluidDerive;
182
- /** Clock for time-dependent maths (seconds). Defaults to local wall clock. */
183
- now: () => bigint;
184
- discovery: DiscoveryLevel;
185
- allows: (level: DiscoveryLevel) => boolean;
186
- };
187
- declare namespace bcs_d_exports {
188
- export { AdminOracle$1 as AdminOracle, Branch, BranchStatus, CapRecord, Field, Holder, LendingRegistry, LendingState, LiquidityRegistry, MoveTick, OracleRegistry, OracleSource, OracleSourceType, OracleV2$1 as OracleV2, PauseFlags, Position, PositionIndex$1 as PositionIndex, PositionIndexEntry, PositionIndexField, PriceQuote, PriceQuoteV2, PythPriceInfoObject, RateDataV1Params, RateDataV2Params, RateMagnifier, RewardsSchedule$1 as RewardsSchedule, RiskConfig, Table, TickIdLiquidation, TickIdLiquidationKey, TokenReserve, TypeName, UnitKey, UserBorrowConfig, UserBorrowPosition, UserSupplyConfig, UserSupplyPosition, VaultMarket, VaultRegistry, VaultTick, bcsId, bcsU16, bcsU256, bcsU64 };
189
- }
190
- declare const TypeName: _mysten_bcs0.BcsStruct<{
191
- name: BcsType<string, string, "string">;
192
- }, string>;
193
- declare const MoveTick: _mysten_bcs0.BcsStruct<{
194
- mag: BcsType<number, number, "u32">;
195
- neg: BcsType<boolean, boolean, "bool">;
196
- }, string>;
197
- declare const Table: _mysten_bcs0.BcsStruct<{
198
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
199
- size: BcsType<string, string | number | bigint, "u64">;
200
- }, string>;
201
- declare const PauseFlags: _mysten_bcs0.BcsStruct<{
202
- supply: BcsType<boolean, boolean, "bool">;
203
- borrow: BcsType<boolean, boolean, "bool">;
204
- payback: BcsType<boolean, boolean, "bool">;
205
- withdraw: BcsType<boolean, boolean, "bool">;
206
- }, string>;
207
- declare const Holder: _mysten_bcs0.BcsEnum<{
208
- Object: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
209
- Type: _mysten_bcs0.BcsStruct<{
210
- name: BcsType<string, string, "string">;
211
- }, string>;
212
- }, "Holder">;
213
- declare const LiquidityRegistry: _mysten_bcs0.BcsStruct<{
214
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
215
- version: BcsType<string, string | number | bigint, "u64">;
216
- pause: _mysten_bcs0.BcsStruct<{
217
- supply: BcsType<boolean, boolean, "bool">;
218
- borrow: BcsType<boolean, boolean, "bool">;
219
- payback: BcsType<boolean, boolean, "bool">;
220
- withdraw: BcsType<boolean, boolean, "bool">;
221
- }, string>;
222
- revenue_collector: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
223
- active_caps: _mysten_bcs0.BcsStruct<{
224
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
225
- size: BcsType<string, string | number | bigint, "u64">;
226
- }, string>;
227
- }, string>;
228
- declare const TokenReserve: _mysten_bcs0.BcsStruct<{
229
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
230
- pause: _mysten_bcs0.BcsStruct<{
231
- supply: BcsType<boolean, boolean, "bool">;
232
- borrow: BcsType<boolean, boolean, "bool">;
233
- payback: BcsType<boolean, boolean, "bool">;
234
- withdraw: BcsType<boolean, boolean, "bool">;
235
- }, string>;
236
- vault: BcsType<string, string | number | bigint, "u64">;
237
- borrow_rate: BcsType<string, string | number | bigint, "u64">;
238
- fee: BcsType<string, string | number | bigint, "u64">;
239
- last_utilization: BcsType<string, string | number | bigint, "u64">;
240
- last_update_timestamp: BcsType<string, string | number | bigint, "u64">;
241
- supply_exchange_price: BcsType<string, string | number | bigint, "u64">;
242
- borrow_exchange_price: BcsType<string, string | number | bigint, "u64">;
243
- max_utilization: BcsType<string, string | number | bigint, "u64">;
244
- total_supply_with_interest: BcsType<string, string | number | bigint, "u64">;
245
- total_supply_interest_free: BcsType<string, string | number | bigint, "u64">;
246
- total_borrow_with_interest: BcsType<string, string | number | bigint, "u64">;
247
- total_borrow_interest_free: BcsType<string, string | number | bigint, "u64">;
248
- rate_data_version: BcsType<number, number, "u8">;
249
- supply_positions: _mysten_bcs0.BcsStruct<{
250
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
251
- size: BcsType<string, string | number | bigint, "u64">;
252
- }, string>;
253
- borrow_positions: _mysten_bcs0.BcsStruct<{
254
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
255
- size: BcsType<string, string | number | bigint, "u64">;
256
- }, string>;
257
- }, string>;
258
- declare const UserSupplyConfig: _mysten_bcs0.BcsStruct<{
259
- mode: BcsType<number, number, "u8">;
260
- expand_percent: BcsType<string, string | number | bigint, "u64">;
261
- expand_duration: BcsType<string, string | number | bigint, "u64">;
262
- base_withdrawal_limit: BcsType<string, string | number | bigint, "u64">;
263
- }, string>;
264
- declare const UserBorrowConfig: _mysten_bcs0.BcsStruct<{
265
- mode: BcsType<number, number, "u8">;
266
- expand_percent: BcsType<string, string | number | bigint, "u64">;
267
- expand_duration: BcsType<string, string | number | bigint, "u64">;
268
- base_debt_ceiling: BcsType<string, string | number | bigint, "u64">;
269
- max_debt_ceiling: BcsType<string, string | number | bigint, "u64">;
270
- }, string>;
271
- declare const UserSupplyPosition: _mysten_bcs0.BcsStruct<{
272
- config: BcsType<{
273
- mode: number;
274
- expand_percent: string;
275
- expand_duration: string;
276
- base_withdrawal_limit: string;
277
- } | null, {
278
- mode: number;
279
- expand_percent: string | number | bigint;
280
- expand_duration: string | number | bigint;
281
- base_withdrawal_limit: string | number | bigint;
282
- } | null | undefined, `Option<${string}>`>;
283
- paused_supply: BcsType<boolean, boolean, "bool">;
284
- paused_withdraw: BcsType<boolean, boolean, "bool">;
285
- amount: BcsType<string, string | number | bigint, "u64">;
286
- withdrawal_limit: BcsType<string, string | number | bigint, "u64">;
287
- last_update: BcsType<string, string | number | bigint, "u64">;
288
- decay_amount: BcsType<string, string | number | bigint, "u64">;
289
- decay_duration: BcsType<string, string | number | bigint, "u64">;
290
- }, string>;
291
- declare const UserBorrowPosition: _mysten_bcs0.BcsStruct<{
292
- config: BcsType<{
293
- mode: number;
294
- expand_percent: string;
295
- expand_duration: string;
296
- base_debt_ceiling: string;
297
- max_debt_ceiling: string;
298
- } | null, {
299
- mode: number;
300
- expand_percent: string | number | bigint;
301
- expand_duration: string | number | bigint;
302
- base_debt_ceiling: string | number | bigint;
303
- max_debt_ceiling: string | number | bigint;
304
- } | null | undefined, `Option<${string}>`>;
305
- paused_borrow: BcsType<boolean, boolean, "bool">;
306
- paused_payback: BcsType<boolean, boolean, "bool">;
307
- amount: BcsType<string, string | number | bigint, "u64">;
308
- debt_ceiling: BcsType<string, string | number | bigint, "u64">;
309
- last_update: BcsType<string, string | number | bigint, "u64">;
310
- }, string>;
311
- declare const RateDataV1Params: _mysten_bcs0.BcsStruct<{
312
- kink: BcsType<string, string | number | bigint, "u64">;
313
- rate_at_utilization_zero: BcsType<string, string | number | bigint, "u64">;
314
- rate_at_utilization_kink: BcsType<string, string | number | bigint, "u64">;
315
- rate_at_utilization_max: BcsType<string, string | number | bigint, "u64">;
316
- }, string>;
317
- declare const RateDataV2Params: _mysten_bcs0.BcsStruct<{
318
- kink1: BcsType<string, string | number | bigint, "u64">;
319
- kink2: BcsType<string, string | number | bigint, "u64">;
320
- rate_at_utilization_zero: BcsType<string, string | number | bigint, "u64">;
321
- rate_at_utilization_kink1: BcsType<string, string | number | bigint, "u64">;
322
- rate_at_utilization_kink2: BcsType<string, string | number | bigint, "u64">;
323
- rate_at_utilization_max: BcsType<string, string | number | bigint, "u64">;
324
- }, string>;
325
- declare const CapRecord: _mysten_bcs0.BcsStruct<{
326
- token: _mysten_bcs0.BcsStruct<{
327
- name: BcsType<string, string, "string">;
328
- }, string>;
329
- holder: _mysten_bcs0.BcsEnum<{
330
- Object: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
331
- Type: _mysten_bcs0.BcsStruct<{
332
- name: BcsType<string, string, "string">;
333
- }, string>;
334
- }, "Holder">;
335
- }, string>;
336
- declare const LendingState: _mysten_bcs0.BcsStruct<{
337
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
338
- supply: BcsType<string, string | number | bigint, "u64">;
339
- reserve_id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
340
- rewards_writer: BcsType<string | null, string | Uint8Array<ArrayBufferLike> | null | undefined, "Option<bytes[32]>">;
341
- token_exchange_price: BcsType<string, string | number | bigint, "u64">;
342
- liquidity_exchange_price: BcsType<string, string | number | bigint, "u64">;
343
- last_update_s: BcsType<string, string | number | bigint, "u64">;
344
- }, string>;
345
- declare const RewardsSchedule$1: _mysten_bcs0.BcsStruct<{
346
- start_tvl: BcsType<string, string | number | bigint, "u64">;
347
- start_s: BcsType<string, string | number | bigint, "u64">;
348
- end_s: BcsType<string, string | number | bigint, "u64">;
349
- yearly_reward: BcsType<string, string | number | bigint, "u64">;
350
- next_start_s: BcsType<string, string | number | bigint, "u64">;
351
- next_end_s: BcsType<string, string | number | bigint, "u64">;
352
- next_yearly_reward: BcsType<string, string | number | bigint, "u64">;
353
- }, string>;
354
- declare const LendingRegistry: _mysten_bcs0.BcsStruct<{
355
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
356
- version: BcsType<string, string | number | bigint, "u64">;
357
- }, string>;
358
- declare const RiskConfig: _mysten_bcs0.BcsStruct<{
359
- collateral_factor: BcsType<number, number, "u16">;
360
- liquidation_threshold: BcsType<number, number, "u16">;
361
- liquidation_max_limit: BcsType<number, number, "u16">;
362
- withdraw_gap: BcsType<number, number, "u16">;
363
- liquidation_penalty: BcsType<number, number, "u16">;
364
- borrow_fee: BcsType<number, number, "u8">;
365
- }, string>;
366
- declare const RateMagnifier: _mysten_bcs0.BcsStruct<{
367
- magnitude: BcsType<number, number, "u16">;
368
- negative: BcsType<boolean, boolean, "bool">;
369
- }, string>;
370
- declare const VaultMarket: _mysten_bcs0.BcsStruct<{
371
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
372
- vault_id: BcsType<string, string | number | bigint, "u64">;
373
- risk: _mysten_bcs0.BcsStruct<{
374
- collateral_factor: BcsType<number, number, "u16">;
375
- liquidation_threshold: BcsType<number, number, "u16">;
376
- liquidation_max_limit: BcsType<number, number, "u16">;
377
- withdraw_gap: BcsType<number, number, "u16">;
378
- liquidation_penalty: BcsType<number, number, "u16">;
379
- borrow_fee: BcsType<number, number, "u8">;
380
- }, string>;
381
- supply_rate_magnifier: _mysten_bcs0.BcsStruct<{
382
- magnitude: BcsType<number, number, "u16">;
383
- negative: BcsType<boolean, boolean, "bool">;
384
- }, string>;
385
- borrow_rate_magnifier: _mysten_bcs0.BcsStruct<{
386
- magnitude: BcsType<number, number, "u16">;
387
- negative: BcsType<boolean, boolean, "bool">;
388
- }, string>;
389
- vault_type: BcsType<number, number, "u8">;
390
- oracle: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
391
- liquidity_program: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
392
- col_decimals: BcsType<number, number, "u8">;
393
- debt_decimals: BcsType<number, number, "u8">;
394
- branch_liquidated: BcsType<boolean, boolean, "bool">;
395
- topmost_tick: _mysten_bcs0.BcsStruct<{
396
- mag: BcsType<number, number, "u32">;
397
- neg: BcsType<boolean, boolean, "bool">;
398
- }, string>;
399
- current_branch_id: BcsType<string, string | number | bigint, "u64">;
400
- total_branch_id: BcsType<string, string | number | bigint, "u64">;
401
- total_supply: BcsType<string, string | number | bigint, "u64">;
402
- total_borrow: BcsType<string, string | number | bigint, "u64">;
403
- absorbed_debt_amount: BcsType<string, string | number | bigint, "u128">;
404
- absorbed_col_amount: BcsType<string, string | number | bigint, "u128">;
405
- absorbed_dust_debt: BcsType<string, string | number | bigint, "u64">;
406
- liquidity_supply_exchange_price: BcsType<string, string | number | bigint, "u64">;
407
- liquidity_borrow_exchange_price: BcsType<string, string | number | bigint, "u64">;
408
- vault_supply_exchange_price: BcsType<string, string | number | bigint, "u64">;
409
- vault_borrow_exchange_price: BcsType<string, string | number | bigint, "u64">;
410
- last_update_timestamp: BcsType<string, string | number | bigint, "u64">;
411
- ticks: _mysten_bcs0.BcsStruct<{
412
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
413
- size: BcsType<string, string | number | bigint, "u64">;
414
- }, string>;
415
- branches: _mysten_bcs0.BcsStruct<{
416
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
417
- size: BcsType<string, string | number | bigint, "u64">;
418
- }, string>;
419
- liq_snaps: _mysten_bcs0.BcsStruct<{
420
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
421
- size: BcsType<string, string | number | bigint, "u64">;
422
- }, string>;
423
- tick_bitmap: _mysten_bcs0.BcsStruct<{
424
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
425
- size: BcsType<string, string | number | bigint, "u64">;
426
- }, string>;
427
- }, string>;
428
- declare const VaultTick: _mysten_bcs0.BcsStruct<{
429
- is_liquidated: BcsType<boolean, boolean, "bool">;
430
- total_ids: BcsType<number, number, "u32">;
431
- raw_debt: BcsType<string, string | number | bigint, "u64">;
432
- is_fully_liquidated: BcsType<boolean, boolean, "bool">;
433
- liquidation_branch_id: BcsType<string, string | number | bigint, "u64">;
434
- debt_factor: BcsType<string, string | number | bigint, "u64">;
435
- }, string>;
436
- declare const TickIdLiquidation: _mysten_bcs0.BcsStruct<{
437
- is_fully_liquidated: BcsType<boolean, boolean, "bool">;
438
- liquidation_branch_id: BcsType<string, string | number | bigint, "u64">;
439
- debt_factor: BcsType<string, string | number | bigint, "u64">;
440
- }, string>;
441
- declare const TickIdLiquidationKey: _mysten_bcs0.BcsStruct<{
442
- tick: _mysten_bcs0.BcsStruct<{
443
- mag: BcsType<number, number, "u32">;
444
- neg: BcsType<boolean, boolean, "bool">;
445
- }, string>;
446
- tick_map: BcsType<number, number, "u32">;
447
- }, string>;
448
- declare const BranchStatus: _mysten_bcs0.BcsEnum<{
449
- NotLiquidated: null;
450
- Liquidated: null;
451
- Merged: null;
452
- Closed: null;
453
- }, "BranchStatus">;
454
- declare const Branch: _mysten_bcs0.BcsStruct<{
455
- status: _mysten_bcs0.BcsEnum<{
456
- NotLiquidated: null;
457
- Liquidated: null;
458
- Merged: null;
459
- Closed: null;
460
- }, "BranchStatus">;
461
- minima_tick: _mysten_bcs0.BcsStruct<{
462
- mag: BcsType<number, number, "u32">;
463
- neg: BcsType<boolean, boolean, "bool">;
464
- }, string>;
465
- minima_tick_partials: BcsType<number, number, "u32">;
466
- debt_liquidity: BcsType<string, string | number | bigint, "u64">;
467
- debt_factor: BcsType<string, string | number | bigint, "u64">;
468
- connected_branch_id: BcsType<string, string | number | bigint, "u64">;
469
- connected_minima_tick: _mysten_bcs0.BcsStruct<{
470
- mag: BcsType<number, number, "u32">;
471
- neg: BcsType<boolean, boolean, "bool">;
472
- }, string>;
473
- }, string>;
474
- declare const Position: _mysten_bcs0.BcsStruct<{
475
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
476
- vault_id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
477
- position_mint: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
478
- is_supply_only_position: BcsType<boolean, boolean, "bool">;
479
- tick: _mysten_bcs0.BcsStruct<{
480
- mag: BcsType<number, number, "u32">;
481
- neg: BcsType<boolean, boolean, "bool">;
482
- }, string>;
483
- tick_id: BcsType<number, number, "u32">;
484
- supply_amount: BcsType<string, string | number | bigint, "u64">;
485
- dust_debt_amount: BcsType<string, string | number | bigint, "u64">;
486
- }, string>;
487
- declare const VaultRegistry: _mysten_bcs0.BcsStruct<{
488
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
489
- next_vault_id: BcsType<string, string | number | bigint, "u64">;
490
- version: BcsType<string, string | number | bigint, "u64">;
491
- }, string>;
492
- declare const AdminOracle$1: _mysten_bcs0.BcsStruct<{
493
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
494
- name: BcsType<string, string, "string">;
495
- rate: BcsType<string, string | number | bigint, "u128">;
496
- version: BcsType<string, string | number | bigint, "u64">;
497
- }, string>;
498
- declare const OracleRegistry: _mysten_bcs0.BcsStruct<{
499
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
500
- version: BcsType<string, string | number | bigint, "u64">;
501
- total_oracles: BcsType<string, string | number | bigint, "u64">;
502
- }, string>;
503
- declare const PriceQuote: _mysten_bcs0.BcsStruct<{
504
- oracle_id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
505
- rate_liquidate: BcsType<string, string | number | bigint, "u128">;
506
- rate_operate: BcsType<string, string | number | bigint, "u128">;
507
- }, string>;
508
- declare const OracleSourceType: _mysten_bcs0.BcsEnum<{
509
- Redstone: _mysten_bcs0.BcsStruct<{
510
- adapter_id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
511
- }, string>;
512
- Pyth: null;
513
- }, "SourceType">;
514
- declare const OracleSource: _mysten_bcs0.BcsStruct<{
515
- feed_id: BcsType<number[], Iterable<number> & {
516
- length: number;
517
- }, string>;
518
- invert: BcsType<boolean, boolean, "bool">;
519
- source_type: _mysten_bcs0.BcsEnum<{
520
- Redstone: _mysten_bcs0.BcsStruct<{
521
- adapter_id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
522
- }, string>;
523
- Pyth: null;
524
- }, "SourceType">;
525
- }, string>;
526
- /** `fluid_oracle::oracle::Oracle` (v2): derived from the registry by nonce. */
527
- declare const OracleV2$1: _mysten_bcs0.BcsStruct<{
528
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
529
- nonce: BcsType<number, number, "u16">;
530
- main: _mysten_bcs0.BcsStruct<{
531
- feed_id: BcsType<number[], Iterable<number> & {
532
- length: number;
533
- }, string>;
534
- invert: BcsType<boolean, boolean, "bool">;
535
- source_type: _mysten_bcs0.BcsEnum<{
536
- Redstone: _mysten_bcs0.BcsStruct<{
537
- adapter_id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
538
- }, string>;
539
- Pyth: null;
540
- }, "SourceType">;
541
- }, string>;
542
- guard: BcsType<{
543
- feed_id: number[];
544
- invert: boolean;
545
- source_type: _mysten_bcs0.EnumOutputShapeWithKeys<{
546
- Redstone: {
547
- adapter_id: string;
548
- };
549
- Pyth: true;
550
- }, "Redstone" | "Pyth">;
551
- } | null, {
552
- feed_id: Iterable<number> & {
553
- length: number;
554
- };
555
- invert: boolean;
556
- source_type: _mysten_bcs0.EnumInputShape<{
557
- Redstone: {
558
- adapter_id: string | Uint8Array<ArrayBufferLike>;
559
- };
560
- Pyth: boolean | object | null;
561
- }>;
562
- } | null | undefined, `Option<${string}>`>;
563
- }, string>;
564
- /** v2 `view::PriceQuote`: each rate is optional (operate-only / liquidate-only quotes). */
565
- declare const PriceQuoteV2: _mysten_bcs0.BcsStruct<{
566
- oracle_id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
567
- rate_liquidate: BcsType<string | null, string | number | bigint | null | undefined, "Option<u128>">;
568
- rate_operate: BcsType<string | null, string | number | bigint | null | undefined, "Option<u128>">;
569
- }, string>;
570
- /** `pyth::price_info::PriceInfoObject`. */
571
- declare const PythPriceInfoObject: _mysten_bcs0.BcsStruct<{
572
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
573
- price_info: _mysten_bcs0.BcsStruct<{
574
- attestation_time: BcsType<string, string | number | bigint, "u64">;
575
- arrival_time: BcsType<string, string | number | bigint, "u64">;
576
- price_feed: _mysten_bcs0.BcsStruct<{
577
- price_identifier: _mysten_bcs0.BcsStruct<{
578
- bytes: BcsType<number[], Iterable<number> & {
579
- length: number;
580
- }, string>;
581
- }, string>;
582
- price: _mysten_bcs0.BcsStruct<{
583
- price: _mysten_bcs0.BcsStruct<{
584
- negative: BcsType<boolean, boolean, "bool">;
585
- magnitude: BcsType<string, string | number | bigint, "u64">;
586
- }, string>;
587
- conf: BcsType<string, string | number | bigint, "u64">;
588
- expo: _mysten_bcs0.BcsStruct<{
589
- negative: BcsType<boolean, boolean, "bool">;
590
- magnitude: BcsType<string, string | number | bigint, "u64">;
591
- }, string>;
592
- timestamp: BcsType<string, string | number | bigint, "u64">;
593
- }, string>;
594
- ema_price: _mysten_bcs0.BcsStruct<{
595
- price: _mysten_bcs0.BcsStruct<{
596
- negative: BcsType<boolean, boolean, "bool">;
597
- magnitude: BcsType<string, string | number | bigint, "u64">;
598
- }, string>;
599
- conf: BcsType<string, string | number | bigint, "u64">;
600
- expo: _mysten_bcs0.BcsStruct<{
601
- negative: BcsType<boolean, boolean, "bool">;
602
- magnitude: BcsType<string, string | number | bigint, "u64">;
603
- }, string>;
604
- timestamp: BcsType<string, string | number | bigint, "u64">;
605
- }, string>;
606
- }, string>;
607
- }, string>;
608
- }, string>;
609
- /** `0x2::dynamic_field::Field<K, V>` wrapper. */
610
- declare function Field<K, KI, V, VI>(name: BcsType<K, KI>, value: BcsType<V, VI>): _mysten_bcs0.BcsStruct<{
611
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
612
- name: BcsType<K, KI, string>;
613
- value: BcsType<V, VI, string>;
614
- }, string>;
615
- declare const bcsU64: BcsType<string, string | number | bigint, "u64">;
616
- declare const bcsU16: BcsType<number, number, "u16">;
617
- declare const bcsU256: BcsType<string, string | number | bigint, "u256">;
618
- declare const bcsId: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
619
- /** Unit key struct (`RateDataKey`, `RewardsKey`, ...): BCS `dummy_field: bool`. */
620
- declare const UnitKey: BcsType<boolean, boolean, "bool">;
621
- /** Proposed `fluid_vaults::position_index::PositionIndex` (docs/onchain-position-index.md). */
622
- declare const PositionIndex$1: _mysten_bcs0.BcsStruct<{
623
- next_position_id: BcsType<string, string | number | bigint, "u64">;
624
- caps: _mysten_bcs0.BcsStruct<{
625
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
626
- size: BcsType<string, string | number | bigint, "u64">;
627
- }, string>;
628
- ordinals: _mysten_bcs0.BcsStruct<{
629
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
630
- size: BcsType<string, string | number | bigint, "u64">;
631
- }, string>;
632
- }, string>;
633
- declare const PositionIndexField: _mysten_bcs0.BcsStruct<{
634
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
635
- name: BcsType<boolean, boolean, string>;
636
- value: BcsType<{
637
- next_position_id: string;
638
- caps: {
639
- id: string;
640
- size: string;
641
- };
642
- ordinals: {
643
- id: string;
644
- size: string;
645
- };
646
- }, {
647
- next_position_id: string | number | bigint;
648
- caps: {
649
- id: string | Uint8Array<ArrayBufferLike>;
650
- size: string | number | bigint;
651
- };
652
- ordinals: {
653
- id: string | Uint8Array<ArrayBufferLike>;
654
- size: string | number | bigint;
655
- };
656
- }, string>;
657
- }, string>;
658
- /** `caps: Table<u64, ID>` entry: ordinal -> PositionOwnerCap id. */
659
- declare const PositionIndexEntry: _mysten_bcs0.BcsStruct<{
660
- id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
661
- name: BcsType<string, string | number | bigint, string>;
662
- value: BcsType<string, string | Uint8Array<ArrayBufferLike>, string>;
663
- }, string>;
664
- //#endregion
665
- //#region src/types.d.ts
666
- /**
667
- * Public types. Field names match `@jup-ag/lend-read` one-for-one wherever the protocol
668
- * concept is the same; differences:
669
- * - `PublicKey` → `string` (a Sui object id, or a coin type for tokens)
670
- * - `BN` → `bigint`
671
- * - Solana `nftId: number` → Sui `positionId: string` (+ `capId`, the PositionOwnerCap)
672
- */
673
- type RateDataV1 = {
674
- token: string;
675
- rateAtUtilizationZero: bigint;
676
- kink: bigint;
677
- rateAtUtilizationKink: bigint;
678
- rateAtUtilizationMax: bigint;
679
- };
680
- type RateDataV2 = {
681
- token: string;
682
- rateAtUtilizationZero: bigint;
683
- kink1: bigint;
684
- rateAtUtilizationKink1: bigint;
685
- kink2: bigint;
686
- rateAtUtilizationKink2: bigint;
687
- rateAtUtilizationMax: bigint;
688
- };
689
- type RateData = {
690
- token: string;
691
- /** 0 = unset, 1 = V1, 2 = V2 (`TokenReserve.rate_data_version`). */
692
- version: number;
693
- rateDataV1: RateDataV1;
694
- rateDataV2: RateDataV2;
695
- };
696
- type RateModelAccount = {
697
- mint: string;
698
- version: number;
699
- rateAtUtilizationZero: bigint;
700
- kink?: bigint;
701
- rateAtUtilizationKink?: bigint;
702
- kink1?: bigint;
703
- rateAtUtilizationKink1?: bigint;
704
- kink2?: bigint;
705
- rateAtUtilizationKink2?: bigint;
706
- rateAtUtilizationMax: bigint;
707
- };
708
- type ExchangePricesAndConfig = {
709
- supplyExchangePrice: bigint;
710
- borrowExchangePrice: bigint;
711
- borrowRate: bigint;
712
- fee: bigint;
713
- lastStoredUtilization: bigint;
714
- lastUpdateTimestamp: bigint;
715
- maxUtilization: bigint;
716
- };
717
- type TotalAmounts = {
718
- supplyRawInterest: bigint;
719
- supplyInterestFree: bigint;
720
- borrowRawInterest: bigint;
721
- borrowInterestFree: bigint;
722
- /** Solana-only concept (claim accounts); always 0 on Sui. */
723
- totalClaimAmount: bigint;
724
- };
725
- type ExchangePriceResult = {
726
- supplyExchangePrice: bigint;
727
- borrowExchangePrice: bigint;
728
- };
729
- type OverallTokenData = {
730
- rateData: RateData;
731
- supplyExchangePrice: bigint;
732
- borrowExchangePrice: bigint;
733
- borrowRate: bigint;
734
- fee: bigint;
735
- lastStoredUtilization: bigint;
736
- lastUpdateTimestamp: bigint;
737
- maxUtilization: bigint;
738
- supplyRawInterest: bigint;
739
- supplyInterestFree: bigint;
740
- borrowRawInterest: bigint;
741
- borrowInterestFree: bigint;
742
- totalSupply: bigint;
743
- totalBorrow: bigint;
744
- revenue: bigint;
745
- supplyRate: bigint;
746
- };
747
- type UserSupplyPositionAccount = {
748
- user: string;
749
- mint: string;
750
- amount: bigint;
751
- withdrawalLimit: bigint;
752
- baseWithdrawalLimit: bigint;
753
- lastUpdateTimestamp: bigint;
754
- expandPercent: bigint;
755
- expandDuration: bigint;
756
- modeWithInterest: boolean;
757
- decayAmount: bigint;
758
- decayDuration: bigint;
759
- /** Sui extras. */
760
- configured: boolean;
761
- pausedSupply: boolean;
762
- pausedWithdraw: boolean;
763
- };
764
- type UserBorrowPositionAccount = {
765
- user: string;
766
- mint: string;
767
- amount: bigint;
768
- borrowLimit: bigint;
769
- baseBorrowLimit: bigint;
770
- maxBorrowLimit: bigint;
771
- lastUpdateTimestamp: bigint;
772
- expandPercent: bigint;
773
- expandDuration: bigint;
774
- modeWithInterest: boolean;
775
- /** Sui extras. */
776
- configured: boolean;
777
- pausedBorrow: boolean;
778
- pausedPayback: boolean;
779
- };
780
- type UserSupplyData = {
781
- modeWithInterest: boolean;
782
- supply: bigint;
783
- withdrawalLimit: bigint;
784
- lastUpdateTimestamp: bigint;
785
- expandPercent: bigint;
786
- expandDuration: bigint;
787
- baseWithdrawalLimit: bigint;
788
- withdrawableUntilLimit: bigint;
789
- withdrawable: bigint;
790
- decayAmount: bigint;
791
- decayEndTimestamp: bigint;
792
- };
793
- type UserBorrowData = {
794
- modeWithInterest: boolean;
795
- borrow: bigint;
796
- borrowLimit: bigint;
797
- lastUpdateTimestamp: bigint;
798
- expandPercent: bigint;
799
- expandDuration: bigint;
800
- baseBorrowLimit: bigint;
801
- maxBorrowLimit: bigint;
802
- borrowLimitUtilization: bigint;
803
- borrowableUntilLimit: bigint;
804
- borrowable: bigint;
805
- };
806
- type LiquidityAccount = {
807
- id: string;
808
- version: bigint;
809
- revenueCollector: string;
810
- /** Global pause flags (true = paused). */
811
- status: {
812
- supply: boolean;
813
- borrow: boolean;
814
- payback: boolean;
815
- withdraw: boolean;
816
- };
817
- activeCapsTableId: string;
818
- activeCapsCount: bigint;
819
- };
820
- /** fToken = the lending (share) token on Sui, `Coin<FToken<T>>` (Solana calls it jlToken). */
821
- type FTokenDetails = {
822
- /** Sui: `FToken<T>` coin type. */
823
- tokenAddress: string;
824
- /** Sui: the `LendingState<T>` object id. */
825
- lendingStateId: string;
826
- name: string;
827
- symbol: string;
828
- decimals: number;
829
- underlyingAddress: string;
830
- totalAssets: bigint;
831
- totalSupply: bigint;
832
- conversionRateToShares: bigint;
833
- conversionRateToAssets: bigint;
834
- rewardsRate: bigint;
835
- supplyRate: bigint;
836
- rebalanceDifference: bigint;
837
- userSupplyData: UserSupplyData;
838
- };
839
- /** @deprecated Solana name; use `FTokenDetails`. */
840
- type JlTokenDetails = FTokenDetails;
841
- type LendingUserPosition = {
842
- /** fToken shares held (`Coin<FToken<T>>` balance). */
843
- fTokenShares: bigint;
844
- underlyingAssets: bigint;
845
- underlyingBalance: bigint;
846
- /** No allowances on Sui (coins are owned objects); always 0. */
847
- allowance: bigint;
266
+ type LendingUserPosition = {
267
+ /** fToken shares held (`Coin<FToken<T>>` balance). */
268
+ fTokenShares: bigint;
269
+ underlyingAssets: bigint;
270
+ underlyingBalance: bigint;
848
271
  };
849
272
  type FTokenDetailsUserPosition = {
850
273
  fTokenDetails: FTokenDetails;
@@ -859,7 +282,7 @@ type RewardsRateModelConfig = {
859
282
  startTvl: bigint;
860
283
  maxRate: bigint;
861
284
  rewardAmount: bigint;
862
- /** Sui extras: the queued next schedule. */
285
+ /** Sui extras: the queued next schedule. `maxRate` is bps (5000 = the 50% cap). */
863
286
  nextStartTime: bigint;
864
287
  nextEndTime: bigint;
865
288
  nextRewardAmount: bigint;
@@ -877,8 +300,6 @@ type FTokenInternalData = {
877
300
  lendingFactory: string;
878
301
  /** Sui: rewards writer cap id, if one is installed. */
879
302
  lendingRewardsRateModel: string | null;
880
- /** No rebalancer account on Sui LendingState; empty string. */
881
- rebalancer: string;
882
303
  liquidityBalance: bigint;
883
304
  liquidityExchangePrice: bigint;
884
305
  tokenExchangePrice: bigint;
@@ -918,8 +339,6 @@ type Configs = {
918
339
  liquidationPenalty: bigint;
919
340
  borrowFee: bigint;
920
341
  oracle: string;
921
- /** No per-vault rebalancer field on Sui (role lives in VaultAdmin); empty string. */
922
- rebalancer: string;
923
342
  oraclePriceOperate?: bigint;
924
343
  oraclePriceLiquidate?: bigint;
925
344
  lastUpdateTimestamp?: bigint;
@@ -1004,7 +423,6 @@ type VaultConfig = {
1004
423
  liquidationPenalty: number;
1005
424
  borrowFee: number;
1006
425
  oracle: string;
1007
- rebalancer: string;
1008
426
  liquidityProgram: string;
1009
427
  oracleProgram: string;
1010
428
  supplyToken: string;
@@ -1096,102 +514,826 @@ type DecodedBranch = {
1096
514
  connectedBranchId: number;
1097
515
  connectedMinimaTick: number;
1098
516
  };
1099
- type DecodedTickIdLiquidation = {
1100
- isFullyLiquidated: boolean;
1101
- liquidationBranchId: number;
1102
- debtFactor: bigint;
517
+ type DecodedTickIdLiquidation = {
518
+ isFullyLiquidated: boolean;
519
+ liquidationBranchId: number;
520
+ debtFactor: bigint;
521
+ };
522
+ type PositionWithRiskRatio = NftPosition & {
523
+ vaultId: number;
524
+ /** debt / (collateral * oracle price), 1e4 scale (e.g. 7500 = 75%). */
525
+ riskRatio: bigint;
526
+ };
527
+ type OraclePrice = {
528
+ oracle: string;
529
+ /** Collateral-per-debt price used on operate (1e15). `null` = the operate view aborts right now (v2: a route stale/invalid). */
530
+ operate: bigint | null;
531
+ /** Price used on liquidate (1e15). `null` = the liquidate view aborts (v2: every route dead). */
532
+ liquidate: bigint | null;
533
+ /** v2: abort reason of the operate view, when `operate` is null. */
534
+ operateError?: string;
535
+ liquidateError?: string;
536
+ };
537
+ type OracleSource = {
538
+ /** 0x-hex 32-byte feed id. */
539
+ feedId: string;
540
+ invert: boolean;
541
+ provider: "redstone" | "pyth";
542
+ /** RedStone only: the PriceAdapter the oracle is pinned to. */
543
+ adapterId?: string;
544
+ };
545
+ type OracleData = {
546
+ id: string;
547
+ nonce: number;
548
+ main: OracleSource;
549
+ guard: OracleSource | null;
550
+ };
551
+ /** One route read on its own (see `Oracle.getOracleRoutes`). */
552
+ type OracleRoute = OracleSource & {
553
+ rawPrice: bigint;
554
+ decimals: number;
555
+ /** 1e15 rate this route contributes (0 when invalid). */
556
+ rate: bigint;
557
+ publishedMs: bigint;
558
+ /** Seconds since publish at the chain clock (-1 = timestamp in the future). */
559
+ ageS: bigint;
560
+ /** Pyth only. */
561
+ confidence?: bigint;
562
+ usableOperate: boolean;
563
+ usableLiquidate: boolean;
564
+ };
565
+ declare namespace liquidity_d_exports {
566
+ export { MathVariant, ReserveSnapshot, calcBorrowLimitBeforeOperate, calcRevenue, calcWithdrawalLimitBeforeOperate, calculateExchangePrice, emptyUserBorrowData, emptyUserSupplyData, processOverallTokenData, processUserBorrowData, processUserSupplyData, supplyRateAt, supplyRateRaw, totalAmountsOf, totalBorrowNormal, totalSupplyNormal };
567
+ }
568
+ /** The TokenReserve fields the exchange-price maths needs. */
569
+ type ReserveSnapshot = {
570
+ supplyExchangePrice: bigint;
571
+ borrowExchangePrice: bigint;
572
+ borrowRate: bigint;
573
+ fee: bigint;
574
+ lastUtilization: bigint;
575
+ lastUpdateTimestamp: bigint;
576
+ maxUtilization: bigint;
577
+ totalSupplyWithInterest: bigint;
578
+ totalSupplyInterestFree: bigint;
579
+ totalBorrowWithInterest: bigint;
580
+ totalBorrowInterestFree: bigint;
581
+ /** Coin balance held by the reserve. */
582
+ vaultBalance: bigint;
583
+ };
584
+ /**
585
+ * Which on-chain liquidity/lending maths a deployment runs.
586
+ * - "audited": fluid-packages-sui after the audit fixes (7e470fb, in 742ea21 and later): the
587
+ * borrow with-interest/free ratio uses the PRE-accrual borrow exchange price, the inverted
588
+ * supply ratio is computed at full precision, and the rewards TVL is rounded up.
589
+ * - "pre-audit": the 2026-09-18 staging packages (verified from deployed bytecode 2026-10-26):
590
+ * ratio on the accrued borrow price, inverse of the floored 1e4 ratio, rewards TVL floored.
591
+ */
592
+ type MathVariant = "pre-audit" | "audited";
593
+ /**
594
+ * Supply rate the reserve credits for a period starting from these exchange prices, at
595
+ * `SUPPLY_RATE_PRECISION` (1e12 = 100% per year): exactly `borrow_rate * ratio_supply_yield * (1e4 - fee)`
596
+ * from `reserve::calculate_exchange_prices` (interest-free ratios on both sides, fee applied).
597
+ * `borrowEpForRatio` is the borrow exchange price the contract normalises the borrow ratio with.
598
+ */
599
+ declare function supplyRateRaw(r: ReserveSnapshot, supplyExchangePrice: bigint, borrowEpForRatio: bigint, variant: MathVariant): bigint;
600
+ /** `reserve::calculate_exchange_prices(now)`. */
601
+ declare function calculateExchangePrice(r: ReserveSnapshot, now: bigint, variant?: MathVariant): ExchangePriceResult;
602
+ /**
603
+ * Instantaneous liquidity supply rate at `now` (1e12 = 100%): the rate the contract would credit
604
+ * for the period starting at `now`, i.e. `supplyRateRaw` on both exchange prices accrued to `now`.
605
+ */
606
+ declare function supplyRateAt(r: ReserveSnapshot, now: bigint, variant?: MathVariant): bigint;
607
+ /** `liquidity_calcs::get_total_supply` (floor). */
608
+ declare const totalSupplyNormal: (r: ReserveSnapshot, supplyEp: bigint) => bigint;
609
+ /** `liquidity_calcs::get_total_borrow` (floor). */
610
+ declare const totalBorrowNormal: (r: ReserveSnapshot, borrowEp: bigint) => bigint;
611
+ /** `reserve::calc_revenue` (supply side ceiled, saturating at 0). */
612
+ declare function calcRevenue(r: ReserveSnapshot, supplyEp: bigint, borrowEp: bigint): bigint;
613
+ declare function totalAmountsOf(r: ReserveSnapshot): TotalAmounts;
614
+ /**
615
+ * Same shape as the Solana reader's `processOverallTokenData`. `supplyRate` (bps) is the exact
616
+ * on-chain supply rate at `now` (`supplyRateAt`, floored to bps), not the Solana approximation.
617
+ */
618
+ declare function processOverallTokenData(r: ReserveSnapshot, rateData: RateData, now: bigint, variant?: MathVariant): OverallTokenData;
619
+ /** `liquidity_calcs::calc_withdrawal_limit_before_operate`. */
620
+ declare function calcWithdrawalLimitBeforeOperate(userAmount: bigint, lastLimit: bigint, expandPercent: bigint, expandDuration: bigint, lastUpdate: bigint, now: bigint): bigint;
621
+ /** `liquidity_calcs::calc_borrow_limit_before_operate`. */
622
+ declare function calcBorrowLimitBeforeOperate(userAmount: bigint, lastLimit: bigint, expandPercent: bigint, expandDuration: bigint, baseLimit: bigint, maxLimit: bigint, lastUpdate: bigint, now: bigint): bigint;
623
+ declare function emptyUserSupplyData(): UserSupplyData;
624
+ declare function emptyUserBorrowData(): UserBorrowData;
625
+ /** Solana `processUserSupplyData`, with Sui's decay fields. */
626
+ declare function processUserSupplyData(acc: UserSupplyPositionAccount | null, overall: OverallTokenData, liquidityBalance: bigint, now: bigint): UserSupplyData;
627
+ /** Solana `processUserBorrowData`. */
628
+ declare function processUserBorrowData(acc: UserBorrowPositionAccount | null, overall: OverallTokenData, liquidityBalance: bigint, now: bigint): UserBorrowData;
629
+ //#endregion
630
+ //#region src/config.d.ts
631
+ type PackageIds = {
632
+ /** Latest version: target of move calls (views). */
633
+ packageId: string;
634
+ /** First version: address used in type tags and derived-object keys. */
635
+ originalId: string;
636
+ };
637
+ type FluidReadConfig = {
638
+ network: string;
639
+ packages: {
640
+ library: PackageIds;
641
+ liquidity: PackageIds;
642
+ lending: PackageIds;
643
+ /** Optional: lending rewards package (write-SDK parity; no read views depend on it yet). */
644
+ lendingRewards?: PackageIds;
645
+ oracle: PackageIds;
646
+ vaults: PackageIds;
647
+ };
648
+ objects: {
649
+ liquidityRegistry: string;
650
+ lendingRegistry: string;
651
+ oracleRegistry: string;
652
+ vaultRegistry: string;
653
+ liquidityAuth?: string;
654
+ lendingAuth?: string;
655
+ rewardsAuth?: string;
656
+ oracleAuth?: string;
657
+ vaultAdmin?: string;
658
+ };
659
+ /** RedStone main + optional Pyth guard; provider objects the quote needs. Pyth PriceInfoObjects keyed by 0x-hex feed id. */
660
+ oracle?: {
661
+ /** RedStone adapter used when an oracle has no RedStone route (the call still takes one). */
662
+ redstoneAdapter: string;
663
+ /** Package to call RedStone views on (route transparency only). */
664
+ redstonePackage: string;
665
+ pythPriceInfoObjects: Record<string, string>;
666
+ /** Pyth State + Wormhole State (write-SDK parity, needed only to build a Pyth price update). */
667
+ pythStateId?: string;
668
+ wormholeStateId?: string;
669
+ };
670
+ /**
671
+ * Coin types seeded into token discovery. Token discovery is pure state: these, plus the
672
+ * collateral/debt types of every VaultMarket (vault ids 1..total_vaults from the registry).
673
+ * Coverage is checked against `Registry.active_caps.size`; see `Liquidity.discoverTokens`.
674
+ */
675
+ tokens?: string[];
676
+ /** Fullnode endpoints, tried in order with failover. "jsonrpc+https://..." selects JSON-RPC. */
677
+ rpcUrls?: string[];
678
+ /**
679
+ * Type of the proposed on-chain position-index key (docs/onchain-position-index.md). A struct
680
+ * added in a package upgrade is defined at the upgraded package id, so set this to
681
+ * `<upgraded vaults package>::position_index::PositionIndexKey` once it ships. Default assumes
682
+ * `<vaults originalId>::position_index::PositionIndexKey`.
683
+ */
684
+ positionIndexKeyType?: string;
685
+ /** GraphQL indexer endpoint. Used with `discovery: "indexer"`, holder lists and checkpoint reads. */
686
+ graphqlUrl?: string;
687
+ /**
688
+ * On-chain maths the deployment runs (see `MathVariant`). Default "audited" (fluid-packages-sui
689
+ * 742ea21 and later). The 2026-09-18 staging liquidity/lending packages run "pre-audit".
690
+ */
691
+ mathVariant?: MathVariant;
692
+ };
693
+ /**
694
+ * STAGING deployment on Sui mainnet (staging deployment gist, 2026-09-30). NOT a final production
695
+ * deployment: ids change at the production launch. Build
696
+ * your own config from a deployment record with `configFromDeployment`.
697
+ *
698
+ * Fluid Sui staging-on-mainnet: library / liquidity / lending
699
+ * from 2026-09-18; oracle (RedStone main + Pyth guard) and vaults redeployed 2026-09-30.
700
+ * Vault 1 = VaultMarket<SUI, USDC> 0x3ba55ebc…72b8 on oracle nonce 1 (0x1a690d20…b279).
701
+ * Vault 2 = VaultMarket<SUI, USDSUI> 0x5120…0efa. fTokens: fUSDC, fUSDSUI.
702
+ * Ids match the write SDK (fluid-packages-sui deployments/mainnet.json @ 06828ff, 2026-10-01) and
703
+ * the live staging deployment (re-read on chain 2026-10-10). Alias: network "staging".
704
+ */
705
+ declare const STAGING: FluidReadConfig;
706
+ /**
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".
711
+ */
712
+ declare const PROD: FluidReadConfig;
713
+ declare const MAINNET: FluidReadConfig;
714
+ declare const CONFIGS: Record<string, FluidReadConfig>;
715
+ /**
716
+ * Deployment record: per-package ids plus the shared object ids the SDK reads. The ids alone are
717
+ * not enough: `liquidity`, `lending`, `oracle` and `vaults` must each carry `objects.registry`
718
+ * (see "Deployment record shape" in the README).
719
+ */
720
+ type DeploymentRecord = {
721
+ packages: Record<"library" | "liquidity" | "lending" | "oracle" | "vaults" | "lending_rewards", {
722
+ packageId: string;
723
+ originalId?: string;
724
+ objects?: Record<string, string>;
725
+ } | undefined>;
1103
726
  };
1104
- type PositionWithRiskRatio = NftPosition & {
1105
- vaultId: number;
1106
- /** debt / (collateral * oracle price), 1e4 scale (e.g. 7500 = 75%). */
1107
- riskRatio: bigint;
727
+ /**
728
+ * Build a read config from a deployment record instead of the built-in ids, e.g.
729
+ * `configFromDeployment(JSON.parse(readFileSync(path, "utf8")), { network: "mainnet", oracle })`.
730
+ * The record has no RedStone package or Pyth feed map, so `oracle` comes from the caller.
731
+ * Throws once, listing every required field the record is missing.
732
+ */
733
+ declare function configFromDeployment(rec: DeploymentRecord, opts: Pick<FluidReadConfig, "network" | "oracle"> & Partial<Pick<FluidReadConfig, "tokens" | "rpcUrls" | "graphqlUrl" | "mathVariant">>): FluidReadConfig;
734
+ declare function resolveConfig(networkOrConfig: string | FluidReadConfig | undefined): FluidReadConfig;
735
+ //#endregion
736
+ //#region src/derive.d.ts
737
+ declare function createDerive(cfg: FluidReadConfig): {
738
+ /** `TokenReserve<T>`: derived from the liquidity Registry, key `ReserveKey<T>`. */
739
+ tokenReserveId: (coinType: string) => string;
740
+ /** `LendingState<T>`: derived from the LendingRegistry, key `LendingStateKey<T>`. */
741
+ lendingStateId: (coinType: string) => string;
742
+ /** `VaultMarket<Col, Debt>`: derived from the VaultRegistry, key `VaultKey(u64)`. */
743
+ vaultMarketId: (vaultId: number | bigint) => string;
744
+ /** `Position`: derived from its VaultMarket, key `PositionKey(cap id)`. */
745
+ positionId: (vaultMarketId: string, capId: string) => string;
746
+ holderKeyType: string;
747
+ /** Entry of `TokenReserve.supply_positions` / `borrow_positions` for `Holder::Object(id)`. */
748
+ holderEntryId: (tableId: string, holderObjectId: string) => string;
749
+ /** `RateDataKey` dynamic field on a TokenReserve. */
750
+ rateDataId: (reserveId: string) => string;
751
+ /** `RewardsKey` dynamic field on a LendingState. */
752
+ rewardsId: (lendingStateId: string) => string;
753
+ /** `VaultMarket.ticks` entry. */
754
+ tickEntryId: (ticksTableId: string, tick: number) => string;
755
+ /** `VaultMarket.branches` entry. */
756
+ branchEntryId: (branchesTableId: string, branchId: number | bigint | string) => string;
757
+ /** `VaultMarket.liq_snaps` entry. */
758
+ liqSnapEntryId: (snapsTableId: string, tick: number, tickId: number) => string;
759
+ /** `VaultMarket.tick_bitmap` word. */
760
+ bitmapWordId: (bitmapTableId: string, word: number) => string;
761
+ /**
762
+ * Proposed on-chain position index (docs/onchain-position-index.md): dynamic field
763
+ * `PositionIndexKey()` on the VaultMarket. Returns null-safe ids; absent until shipped.
764
+ */
765
+ positionIndexKeyType: string;
766
+ positionIndexId: (vaultMarketId: string) => string;
767
+ /** Entry `n` (1-based ordinal) of the index's `caps: Table<u64, ID>`. */
768
+ positionIndexEntryId: (capsTableId: string, n: number | bigint) => string;
769
+ /** v2 `Oracle`: derived from the OracleRegistry, key `OracleKey(nonce: u16)`; nonces 1..total_oracles. */
770
+ oracleId: (nonce: number) => string;
771
+ fTokenType: (coinType: string) => string;
772
+ positionCapType: string;
1108
773
  };
1109
- type OraclePrice = {
1110
- oracle: string;
1111
- /** Collateral-per-debt price used on operate (1e15). `null` = the operate view aborts right now (v2: a route stale/invalid). */
1112
- operate: bigint | null;
1113
- /** Price used on liquidate (1e15). `null` = the liquidate view aborts (v2: every route dead). */
1114
- liquidate: bigint | null;
1115
- /** "v2": RedStone main + Pyth guard. "admin": stored admin-set rate (2026-09-18 preset). */
1116
- source: "admin" | "v2";
1117
- /** v2: abort reason of the operate view, when `operate` is null. */
1118
- operateError?: string;
1119
- liquidateError?: string;
774
+ type FluidDerive = ReturnType<typeof createDerive>;
775
+ //#endregion
776
+ //#region src/context.d.ts
777
+ /**
778
+ * Where time-dependent maths gets "now" from.
779
+ * - "chain" (default): the on-chain Clock, read alongside the state (one extra object in the read).
780
+ * - "local": this machine's wall clock. Only for offline/back-testing use; elapsed time and the
781
+ * rewards windows then depend on the server's clock.
782
+ * - a function: fixed or custom clock (unix seconds), e.g. a checkpoint timestamp.
783
+ */
784
+ type ClockSource = "chain" | "local" | (() => bigint | Promise<bigint>);
785
+ /**
786
+ * How far the SDK may go beyond pure object state when it has to ENUMERATE something.
787
+ *
788
+ * - "state" (default): only reads of objects by derived id (`getObjects`) and Move view
789
+ * simulation. No list/scan queries of any kind. Anything that cannot be resolved this way
790
+ * throws `NeedsDiscoveryError` naming the on-chain change that would make it pure.
791
+ * - "fullnode": also the fullnode's own secondary indexes (`listDynamicFields`,
792
+ * `listOwnedObjects`). Same endpoint(s) as state reads, so failover covers them, but the
793
+ * node must run with indexing enabled.
794
+ * - "indexer": also the external GraphQL indexer (event scans). Last resort.
795
+ */
796
+ type DiscoveryLevel = "state" | "fullnode" | "indexer";
797
+ declare class NeedsDiscoveryError extends Error {
798
+ readonly what: string;
799
+ readonly needed: DiscoveryLevel;
800
+ readonly onchainFix: string;
801
+ constructor(what: string, needed: DiscoveryLevel, onchainFix: string);
802
+ }
803
+ /** Shared state every module reads through. */
804
+ type ReadContext = {
805
+ client: ClientWithCoreApi;
806
+ config: FluidReadConfig;
807
+ derive: FluidDerive;
808
+ /** Clock for time-dependent maths (unix seconds). Defaults to the on-chain Clock. */
809
+ now: () => Promise<bigint>;
810
+ discovery: DiscoveryLevel;
811
+ allows: (level: DiscoveryLevel) => boolean;
812
+ /** `config.mathVariant ?? "audited"`. */
813
+ math: MathVariant;
814
+ /** Coin metadata (immutable), fetched once per coin type and cached for the client's lifetime. */
815
+ coinMetadata: (coinType: string) => Promise<CoinMeta | null>;
1120
816
  };
1121
- type OracleV2Source = {
1122
- /** 0x-hex 32-byte feed id. */
1123
- feedId: string;
1124
- invert: boolean;
1125
- provider: "redstone" | "pyth";
1126
- /** RedStone only: the PriceAdapter the oracle is pinned to. */
1127
- adapterId?: string;
817
+ type CoinMeta = {
818
+ name: string;
819
+ symbol: string;
820
+ decimals: number;
1128
821
  };
1129
- type OracleV2 = {
1130
- id: string;
1131
- nonce: number;
1132
- main: OracleV2Source;
1133
- guard: OracleV2Source | null;
822
+ //#endregion
823
+ //#region src/transport.d.ts
824
+ type FailoverOptions = {
825
+ network: string;
826
+ /** Per-call timeout before moving to the next endpoint. Default 15000 ms. */
827
+ timeoutMs?: number;
828
+ /** Full passes over the endpoint list before giving up. Default 3. */
829
+ rounds?: number;
830
+ /** Wait before the second pass; doubles every pass. Default 250 ms. */
831
+ backoffMs?: number;
832
+ /** Cap on the wait between passes. Default 4000 ms. */
833
+ maxBackoffMs?: number;
1134
834
  };
1135
- /** One v2 route read on its own (see `Oracle.getOracleRoutes`). */
1136
- type OracleRoute = OracleV2Source & {
1137
- rawPrice: bigint;
1138
- decimals: number;
1139
- /** 1e15 rate this route contributes (0 when invalid). */
1140
- rate: bigint;
1141
- publishedMs: bigint;
1142
- /** Seconds since publish at the chain clock (-1 = timestamp in the future). */
1143
- ageS: bigint;
1144
- /** Pyth only. */
1145
- confidence?: bigint;
1146
- usableOperate: boolean;
1147
- usableLiquidate: boolean;
835
+ /** Wait before pass `pass` (1-based, pass >= 2): exponential, capped, +/-25% jitter. */
836
+ declare function backoffDelay(pass: number, base: number, cap: number): number;
837
+ declare class AllEndpointsFailedError extends Error {
838
+ readonly method: string;
839
+ readonly errors: {
840
+ endpoint: string;
841
+ error: unknown;
842
+ }[];
843
+ constructor(method: string, errors: {
844
+ endpoint: string;
845
+ error: unknown;
846
+ }[]);
847
+ }
848
+ declare function clientForEndpoint(endpoint: string, network: string): ClientWithCoreApi;
849
+ /**
850
+ * One `ClientWithCoreApi` over many endpoints. Accepts endpoint strings or ready clients
851
+ * (label = index). Synchronous core members (e.g. `resolveTransactionPlugin`) come from the
852
+ * currently preferred endpoint.
853
+ */
854
+ declare function createFailoverClient(endpoints: readonly (string | ClientWithCoreApi)[], opts: FailoverOptions): ClientWithCoreApi & {
855
+ endpoints: string[];
856
+ preferred: () => string;
1148
857
  };
1149
- type AdminOracle = {
1150
- id: string;
1151
- name: string;
1152
- rate: bigint;
1153
- version: bigint;
858
+ declare namespace bcs_d_exports {
859
+ export { Branch, BranchStatus, CapRecord, Field, Holder, LendingRegistry, LendingState, LiquidityRegistry, MoveTick, OracleObject, OracleRegistry, OracleSource$1 as OracleSource, OracleSourceType, PauseFlags, Position, PositionIndex$1 as PositionIndex, PositionIndexEntry, PositionIndexField, PriceQuote, PythPriceInfoObject, RateDataV1Params, RateDataV2Params, RateMagnifier, RewardsSchedule$1 as RewardsSchedule, RiskConfig, Table, TickIdLiquidation, TickIdLiquidationKey, TokenReserve, TypeName, UnitKey, UserBorrowConfig, UserBorrowPosition, UserSupplyConfig, UserSupplyPosition, VaultMarket, VaultRegistry, VaultTick, bcsId, bcsU16, bcsU256, bcsU64 };
860
+ }
861
+ declare const TypeName: _mysten_bcs0.BcsStruct<{
862
+ name: BcsType<string, string, "string">;
863
+ }, string>;
864
+ declare const MoveTick: _mysten_bcs0.BcsStruct<{
865
+ mag: BcsType<number, number, "u32">;
866
+ neg: BcsType<boolean, boolean, "bool">;
867
+ }, string>;
868
+ declare const Table: _mysten_bcs0.BcsStruct<{
869
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
870
+ size: BcsType<string, string | number | bigint, "u64">;
871
+ }, string>;
872
+ declare const PauseFlags: _mysten_bcs0.BcsStruct<{
873
+ supply: BcsType<boolean, boolean, "bool">;
874
+ borrow: BcsType<boolean, boolean, "bool">;
875
+ payback: BcsType<boolean, boolean, "bool">;
876
+ withdraw: BcsType<boolean, boolean, "bool">;
877
+ }, string>;
878
+ declare const Holder: _mysten_bcs0.BcsEnum<{
879
+ Object: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
880
+ Type: _mysten_bcs0.BcsStruct<{
881
+ name: BcsType<string, string, "string">;
882
+ }, string>;
883
+ }, "Holder">;
884
+ declare const LiquidityRegistry: _mysten_bcs0.BcsStruct<{
885
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
886
+ version: BcsType<string, string | number | bigint, "u64">;
887
+ pause: _mysten_bcs0.BcsStruct<{
888
+ supply: BcsType<boolean, boolean, "bool">;
889
+ borrow: BcsType<boolean, boolean, "bool">;
890
+ payback: BcsType<boolean, boolean, "bool">;
891
+ withdraw: BcsType<boolean, boolean, "bool">;
892
+ }, string>;
893
+ revenue_collector: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
894
+ active_caps: _mysten_bcs0.BcsStruct<{
895
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
896
+ size: BcsType<string, string | number | bigint, "u64">;
897
+ }, string>;
898
+ }, string>;
899
+ declare const TokenReserve: _mysten_bcs0.BcsStruct<{
900
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
901
+ pause: _mysten_bcs0.BcsStruct<{
902
+ supply: BcsType<boolean, boolean, "bool">;
903
+ borrow: BcsType<boolean, boolean, "bool">;
904
+ payback: BcsType<boolean, boolean, "bool">;
905
+ withdraw: BcsType<boolean, boolean, "bool">;
906
+ }, string>;
907
+ vault: BcsType<string, string | number | bigint, "u64">;
908
+ borrow_rate: BcsType<string, string | number | bigint, "u64">;
909
+ fee: BcsType<string, string | number | bigint, "u64">;
910
+ last_utilization: BcsType<string, string | number | bigint, "u64">;
911
+ last_update_timestamp: BcsType<string, string | number | bigint, "u64">;
912
+ supply_exchange_price: BcsType<string, string | number | bigint, "u64">;
913
+ borrow_exchange_price: BcsType<string, string | number | bigint, "u64">;
914
+ max_utilization: BcsType<string, string | number | bigint, "u64">;
915
+ total_supply_with_interest: BcsType<string, string | number | bigint, "u64">;
916
+ total_supply_interest_free: BcsType<string, string | number | bigint, "u64">;
917
+ total_borrow_with_interest: BcsType<string, string | number | bigint, "u64">;
918
+ total_borrow_interest_free: BcsType<string, string | number | bigint, "u64">;
919
+ rate_data_version: BcsType<number, number, "u8">;
920
+ supply_positions: _mysten_bcs0.BcsStruct<{
921
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
922
+ size: BcsType<string, string | number | bigint, "u64">;
923
+ }, string>;
924
+ borrow_positions: _mysten_bcs0.BcsStruct<{
925
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
926
+ size: BcsType<string, string | number | bigint, "u64">;
927
+ }, string>;
928
+ }, string>;
929
+ declare const UserSupplyConfig: _mysten_bcs0.BcsStruct<{
930
+ mode: BcsType<number, number, "u8">;
931
+ expand_percent: BcsType<string, string | number | bigint, "u64">;
932
+ expand_duration: BcsType<string, string | number | bigint, "u64">;
933
+ base_withdrawal_limit: BcsType<string, string | number | bigint, "u64">;
934
+ }, string>;
935
+ declare const UserBorrowConfig: _mysten_bcs0.BcsStruct<{
936
+ mode: BcsType<number, number, "u8">;
937
+ expand_percent: BcsType<string, string | number | bigint, "u64">;
938
+ expand_duration: BcsType<string, string | number | bigint, "u64">;
939
+ base_debt_ceiling: BcsType<string, string | number | bigint, "u64">;
940
+ max_debt_ceiling: BcsType<string, string | number | bigint, "u64">;
941
+ }, string>;
942
+ declare const UserSupplyPosition: _mysten_bcs0.BcsStruct<{
943
+ config: BcsType<{
944
+ mode: number;
945
+ expand_percent: string;
946
+ expand_duration: string;
947
+ base_withdrawal_limit: string;
948
+ } | null, {
949
+ mode: number;
950
+ expand_percent: string | number | bigint;
951
+ expand_duration: string | number | bigint;
952
+ base_withdrawal_limit: string | number | bigint;
953
+ } | null | undefined, `Option<${string}>`>;
954
+ paused_supply: BcsType<boolean, boolean, "bool">;
955
+ paused_withdraw: BcsType<boolean, boolean, "bool">;
956
+ amount: BcsType<string, string | number | bigint, "u64">;
957
+ withdrawal_limit: BcsType<string, string | number | bigint, "u64">;
958
+ last_update: BcsType<string, string | number | bigint, "u64">;
959
+ decay_amount: BcsType<string, string | number | bigint, "u64">;
960
+ decay_duration: BcsType<string, string | number | bigint, "u64">;
961
+ }, string>;
962
+ declare const UserBorrowPosition: _mysten_bcs0.BcsStruct<{
963
+ config: BcsType<{
964
+ mode: number;
965
+ expand_percent: string;
966
+ expand_duration: string;
967
+ base_debt_ceiling: string;
968
+ max_debt_ceiling: string;
969
+ } | null, {
970
+ mode: number;
971
+ expand_percent: string | number | bigint;
972
+ expand_duration: string | number | bigint;
973
+ base_debt_ceiling: string | number | bigint;
974
+ max_debt_ceiling: string | number | bigint;
975
+ } | null | undefined, `Option<${string}>`>;
976
+ paused_borrow: BcsType<boolean, boolean, "bool">;
977
+ paused_payback: BcsType<boolean, boolean, "bool">;
978
+ amount: BcsType<string, string | number | bigint, "u64">;
979
+ debt_ceiling: BcsType<string, string | number | bigint, "u64">;
980
+ last_update: BcsType<string, string | number | bigint, "u64">;
981
+ }, string>;
982
+ declare const RateDataV1Params: _mysten_bcs0.BcsStruct<{
983
+ kink: BcsType<string, string | number | bigint, "u64">;
984
+ rate_at_utilization_zero: BcsType<string, string | number | bigint, "u64">;
985
+ rate_at_utilization_kink: BcsType<string, string | number | bigint, "u64">;
986
+ rate_at_utilization_max: BcsType<string, string | number | bigint, "u64">;
987
+ }, string>;
988
+ declare const RateDataV2Params: _mysten_bcs0.BcsStruct<{
989
+ kink1: BcsType<string, string | number | bigint, "u64">;
990
+ kink2: BcsType<string, string | number | bigint, "u64">;
991
+ rate_at_utilization_zero: BcsType<string, string | number | bigint, "u64">;
992
+ rate_at_utilization_kink1: BcsType<string, string | number | bigint, "u64">;
993
+ rate_at_utilization_kink2: BcsType<string, string | number | bigint, "u64">;
994
+ rate_at_utilization_max: BcsType<string, string | number | bigint, "u64">;
995
+ }, string>;
996
+ declare const CapRecord: _mysten_bcs0.BcsStruct<{
997
+ token: _mysten_bcs0.BcsStruct<{
998
+ name: BcsType<string, string, "string">;
999
+ }, string>;
1000
+ holder: _mysten_bcs0.BcsEnum<{
1001
+ Object: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1002
+ Type: _mysten_bcs0.BcsStruct<{
1003
+ name: BcsType<string, string, "string">;
1004
+ }, string>;
1005
+ }, "Holder">;
1006
+ }, string>;
1007
+ declare const LendingState: _mysten_bcs0.BcsStruct<{
1008
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1009
+ supply: BcsType<string, string | number | bigint, "u64">;
1010
+ reserve_id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1011
+ rewards_writer: BcsType<string | null, string | Uint8Array<ArrayBufferLike> | null | undefined, "Option<bytes[32]>">;
1012
+ token_exchange_price: BcsType<string, string | number | bigint, "u64">;
1013
+ liquidity_exchange_price: BcsType<string, string | number | bigint, "u64">;
1014
+ last_update_s: BcsType<string, string | number | bigint, "u64">;
1015
+ }, string>;
1016
+ declare const RewardsSchedule$1: _mysten_bcs0.BcsStruct<{
1017
+ start_tvl: BcsType<string, string | number | bigint, "u64">;
1018
+ start_s: BcsType<string, string | number | bigint, "u64">;
1019
+ end_s: BcsType<string, string | number | bigint, "u64">;
1020
+ yearly_reward: BcsType<string, string | number | bigint, "u64">;
1021
+ next_start_s: BcsType<string, string | number | bigint, "u64">;
1022
+ next_end_s: BcsType<string, string | number | bigint, "u64">;
1023
+ next_yearly_reward: BcsType<string, string | number | bigint, "u64">;
1024
+ }, string>;
1025
+ declare const LendingRegistry: _mysten_bcs0.BcsStruct<{
1026
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1027
+ version: BcsType<string, string | number | bigint, "u64">;
1028
+ }, string>;
1029
+ declare const RiskConfig: _mysten_bcs0.BcsStruct<{
1030
+ collateral_factor: BcsType<number, number, "u16">;
1031
+ liquidation_threshold: BcsType<number, number, "u16">;
1032
+ liquidation_max_limit: BcsType<number, number, "u16">;
1033
+ withdraw_gap: BcsType<number, number, "u16">;
1034
+ liquidation_penalty: BcsType<number, number, "u16">;
1035
+ borrow_fee: BcsType<number, number, "u8">;
1036
+ }, string>;
1037
+ declare const RateMagnifier: _mysten_bcs0.BcsStruct<{
1038
+ magnitude: BcsType<number, number, "u16">;
1039
+ negative: BcsType<boolean, boolean, "bool">;
1040
+ }, string>;
1041
+ declare const VaultMarket: _mysten_bcs0.BcsStruct<{
1042
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1043
+ vault_id: BcsType<string, string | number | bigint, "u64">;
1044
+ risk: _mysten_bcs0.BcsStruct<{
1045
+ collateral_factor: BcsType<number, number, "u16">;
1046
+ liquidation_threshold: BcsType<number, number, "u16">;
1047
+ liquidation_max_limit: BcsType<number, number, "u16">;
1048
+ withdraw_gap: BcsType<number, number, "u16">;
1049
+ liquidation_penalty: BcsType<number, number, "u16">;
1050
+ borrow_fee: BcsType<number, number, "u8">;
1051
+ }, string>;
1052
+ supply_rate_magnifier: _mysten_bcs0.BcsStruct<{
1053
+ magnitude: BcsType<number, number, "u16">;
1054
+ negative: BcsType<boolean, boolean, "bool">;
1055
+ }, string>;
1056
+ borrow_rate_magnifier: _mysten_bcs0.BcsStruct<{
1057
+ magnitude: BcsType<number, number, "u16">;
1058
+ negative: BcsType<boolean, boolean, "bool">;
1059
+ }, string>;
1060
+ vault_type: BcsType<number, number, "u8">;
1061
+ oracle: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1062
+ liquidity_program: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1063
+ col_decimals: BcsType<number, number, "u8">;
1064
+ debt_decimals: BcsType<number, number, "u8">;
1065
+ branch_liquidated: BcsType<boolean, boolean, "bool">;
1066
+ topmost_tick: _mysten_bcs0.BcsStruct<{
1067
+ mag: BcsType<number, number, "u32">;
1068
+ neg: BcsType<boolean, boolean, "bool">;
1069
+ }, string>;
1070
+ current_branch_id: BcsType<string, string | number | bigint, "u64">;
1071
+ total_branch_id: BcsType<string, string | number | bigint, "u64">;
1072
+ total_supply: BcsType<string, string | number | bigint, "u64">;
1073
+ total_borrow: BcsType<string, string | number | bigint, "u64">;
1074
+ absorbed_debt_amount: BcsType<string, string | number | bigint, "u128">;
1075
+ absorbed_col_amount: BcsType<string, string | number | bigint, "u128">;
1076
+ absorbed_dust_debt: BcsType<string, string | number | bigint, "u64">;
1077
+ liquidity_supply_exchange_price: BcsType<string, string | number | bigint, "u64">;
1078
+ liquidity_borrow_exchange_price: BcsType<string, string | number | bigint, "u64">;
1079
+ vault_supply_exchange_price: BcsType<string, string | number | bigint, "u64">;
1080
+ vault_borrow_exchange_price: BcsType<string, string | number | bigint, "u64">;
1081
+ last_update_timestamp: BcsType<string, string | number | bigint, "u64">;
1082
+ ticks: _mysten_bcs0.BcsStruct<{
1083
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1084
+ size: BcsType<string, string | number | bigint, "u64">;
1085
+ }, string>;
1086
+ branches: _mysten_bcs0.BcsStruct<{
1087
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1088
+ size: BcsType<string, string | number | bigint, "u64">;
1089
+ }, string>;
1090
+ liq_snaps: _mysten_bcs0.BcsStruct<{
1091
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1092
+ size: BcsType<string, string | number | bigint, "u64">;
1093
+ }, string>;
1094
+ tick_bitmap: _mysten_bcs0.BcsStruct<{
1095
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1096
+ size: BcsType<string, string | number | bigint, "u64">;
1097
+ }, string>;
1098
+ }, string>;
1099
+ declare const VaultTick: _mysten_bcs0.BcsStruct<{
1100
+ is_liquidated: BcsType<boolean, boolean, "bool">;
1101
+ total_ids: BcsType<number, number, "u32">;
1102
+ raw_debt: BcsType<string, string | number | bigint, "u64">;
1103
+ is_fully_liquidated: BcsType<boolean, boolean, "bool">;
1104
+ liquidation_branch_id: BcsType<string, string | number | bigint, "u64">;
1105
+ debt_factor: BcsType<string, string | number | bigint, "u64">;
1106
+ }, string>;
1107
+ declare const TickIdLiquidation: _mysten_bcs0.BcsStruct<{
1108
+ is_fully_liquidated: BcsType<boolean, boolean, "bool">;
1109
+ liquidation_branch_id: BcsType<string, string | number | bigint, "u64">;
1110
+ debt_factor: BcsType<string, string | number | bigint, "u64">;
1111
+ }, string>;
1112
+ declare const TickIdLiquidationKey: _mysten_bcs0.BcsStruct<{
1113
+ tick: _mysten_bcs0.BcsStruct<{
1114
+ mag: BcsType<number, number, "u32">;
1115
+ neg: BcsType<boolean, boolean, "bool">;
1116
+ }, string>;
1117
+ tick_map: BcsType<number, number, "u32">;
1118
+ }, string>;
1119
+ declare const BranchStatus: _mysten_bcs0.BcsEnum<{
1120
+ NotLiquidated: null;
1121
+ Liquidated: null;
1122
+ Merged: null;
1123
+ Closed: null;
1124
+ }, "BranchStatus">;
1125
+ declare const Branch: _mysten_bcs0.BcsStruct<{
1126
+ status: _mysten_bcs0.BcsEnum<{
1127
+ NotLiquidated: null;
1128
+ Liquidated: null;
1129
+ Merged: null;
1130
+ Closed: null;
1131
+ }, "BranchStatus">;
1132
+ minima_tick: _mysten_bcs0.BcsStruct<{
1133
+ mag: BcsType<number, number, "u32">;
1134
+ neg: BcsType<boolean, boolean, "bool">;
1135
+ }, string>;
1136
+ minima_tick_partials: BcsType<number, number, "u32">;
1137
+ debt_liquidity: BcsType<string, string | number | bigint, "u64">;
1138
+ debt_factor: BcsType<string, string | number | bigint, "u64">;
1139
+ connected_branch_id: BcsType<string, string | number | bigint, "u64">;
1140
+ connected_minima_tick: _mysten_bcs0.BcsStruct<{
1141
+ mag: BcsType<number, number, "u32">;
1142
+ neg: BcsType<boolean, boolean, "bool">;
1143
+ }, string>;
1144
+ }, string>;
1145
+ declare const Position: _mysten_bcs0.BcsStruct<{
1146
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1147
+ vault_id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1148
+ position_mint: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1149
+ is_supply_only_position: BcsType<boolean, boolean, "bool">;
1150
+ tick: _mysten_bcs0.BcsStruct<{
1151
+ mag: BcsType<number, number, "u32">;
1152
+ neg: BcsType<boolean, boolean, "bool">;
1153
+ }, string>;
1154
+ tick_id: BcsType<number, number, "u32">;
1155
+ supply_amount: BcsType<string, string | number | bigint, "u64">;
1156
+ dust_debt_amount: BcsType<string, string | number | bigint, "u64">;
1157
+ }, string>;
1158
+ declare const VaultRegistry: _mysten_bcs0.BcsStruct<{
1159
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1160
+ next_vault_id: BcsType<string, string | number | bigint, "u64">;
1161
+ version: BcsType<string, string | number | bigint, "u64">;
1162
+ }, string>;
1163
+ declare const OracleRegistry: _mysten_bcs0.BcsStruct<{
1164
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1165
+ version: BcsType<string, string | number | bigint, "u64">;
1166
+ total_oracles: BcsType<string, string | number | bigint, "u64">;
1167
+ }, string>;
1168
+ declare const OracleSourceType: _mysten_bcs0.BcsEnum<{
1169
+ Redstone: _mysten_bcs0.BcsStruct<{
1170
+ adapter_id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1171
+ }, string>;
1172
+ Pyth: null;
1173
+ }, "SourceType">;
1174
+ declare const OracleSource$1: _mysten_bcs0.BcsStruct<{
1175
+ feed_id: BcsType<number[], Iterable<number> & {
1176
+ length: number;
1177
+ }, string>;
1178
+ invert: BcsType<boolean, boolean, "bool">;
1179
+ source_type: _mysten_bcs0.BcsEnum<{
1180
+ Redstone: _mysten_bcs0.BcsStruct<{
1181
+ adapter_id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1182
+ }, string>;
1183
+ Pyth: null;
1184
+ }, "SourceType">;
1185
+ }, string>;
1186
+ /** `fluid_oracle::oracle::Oracle` derived from the registry by nonce. */
1187
+ declare const OracleObject: _mysten_bcs0.BcsStruct<{
1188
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1189
+ nonce: BcsType<number, number, "u16">;
1190
+ main: _mysten_bcs0.BcsStruct<{
1191
+ feed_id: BcsType<number[], Iterable<number> & {
1192
+ length: number;
1193
+ }, string>;
1194
+ invert: BcsType<boolean, boolean, "bool">;
1195
+ source_type: _mysten_bcs0.BcsEnum<{
1196
+ Redstone: _mysten_bcs0.BcsStruct<{
1197
+ adapter_id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1198
+ }, string>;
1199
+ Pyth: null;
1200
+ }, "SourceType">;
1201
+ }, string>;
1202
+ guard: BcsType<{
1203
+ feed_id: number[];
1204
+ invert: boolean;
1205
+ source_type: _mysten_bcs0.EnumOutputShapeWithKeys<{
1206
+ Redstone: {
1207
+ adapter_id: string;
1208
+ };
1209
+ Pyth: true;
1210
+ }, "Redstone" | "Pyth">;
1211
+ } | null, {
1212
+ feed_id: Iterable<number> & {
1213
+ length: number;
1214
+ };
1215
+ invert: boolean;
1216
+ source_type: _mysten_bcs0.EnumInputShape<{
1217
+ Redstone: {
1218
+ adapter_id: string | Uint8Array<ArrayBufferLike>;
1219
+ };
1220
+ Pyth: boolean | object | null;
1221
+ }>;
1222
+ } | null | undefined, `Option<${string}>`>;
1223
+ }, string>;
1224
+ /** `view::PriceQuote`: each rate is optional (operate-only / liquidate-only quotes). */
1225
+ declare const PriceQuote: _mysten_bcs0.BcsStruct<{
1226
+ oracle_id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1227
+ rate_liquidate: BcsType<string | null, string | number | bigint | null | undefined, "Option<u128>">;
1228
+ rate_operate: BcsType<string | null, string | number | bigint | null | undefined, "Option<u128>">;
1229
+ }, string>;
1230
+ /** `pyth::price_info::PriceInfoObject`. */
1231
+ declare const PythPriceInfoObject: _mysten_bcs0.BcsStruct<{
1232
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1233
+ price_info: _mysten_bcs0.BcsStruct<{
1234
+ attestation_time: BcsType<string, string | number | bigint, "u64">;
1235
+ arrival_time: BcsType<string, string | number | bigint, "u64">;
1236
+ price_feed: _mysten_bcs0.BcsStruct<{
1237
+ price_identifier: _mysten_bcs0.BcsStruct<{
1238
+ bytes: BcsType<number[], Iterable<number> & {
1239
+ length: number;
1240
+ }, string>;
1241
+ }, string>;
1242
+ price: _mysten_bcs0.BcsStruct<{
1243
+ price: _mysten_bcs0.BcsStruct<{
1244
+ negative: BcsType<boolean, boolean, "bool">;
1245
+ magnitude: BcsType<string, string | number | bigint, "u64">;
1246
+ }, string>;
1247
+ conf: BcsType<string, string | number | bigint, "u64">;
1248
+ expo: _mysten_bcs0.BcsStruct<{
1249
+ negative: BcsType<boolean, boolean, "bool">;
1250
+ magnitude: BcsType<string, string | number | bigint, "u64">;
1251
+ }, string>;
1252
+ timestamp: BcsType<string, string | number | bigint, "u64">;
1253
+ }, string>;
1254
+ ema_price: _mysten_bcs0.BcsStruct<{
1255
+ price: _mysten_bcs0.BcsStruct<{
1256
+ negative: BcsType<boolean, boolean, "bool">;
1257
+ magnitude: BcsType<string, string | number | bigint, "u64">;
1258
+ }, string>;
1259
+ conf: BcsType<string, string | number | bigint, "u64">;
1260
+ expo: _mysten_bcs0.BcsStruct<{
1261
+ negative: BcsType<boolean, boolean, "bool">;
1262
+ magnitude: BcsType<string, string | number | bigint, "u64">;
1263
+ }, string>;
1264
+ timestamp: BcsType<string, string | number | bigint, "u64">;
1265
+ }, string>;
1266
+ }, string>;
1267
+ }, string>;
1268
+ }, string>;
1269
+ /** `0x2::dynamic_field::Field<K, V>` wrapper. */
1270
+ declare function Field<K, KI, V, VI>(name: BcsType<K, KI>, value: BcsType<V, VI>): _mysten_bcs0.BcsStruct<{
1271
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1272
+ name: BcsType<K, KI, string>;
1273
+ value: BcsType<V, VI, string>;
1274
+ }, string>;
1275
+ declare const bcsU64: BcsType<string, string | number | bigint, "u64">;
1276
+ declare const bcsU16: BcsType<number, number, "u16">;
1277
+ declare const bcsU256: BcsType<string, string | number | bigint, "u256">;
1278
+ declare const bcsId: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1279
+ /** Unit key struct (`RateDataKey`, `RewardsKey`, ...): BCS `dummy_field: bool`. */
1280
+ declare const UnitKey: BcsType<boolean, boolean, "bool">;
1281
+ /** Proposed `fluid_vaults::position_index::PositionIndex` (docs/onchain-position-index.md). */
1282
+ declare const PositionIndex$1: _mysten_bcs0.BcsStruct<{
1283
+ next_position_id: BcsType<string, string | number | bigint, "u64">;
1284
+ caps: _mysten_bcs0.BcsStruct<{
1285
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1286
+ size: BcsType<string, string | number | bigint, "u64">;
1287
+ }, string>;
1288
+ ordinals: _mysten_bcs0.BcsStruct<{
1289
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1290
+ size: BcsType<string, string | number | bigint, "u64">;
1291
+ }, string>;
1292
+ }, string>;
1293
+ declare const PositionIndexField: _mysten_bcs0.BcsStruct<{
1294
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1295
+ name: BcsType<boolean, boolean, string>;
1296
+ value: BcsType<{
1297
+ next_position_id: string;
1298
+ caps: {
1299
+ id: string;
1300
+ size: string;
1301
+ };
1302
+ ordinals: {
1303
+ id: string;
1304
+ size: string;
1305
+ };
1306
+ }, {
1307
+ next_position_id: string | number | bigint;
1308
+ caps: {
1309
+ id: string | Uint8Array<ArrayBufferLike>;
1310
+ size: string | number | bigint;
1311
+ };
1312
+ ordinals: {
1313
+ id: string | Uint8Array<ArrayBufferLike>;
1314
+ size: string | number | bigint;
1315
+ };
1316
+ }, string>;
1317
+ }, string>;
1318
+ /** `caps: Table<u64, ID>` entry: ordinal -> PositionOwnerCap id. */
1319
+ declare const PositionIndexEntry: _mysten_bcs0.BcsStruct<{
1320
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1321
+ name: BcsType<string, string | number | bigint, string>;
1322
+ value: BcsType<string, string | Uint8Array<ArrayBufferLike>, string>;
1323
+ }, string>;
1324
+ //#endregion
1325
+ //#region src/objects.d.ts
1326
+ type FetchedObject = {
1327
+ objectId: string;
1328
+ type: string;
1329
+ content: Uint8Array;
1330
+ owner: unknown;
1154
1331
  };
1155
- declare namespace liquidity_d_exports {
1156
- export { ReserveSnapshot, calcBorrowLimitBeforeOperate, calcRevenue, calcWithdrawalLimitBeforeOperate, calculateExchangePrice, emptyUserBorrowData, emptyUserSupplyData, processOverallTokenData, processUserBorrowData, processUserSupplyData, totalAmountsOf, totalBorrowNormal, totalSupplyNormal };
1332
+ declare class ObjectNotFoundError extends Error {
1333
+ readonly objectId: string;
1334
+ readonly what: string;
1335
+ constructor(objectId: string, what: string);
1157
1336
  }
1158
- /** The TokenReserve fields the exchange-price maths needs. */
1159
- type ReserveSnapshot = {
1160
- supplyExchangePrice: bigint;
1161
- borrowExchangePrice: bigint;
1162
- borrowRate: bigint;
1163
- fee: bigint;
1164
- lastUtilization: bigint;
1165
- lastUpdateTimestamp: bigint;
1166
- maxUtilization: bigint;
1167
- totalSupplyWithInterest: bigint;
1168
- totalSupplyInterestFree: bigint;
1169
- totalBorrowWithInterest: bigint;
1170
- totalBorrowInterestFree: bigint;
1171
- /** Coin balance held by the reserve. */
1172
- vaultBalance: bigint;
1173
- };
1174
- /** `reserve::calculate_exchange_prices(now)`. */
1175
- declare function calculateExchangePrice(r: ReserveSnapshot, now: bigint): ExchangePriceResult;
1176
- /** `liquidity_calcs::get_total_supply` (floor). */
1177
- declare const totalSupplyNormal: (r: ReserveSnapshot, supplyEp: bigint) => bigint;
1178
- /** `liquidity_calcs::get_total_borrow` (floor). */
1179
- declare const totalBorrowNormal: (r: ReserveSnapshot, borrowEp: bigint) => bigint;
1180
- /** `reserve::calc_revenue` (supply side ceiled, saturating at 0). */
1181
- declare function calcRevenue(r: ReserveSnapshot, supplyEp: bigint, borrowEp: bigint): bigint;
1182
- declare function totalAmountsOf(r: ReserveSnapshot): TotalAmounts;
1183
- /** Same shape/semantics as the Solana reader's `processOverallTokenData`. */
1184
- declare function processOverallTokenData(r: ReserveSnapshot, rateData: RateData, now: bigint): OverallTokenData;
1185
- /** `liquidity_calcs::calc_withdrawal_limit_before_operate`. */
1186
- declare function calcWithdrawalLimitBeforeOperate(userAmount: bigint, lastLimit: bigint, expandPercent: bigint, expandDuration: bigint, lastUpdate: bigint, now: bigint): bigint;
1187
- /** `liquidity_calcs::calc_borrow_limit_before_operate`. */
1188
- declare function calcBorrowLimitBeforeOperate(userAmount: bigint, lastLimit: bigint, expandPercent: bigint, expandDuration: bigint, baseLimit: bigint, maxLimit: bigint, lastUpdate: bigint, now: bigint): bigint;
1189
- declare function emptyUserSupplyData(): UserSupplyData;
1190
- declare function emptyUserBorrowData(): UserBorrowData;
1191
- /** Solana `processUserSupplyData`, with Sui's decay fields. */
1192
- declare function processUserSupplyData(acc: UserSupplyPositionAccount | null, overall: OverallTokenData, liquidityBalance: bigint, now: bigint): UserSupplyData;
1193
- /** Solana `processUserBorrowData`. */
1194
- declare function processUserBorrowData(acc: UserBorrowPositionAccount | null, overall: OverallTokenData, liquidityBalance: bigint, now: bigint): UserBorrowData;
1195
1337
  //#endregion
1196
1338
  //#region src/liquidity.d.ts
1197
1339
  type ReserveRecord = {
@@ -1204,7 +1346,11 @@ type ReserveRecord = {
1204
1346
  declare class Liquidity {
1205
1347
  private readonly ctx;
1206
1348
  constructor(ctx: ReadContext);
1207
- /** Reserves + their rate-data fields in 2 batched round trips. */
1349
+ /** Object ids `loadReserves` reads: every reserve, then every reserve's rate-data field. */
1350
+ reserveObjectIds(tokens: readonly string[]): string[];
1351
+ /** Parse objects fetched for `reserveObjectIds(tokens)` (same order). */
1352
+ reservesFromObjects(tokens: readonly string[], objs: readonly (FetchedObject | null)[]): ReserveRecord[];
1353
+ /** Reserves + their rate-data fields in one batched `getObjects`. */
1208
1354
  loadReserves(tokens: readonly string[]): Promise<ReserveRecord[]>;
1209
1355
  loadReserve(token: string): Promise<ReserveRecord>;
1210
1356
  /** Supply/borrow Table entries of `holders` on `reserves` (one batched round trip). */
@@ -1252,8 +1398,8 @@ declare class Liquidity {
1252
1398
  /** Listed tokens (see `discoverTokens`; pure state by default). */
1253
1399
  listedTokens(): Promise<string[]>;
1254
1400
  getExchangePricesAndConfig(token: string): Promise<ExchangePricesAndConfig>;
1255
- /** Pure: accrue a reserve snapshot to `now` (defaults to the context clock). */
1256
- calculateExchangePrice(snapshot: ReserveSnapshot, now?: bigint): ExchangePriceResult;
1401
+ /** Pure: accrue a reserve snapshot to `now` (unix seconds; use `await ctx.now()` for chain time). */
1402
+ calculateExchangePrice(snapshot: ReserveSnapshot, now: bigint): ExchangePriceResult;
1257
1403
  getRateConfig(token: string): Promise<RateModelAccount | null>;
1258
1404
  getTotalAmounts(token: string): Promise<TotalAmounts>;
1259
1405
  getConfigs2(token: string): Promise<{
@@ -1262,18 +1408,18 @@ declare class Liquidity {
1262
1408
  getRevenue(token: string): Promise<bigint>;
1263
1409
  getTokenRateData(token: string): Promise<RateData>;
1264
1410
  getTokensRateData(tokens: readonly string[]): Promise<RateData[]>;
1265
- overallFromRecord(r: ReserveRecord, now?: bigint): OverallTokenData;
1411
+ overallFromRecord(r: ReserveRecord, now: bigint): OverallTokenData;
1266
1412
  getOverallTokenData(token: string): Promise<OverallTokenData>;
1267
1413
  getOverallTokensData(tokens: readonly string[]): Promise<OverallTokenData[]>;
1268
1414
  getAllOverallTokensData(): Promise<OverallTokenData[]>;
1269
1415
  /** Raw supply position of a holder, or `0n` when none exists (Solana returns BN 0). */
1270
1416
  getUserSupply(user: string, token: string): Promise<UserSupplyPositionAccount | bigint>;
1271
1417
  getUserBorrow(user: string, token: string): Promise<UserBorrowPositionAccount | bigint>;
1272
- supplyDataFromRecords(reserve: ReserveRecord, acc: UserSupplyPositionAccount | null, now?: bigint): {
1418
+ supplyDataFromRecords(reserve: ReserveRecord, acc: UserSupplyPositionAccount | null, now: bigint): {
1273
1419
  userSupplyData: UserSupplyData;
1274
1420
  overallTokenData: OverallTokenData;
1275
1421
  };
1276
- borrowDataFromRecords(reserve: ReserveRecord, acc: UserBorrowPositionAccount | null, now?: bigint): {
1422
+ borrowDataFromRecords(reserve: ReserveRecord, acc: UserBorrowPositionAccount | null, now: bigint): {
1277
1423
  userBorrowData: UserBorrowData;
1278
1424
  overallTokenData: OverallTokenData;
1279
1425
  };
@@ -1330,7 +1476,7 @@ declare class Liquidity {
1330
1476
  private listAllUserPositions;
1331
1477
  }
1332
1478
  declare namespace lending_d_exports {
1333
- export { LendingSnapshot, RewardsSchedule, accruedTokenExchangePrice, currentRewardsRate, previews, rateSegments, rewardsRateFor, toAssets, toShares };
1479
+ export { LendingSnapshot, RewardsSchedule, accruedTokenExchangePrice, currentRewardsRate, previews, rateSegments, rewardsRateFor, rewardsTvl, toAssets, toShares };
1334
1480
  }
1335
1481
  type RewardsSchedule = {
1336
1482
  startTvl: bigint;
@@ -1358,12 +1504,22 @@ declare function rateSegments(s: RewardsSchedule, totalAssets: bigint, fromS: bi
1358
1504
  fromS: bigint;
1359
1505
  toS: bigint;
1360
1506
  }[];
1361
- /** Current rewards rate (1e12 = 100%) at `now`, from the active schedule segment. */
1362
- declare function currentRewardsRate(state: LendingSnapshot, now: bigint): bigint;
1507
+ /**
1508
+ * TVL the contract prices rewards on: total shares at the STORED (pre-accrual) token exchange
1509
+ * price, as `accounting::accrued_token_exchange_price` does. Rounded up on "audited" packages
1510
+ * (742ea21+), floored on the 09-18 "pre-audit" packages.
1511
+ */
1512
+ declare const rewardsTvl: (state: LendingSnapshot, variant?: MathVariant) => bigint;
1513
+ /**
1514
+ * Current rewards rate (raw, RETURN_PERCENT_PRECISION: 1e14 = 100%) at `now`, from the active schedule segment, priced on
1515
+ * the pre-accrual TVL (`rewardsTvl`) exactly as the contract prices the segment it will credit.
1516
+ * Windows are [start, end): the rate is live from `startS` and gone at `endS`.
1517
+ */
1518
+ declare function currentRewardsRate(state: LendingSnapshot, now: bigint, variant?: MathVariant): bigint;
1363
1519
  /** `accounting::accrued_token_exchange_price`. */
1364
- declare function accruedTokenExchangePrice(state: LendingSnapshot, newLiquidityExchangePrice: bigint, nowS: bigint): bigint;
1520
+ declare function accruedTokenExchangePrice(state: LendingSnapshot, newLiquidityExchangePrice: bigint, nowS: bigint, variant?: MathVariant): bigint;
1365
1521
  /** `accounting::preview_*` given the reserve's current liquidity (supply) exchange price. */
1366
- declare function previews(state: LendingSnapshot, liquidityExchangePrice: bigint, nowS: bigint, assets: bigint, shares: bigint): {
1522
+ declare function previews(state: LendingSnapshot, liquidityExchangePrice: bigint, nowS: bigint, assets: bigint, shares: bigint, variant?: MathVariant): {
1367
1523
  tokenExchangePrice: bigint;
1368
1524
  previewDeposit: bigint;
1369
1525
  previewMint: bigint;
@@ -1378,12 +1534,29 @@ type LendingRecord = {
1378
1534
  raw: ReturnType<typeof LendingState.parse>;
1379
1535
  snapshot: LendingSnapshot;
1380
1536
  };
1537
+ type Pool = {
1538
+ lending: LendingRecord;
1539
+ reserve: ReserveRecord;
1540
+ supplyEntry: UserSupplyPositionAccount | null;
1541
+ };
1381
1542
  declare class Lending {
1382
1543
  private readonly ctx;
1383
1544
  private readonly liquidity;
1384
1545
  constructor(ctx: ReadContext, liquidity: Liquidity);
1546
+ /** Object ids `loadLendings` reads: every LendingState, then every rewards field. */
1547
+ lendingObjectIds(tokens: readonly string[]): string[];
1385
1548
  /** LendingStates (+ rewards fields) for `tokens`; `null` where no pool exists. */
1386
1549
  loadLendings(tokens: readonly string[]): Promise<(LendingRecord | null)[]>;
1550
+ lendingsFromObjects(tokens: readonly string[], objs: readonly (FetchedObject | null)[]): (LendingRecord | null)[];
1551
+ /**
1552
+ * Everything a pool read needs in ONE `getObjects` batch (LendingState, rewards field,
1553
+ * TokenReserve, rate data per token; 50 ids per request, chunks in parallel), plus the chain
1554
+ * clock in parallel. With `withEntries`, a second batch reads each pool's liquidity supply entry.
1555
+ */
1556
+ loadPools(tokens: readonly string[], withEntries?: boolean): Promise<{
1557
+ pools: Pool[];
1558
+ now: bigint;
1559
+ }>;
1387
1560
  private loadOne;
1388
1561
  getAllLendings(): Promise<LendingAccount[]>;
1389
1562
  /** Underlying coin types that have a lending pool. */
@@ -1397,17 +1570,50 @@ declare class Lending {
1397
1570
  name: string;
1398
1571
  symbol: string;
1399
1572
  decimals: number;
1400
- }, now?: bigint): FTokenDetails;
1401
- private fTokenMeta;
1573
+ }, now: bigint): FTokenDetails;
1574
+ /** fToken name/symbol/decimals (cached; falls back to the underlying's metadata). */
1575
+ fTokenMeta(token: string): Promise<CoinMeta>;
1402
1576
  getFTokenDetails(token: string): Promise<FTokenDetails>;
1577
+ /** Details for many fTokens: 2 batched object reads + the clock, metadata cached. */
1578
+ getFTokensDetails(tokens: readonly string[]): Promise<FTokenDetails[]>;
1579
+ private detailsWithPrices;
1403
1580
  /** @deprecated Solana name; use `getFTokenDetails`. */
1404
1581
  getJlTokenDetails: (token: string) => Promise<FTokenDetails>;
1405
1582
  getAllFTokenDetails(): Promise<FTokenDetails[]>;
1583
+ /** Underlying coin types that have a lending pool (pure state: one batched existence read). */
1584
+ listedLendingTokens(): Promise<string[]>;
1406
1585
  /** @deprecated Solana name; use `getAllFTokenDetails`. */
1407
1586
  getAllJlTokenDetails: () => Promise<FTokenDetails[]>;
1408
1587
  getFTokenInternalData(token: string): Promise<FTokenInternalData>;
1409
1588
  /** @deprecated Solana name; use `getFTokenInternalData`. */
1410
1589
  getJlTokenInternalData: (token: string) => Promise<FTokenInternalData>;
1590
+ /**
1591
+ * Generic lending state per fToken (identity, accrued + stored exchange prices, TVL, rates in
1592
+ * bps, rewards schedule) for `tokens` (underlying coin types), or every listed pool when
1593
+ * omitted. One batched `getObjects` for all pools + the on-chain Clock; metadata cached.
1594
+ */
1595
+ getLendingStateData(tokens?: readonly string[]): Promise<LendingStateData[]>;
1596
+ /** Pure: `LendingStateData` from loaded records at `now`. */
1597
+ stateDataFrom(lending: LendingRecord, reserve: ReserveRecord, decimals: number, now: bigint): LendingStateData;
1598
+ /**
1599
+ * Wallet holders of `Coin<FToken<T>>` for `token` (underlying coin type), via the GraphQL
1600
+ * indexer (`config.graphqlUrl`; needs `discovery: "indexer"`). Lists every Coin<FToken<T>>
1601
+ * object by type and keeps the ones with an ADDRESS owner (AddressOwner or
1602
+ * ConsensusAddressOwner), aggregated by owner, all pages at one checkpoint (consistent cursors).
1603
+ *
1604
+ * LIMITS (documented, by design): coins owned by other objects, shared/immutable coins and
1605
+ * wrapped `Balance<FToken<T>>` (inside other protocols' objects) are NOT attributed to a wallet;
1606
+ * nor are address balances (funds credited to an address without a coin object), since they are
1607
+ * not objects and cannot be enumerated by type. `totalSupply` is returned so a caller can
1608
+ * compare it with the sum of the wallets. With `verify` (default true) each wallet is cross-checked against
1609
+ * fullnode `getBalance` (coinBalance + addressBalance), `concurrency` at a time (default 8).
1610
+ */
1611
+ getFTokenHolders(token: string, opts?: {
1612
+ verify?: boolean;
1613
+ concurrency?: number;
1614
+ pageSize?: number;
1615
+ }): Promise<FTokenHolders>;
1616
+ /** `[rewards writer cap id, current rewards rate in bps]`. */
1411
1617
  getFTokenRewards(token: string): Promise<[string | null, bigint]>;
1412
1618
  /** @deprecated Solana name; use `getFTokenRewards`. */
1413
1619
  getJlTokenRewards: (token: string) => Promise<[string | null, bigint]>;
@@ -1427,7 +1633,7 @@ declare class Lending {
1427
1633
  /** Oracle rates are debt-per-collateral in the vault's internal 1e9 space, scaled by 1e15. */
1428
1634
  declare const ORACLE_RATE_PRECISION = 1000000000000000n;
1429
1635
  /** Mirrors `fluid_oracle::constants` of the deployed v2 package. */
1430
- declare const ORACLE_V2_LIMITS: {
1636
+ declare const ORACLE_LIMITS: {
1431
1637
  readonly rateOutputDecimals: 15;
1432
1638
  readonly maxAgeOperateS: 600n;
1433
1639
  readonly maxAgeLiquidateS: 7200n;
@@ -1443,14 +1649,12 @@ declare function scaleAndInvert(raw: bigint, decimals: number, invert: boolean):
1443
1649
  declare class Oracle {
1444
1650
  private readonly ctx;
1445
1651
  constructor(ctx: ReadContext);
1446
- private get v2();
1447
- /** Admin oracle object (2026-09-18 preset). */
1448
- getOracle(oracleId: string): Promise<AdminOracle>;
1652
+ private get providers();
1449
1653
  /** v2 oracle object: nonce + main / guard routes. */
1450
- getOracleV2(oracleId: string): Promise<OracleV2>;
1654
+ getOracle(oracleId: string): Promise<OracleData>;
1451
1655
  /** Provider objects the v2 views take for this oracle. */
1452
1656
  private providerArgs;
1453
- private quoteV2;
1657
+ private quote;
1454
1658
  /** Price exactly as vaults see it. v2: operate and liquidate simulated separately (one can abort alone). */
1455
1659
  getOraclePrice(oracleId: string): Promise<OraclePrice>;
1456
1660
  /**
@@ -1459,7 +1663,7 @@ declare class Oracle {
1459
1663
  * Operate price = min over routes; liquidate = min over routes usable for liquidate.
1460
1664
  */
1461
1665
  getOracleRoutes(oracleId: string): Promise<{
1462
- oracle: OracleV2;
1666
+ oracle: OracleData;
1463
1667
  nowMs: bigint;
1464
1668
  main: OracleRoute;
1465
1669
  guard: OracleRoute | null;
@@ -1480,7 +1684,18 @@ declare const RATE_OUTPUT_DECIMALS = 100000000000000000n;
1480
1684
  declare const EXCHANGE_PRICE_SCALE_FACTOR = 1000000000000000000n;
1481
1685
  /** Lending return precision (1e14 = 1e12 * 100). */
1482
1686
  declare const RETURN_PERCENT_PRECISION = 100000000000000n;
1483
- /** Lending max rewards rate (50% in 1e12). */
1687
+ /**
1688
+ * The two raw on-chain rate scales differ, which is why every rate FIELD the SDK returns is bps
1689
+ * (1e4 = 100% per year, floored):
1690
+ * - liquidity supply rate (`reserve::calculate_exchange_prices`): 1e12 = 100% -> SUPPLY_RATE_PRECISION
1691
+ * - lending rewards rate (`rewards`, `lending_calcs`): 1e14 = 100% -> RETURN_PERCENT_PRECISION
1692
+ */
1693
+ declare const SUPPLY_RATE_PRECISION = 1000000000000n;
1694
+ /** Raw liquidity supply rate (1e12 = 100%) -> bps, floored. */
1695
+ declare const supplyRateToBps: (raw: bigint) => bigint;
1696
+ /** Raw lending rewards rate (1e14 = 100%) -> bps, floored. */
1697
+ declare const rewardsRateToBps: (raw: bigint) => bigint;
1698
+ /** Lending max rewards rate: 50% at RETURN_PERCENT_PRECISION (1e14 = 100%). */
1484
1699
  declare const MAX_REWARDS_RATE = 50000000000000n;
1485
1700
  declare function mulDiv(a: bigint, b: bigint, c: bigint): bigint;
1486
1701
  declare function divCeil(a: bigint, b: bigint): bigint;
@@ -1622,7 +1837,7 @@ declare class Vault {
1622
1837
  positionCounts?: boolean;
1623
1838
  }): Promise<VaultState>;
1624
1839
  /** `user::get_exchange_prices`: (liqSupply, liqBorrow, vaultSupply, vaultBorrow) accrued to `now`. */
1625
- exchangePricesFromRecords(v: VaultRecord, colReserve: ReserveRecord, debtReserve: ReserveRecord, now?: bigint): {
1840
+ exchangePricesFromRecords(v: VaultRecord, colReserve: ReserveRecord, debtReserve: ReserveRecord, now: bigint): {
1626
1841
  liquiditySupplyExchangePrice: bigint;
1627
1842
  liquidityBorrowExchangePrice: bigint;
1628
1843
  vaultSupplyExchangePrice: bigint;
@@ -1732,22 +1947,32 @@ declare class Vault {
1732
1947
  //#region src/client.d.ts
1733
1948
  declare const DEFAULT_RPC_URL = "https://fullnode.mainnet.sui.io:443";
1734
1949
  type ClientOptions = {
1735
- /** Built-in network name ("staging", ...) or a full config. Default "staging". */
1736
- network?: string | FluidReadConfig;
1737
- /** Clock override (unix seconds) for time-dependent maths. Default: local wall clock. */
1738
- now?: () => bigint;
1950
+ /**
1951
+ * REQUIRED. Built-in network name ("mainnet" = production, "staging") or a
1952
+ * full config (e.g. from `configFromDeployment`). No default, so nobody reads
1953
+ * staging believing it is production.
1954
+ */
1955
+ network: string | FluidReadConfig;
1956
+ /**
1957
+ * Clock for time-dependent maths. Default "chain": the on-chain Clock (0x6), so accrual and the
1958
+ * rewards windows never depend on this server's clock. "local" = wall clock; or a function
1959
+ * returning unix seconds.
1960
+ */
1961
+ now?: ClockSource;
1739
1962
  /** Enumeration policy. Default "state" (no indexer, no list queries). See `DiscoveryLevel`. */
1740
1963
  discovery?: DiscoveryLevel;
1741
1964
  /** Per-call timeout before failing over to the next endpoint. Default 15000 ms. */
1742
1965
  timeoutMs?: number;
1966
+ /** Retry passes over the endpoints with exponential backoff (see `FailoverOptions`). Default 3 passes, 250 ms base, 4 s cap. */
1967
+ retry?: Pick<FailoverOptions, "rounds" | "backoffMs" | "maxBackoffMs">;
1743
1968
  };
1744
1969
  /**
1745
1970
  * Unified reader, same shape as `@jup-ag/lend-read`'s `Client`:
1746
1971
  * `client.liquidity`, `client.lending`, `client.vault` (+ `client.oracle`, Sui-only).
1747
1972
  *
1748
1973
  * @example
1749
- * const client = new Client(); // staging deployment, Sui mainnet gRPC
1750
- * const client = new Client("https://my-fullnode:443");
1974
+ * const client = new Client(undefined, { network: "mainnet" }); // production deployment, Sui mainnet gRPC
1975
+ * const client = new Client("https://my-fullnode:443", { network: customConfig });
1751
1976
  * const client = new Client(existingSuiGrpcClient, { network: "staging" });
1752
1977
  * const vault = await client.vault.getVaultEntireData(1);
1753
1978
  */
@@ -1757,47 +1982,29 @@ declare class Client {
1757
1982
  readonly vault: Vault;
1758
1983
  readonly oracle: Oracle;
1759
1984
  readonly context: ReadContext;
1760
- constructor(rpc?: string | readonly (string | ClientWithCoreApi)[] | ClientWithCoreApi, opts?: ClientOptions);
1985
+ constructor(rpc: string | readonly (string | ClientWithCoreApi)[] | ClientWithCoreApi | undefined, opts: ClientOptions);
1986
+ /**
1987
+ * The same reader pinned to a past `checkpoint`: every object read comes from the GraphQL service
1988
+ * (`config.graphqlUrl`) at that checkpoint and the clock is the checkpoint's timestamp, so
1989
+ * `lending.getLendingStateData()`, rates, reserves and vault state are what the chain held then.
1990
+ * Move views / oracle quotes / balances are not available historically (`CheckpointReadError`).
1991
+ * Needs `discovery: "indexer"` (it is a GraphQL read).
1992
+ *
1993
+ * @example
1994
+ * const past = await client.atCheckpoint(330_000_000);
1995
+ * const state = await past.lending.getLendingStateData();
1996
+ */
1997
+ atCheckpoint(checkpoint: number | bigint): Promise<Client>;
1761
1998
  }
1762
1999
  /**
1763
2000
  * `$extend` form, same pattern as the write SDK's `fluid()`:
1764
2001
  * `const c = new SuiGrpcClient({...}).$extend(fluidRead()); c.fluidRead.vault...`
1765
2002
  */
1766
- declare function fluidRead(opts?: ClientOptions): {
2003
+ declare function fluidRead(opts: ClientOptions): {
1767
2004
  name: "fluidRead";
1768
2005
  register: (client: ClientWithCoreApi) => Client;
1769
2006
  };
1770
2007
  //#endregion
1771
- //#region src/transport.d.ts
1772
- type FailoverOptions = {
1773
- network: string;
1774
- /** Per-call timeout before moving to the next endpoint. Default 15000 ms. */
1775
- timeoutMs?: number;
1776
- /** Full passes over the endpoint list before giving up. Default 2. */
1777
- rounds?: number;
1778
- };
1779
- declare class AllEndpointsFailedError extends Error {
1780
- readonly method: string;
1781
- readonly errors: {
1782
- endpoint: string;
1783
- error: unknown;
1784
- }[];
1785
- constructor(method: string, errors: {
1786
- endpoint: string;
1787
- error: unknown;
1788
- }[]);
1789
- }
1790
- declare function clientForEndpoint(endpoint: string, network: string): ClientWithCoreApi;
1791
- /**
1792
- * One `ClientWithCoreApi` over many endpoints. Accepts endpoint strings or ready clients
1793
- * (label = index). Synchronous core members (e.g. `resolveTransactionPlugin`) come from the
1794
- * currently preferred endpoint.
1795
- */
1796
- declare function createFailoverClient(endpoints: readonly (string | ClientWithCoreApi)[], opts: FailoverOptions): ClientWithCoreApi & {
1797
- endpoints: string[];
1798
- preferred: () => string;
1799
- };
1800
- //#endregion
1801
2008
  //#region src/view.d.ts
1802
2009
  declare class ViewCallError extends Error {
1803
2010
  readonly details?: unknown | undefined;
@@ -1809,12 +2016,39 @@ declare class ViewCallError extends Error {
1809
2016
  */
1810
2017
  declare function simulateView(client: ClientWithCoreApi, build: (tx: Transaction) => void | TransactionResult | unknown): Promise<Uint8Array[][]>;
1811
2018
  //#endregion
1812
- //#region src/objects.d.ts
1813
- declare class ObjectNotFoundError extends Error {
1814
- readonly objectId: string;
1815
- readonly what: string;
1816
- constructor(objectId: string, what: string);
2019
+ //#region src/graphql.d.ts
2020
+ declare class GraphQLError extends Error {
2021
+ readonly errors?: unknown | undefined;
2022
+ constructor(message: string, errors?: unknown | undefined);
2023
+ }
2024
+ type GraphQLOptions = {
2025
+ /** Attempts in total. Default 3. */
2026
+ rounds?: number;
2027
+ backoffMs?: number;
2028
+ maxBackoffMs?: number;
2029
+ timeoutMs?: number;
2030
+ };
2031
+ /**
2032
+ * POST one query. Network errors, timeouts, HTTP 429/5xx are retried with backoff; a GraphQL
2033
+ * `errors` payload (bad query, unknown object) is NOT retried.
2034
+ */
2035
+ declare function graphqlQuery<T>(url: string, query: string, variables?: Record<string, unknown>, opts?: GraphQLOptions): Promise<T>;
2036
+ //#endregion
2037
+ //#region src/checkpoint.d.ts
2038
+ declare class CheckpointReadError extends Error {
2039
+ constructor(method: string, checkpoint: bigint);
1817
2040
  }
2041
+ /** Timestamp of `checkpoint` in unix seconds (floored, as `units::from_clock` reads it). */
2042
+ declare function checkpointTimestampSeconds(url: string, checkpoint: bigint, opts?: GraphQLOptions): Promise<bigint>;
2043
+ /** Latest checkpoint the GraphQL service has indexed. */
2044
+ declare function latestCheckpoint(url: string, opts?: GraphQLOptions): Promise<bigint>;
2045
+ /**
2046
+ * A core client pinned to `checkpoint`: `getObjects` via GraphQL at that checkpoint,
2047
+ * `getCoinMetadata` from `live` (immutable data), every other core read throws.
2048
+ */
2049
+ declare function checkpointClient(url: string, checkpoint: bigint, live: ClientWithCoreApi, opts?: GraphQLOptions): ClientWithCoreApi & {
2050
+ checkpoint: bigint;
2051
+ };
1818
2052
  declare namespace vault_d_exports {
1819
2053
  export { BRANCH_STATUS, LiquidationLookups, SignedMagnifier, currentPositionState, fetchLatestPosition, loadVaultExchangePrices, minimumDebt, needsLiquidationSettle, positionInfo, rawToNormal, unscale };
1820
2054
  }
@@ -1918,4 +2152,4 @@ declare function mulBigNumber(a: bigint, b: bigint): bigint;
1918
2152
  /** `big_number::mul_div_normal`: normal * bn1 / bn2. */
1919
2153
  declare function mulDivNormal(normal: bigint, bn1: bigint, bn2: bigint): bigint;
1920
2154
  //#endregion
1921
- export { AdminOracle, AllEndpointsFailedError, CONFIGS, Client, type ClientOptions, Configs, ConstantViews, CurrentBranchState, DEFAULT_NETWORK, DEFAULT_RPC_URL, DecodedBranch, DecodedTick, DecodedTickIdLiquidation, type DeploymentRecord, type DiscoveryLevel, EXCHANGE_PRICES_PRECISION, EXCHANGE_PRICE_SCALE_FACTOR, ExchangePriceResult, ExchangePricesAndConfig, ExchangePricesAndRates, FOUR_DECIMALS, FTokenDetails, FTokenDetailsUserPosition, FTokenInternalData, type FailoverOptions, type FluidDerive, type FluidReadConfig, JlTokenDetails, JlTokenDetailsUserPosition, JlTokenInternalData, Lending, LendingAccount, type LendingRecord, LendingUserPosition, LimitsAndAvailability, Liquidity, LiquidityAccount, MAINNET, MAX_REWARDS_RATE, NeedsDiscoveryError, NftPosition, ORACLE_RATE_PRECISION, ORACLE_V2_LIMITS, ObjectNotFoundError, Oracle, OraclePrice, OracleRoute, OracleV2, OracleV2Source, 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, STAGING_LEGACY, TotalAmounts, TotalSupplyAndBorrow, UserBorrowData, UserBorrowPositionAccount, UserPosition, UserPositionWithDebt, UserSupplyData, UserSupplyPositionAccount, Vault, VaultConfig, VaultEntireData, VaultEntireDataV2, type VaultReadOpts, type VaultRecord, VaultState, ViewCallError, bcs_d_exports as bcsTypes, clientForEndpoint, configFromDeployment, createDerive, createFailoverClient, divCeil, fluidRead, lending_d_exports as lendingMath, liquidity_d_exports as liquidityMath, max, min, mulDiv, mulDivCeil, nowSeconds, resolveConfig, scaleAndInvert, simulateView, 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 };