import BigNumber from "bignumber.js"; import { Log } from "web3-core"; import { Address, ChainId } from "../constants"; import { Wallet } from "../wallet"; /** * * Fetches current token prices for a chain. Prices can be up to 5 minutes stale currently, * and will be denominated in the supplied base currency. * * @param apiKey API Key used for authentication * @param chainId ChainId to get prices from. If no ID is provided, will provide prices for all chains * @param currency Base currency. If none is provided, price quotes will be in USD * @returns A mapping from token address to current price */ export declare const fetchPrices: (apiKey: string, chainId?: ChainId, currency?: string) => Promise<{}>; /** * * Uses multicall to fetch token balances for a given wallet and list of token addresses. * * @param chainId ChainId to fetch balances from * @param wallet Address of wallet to find balances for * @param tokens Array of token addresses to fetch balances for * @returns A map of token address to balance, in TokenAmount. If a wallet has 0 balance for a token, the entry will be undefined. */ export declare function getBalances(chainId: ChainId, wallet: string, tokens: Address[]): Promise<{ [x: string]: BigNumber; }>; /** * * Listen for an react to any transfer involving a given wallet. * When no longer interested in listending, call the returned callback to terminate the listeners. * * @param wallet Wallet to watch transfers for * @param chain Chain to watch transfers on * @param tokens Tokens to explicitly watch for transfers * @param callback Callback to execute when a transfer is detected * @returns A method to unsubcribe from all event listeners requried to watch transfers * * @exmample * ```ts * const wallet = getMyWallet() * const tokens = getMyTokensToWatchOver * * const onTransfer = (token: Address, _, pureEvent) => console.log(`Transfer detected for token ${token} in transaction ${pureEvent.transactionHash}`) * * const terminate = subscribeToTokenTransfers(wallet, wallet.homeChain, tokens, onTransfer) * * \* // Do something * * terminate() \* // Close subscriptions * ``` * * @exmample * ```ts * const MyComponent() { * const wallet = useWallet; * const tokens = useTokens(); * * const onTransfer = useCallback((token) => console.log(token)) * * useEffect(() => { * const terminate = subscribeToTokenTransfers(wallet, wallet.homeChain, tokens, onTransfer) * * \* // Close event listeners on lifecycle end * return terminate * }, []) * } * ``` */ export declare function subscribeToTokenTransfers(wallet: string | Wallet, chain: ChainId, tokens: Address[], callback: (token: Address, newBalance: BigNumber, e?: Log) => void): () => void;