static version.json file
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user