import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';

interface T2000Options {
    keyPath?: string;
    /** PIN to decrypt the key file. Accepts any string (4+ chars). */
    pin?: string;
    /** @deprecated Use `pin` instead. */
    passphrase?: string;
    network?: 'mainnet' | 'testnet';
    rpcUrl?: string;
    sponsored?: boolean;
    name?: string;
}
interface GasReserve {
    sui: number;
    usdEquiv: number;
}
interface BalanceResponse {
    available: number;
    savings: number;
    debt: number;
    investment: number;
    investmentPnL: number;
    pendingRewards: number;
    gasReserve: GasReserve;
    total: number;
    assets: Record<string, number>;
    stables: Record<string, number>;
}
type GasMethod = 'self-funded' | 'sponsored' | 'auto-topup' | 'none';
interface SendResult {
    success: boolean;
    tx: string;
    amount: number;
    to: string;
    contactName?: string;
    gasCost: number;
    gasCostUnit: string;
    gasMethod: GasMethod;
    balance: BalanceResponse;
}
interface SaveResult {
    success: boolean;
    tx: string;
    amount: number;
    apy: number;
    fee: number;
    gasCost: number;
    gasMethod: GasMethod;
    savingsBalance: number;
}
interface WithdrawResult {
    success: boolean;
    tx: string;
    amount: number;
    gasCost: number;
    gasMethod: GasMethod;
}
interface BorrowResult {
    success: boolean;
    tx: string;
    amount: number;
    fee: number;
    healthFactor: number;
    gasCost: number;
    gasMethod: GasMethod;
}
interface RepayResult {
    success: boolean;
    tx: string;
    amount: number;
    remainingDebt: number;
    gasCost: number;
    gasMethod: GasMethod;
}
interface SwapResult {
    success: boolean;
    tx: string;
    fromAmount: number;
    fromAsset: string;
    toAmount: number;
    toAsset: string;
    priceImpact: number;
    fee: number;
    gasCost: number;
    gasMethod: GasMethod;
}
interface HealthFactorResult {
    healthFactor: number;
    supplied: number;
    borrowed: number;
    maxBorrow: number;
    liquidationThreshold: number;
}
interface MaxWithdrawResult {
    maxAmount: number;
    healthFactorAfter: number;
    currentHF: number;
}
interface MaxBorrowResult {
    maxAmount: number;
    healthFactorAfter: number;
    currentHF: number;
}
interface AssetRates {
    saveApy: number;
    borrowApy: number;
}
interface RatesResult {
    [asset: string]: AssetRates;
}
interface PositionEntry {
    protocol: string;
    asset: string;
    type: 'save' | 'borrow';
    amount: number;
    amountUsd?: number;
    apy: number;
}
interface PositionsResult {
    positions: PositionEntry[];
}
interface EarningsResult {
    totalYieldEarned: number;
    currentApy: number;
    dailyEarning: number;
    supplied: number;
}
interface FundStatusResult {
    supplied: number;
    apy: number;
    earnedToday: number;
    earnedAllTime: number;
    projectedMonthly: number;
}
interface RebalanceStep {
    action: 'withdraw' | 'swap' | 'deposit';
    protocol?: string;
    fromAsset?: string;
    toAsset?: string;
    amount: number;
    estimatedOutput?: number;
}
interface RebalanceResult {
    executed: boolean;
    steps: RebalanceStep[];
    fromProtocol: string;
    fromAsset: string;
    toProtocol: string;
    toAsset: string;
    amount: number;
    currentApy: number;
    newApy: number;
    annualGain: number;
    estimatedSwapCost: number;
    breakEvenDays: number;
    txDigests: string[];
    totalGasCost: number;
}
interface DepositInfo {
    address: string;
    network: string;
    supportedAssets: string[];
    instructions: string;
}
interface TransactionRecord {
    digest: string;
    action: string;
    amount?: number;
    asset?: string;
    timestamp: number;
    gasMethod?: GasMethod;
}
interface SentinelAgent {
    id: string;
    objectId: string;
    name: string;
    model: string;
    systemPrompt: string;
    attackFee: bigint;
    prizePool: bigint;
    totalAttacks: number;
    successfulBreaches: number;
    state: string;
}
interface SentinelVerdict {
    success: boolean;
    score: number;
    agentResponse: string;
    juryResponse: string;
    funResponse: string;
    signature: string;
    timestampMs: number;
}
interface SentinelAttackResult {
    attackObjectId: string;
    sentinelId: string;
    prompt: string;
    verdict: SentinelVerdict;
    requestTx: string;
    settleTx: string;
    won: boolean;
    feePaid: number;
}
interface InvestmentTrade {
    id: string;
    type: 'buy' | 'sell';
    asset: string;
    amount: number;
    price: number;
    usdValue: number;
    fee: number;
    tx: string;
    timestamp: string;
}
interface InvestmentPosition {
    asset: string;
    totalAmount: number;
    costBasis: number;
    avgPrice: number;
    currentPrice: number;
    currentValue: number;
    unrealizedPnL: number;
    unrealizedPnLPct: number;
    trades: InvestmentTrade[];
    earning?: boolean;
    earningProtocol?: string;
    earningApy?: number;
}
interface PortfolioResult {
    positions: InvestmentPosition[];
    totalInvested: number;
    totalValue: number;
    unrealizedPnL: number;
    unrealizedPnLPct: number;
    realizedPnL: number;
}
interface InvestResult {
    success: boolean;
    tx: string;
    type: 'buy' | 'sell';
    asset: string;
    amount: number;
    price: number;
    usdValue: number;
    fee: number;
    gasCost: number;
    gasMethod: GasMethod;
    realizedPnL?: number;
    position: InvestmentPosition;
}
interface InvestEarnResult {
    success: boolean;
    tx: string;
    asset: string;
    amount: number;
    protocol: string;
    apy: number;
    gasCost: number;
    gasMethod: GasMethod;
}
interface InvestRebalanceMove {
    asset: string;
    fromProtocol: string;
    toProtocol: string;
    amount: number;
    oldApy: number;
    newApy: number;
    txDigests: string[];
    gasCost: number;
}
interface InvestRebalanceResult {
    executed: boolean;
    moves: InvestRebalanceMove[];
    totalGasCost: number;
    skipped: Array<{
        asset: string;
        protocol: string;
        apy: number;
        bestApy: number;
        reason: string;
    }>;
}
interface StrategyDefinition {
    name: string;
    allocations: Record<string, number>;
    description: string;
    custom: boolean;
}
interface StrategyBuyResult {
    success: boolean;
    strategy: string;
    totalInvested: number;
    buys: Array<{
        asset: string;
        usdAmount: number;
        amount: number;
        price: number;
        tx: string;
    }>;
    gasCost: number;
    gasMethod: GasMethod;
}
interface StrategySellResult {
    success: boolean;
    strategy: string;
    totalProceeds: number;
    realizedPnL: number;
    sells: Array<{
        asset: string;
        amount: number;
        usdValue: number;
        realizedPnL: number;
        tx: string;
    }>;
    failed?: Array<{
        asset: string;
        reason: string;
    }>;
    gasCost: number;
    gasMethod: GasMethod;
}
interface StrategyRebalanceResult {
    success: boolean;
    strategy: string;
    trades: Array<{
        action: 'buy' | 'sell';
        asset: string;
        usdAmount: number;
        amount: number;
        tx: string;
    }>;
    beforeWeights: Record<string, number>;
    afterWeights: Record<string, number>;
    targetWeights: Record<string, number>;
}
interface StrategyStatusResult {
    definition: StrategyDefinition;
    positions: InvestmentPosition[];
    currentWeights: Record<string, number>;
    totalValue: number;
}
interface AutoInvestSchedule {
    id: string;
    strategy?: string;
    asset?: string;
    amount: number;
    frequency: 'daily' | 'weekly' | 'monthly';
    dayOfWeek?: number;
    dayOfMonth?: number;
    lastRun?: string;
    nextRun: string;
    enabled: boolean;
    totalInvested: number;
    runCount: number;
}
interface AutoInvestStatus {
    schedules: AutoInvestSchedule[];
    pendingRuns: AutoInvestSchedule[];
}
interface AutoInvestRunResult {
    executed: Array<{
        scheduleId: string;
        strategy?: string;
        asset?: string;
        amount: number;
        result: StrategyBuyResult | InvestResult;
    }>;
    skipped: Array<{
        scheduleId: string;
        reason: string;
    }>;
}
interface PendingReward$1 {
    protocol: string;
    asset: string;
    coinType: string;
    symbol: string;
    amount: number;
    estimatedValueUsd: number;
}
interface ClaimRewardsResult {
    success: boolean;
    tx: string;
    rewards: PendingReward$1[];
    totalValueUsd: number;
    usdcReceived: number;
    gasCost: number;
    gasMethod: GasMethod;
}
type PositionSide = 'long' | 'short';
interface PerpsPosition {
    market: string;
    side: PositionSide;
    margin: number;
    leverage: number;
    size: number;
    entryPrice: number;
    markPrice: number;
    liquidationPrice: number;
    unrealizedPnL: number;
    unrealizedPnLPct: number;
}
interface TradeResult {
    success: boolean;
    action: 'open' | 'close';
    market: string;
    side: PositionSide;
    margin: number;
    leverage: number;
    size: number;
    entryPrice: number;
    liquidationPrice?: number;
    realizedPnL?: number;
    tx?: string;
}
interface TradePositionsResult {
    positions: PerpsPosition[];
    totalMargin: number;
    totalUnrealizedPnL: number;
}

