import { BaseYields, RewardsList } from './apiReturnType';
export type SerializedBigNumber = string;
export type SerializedNumber = string;
export interface LenderUserQuery {
    /** the lender enum (Note that for multi-market ones, it is not the lender but the group)  */
    lender: any;
    /** user address */
    account: string;
    /** custom parameters for fetching e.g. multi-market lenders */
    params?: any[];
    /** custom parameters for spceifying assets */
    assets?: any[];
}
/**
 * Collapse per-market queries whose builder + RPC call are identical
 * across every market key into a single query. Without this, a chain
 * with N Gearbox CMs (or N Morpho markets) would fan out into N
 * identical RPC calls — all returning the same owner-scoped data.
 *
 * - **Morpho** (`MORPHO_BLUE_*` / `LISTA_DAO_*`): one query per family,
 *   `params` carries the original per-market lender keys.
 * - **Gearbox V3** (`GEARBOX_V3_*`): one `Lender.GEARBOX_V3` query per
 *   chain; `AccountCompressor.getCreditAccounts` already scopes by
 *   `configurators` + `owner`, so we only need to run the call once.
 *   `params` carries the requested per-CM lender keys in case the
 *   parser wants to emit empty buckets for CMs the user has no CAs
 *   in (currently it only emits populated ones — same outcome, but
 *   without the 24-duplicate-RPC-call penalty).
 */
export declare function organizeUserQueries(queries: LenderUserQuery[]): LenderUserQuery[];
export interface UserLendingPosition {
    deposits: string;
    debt: string;
    debtStable: number;
    depositsUSD: number;
    debtUSD: number;
    debtStableUSD: number;
    collateralEnabled: boolean;
    claimableRewards: number;
}
export type UserRewardEntry = {
    asset: string;
    totalRewards: number;
    claimableRewards: number;
}[];
export interface LenderUserResponse {
    chainId: string;
    account: string;
    lendingPositions: {
        [lender: string]: {
            [marketUid: string]: UserLendingPosition;
        };
    };
    rewards: UserRewardEntry;
}
export declare enum AaveV2TypeGetUserReserveData {
    currentATokenBalance = 0,
    currentStableDebt = 1,
    currentVariableDebt = 2,
    principalStableDebt = 3,
    scaledVariableDebt = 4,
    stableBorrowRate = 5,
    liquidityRate = 6,
    stableRateLastUpdated = 7,
    usageAsCollateralEnabled = 8
}
export declare enum AaveV3TypeGetUserReserveData {
    currentATokenBalance = 0,
    currentStableDebt = 1,
    currentVariableDebt = 2,
    principalStableDebt = 3,
    scaledVariableDebt = 4,
    stableBorrowRate = 5,
    liquidityRate = 6,
    stableRateLastUpdated = 7,
    usageAsCollateralEnabled = 8
}
export interface AaveV2UserReserveResponse {
    chainId: string;
    account: string;
    lendingPositions: {
        [marketUid: string]: BaseLendingPositions;
    };
    rewards: UserRewardEntry;
}
export interface CompoundV2UserReserveResponse extends AaveV2UserReserveResponse {
}
export interface BaseLendingPositions {
    marketUid: string;
    /**
     * Optional loan binding. Absent ⇒ the position applies to ALL loans (e.g. shared collateral);
     * present ⇒ the position is strictly tied to that loan. (Distinct from sub-account `accountId`.)
     */
    loanId?: string;
    deposits: string;
    debt: string;
    debtStable: string;
    depositsUSD: number;
    debtUSD: number;
    debtStableUSD: number;
    depositsUSDOracle?: number;
    debtUSDOracle?: number;
    debtStableUSDOracle?: number;
    collateralEnabled: boolean;
    claimableRewards: number;
    /** max withdrawable token amount (capped at deposit balance) */
    withdrawable?: string;
    /** max borrowable token amount */
    borrowable?: string;
    /** remaining deposit capacity in token units (null = uncapped) */
    depositable?: string;
    /** Underlying asset info (asset metadata, prices, oracle price) */
    underlyingInfo?: {
        asset: any;
        oraclePrice?: any;
        prices: any;
    };
    /** Standard collateral deposit amount (borrowable, accrues interest) */
    depositsStandard?: string;
    /** Protected collateral deposit amount (non-borrowable, no interest accrual) */
    depositsProtected?: string;
    /** Collateral share exchange rate: assets per 10^decimals shares */
    collateralRate?: string;
}
/**
 * Early-repayment policy for a fixed-term market. `none` = a borrower can exit
 * any time at the current market price with no penalty (Morpho Midnight buys the
 * debt units back on the order book). `penalty` = a per-loan penalty applies
 * (Lista); the concrete amount is position-level, on `ListaTermLoan.earlyRepayPenalty`.
 * `discount` = repaying early costs LESS than face value (Exactly: the pool's
 * unassigned earnings are rebated to the early repayer — the exact amount comes
 * from `previewRepayAtMaturity` at repay time). Note that a `discount` lender
 * can still have a LATE-repay penalty (see `fees.latePenaltyApr`).
 */
