@@ -39,13 +39,16 @@ export function useMetamask(
3939) : UseMatamaskAPI
4040/**
4141 * Fetch token price in USD,JPY & EUR from CoinGecko public api
42- * @param coinGeckoID API ID, like ` bitcoin`
42+ * @param coinGeckoID API ID, like " bitcoin"
4343 * @returns [{ usd, jpy, eur }, triggerReFetchFn]
44+ * @example
45+ * const [btcPrice, reFetchFn] = useTokenPrice("bitcoin")
46+ * console.log(btcPrice.usd) // Math.random() * 45_000
4447 */
4548export function useTokenPrice (
4649 coinGeckoID : string ,
4750 refreshInternvalInSecs ?: number
48- ) : [ FIATCurrencies , /** Triggers a re-fetch to the API */ VoidCallback ]
51+ ) : [ FIATCurrencies , VoidCallback ]
4952export function addEtherNetwork ( props : AddEtherNetwork ) : Promise < null >
5053export function addEtherToken ( props : AddEtherToken ) : Promise < null >
5154export function getMetamaskProvider ( ) : Metamask | null
@@ -58,9 +61,21 @@ export function switchOrAppendNetwork(props: AddEtherNetwork): Promise<null>
5861export function sendEther ( props : SendMethodProps ) : Promise < string >
5962export function connectToMetamask ( ) : Promise < string >
6063export function formatEther ( balance : number ) : string
61- export function getFIATBalance (
64+ /**
65+ * Returns a formatted string with a token FIAT value
66+ * @param tokenBalance The amount of tokens to calculate
67+ * @param tokenPrice The current token price per unit
68+ * @param currency The currency token price is matched to
69+ * @example
70+ * const amount = 12
71+ * const priceInUSD = 200
72+ * const formattedValue = getFIATValue(amount, priceInUSD) // "2,400"
73+ */
74+ export function getFIATValue (
6275 tokenBalance : number | string ,
63- tokenPrice : number
64- ) : number
76+ tokenPrice : number | string ,
77+ /** Define a currency for `tokenPrice`. Defaults to "USD" */
78+ currency ?: "USD" | "JPY" | "EUR"
79+ ) : string
6580export const metamaskRequest : OnRequest [ "request" ]
6681export const parse : Parse
0 commit comments