type AdapterCapability = 'save' | 'withdraw' | 'borrow' | 'repay' | 'swap' | 'perps';
/**
 * Describes a protocol for indexer event classification.
 * Each adapter exports one of these so the server can auto-build
 * detection rules without manual sync.
 *
 * To add a new protocol: export a `descriptor` from your adapter file.
 */
interface ProtocolDescriptor {
    /** Unique protocol ID — must match the adapter's `id` field */
    id: string;
    /** Human-readable name */
    name: string;
    /**
     * On-chain package IDs that identify this protocol's transactions.
     * For protocols with upgradeable packages, list the original/base package.
     */
    packages: string[];
    /**
     * Maps `module::function` patterns to action types.
     * The indexer matches Move call targets against these patterns.
     * For dynamic package IDs (e.g. NAVI), matching is done on module::function only.
     */
    actionMap: Record<string, string>;
    /**
     * If true, the indexer matches by module::function suffix only,
     * ignoring the package ID prefix. Use for protocols with frequently
     * upgraded (dynamic) package IDs.
     */
    dynamicPackageId?: boolean;
}
interface AdapterTxResult {
    tx: Transaction;
    feeCoin?: TransactionObjectArgument;
    meta?: Record<string, unknown>;
}
interface LendingRates {
    asset: string;
    saveApy: number;
    borrowApy: number;
}
interface AdapterPositions {
    supplies: Array<{
        asset: string;
        amount: number;
        amountUsd?: number;
        apy: number;
    }>;
    borrows: Array<{
        asset: string;
        amount: number;
        amountUsd?: number;
        apy: number;
    }>;
}
interface HealthInfo {
    healthFactor: number;
    supplied: number;
    borrowed: number;
    maxBorrow: number;
    liquidationThreshold: number;
}
interface SwapQuote {
    expectedOutput: number;
    priceImpact: number;
    poolPrice: number;
}
interface LendingAdapter {
    readonly id: string;
    readonly name: string;
    readonly version: string;
    readonly capabilities: readonly AdapterCapability[];
    readonly supportedAssets: readonly string[];
    readonly supportsSameAssetBorrow: boolean;
    init(client: SuiJsonRpcClient): Promise<void>;
    getRates(asset: string): Promise<LendingRates>;
    getPositions(address: string): Promise<AdapterPositions>;
    getHealth(address: string): Promise<HealthInfo>;
    buildSaveTx(address: string, amount: number, asset: string, options?: {
        collectFee?: boolean;
    }): Promise<AdapterTxResult>;
    buildWithdrawTx(address: string, amount: number, asset: string): Promise<AdapterTxResult & {
        effectiveAmount: number;
    }>;
    buildBorrowTx(address: string, amount: number, asset: string, options?: {
        collectFee?: boolean;
    }): Promise<AdapterTxResult>;
    buildRepayTx(address: string, amount: number, asset: string): Promise<AdapterTxResult>;
    maxWithdraw(address: string, asset: string): Promise<{
        maxAmount: number;
        healthFactorAfter: number;
        currentHF: number;
    }>;
    maxBorrow(address: string, asset: string): Promise<{
        maxAmount: number;
        healthFactorAfter: number;
        currentHF: number;
    }>;
    addWithdrawToTx?(tx: Transaction, address: string, amount: number, asset: string): Promise<{
        coin: TransactionObjectArgument;
        effectiveAmount: number;
    }>;
    addSaveToTx?(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string, options?: {
        collectFee?: boolean;
    }): Promise<void>;
    addRepayToTx?(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string): Promise<void>;
    getPendingRewards?(address: string): Promise<PendingReward[]>;
    addClaimRewardsToTx?(tx: Transaction, address: string): Promise<PendingReward[]>;
}
interface PendingReward {
    protocol: string;
    asset: string;
    coinType: string;
    symbol: string;
    amount: number;
    estimatedValueUsd: number;
}
interface SwapAdapter {
    readonly id: string;
    readonly name: string;
    readonly version: string;
    readonly capabilities: readonly AdapterCapability[];
    init(client: SuiJsonRpcClient): Promise<void>;
    getQuote(from: string, to: string, amount: number): Promise<SwapQuote>;
    buildSwapTx(address: string, from: string, to: string, amount: number, maxSlippageBps?: number): Promise<AdapterTxResult & {
        estimatedOut: number;
        toDecimals: number;
    }>;
    getSupportedPairs(): Array<{
        from: string;
        to: string;
    }>;
    getPoolPrice(): Promise<number>;
    addSwapToTx?(tx: Transaction, address: string, inputCoin: TransactionObjectArgument, from: string, to: string, amount: number, maxSlippageBps?: number): Promise<{
        outputCoin: TransactionObjectArgument;
        estimatedOut: number;
        toDecimals: number;
    }>;
}
interface PerpsAdapter {
    readonly id: string;
    readonly name: string;
    readonly version: string;
    readonly capabilities: readonly AdapterCapability[];
    readonly supportedMarkets: readonly string[];
    init(keypair: unknown, network: 'mainnet' | 'testnet'): Promise<void>;
    getAccountBalance(address: string): Promise<number>;
    getPositions(address: string): Promise<PerpsPosition[]>;
    getMarketPrice(market: string): Promise<number>;
    deposit(amount: number): Promise<string>;
    withdraw(amount: number): Promise<string>;
    openPosition(params: {
        market: string;
        side: PositionSide;
        margin: number;
        leverage: number;
    }): Promise<TradeResult>;
    closePosition(market: string): Promise<TradeResult>;
}