export type FixedTermEarlyRepay = {
    kind: 'none' | 'penalty' | 'discount';
};
/**
 * Who fronts a fixed term — the cross-protocol answer to "who is offering these
 * borrow/lend terms". Consistent across lenders even though the shape differs:
 *  - `broker`: a single market broker sets the term (Lista LendingBroker proxy).
 *    `address` is that broker contract — one per market, stable, public.
 *  - `orderbook`: the term is an aggregate of many signed maker offers (Morpho
 *    Midnight) or continuous repo-token listings (Term Finance secondary
 *    market). There is no single provider at the market level, so `address` is
 *    omitted; the concrete maker(s) are per-offer and only known at quote time.
 *  - `auction`: the term is discovered by a periodic sealed-bid auction (Term
 *    Finance primary market). `address` is the per-repo auction/servicer venue.
 *  - `pool`: the term is fronted by a passive liquidity pool with a
 *    utilization-curve rate (Exactly fixed pools backed by the floating pool).
 *    `address` is the Market contract.
 */
export interface FixedTermProvider {
    kind: 'broker' | 'orderbook' | 'auction' | 'pool';
    /** The single counterparty/venue contract, when there is one (Lista broker, Term servicer). */
    address?: string;
}
/**
 * Canonical fixed-term market descriptor, emitted on `params.market.fixedTerm`
 * for EVERY fixed-rate / fixed-maturity market (Lista brokered + Morpho
 * Midnight) so consumers read ONE shape instead of branching per protocol. The
 * rate-card menu stays on `params.market.terms`; this carries the cross-protocol
 * maturity + fee + early-repay facts. Absent on non-fixed-term markets.
 */
export interface FixedTermInfo {
    /** Underlying fixed-term protocol shape. */
    model: 'lista' | 'midnight' | 'term' | 'exactly' | 'teller';
    /**
     * Single fixed calendar maturity (unix secs). Undefined for rolling-duration
     * menus (Lista) and multi-maturity markets (Exactly — the maturity menu lives
     * on `params.market.terms`, keyed by `termId` = maturity timestamp).
     */
    maturity?: number;
    /** Market-level fees. Empty for lenders without them (Lista); values are 0 when genuinely off. */
    fees: {
        /** Continuous fee, %/yr — ongoing lender-side haircut (Midnight). */
        continuousFeeApr?: number;
        /** Settlement fee as a fraction at the current time-to-maturity (Midnight). */
        settlementFee?: number;
        /**
         * LATE-repayment penalty, %/yr, accruing per second on overdue debt after
         * maturity until repaid (Exactly `penaltyRate`). Absent for lenders whose
         * overdue handling is liquidation-only (Midnight/Term).
         */
        latePenaltyApr?: number;
        /**
         * UPFRONT origination fee as a percent of the borrowed principal, charged
         * once at borrow time (Teller: market fee + protocol fee). Not an APR.
         */
        originationFeePercent?: number;
    };
    /** Early-repayment policy. */
    earlyRepay: FixedTermEarlyRepay;
    /** Who offers the term (Lista broker vs Midnight order book). */
    provider?: FixedTermProvider;
}
/** A Lista loan, attached to its own entry in the positions array. */
export interface ListaTermLoan {
    /** loanId — the repay target for the LISTA_BROKER_REPAY composer op. For fixed loans this is the
     *  posId; for the dynamic (flexible) loan it is the dynamic sentinel (type(uint128).max). */
    loanId: string;
    /** true for the flexible (dynamic / variable-rate) loan; fixed loans omit it */
    isDynamic?: boolean;
    /** best-effort term product id (matched from duration vs the current menu); may be undefined */
    termId?: number;
    /** outstanding debt in loan-token units (principal + accrued interest) */
    debt: string;
    /** locked annualised borrow rate in PERCENT (e.g. 3.857 = 3.857% APR) */
    apr?: number;
    /** unix maturity timestamp */
    maturity?: number;
    termDays?: number;
    /** outstanding accrued interest in loan-token units */
    accruedInterest?: string;
    /** early-repayment penalty (loan-token units) to close the loan now; 0 once matured */
    earlyRepayPenalty?: string;
    isMatured?: boolean;
}
interface MorphoLendingPositions extends BaseLendingPositions {
    isWhitelisted?: boolean;
    /**
     * Lista fixed-term loan detail. A brokered market emits, under the same accountId, one extra
     * positions[] entry per fixed-term loan carrying this `term` (with termId + term data); its
     * debt sits in `debtStable` and `loanId` is the repay target. The aggregate loan position
     * (no `term`) carries the rollup `debtStable` total for health.
     */
    term?: ListaTermLoan;
}
export interface AaveV3UserReserveResponse {
    chainId: string;
    lendingPositions: {
        [marketUid: string]: BaseLendingPositions;
    };
    userEMode: number;
    rewards?: any;
    account: string;
}
export interface MorphoUserReserveResponse {
    chainId: string;
    lendingPositions: {
        [marketUid: string]: MorphoLendingPositions;
    };
    id: string;
    rewards?: any;
    account: string;
}
export interface CompoundV3UserReserveResponse {
    lendingPositions: {
        [marketUid: string]: {
            deposits: string;
            debt: string;
            debtStable: string;
            depositsUSD: number;
            debtUSD: number;
            debtStableUSD: number;
            collateralEnabled: boolean;
            isAllowed: boolean;
        };
    };
    chainId: string;
    baseAsset: string;
    rewards: UserRewardEntry;
    account: string;
}
export interface AaveV3Public extends LenderPublicBase {
    lastUpdateTimestamp?: number;
    collateralActive?: boolean;
    hasStable?: boolean;
    isActive?: boolean;
    isFrozen?: boolean;
    eMode?: EModeData;
    debtCeiling: number;
    supplyCap: number;
    borrowCap: number;
    config: {
        [modeId: string]: LenderConfigData;
    };
}
/**
 * Interface shared by all lenders
 */
