import { EthAddress, IncentiveData, LeverageType, NetworkNumber, } from './common'; export enum AaveV4HubsType { AaveV4CoreHub = 'aave_v4_core_hub', AaveV4PlusHub = 'aave_v4_plus_hub', AaveV4PrimeHub = 'aave_v4_prime_hub', AaveV4PaxosHub = 'aave_v4_paxos_hub', } export enum AaveV4SpokesType { AaveV4BluechipSpoke = 'aave_v4_bluechip_spoke', AaveV4EthenaCorrelatedSpoke = 'aave_v4_ethena_correlated_spoke', AaveV4EthenaEcosystemSpoke = 'aave_v4_ethena_ecosystem_spoke', AaveV4EtherfiSpoke = 'aave_v4_etherfi_spoke', AaveV4ForexSpoke = 'aave_v4_forex_spoke', AaveV4GoldSpoke = 'aave_v4_gold_spoke', AaveV4KelpSpoke = 'aave_v4_kelp_spoke', AaveV4LidoSpoke = 'aave_v4_lido_spoke', AaveV4LombardBtcSpoke = 'aave_v4_lombard_btc_spoke', AaveV4MainSpoke = 'aave_v4_main_spoke', AaveV4PaxgGoldSpoke = 'aave_v4_paxg_gold_spoke', AaveV4USDGPendleSpoke = 'aave_v4_usdg_pendle_spoke', AaveV4USDGMapleSpoke = 'aave_v4_usdg_maple_spoke', } export interface AaveV4HubInfo { chainIds: NetworkNumber[], label: string, value: AaveV4HubsType, address: EthAddress, } export interface AaveV4HubAssetOnChainData { assetId: number, drawnRate: bigint, liquidity: bigint, liquidityFee: number, swept: bigint, totalDrawn: bigint, totalDrawnShares: bigint, totalPremiumShares: bigint, } export interface AaveV4HubOnChainData { assets: Record, } export interface AaveV4SpokeInfo { chainIds: NetworkNumber[], label: string, value: AaveV4SpokesType, url: string, address: EthAddress, /** * Known hub addresses, used only to prefetch hub data in parallel with the spoke data. * The on-chain reserves are the source of truth — hubs found there but missing here are * fetched dynamically, so this list going stale can't break spoke loading. */ hubs: EthAddress[], } export interface AaveV4SpokeData { assetsData: AaveV4AssetsData, oracle: EthAddress, oracleDecimals: number, address: EthAddress, } export interface AaveV4ReserveAssetOnChain { underlying: EthAddress, hub: EthAddress, assetId: number, decimals: number, paused: boolean, frozen: boolean, borrowable: boolean, collateralRisk: number, collateralFactor: number, maxLiquidationBonus: number, liquidationFee: number, price: bigint, totalSupplied: bigint, totalDrawn: bigint, totalPremium: bigint, totalDebt: bigint, supplyCap: bigint, borrowCap: bigint, deficitRay: bigint, spokeActive: boolean, spokeHalted: boolean } export interface AaveV4ReserveAssetData { symbol: string, /** Underlying token decimals as reported on-chain (independent of `@defisaver/tokens`). */ decimals: number, underlying: EthAddress, hub: EthAddress, hubName: string, assetId: number, reserveId: number, paused: boolean, frozen: boolean, borrowable: boolean, collateralRisk: number, collateralFactor: number, liquidationFee: number, maxLiquidationBonus: number, price: string, totalSupplied: string, totalDrawn: string, totalPremium: string, totalDebt: string, supplyCap: string, borrowCap: string, spokeActive: boolean, spokeHalted: boolean, drawnRate: string, supplyRate: string, borrowRate: string, supplyIncentives: IncentiveData[]; borrowIncentives: IncentiveData[]; /** * Intrinsic incentives pre-combined with scope-specific Merkl rewards, ready to render per surface: * - spoke* → spoke supply/borrow (Create page + dashboard market table) * - hub* → hub supply/borrow (Lend page) * `supplyIncentives`/`borrowIncentives` above remain intrinsic-only; calculateNetApyAaveV4 merges * these scope-specific arrays back in so net APY reflects applicable Merkl rewards too. */ spokeSupplyIncentives?: IncentiveData[]; spokeBorrowIncentives?: IncentiveData[]; hubSupplyIncentives?: IncentiveData[]; hubBorrowIncentives?: IncentiveData[]; canBeBorrowed: boolean; canBeSupplied: boolean; canBeWithdrawn: boolean; canBePayBacked: boolean; utilization: string; /** Hub `liquidity` for this assetId (underlying amount), used for pool-level borrow/withdraw limits */ hubLiquidity: string, premiumMultiplier: string; liquidityFee: string; /** * True when the underlying token is missing from `@defisaver/tokens` (placeholder `?` asset). * The reserve is kept for read-only display, but amounts are zeroed and all actions are disabled. */ isUnsupported?: boolean; } export type AaveV4AssetsData = Record; export interface AaveV4UsedReserveAsset { symbol: string, hubName: string, assetId: number, reserveId: number, supplied: string, suppliedUsd: string, drawn: string, drawnUsd: string, premium: string, premiumUsd: string, borrowed: string, borrowedUsd: string, isSupplied: boolean, isBorrowed: boolean, collateral: boolean, collateralFactor: number, /** True when the underlying token is missing from `@defisaver/tokens` (placeholder `?` asset). */ isUnsupported?: boolean, } export interface AaveV4AggregatedPositionData { suppliedUsd: string, suppliedCollateralUsd: string, borrowLimitUsd: string, liquidationLimitUsd: string, borrowedUsd: string, drawnUsd: string, premiumUsd: string, leftToBorrowUsd: string, ratio: string, collRatio: string, safetyRatio: string, liqRatio: string, liqPercent: string, leveragedType: LeverageType, leveragedAsset: string, liquidationPrice: string, minCollRatio: string, collLiquidationRatio: string, minHealthRatio: string, healthRatio: string, netApy: string, incentiveUsd: string, totalInterestUsd: string, currentVolatilePairRatio?: string, minRatio: string, } export type AaveV4UsedReserveAssets = Record; export interface AaveV4AccountData extends AaveV4AggregatedPositionData { usedAssets: AaveV4UsedReserveAssets, healthFactor: string, riskPremiumBps: number, } /** One Aave V4 tokenized spoke (Lend vault) as the view contract returns it for a user. */ export interface AaveV4TokenizationSpokeData { underlyingAsset: EthAddress; assetId: string; decimals: number; spoke: EthAddress; spokeActive: boolean; spokeHalted: boolean; spokeDepositCap: string; spokeTotalAssets: string; spokeTotalShares: string; hub: EthAddress; hubLiquidity: string; hubDrawnRate: string; convertToShares: string; convertToAssets: string; user: EthAddress; userSuppliedAssets: string; userSuppliedShares: string; } /** Parsed tokenization spoke data with human-readable supplied amounts for display */ export interface AaveV4TokenizationSpokeDataParsed { vaultAddress: EthAddress; key: string | null; symbol: string; hubKey: string; // ---- Spoke ---- spokeActive: boolean; spokeHalted: boolean; /** Deposit cap in asset units (wei string) */ spokeDepositCap: string; /** Total assets currently in spoke in asset units (wei string) */ spokeTotalAssets: string; // ---- Hub ---- /** Available hub liquidity in asset units (wei string) */ hubLiquidity: string; /** The conversion rate from assets to shares expressed in asset units. */ convertToShares: string; // ---- User ---- userSuppliedAssetsEth: string; userSuppliedSharesEth: string; userSuppliedAssets: string; userSuppliedShares: string; underlyingAsset: EthAddress; spoke: EthAddress; decimals: number; }