declare class ProtocolRegistry {
    private lending;
    private swap;
    registerLending(adapter: LendingAdapter): void;
    registerSwap(adapter: SwapAdapter): void;
    bestSaveRate(asset: string): Promise<{
        adapter: LendingAdapter;
        rate: LendingRates;
    }>;
    bestBorrowRate(asset: string, opts?: {
        requireSameAssetBorrow?: boolean;
    }): Promise<{
        adapter: LendingAdapter;
        rate: LendingRates;
    }>;
    bestSwapQuote(from: string, to: string, amount: number): Promise<{
        adapter: SwapAdapter;
        quote: SwapQuote;
    }>;
    bestSaveRateAcrossAssets(): Promise<{
        adapter: LendingAdapter;
        rate: LendingRates;
        asset: string;
    }>;
    allRatesAcrossAssets(): Promise<Array<{
        protocol: string;
        protocolId: string;
        asset: string;
        rates: LendingRates;
    }>>;
    allRates(asset: string): Promise<Array<{
        protocol: string;
        protocolId: string;
        rates: LendingRates;
    }>>;
    allPositions(address: string): Promise<Array<{
        protocol: string;
        protocolId: string;
        positions: AdapterPositions;
    }>>;
    getLending(id: string): LendingAdapter | undefined;
    getSwap(id: string): SwapAdapter | undefined;
    listLending(): LendingAdapter[];
    listSwap(): SwapAdapter[];
}

