import { BigNumber, CallOverrides } from 'ethers'; import { BlockInfo, TokenInfo } from '@derivation-tech/context'; import { Side } from '../enum'; import { FetchPortfolioParam, FetchInstrumentParam, FundFlow, InstrumentIdentifier, Pending, Quotation, Portfolio, Instrument, Position, RawAmm, LiquidityDetails, } from '../types'; export interface ObserverInterface { /** * Get account infos from instrument * @param params {@link FetchPortfolioParam} * @param overrides {@link CallOverrides} */ getPortfolio(params: FetchPortfolioParam, overrides?: CallOverrides): Promise; getPortfolio(params: FetchPortfolioParam[], overrides?: CallOverrides): Promise; getPortfolio( params: FetchPortfolioParam | FetchPortfolioParam[], overrides?: CallOverrides, ): Promise; /** * Get instrument by given params * @param params {@link FetchInstrumentParam} * @param overrides {@link CallOverrides} */ getInstrument(params: FetchInstrumentParam | string, overrides?: CallOverrides): Promise; getInstrument(params: (FetchInstrumentParam | string)[], overrides?: CallOverrides): Promise; getInstrument( params: FetchInstrumentParam | string | (FetchInstrumentParam | string)[], overrides?: CallOverrides, ): Promise; /** * Get all instruments * @param overrides {@link CallOverrides} */ getAllInstruments(overrides?: CallOverrides): Promise; /** * Get quote token info by quote symbol and instrument * @param quoteSymbol the quote symbol * @param instrumentAddr the instrument * @param overrides {@link CallOverrides} */ getQuoteTokenInfo(quoteSymbol: string, instrumentAddr: string, overrides?: CallOverrides): Promise; /** * Inspect dex v2 market benchmark price * @param instrumentIdentifier the instrument * @param expiry the expiry * @param overrides {@link CallOverrides} */ inspectDexV2MarketBenchmarkPrice( instrumentIdentifier: InstrumentIdentifier, expiry: number, overrides?: CallOverrides, ): Promise; /** * Inspect cex market benchmark price * @param instrumentIdentifier the instrument * @param expiry the expiry * @param overrides {@link CallOverrides} */ inspectCexMarketBenchmarkPrice( instrumentIdentifier: InstrumentIdentifier, expiry: number, overrides?: CallOverrides, ): Promise; /** * Get raw spot price by instrument marketType * @param identifier the instrument identifier * @param overrides {@link CallOverrides} */ getRawSpotPrice(identifier: InstrumentIdentifier, overrides?: CallOverrides): Promise; /** * Get next initialized tick outside * @param instrumentAddr the instrument address * @param expiry the expiry * @param tick the tick * @param right whether search to the right * @param overrides {@link CallOverrides} */ getNextInitializedTickOutside( instrumentAddr: string, expiry: number, tick: number, right: boolean, overrides?: CallOverrides, ): Promise; /** * Get trade size needed to move AMM price to target tick * @param instrumentAddr the instrument address * @param expiry the expiry * @param targetTick the target tick * @param overrides {@link CallOverrides} */ getSizeToTargetTick( instrumentAddr: string, expiry: number, targetTick: number, overrides?: CallOverrides, ): Promise; /** * Get fund flows * @param quoteAddrs the quote addresses * @param trader the trader address * @param overrides {@link CallOverrides} */ getFundFlows( quoteAddrs: string[], trader: string, overrides?: CallOverrides, ): Promise<{ fundFlows: FundFlow[]; blockInfo: BlockInfo }>; /** * Get user pendings * @param quoteAddrs the quote addresses * @param trader the trader address * @param overrides {@link CallOverrides} */ getUserPendings( quoteAddrs: string[], trader: string, overrides?: CallOverrides, ): Promise<{ pendings: { maxWithdrawable: BigNumber; pending: Pending }[]; blockInfo: BlockInfo }>; /** * Inquire by base * @param instrumentAddr the instrument address * @param expiry the expiry * @param side the side * @param baseAmount the base amount * @param overrides {@link CallOverrides} */ inquireByBase( instrumentAddr: string, expiry: number, side: Side, baseAmount: BigNumber, overrides?: CallOverrides, ): Promise<{ quoteAmount: BigNumber; quotation: Quotation }>; /** * Inquire by quote * @param instrumentAddr the instrument address * @param expiry the expiry * @param side the side * @param quoteAmount the quote amount * @param overrides {@link CallOverrides} */ inquireByQuote( instrumentAddr: string, expiry: number, side: Side, quoteAmount: BigNumber, overrides?: CallOverrides, ): Promise<{ baseAmount: BigNumber; quotation: Quotation }>; /** * Get position if settle * @param portfolio the trader account * @param amm the amm of instrument */ getPositionIfSettle(portfolio: Portfolio, amm: RawAmm, overrides?: CallOverrides): Promise; /** * Get address balance in gate * @param target target address * @param quoteAddrs the quote addresses * @param overrides {@link CallOverrides} */ getGateBalance(target: string, quoteAddrs: string[], overrides?: CallOverrides): Promise; /** * Get address balances in gate * @param target target address * @param overrides {@link CallOverrides} */ getGateBalances(target: string, overrides?: CallOverrides): Promise<(TokenInfo & { balance: BigNumber })[]>; /** * Get liquidity detail information * @param instrumentAddr the instrument address * @param expiry the expiry * @param tickDelta tick delta */ getLiquidityDetails( instrumentAddr: string, expiry: number, tickDelta: number, overrides?: CallOverrides, ): Promise; }