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)

View File

@@ -3,11 +3,11 @@ import {Exchange} from "@/blockchain/orderlib.js";
export async function findRoute(chainId, tokenA, tokenB) {
// console.log('getting query helper')
console.log('getting query helper')
const helper = await queryHelperContract()
if (!helper)
throw Error('no helper')
console.log('getting raw routes', tokenA.address, tokenB.address)
console.log('getting raw routes', helper, tokenA.address, tokenB.address)
const rawRoutes = await helper.getRoutes(tokenA.address, tokenB.address)
// todo expose all available pools
console.log('raw routes', rawRoutes)

View File

@@ -125,7 +125,7 @@ async function _discoverVaults(owner) {
console.error(`bad vault version ${version}`)
}
catch (e) {
console.log(`no vault ${num}`, e)
console.log(`no vault ${num}`)
}
if( s.account === owner ) { // double-check the account since it could have changed during our await
s.vaults = result