import { PublicKey, TransactionSignature, AddressLookupTableAccount, TransactionInstruction, Connection } from '@solana/web3.js';
import { Basket } from './basketState';
import { TokenSettings, TransactionToSend } from './config';
import { Program } from '@coral-xyz/anchor';
import { BasketsIDL } from './basketsIDL';
type RebalanceInfo = {
    over: TokenRebalanceInfo[];
    under: TokenRebalanceInfo[];
};
type TokenRebalanceInfo = {
    value: number;
    token: number;
    amount: number;
    iT?: boolean;
    rR?: boolean;
    uM: number;
};
type RebalanceAmounts = {
    from: number;
    to: number;
    tokenAmount: number;
    value: number;
};
type JupiterSwapData = {
    addressLookupTableAddresses: string[];
    swapInstruction: any;
    setupInstructions: any[];
    res: {
        inAmount: number;
    };
    tokenAmount: number;
    swapValue: number;
};
/**
 * Fetches the current timestamp from the confirmed slot on the Solana blockchain.
 * This is used to determine when rebalances should occur based on basket settings.
 * @param connection The Solana connection
 * @returns The current timestamp or a default value
 */
export declare function getConfirmedTimestamp(connection: Connection, basket: Basket): Promise<number>;
/**
 * Fetches the lookup table account from the Solana blockchain.
 * Lookup tables are used to optimize transaction size and cost for complex operations like rebalancing.
 * @param connection The Solana connection
 * @returns The lookup table account
 */
export declare function getLookupTableAccount(connection: Connection, lookupTableAccount: PublicKey): Promise<AddressLookupTableAccount>;
/**
 * Determines if force rebalance is needed for actively managed baskets.
 * This allows basket managers to trigger rebalances regardless of other conditions.
 * @param basket The basket to check
 * @param wallet The wallet to use
 * @returns True if force rebalance is needed, false otherwise
 */
export declare function isForceRebalanceNeeded(basket: Basket, walletPublicKey: PublicKey): boolean;
/**
 * Gets and sorts the rebalance info for a basket.
 * This function calculates which tokens are over or under their target weights,
 * considering the basket's rebalance threshold and current market prices.
 * @param basket The basket to rebalance
 * @param oraclePriceData Oracle price data for accurate token valuation
 * @param timestamp Current timestamp
 * @param tokenList The token list
 * @returns Sorted rebalance info
 */
export declare function getSortedRebalanceInfo(basket: Basket, oraclePriceData: number[], timestamp: number, tokenList: any): RebalanceInfo;
/**
 * Builds rebalance transactions for a basket.
 * This function creates transactions to adjust token weights to match their target weights,
 * considering factors like rebalance threshold, interval, and slippage settings.
 * @param basket The basket to rebalance
 * @param rebalanceInfos Information about tokens that need rebalancing
 * @param oraclePriceData Current oracle price data for tokens
 * @param forceRebalance Whether to force rebalance regardless of conditions
 * @param lookupTableAccount The lookup table account for the transaction
 * @param wallet The wallet to use for the transaction
 * @param connection The Solana connection
 * @param program The program instance
 * @param tokenList List of tokens in the basket
 * @param lamports Amount of lamports to use
 * @returns An array of transactions to send to the Solana blockchain
 */
export declare function buildRebalanceTransactions(basket: Basket, rebalanceInfos: RebalanceInfo, oraclePriceData: number[], forceRebalance: boolean, lookups: AddressLookupTableAccount[], maxAllowedAccounts: number, walletPublicKey: PublicKey, connection: Connection, program: Program<BasketsIDL>, tokenList: TokenSettings[], lamports: number, updateOraclesTxData: TransactionToSend[], softCap: number, hardCap: number, underTokens: number, overTokens: number, jupAPIkey: string): Promise<TransactionToSend[]>;
/**
 * Determines if a rebalance should be processed.
 * This function checks if the rebalance is necessary based on the basket's settings and current state.
 * @param over Over-weighted token info
 * @param under Under-weighted token info
 * @param forceRebalance Whether to force rebalance
 * @returns True if rebalance should be processed, false otherwise
 */
export declare function shouldProcessRebalance(over: TokenRebalanceInfo, under: TokenRebalanceInfo, forceRebalance: boolean): boolean;
/**
 * Calculates rebalance amounts.
 * This function determines how much of each token should be swapped to bring them closer to their target weights.
 * @param over Over-weighted token info
 * @param under Under-weighted token info
 * @param oraclePriceData Oracle price data
 * @param tokenList The token list
 * @returns Calculated rebalance amounts
 */
