From 1b670b1398067ff2edabe5f6de99daa0566b517a Mon Sep 17 00:00:00 2001 From: Tim Olson <> Date: Sat, 18 Nov 2023 16:26:51 -0400 Subject: [PATCH] more price handling bugfixes --- src/blockchain/prices.js | 6 +++--- src/components/Faucet.vue | 4 +--- src/components/RoutePrice.vue | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/blockchain/prices.js b/src/blockchain/prices.js index e1fd53c..990aa8a 100644 --- a/src/blockchain/prices.js +++ b/src/blockchain/prices.js @@ -6,6 +6,7 @@ import {ethers, FixedNumber} from "ethers"; import {uniswapV3PoolAbi} from "@/blockchain/abi.js"; const subscriptionCounts = {} // key is route and value is a subscription counter +export const WIDE_PRICE_FORMAT = {decimals:38, width:512, signed:false}; // 38 decimals is 127 bits export function subPrices( routes ) { @@ -84,9 +85,8 @@ async function getPriceForRoute(route) { const [sqrtPrice,,,,,,] = got const spn = BigInt(sqrtPrice) let price = spn*spn * 10n**BigInt(route.token0.decimals-route.token1.decimals) - const format = {decimals:38,width:512,signed:false}; // 38 decimals is 127 bits - price = FixedNumber.fromValue(price,0,format) - price = price.div(FixedNumber.fromValue(2n**(96n*2n),0,format)) + price = FixedNumber.fromValue(price,0,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) store.poolPrices[addr] = price diff --git a/src/components/Faucet.vue b/src/components/Faucet.vue index 001ddc7..7cf7f28 100644 --- a/src/components/Faucet.vue +++ b/src/components/Faucet.vue @@ -50,9 +50,7 @@ function gib() { if( s.account ) { disabled.value = true socket.emit('faucet', s.chainId, s.account) - setTimeout(()=>disabled.value=false, - 1000) // todo - // 60*1000) + setTimeout(()=>disabled.value=false, 60*1000) } } diff --git a/src/components/RoutePrice.vue b/src/components/RoutePrice.vue index 642f123..6fa395d 100644 --- a/src/components/RoutePrice.vue +++ b/src/components/RoutePrice.vue @@ -4,7 +4,7 @@