/// import { Connection, PublicKey, Signer, Transaction, TransactionInstruction, TransactionSignature } from "@solana/web3.js"; import { BN, Program, Provider } from "@project-serum/anchor"; import { Dsov, OptionChain, OptionVault, PrizePool, SpinRecord, TokenWhitelist, TradingAccount, TransferQueue, TransferRecord, TransferType, VolatilityFeed } from "../types"; import { Account } from "@solana/spl-token"; import { EuroPrimitive } from "@mithraic-labs/tokenized-euros"; import { AssetDetails, AssetDetailsInput, AssetType, DepositEstimate, EstimatedOptionPricing, EstimatedTradeDetails, InitializeState, OptionPricing, ProgramAuthority, SdxClientConfig, SendAndConfirmOptions, State, SwapEstimate, TokenPriceEstimate, TradeType, VaultAndTradingSummary, WithdrawalEstimate } from "./clientTypes"; export * from "./clientTypes"; export * from "./utils/math"; export declare class SdxClient { private _connection; private _sdxProgram; private _wallet; private _eurosProgram; private _provider; private _state; private _assetMap; private _stableAsset; private _associatedTokenAccounts; private _tradingTokenAccounts; private _programAuthority; private _volatilityFeed; private _tokenWhitelist; private _tradingAccount; private _placeholderOptionChain; private _isInitialized; private _idlErrors; private _confirmOptions; private _priorityFeeMicroLamports; private _maxPriorityFeeMicroLamports; private _priorityFeeMultiplier; private _computeBudgetMultiplier; private _useOnChainClock; constructor(config: SdxClientConfig); private readonly boundLoadProgramAuthority; /** * @see [loadProgramAuthorityImpl](../functions/client_methods.loadProgramAuthorityImpl.html) for usage details */ loadProgramAuthority(enableLogging?: boolean): Promise; private readonly boundLoadTradingAccount; /** * @see [loadTradingAccountImpl](../functions/client_methods.loadTradingAccountImpl.html) for usage details */ loadTradingAccount(tradingAccountKey?: PublicKey, fromCache?: boolean, enableLogging?: boolean): Promise; private readonly boundLoadAccountBalances; /** * @see [loadAccountBalancesImpl](../functions/client_methods.loadAccountBalancesImpl.html) for usage details */ loadAccountBalances(fromCache?: boolean): Promise>; private readonly boundLoadOptionVault; /** * @see [loadOptionVaultImpl](../functions/client_methods.loadOptionVaultImpl.html) for usage details */ loadOptionVault(asset: AssetType, fromCache?: boolean, enableLogging?: boolean): Promise; private readonly boundLoadOptionChain; /** * @see [loadOptionChainImpl](../functions/client_methods.loadOptionChainImpl.html) for usage details */ loadOptionChain(asset: AssetType, fromCache?: boolean, enableLogging?: boolean): Promise; private readonly boundLoadTransferRecord; /** * @see [loadTransferRecordImpl](../functions/client_methods.loadTransferRecordImpl.html) for usage details */ loadTransferRecord(transferRecord: PublicKey, fromCache?: boolean, enableLogging?: boolean): Promise; private readonly boundLoadTransferQueue; /** * @see [loadTransferQueueImpl](../functions/client_methods.loadTransferQueueImpl.html) for usage details */ loadTransferQueue(asset: AssetType, transferType: TransferType, fromCache?: boolean, enableLogging?: boolean): Promise; private readonly boundLoadVolatilityFeed; /** * @see [loadVolatilityFeedImpl](../functions/client_methods.loadVolatilityFeedImpl.html) for usage details */ loadVolatilityFeed(fromCache?: boolean, enableLogging?: boolean): Promise; private readonly boundLoadTokenWhitelist; /** * @see [loadTokenWhitelistImpl](../functions/client_methods.loadTokenWhitelistImpl.html) for usage details */ loadTokenWhitelist(fromCache?: boolean, enableLogging?: boolean): Promise; private readonly boundLoadPrizePool; /** * @see [loadPrizePoolImpl](../functions/client_methods.loadPrizePoolImpl.html) for usage details */ loadPrizePool(season?: number, enableLogging?: boolean): Promise; private readonly boundLoadSpinRecord; /** * @see [loadSpinRecordImpl](../functions/client_methods.loadSpinRecordImpl.html) for usage details */ loadSpinRecord(season?: number, enableLogging?: boolean): Promise; private readonly boundSpendTickets; /** * @see [spendTicketsImpl](../functions/client_methods.spendTicketsImpl.html) for usage details */ spendTickets(count: number, season?: number): Promise; private readonly boundDepositToVault; /** * @see [depositToVaultImpl](../functions/client_methods.depositToVaultImpl.html) for usage details */ depositToVault(asset: AssetType, underlyingAmount: BN, stableAmount: BN): Promise; private readonly boundWithdrawFromVault; /** * @see [withdrawFromVaultImpl](../functions/client_methods.withdrawFromVaultImpl.html) for usage details */ withdrawFromVault(asset: AssetType, lpAmount: BN): Promise; private readonly boundCancelVaultTransfer; /** * @see [cancelVaultTransferImpl](../functions/client_methods.cancelVaultTransferImpl.html) for usage details */ cancelVaultTransfer(asset: AssetType, transferType: TransferType): Promise; private readonly boundProcessNextTransferRecord; /** * @see [processNextTransferRecordImpl](../functions/client_methods.processNextTransferRecordImpl.html) for usage details */ processNextTransferRecord(asset: AssetType, transferType: TransferType, minUnderlyingToReceive?: BN, maxUnderlyingToSend?: BN, minStableToReceive?: BN, maxStableToSend?: BN): Promise; private readonly boundSwap; /** * @see [swapImpl](../functions/client_methods.swapImpl.html) for usage details */ swap(asset: AssetType, underlyingToSend: BN, stableToSend: BN, minUnderlyingToReceive?: BN, minStableToReceive?: BN, priorityFeesMicroLamports?: number): Promise; private readonly boundTradingAccountSwap; /** * @see [tradingAccountSwapImpl](../functions/client_methods.tradingAccountSwapImpl.html) for usage details */ tradingAccountSwap(fromAsset: AssetType, toAsset: AssetType, amount: BN, walletKey: string, onTxConfirmed?: (txId: TransactionSignature, completedTxs: number, totalTxs: number) => void, optionalAssetDetails?: AssetDetails): Promise; private readonly boundDepositToTrading; /** * @see [depositToTradingImpl](../functions/client_methods.depositToTradingImpl.html) for usage details */ depositToTrading(asset: AssetType, amount: BN, optionalAssetDetails?: AssetDetails): Promise; private readonly boundWithdrawFromTrading; /** * @see [withdrawFromTradingImpl](../functions/client_methods.withdrawFromTradingImpl.html) for usage details */ withdrawFromTrading(asset: AssetType, amount: BN, optionalAssetDetails?: AssetDetails): Promise; private readonly boundSellOptionBySeriesId; /** * @see [sellOptionBySeriesIdImpl](../functions/client_methods.sellOptionBySeriesIdImpl.html) for usage details */ sellOptionBySeriesId(asset: AssetType, seriesId: number, optionAmount: BN, minAmountToReceive: BN, splitTx?: boolean, onTxConfirmed?: (txId: TransactionSignature, completedTxs: number, totalTxs: number) => void): Promise; private readonly boundBuyOptionBySeriesId; /** */ private readonly boundSettleExpiredPosition; /** * @see [buyOptionBySeriesIdImpl](../functions/client_methods.buyOptionBySeriesIdImpl.html) for usage details */ buyOptionBySeriesId(asset: AssetType, seriesId: number, optionAmount: BN, maxAmountToPay: BN, splitTx?: boolean, onTxConfirmed?: (txId: TransactionSignature, completedTxs: number, totalTxs: number) => void): Promise; /** * @see [settleExpiredPositionImpl](../functions/client_methods.settleExpiredPositionImpl.html) for usage details */ settleExpiredPosition(asset: AssetType, seriesId: number, tradingAccount?: PublicKey): Promise; private readonly boundCloseTradingAccount; private readonly boundSetupTradingAccount; /** * @see [closeTradingAccountImpl](../functions/client_methods.closeTradingAccountImpl.html) for usage details */ closeTradingAccount(): Promise; /** * @see [setupTradingAccountImpl](../functions/client_methods.setupTradingAccountImpl.html) for usage details */ setupTradingAccount(): Promise; setPriorityFeeMicroLamports(microLamports: number): void; getPriorityFees(): Promise; /** * Gets instruction to set the priority fee, if fee is greater than 0. * * @returns {TransactionInstruction} ComputeBudgetProgram instruction. */ getSetPriorityFeeIx(): Promise; getCurrentEpochTime(): Promise; addAsset(assetType: AssetType, assetDetailsInput: AssetDetailsInput): void; getAsset(assetType: AssetType): AssetDetails | undefined; /** * * Gets the associated token account for the given asset mint, for the current wallet. * * @param {PublicKey} assetMint - The asset mint to get the associated token account for. * @returns {PublicKey} The associated token account. */ getAssociatedTokenAccount(assetMint: PublicKey): PublicKey; /** * Gets the trading token account for the given asset mint. * * @param {PublicKey} assetMint - The asset mint to get the trading token account for. * @param {PublicKey} [tradingAccount] - The trading account to use. Defaults to the current wallet's trading account. * @returns {PublicKey} The trading token account. */ getTradingTokenAccount(assetMint: PublicKey, tradingAccount?: PublicKey): PublicKey; /** * * Gets the associated token account balance for the given asset mint, for the current wallet. * Returns 0 if the associated token account is not initialized. * * @param {PublicKey} assetMint - The asset mint to get the associated token account for. * @returns {Promise} Token balance of account in raw decimals */ getAssociatedTokenAccountBalance(assetMint: PublicKey): Promise; /** * For a given array of mints, find the associated token account addresses, check if they are * initialized, and if not, generate instructions to initialize them. * * @param {PublicKey[]} accountsMint - The mint accounts to setup ATAs for. * @returns {Promise<[PublicKey[], TransactionInstruction[]]>} A promise that resolves to an array of ATAs, and initialization instructions. */ setupAtasInstructions(accountsMint: PublicKey[]): Promise<[PublicKey[], TransactionInstruction[]]>; /** * Function to load option chains, option vaults, current prices and user trading account all batched into one RPC call. * * @param {AssetType[]} assetTypes - The mint accounts to setup ATAs for. * @param accountToLoadPerCall - The number of accounts to load per RPC call. Defaults to 100. * @returns {Promise<{ * optionChain: Map; * optionVault: Map; * vaultTradingAccount: Map; * tokenPrices: Map; * tokenBalances: Map; * userTradingAccount: TradingAccount; * }>} * * A promise that resolves to an option chain, option vault, token prices object indexed by asset type, and user trading account. */ loadAllInitialAccounts(assetTypes: AssetType[], accountToLoadPerCall?: number): Promise<{ optionChain: Map; optionVault: Map; vaultTradingAccount: Map; tokenPrices: Map; tokenBalances: Map; userTradingAccount: TradingAccount; }>; /** * Estimates the liquidity pool tokens receivable for a deposit and provides a suggested * deposit amount to minimize slippage. * * @async * @param {number} underlyingAmount - The amount of the underlying asset to deposit (in float). * @param {number} stableAmount - The amount of the stable token to deposit (in float). * @param {AssetType} asset - The type of the underlying asset. * @returns {Promise} A promise that resolves to an object that contains the estimated LP deposit amount. * * @todo Implementation currently does not account for other pending deposits. Assumes user * is the first to deposit. */ estimateLpDepositAmount(underlyingAmount: number, stableAmount: number, asset: AssetType): Promise; /** * Estimates the amounts of underlying and stable assets receivable for a liquidity pool withdrawal. * * @async * @param {number} lpTokenAmount - The amount of the liquidity pool tokens to withdraw (in float). * @param {AssetType} asset - The type of the underlying asset. * @returns {Promise} A promise that resolves to estimated amounts of underlying and stable assets receivable. */ estimateLpWithdrawAmount(lpTokenAmount: number, asset: AssetType): Promise; /** * Asynchronously calculates the price and associated fees for given series of options on a specific asset. * * @async * @param {AssetType} asset - The asset for which the option pricing is to be estimated. * @param {number[]} seriesIds - An array of series IDs for which the option pricing needs to be estimated. * @param {number[]} sizesForUser - Sizes of the position the user is considering, use 1 for buying and -1 for selling. * @param {boolean} [enableLogging=false] - A flag indicating whether to enable logging. Defaults to false. * @returns {Promise} - A promise that resolves to an array of 'PriceAndFees' objects. Each object in the array provides detailed price and fee * estimates for a specific option series identified by the series ID. */ estimateOptionPricing(asset: AssetType, seriesIds: number[], sizesForUser: number[], enableLogging?: boolean): Promise; /** * Estimates the maximum position size a user can obtain for a given asset and series ID. The estimate is * typically conservative and may not be exact. * * @async * @param {AssetType} asset - The asset involved in the trade. * @param {number} seriesId - The ID of the option series involved in the trade. * * @param tradeType * @returns {Promise} The estimated maximum position size the user can obtain. */ /** TODO: * 1) Extract the redundant code between estimateTradeDetails and estimateMaxPositionSize into a separate function. * 2) Optimise account loads * 3) Account for collateral released if an existing position is closed. * 4) Better way to estimate price per contract, instead of linear interpolation. * */ estimateMaxPositionSize(asset: AssetType, seriesId: number, tradeType: TradeType): Promise; /** * Estimates the details of a trade for a given asset, option series ID and size to trade. * If user trading account does not exist, assumes that user has normal fee tier. * * @async * @param {AssetType} asset - The asset involved in the trade. * @param {number} seriesId - The ID of the option series involved in the trade. * @param {number} sizeForUser - The user's position size. * @param {boolean} [fromCache=false] - A flag indicating whether to fetch account data from cache. Defaults to false. * @param {boolean} [enableLogging=false] - A flag indicating whether to enable logging. Defaults to false. * @returns {Promise} - Returns a Promise that resolves to an EstimatedTradeDetails object. */ estimateTradeDetails(asset: AssetType, seriesId: number, sizeForUser: number, fromCache?: boolean, enableLogging?: boolean): Promise; /** * Calculate updated vault account summary and trading account's asset group summary. * * @async * @param {AssetType} asset - Type of the underlying asset. * @returns {Promise} */ calculateUpdatedVaultAndTradingSummary(asset: AssetType): Promise; /** * Calculates the amount of asset receivable for a swap with the OptionVault. * Returns swap price, amount receivable, and new vault delta in floating point representation. * * @async * @param {AssetType} asset - The asset involved in the swap. * @param {number} inputAmount - The amount of asset to be swapped, in float value. * @param {boolean} buyUnderlying - If is buying or selling the underlying asset. * @param {boolean} [enableLogging=false] - A flag indicating whether to enable logging. Defaults to false. * @returns {Promise} */ retrieveSwapEstimate(asset: AssetType, inputAmount: number, buyUnderlying: boolean, enableLogging?: boolean): Promise; /** * For a given array of mints, find the trading token account addresses, check if they are * initialized, and if not, generate instructions to initialize them. * * @param {PublicKey[]} accountsMint - The mint accounts to setup trading token accounts for. * @param {PublicKey} [tradingAccount] - The trading account to use. Defaults to the current wallet's trading account. * @returns {Promise<[PublicKey[], TransactionInstruction[], Account[]]>} */ setupTradingTokenAccInstructions(accountsMint: PublicKey[], tradingAccount?: PublicKey): Promise<[PublicKey[], TransactionInstruction[], Account[]]>; /** * This method is used to fetch the market option pricing for an array of specified assets. * It gets the details of each asset, batch-loads their respective option chains, volatility feeds, * and underlying prices. It then calculates and returns new option pricing for each asset based on these inputs. * * @param {AssetType[]} assets - An array of assets for which to fetch the market option pricing. * @returns {Promise[]>} A promise that resolves to an array of maps, each map corresponding * to an asset in the input array. In each map, the key is a number (typically representing an option ID or similar identifier) * and the value is an object representing the pricing details for that option. * @throws {Error} Throws an error if unable to fetch the market option pricing for any of the assets. */ fetchMultipleAssetMarkOptionPricing(assets: AssetType[]): Promise[]>; /** * This method is used to fetch the market option pricing for a specified asset. * It gets the details of the asset, loads the option chain, volatility feed, and underlying price of the asset. * It then calculates and returns the new option pricing based on these inputs. * * @param {AssetType} asset - The asset for which to fetch the market option pricing. * @returns {Promise>} A promise that resolves to a map where the key is a number * (typically representing an option ID or similar identifier) and the value is an object representing * the pricing details for that option. * @throws {Error} Throws an error if unable to fetch the market option pricing for the asset. */ fetchMarkOptionPricing(asset: AssetType): Promise>; /** * This method is used to fetch the price of a liquidity pool (LP) token. It obtains the details of the underlying * and stable assets, loads the necessary accounts (option chain, option vault, volatility feed, vault trading account), * and fetches the current timestamp and underlying price. It uses these inputs to estimate and return the price of the * LP token. * * @param {number} lpTokenAmount - The amount of LP tokens for which to fetch the price (in float) * @param {AssetType} asset - The underlying asset associated with the LP token. * @returns {Promise} A promise that resolves to an estimate of the LP token price, values in float. * @throws {Error} Throws an error if unable to fetch the LP token price. */ fetchLpTokenPrice(lpTokenAmount: number, asset: AssetType): Promise; /** * Send and confirm a transaction. If _wallet is defined, the transaction will be signed with the wallet, * and sent using the BlockheightBasedTransactionConfirmationStrategy. Otherwise, the transaction will be * signed by the Provider and sent using the LegacyTimeoutStrategy. * * @param {Transaction} tx - The transaction to send. * @param {Signer[]} [signers=[]] * * @return {Promise} Transaction ID. * */ sendAndConfirm(tx: Transaction, signers?: Signer[], options?: SendAndConfirmOptions): Promise; sendAndConfirmBatch(txs: Transaction[], signers?: Signer[], options?: SendAndConfirmOptions, onTxConfirmed?: (txId: TransactionSignature, completedTxs: number, totalTxs: number) => void): Promise; get connection(): Connection; get sdxProgram(): Program; get eurosProgram(): Program; get tradingAccount(): PublicKey; get placeholderOptionChain(): PublicKey; get state(): State; get associatedTokenAccounts(): Map; get tradingTokenAccounts(): Map; get assetMap(): Map; get volatilityFeed(): PublicKey; get tokenWhitelist(): PublicKey; get programAuthority(): PublicKey; get stableAsset(): AssetType; get provider(): Provider; get isInitialized(): InitializeState; } //# sourceMappingURL=SdxClient.d.ts.map