export interface LenderPublicBase extends LenderYields, LenderTotalAmounts {
    borrowingEnabled: boolean;
    depositsEnabled: boolean;
    /**
     * Max fraction of a borrower's debt repayable in one liquidation (0..1).
     * Protocol-level constant for most lenders (Aave `0.5`, Compound V2
     * `closeFactorMantissa`); `1` (full liquidation) for isolated /
     * credit-account protocols. Defaults to `1` when not applicable.
     */
    closeFactor: number;
    /**
     * Liquidation target health factor (e.g. 1.05) for protocols that liquidate
     * to a target HF rather than by a fixed close factor (Aave V4, spoke-level).
     * `undefined` where the protocol has no such parameter.
     */
    targetHealthFactor?: number;
    config: LenderConfigMap;
}
export interface LenderYields extends BaseYields {
    intrinsicYield: number;
    rewards?: RewardsList;
}
export interface LenderTotalAmounts {
    totalDebt: number;
    totalDebtStable: number;
    totalDeposits: number;
    totalLiquidity: number;
    /** USD values */
    totalDebtUSD: number;
    totalDebtStableUSD: number;
    totalDepositsUSD: number;
    totalLiquidityUSD: number;
}
export interface LenderConfigMap {
    [modeId: string]: LenderConfigData;
}
/**
 * The Mode-specific configuration for a lender asset
 */
export interface LenderConfigData {
    label?: string;
    category: number;
    borrowCollateralFactor: number;
    collateralFactor: number;
    borrowFactor: number;
    /**
     * Liquidation penalty for this mode, as a fraction of repaid debt the
     * liquidator receives on top of par (e.g. `0.05` = 5% bonus). Mode-specific
     * where the protocol supports it (Aave e-modes, Dolomite categories, Euler
     * vaults); `0` when not liquidatable in this mode or unsupported.
     */
    liquidationPenalty: number;
    /**
     * Max fraction of debt repayable in a single liquidation (0..1). Mirrors the
     * pool-level {@link LenderPublicBase.closeFactor}; identical across every mode
     * of a market (no supported protocol varies close factor by e-mode).
     */
    closeFactor: number;
    /**
     * Liquidation target health factor (e.g. 1.05) for protocols that liquidate
     * to a target HF rather than by a fixed close factor (Aave V4, spoke-level).
     * Mirrors {@link LenderPublicBase.targetHealthFactor}; `undefined` otherwise.
     */
    targetHealthFactor?: number;
    collateralDisabled?: boolean;
    debtDisabled?: boolean;
}
export interface ModeBase {
    category: number;
    label: string;
}
export interface EModeData extends ModeBase {
    borrowCollateralFactor: number;
    collateralFactor: number;
    priceSource: string;
}
export interface AaveV2Public extends LenderPublicBase {
    lastUpdateTimestamp?: number;
    decimals?: number;
    reserveFactor?: SerializedBigNumber;
    collateralActive?: boolean;
    hasStable?: boolean;
    isActive?: boolean;
    isFrozen?: boolean;
}
export interface CompoundV3Public extends LenderPublicBase {
    supplyCap: number;
    collateralActive: boolean;
    utilization: number;
}
export interface UserApr {
    apr: number;
    borrowApr: number;
    depositApr: number;
}
export interface InitUserReserveResponse {
    chainId: string;
    lendingPositions: {
        [posId: string]: {
            [marketUid: string]: {
                deposits: string;
                debt: string;
                depositsUSD: number;
                debtUSD: number;
                debtStable: '0';
                debtStableUSD: 0;
                collateralEnabled: boolean;
                isAllowed: boolean;
            };
        };
    };
    /** Mode per position ID, separated from positions for clean array serialization */
    modes: {
        [posId: string]: any;
    };
    account: string;
}
export interface InitPublic extends LenderPublicBase {
    collateralActive?: boolean;
    debtCeiling: number;
    supplyCap: number;
    borrowCap: number;
}
export {};
//# sourceMappingURL=lenderTypes.d.ts.map