complete store refactor; moved form inputs into store; refactored components out of TimedOrderEntry
This commit is contained in:
@@ -15,10 +15,10 @@ export function subPrices( routes ) {
|
||||
const subRoutes = []
|
||||
let chainId = null
|
||||
for( const route of routes ) {
|
||||
console.log('sub route', route, subscriptionCounts)
|
||||
// console.log('sub route', route, subscriptionCounts)
|
||||
if( !(route in subscriptionCounts) || subscriptionCounts[route] === 0 ) {
|
||||
subscriptionCounts[route] = 1
|
||||
console.log('subscribing to pool', route.pool)
|
||||
// console.log('subscribing to pool', route.pool)
|
||||
subRoutes.push(route)
|
||||
}
|
||||
else {
|
||||
@@ -33,9 +33,7 @@ export function subPrices( routes ) {
|
||||
// perform a local query if necessary
|
||||
for( const route of subRoutes ) {
|
||||
const s = useStore()
|
||||
console.log('route in prices?', route.pool in s.poolPrices, route.pool, s.poolPrices)
|
||||
if( !(route.pool in s.poolPrices) ) {
|
||||
console.log('querying initial route price', route.pool)
|
||||
getPriceForRoute(route).then((price)=>s.poolPrices[route.pool]=price)
|
||||
}
|
||||
}
|
||||
@@ -46,7 +44,7 @@ export function unsubPrices( routes ) {
|
||||
let chainId = null
|
||||
const unsubAddrs = []
|
||||
for( const route of routes ) {
|
||||
console.log('unsub route', route, subscriptionCounts)
|
||||
// console.log('unsub route', route, subscriptionCounts)
|
||||
if( !(route in subscriptionCounts) ) {
|
||||
console.error('unsubscribed to a nonexistent route', route)
|
||||
}
|
||||
@@ -56,7 +54,7 @@ export function unsubPrices( routes ) {
|
||||
unsubAddrs.push(route.pool)
|
||||
if( chainId !== null && route.chainId !== chainId )
|
||||
throw Error('cannot mix chainIds in a subscription list')
|
||||
console.log('unsubscribing from pool', route.pool)
|
||||
// console.log('unsubscribing from pool', route.pool)
|
||||
chainId = route.chainId
|
||||
}
|
||||
else if( subscriptionCounts[route] < 0 ) {
|
||||
@@ -71,7 +69,6 @@ export function unsubPrices( routes ) {
|
||||
|
||||
|
||||
async function getPriceForRoute(route) {
|
||||
console.log('route is',route)
|
||||
if( route.exchange === Exchange.UniswapV3 ) {
|
||||
const addr = uniswapV3PoolAddress(route.chainId, route.token0.address, route.token1.address, route.fee)
|
||||
const store = useStore();
|
||||
@@ -88,7 +85,7 @@ async function getPriceForRoute(route) {
|
||||
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)
|
||||
// console.log(`price for ${route.token0.symbol}/${route.token1.symbol}`,price)
|
||||
store.poolPrices[addr] = price
|
||||
return price
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user