export declare function calculateRebalanceAmounts(over: TokenRebalanceInfo, under: TokenRebalanceInfo, oraclePriceData: number[], tokenList: any, hardCap: number): RebalanceAmounts;
/**
 * Gets Jupiter swap data.
 * This function prepares the data needed for a token swap using Jupiter DEX aggregator.
 * @param from From token
 * @param to To token
 * @param tokenAmount Token amount
 * @param basket Basket
 * @param oraclePriceData Oracle price data
 * @param wallet The wallet to use
 * @param tokenList The token list
 * @returns Jupiter swap data or null if failed
 */
export declare function getJupiterSwapData(from: number, to: number, tokenAmount: number, maxAllowedAccounts: number, basket: Basket, oraclePriceData: number[], walletPublicKey: PublicKey, tokenList: any, jupAPIkey: string): Promise<JupiterSwapData | null>;
/**
 * Builds a rebalance transaction.
 * This function creates a transaction that will perform the actual rebalancing of tokens in the basket on the Solana blockchain.
 * @param basket The basket to rebalance
 * @param from From token
 * @param to To token
 * @param tokenAmount Token amount
 * @param jupData Jupiter swap data
 * @param lookupTableAccount Lookup table account
 * @param wallet The wallet to use
 * @param connection The Solana connection
 * @param program The program to use
 * @param tokenList The token list
 * @param lamports The lamports to use
 * @returns A transaction to send to the Solana blockchain
 */
export declare function buildRebalanceTransaction(basket: Basket, from: number, to: number, tokenAmount: number, jupData: JupiterSwapData, lookups: AddressLookupTableAccount[], walletPublicKey: PublicKey, connection: Connection, program: Program<BasketsIDL>, tokenList: TokenSettings[], lamports: number): Promise<TransactionToSend>;
/**
 * Processes instructions by converting pubkeys to PublicKey objects.
 * @param instructions Instructions to process
 * @returns Processed instructions
 */
export declare function processInstructions(instructions: any[]): TransactionInstruction[];
/**
 * Processes a single instruction by converting pubkeys to PublicKey objects.
 * @param instruction Instruction to process
 * @returns Processed instruction
 */
export declare function processInstruction(instruction: any): TransactionInstruction;
/**
 * Signs and sends transactions to the Solana blockchain.
 * @param txsToSend Transactions to send
 * @param connection The Solana connection
 * @param wallet The wallet to use
 * @returns An array of transaction signatures
 */
export declare function signAndSendTransactions(txsToSend: TransactionToSend[], connection: Connection, wallet: any, confirmFirst: number): Promise<TransactionSignature[]>;
/**
 * Calculates the flash rebalance amounts for a basket of tokens.
 * This function determines which tokens need to be rebalanced based on their current weights,
 * target weights, and the basket's rebalance threshold.
 *
 * @param numTokens - The number of tokens in the basket
 * @param timestamp - The current timestamp
 * @param lastRebalanceTime - Array of timestamps for the last rebalance of each token
 * @param rebalanceInterval - The interval between rebalances
 * @param currentCompToken - Array of current token compositions
 * @param currentCompAmount - Array of current token amounts
 * @param targetWeights - Array of target weights for each token
 * @param weightSum - The sum of all target weights
 * @param tokenList - List of token settings
 * @param rebalanceThreshold - The threshold for rebalancing
 * @param oraclePriceData - Array of current oracle prices for each token
 *
 * @returns An object containing arrays of over-weighted and under-weighted tokens
 */
export declare function calculateFlashRebalanceAmounts(numTokens: number, timestamp: number, lastRebalanceTime: number[], rebalanceInterval: number, currentCompToken: number[], currentCompAmount: number[], targetWeights: number[], weightSum: number, tokenList: TokenSettings[], rebalanceThreshold: number, oraclePriceData: number[]): {
    over: TokenRebalanceInfo[];
    under: TokenRebalanceInfo[];
};
/**
 * Retrieves flash rebalance information for a given basket.
 *
 * @param basket - The basket to analyze
 * @param tokenList - List of token settings
 * @param oraclePriceData - Array of current oracle prices for each token
 * @param timestamp - The current timestamp
 *
 * @returns An object containing arrays of over-weighted and under-weighted tokens
 */
export declare function getFlashRebalanceInfo(basket: Basket, tokenList: TokenSettings[], oraclePriceData: number[], timestamp: number): {
    over: TokenRebalanceInfo[];
    under: TokenRebalanceInfo[];
};
export {};
