static version.json file

This commit is contained in:
Tim Olson
2024-01-03 16:07:10 -04:00
parent 29517807f5
commit 80cd86dcec
8 changed files with 39 additions and 29 deletions

View File

@@ -73,6 +73,8 @@ export function unsubPrices( routes ) {
async function getPriceForRoute(route) {
if( !route.token0 || !route.token1 )
return null
if( route.exchange === Exchange.UniswapV3 ) {
const addr = uniswapV3PoolAddress(route.chainId, route.token0.address, route.token1.address, route.fee)
const store = useStore();
@@ -85,8 +87,7 @@ async function getPriceForRoute(route) {
const got = await pool.slot0()
const [sqrtPrice,,,,,,] = got
const spn = BigInt(sqrtPrice)
let price = spn*spn * 10n**BigInt(route.token0.decimals-route.token1.decimals)
price = FixedNumber.fromValue(price,0,WIDE_PRICE_FORMAT)
let price = FixedNumber.fromValue(spn*spn, route.token1.decimals - route.token0.decimals, WIDE_PRICE_FORMAT)
price = price.div(FixedNumber.fromValue(2n**(96n*2n),0,WIDE_PRICE_FORMAT))
price = price.round(18).toString()
// console.log(`price for ${route.token0.symbol}/${route.token1.symbol}`,price)