import { Account, Address, Base64EncodedDataResponse, GetMultipleAccountsApi, Rpc } from '@solana/kit'; import Decimal from 'decimal.js'; import { Scope } from '@kamino-finance/scope-sdk'; import { OraclePrices } from '@kamino-finance/scope-sdk/dist/@codegen/scope/accounts/OraclePrices'; import { ReserveWithAddress } from '../classes'; import { Reserve } from '../lib'; import { Configuration } from '@kamino-finance/scope-sdk/dist/@codegen/scope/accounts/Configuration'; export declare const MAX_CONFIDENCE_PERCENTAGE: Decimal; export declare const CONFIDENCE_FACTOR: Decimal; export type TokenOracleData = { mintAddress: Address; decimals: Decimal; price: Decimal; timestamp: bigint; valid: boolean; }; export type CandidatePrice = { price: Decimal; timestamp: bigint; valid: boolean; }; /** * A single price source's readings: the spot price, and - when the source has one configured - its twap. */ export type CandidateFeed = { spot: CandidatePrice; twap?: CandidatePrice; }; export type ScopePriceRefreshConfig = { scope: Scope; scopeConfigurations: [Address, Configuration][]; }; export declare function hasOracleConfigured(reserve: Reserve): boolean; export declare function getUnconfiguredOracleReserveMessage(reserveAddress: Address, reserve: Reserve): string; export declare function getTokenOracleDataSync(allOracleAccounts: AllOracleAccounts, reserves: ReserveWithAddress[]): Array<[ReserveWithAddress, TokenOracleData | undefined]>; export declare function getTokenOracleData(rpc: Rpc, reserves: ReserveWithAddress[], oracleAccounts?: AllOracleAccounts): Promise>; export type AllOracleAccounts = Map>; export declare function getAllOracleAccounts(rpc: Rpc, reserves: Reserve[]): Promise; export type PythPrices = { spot?: CandidatePrice; twap?: CandidatePrice; }; /** * Get pyth price from cache or fetch if not available * @param oracle oracle address * @param cache pyth cache * @param oracleAccounts all oracle accounts */ export declare function cacheOrGetPythPrices(oracle: Address, cache: Map, oracleAccounts: AllOracleAccounts): PythPrices | null; /** * Get switchboard price from cache or fetch if not available * @param oracle oracle address * @param switchboardCache cache for oracle prices * @param oracleAccounts all oracle accounts */ export declare function cacheOrGetSwitchboardPrice(oracle: Address, switchboardCache: Map, oracleAccounts: AllOracleAccounts): CandidatePrice | null; /** * Interpret a raw Switchboard aggregator value as a price candidate. * * Like the program, a negative reading is rejected outright (the feed contributes nothing), while a zero reading is * kept as a parsed candidate - the zeroed-feed exclusion belongs to {@link selectBestOracleCandidate}. */ export declare function switchboardValueToCandidate(value: Decimal, timestamp: bigint, valid: boolean): CandidatePrice | null; /** * Get scope price from cache or fetch if not available * @param oracle oracle address * @param scopeCache cache for oracle prices * @param allOracleAccounts all oracle accounts * @param chain scope chain */ export declare function cacheOrGetScopePrice(oracle: Address, scopeCache: Map, allOracleAccounts: AllOracleAccounts, chain: number[]): CandidatePrice | null; /** * Select the price to use among the given sources' readings. * * This mirrors the program's `get_most_recent_price_and_twap()` (klend >= 1.25.0): a zeroed feed - a zero spot price, * or a zero reading on a *present* twap when the twap check is enabled - takes no part in the selection, so that it * cannot win over a healthy alternate source (while a twap missing altogether does not exclude its feed). Among the * remaining candidates, the freshest valid one wins. `undefined` means no healthy feed exists - on such a refresh * miss the program keeps the reserve's cached price, and so does the caller here (see `getTokenOracleDataSync()`). */ export declare function selectBestOracleCandidate(feeds: CandidateFeed[], twapEnabled: boolean): CandidatePrice | undefined; //# sourceMappingURL=oracle.d.ts.map