declare const descriptor$3: ProtocolDescriptor;
declare class NaviAdapter implements LendingAdapter {
    readonly id = "navi";
    readonly name = "NAVI Protocol";
    readonly version = "1.0.0";
    readonly capabilities: readonly AdapterCapability[];
    readonly supportedAssets: readonly string[];
    readonly supportsSameAssetBorrow = true;
    private client;
    init(client: SuiJsonRpcClient): Promise<void>;
    initSync(client: SuiJsonRpcClient): void;
    getRates(asset: string): Promise<LendingRates>;
    getPositions(address: string): Promise<AdapterPositions>;
    getHealth(address: string): Promise<HealthInfo>;
    buildSaveTx(address: string, amount: number, asset: string, options?: {
        collectFee?: boolean;
    }): Promise<AdapterTxResult>;
    buildWithdrawTx(address: string, amount: number, asset: string): Promise<AdapterTxResult & {
        effectiveAmount: number;
    }>;
    buildBorrowTx(address: string, amount: number, asset: string, options?: {
        collectFee?: boolean;
    }): Promise<AdapterTxResult>;
    buildRepayTx(address: string, amount: number, asset: string): Promise<AdapterTxResult>;
    maxWithdraw(address: string, _asset: string): Promise<MaxWithdrawResult>;
    maxBorrow(address: string, _asset: string): Promise<MaxBorrowResult>;
    addWithdrawToTx(tx: Transaction, address: string, amount: number, asset: string): Promise<{
        coin: TransactionObjectArgument;
        effectiveAmount: number;
    }>;
    addSaveToTx(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string, options?: {
        collectFee?: boolean;
    }): Promise<void>;
    addRepayToTx(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string): Promise<void>;
    getPendingRewards(address: string): Promise<PendingReward[]>;
    addClaimRewardsToTx(tx: Transaction, address: string): Promise<PendingReward[]>;
}

