import { Provider, Signer } from 'ethers'; import { MulticallProvider } from 'ethers-multicall-provider'; import * as _entities from './entities'; import { AnalyticsAPI, ContractAPI, OptionAPI, OrdersAPI, PoolAPI, PricingAPI, TokenAPI, TokenPairAPI, TransactionAPI, UserAPI, VaultAPI, VxPremiaAPI, ReferralAPI, OptionPSAPI, OptionRewardAPI, MiningAPI, GasAPI } from './api'; import { Coingecko, OrderbookV1 } from './services'; import { PremiaVoidnode, VoidnodeAuthentication } from './services/voidnode'; export interface SetProviderParams { /** * An ethers.js provider instance or a string representing a JSON-RPC URL. * This provider is used for interacting with the main exchange contracts. * If not provided, a default connection string will be used. * * @defaultValue {@link Premia.provider} */ provider?: Provider | string; /** * An ethers.js provider instance or a string representing a JSON-RPC URL. * This provider is used for interacting with the orderbook contract. * If not provided, a default connection string will be used. * * @defaultValue {@link Premia.orderbookProvider} */ orderbookProvider?: Provider | string; } export interface SetSignerParams { /** * A string representing a wallet's private key for use with the `provider`, * to instantiate the `signer`. Ignored if `signer` is provided. */ privateKey?: string; /** * A string representing a wallet's secret phrase for use with the `provider`, * to instantiate the `signer`. Ignored if `privateKey` or `signer` is provided. */ phrase?: string; /** * An ethers.js signer instance for transacting with the main exchange contracts. If no `signer`, * `privateKey`, or `phrase` is provided, the `provider`'s default signer will be used. * * @defaultValue {@link Premia.provider.getSigner} */ signer?: Signer; /** * A string representing a wallet's private key for use with the `orderbookProvider`, * to instantiate the `orderbookSigner`. Ignored if `orderbookSigner` is provided. */ orderbookPrivateKey?: string; /** * A string representing a wallet's secret phrase for use with the `orderbookProvider`, * to instantiate the `orderbookSigner`. Ignored if `orderbookPrivateKey` or `orderbookSigner` is provided. */ orderbookPhrase?: string; /** * An ethers.js signer instance for transacting with the orderbook contract. If no `orderbookSigner`, * `orderbookPrivateKey`, or `orderbookPhrase` is provided, the `orderbookProvider`'s default signer will be used. * * @defaultValue {@link Premia.orderbookProvider.getSigner} */ orderbookSigner?: Signer; } export interface VoidnodeParams { /** * The voidnode URL to use for fetching indexed contract data. * * @defaultValue {@link Premia.voidnode.uri} * @see https://docs.premia.finance/api/voidnode */ voidnodeUri?: string; /** * The authentication headers to connect to voidnode with. * * @see https://docs.premia.finance/api/voidnode */ voidnodeAuthentication?: { apiId?: string; apiKey: string; }; } export interface PremiaConfig extends SetProviderParams, SetSignerParams, VoidnodeParams { /** * The chain ID to use for interacting with main exchange contracts. * * @defaultValue {@link Premia.useTestnet} */ useTestnet?: boolean; /** * The chain ID to use for interacting with main exchange contracts. * * @defaultValue {@link Premia.chainId} */ chainId?: number; /** * The chain ID to use for interacting with the auxiliary orderbook contract. * * @defaultValue {@link Premia.chainId} */ orderbookChainId?: number; /** * The API key to use for fetching data from the Premia API. * * @defaultValue {@link Premia.apiKey} * @see https://docs.premia.finance/api/authentication */ apiKey?: string; /** * The base URL to use for fetching data from the Premia API. * * @defaultValue {@link Premia.apiBaseUri} * @see https://docs.premia.finance/api */ apiBaseUri?: string; /** * The base websocket URL to use for streaming data from the Premia API. * * @defaultValue {@link Premia.apiWsUri} * @see https://docs.premia.finance/api */ apiWsUri?: string; /** * The base URL to use for fetching data from the Coingecko API. * * @defaultValue {@link Premia.coingeckoBaseUri} * @see https://www.coingecko.com/api/documentations/v3 */ coingeckoBaseUri?: string; /** * The API Key to use for fetching data from the Coingecko Pro API. * * @see https://www.coingecko.com/api/documentations/v3 */ coingeckoProApiKey?: string; /** * A flag to disable usage of the voidnode, and instead use smart contract data where available. */ skipVoidnode?: boolean; /** * The address of the OrderbookStreamer contract (on Arbitrum Nova). * * @defaultValue {@link Premia.orderbookAddress} * @see https://docs.premia.finance/contracts/orderbook */ orderbookAddress?: string; /** * The address of the VaultRegistry contract (on Arbitrum). * * @defaultValue {@link Premia.vaultRegistryAddress} * @see https://docs.premia.finance/contracts/vaults */ vaultRegistryAddress?: string; /** * The address of the PoolFactory contract (on Arbitrum). * * @defaultValue {@link Premia.poolFactoryAddress} * @see https://docs.premia.finance/contracts/pools */ poolFactoryAddress?: string; /** * The address of the PremiaDiamond contract (on Arbitrum). * @defaultValue {@link Premia.poolDiamondAddress} * @see https://docs.premia.finance/contracts/pools */ poolDiamondAddress?: string; /** * The address of the UserSettings contract (on Arbitrum). * * @defaultValue {@link Premia.userSettingsAddress} * @see https://docs.premia.finance/contracts/pools */ userSettingsAddress?: string; /** * The address of the VxPremia contract (on Arbitrum). * * @defaultValue {@link Premia.vxPremiaAddress} */ vxPremiaAddress?: string; /** * The address of the VaultMining contract (on Arbitrum). * * @defaultValue {@link Premia.vaultMiningAddress} */ vaultMiningAddress?: string; } export interface PremiaConfigWithDefaults extends Required> { voidnodeAuthentication?: VoidnodeAuthentication; } /** * The SDK class is the main entry point for interacting with the Premia V3 protocol. * It provides access to all the protocol's functionality, including, but not limited to: * - Querying on-chain and indexed data using various APIs and services * - Interacting with the main exchange contracts, including trading options * and minting/burning LP tokens. * - Interacting with the orderbook contract and indexing API, including placing/cancelling orders. * - Interacting with various DeFi APIs, including fetching market data and user balances. * - Utilizing token lists and pair lists for interacting with the protocol. * * @public @alpha */ export declare class Premia { /** * The ethers.js provider instance used for interacting with the main exchange contracts. * * @defaultValue {@link JsonRpcProvider} * @see https://docs.ethers.org/v6/api/providers/#Provider */ provider: Provider; /** * The ethers.js multicall provider instance used for batched contract calls. * * @see https://github.com/Rubilmax/ethers-multicall-provider */ multicallProvider: MulticallProvider; /** * The `SetProviderParams` field used to instantiate the SDK. */ providerCredentials: { rpcUrl?: string; provider?: Provider; }; /** * The ethers.js provider instance used for interacting with the orderbook contract. * * @defaultValue {@link JsonRpcProvider} * @see https://docs.ethers.org/v6/api/providers/#Provider */ orderbookProvider?: Provider; /** * The `SetProviderParams` field used to instantiate the SDK. */ orderbookProviderCredentials?: { rpcUrl?: string; provider?: Provider; }; /** * The ethers.js signer instance used for transacting with the main exchange contracts. * * @defaultValue {@link Wallet} * @see https://docs.ethers.org/v6/api/providers/#Signer */ signer?: Signer; /** * The `SetSignerParams` field used to instantiate the SDK. */ signerCredentials?: { phrase?: string; privateKey?: string; }; /** * The address of the signer, if a signer is set. */ signerAddress?: string; /** * The ethers.js signer instance used for transacting with the orderbook contract. * * @defaultValue {@link Wallet} * @see https://docs.ethers.org/v6/api/providers/#Signer */ orderbookSigner?: Signer; /** * The `SetSignerParams` field used to instantiate the SDK. */ orderbookSignerCredentials?: { phrase?: string; privateKey?: string; }; /** * The address of the orderbook signer, if an orderbook signer is set. */ orderbookSignerAddress?: string; /** * @inheritdoc {@link PremiaConfig.useTestnet} */ useTestnet: boolean; /** * @inheritdoc {@link PremiaConfig.chainId} */ chainId: number; /** * @inheritdoc {@link PremiaConfig.skipVoidnode} */ skipVoidnode: boolean; /** * The Premia voidnode object which handles all interactions with voidnode server. */ voidnode: PremiaVoidnode; /** * The service used to interact with the Coingecko v3 API. * * @see https://www.coingecko.com/api/documentations/v3 */ coingecko: Coingecko; /** * The service used to interact with the Premia Orderbook API. * * @defaultValue {@link OrderbookV1} * @see https://docs.premia.finance/api/orderbook */ orderbook: OrderbookV1; /** * The API used to interact with the Analytics data on Premia V3. * * @defaultValue {@link AnalyticsAPI} */ analytics: AnalyticsAPI; /** * The API used to interact with the Contracts on Premia V3. * * @defaultValue {@link ContractAPI} */ contracts: ContractAPI; /** * The API used to interact with Options on Premia V3. * * @defaultValue {@link OptionAPI} */ options: OptionAPI; /** * The API used to interact with Token Pairs on Premia V3. * * @defaultValue {@link TokenPairAPI} */ pairs: TokenPairAPI; /** * The API used to interact with Pools on Premia V3. * * @defaultValue {@link PoolAPI} */ pools: PoolAPI; /** * The API used to determine best pricing between quotes on Premia V3. * * @defaultValue {@link PricingAPI} */ pricing: PricingAPI; /** * The API used to interact with the RFQ Messaging Network for Premia V3. * * @defaultValue {@link OrdersAPI} */ orders: OrdersAPI; /** * The API used to interact with the Tokens on Premia V3. * * @defaultValue {@link TokenAPI} */ tokens: TokenAPI; /** * The API used to interact with the Transactions on Premia V3. * * @defaultValue {@link TransactionAPI} */ transactions: TransactionAPI; /** * The API used to interact with the Users on Premia V3. * * @defaultValue {@link UserAPI} */ users: UserAPI; /** * The API used to interact with the Vaults on Premia V3. * * @defaultValue {@link VaultAPI} */ vaults: VaultAPI; /** * The API used to interact with VxPremia for Premia V3. * * @defaultValue {@link VxPremiaAPI} */ vxPremia: VxPremiaAPI; /** * The API used to interact with referrals for Premia V3. * * @defaultValue {@link ReferralAPI} */ referral: ReferralAPI; /** * The API used to interact with liquidity mining for Premia V3. * * @defaultValue {@link MiningAPI} */ mining: MiningAPI; /** * The API used to interact with gas for Premia V3. * * @defaultValue {@link GasAPI} */ gas: GasAPI; /** * The API used to interact with optionPS for Premia V3. * * @defaultValue {@link OptionPSAPI} */ optionPS: OptionPSAPI; /** * The API used to interact with option reward for Premia V3. * * @defaultValue {@link OptionRewardAPI} */ optionReward: OptionRewardAPI; /** * The static types used to interact with the Premia V3 protocol. * * @defaultValue {@link _entities} */ static entities: typeof _entities; /** * Creates a new Premia V3 SDK instance. * * @remarks * The SDK needs to be initialized before it can be used with * non-default parameters. */ private constructor(); /** * Builds the SDK with the provided parameters. * * @remarks * Default parameters will be used for any values not passed. * * @returns A promise that resolves when the SDK has been initialized. * @param config */ static initialize(config?: PremiaConfig): Promise; /** * Builds the SDK with the provided parameters, synchronously. * * @remarks * Async signers are not supported, use async `initialize` if necessary. * Default parameters will be used for any values not passed. * * @returns The synchronously initialized SDK. * @param config */ static initializeSync(config?: PremiaConfig): Premia; private static getDefaultConfig; /** * @param uri - A uri to connect to the Voidnode indexed data service. */ set voidnodeUri(uri: string); /** * @param authentication - Authentication headers to connect to Voidnode with */ set voidnodeAuthentication(authentication: VoidnodeAuthentication | undefined); get apiKey(): string; /** * @param [apiKey] - {@link PremiaConfig.apiKey} */ set apiKey(apiKey: string); get apiBaseUri(): string; /** * @param [uri] - {@link PremiaConfig.apiBaseUri} */ set apiBaseUri(uri: string); get apiWsUri(): string; /** * @param [wsUri] - {@link PremiaConfig.apiWsUri} */ set apiWsUri(wsUri: string); get coingeckoBaseUri(): string; /** * @param [uri] - {@link PremiaConfig.coingeckoBaseUri} */ set coingeckoBaseUri(uri: string); get coingeckoProApiKey(): PremiaConfig['coingeckoProApiKey']; /** * @param [apiKey] - {@link PremiaConfig.coingeckoProApiKey} */ set coingeckoProApiKey(apiKey: PremiaConfig['coingeckoProApiKey']); /** * @param [skipVoidnode] - {@link PremiaConfig.skipVoidnode} */ setSkipVoidnode(skipVoidnode: PremiaConfig['skipVoidnode']): void; /** * @param [params] - {@link SetProviderParams} */ setProvider(params: SetProviderParams): void; /** * @param [params] - {@link SetSignerParams} */ setSigner(params: SetSignerParams): Promise; /** * @remarks * This method is synchronous and will not initialize via `this.provider.getSigner()`. * If this behavior is required, use `async setSigner()`. * * @param [params] - {@link SetSignerParams} */ setSignerSync(params: SetSignerParams): void; /** * @param factoryAddress - {@link PremiaConfig.poolFactoryAddress} */ setPoolFactoryAddress(factoryAddress: string): void; /** * @param diamondAddress - {@link PremiaConfig.poolDiamondAddress} */ setPoolDiamondAddress(diamondAddress: string): void; /** * @param registryAddress - {@link PremiaConfig.vaultRegistryAddress} */ setVaultRegistryAddress(registryAddress: string): void; /** * @param settingsAddress - {@link PremiaConfig.vaultRegistryAddress} */ setUserSettingsAddress(settingsAddress: string): void; /** * @param vxPremiaAddress - {@link PremiaConfig.vxPremiaAddress} */ setVxPremiaAddress(vxPremiaAddress: string): void; /** * Cancel all open quote streams. */ cancelAllStreams(): Promise; /** * Cancel all contract event listeners. */ cancelAllEventStreams(): Promise; /** * Return the serialialized SDK constructor params used to instantiate the SDK. * * @returns {@link PremiaConfig} */ toParams(): PremiaConfig; } export default Premia;