Content
@
0 reply
0 recast
2 reactions
Stephan
@stephancill
Has anyone built a dead simple uniswap ts library for getting quotes with viem?
3 replies
3 recasts
9 reactions
Steve
@stevedylandev.eth
Here’s the plan We tag @dalechyn.eth Then we wait
3 replies
0 recast
3 reactions
Samuel ツ
@samuellhuber.eth
if y'all checked /devfc TG you'd see ``` import Decimal from 'decimal.js' import { uniswapV3PoolAbi } from '@/lib/abis/uniswapV3Pool' import { publicBaseClient } from '../publicBaseClient' export type GetEthPriceReturnType = number export type GetEthPriceErrorType = Error export async function getEthPrice(): Promise<GetEthPriceReturnType> { const [sqrtPriceX96] = await publicBaseClient.readContract({ abi: uniswapV3PoolAbi, functionName: 'slot0', address: '0xd0b53d9277642d899df5c87a3966a349a798f224' }) return new Decimal(sqrtPriceX96.toString()) .pow(2) .div(new Decimal(2).pow(192)) .mul(new Decimal(10).pow(12)) .toNumber() } ``` shared by @dalechyn.eth yesterday :D
0 reply
0 recast
2 reactions