/** * Vendored Navi flash-loan helpers. * * WHY THIS EXISTS * --------------- * `@naviprotocol/lending@1.4.6` (the latest release as of this writing) is not * compatible with `@mysten/sui` v2. Two problems: * 1. Its dist imports `SuiClient` / `getFullnodeUrl` from `@mysten/sui/client`, * which v2 removed (they moved to `@mysten/sui/jsonRpc` as * `SuiJsonRpcClient` / `getJsonRpcFullnodeUrl`). * 2. It eagerly runs `new SuiClient({ url: getFullnodeUrl("mainnet") })` at * module top-level, so merely importing it throws under v2. * Because `@alphafi/alphalend-sdk`'s entry point re-exports the flash-repay path, * importing the SDK *at all* would crash for any consumer on `@mysten/sui` v2. * * We previously worked around this with a `patch-package` patch, but that only * applies in this repo's own dev/CI install — it is not shipped to npm consumers * (patches aren't published, and patch-package can't reliably patch a hoisted * transitive dep). So instead we vendor the three flash-loan helpers we use, * faithfully ported from Navi's public source: * https://github.com/naviprotocol/naviprotocol-monorepo/tree/main/packages/lending/src * (flashloan.ts, config.ts, pool.ts, utils.ts, market.ts — vendored from v1.4.6). * * This module imports ONLY v2-native `@mysten/sui` symbols and does no eager * client construction, so it is safe for external consumers with no patch. * * SCOPE: only the flash-loan path is vendored. `getPools` is intentionally * simplified to return the raw API payload — the flash-loan helpers only read * `suiCoinType` / `contract.pool` / `id` / `isDeprecated`, so Navi's BigNumber * display-field decoration and e-mode handling are omitted on purpose. * * If/when Navi ships a `@mysten/sui` v2-clean release, delete this file and go * back to importing from `@naviprotocol/lending`. */ import type { Transaction } from "@mysten/sui/transactions"; /** Configuration is cached for 5 minutes (matches Navi's DEFAULT_CACHE_TIME). */ export declare const DEFAULT_CACHE_TIME: number; export interface EnvOption { env: "prod" | "dev"; } export interface CacheOption { cacheTime: number; disableCache: boolean; } export interface MarketOption { market: string; } /** Flash loan asset configuration returned by Navi's flashloan API. */ export interface FlashloanAsset { max: string; min: string; assetId: number; poolId: string; supplierFee: number; flashloanFee: number; coinType: string; } /** Subset of Navi's pool shape that the flash-loan path reads. */ interface Pool { suiCoinType: string; id: number; isDeprecated: boolean; contract: { pool: string; }; } /** A coin type, a pool id, or an already-resolved pool object. */ type AssetIdentifier = string | number | Pool; type TxValue = unknown; /** Get all available flash loan assets from the Navi API (cached). */ export declare const getAllFlashLoanAssets: (options?: Partial) => Promise; /** * Add a Navi flash-loan borrow to the PTB. * @returns `[balance, receipt]` — receipt is needed for {@link repayFlashLoanPTB}. * @throws if the pool does not support flash loans. */ export declare function flashloanPTB(tx: Transaction, identifier: AssetIdentifier, amount: number | TxValue, options?: Partial): Promise<{ NestedResult: [number, number]; $kind: "NestedResult"; }[]>; /** * Add a Navi flash-loan repayment to the PTB. * @returns `[balance]` left over after repayment. * @throws if the pool does not support flash loans. */ export declare function repayFlashLoanPTB(tx: Transaction, identifier: AssetIdentifier, receipt: TxValue | string, coinObject: TxValue, options?: Partial): Promise<{ NestedResult: [number, number]; $kind: "NestedResult"; }[]>; export {}; //# sourceMappingURL=naviFlashloan.d.ts.map