declare const descriptor$2: ProtocolDescriptor;
declare class CetusAdapter implements SwapAdapter {
    readonly id = "cetus";
    readonly name = "Cetus";
    readonly version = "1.0.0";
    readonly capabilities: readonly AdapterCapability[];
    private client;
    init(client: SuiJsonRpcClient): Promise<void>;
    initSync(client: SuiJsonRpcClient): void;
    getQuote(from: string, to: string, amount: number): Promise<SwapQuote>;
    buildSwapTx(address: string, from: string, to: string, amount: number, maxSlippageBps?: number): Promise<AdapterTxResult & {
        estimatedOut: number;
        toDecimals: number;
    }>;
    getSupportedPairs(): Array<{
        from: string;
        to: string;
    }>;
    getPoolPrice(): Promise<number>;
    addSwapToTx(tx: Transaction, address: string, inputCoin: TransactionObjectArgument, from: string, to: string, amount: number, maxSlippageBps?: number): Promise<{
        outputCoin: TransactionObjectArgument;
        estimatedOut: number;
        toDecimals: number;
    }>;
}

declare const descriptor$1: ProtocolDescriptor;
declare class SuilendAdapter implements LendingAdapter {
    readonly id = "suilend";
    readonly name = "Suilend";
    readonly version = "3.0.0";
    readonly capabilities: readonly AdapterCapability[];
    readonly supportedAssets: readonly string[];
    readonly supportsSameAssetBorrow = false;
    private client;
    private sdkClient;
    init(client: SuiJsonRpcClient): Promise<void>;
    initSync(client: SuiJsonRpcClient): void;
    private getSdkClient;
    private resolveSymbol;
    getRates(asset: string): Promise<LendingRates>;
    getPositions(address: string): Promise<AdapterPositions>;
    getHealth(address: string): Promise<HealthInfo>;
    buildSaveTx(address: string, amount: number, asset: string, options?: {
        collectFee?: boolean;
    }): Promise<AdapterTxResult>;
    buildWithdrawTx(address: string, amount: number, asset: string): Promise<AdapterTxResult & {
        effectiveAmount: number;
    }>;
    addWithdrawToTx(tx: Transaction, address: string, amount: number, asset: string): Promise<{
        coin: TransactionObjectArgument;
        effectiveAmount: number;
    }>;
    addSaveToTx(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string, options?: {
        collectFee?: boolean;
    }): Promise<void>;
    buildBorrowTx(address: string, amount: number, asset: string, options?: {
        collectFee?: boolean;
    }): Promise<AdapterTxResult>;
    buildRepayTx(address: string, amount: number, asset: string): Promise<AdapterTxResult>;
    addRepayToTx(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string): Promise<void>;
    private resolveWithdrawCTokens;
    maxWithdraw(address: string, _asset: string): Promise<{
        maxAmount: number;
        healthFactorAfter: number;
        currentHF: number;
    }>;
    maxBorrow(address: string, _asset: string): Promise<{
        maxAmount: number;
        healthFactorAfter: number;
        currentHF: number;
    }>;
    private fetchAllCoins;
    getPendingRewards(address: string): Promise<PendingReward[]>;
    addClaimRewardsToTx(tx: Transaction, address: string): Promise<PendingReward[]>;
}

