import { Address, GetAccountInfoApi, GetMinimumBalanceForRentExemptionApi, GetMultipleAccountsApi, GetProgramAccountsApi, AccountMeta, Instruction, Rpc, TransactionSigner } from '@solana/kit'; import Decimal from 'decimal.js'; import { type Configuration, type OracleMappings, type OraclePrices, type TokenMetadatas } from './@codegen/scope/accounts'; import { EmaType, OracleType } from './@codegen/scope/types'; export { SCOPE_PROGRAM_ADDRESS } from './@codegen/scope/programs'; export { EmaType } from './@codegen/scope/types'; import { ScopeConfig } from './constants'; import { FeedParam, PricesParam } from './model'; export type ScopeDatedPrice = { price: Decimal; timestamp: Decimal; }; /** * Token metadata fields to update on a feed entry; only the provided fields are written. */ export type FeedMetadataUpdate = { index: number; name?: string; maxPriceAgeSlots?: number | bigint; groupIdsBitset?: number | bigint; }; export type ProviderKind = 'Pyth' | 'Switchboard' | 'Chainlink' | 'Redstone' | 'Scope'; /** * Build the TWAP-enabled bitmask expected by the scope program from a list of EMA types * (each EMA type is a bit index of the bitmask). */ export declare function twapEnabledBitmask(...emaTypes: EmaType[]): number; /** * Bit of a raw `OracleMappings.priceTypes` byte marking the entry as frozen * (see `FROZEN_FLAG` in the scope program). */ export declare const FROZEN_FLAG = 128; /** * Get the `OracleType` of a raw `OracleMappings.priceTypes` byte, stripping the frozen flag. */ export declare function stripFrozenFlag(rawPriceType: number): OracleType; /** * Whether a raw `OracleMappings.priceTypes` byte has the frozen flag set. */ export declare function isPriceFrozen(rawPriceType: number): boolean; /** * Oracle types whose price is a TWAP of another scope entry. * These are configured with `MappingTwapEntry` instead of `MappingConfig` and use no price account. */ export declare const TWAP_ORACLE_TYPES: ReadonlySet; /** * Oracle types that cannot be refreshed with the `refreshPriceList` instruction: * the Chainlink & PythLazer types are refreshed by their dedicated instructions carrying a signed off-chain report. */ export declare const NON_REFRESHABLE_ORACLE_TYPES: ReadonlySet; export declare class ScopeEntryMetadata { mappings: OracleMappings; metadatas: TokenMetadatas; priceId: number; constructor(mappings: OracleMappings, metadatas: TokenMetadatas, priceId: number); private get priceTypeId(); get isFrozen(): boolean; private get refPriceId(); /** * Get the oracle type string (e.g., "PythPull", "CappedFloored", "ChainlinkX") */ get oracleType(): string; private get generic(); private get metadata(); /** * Get a simple base name without nested oracle details. * Use this for display in UI components that show nested details separately via tooltips. */ get simpleName(): string; /** * Get the full verbose name including nested oracle details for composite types. * This is the default name getter for backward compatibility. */ get name(): string; get provider(): ProviderKind; /** * Get nested oracle references for composite oracle types (CappedFloored, MostRecentOf, CappedMostRecentOf) * Returns null for non-composite oracle types */ get nestedOracles(): { type: 'CappedFloored' | 'MostRecentOf' | 'CappedMostRecentOf'; source?: { name: string; oracleType: string; provider: ProviderKind; }; sources?: Array<{ name: string; oracleType: string; provider: ProviderKind; }>; cap?: { name: string; oracleType: string; provider: ProviderKind; }; floor?: { name: string; oracleType: string; provider: ProviderKind; }; } | null; } export type ScopeRpcApi = GetAccountInfoApi & GetMultipleAccountsApi & GetProgramAccountsApi & GetMinimumBalanceForRentExemptionApi; export declare class Scope { private readonly _rpc; private readonly _config; /** * Create a new instance of the Scope SDK class. * @param cluster Name of the Solana cluster * @param rpc Connection to the Solana rpc */ constructor(cluster: 'localnet' | 'devnet' | 'mainnet-beta', rpc: Rpc); get config(): ScopeConfig; private static priceToDecimal; /** * Get the deserialised OraclePrices account for a single feed * @param feed - either the feed PDA seed, configuration account address or OraclePrices account pubkey * @returns OraclePrices */ getSingleOraclePrices(feed: PricesParam): Promise; /** * Get the deserialised OraclePrices accounts for the given `OraclePrices` account pubkeys * Optimised to filter duplicate keys from the network request but returns the same size response as requested in the same order * @throws Error if any of the accounts cannot be fetched * @param prices - public keys of the `OraclePrices` accounts * @returns [Address, OraclePrices][] */ getOraclePrices(prices: Address[]): Promise<[Address, OraclePrices][]>; /** * Get the deserialised OraclePrices accounts for the given `OraclePrices` account pubkeys * Optimised to filter duplicate keys from the network request but returns the same size response as requested in the same order * @throws Error if any of the accounts cannot be fetched * @param prices - public keys of the `OraclePrices` accounts * @returns [Address, OraclePrices][] */ getMultipleOraclePrices(prices: Address[]): Promise<[Address, OraclePrices][]>; getAllOraclePrices(): Promise<[Address, OraclePrices][]>; /** * Get the deserialised Configuration account for a given feed * @param feedParam - either the feed PDA seed or the configuration account address * @returns [configuration account address, deserialised configuration] */ getSingleFeedConfiguration(pricesParam: PricesParam): Promise<[Address, Configuration]>; /** * Get the deserialised Configuration accounts for given feeds * @param feedParams - either the feed PDA seed or the configuration account address * @returns [configuration account address, deserialised configuration] */ getFeedConfiguration(pricesParams: PricesParam[]): Promise<[Address, Configuration][]>; getAllConfigurations(): Promise<[Address, Configuration][]>; /** * Get the deserialised OracleMappings account for a given feed * @param feed - either the feed PDA seed or the configuration account address * @returns OracleMappings */ getOracleMappings(feed: FeedParam): Promise; /** * Get the deserialized OracleMappings account for a given feed and config * @param feed - either the feed PDA seed or the configuration account address * @param config - the configuration account address * @param configAccount - the deserialized configuration account * @returns OracleMappings */ getOracleMappingsFromConfig(feed: FeedParam, config: Address, configAccount: Configuration): Promise; /** * Get the price of a token from a chain of token prices * @param chain * @param prices */ static getPriceFromScopeChain(chain: Array, prices: OraclePrices): ScopeDatedPrice; /** * Verify if the scope chain is valid * @param chain */ static isScopeChainValid(chain: Array): boolean; /** * Get the price of a token from a chain of token prices * @param chain * @param oraclePrices */ getPriceFromChain(chain: Array, oraclePrices: OraclePrices): Promise; static getChainMetadataSync(mappings: OracleMappings, metadatas: TokenMetadatas, chain: number[]): ScopeEntryMetadata[]; /** * Fetch the oracle mapping and metadata information for a chain of token indices * @param feed The feed, configuration or prices account describing the scope feed * @param chain Token indices describing the scope chain */ getChainMetadata(feed: PricesParam, chain: number[]): Promise; /** * Create a new scope price feed * @param admin * @param feed */ initialise(admin: TransactionSigner, feed: string): Promise<[ Instruction[], TransactionSigner[], { configuration: Address; oracleMappings: Address; oraclePrices: Address; oracleTwaps: Address; tokenMetadatas: Address; } ]>; /** * Update the price mapping of a token. * * This is a full-entry setter: every call writes the mapping config, the TWAP-enabled bitmask and the ref price * from the given parameters, so omitted parameters actively reset their fields to the defaults (like the legacy * `updateMapping` instruction did). To update a single field while leaving the others untouched, build the * instruction with `getUpdateMappingAndMetadataInstruction` and only the wanted update entries instead. * @param admin * @param feed * @param index * @param oracleType * @param mapping - price info account of the oracle, or null for oracle types that use no account. * Ignored for TWAP oracle types. * @param twapEnabledBitmask - bitmask of the EMA types enabled for this entry (see {@link twapEnabledBitmask}) * @param twapSource - entry index the TWAP is computed from (only used for TWAP oracle types) * @param refPriceIndex * @param genericData * @param refPriceToleranceBps - max deviation from the ref price in bps; only valid for non-TWAP oracle types */ updateFeedMapping(admin: TransactionSigner, feed: string, index: number, oracleType: OracleType, mapping: Address | null, twapEnabledBitmask?: number, twapSource?: number, refPriceIndex?: number, genericData?: Array, refPriceToleranceBps?: number): Promise; /** * Update the token metadata of feed entries; only the fields provided in each update are written. * @param admin * @param feed * @param updates */ updateFeedMetadata(admin: TransactionSigner, feed: string, updates: FeedMetadataUpdate[]): Promise; refreshPriceListIx(feed: FeedParam, tokens: number[]): Promise; refreshPriceListIxWithAccounts(tokens: number[], configAccount: Configuration, mappings: OracleMappings): Promise; static getRefreshAccounts(connection: Rpc, kaminoProgramId: Address, klendProgramId: Address, mappings: OracleMappings, token: number): Promise; static getKTokenRefreshAccounts(connection: Rpc, _kaminoProgramId: Address, mappings: OracleMappings, token: number): Promise; } export default Scope; //# sourceMappingURL=Scope.d.ts.map