@instadapp/fluid-sui-read-sdk 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1921 @@
1
+ import { BcsType } from "@mysten/sui/bcs";
2
+ import { ClientWithCoreApi } from "@mysten/sui/client";
3
+ import { Transaction, TransactionResult } from "@mysten/sui/transactions";
4
+ import * as _mysten_bcs0 from "@mysten/bcs";
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;
12
+ };
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;
51
+ };
52
+ /**
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`.
65
+ */
66
+ positionIndexKeyType?: string;
67
+ /** GraphQL indexer endpoint. Used ONLY with `discovery: "indexer"`. */
68
+ graphqlUrl?: string;
69
+ };
70
+ /**
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).
101
+ */
102
+ type DeploymentRecord = {
103
+ packages: Record<"library" | "liquidity" | "lending" | "oracle" | "vaults" | "lending_rewards", {
104
+ packageId: string;
105
+ originalId?: string;
106
+ objects?: Record<string, string>;
107
+ } | undefined>;
108
+ };
109
+ /**
110
+ * Build a read config from a deployment record instead of the built-in ids, e.g.
111
+ * `configFromDeployment(JSON.parse(readFileSync(path, "utf8")), { network: "mainnet", oracleV2 })`.
112
+ * The record has no RedStone package or Pyth feed map, so `oracleV2` comes from the caller.
113
+ * Throws once, listing every required field the record is missing.
114
+ */
115
+ declare function configFromDeployment(rec: DeploymentRecord, opts: Pick<FluidReadConfig, "network" | "oracleV2"> & Partial<Pick<FluidReadConfig, "tokens" | "rpcUrls" | "graphqlUrl">>): FluidReadConfig;
116
+ declare function resolveConfig(networkOrConfig: string | FluidReadConfig): FluidReadConfig;
117
+ //#endregion
118
+ //#region src/derive.d.ts
119
+ declare function createDerive(cfg: FluidReadConfig): {
120
+ /** `TokenReserve<T>`: derived from the liquidity Registry, key `ReserveKey<T>`. */
121
+ tokenReserveId: (coinType: string) => string;
122
+ /** `LendingState<T>`: derived from the LendingRegistry, key `LendingStateKey<T>`. */
123
+ lendingStateId: (coinType: string) => string;
124
+ /** `VaultMarket<Col, Debt>`: derived from the VaultRegistry, key `VaultKey(u64)`. */
125
+ vaultMarketId: (vaultId: number | bigint) => string;
126
+ /** `Position`: derived from its VaultMarket, key `PositionKey(cap id)`. */
127
+ positionId: (vaultMarketId: string, capId: string) => string;
128
+ holderKeyType: string;
129
+ /** Entry of `TokenReserve.supply_positions` / `borrow_positions` for `Holder::Object(id)`. */
130
+ holderEntryId: (tableId: string, holderObjectId: string) => string;
131
+ /** `RateDataKey` dynamic field on a TokenReserve. */
132
+ rateDataId: (reserveId: string) => string;
133
+ /** `RewardsKey` dynamic field on a LendingState. */
134
+ rewardsId: (lendingStateId: string) => string;
135
+ /** `VaultMarket.ticks` entry. */
136
+ tickEntryId: (ticksTableId: string, tick: number) => string;
137
+ /** `VaultMarket.branches` entry. */
138
+ branchEntryId: (branchesTableId: string, branchId: number | bigint | string) => string;
139
+ /** `VaultMarket.liq_snaps` entry. */
140
+ liqSnapEntryId: (snapsTableId: string, tick: number, tickId: number) => string;
141
+ /** `VaultMarket.tick_bitmap` word. */
142
+ bitmapWordId: (bitmapTableId: string, word: number) => string;
143
+ /**
144
+ * Proposed on-chain position index (docs/onchain-position-index.md): dynamic field
145
+ * `PositionIndexKey()` on the VaultMarket. Returns null-safe ids; absent until shipped.
146
+ */
147
+ positionIndexKeyType: string;
148
+ positionIndexId: (vaultMarketId: string) => string;
149
+ /** Entry `n` (1-based ordinal) of the index's `caps: Table<u64, ID>`. */
150
+ positionIndexEntryId: (capsTableId: string, n: number | bigint) => string;
151
+ /** v2 `Oracle`: derived from the OracleRegistry, key `OracleKey(nonce: u16)`; nonces 1..total_oracles. */
152
+ oracleId: (nonce: number) => string;
153
+ fTokenType: (coinType: string) => string;
154
+ positionCapType: string;
155
+ };
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;
852
+ };
853
+ /** @deprecated Solana name; use `FTokenDetailsUserPosition`. */
854
+ type JlTokenDetailsUserPosition = FTokenDetailsUserPosition;
855
+ type RewardsRateModelConfig = {
856
+ duration: bigint;
857
+ startTime: bigint;
858
+ endTime: bigint;
859
+ startTvl: bigint;
860
+ maxRate: bigint;
861
+ rewardAmount: bigint;
862
+ /** Sui extras: the queued next schedule. */
863
+ nextStartTime: bigint;
864
+ nextEndTime: bigint;
865
+ nextRewardAmount: bigint;
866
+ };
867
+ type PreviewData = {
868
+ previewDeposit: bigint;
869
+ previewMint: bigint;
870
+ previewWithdraw: bigint;
871
+ previewRedeem: bigint;
872
+ };
873
+ type FTokenInternalData = {
874
+ /** Sui: TokenReserve<T> id backing the pool. */
875
+ liquidity: string;
876
+ /** Sui: LendingRegistry id. */
877
+ lendingFactory: string;
878
+ /** Sui: rewards writer cap id, if one is installed. */
879
+ lendingRewardsRateModel: string | null;
880
+ /** No rebalancer account on Sui LendingState; empty string. */
881
+ rebalancer: string;
882
+ liquidityBalance: bigint;
883
+ liquidityExchangePrice: bigint;
884
+ tokenExchangePrice: bigint;
885
+ };
886
+ /** @deprecated Solana name; use `FTokenInternalData`. */
887
+ type JlTokenInternalData = FTokenInternalData;
888
+ type LendingAccount = {
889
+ id: string;
890
+ mint: string;
891
+ fTokenMint: string;
892
+ decimals: number;
893
+ totalShares: bigint;
894
+ liquidityExchangePrice: bigint;
895
+ tokenExchangePrice: bigint;
896
+ lastUpdateTimestamp: bigint;
897
+ tokenReservesLiquidity: string;
898
+ rewardsWriter: string | null;
899
+ };
900
+ type ConstantViews = {
901
+ liquidity: string;
902
+ /** Collateral TokenReserve id. */
903
+ supply: string;
904
+ /** Debt TokenReserve id. */
905
+ borrow: string;
906
+ supplyToken: string;
907
+ borrowToken: string;
908
+ vaultId: number;
909
+ vaultType: number;
910
+ };
911
+ type Configs = {
912
+ supplyRateMagnifier: bigint;
913
+ borrowRateMagnifier: bigint;
914
+ collateralFactor: bigint;
915
+ liquidationThreshold: bigint;
916
+ liquidationMaxLimit: bigint;
917
+ withdrawalGap: bigint;
918
+ liquidationPenalty: bigint;
919
+ borrowFee: bigint;
920
+ oracle: string;
921
+ /** No per-vault rebalancer field on Sui (role lives in VaultAdmin); empty string. */
922
+ rebalancer: string;
923
+ oraclePriceOperate?: bigint;
924
+ oraclePriceLiquidate?: bigint;
925
+ lastUpdateTimestamp?: bigint;
926
+ };
927
+ type ExchangePricesAndRates = {
928
+ lastStoredLiquiditySupplyExchangePrice: bigint;
929
+ lastStoredLiquidityBorrowExchangePrice: bigint;
930
+ lastStoredVaultSupplyExchangePrice: bigint;
931
+ lastStoredVaultBorrowExchangePrice: bigint;
932
+ liquiditySupplyExchangePrice: bigint;
933
+ liquidityBorrowExchangePrice: bigint;
934
+ vaultSupplyExchangePrice: bigint;
935
+ vaultBorrowExchangePrice: bigint;
936
+ supplyRateLiquidity: bigint;
937
+ borrowRateLiquidity: bigint;
938
+ supplyRateVault: bigint;
939
+ borrowRateVault: bigint;
940
+ rewardsOrFeeRateSupply: bigint;
941
+ rewardsOrFeeRateBorrow: bigint;
942
+ };
943
+ type TotalSupplyAndBorrow = {
944
+ totalSupplyVault: bigint;
945
+ totalBorrowVault: bigint;
946
+ totalSupplyLiquidityOrDex: bigint;
947
+ totalBorrowLiquidityOrDex: bigint;
948
+ absorbedSupply: bigint;
949
+ absorbedBorrow: bigint;
950
+ };
951
+ type LimitsAndAvailability = {
952
+ withdrawLimit: bigint;
953
+ withdrawableUntilLimit: bigint;
954
+ withdrawable: bigint;
955
+ borrowLimit: bigint;
956
+ borrowLimitUtilization: bigint;
957
+ borrowableUntilLimit: bigint;
958
+ borrowable: bigint;
959
+ minimumBorrowing: bigint;
960
+ };
961
+ type CurrentBranchState = {
962
+ /** 0 NotLiquidated · 1 Liquidated · 2 Merged · 3 Closed. */
963
+ status: number;
964
+ minimaTick: number;
965
+ debtFactor: bigint;
966
+ partials: bigint;
967
+ debtLiquidity: bigint;
968
+ baseBranchId: number;
969
+ baseBranchMinima: number;
970
+ };
971
+ type VaultState = {
972
+ topTick: number;
973
+ currentBranch: number;
974
+ totalBranch: number;
975
+ totalSupply: bigint;
976
+ totalBorrow: bigint;
977
+ /** Positions ever opened (EVM parity). DERIVED on Sui (no on-chain counter): events + object
978
+ * reads via `vault.getVaultPositionCounts`; -1 if `positionCounts: false` or endpoint down. */
979
+ totalPositions: number;
980
+ currentBranchState?: CurrentBranchState;
981
+ branchLiquidated: boolean;
982
+ absorbedDebtAmount: bigint;
983
+ absorbedColAmount: bigint;
984
+ absorbedDustDebt: bigint;
985
+ liquiditySupplyExchangePrice: bigint;
986
+ liquidityBorrowExchangePrice: bigint;
987
+ vaultSupplyExchangePrice: bigint;
988
+ vaultBorrowExchangePrice: bigint;
989
+ /** `totalPositions + 1`, DERIVED. Ordinal only: Sui position ids are object ids. -1 as above. */
990
+ nextPositionId: number;
991
+ /** Sui extra: seconds. */
992
+ lastUpdateTimestamp: bigint;
993
+ };
994
+ type VaultConfig = {
995
+ vaultId: number;
996
+ /** Sui: the VaultMarket object id. */
997
+ vault: string;
998
+ supplyRateMagnifier: number;
999
+ borrowRateMagnifier: number;
1000
+ collateralFactor: number;
1001
+ liquidationThreshold: number;
1002
+ liquidationMaxLimit: number;
1003
+ withdrawGap: number;
1004
+ liquidationPenalty: number;
1005
+ borrowFee: number;
1006
+ oracle: string;
1007
+ rebalancer: string;
1008
+ liquidityProgram: string;
1009
+ oracleProgram: string;
1010
+ supplyToken: string;
1011
+ borrowToken: string;
1012
+ vaultType: number;
1013
+ collateralDecimals: number;
1014
+ debtDecimals: number;
1015
+ };
1016
+ type VaultEntireData = {
1017
+ vault: string;
1018
+ isSmartCol: boolean;
1019
+ isSmartDebt: boolean;
1020
+ constantViews: ConstantViews;
1021
+ configs: Configs;
1022
+ exchangePricesAndRates: ExchangePricesAndRates;
1023
+ limitsAndAvailability: LimitsAndAvailability;
1024
+ liquidityUserSupplyData: UserSupplyData;
1025
+ liquidityUserBorrowData: UserBorrowData;
1026
+ vaultState: VaultState;
1027
+ totalSupplyAndBorrow: TotalSupplyAndBorrow;
1028
+ };
1029
+ type VaultEntireDataV2 = VaultEntireData & {
1030
+ vaultId: number;
1031
+ vaultType: number;
1032
+ /** No DEX on Sui yet. */
1033
+ supplyDex: null;
1034
+ borrowDex: null;
1035
+ supplyDexPosition: null;
1036
+ borrowDexPosition: null;
1037
+ };
1038
+ /** Raw on-chain Position (Solana `UserPosition`). */
1039
+ type UserPosition = {
1040
+ vaultId: number;
1041
+ /** Sui: Position object id (Solana nftId). */
1042
+ positionId: string;
1043
+ /** Sui: VaultMarket object id. */
1044
+ vault: string;
1045
+ /** Sui: PositionOwnerCap id (Solana positionMint). */
1046
+ positionMint: string;
1047
+ isSupplyOnlyPosition: boolean;
1048
+ tick: number;
1049
+ tickId: number;
1050
+ supplyAmount: bigint;
1051
+ dustDebtAmount: bigint;
1052
+ };
1053
+ type UserPositionWithDebt = {
1054
+ tick: number;
1055
+ tickId: number;
1056
+ colRaw: bigint;
1057
+ debtRaw: bigint;
1058
+ dustDebtRaw: bigint;
1059
+ finalAmount: bigint;
1060
+ isSupplyOnlyPosition: boolean;
1061
+ userLiquidationStatus?: boolean;
1062
+ postLiquidationBranchId?: number;
1063
+ };
1064
+ type NftPosition = {
1065
+ /** Sui: Position object id. */
1066
+ nftId: string;
1067
+ /** Owner of the PositionOwnerCap (address, or object id when wrapped/object-owned). */
1068
+ owner: string | null;
1069
+ capId: string;
1070
+ isSupplyPosition: boolean;
1071
+ supply: bigint;
1072
+ beforeSupply: bigint;
1073
+ dustBorrow: bigint;
1074
+ beforeDustBorrow: bigint;
1075
+ tick: number;
1076
+ tickId: number;
1077
+ borrow: bigint;
1078
+ beforeBorrow: bigint;
1079
+ isLiquidated: boolean;
1080
+ };
1081
+ type DecodedTick = {
1082
+ isLiquidated: boolean;
1083
+ totalIds: number;
1084
+ rawDebt: bigint;
1085
+ isFullyLiquidated: boolean;
1086
+ liquidationBranchId: number;
1087
+ debtFactor: bigint;
1088
+ };
1089
+ type DecodedBranch = {
1090
+ branchId: number;
1091
+ status: number;
1092
+ minimaTick: number;
1093
+ minimaTickPartials: number;
1094
+ debtLiquidity: bigint;
1095
+ debtFactor: bigint;
1096
+ connectedBranchId: number;
1097
+ connectedMinimaTick: number;
1098
+ };
1099
+ type DecodedTickIdLiquidation = {
1100
+ isFullyLiquidated: boolean;
1101
+ liquidationBranchId: number;
1102
+ debtFactor: bigint;
1103
+ };
1104
+ type PositionWithRiskRatio = NftPosition & {
1105
+ vaultId: number;
1106
+ /** debt / (collateral * oracle price), 1e4 scale (e.g. 7500 = 75%). */
1107
+ riskRatio: bigint;
1108
+ };
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;
1120
+ };
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;
1128
+ };
1129
+ type OracleV2 = {
1130
+ id: string;
1131
+ nonce: number;
1132
+ main: OracleV2Source;
1133
+ guard: OracleV2Source | null;
1134
+ };
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;
1148
+ };
1149
+ type AdminOracle = {
1150
+ id: string;
1151
+ name: string;
1152
+ rate: bigint;
1153
+ version: bigint;
1154
+ };
1155
+ declare namespace liquidity_d_exports {
1156
+ export { ReserveSnapshot, calcBorrowLimitBeforeOperate, calcRevenue, calcWithdrawalLimitBeforeOperate, calculateExchangePrice, emptyUserBorrowData, emptyUserSupplyData, processOverallTokenData, processUserBorrowData, processUserSupplyData, totalAmountsOf, totalBorrowNormal, totalSupplyNormal };
1157
+ }
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
+ //#endregion
1196
+ //#region src/liquidity.d.ts
1197
+ type ReserveRecord = {
1198
+ token: string;
1199
+ id: string;
1200
+ raw: ReturnType<typeof TokenReserve.parse>;
1201
+ snapshot: ReserveSnapshot;
1202
+ rateData: RateData;
1203
+ };
1204
+ declare class Liquidity {
1205
+ private readonly ctx;
1206
+ constructor(ctx: ReadContext);
1207
+ /** Reserves + their rate-data fields in 2 batched round trips. */
1208
+ loadReserves(tokens: readonly string[]): Promise<ReserveRecord[]>;
1209
+ loadReserve(token: string): Promise<ReserveRecord>;
1210
+ /** Supply/borrow Table entries of `holders` on `reserves` (one batched round trip). */
1211
+ loadUserEntries(pairs: readonly {
1212
+ holder: string;
1213
+ reserve: ReserveRecord;
1214
+ }[]): Promise<{
1215
+ supply: UserSupplyPositionAccount | null;
1216
+ borrow: UserBorrowPositionAccount | null;
1217
+ }[]>;
1218
+ getLiquidityAccount(): Promise<LiquidityAccount>;
1219
+ getRevenueCollector(): Promise<string>;
1220
+ /**
1221
+ * Protocol holders discoverable from object state alone: every VaultMarket (ids 1..total from
1222
+ * `VaultRegistry.next_vault_id`, derived) and every LendingState of a candidate token
1223
+ * (derived). Pure state, no list query.
1224
+ */
1225
+ discoverProtocolHolders(seedTokens?: readonly string[]): Promise<{
1226
+ vaults: {
1227
+ vaultId: number;
1228
+ id: string;
1229
+ collateralType: string;
1230
+ debtType: string;
1231
+ capCount: number;
1232
+ }[];
1233
+ lendings: {
1234
+ token: string;
1235
+ id: string;
1236
+ }[];
1237
+ }>;
1238
+ /**
1239
+ * Token discovery from object state alone (default, no indexer, no list query):
1240
+ * seed tokens (`config.tokens`) ∪ collateral/debt types of every VaultMarket, kept if their
1241
+ * `TokenReserve` exists (derived id). Coverage check: every liquidity user cap is counted in
1242
+ * `Registry.active_caps.size`; caps held by known holders (2 per vault, 1 per LendingState)
1243
+ * are subtracted, and `untrackedCaps > 0` means some other holder exists that state alone
1244
+ * cannot name (a token listed only by a non-Fluid integrator, or a test holder).
1245
+ */
1246
+ discoverTokens(): Promise<{
1247
+ tokens: string[];
1248
+ activeCaps: number;
1249
+ untrackedCaps: number;
1250
+ source: "state" | "state+fullnode-index";
1251
+ }>;
1252
+ /** Listed tokens (see `discoverTokens`; pure state by default). */
1253
+ listedTokens(): Promise<string[]>;
1254
+ 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;
1257
+ getRateConfig(token: string): Promise<RateModelAccount | null>;
1258
+ getTotalAmounts(token: string): Promise<TotalAmounts>;
1259
+ getConfigs2(token: string): Promise<{
1260
+ maxUtilization: bigint;
1261
+ }>;
1262
+ getRevenue(token: string): Promise<bigint>;
1263
+ getTokenRateData(token: string): Promise<RateData>;
1264
+ getTokensRateData(tokens: readonly string[]): Promise<RateData[]>;
1265
+ overallFromRecord(r: ReserveRecord, now?: bigint): OverallTokenData;
1266
+ getOverallTokenData(token: string): Promise<OverallTokenData>;
1267
+ getOverallTokensData(tokens: readonly string[]): Promise<OverallTokenData[]>;
1268
+ getAllOverallTokensData(): Promise<OverallTokenData[]>;
1269
+ /** Raw supply position of a holder, or `0n` when none exists (Solana returns BN 0). */
1270
+ getUserSupply(user: string, token: string): Promise<UserSupplyPositionAccount | bigint>;
1271
+ getUserBorrow(user: string, token: string): Promise<UserBorrowPositionAccount | bigint>;
1272
+ supplyDataFromRecords(reserve: ReserveRecord, acc: UserSupplyPositionAccount | null, now?: bigint): {
1273
+ userSupplyData: UserSupplyData;
1274
+ overallTokenData: OverallTokenData;
1275
+ };
1276
+ borrowDataFromRecords(reserve: ReserveRecord, acc: UserBorrowPositionAccount | null, now?: bigint): {
1277
+ userBorrowData: UserBorrowData;
1278
+ overallTokenData: OverallTokenData;
1279
+ };
1280
+ getUserSupplyData(user: string, token: string): Promise<{
1281
+ userSupplyData: UserSupplyData;
1282
+ overallTokenData: OverallTokenData;
1283
+ }>;
1284
+ getUserBorrowData(user: string, token: string): Promise<{
1285
+ userBorrowData: UserBorrowData;
1286
+ overallTokenData: OverallTokenData;
1287
+ }>;
1288
+ getUserMultipleSupplyData(user: string, tokens: readonly string[]): Promise<{
1289
+ userSuppliesData: UserSupplyData[];
1290
+ overallTokensData: OverallTokenData[];
1291
+ }>;
1292
+ getUserMultipleBorrowData(user: string, tokens: readonly string[]): Promise<{
1293
+ userBorrowingsData: UserBorrowData[];
1294
+ overallTokensData: OverallTokenData[];
1295
+ }>;
1296
+ getUserMultipleBorrowSupplyData(user: string, supplyTokens: readonly string[], borrowTokens: readonly string[]): Promise<{
1297
+ userSuppliesData: UserSupplyData[];
1298
+ overallSupplyTokensData: OverallTokenData[];
1299
+ userBorrowingsData: UserBorrowData[];
1300
+ overallBorrowTokensData: OverallTokenData[];
1301
+ }>;
1302
+ /**
1303
+ * Every supply/borrow position on every listed reserve, grouped by holder.
1304
+ *
1305
+ * Default ("state"): holders = every VaultMarket + LendingState (derived), entries read by
1306
+ * derived Table-entry id. `untracked` = `Table.size` minus entries found, per reserve: rows of
1307
+ * holders that object state cannot name (non-Fluid integrators). With `discovery: "fullnode"`
1308
+ * the tables are listed and `untracked` is always empty.
1309
+ */
1310
+ getAllUserPositionsDetailed(): Promise<{
1311
+ positions: {
1312
+ user: string;
1313
+ supply: Record<string, UserSupplyPositionAccount>;
1314
+ borrow: Record<string, UserBorrowPositionAccount>;
1315
+ }[];
1316
+ untracked: {
1317
+ token: string;
1318
+ supply: number;
1319
+ borrow: number;
1320
+ }[];
1321
+ source: "state" | "fullnode-index";
1322
+ }>;
1323
+ /** Positions only (see `getAllUserPositionsDetailed`). */
1324
+ getAllUserPositions(): Promise<{
1325
+ user: string;
1326
+ supply: Record<string, UserSupplyPositionAccount>;
1327
+ borrow: Record<string, UserBorrowPositionAccount>;
1328
+ }[]>;
1329
+ /** Fullnode-index tier: lists every Table entry. */
1330
+ private listAllUserPositions;
1331
+ }
1332
+ declare namespace lending_d_exports {
1333
+ export { LendingSnapshot, RewardsSchedule, accruedTokenExchangePrice, currentRewardsRate, previews, rateSegments, rewardsRateFor, toAssets, toShares };
1334
+ }
1335
+ type RewardsSchedule = {
1336
+ startTvl: bigint;
1337
+ startS: bigint;
1338
+ endS: bigint;
1339
+ yearlyReward: bigint;
1340
+ nextStartS: bigint;
1341
+ nextEndS: bigint;
1342
+ nextYearlyReward: bigint;
1343
+ };
1344
+ type LendingSnapshot = {
1345
+ totalShares: bigint;
1346
+ liquidityExchangePrice: bigint;
1347
+ tokenExchangePrice: bigint;
1348
+ lastUpdateS: bigint;
1349
+ rewards: RewardsSchedule | null;
1350
+ };
1351
+ declare const toShares: (assets: bigint, ep: bigint, roundUp: boolean) => bigint;
1352
+ declare const toAssets: (shares: bigint, ep: bigint, roundUp: boolean) => bigint;
1353
+ /** `lending_calcs::calc_rewards_rate` via `rewards::rate_for`. */
1354
+ declare function rewardsRateFor(yearlyReward: bigint, totalAssets: bigint, startTvl: bigint): bigint;
1355
+ /** `rewards::get_rate_segments`. */
1356
+ declare function rateSegments(s: RewardsSchedule, totalAssets: bigint, fromS: bigint, nowS: bigint): {
1357
+ rate: bigint;
1358
+ fromS: bigint;
1359
+ toS: bigint;
1360
+ }[];
1361
+ /** Current rewards rate (1e12 = 100%) at `now`, from the active schedule segment. */
1362
+ declare function currentRewardsRate(state: LendingSnapshot, now: bigint): bigint;
1363
+ /** `accounting::accrued_token_exchange_price`. */
1364
+ declare function accruedTokenExchangePrice(state: LendingSnapshot, newLiquidityExchangePrice: bigint, nowS: bigint): bigint;
1365
+ /** `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): {
1367
+ tokenExchangePrice: bigint;
1368
+ previewDeposit: bigint;
1369
+ previewMint: bigint;
1370
+ previewWithdraw: bigint;
1371
+ previewRedeem: bigint;
1372
+ };
1373
+ //#endregion
1374
+ //#region src/lending.d.ts
1375
+ type LendingRecord = {
1376
+ token: string;
1377
+ id: string;
1378
+ raw: ReturnType<typeof LendingState.parse>;
1379
+ snapshot: LendingSnapshot;
1380
+ };
1381
+ declare class Lending {
1382
+ private readonly ctx;
1383
+ private readonly liquidity;
1384
+ constructor(ctx: ReadContext, liquidity: Liquidity);
1385
+ /** LendingStates (+ rewards fields) for `tokens`; `null` where no pool exists. */
1386
+ loadLendings(tokens: readonly string[]): Promise<(LendingRecord | null)[]>;
1387
+ private loadOne;
1388
+ getAllLendings(): Promise<LendingAccount[]>;
1389
+ /** Underlying coin types that have a lending pool. */
1390
+ getAllFTokens(): Promise<string[]>;
1391
+ /** @deprecated Solana name; use `getAllFTokens`. */
1392
+ getAllJlTokens: () => Promise<string[]>;
1393
+ /** Token exchange price accrued to now (`accounting::calculate_new_token_exchange_price`). */
1394
+ getExchangePrice(token: string): Promise<bigint>;
1395
+ getPreviews(token: string, assets: bigint, shares: bigint): Promise<PreviewData>;
1396
+ detailsFromRecords(lending: LendingRecord, reserve: ReserveRecord, supplyEntry: Parameters<Liquidity["supplyDataFromRecords"]>[1], meta: {
1397
+ name: string;
1398
+ symbol: string;
1399
+ decimals: number;
1400
+ }, now?: bigint): FTokenDetails;
1401
+ private fTokenMeta;
1402
+ getFTokenDetails(token: string): Promise<FTokenDetails>;
1403
+ /** @deprecated Solana name; use `getFTokenDetails`. */
1404
+ getJlTokenDetails: (token: string) => Promise<FTokenDetails>;
1405
+ getAllFTokenDetails(): Promise<FTokenDetails[]>;
1406
+ /** @deprecated Solana name; use `getAllFTokenDetails`. */
1407
+ getAllJlTokenDetails: () => Promise<FTokenDetails[]>;
1408
+ getFTokenInternalData(token: string): Promise<FTokenInternalData>;
1409
+ /** @deprecated Solana name; use `getFTokenInternalData`. */
1410
+ getJlTokenInternalData: (token: string) => Promise<FTokenInternalData>;
1411
+ getFTokenRewards(token: string): Promise<[string | null, bigint]>;
1412
+ /** @deprecated Solana name; use `getFTokenRewards`. */
1413
+ getJlTokenRewards: (token: string) => Promise<[string | null, bigint]>;
1414
+ getFTokenRewardsRateModelConfig(token: string): Promise<RewardsRateModelConfig | null>;
1415
+ /** @deprecated Solana name; use `getFTokenRewardsRateModelConfig`. */
1416
+ getJlTokenRewardsRateModelConfig: (token: string) => Promise<RewardsRateModelConfig | null>;
1417
+ getUserPosition(token: string, user: string): Promise<LendingUserPosition>;
1418
+ getUserPositions(user: string): Promise<FTokenDetailsUserPosition[]>;
1419
+ /** `lending::auth::is_admin(&Auth, addr)` via simulation. */
1420
+ isLendingAdmin(addr: string): Promise<boolean>;
1421
+ /** `lending::auth::has_role(&Auth, addr)` (any role) via simulation. */
1422
+ isLendingAuth(addr: string): Promise<boolean>;
1423
+ private authView;
1424
+ }
1425
+ //#endregion
1426
+ //#region src/oracle.d.ts
1427
+ /** Oracle rates are debt-per-collateral in the vault's internal 1e9 space, scaled by 1e15. */
1428
+ declare const ORACLE_RATE_PRECISION = 1000000000000000n;
1429
+ /** Mirrors `fluid_oracle::constants` of the deployed v2 package. */
1430
+ declare const ORACLE_V2_LIMITS: {
1431
+ readonly rateOutputDecimals: 15;
1432
+ readonly maxAgeOperateS: 600n;
1433
+ readonly maxAgeLiquidateS: 7200n;
1434
+ readonly maxPythArrivalLagS: 60n;
1435
+ readonly confidenceScaleOperate: 50n;
1436
+ readonly confidenceScaleLiquidate: 25n;
1437
+ readonly maxPythExponent: 12n;
1438
+ readonly redstoneDecimals: 8;
1439
+ readonly maxInvertibleRate: bigint;
1440
+ };
1441
+ /** `rate::scale_and_invert`: raw provider price with `decimals` → 1e15 rate, optionally inverted. */
1442
+ declare function scaleAndInvert(raw: bigint, decimals: number, invert: boolean): bigint;
1443
+ declare class Oracle {
1444
+ private readonly ctx;
1445
+ constructor(ctx: ReadContext);
1446
+ private get v2();
1447
+ /** Admin oracle object (2026-09-18 preset). */
1448
+ getOracle(oracleId: string): Promise<AdminOracle>;
1449
+ /** v2 oracle object: nonce + main / guard routes. */
1450
+ getOracleV2(oracleId: string): Promise<OracleV2>;
1451
+ /** Provider objects the v2 views take for this oracle. */
1452
+ private providerArgs;
1453
+ private quoteV2;
1454
+ /** Price exactly as vaults see it. v2: operate and liquidate simulated separately (one can abort alone). */
1455
+ getOraclePrice(oracleId: string): Promise<OraclePrice>;
1456
+ /**
1457
+ * Each v2 route read on its own, at the chain's clock: raw price, 1e15 rate, age, and whether it
1458
+ * passes the operate / liquidate checks (`*_core::reading_error`, mirrored off-chain).
1459
+ * Operate price = min over routes; liquidate = min over routes usable for liquidate.
1460
+ */
1461
+ getOracleRoutes(oracleId: string): Promise<{
1462
+ oracle: OracleV2;
1463
+ nowMs: bigint;
1464
+ main: OracleRoute;
1465
+ guard: OracleRoute | null;
1466
+ }>;
1467
+ /** Human price (collateral priced in debt units) from a raw 1e15 rate. */
1468
+ static toNumber(rate: bigint): number;
1469
+ }
1470
+ //#endregion
1471
+ //#region src/math/core.d.ts
1472
+ /** Integer helpers that mirror `fluid_library::math` (all bigint, floor unless named ceil). */
1473
+ declare const FOUR_DECIMALS = 10000n;
1474
+ declare const SECONDS_PER_YEAR = 31536000n;
1475
+ /** Liquidity / vault / lending exchange-price precision (1e12). */
1476
+ declare const EXCHANGE_PRICES_PRECISION = 1000000000000n;
1477
+ /** `exchange_price_rate_output_decimals` in liquidity (1e17). */
1478
+ declare const RATE_OUTPUT_DECIMALS = 100000000000000000n;
1479
+ /** Vault exchange-price scale factor (1e18). */
1480
+ declare const EXCHANGE_PRICE_SCALE_FACTOR = 1000000000000000000n;
1481
+ /** Lending return precision (1e14 = 1e12 * 100). */
1482
+ declare const RETURN_PERCENT_PRECISION = 100000000000000n;
1483
+ /** Lending max rewards rate (50% in 1e12). */
1484
+ declare const MAX_REWARDS_RATE = 50000000000000n;
1485
+ declare function mulDiv(a: bigint, b: bigint, c: bigint): bigint;
1486
+ declare function divCeil(a: bigint, b: bigint): bigint;
1487
+ declare function mulDivCeil(a: bigint, b: bigint, c: bigint): bigint;
1488
+ declare const max: (a: bigint, b: bigint) => bigint;
1489
+ declare const min: (a: bigint, b: bigint) => bigint;
1490
+ /** Current unix time in seconds (the default `now` for time-dependent reads). */
1491
+ declare const nowSeconds: () => bigint;
1492
+ //#endregion
1493
+ //#region src/positionIndex.d.ts
1494
+ type PositionSource = "state" | "fullnode-index" | "events+objects";
1495
+ type PositionCounts = {
1496
+ vaultId: number;
1497
+ /** Positions ever opened in this vault (EVM `totalPositions` semantics). */
1498
+ totalPositions: number;
1499
+ /** Positions whose object exists right now (verified on-chain, never from events alone). */
1500
+ openPositions: number;
1501
+ /** On-chain `next_position_id` when the index exists, else `totalPositions + 1` (ordinal). */
1502
+ nextPositionId: number;
1503
+ /** Open position object ids (index order when the on-chain index exists). */
1504
+ openPositionIds: string[];
1505
+ /** Where the enumeration came from. Only "state" is a stored on-chain value. */
1506
+ source: PositionSource;
1507
+ };
1508
+ type PositionIndexOptions = {
1509
+ /** Override `config.graphqlUrl`. */
1510
+ graphqlUrl?: string;
1511
+ pageSize?: number;
1512
+ retries?: number;
1513
+ /** Base backoff in ms (doubles per attempt). */
1514
+ backoffMs?: number;
1515
+ fetchImpl?: typeof fetch;
1516
+ };
1517
+ declare const POSITION_INDEX_FIX: string;
1518
+ declare class PositionIndex {
1519
+ private ctx;
1520
+ private opts;
1521
+ private streams;
1522
+ private inflight;
1523
+ constructor(ctx: ReadContext, opts?: PositionIndexOptions);
1524
+ /**
1525
+ * Reads the proposed on-chain index by derived ids. `null` when the vault has no index yet.
1526
+ * Returns ordinal -> cap id for every position ever opened, and the stored counter.
1527
+ */
1528
+ readOnchainIndex(vaultMarketId: string): Promise<{
1529
+ nextPositionId: number;
1530
+ capIds: string[];
1531
+ } | null>;
1532
+ /** Every position id ever claimed on `vaultMarketId` (`derived_object::Claimed` fields). */
1533
+ claimedIds(vaultMarketId: string): Promise<string[]>;
1534
+ counts(vaultId: number, vaultMarketId: string): Promise<PositionCounts>;
1535
+ private finish;
1536
+ /** Lowest discovery level `counts` would need right now for this vault. */
1537
+ requiredLevel(vaultMarketId: string): Promise<DiscoveryLevel>;
1538
+ private get url();
1539
+ private type;
1540
+ private post;
1541
+ /** All events of `type`, resuming from the last cursor. Concurrent callers share one scan. */
1542
+ private sync;
1543
+ /** Every position id ever opened in `vaultMarketId` (event order, deduped). Indexer tier. */
1544
+ openedIds(vaultMarketId: string): Promise<string[]>;
1545
+ /** Position ids with a `LogClosePosition` for numeric `vaultId`. Indexer tier. */
1546
+ closedIds(vaultId: number): Promise<Set<string>>;
1547
+ /** Drop cached cursors (forces a full rescan next call). */
1548
+ reset(): void;
1549
+ }
1550
+ //#endregion
1551
+ //#region src/vault.d.ts
1552
+ /** `withOracle` (default true): oracle price via one simulation. `positionCounts` (default true):
1553
+ * fill `totalPositions` / `nextPositionId` from the derived position index (-1 if unreachable). */
1554
+ type VaultReadOpts = {
1555
+ withOracle?: boolean;
1556
+ positionCounts?: boolean;
1557
+ };
1558
+ type VaultRecord = {
1559
+ vaultId: number;
1560
+ id: string;
1561
+ collateralType: string;
1562
+ debtType: string;
1563
+ raw: ReturnType<typeof VaultMarket.parse>;
1564
+ };
1565
+ declare class Vault {
1566
+ private readonly ctx;
1567
+ private readonly liquidity;
1568
+ private readonly oracle;
1569
+ /** Derived per-vault position counts (no counter exists on-chain on Sui). */
1570
+ readonly positions: PositionIndex;
1571
+ constructor(ctx: ReadContext, liquidity: Liquidity, oracle: Oracle);
1572
+ /**
1573
+ * totalPositions (ever opened, EVM parity), openPositions (object exists now), nextPositionId
1574
+ * (stored counter once the on-chain index ships, else totalPositions + 1). Pure state when the
1575
+ * vault has the on-chain index; otherwise needs `discovery: "fullnode"` (derived_object claims)
1576
+ * or "indexer" (events), and throws `NeedsDiscoveryError` under the default "state".
1577
+ */
1578
+ getVaultPositionCounts(vaultId: number): Promise<PositionCounts>;
1579
+ /** Counts for state fills: never lets an event-endpoint outage break a vault read (-1 then). */
1580
+ private countsOrNull;
1581
+ getTotalVaults(): Promise<number>;
1582
+ loadVaults(vaultIds: readonly number[]): Promise<VaultRecord[]>;
1583
+ loadVault(vaultId: number): Promise<VaultRecord>;
1584
+ configFromRecord(v: VaultRecord): VaultConfig;
1585
+ getVaultConfig(vaultId: number): Promise<VaultConfig>;
1586
+ batchGetTicks(vaultId: number, ticks: readonly number[]): Promise<(DecodedTick | null)[]>;
1587
+ private ticksOf;
1588
+ getTick({
1589
+ vaultId,
1590
+ tick
1591
+ }: {
1592
+ vaultId: number;
1593
+ tick: number;
1594
+ }): Promise<DecodedTick | null>;
1595
+ batchGetBranches(vaultId: number, branchIds: readonly number[]): Promise<(DecodedBranch | null)[]>;
1596
+ private branchesOf;
1597
+ getBranch({
1598
+ vaultId,
1599
+ branchId
1600
+ }: {
1601
+ vaultId: number;
1602
+ branchId: number;
1603
+ }): Promise<DecodedBranch | null>;
1604
+ /** Branches 1..total_branch_id. */
1605
+ getAllBranches(vaultId: number): Promise<DecodedBranch[]>;
1606
+ getTickIdLiquidation({
1607
+ vaultId,
1608
+ tick,
1609
+ tickId
1610
+ }: {
1611
+ vaultId: number;
1612
+ tick: number;
1613
+ tickId: number;
1614
+ }): Promise<DecodedTickIdLiquidation | null>;
1615
+ /** Raw `tick_bitmap` words (u256) for `words`; missing words = 0. */
1616
+ getTickHasDebtArray(vaultId: number, words: readonly number[]): Promise<{
1617
+ word: number;
1618
+ bitmap: bigint;
1619
+ }[]>;
1620
+ private stateFromRecord;
1621
+ getVaultState(vaultId: number, opts?: {
1622
+ positionCounts?: boolean;
1623
+ }): Promise<VaultState>;
1624
+ /** `user::get_exchange_prices`: (liqSupply, liqBorrow, vaultSupply, vaultBorrow) accrued to `now`. */
1625
+ exchangePricesFromRecords(v: VaultRecord, colReserve: ReserveRecord, debtReserve: ReserveRecord, now?: bigint): {
1626
+ liquiditySupplyExchangePrice: bigint;
1627
+ liquidityBorrowExchangePrice: bigint;
1628
+ vaultSupplyExchangePrice: bigint;
1629
+ vaultBorrowExchangePrice: bigint;
1630
+ };
1631
+ /** Full vault view. `withOracle` (default true) adds the oracle price via one simulation. */
1632
+ getVaultEntireData(vaultId: number, opts?: VaultReadOpts): Promise<VaultEntireData>;
1633
+ getVaultEntireDataV2(vaultId: number, opts?: VaultReadOpts): Promise<VaultEntireDataV2>;
1634
+ getAllVaults(opts?: VaultReadOpts): Promise<VaultEntireData[]>;
1635
+ getAllVaultsV2(opts?: VaultReadOpts): Promise<VaultEntireDataV2[]>;
1636
+ getVaultByVaultId: (vaultId: number) => Promise<VaultEntireData>;
1637
+ private toV2;
1638
+ private entireDataFor;
1639
+ /** Raw Position object. `vaultId` is resolved from the position's VaultMarket if omitted. */
1640
+ getUserPosition({
1641
+ positionId,
1642
+ vaultId
1643
+ }: {
1644
+ positionId: string;
1645
+ vaultId?: number;
1646
+ }): Promise<UserPosition | null>;
1647
+ batchGetUserPositions(positionIds: readonly string[]): Promise<(UserPosition | null)[]>;
1648
+ private vaultIdOf;
1649
+ /** Everything `fetch_latest_position` needs for one position (tick, snapshot, branch chain). */
1650
+ private liquidationLookups;
1651
+ /** Solana `getCurrentPositionState`: raw col/debt after any liquidation, as operate would settle it. */
1652
+ getCurrentPositionState({
1653
+ vaultId,
1654
+ position
1655
+ }: {
1656
+ vaultId: number;
1657
+ position: UserPosition;
1658
+ }): Promise<UserPositionWithDebt>;
1659
+ getFinalPosition({
1660
+ vaultId,
1661
+ positionId
1662
+ }: {
1663
+ vaultId: number;
1664
+ positionId: string;
1665
+ }): Promise<UserPositionWithDebt>;
1666
+ /** Owner of a PositionOwnerCap (Solana `getNftOwner`). */
1667
+ getPositionOwner(capId: string): Promise<string | null>;
1668
+ getNftOwner: (capId: string) => Promise<string | null>;
1669
+ /** Solana `buildNftPositionFromPositionAccount` semantics, on a fetched vault context. */
1670
+ private buildNftPosition;
1671
+ /** Solana `getPositionByVaultId(vaultId, nftId)`; Sui takes the Position object id. */
1672
+ getPositionByVaultId(vaultId: number, positionId: string): Promise<NftPosition & {
1673
+ vault: VaultEntireData;
1674
+ }>;
1675
+ getPositionByVaultIdV2(vaultId: number, positionId: string): Promise<{
1676
+ vault: VaultEntireDataV2;
1677
+ nftId: string;
1678
+ owner: string | null;
1679
+ capId: string;
1680
+ isSupplyPosition: boolean;
1681
+ supply: bigint;
1682
+ beforeSupply: bigint;
1683
+ dustBorrow: bigint;
1684
+ beforeDustBorrow: bigint;
1685
+ tick: number;
1686
+ tickId: number;
1687
+ borrow: bigint;
1688
+ beforeBorrow: bigint;
1689
+ isLiquidated: boolean;
1690
+ }>;
1691
+ /**
1692
+ * Every position whose PositionOwnerCap `user` owns, across all vaults.
1693
+ *
1694
+ * Pure state when every vault has the on-chain position index: all cap ids come from the
1695
+ * index, their owners from the cap objects themselves. Otherwise needs `discovery: "fullnode"`
1696
+ * (`listOwnedObjects`). If the caller already knows the cap ids (a wallet does), use
1697
+ * `getUserPositionsByCapIds`, which is always pure state.
1698
+ */
1699
+ getAllUserPositions(user: string): Promise<(NftPosition & {
1700
+ vault: VaultEntireData;
1701
+ })[]>;
1702
+ /** Positions for known PositionOwnerCap ids (pure state: derived position ids only). */
1703
+ getUserPositionsByCapIds(capIds: readonly string[], user?: string): Promise<(NftPosition & {
1704
+ vault: VaultEntireData;
1705
+ })[]>;
1706
+ getAllUserPositionsV2: (user: string) => Promise<{
1707
+ vault: VaultEntireDataV2;
1708
+ nftId: string;
1709
+ owner: string | null;
1710
+ capId: string;
1711
+ isSupplyPosition: boolean;
1712
+ supply: bigint;
1713
+ beforeSupply: bigint;
1714
+ dustBorrow: bigint;
1715
+ beforeDustBorrow: bigint;
1716
+ tick: number;
1717
+ tickId: number;
1718
+ borrow: bigint;
1719
+ beforeBorrow: bigint;
1720
+ isLiquidated: boolean;
1721
+ }[]>;
1722
+ /** Open Position ids in a vault: opened events, minus closes, verified by object existence. */
1723
+ getAllPositionIdsForVault(vaultId: number): Promise<string[]>;
1724
+ /** All open positions of a vault with `riskRatio` = debt / (col × liquidate price), 1e4 scale. */
1725
+ getAllPositionsWithRiskRatio(vaultId: number): Promise<PositionWithRiskRatio[]>;
1726
+ /** Oracle price of a vault's oracle (as vaults consume it). */
1727
+ getOraclePrice(vaultId: number): Promise<OraclePrice>;
1728
+ /** Raw vault-internal 1e9 amounts → token units (`constants::unscale_amounts`). */
1729
+ static unscale(amount: bigint, decimals: number): bigint;
1730
+ }
1731
+ //#endregion
1732
+ //#region src/client.d.ts
1733
+ declare const DEFAULT_RPC_URL = "https://fullnode.mainnet.sui.io:443";
1734
+ 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;
1739
+ /** Enumeration policy. Default "state" (no indexer, no list queries). See `DiscoveryLevel`. */
1740
+ discovery?: DiscoveryLevel;
1741
+ /** Per-call timeout before failing over to the next endpoint. Default 15000 ms. */
1742
+ timeoutMs?: number;
1743
+ };
1744
+ /**
1745
+ * Unified reader, same shape as `@jup-ag/lend-read`'s `Client`:
1746
+ * `client.liquidity`, `client.lending`, `client.vault` (+ `client.oracle`, Sui-only).
1747
+ *
1748
+ * @example
1749
+ * const client = new Client(); // staging deployment, Sui mainnet gRPC
1750
+ * const client = new Client("https://my-fullnode:443");
1751
+ * const client = new Client(existingSuiGrpcClient, { network: "staging" });
1752
+ * const vault = await client.vault.getVaultEntireData(1);
1753
+ */
1754
+ declare class Client {
1755
+ readonly liquidity: Liquidity;
1756
+ readonly lending: Lending;
1757
+ readonly vault: Vault;
1758
+ readonly oracle: Oracle;
1759
+ readonly context: ReadContext;
1760
+ constructor(rpc?: string | readonly (string | ClientWithCoreApi)[] | ClientWithCoreApi, opts?: ClientOptions);
1761
+ }
1762
+ /**
1763
+ * `$extend` form, same pattern as the write SDK's `fluid()`:
1764
+ * `const c = new SuiGrpcClient({...}).$extend(fluidRead()); c.fluidRead.vault...`
1765
+ */
1766
+ declare function fluidRead(opts?: ClientOptions): {
1767
+ name: "fluidRead";
1768
+ register: (client: ClientWithCoreApi) => Client;
1769
+ };
1770
+ //#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
+ //#region src/view.d.ts
1802
+ declare class ViewCallError extends Error {
1803
+ readonly details?: unknown | undefined;
1804
+ constructor(message: string, details?: unknown | undefined);
1805
+ }
1806
+ /**
1807
+ * Build a PTB with `build`, simulate it, and return every command's return values as raw BCS.
1808
+ * `results[i][j]` = return value j of command i.
1809
+ */
1810
+ declare function simulateView(client: ClientWithCoreApi, build: (tx: Transaction) => void | TransactionResult | unknown): Promise<Uint8Array[][]>;
1811
+ //#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);
1817
+ }
1818
+ declare namespace vault_d_exports {
1819
+ export { BRANCH_STATUS, LiquidationLookups, SignedMagnifier, currentPositionState, fetchLatestPosition, loadVaultExchangePrices, minimumDebt, needsLiquidationSettle, positionInfo, rawToNormal, unscale };
1820
+ }
1821
+ declare const BRANCH_STATUS: {
1822
+ readonly NotLiquidated: 0;
1823
+ readonly Liquidated: 1;
1824
+ readonly Merged: 2;
1825
+ readonly Closed: 3;
1826
+ };
1827
+ /** Signed rate magnifier (Move `RateMagnifier { magnitude, negative }` → signed bigint). */
1828
+ type SignedMagnifier = bigint;
1829
+ /** `exchange_price::load_exchange_prices` → `(vaultSupplyExPrice, vaultBorrowExPrice)`. */
1830
+ declare function loadVaultExchangePrices(p: {
1831
+ vaultSupplyExPrice: bigint;
1832
+ vaultBorrowExPrice: bigint;
1833
+ oldLiqSupplyExPrice: bigint;
1834
+ oldLiqBorrowExPrice: bigint;
1835
+ liqSupplyExPrice: bigint;
1836
+ liqBorrowExPrice: bigint;
1837
+ timeDiff: bigint;
1838
+ supplyRateMagnifier: SignedMagnifier;
1839
+ borrowRateMagnifier: SignedMagnifier;
1840
+ }): {
1841
+ vaultSupplyExchangePrice: bigint;
1842
+ vaultBorrowExchangePrice: bigint;
1843
+ };
1844
+ /** `position::get_position_info`: (colRaw, dustDebtRaw, debtRaw, tick, tickId). Debt is rounded up. */
1845
+ declare function positionInfo(pos: {
1846
+ isSupplyOnlyPosition: boolean;
1847
+ tick: number;
1848
+ tickId: number;
1849
+ supplyAmount: bigint;
1850
+ dustDebtAmount: bigint;
1851
+ }): {
1852
+ colRaw: bigint;
1853
+ dustDebtRaw: bigint;
1854
+ debtRaw: bigint;
1855
+ tick: number;
1856
+ tickId: number;
1857
+ };
1858
+ type LiquidationLookups = {
1859
+ tick: DecodedTick;
1860
+ /** Required when `tick.totalIds !== tickId` (the position's id was snapshotted). */
1861
+ snap?: DecodedTickIdLiquidation | null;
1862
+ /** Branch lookup by id; must cover every branch on the merge chain. */
1863
+ branch: (id: number) => DecodedBranch;
1864
+ };
1865
+ /**
1866
+ * `operate_utils::fetch_latest_position`: the position's debt/col after liquidations, as
1867
+ * `operate` would settle it. `debtRaw` is the position's pre-liquidation raw debt.
1868
+ */
1869
+ declare function fetchLatestPosition(debtRaw: bigint, tickId: number, l: LiquidationLookups): {
1870
+ tick: number;
1871
+ colRaw: bigint;
1872
+ debtRaw: bigint;
1873
+ branchId: number;
1874
+ };
1875
+ /** Whether `operate` would run `fetch_latest_position` for this position. */
1876
+ declare const needsLiquidationSettle: (tick: DecodedTick, tickId: number) => boolean;
1877
+ /** Current raw state of a position (Solana `getCurrentPositionState`). */
1878
+ declare function currentPositionState(pos: {
1879
+ isSupplyOnlyPosition: boolean;
1880
+ tick: number;
1881
+ tickId: number;
1882
+ supplyAmount: bigint;
1883
+ dustDebtAmount: bigint;
1884
+ }, lookups: LiquidationLookups | null, debtDecimals?: number): UserPositionWithDebt;
1885
+ /** raw (internal 1e9 space) → normal (still internal space) through a vault exchange price. */
1886
+ declare const rawToNormal: (raw: bigint, exPrice: bigint) => bigint;
1887
+ /** `constants::get_minimum_debt(decimals)` in the internal 1e9 space. */
1888
+ declare const minimumDebt: (decimals: number) => bigint;
1889
+ /** Internal 1e9 space → token units (`constants::unscale_amounts`, floor). */
1890
+ declare const unscale: (amount: bigint, decimals: number) => bigint;
1891
+ declare namespace tick_d_exports {
1892
+ export { COLD_TICK, MAX_MASK_DEBT_FACTOR, MAX_TICK, MIN_TICK, SHIFT, TICK_SPACING, X30, ZERO_TICK_SCALED_RATIO, getRatioAtTick, mulBigNumber, mulDivNormal, tickFromMove, tickToMove };
1893
+ }
1894
+ /** Port of `fluid_library::tick_math` + `fluid_library::big_number` (the parts a reader needs). */
1895
+ declare const MAX_TICK = 16383;
1896
+ declare const MIN_TICK = -16383;
1897
+ /** `tick_math::cold_tick()` = { mag: 2^31, neg: true }: "no tick" (supply-only / fully liquidated). */
1898
+ declare const COLD_TICK = -2147483648;
1899
+ declare const TICK_SPACING = 10015n;
1900
+ declare const ZERO_TICK_SCALED_RATIO = 281474976710656n;
1901
+ declare const SHIFT = 48n;
1902
+ declare const X30 = 1073741823n;
1903
+ /** Move `Tick { mag, neg }` → signed number. */
1904
+ declare function tickFromMove(t: {
1905
+ mag: number;
1906
+ neg: boolean;
1907
+ }): number;
1908
+ /** Signed number → Move `Tick { mag, neg }` (zero is `neg: false`). */
1909
+ declare function tickToMove(tick: number): {
1910
+ mag: number;
1911
+ neg: boolean;
1912
+ };
1913
+ /** ratioX48 = 1.0015^tick * 2^48, bit-exact with `tick_math::get_ratio_at_tick`. */
1914
+ declare function getRatioAtTick(tick: number): bigint;
1915
+ declare const MAX_MASK_DEBT_FACTOR = 1125899906842623n;
1916
+ /** `big_number::mul_big_number`. */
1917
+ declare function mulBigNumber(a: bigint, b: bigint): bigint;
1918
+ /** `big_number::mul_div_normal`: normal * bn1 / bn2. */
1919
+ declare function mulDivNormal(normal: bigint, bn1: bigint, bn2: bigint): bigint;
1920
+ //#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 };