declare const descriptor: ProtocolDescriptor;
declare function listSentinels(): Promise<SentinelAgent[]>;
declare function getSentinelInfo(client: SuiJsonRpcClient, sentinelObjectId: string): Promise<SentinelAgent>;
declare function requestAttack(client: SuiJsonRpcClient, signer: Ed25519Keypair, sentinelObjectId: string, feeMist: bigint): Promise<{
    attackObjectId: string;
    digest: string;
}>;
declare function submitPrompt(agentId: string, attackObjectId: string, prompt: string): Promise<SentinelVerdict>;
declare function settleAttack(client: SuiJsonRpcClient, signer: Ed25519Keypair, sentinelObjectId: string, attackObjectId: string, prompt: string, verdict: SentinelVerdict): Promise<{
    digest: string;
    success: boolean;
}>;
declare function attack(client: SuiJsonRpcClient, signer: Ed25519Keypair, sentinelId: string, prompt: string, feeMist?: bigint): Promise<SentinelAttackResult>;

/** All registered protocol descriptors — used by the indexer for event classification */
declare const allDescriptors: ProtocolDescriptor[];

export { type ProtocolDescriptor as $, type AutoInvestSchedule as A, type BalanceResponse as B, type ClaimRewardsResult as C, type DepositInfo as D, type EarningsResult as E, type FundStatusResult as F, type GasMethod as G, type HealthFactorResult as H, type InvestmentTrade as I, type AdapterTxResult as J, type AssetRates as K, type LendingAdapter as L, type MaxWithdrawResult as M, CetusAdapter as N, type GasReserve as O, type PendingReward$1 as P, type HealthInfo as Q, type RepayResult as R, type StrategyDefinition as S, type T2000Options as T, type InvestRebalanceMove as U, NaviAdapter as V, type WithdrawResult as W, type PerpsAdapter as X, type PerpsPosition as Y, type PositionEntry as Z, type PositionSide as _, type AutoInvestStatus as a, ProtocolRegistry as a0, type RebalanceStep as a1, type SentinelVerdict as a2, SuilendAdapter as a3, type SwapQuote as a4, type TradePositionsResult as a5, type TradeResult as a6, allDescriptors as a7, descriptor$2 as a8, getSentinelInfo as a9, listSentinels as aa, descriptor$3 as ab, requestAttack as ac, attack as ad, descriptor as ae, settleAttack as af, submitPrompt as ag, descriptor$1 as ah, type SendResult as b, type TransactionRecord as c, type SwapAdapter as d, type SaveResult as e, type BorrowResult as f, type MaxBorrowResult as g, type SwapResult as h, type InvestResult as i, type InvestEarnResult as j, type InvestRebalanceResult as k, type StrategyBuyResult as l, type StrategySellResult as m, type StrategyRebalanceResult as n, type StrategyStatusResult as o, type AutoInvestRunResult as p, type PortfolioResult as q, type InvestmentPosition as r, type PositionsResult as s, type RatesResult as t, type LendingRates as u, type RebalanceResult as v, type SentinelAgent as w, type SentinelAttackResult as x, type AdapterCapability as y, type AdapterPositions as z };
