@instadapp/fluid-sui-read-sdk 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +147 -21
  2. package/dist/index.d.mts +1229 -998
  3. package/dist/index.mjs +688 -318
  4. package/package.json +1 -1
package/dist/index.d.mts CHANGED
@@ -1,854 +1,277 @@
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>;
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;
108
265
  };
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;
266
+ type LendingUserPosition = {
267
+ /** fToken shares held (`Coin<FToken<T>>` balance). */
268
+ fTokenShares: bigint;
269
+ underlyingAssets: bigint;
270
+ underlyingBalance: bigint;
155
271
  };
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;
848
- };
849
- type FTokenDetailsUserPosition = {
850
- fTokenDetails: FTokenDetails;
851
- userPosition: LendingUserPosition;
272
+ type FTokenDetailsUserPosition = {
273
+ fTokenDetails: FTokenDetails;
274
+ userPosition: LendingUserPosition;
852
275
  };
853
276
  /** @deprecated Solana name; use `FTokenDetailsUserPosition`. */
854
277
  type JlTokenDetailsUserPosition = FTokenDetailsUserPosition;
@@ -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,823 @@ 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
+ * @deprecated Misleading name kept for compatibility: this is the STAGING deployment
708
+ * (`STAGING`), not production. Use `STAGING` / network "staging".
709
+ */
710
+ declare const MAINNET: FluidReadConfig;
711
+ declare const CONFIGS: Record<string, FluidReadConfig>;
712
+ /**
713
+ * Deployment record: per-package ids plus the shared object ids the SDK reads. The ids alone are
714
+ * not enough: `liquidity`, `lending`, `oracle` and `vaults` must each carry `objects.registry`
715
+ * (see "Deployment record shape" in the README).
716
+ */
717
+ type DeploymentRecord = {
718
+ packages: Record<"library" | "liquidity" | "lending" | "oracle" | "vaults" | "lending_rewards", {
719
+ packageId: string;
720
+ originalId?: string;
721
+ objects?: Record<string, string>;
722
+ } | undefined>;
1103
723
  };
1104
- type PositionWithRiskRatio = NftPosition & {
1105
- vaultId: number;
1106
- /** debt / (collateral * oracle price), 1e4 scale (e.g. 7500 = 75%). */
1107
- riskRatio: bigint;
724
+ /**
725
+ * Build a read config from a deployment record instead of the built-in ids, e.g.
726
+ * `configFromDeployment(JSON.parse(readFileSync(path, "utf8")), { network: "mainnet", oracle })`.
727
+ * The record has no RedStone package or Pyth feed map, so `oracle` comes from the caller.
728
+ * Throws once, listing every required field the record is missing.
729
+ */
730
+ declare function configFromDeployment(rec: DeploymentRecord, opts: Pick<FluidReadConfig, "network" | "oracle"> & Partial<Pick<FluidReadConfig, "tokens" | "rpcUrls" | "graphqlUrl" | "mathVariant">>): FluidReadConfig;
731
+ declare function resolveConfig(networkOrConfig: string | FluidReadConfig | undefined): FluidReadConfig;
732
+ //#endregion
733
+ //#region src/derive.d.ts
734
+ declare function createDerive(cfg: FluidReadConfig): {
735
+ /** `TokenReserve<T>`: derived from the liquidity Registry, key `ReserveKey<T>`. */
736
+ tokenReserveId: (coinType: string) => string;
737
+ /** `LendingState<T>`: derived from the LendingRegistry, key `LendingStateKey<T>`. */
738
+ lendingStateId: (coinType: string) => string;
739
+ /** `VaultMarket<Col, Debt>`: derived from the VaultRegistry, key `VaultKey(u64)`. */
740
+ vaultMarketId: (vaultId: number | bigint) => string;
741
+ /** `Position`: derived from its VaultMarket, key `PositionKey(cap id)`. */
742
+ positionId: (vaultMarketId: string, capId: string) => string;
743
+ holderKeyType: string;
744
+ /** Entry of `TokenReserve.supply_positions` / `borrow_positions` for `Holder::Object(id)`. */
745
+ holderEntryId: (tableId: string, holderObjectId: string) => string;
746
+ /** `RateDataKey` dynamic field on a TokenReserve. */
747
+ rateDataId: (reserveId: string) => string;
748
+ /** `RewardsKey` dynamic field on a LendingState. */
749
+ rewardsId: (lendingStateId: string) => string;
750
+ /** `VaultMarket.ticks` entry. */
751
+ tickEntryId: (ticksTableId: string, tick: number) => string;
752
+ /** `VaultMarket.branches` entry. */
753
+ branchEntryId: (branchesTableId: string, branchId: number | bigint | string) => string;
754
+ /** `VaultMarket.liq_snaps` entry. */
755
+ liqSnapEntryId: (snapsTableId: string, tick: number, tickId: number) => string;
756
+ /** `VaultMarket.tick_bitmap` word. */
757
+ bitmapWordId: (bitmapTableId: string, word: number) => string;
758
+ /**
759
+ * Proposed on-chain position index (docs/onchain-position-index.md): dynamic field
760
+ * `PositionIndexKey()` on the VaultMarket. Returns null-safe ids; absent until shipped.
761
+ */
762
+ positionIndexKeyType: string;
763
+ positionIndexId: (vaultMarketId: string) => string;
764
+ /** Entry `n` (1-based ordinal) of the index's `caps: Table<u64, ID>`. */
765
+ positionIndexEntryId: (capsTableId: string, n: number | bigint) => string;
766
+ /** v2 `Oracle`: derived from the OracleRegistry, key `OracleKey(nonce: u16)`; nonces 1..total_oracles. */
767
+ oracleId: (nonce: number) => string;
768
+ fTokenType: (coinType: string) => string;
769
+ positionCapType: string;
1108
770
  };
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;
771
+ type FluidDerive = ReturnType<typeof createDerive>;
772
+ //#endregion
773
+ //#region src/context.d.ts
774
+ /**
775
+ * Where time-dependent maths gets "now" from.
776
+ * - "chain" (default): the on-chain Clock, read alongside the state (one extra object in the read).
777
+ * - "local": this machine's wall clock. Only for offline/back-testing use; elapsed time and the
778
+ * rewards windows then depend on the server's clock.
779
+ * - a function: fixed or custom clock (unix seconds), e.g. a checkpoint timestamp.
780
+ */
781
+ type ClockSource = "chain" | "local" | (() => bigint | Promise<bigint>);
782
+ /**
783
+ * How far the SDK may go beyond pure object state when it has to ENUMERATE something.
784
+ *
785
+ * - "state" (default): only reads of objects by derived id (`getObjects`) and Move view
786
+ * simulation. No list/scan queries of any kind. Anything that cannot be resolved this way
787
+ * throws `NeedsDiscoveryError` naming the on-chain change that would make it pure.
788
+ * - "fullnode": also the fullnode's own secondary indexes (`listDynamicFields`,
789
+ * `listOwnedObjects`). Same endpoint(s) as state reads, so failover covers them, but the
790
+ * node must run with indexing enabled.
791
+ * - "indexer": also the external GraphQL indexer (event scans). Last resort.
792
+ */
793
+ type DiscoveryLevel = "state" | "fullnode" | "indexer";
794
+ declare class NeedsDiscoveryError extends Error {
795
+ readonly what: string;
796
+ readonly needed: DiscoveryLevel;
797
+ readonly onchainFix: string;
798
+ constructor(what: string, needed: DiscoveryLevel, onchainFix: string);
799
+ }
800
+ /** Shared state every module reads through. */
801
+ type ReadContext = {
802
+ client: ClientWithCoreApi;
803
+ config: FluidReadConfig;
804
+ derive: FluidDerive;
805
+ /** Clock for time-dependent maths (unix seconds). Defaults to the on-chain Clock. */
806
+ now: () => Promise<bigint>;
807
+ discovery: DiscoveryLevel;
808
+ allows: (level: DiscoveryLevel) => boolean;
809
+ /** `config.mathVariant ?? "audited"`. */
810
+ math: MathVariant;
811
+ /** Coin metadata (immutable), fetched once per coin type and cached for the client's lifetime. */
812
+ coinMetadata: (coinType: string) => Promise<CoinMeta | null>;
1120
813
  };
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;
814
+ type CoinMeta = {
815
+ name: string;
816
+ symbol: string;
817
+ decimals: number;
1128
818
  };
1129
- type OracleV2 = {
1130
- id: string;
1131
- nonce: number;
1132
- main: OracleV2Source;
1133
- guard: OracleV2Source | null;
819
+ //#endregion
820
+ //#region src/transport.d.ts
821
+ type FailoverOptions = {
822
+ network: string;
823
+ /** Per-call timeout before moving to the next endpoint. Default 15000 ms. */
824
+ timeoutMs?: number;
825
+ /** Full passes over the endpoint list before giving up. Default 3. */
826
+ rounds?: number;
827
+ /** Wait before the second pass; doubles every pass. Default 250 ms. */
828
+ backoffMs?: number;
829
+ /** Cap on the wait between passes. Default 4000 ms. */
830
+ maxBackoffMs?: number;
1134
831
  };
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;
832
+ /** Wait before pass `pass` (1-based, pass >= 2): exponential, capped, +/-25% jitter. */
833
+ declare function backoffDelay(pass: number, base: number, cap: number): number;
834
+ declare class AllEndpointsFailedError extends Error {
835
+ readonly method: string;
836
+ readonly errors: {
837
+ endpoint: string;
838
+ error: unknown;
839
+ }[];
840
+ constructor(method: string, errors: {
841
+ endpoint: string;
842
+ error: unknown;
843
+ }[]);
844
+ }
845
+ declare function clientForEndpoint(endpoint: string, network: string): ClientWithCoreApi;
846
+ /**
847
+ * One `ClientWithCoreApi` over many endpoints. Accepts endpoint strings or ready clients
848
+ * (label = index). Synchronous core members (e.g. `resolveTransactionPlugin`) come from the
849
+ * currently preferred endpoint.
850
+ */
851
+ declare function createFailoverClient(endpoints: readonly (string | ClientWithCoreApi)[], opts: FailoverOptions): ClientWithCoreApi & {
852
+ endpoints: string[];
853
+ preferred: () => string;
1148
854
  };
1149
- type AdminOracle = {
1150
- id: string;
1151
- name: string;
1152
- rate: bigint;
1153
- version: bigint;
855
+ declare namespace bcs_d_exports {
856
+ 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 };
857
+ }
858
+ declare const TypeName: _mysten_bcs0.BcsStruct<{
859
+ name: BcsType<string, string, "string">;
860
+ }, string>;
861
+ declare const MoveTick: _mysten_bcs0.BcsStruct<{
862
+ mag: BcsType<number, number, "u32">;
863
+ neg: BcsType<boolean, boolean, "bool">;
864
+ }, string>;
865
+ declare const Table: _mysten_bcs0.BcsStruct<{
866
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
867
+ size: BcsType<string, string | number | bigint, "u64">;
868
+ }, string>;
869
+ declare const PauseFlags: _mysten_bcs0.BcsStruct<{
870
+ supply: BcsType<boolean, boolean, "bool">;
871
+ borrow: BcsType<boolean, boolean, "bool">;
872
+ payback: BcsType<boolean, boolean, "bool">;
873
+ withdraw: BcsType<boolean, boolean, "bool">;
874
+ }, string>;
875
+ declare const Holder: _mysten_bcs0.BcsEnum<{
876
+ Object: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
877
+ Type: _mysten_bcs0.BcsStruct<{
878
+ name: BcsType<string, string, "string">;
879
+ }, string>;
880
+ }, "Holder">;
881
+ declare const LiquidityRegistry: _mysten_bcs0.BcsStruct<{
882
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
883
+ version: BcsType<string, string | number | bigint, "u64">;
884
+ pause: _mysten_bcs0.BcsStruct<{
885
+ supply: BcsType<boolean, boolean, "bool">;
886
+ borrow: BcsType<boolean, boolean, "bool">;
887
+ payback: BcsType<boolean, boolean, "bool">;
888
+ withdraw: BcsType<boolean, boolean, "bool">;
889
+ }, string>;
890
+ revenue_collector: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
891
+ active_caps: _mysten_bcs0.BcsStruct<{
892
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
893
+ size: BcsType<string, string | number | bigint, "u64">;
894
+ }, string>;
895
+ }, string>;
896
+ declare const TokenReserve: _mysten_bcs0.BcsStruct<{
897
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
898
+ pause: _mysten_bcs0.BcsStruct<{
899
+ supply: BcsType<boolean, boolean, "bool">;
900
+ borrow: BcsType<boolean, boolean, "bool">;
901
+ payback: BcsType<boolean, boolean, "bool">;
902
+ withdraw: BcsType<boolean, boolean, "bool">;
903
+ }, string>;
904
+ vault: BcsType<string, string | number | bigint, "u64">;
905
+ borrow_rate: BcsType<string, string | number | bigint, "u64">;
906
+ fee: BcsType<string, string | number | bigint, "u64">;
907
+ last_utilization: BcsType<string, string | number | bigint, "u64">;
908
+ last_update_timestamp: BcsType<string, string | number | bigint, "u64">;
909
+ supply_exchange_price: BcsType<string, string | number | bigint, "u64">;
910
+ borrow_exchange_price: BcsType<string, string | number | bigint, "u64">;
911
+ max_utilization: BcsType<string, string | number | bigint, "u64">;
912
+ total_supply_with_interest: BcsType<string, string | number | bigint, "u64">;
913
+ total_supply_interest_free: BcsType<string, string | number | bigint, "u64">;
914
+ total_borrow_with_interest: BcsType<string, string | number | bigint, "u64">;
915
+ total_borrow_interest_free: BcsType<string, string | number | bigint, "u64">;
916
+ rate_data_version: BcsType<number, number, "u8">;
917
+ supply_positions: _mysten_bcs0.BcsStruct<{
918
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
919
+ size: BcsType<string, string | number | bigint, "u64">;
920
+ }, string>;
921
+ borrow_positions: _mysten_bcs0.BcsStruct<{
922
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
923
+ size: BcsType<string, string | number | bigint, "u64">;
924
+ }, string>;
925
+ }, string>;
926
+ declare const UserSupplyConfig: _mysten_bcs0.BcsStruct<{
927
+ mode: BcsType<number, number, "u8">;
928
+ expand_percent: BcsType<string, string | number | bigint, "u64">;
929
+ expand_duration: BcsType<string, string | number | bigint, "u64">;
930
+ base_withdrawal_limit: BcsType<string, string | number | bigint, "u64">;
931
+ }, string>;
932
+ declare const UserBorrowConfig: _mysten_bcs0.BcsStruct<{
933
+ mode: BcsType<number, number, "u8">;
934
+ expand_percent: BcsType<string, string | number | bigint, "u64">;
935
+ expand_duration: BcsType<string, string | number | bigint, "u64">;
936
+ base_debt_ceiling: BcsType<string, string | number | bigint, "u64">;
937
+ max_debt_ceiling: BcsType<string, string | number | bigint, "u64">;
938
+ }, string>;
939
+ declare const UserSupplyPosition: _mysten_bcs0.BcsStruct<{
940
+ config: BcsType<{
941
+ mode: number;
942
+ expand_percent: string;
943
+ expand_duration: string;
944
+ base_withdrawal_limit: string;
945
+ } | null, {
946
+ mode: number;
947
+ expand_percent: string | number | bigint;
948
+ expand_duration: string | number | bigint;
949
+ base_withdrawal_limit: string | number | bigint;
950
+ } | null | undefined, `Option<${string}>`>;
951
+ paused_supply: BcsType<boolean, boolean, "bool">;
952
+ paused_withdraw: BcsType<boolean, boolean, "bool">;
953
+ amount: BcsType<string, string | number | bigint, "u64">;
954
+ withdrawal_limit: BcsType<string, string | number | bigint, "u64">;
955
+ last_update: BcsType<string, string | number | bigint, "u64">;
956
+ decay_amount: BcsType<string, string | number | bigint, "u64">;
957
+ decay_duration: BcsType<string, string | number | bigint, "u64">;
958
+ }, string>;
959
+ declare const UserBorrowPosition: _mysten_bcs0.BcsStruct<{
960
+ config: BcsType<{
961
+ mode: number;
962
+ expand_percent: string;
963
+ expand_duration: string;
964
+ base_debt_ceiling: string;
965
+ max_debt_ceiling: string;
966
+ } | null, {
967
+ mode: number;
968
+ expand_percent: string | number | bigint;
969
+ expand_duration: string | number | bigint;
970
+ base_debt_ceiling: string | number | bigint;
971
+ max_debt_ceiling: string | number | bigint;
972
+ } | null | undefined, `Option<${string}>`>;
973
+ paused_borrow: BcsType<boolean, boolean, "bool">;
974
+ paused_payback: BcsType<boolean, boolean, "bool">;
975
+ amount: BcsType<string, string | number | bigint, "u64">;
976
+ debt_ceiling: BcsType<string, string | number | bigint, "u64">;
977
+ last_update: BcsType<string, string | number | bigint, "u64">;
978
+ }, string>;
979
+ declare const RateDataV1Params: _mysten_bcs0.BcsStruct<{
980
+ kink: BcsType<string, string | number | bigint, "u64">;
981
+ rate_at_utilization_zero: BcsType<string, string | number | bigint, "u64">;
982
+ rate_at_utilization_kink: BcsType<string, string | number | bigint, "u64">;
983
+ rate_at_utilization_max: BcsType<string, string | number | bigint, "u64">;
984
+ }, string>;
985
+ declare const RateDataV2Params: _mysten_bcs0.BcsStruct<{
986
+ kink1: BcsType<string, string | number | bigint, "u64">;
987
+ kink2: BcsType<string, string | number | bigint, "u64">;
988
+ rate_at_utilization_zero: BcsType<string, string | number | bigint, "u64">;
989
+ rate_at_utilization_kink1: BcsType<string, string | number | bigint, "u64">;
990
+ rate_at_utilization_kink2: BcsType<string, string | number | bigint, "u64">;
991
+ rate_at_utilization_max: BcsType<string, string | number | bigint, "u64">;
992
+ }, string>;
993
+ declare const CapRecord: _mysten_bcs0.BcsStruct<{
994
+ token: _mysten_bcs0.BcsStruct<{
995
+ name: BcsType<string, string, "string">;
996
+ }, string>;
997
+ holder: _mysten_bcs0.BcsEnum<{
998
+ Object: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
999
+ Type: _mysten_bcs0.BcsStruct<{
1000
+ name: BcsType<string, string, "string">;
1001
+ }, string>;
1002
+ }, "Holder">;
1003
+ }, string>;
1004
+ declare const LendingState: _mysten_bcs0.BcsStruct<{
1005
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1006
+ supply: BcsType<string, string | number | bigint, "u64">;
1007
+ reserve_id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1008
+ rewards_writer: BcsType<string | null, string | Uint8Array<ArrayBufferLike> | null | undefined, "Option<bytes[32]>">;
1009
+ token_exchange_price: BcsType<string, string | number | bigint, "u64">;
1010
+ liquidity_exchange_price: BcsType<string, string | number | bigint, "u64">;
1011
+ last_update_s: BcsType<string, string | number | bigint, "u64">;
1012
+ }, string>;
1013
+ declare const RewardsSchedule$1: _mysten_bcs0.BcsStruct<{
1014
+ start_tvl: BcsType<string, string | number | bigint, "u64">;
1015
+ start_s: BcsType<string, string | number | bigint, "u64">;
1016
+ end_s: BcsType<string, string | number | bigint, "u64">;
1017
+ yearly_reward: BcsType<string, string | number | bigint, "u64">;
1018
+ next_start_s: BcsType<string, string | number | bigint, "u64">;
1019
+ next_end_s: BcsType<string, string | number | bigint, "u64">;
1020
+ next_yearly_reward: BcsType<string, string | number | bigint, "u64">;
1021
+ }, string>;
1022
+ declare const LendingRegistry: _mysten_bcs0.BcsStruct<{
1023
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1024
+ version: BcsType<string, string | number | bigint, "u64">;
1025
+ }, string>;
1026
+ declare const RiskConfig: _mysten_bcs0.BcsStruct<{
1027
+ collateral_factor: BcsType<number, number, "u16">;
1028
+ liquidation_threshold: BcsType<number, number, "u16">;
1029
+ liquidation_max_limit: BcsType<number, number, "u16">;
1030
+ withdraw_gap: BcsType<number, number, "u16">;
1031
+ liquidation_penalty: BcsType<number, number, "u16">;
1032
+ borrow_fee: BcsType<number, number, "u8">;
1033
+ }, string>;
1034
+ declare const RateMagnifier: _mysten_bcs0.BcsStruct<{
1035
+ magnitude: BcsType<number, number, "u16">;
1036
+ negative: BcsType<boolean, boolean, "bool">;
1037
+ }, string>;
1038
+ declare const VaultMarket: _mysten_bcs0.BcsStruct<{
1039
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1040
+ vault_id: BcsType<string, string | number | bigint, "u64">;
1041
+ risk: _mysten_bcs0.BcsStruct<{
1042
+ collateral_factor: BcsType<number, number, "u16">;
1043
+ liquidation_threshold: BcsType<number, number, "u16">;
1044
+ liquidation_max_limit: BcsType<number, number, "u16">;
1045
+ withdraw_gap: BcsType<number, number, "u16">;
1046
+ liquidation_penalty: BcsType<number, number, "u16">;
1047
+ borrow_fee: BcsType<number, number, "u8">;
1048
+ }, string>;
1049
+ supply_rate_magnifier: _mysten_bcs0.BcsStruct<{
1050
+ magnitude: BcsType<number, number, "u16">;
1051
+ negative: BcsType<boolean, boolean, "bool">;
1052
+ }, string>;
1053
+ borrow_rate_magnifier: _mysten_bcs0.BcsStruct<{
1054
+ magnitude: BcsType<number, number, "u16">;
1055
+ negative: BcsType<boolean, boolean, "bool">;
1056
+ }, string>;
1057
+ vault_type: BcsType<number, number, "u8">;
1058
+ oracle: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1059
+ liquidity_program: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1060
+ col_decimals: BcsType<number, number, "u8">;
1061
+ debt_decimals: BcsType<number, number, "u8">;
1062
+ branch_liquidated: BcsType<boolean, boolean, "bool">;
1063
+ topmost_tick: _mysten_bcs0.BcsStruct<{
1064
+ mag: BcsType<number, number, "u32">;
1065
+ neg: BcsType<boolean, boolean, "bool">;
1066
+ }, string>;
1067
+ current_branch_id: BcsType<string, string | number | bigint, "u64">;
1068
+ total_branch_id: BcsType<string, string | number | bigint, "u64">;
1069
+ total_supply: BcsType<string, string | number | bigint, "u64">;
1070
+ total_borrow: BcsType<string, string | number | bigint, "u64">;
1071
+ absorbed_debt_amount: BcsType<string, string | number | bigint, "u128">;
1072
+ absorbed_col_amount: BcsType<string, string | number | bigint, "u128">;
1073
+ absorbed_dust_debt: BcsType<string, string | number | bigint, "u64">;
1074
+ liquidity_supply_exchange_price: BcsType<string, string | number | bigint, "u64">;
1075
+ liquidity_borrow_exchange_price: BcsType<string, string | number | bigint, "u64">;
1076
+ vault_supply_exchange_price: BcsType<string, string | number | bigint, "u64">;
1077
+ vault_borrow_exchange_price: BcsType<string, string | number | bigint, "u64">;
1078
+ last_update_timestamp: BcsType<string, string | number | bigint, "u64">;
1079
+ ticks: _mysten_bcs0.BcsStruct<{
1080
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1081
+ size: BcsType<string, string | number | bigint, "u64">;
1082
+ }, string>;
1083
+ branches: _mysten_bcs0.BcsStruct<{
1084
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1085
+ size: BcsType<string, string | number | bigint, "u64">;
1086
+ }, string>;
1087
+ liq_snaps: _mysten_bcs0.BcsStruct<{
1088
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1089
+ size: BcsType<string, string | number | bigint, "u64">;
1090
+ }, string>;
1091
+ tick_bitmap: _mysten_bcs0.BcsStruct<{
1092
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1093
+ size: BcsType<string, string | number | bigint, "u64">;
1094
+ }, string>;
1095
+ }, string>;
1096
+ declare const VaultTick: _mysten_bcs0.BcsStruct<{
1097
+ is_liquidated: BcsType<boolean, boolean, "bool">;
1098
+ total_ids: BcsType<number, number, "u32">;
1099
+ raw_debt: BcsType<string, string | number | bigint, "u64">;
1100
+ is_fully_liquidated: BcsType<boolean, boolean, "bool">;
1101
+ liquidation_branch_id: BcsType<string, string | number | bigint, "u64">;
1102
+ debt_factor: BcsType<string, string | number | bigint, "u64">;
1103
+ }, string>;
1104
+ declare const TickIdLiquidation: _mysten_bcs0.BcsStruct<{
1105
+ is_fully_liquidated: BcsType<boolean, boolean, "bool">;
1106
+ liquidation_branch_id: BcsType<string, string | number | bigint, "u64">;
1107
+ debt_factor: BcsType<string, string | number | bigint, "u64">;
1108
+ }, string>;
1109
+ declare const TickIdLiquidationKey: _mysten_bcs0.BcsStruct<{
1110
+ tick: _mysten_bcs0.BcsStruct<{
1111
+ mag: BcsType<number, number, "u32">;
1112
+ neg: BcsType<boolean, boolean, "bool">;
1113
+ }, string>;
1114
+ tick_map: BcsType<number, number, "u32">;
1115
+ }, string>;
1116
+ declare const BranchStatus: _mysten_bcs0.BcsEnum<{
1117
+ NotLiquidated: null;
1118
+ Liquidated: null;
1119
+ Merged: null;
1120
+ Closed: null;
1121
+ }, "BranchStatus">;
1122
+ declare const Branch: _mysten_bcs0.BcsStruct<{
1123
+ status: _mysten_bcs0.BcsEnum<{
1124
+ NotLiquidated: null;
1125
+ Liquidated: null;
1126
+ Merged: null;
1127
+ Closed: null;
1128
+ }, "BranchStatus">;
1129
+ minima_tick: _mysten_bcs0.BcsStruct<{
1130
+ mag: BcsType<number, number, "u32">;
1131
+ neg: BcsType<boolean, boolean, "bool">;
1132
+ }, string>;
1133
+ minima_tick_partials: BcsType<number, number, "u32">;
1134
+ debt_liquidity: BcsType<string, string | number | bigint, "u64">;
1135
+ debt_factor: BcsType<string, string | number | bigint, "u64">;
1136
+ connected_branch_id: BcsType<string, string | number | bigint, "u64">;
1137
+ connected_minima_tick: _mysten_bcs0.BcsStruct<{
1138
+ mag: BcsType<number, number, "u32">;
1139
+ neg: BcsType<boolean, boolean, "bool">;
1140
+ }, string>;
1141
+ }, string>;
1142
+ declare const Position: _mysten_bcs0.BcsStruct<{
1143
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1144
+ vault_id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1145
+ position_mint: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1146
+ is_supply_only_position: BcsType<boolean, boolean, "bool">;
1147
+ tick: _mysten_bcs0.BcsStruct<{
1148
+ mag: BcsType<number, number, "u32">;
1149
+ neg: BcsType<boolean, boolean, "bool">;
1150
+ }, string>;
1151
+ tick_id: BcsType<number, number, "u32">;
1152
+ supply_amount: BcsType<string, string | number | bigint, "u64">;
1153
+ dust_debt_amount: BcsType<string, string | number | bigint, "u64">;
1154
+ }, string>;
1155
+ declare const VaultRegistry: _mysten_bcs0.BcsStruct<{
1156
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1157
+ next_vault_id: BcsType<string, string | number | bigint, "u64">;
1158
+ version: BcsType<string, string | number | bigint, "u64">;
1159
+ }, string>;
1160
+ declare const OracleRegistry: _mysten_bcs0.BcsStruct<{
1161
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1162
+ version: BcsType<string, string | number | bigint, "u64">;
1163
+ total_oracles: BcsType<string, string | number | bigint, "u64">;
1164
+ }, string>;
1165
+ declare const OracleSourceType: _mysten_bcs0.BcsEnum<{
1166
+ Redstone: _mysten_bcs0.BcsStruct<{
1167
+ adapter_id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1168
+ }, string>;
1169
+ Pyth: null;
1170
+ }, "SourceType">;
1171
+ declare const OracleSource$1: _mysten_bcs0.BcsStruct<{
1172
+ feed_id: BcsType<number[], Iterable<number> & {
1173
+ length: number;
1174
+ }, string>;
1175
+ invert: BcsType<boolean, boolean, "bool">;
1176
+ source_type: _mysten_bcs0.BcsEnum<{
1177
+ Redstone: _mysten_bcs0.BcsStruct<{
1178
+ adapter_id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1179
+ }, string>;
1180
+ Pyth: null;
1181
+ }, "SourceType">;
1182
+ }, string>;
1183
+ /** `fluid_oracle::oracle::Oracle` derived from the registry by nonce. */
1184
+ declare const OracleObject: _mysten_bcs0.BcsStruct<{
1185
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1186
+ nonce: BcsType<number, number, "u16">;
1187
+ main: _mysten_bcs0.BcsStruct<{
1188
+ feed_id: BcsType<number[], Iterable<number> & {
1189
+ length: number;
1190
+ }, string>;
1191
+ invert: BcsType<boolean, boolean, "bool">;
1192
+ source_type: _mysten_bcs0.BcsEnum<{
1193
+ Redstone: _mysten_bcs0.BcsStruct<{
1194
+ adapter_id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1195
+ }, string>;
1196
+ Pyth: null;
1197
+ }, "SourceType">;
1198
+ }, string>;
1199
+ guard: BcsType<{
1200
+ feed_id: number[];
1201
+ invert: boolean;
1202
+ source_type: _mysten_bcs0.EnumOutputShapeWithKeys<{
1203
+ Redstone: {
1204
+ adapter_id: string;
1205
+ };
1206
+ Pyth: true;
1207
+ }, "Redstone" | "Pyth">;
1208
+ } | null, {
1209
+ feed_id: Iterable<number> & {
1210
+ length: number;
1211
+ };
1212
+ invert: boolean;
1213
+ source_type: _mysten_bcs0.EnumInputShape<{
1214
+ Redstone: {
1215
+ adapter_id: string | Uint8Array<ArrayBufferLike>;
1216
+ };
1217
+ Pyth: boolean | object | null;
1218
+ }>;
1219
+ } | null | undefined, `Option<${string}>`>;
1220
+ }, string>;
1221
+ /** `view::PriceQuote`: each rate is optional (operate-only / liquidate-only quotes). */
1222
+ declare const PriceQuote: _mysten_bcs0.BcsStruct<{
1223
+ oracle_id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1224
+ rate_liquidate: BcsType<string | null, string | number | bigint | null | undefined, "Option<u128>">;
1225
+ rate_operate: BcsType<string | null, string | number | bigint | null | undefined, "Option<u128>">;
1226
+ }, string>;
1227
+ /** `pyth::price_info::PriceInfoObject`. */
1228
+ declare const PythPriceInfoObject: _mysten_bcs0.BcsStruct<{
1229
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1230
+ price_info: _mysten_bcs0.BcsStruct<{
1231
+ attestation_time: BcsType<string, string | number | bigint, "u64">;
1232
+ arrival_time: BcsType<string, string | number | bigint, "u64">;
1233
+ price_feed: _mysten_bcs0.BcsStruct<{
1234
+ price_identifier: _mysten_bcs0.BcsStruct<{
1235
+ bytes: BcsType<number[], Iterable<number> & {
1236
+ length: number;
1237
+ }, string>;
1238
+ }, string>;
1239
+ price: _mysten_bcs0.BcsStruct<{
1240
+ price: _mysten_bcs0.BcsStruct<{
1241
+ negative: BcsType<boolean, boolean, "bool">;
1242
+ magnitude: BcsType<string, string | number | bigint, "u64">;
1243
+ }, string>;
1244
+ conf: BcsType<string, string | number | bigint, "u64">;
1245
+ expo: _mysten_bcs0.BcsStruct<{
1246
+ negative: BcsType<boolean, boolean, "bool">;
1247
+ magnitude: BcsType<string, string | number | bigint, "u64">;
1248
+ }, string>;
1249
+ timestamp: BcsType<string, string | number | bigint, "u64">;
1250
+ }, string>;
1251
+ ema_price: _mysten_bcs0.BcsStruct<{
1252
+ price: _mysten_bcs0.BcsStruct<{
1253
+ negative: BcsType<boolean, boolean, "bool">;
1254
+ magnitude: BcsType<string, string | number | bigint, "u64">;
1255
+ }, string>;
1256
+ conf: BcsType<string, string | number | bigint, "u64">;
1257
+ expo: _mysten_bcs0.BcsStruct<{
1258
+ negative: BcsType<boolean, boolean, "bool">;
1259
+ magnitude: BcsType<string, string | number | bigint, "u64">;
1260
+ }, string>;
1261
+ timestamp: BcsType<string, string | number | bigint, "u64">;
1262
+ }, string>;
1263
+ }, string>;
1264
+ }, string>;
1265
+ }, string>;
1266
+ /** `0x2::dynamic_field::Field<K, V>` wrapper. */
1267
+ declare function Field<K, KI, V, VI>(name: BcsType<K, KI>, value: BcsType<V, VI>): _mysten_bcs0.BcsStruct<{
1268
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1269
+ name: BcsType<K, KI, string>;
1270
+ value: BcsType<V, VI, string>;
1271
+ }, string>;
1272
+ declare const bcsU64: BcsType<string, string | number | bigint, "u64">;
1273
+ declare const bcsU16: BcsType<number, number, "u16">;
1274
+ declare const bcsU256: BcsType<string, string | number | bigint, "u256">;
1275
+ declare const bcsId: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1276
+ /** Unit key struct (`RateDataKey`, `RewardsKey`, ...): BCS `dummy_field: bool`. */
1277
+ declare const UnitKey: BcsType<boolean, boolean, "bool">;
1278
+ /** Proposed `fluid_vaults::position_index::PositionIndex` (docs/onchain-position-index.md). */
1279
+ declare const PositionIndex$1: _mysten_bcs0.BcsStruct<{
1280
+ next_position_id: BcsType<string, string | number | bigint, "u64">;
1281
+ caps: _mysten_bcs0.BcsStruct<{
1282
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1283
+ size: BcsType<string, string | number | bigint, "u64">;
1284
+ }, string>;
1285
+ ordinals: _mysten_bcs0.BcsStruct<{
1286
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1287
+ size: BcsType<string, string | number | bigint, "u64">;
1288
+ }, string>;
1289
+ }, string>;
1290
+ declare const PositionIndexField: _mysten_bcs0.BcsStruct<{
1291
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1292
+ name: BcsType<boolean, boolean, string>;
1293
+ value: BcsType<{
1294
+ next_position_id: string;
1295
+ caps: {
1296
+ id: string;
1297
+ size: string;
1298
+ };
1299
+ ordinals: {
1300
+ id: string;
1301
+ size: string;
1302
+ };
1303
+ }, {
1304
+ next_position_id: string | number | bigint;
1305
+ caps: {
1306
+ id: string | Uint8Array<ArrayBufferLike>;
1307
+ size: string | number | bigint;
1308
+ };
1309
+ ordinals: {
1310
+ id: string | Uint8Array<ArrayBufferLike>;
1311
+ size: string | number | bigint;
1312
+ };
1313
+ }, string>;
1314
+ }, string>;
1315
+ /** `caps: Table<u64, ID>` entry: ordinal -> PositionOwnerCap id. */
1316
+ declare const PositionIndexEntry: _mysten_bcs0.BcsStruct<{
1317
+ id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
1318
+ name: BcsType<string, string | number | bigint, string>;
1319
+ value: BcsType<string, string | Uint8Array<ArrayBufferLike>, string>;
1320
+ }, string>;
1321
+ //#endregion
1322
+ //#region src/objects.d.ts
1323
+ type FetchedObject = {
1324
+ objectId: string;
1325
+ type: string;
1326
+ content: Uint8Array;
1327
+ owner: unknown;
1154
1328
  };
1155
- declare namespace liquidity_d_exports {
1156
- export { ReserveSnapshot, calcBorrowLimitBeforeOperate, calcRevenue, calcWithdrawalLimitBeforeOperate, calculateExchangePrice, emptyUserBorrowData, emptyUserSupplyData, processOverallTokenData, processUserBorrowData, processUserSupplyData, totalAmountsOf, totalBorrowNormal, totalSupplyNormal };
1329
+ declare class ObjectNotFoundError extends Error {
1330
+ readonly objectId: string;
1331
+ readonly what: string;
1332
+ constructor(objectId: string, what: string);
1157
1333
  }
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
1334
  //#endregion
1196
1335
  //#region src/liquidity.d.ts
1197
1336
  type ReserveRecord = {
@@ -1204,7 +1343,11 @@ type ReserveRecord = {
1204
1343
  declare class Liquidity {
1205
1344
  private readonly ctx;
1206
1345
  constructor(ctx: ReadContext);
1207
- /** Reserves + their rate-data fields in 2 batched round trips. */
1346
+ /** Object ids `loadReserves` reads: every reserve, then every reserve's rate-data field. */
1347
+ reserveObjectIds(tokens: readonly string[]): string[];
1348
+ /** Parse objects fetched for `reserveObjectIds(tokens)` (same order). */
1349
+ reservesFromObjects(tokens: readonly string[], objs: readonly (FetchedObject | null)[]): ReserveRecord[];
1350
+ /** Reserves + their rate-data fields in one batched `getObjects`. */
1208
1351
  loadReserves(tokens: readonly string[]): Promise<ReserveRecord[]>;
1209
1352
  loadReserve(token: string): Promise<ReserveRecord>;
1210
1353
  /** Supply/borrow Table entries of `holders` on `reserves` (one batched round trip). */
@@ -1252,8 +1395,8 @@ declare class Liquidity {
1252
1395
  /** Listed tokens (see `discoverTokens`; pure state by default). */
1253
1396
  listedTokens(): Promise<string[]>;
1254
1397
  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;
1398
+ /** Pure: accrue a reserve snapshot to `now` (unix seconds; use `await ctx.now()` for chain time). */
1399
+ calculateExchangePrice(snapshot: ReserveSnapshot, now: bigint): ExchangePriceResult;
1257
1400
  getRateConfig(token: string): Promise<RateModelAccount | null>;
1258
1401
  getTotalAmounts(token: string): Promise<TotalAmounts>;
1259
1402
  getConfigs2(token: string): Promise<{
@@ -1262,18 +1405,18 @@ declare class Liquidity {
1262
1405
  getRevenue(token: string): Promise<bigint>;
1263
1406
  getTokenRateData(token: string): Promise<RateData>;
1264
1407
  getTokensRateData(tokens: readonly string[]): Promise<RateData[]>;
1265
- overallFromRecord(r: ReserveRecord, now?: bigint): OverallTokenData;
1408
+ overallFromRecord(r: ReserveRecord, now: bigint): OverallTokenData;
1266
1409
  getOverallTokenData(token: string): Promise<OverallTokenData>;
1267
1410
  getOverallTokensData(tokens: readonly string[]): Promise<OverallTokenData[]>;
1268
1411
  getAllOverallTokensData(): Promise<OverallTokenData[]>;
1269
1412
  /** Raw supply position of a holder, or `0n` when none exists (Solana returns BN 0). */
1270
1413
  getUserSupply(user: string, token: string): Promise<UserSupplyPositionAccount | bigint>;
1271
1414
  getUserBorrow(user: string, token: string): Promise<UserBorrowPositionAccount | bigint>;
1272
- supplyDataFromRecords(reserve: ReserveRecord, acc: UserSupplyPositionAccount | null, now?: bigint): {
1415
+ supplyDataFromRecords(reserve: ReserveRecord, acc: UserSupplyPositionAccount | null, now: bigint): {
1273
1416
  userSupplyData: UserSupplyData;
1274
1417
  overallTokenData: OverallTokenData;
1275
1418
  };
1276
- borrowDataFromRecords(reserve: ReserveRecord, acc: UserBorrowPositionAccount | null, now?: bigint): {
1419
+ borrowDataFromRecords(reserve: ReserveRecord, acc: UserBorrowPositionAccount | null, now: bigint): {
1277
1420
  userBorrowData: UserBorrowData;
1278
1421
  overallTokenData: OverallTokenData;
1279
1422
  };
@@ -1330,7 +1473,7 @@ declare class Liquidity {
1330
1473
  private listAllUserPositions;
1331
1474
  }
1332
1475
  declare namespace lending_d_exports {
1333
- export { LendingSnapshot, RewardsSchedule, accruedTokenExchangePrice, currentRewardsRate, previews, rateSegments, rewardsRateFor, toAssets, toShares };
1476
+ export { LendingSnapshot, RewardsSchedule, accruedTokenExchangePrice, currentRewardsRate, previews, rateSegments, rewardsRateFor, rewardsTvl, toAssets, toShares };
1334
1477
  }
1335
1478
  type RewardsSchedule = {
1336
1479
  startTvl: bigint;
@@ -1358,12 +1501,22 @@ declare function rateSegments(s: RewardsSchedule, totalAssets: bigint, fromS: bi
1358
1501
  fromS: bigint;
1359
1502
  toS: bigint;
1360
1503
  }[];
1361
- /** Current rewards rate (1e12 = 100%) at `now`, from the active schedule segment. */
1362
- declare function currentRewardsRate(state: LendingSnapshot, now: bigint): bigint;
1504
+ /**
1505
+ * TVL the contract prices rewards on: total shares at the STORED (pre-accrual) token exchange
1506
+ * price, as `accounting::accrued_token_exchange_price` does. Rounded up on "audited" packages
1507
+ * (742ea21+), floored on the 09-18 "pre-audit" packages.
1508
+ */
1509
+ declare const rewardsTvl: (state: LendingSnapshot, variant?: MathVariant) => bigint;
1510
+ /**
1511
+ * Current rewards rate (raw, RETURN_PERCENT_PRECISION: 1e14 = 100%) at `now`, from the active schedule segment, priced on
1512
+ * the pre-accrual TVL (`rewardsTvl`) exactly as the contract prices the segment it will credit.
1513
+ * Windows are [start, end): the rate is live from `startS` and gone at `endS`.
1514
+ */
1515
+ declare function currentRewardsRate(state: LendingSnapshot, now: bigint, variant?: MathVariant): bigint;
1363
1516
  /** `accounting::accrued_token_exchange_price`. */
1364
- declare function accruedTokenExchangePrice(state: LendingSnapshot, newLiquidityExchangePrice: bigint, nowS: bigint): bigint;
1517
+ declare function accruedTokenExchangePrice(state: LendingSnapshot, newLiquidityExchangePrice: bigint, nowS: bigint, variant?: MathVariant): bigint;
1365
1518
  /** `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): {
1519
+ declare function previews(state: LendingSnapshot, liquidityExchangePrice: bigint, nowS: bigint, assets: bigint, shares: bigint, variant?: MathVariant): {
1367
1520
  tokenExchangePrice: bigint;
1368
1521
  previewDeposit: bigint;
1369
1522
  previewMint: bigint;
@@ -1378,12 +1531,29 @@ type LendingRecord = {
1378
1531
  raw: ReturnType<typeof LendingState.parse>;
1379
1532
  snapshot: LendingSnapshot;
1380
1533
  };
1534
+ type Pool = {
1535
+ lending: LendingRecord;
1536
+ reserve: ReserveRecord;
1537
+ supplyEntry: UserSupplyPositionAccount | null;
1538
+ };
1381
1539
  declare class Lending {
1382
1540
  private readonly ctx;
1383
1541
  private readonly liquidity;
1384
1542
  constructor(ctx: ReadContext, liquidity: Liquidity);
1543
+ /** Object ids `loadLendings` reads: every LendingState, then every rewards field. */
1544
+ lendingObjectIds(tokens: readonly string[]): string[];
1385
1545
  /** LendingStates (+ rewards fields) for `tokens`; `null` where no pool exists. */
1386
1546
  loadLendings(tokens: readonly string[]): Promise<(LendingRecord | null)[]>;
1547
+ lendingsFromObjects(tokens: readonly string[], objs: readonly (FetchedObject | null)[]): (LendingRecord | null)[];
1548
+ /**
1549
+ * Everything a pool read needs in ONE `getObjects` batch (LendingState, rewards field,
1550
+ * TokenReserve, rate data per token; 50 ids per request, chunks in parallel), plus the chain
1551
+ * clock in parallel. With `withEntries`, a second batch reads each pool's liquidity supply entry.
1552
+ */
1553
+ loadPools(tokens: readonly string[], withEntries?: boolean): Promise<{
1554
+ pools: Pool[];
1555
+ now: bigint;
1556
+ }>;
1387
1557
  private loadOne;
1388
1558
  getAllLendings(): Promise<LendingAccount[]>;
1389
1559
  /** Underlying coin types that have a lending pool. */
@@ -1397,17 +1567,50 @@ declare class Lending {
1397
1567
  name: string;
1398
1568
  symbol: string;
1399
1569
  decimals: number;
1400
- }, now?: bigint): FTokenDetails;
1401
- private fTokenMeta;
1570
+ }, now: bigint): FTokenDetails;
1571
+ /** fToken name/symbol/decimals (cached; falls back to the underlying's metadata). */
1572
+ fTokenMeta(token: string): Promise<CoinMeta>;
1402
1573
  getFTokenDetails(token: string): Promise<FTokenDetails>;
1574
+ /** Details for many fTokens: 2 batched object reads + the clock, metadata cached. */
1575
+ getFTokensDetails(tokens: readonly string[]): Promise<FTokenDetails[]>;
1576
+ private detailsWithPrices;
1403
1577
  /** @deprecated Solana name; use `getFTokenDetails`. */
1404
1578
  getJlTokenDetails: (token: string) => Promise<FTokenDetails>;
1405
1579
  getAllFTokenDetails(): Promise<FTokenDetails[]>;
1580
+ /** Underlying coin types that have a lending pool (pure state: one batched existence read). */
1581
+ listedLendingTokens(): Promise<string[]>;
1406
1582
  /** @deprecated Solana name; use `getAllFTokenDetails`. */
1407
1583
  getAllJlTokenDetails: () => Promise<FTokenDetails[]>;
1408
1584
  getFTokenInternalData(token: string): Promise<FTokenInternalData>;
1409
1585
  /** @deprecated Solana name; use `getFTokenInternalData`. */
1410
1586
  getJlTokenInternalData: (token: string) => Promise<FTokenInternalData>;
1587
+ /**
1588
+ * Generic lending state per fToken (identity, accrued + stored exchange prices, TVL, rates in
1589
+ * bps, rewards schedule) for `tokens` (underlying coin types), or every listed pool when
1590
+ * omitted. One batched `getObjects` for all pools + the on-chain Clock; metadata cached.
1591
+ */
1592
+ getLendingStateData(tokens?: readonly string[]): Promise<LendingStateData[]>;
1593
+ /** Pure: `LendingStateData` from loaded records at `now`. */
1594
+ stateDataFrom(lending: LendingRecord, reserve: ReserveRecord, decimals: number, now: bigint): LendingStateData;
1595
+ /**
1596
+ * Wallet holders of `Coin<FToken<T>>` for `token` (underlying coin type), via the GraphQL
1597
+ * indexer (`config.graphqlUrl`; needs `discovery: "indexer"`). Lists every Coin<FToken<T>>
1598
+ * object by type and keeps the ones with an ADDRESS owner (AddressOwner or
1599
+ * ConsensusAddressOwner), aggregated by owner, all pages at one checkpoint (consistent cursors).
1600
+ *
1601
+ * LIMITS (documented, by design): coins owned by other objects, shared/immutable coins and
1602
+ * wrapped `Balance<FToken<T>>` (inside other protocols' objects) are NOT attributed to a wallet;
1603
+ * nor are address balances (funds credited to an address without a coin object), since they are
1604
+ * not objects and cannot be enumerated by type. `totalSupply` is returned so a caller can
1605
+ * compare it with the sum of the wallets. With `verify` (default true) each wallet is cross-checked against
1606
+ * fullnode `getBalance` (coinBalance + addressBalance), `concurrency` at a time (default 8).
1607
+ */
1608
+ getFTokenHolders(token: string, opts?: {
1609
+ verify?: boolean;
1610
+ concurrency?: number;
1611
+ pageSize?: number;
1612
+ }): Promise<FTokenHolders>;
1613
+ /** `[rewards writer cap id, current rewards rate in bps]`. */
1411
1614
  getFTokenRewards(token: string): Promise<[string | null, bigint]>;
1412
1615
  /** @deprecated Solana name; use `getFTokenRewards`. */
1413
1616
  getJlTokenRewards: (token: string) => Promise<[string | null, bigint]>;
@@ -1427,7 +1630,7 @@ declare class Lending {
1427
1630
  /** Oracle rates are debt-per-collateral in the vault's internal 1e9 space, scaled by 1e15. */
1428
1631
  declare const ORACLE_RATE_PRECISION = 1000000000000000n;
1429
1632
  /** Mirrors `fluid_oracle::constants` of the deployed v2 package. */
1430
- declare const ORACLE_V2_LIMITS: {
1633
+ declare const ORACLE_LIMITS: {
1431
1634
  readonly rateOutputDecimals: 15;
1432
1635
  readonly maxAgeOperateS: 600n;
1433
1636
  readonly maxAgeLiquidateS: 7200n;
@@ -1443,14 +1646,12 @@ declare function scaleAndInvert(raw: bigint, decimals: number, invert: boolean):
1443
1646
  declare class Oracle {
1444
1647
  private readonly ctx;
1445
1648
  constructor(ctx: ReadContext);
1446
- private get v2();
1447
- /** Admin oracle object (2026-09-18 preset). */
1448
- getOracle(oracleId: string): Promise<AdminOracle>;
1649
+ private get providers();
1449
1650
  /** v2 oracle object: nonce + main / guard routes. */
1450
- getOracleV2(oracleId: string): Promise<OracleV2>;
1651
+ getOracle(oracleId: string): Promise<OracleData>;
1451
1652
  /** Provider objects the v2 views take for this oracle. */
1452
1653
  private providerArgs;
1453
- private quoteV2;
1654
+ private quote;
1454
1655
  /** Price exactly as vaults see it. v2: operate and liquidate simulated separately (one can abort alone). */
1455
1656
  getOraclePrice(oracleId: string): Promise<OraclePrice>;
1456
1657
  /**
@@ -1459,7 +1660,7 @@ declare class Oracle {
1459
1660
  * Operate price = min over routes; liquidate = min over routes usable for liquidate.
1460
1661
  */
1461
1662
  getOracleRoutes(oracleId: string): Promise<{
1462
- oracle: OracleV2;
1663
+ oracle: OracleData;
1463
1664
  nowMs: bigint;
1464
1665
  main: OracleRoute;
1465
1666
  guard: OracleRoute | null;
@@ -1480,7 +1681,18 @@ declare const RATE_OUTPUT_DECIMALS = 100000000000000000n;
1480
1681
  declare const EXCHANGE_PRICE_SCALE_FACTOR = 1000000000000000000n;
1481
1682
  /** Lending return precision (1e14 = 1e12 * 100). */
1482
1683
  declare const RETURN_PERCENT_PRECISION = 100000000000000n;
1483
- /** Lending max rewards rate (50% in 1e12). */
1684
+ /**
1685
+ * The two raw on-chain rate scales differ, which is why every rate FIELD the SDK returns is bps
1686
+ * (1e4 = 100% per year, floored):
1687
+ * - liquidity supply rate (`reserve::calculate_exchange_prices`): 1e12 = 100% -> SUPPLY_RATE_PRECISION
1688
+ * - lending rewards rate (`rewards`, `lending_calcs`): 1e14 = 100% -> RETURN_PERCENT_PRECISION
1689
+ */
1690
+ declare const SUPPLY_RATE_PRECISION = 1000000000000n;
1691
+ /** Raw liquidity supply rate (1e12 = 100%) -> bps, floored. */
1692
+ declare const supplyRateToBps: (raw: bigint) => bigint;
1693
+ /** Raw lending rewards rate (1e14 = 100%) -> bps, floored. */
1694
+ declare const rewardsRateToBps: (raw: bigint) => bigint;
1695
+ /** Lending max rewards rate: 50% at RETURN_PERCENT_PRECISION (1e14 = 100%). */
1484
1696
  declare const MAX_REWARDS_RATE = 50000000000000n;
1485
1697
  declare function mulDiv(a: bigint, b: bigint, c: bigint): bigint;
1486
1698
  declare function divCeil(a: bigint, b: bigint): bigint;
@@ -1622,7 +1834,7 @@ declare class Vault {
1622
1834
  positionCounts?: boolean;
1623
1835
  }): Promise<VaultState>;
1624
1836
  /** `user::get_exchange_prices`: (liqSupply, liqBorrow, vaultSupply, vaultBorrow) accrued to `now`. */
1625
- exchangePricesFromRecords(v: VaultRecord, colReserve: ReserveRecord, debtReserve: ReserveRecord, now?: bigint): {
1837
+ exchangePricesFromRecords(v: VaultRecord, colReserve: ReserveRecord, debtReserve: ReserveRecord, now: bigint): {
1626
1838
  liquiditySupplyExchangePrice: bigint;
1627
1839
  liquidityBorrowExchangePrice: bigint;
1628
1840
  vaultSupplyExchangePrice: bigint;
@@ -1732,22 +1944,32 @@ declare class Vault {
1732
1944
  //#region src/client.d.ts
1733
1945
  declare const DEFAULT_RPC_URL = "https://fullnode.mainnet.sui.io:443";
1734
1946
  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;
1947
+ /**
1948
+ * REQUIRED. Built-in network name ("staging") or a
1949
+ * full config (e.g. production from `configFromDeployment`). No default, so nobody reads
1950
+ * staging believing it is production.
1951
+ */
1952
+ network: string | FluidReadConfig;
1953
+ /**
1954
+ * Clock for time-dependent maths. Default "chain": the on-chain Clock (0x6), so accrual and the
1955
+ * rewards windows never depend on this server's clock. "local" = wall clock; or a function
1956
+ * returning unix seconds.
1957
+ */
1958
+ now?: ClockSource;
1739
1959
  /** Enumeration policy. Default "state" (no indexer, no list queries). See `DiscoveryLevel`. */
1740
1960
  discovery?: DiscoveryLevel;
1741
1961
  /** Per-call timeout before failing over to the next endpoint. Default 15000 ms. */
1742
1962
  timeoutMs?: number;
1963
+ /** Retry passes over the endpoints with exponential backoff (see `FailoverOptions`). Default 3 passes, 250 ms base, 4 s cap. */
1964
+ retry?: Pick<FailoverOptions, "rounds" | "backoffMs" | "maxBackoffMs">;
1743
1965
  };
1744
1966
  /**
1745
1967
  * Unified reader, same shape as `@jup-ag/lend-read`'s `Client`:
1746
1968
  * `client.liquidity`, `client.lending`, `client.vault` (+ `client.oracle`, Sui-only).
1747
1969
  *
1748
1970
  * @example
1749
- * const client = new Client(); // staging deployment, Sui mainnet gRPC
1750
- * const client = new Client("https://my-fullnode:443");
1971
+ * const client = new Client(undefined, { network: "staging" }); // staging deployment, Sui mainnet gRPC
1972
+ * const client = new Client("https://my-fullnode:443", { network: prodConfig });
1751
1973
  * const client = new Client(existingSuiGrpcClient, { network: "staging" });
1752
1974
  * const vault = await client.vault.getVaultEntireData(1);
1753
1975
  */
@@ -1757,47 +1979,29 @@ declare class Client {
1757
1979
  readonly vault: Vault;
1758
1980
  readonly oracle: Oracle;
1759
1981
  readonly context: ReadContext;
1760
- constructor(rpc?: string | readonly (string | ClientWithCoreApi)[] | ClientWithCoreApi, opts?: ClientOptions);
1982
+ constructor(rpc: string | readonly (string | ClientWithCoreApi)[] | ClientWithCoreApi | undefined, opts: ClientOptions);
1983
+ /**
1984
+ * The same reader pinned to a past `checkpoint`: every object read comes from the GraphQL service
1985
+ * (`config.graphqlUrl`) at that checkpoint and the clock is the checkpoint's timestamp, so
1986
+ * `lending.getLendingStateData()`, rates, reserves and vault state are what the chain held then.
1987
+ * Move views / oracle quotes / balances are not available historically (`CheckpointReadError`).
1988
+ * Needs `discovery: "indexer"` (it is a GraphQL read).
1989
+ *
1990
+ * @example
1991
+ * const past = await client.atCheckpoint(330_000_000);
1992
+ * const state = await past.lending.getLendingStateData();
1993
+ */
1994
+ atCheckpoint(checkpoint: number | bigint): Promise<Client>;
1761
1995
  }
1762
1996
  /**
1763
1997
  * `$extend` form, same pattern as the write SDK's `fluid()`:
1764
1998
  * `const c = new SuiGrpcClient({...}).$extend(fluidRead()); c.fluidRead.vault...`
1765
1999
  */
1766
- declare function fluidRead(opts?: ClientOptions): {
2000
+ declare function fluidRead(opts: ClientOptions): {
1767
2001
  name: "fluidRead";
1768
2002
  register: (client: ClientWithCoreApi) => Client;
1769
2003
  };
1770
2004
  //#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
2005
  //#region src/view.d.ts
1802
2006
  declare class ViewCallError extends Error {
1803
2007
  readonly details?: unknown | undefined;
@@ -1809,12 +2013,39 @@ declare class ViewCallError extends Error {
1809
2013
  */
1810
2014
  declare function simulateView(client: ClientWithCoreApi, build: (tx: Transaction) => void | TransactionResult | unknown): Promise<Uint8Array[][]>;
1811
2015
  //#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);
2016
+ //#region src/graphql.d.ts
2017
+ declare class GraphQLError extends Error {
2018
+ readonly errors?: unknown | undefined;
2019
+ constructor(message: string, errors?: unknown | undefined);
2020
+ }
2021
+ type GraphQLOptions = {
2022
+ /** Attempts in total. Default 3. */
2023
+ rounds?: number;
2024
+ backoffMs?: number;
2025
+ maxBackoffMs?: number;
2026
+ timeoutMs?: number;
2027
+ };
2028
+ /**
2029
+ * POST one query. Network errors, timeouts, HTTP 429/5xx are retried with backoff; a GraphQL
2030
+ * `errors` payload (bad query, unknown object) is NOT retried.
2031
+ */
2032
+ declare function graphqlQuery<T>(url: string, query: string, variables?: Record<string, unknown>, opts?: GraphQLOptions): Promise<T>;
2033
+ //#endregion
2034
+ //#region src/checkpoint.d.ts
2035
+ declare class CheckpointReadError extends Error {
2036
+ constructor(method: string, checkpoint: bigint);
1817
2037
  }
2038
+ /** Timestamp of `checkpoint` in unix seconds (floored, as `units::from_clock` reads it). */
2039
+ declare function checkpointTimestampSeconds(url: string, checkpoint: bigint, opts?: GraphQLOptions): Promise<bigint>;
2040
+ /** Latest checkpoint the GraphQL service has indexed. */
2041
+ declare function latestCheckpoint(url: string, opts?: GraphQLOptions): Promise<bigint>;
2042
+ /**
2043
+ * A core client pinned to `checkpoint`: `getObjects` via GraphQL at that checkpoint,
2044
+ * `getCoinMetadata` from `live` (immutable data), every other core read throws.
2045
+ */
2046
+ declare function checkpointClient(url: string, checkpoint: bigint, live: ClientWithCoreApi, opts?: GraphQLOptions): ClientWithCoreApi & {
2047
+ checkpoint: bigint;
2048
+ };
1818
2049
  declare namespace vault_d_exports {
1819
2050
  export { BRANCH_STATUS, LiquidationLookups, SignedMagnifier, currentPositionState, fetchLatestPosition, loadVaultExchangePrices, minimumDebt, needsLiquidationSettle, positionInfo, rawToNormal, unscale };
1820
2051
  }
@@ -1918,4 +2149,4 @@ declare function mulBigNumber(a: bigint, b: bigint): bigint;
1918
2149
  /** `big_number::mul_div_normal`: normal * bn1 / bn2. */
1919
2150
  declare function mulDivNormal(normal: bigint, bn1: bigint, bn2: bigint): bigint;
1920
2151
  //#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 };
2152
+ export { AllEndpointsFailedError, CONFIGS, CheckpointReadError, Client, type ClientOptions, Configs, ConstantViews, CurrentBranchState, DEFAULT_RPC_URL, DecodedBranch, DecodedTick, DecodedTickIdLiquidation, type DeploymentRecord, type DiscoveryLevel, EXCHANGE_PRICES_PRECISION, EXCHANGE_PRICE_SCALE_FACTOR, ExchangePriceResult, ExchangePricesAndConfig, ExchangePricesAndRates, FOUR_DECIMALS, FTokenDetails, FTokenDetailsUserPosition, FTokenHolder, FTokenHolders, FTokenInternalData, type FailoverOptions, type FluidDerive, type FluidReadConfig, GraphQLError, type GraphQLOptions, JlTokenDetails, JlTokenDetailsUserPosition, JlTokenInternalData, Lending, LendingAccount, type LendingRecord, LendingStateData, LendingUserPosition, LimitsAndAvailability, Liquidity, LiquidityAccount, MAINNET, MAX_REWARDS_RATE, NeedsDiscoveryError, NftPosition, ORACLE_LIMITS, ORACLE_RATE_PRECISION, ObjectNotFoundError, Oracle, OracleData, OraclePrice, OracleRoute, OracleSource, OverallTokenData, POSITION_INDEX_FIX, type PackageIds, type PositionCounts, PositionIndex, type PositionIndexOptions, type PositionSource, PositionWithRiskRatio, PreviewData, RATE_OUTPUT_DECIMALS, RETURN_PERCENT_PRECISION, RateData, RateDataV1, RateDataV2, RateModelAccount, type ReadContext, type ReserveRecord, RewardsRateModelConfig, SECONDS_PER_YEAR, STAGING, SUPPLY_RATE_PRECISION, TotalAmounts, TotalSupplyAndBorrow, UserBorrowData, UserBorrowPositionAccount, UserPosition, UserPositionWithDebt, UserSupplyData, UserSupplyPositionAccount, Vault, VaultConfig, VaultEntireData, VaultEntireDataV2, type VaultReadOpts, type VaultRecord, VaultState, ViewCallError, backoffDelay, bcs_d_exports as bcsTypes, checkpointClient, checkpointTimestampSeconds, clientForEndpoint, configFromDeployment, createDerive, createFailoverClient, divCeil, fluidRead, graphqlQuery, latestCheckpoint, lending_d_exports as lendingMath, liquidity_d_exports as liquidityMath, max, min, mulDiv, mulDivCeil, nowSeconds, resolveConfig, rewardsRateToBps, scaleAndInvert, simulateView, supplyRateToBps, tick_d_exports as tickMath, vault_d_exports as vaultMath };