MCPcopy Create free account
hub / github.com/cardstack/cardstack / ethPrice

Function ethPrice

packages/cardpay-cli/exchange-rate.ts:14–21  ·  view source on GitHub ↗
(network: string, token: string, amount?: string, mnemonic?: string)

Source from the content-addressed store, hash-verified

12 console.log(`USD value: $${usdPrice.toFixed(2)} USD`);
13}
14export async function ethPrice(network: string, token: string, amount?: string, mnemonic?: string): Promise<void> {
15 amount = amount ?? '1';
16 let web3 = await getWeb3(network, mnemonic);
17 let amountInWei = toWei(amount);
18 let exchangeRate = await getSDK('ExchangeRate', web3);
19 let ethWeiPrice = await exchangeRate.getETHPrice(token, amountInWei);
20 console.log(`ETH value: ${fromWei(ethWeiPrice)} ETH`);
21}
22export async function priceOracleUpdatedAt(network: string, token: string, mnemonic?: string): Promise<void> {
23 let web3 = await getWeb3(network, mnemonic);
24 let exchangeRate = await getSDK('ExchangeRate', web3);

Callers 1

index.tsFile · 0.90

Calls 5

getWeb3Function · 0.90
getSDKFunction · 0.90
fromWeiFunction · 0.85
getETHPriceMethod · 0.80
logMethod · 0.45

Tested by

no test coverage detected