fill notifications and chart autoupdate

This commit is contained in:
tim
2024-10-29 16:30:05 -04:00
parent b9ca6ab2cc
commit 5d3d1d6f5a
5 changed files with 67 additions and 6 deletions

View File

@@ -31,7 +31,7 @@ export function uniswapV3PoolAddress(chainId, tokenAddrA, tokenAddrB, fee) {
export function uniswapV3AveragePrice(amountIn, amountOut, fee) {
if (amountIn === 0n || amountOut === 0n) return null
const fmtX18 = {decimals: 18, width: 256, signed: false};
const fmtX18 = {decimals: 18, width: 512, signed: false};
let result = FixedNumber.fromValue(amountOut, 0, fmtX18)
.div(FixedNumber.fromValue(amountIn, 0, fmtX18)).toUnsafeFloat()
result /= (1 - fee / 1_000_000) // adjust for pool fee