diff --git a/src/blockchain/token.js b/src/blockchain/token.js index ee89509..df18f96 100644 --- a/src/blockchain/token.js +++ b/src/blockchain/token.js @@ -6,21 +6,9 @@ import {metadata, metadataMap} from "@/version.js"; // synchronous version may return null but will trigger a lookup -export function token(addr) { - // todo deprecated. use metadataMap[chainId][addr] - console.warn('token() is deprecated') - console.log('token', addr) - if( !addr ) { - // console.log('ignoring call to token', addr) - return null - } - const s = useStore() - if( !(addr in s.tokens) ) { - // noinspection JSIgnoredPromiseFromCall - getToken(addr) - return null - } - return s.tokens[addr] +export function token(chainId, addr) { + const found = metadataMap[chainId][addr] + return found ? found : null } diff --git a/src/components/chart/ChartOrder.vue b/src/components/chart/ChartOrder.vue index 305d5bc..d9f6f17 100644 --- a/src/components/chart/ChartOrder.vue +++ b/src/components/chart/ChartOrder.vue @@ -80,8 +80,8 @@ function buildOrder() { // } const symbol = co.selectedSymbol const fee = co.selectedPool[1] - const tokenIn = order.buy ^ symbol.inverted ? symbol.quote : symbol.base - const tokenOut = order.buy ^ symbol.inverted ? symbol.base : symbol.quote + const tokenIn = order.buy ? symbol.quote : symbol.base + const tokenOut = order.buy ? symbol.base : symbol.quote const amountDec = order.amountIsTokenA ? symbol.base.d : symbol.quote.d const amount = BigInt(Math.trunc(order.amount * 10 ** amountDec)) const amountIsInput = !!(order.amountIsTokenA ^ order.buy) diff --git a/src/orderbuild.js b/src/orderbuild.js index 04a0862..45c0dc2 100644 --- a/src/orderbuild.js +++ b/src/orderbuild.js @@ -139,15 +139,17 @@ export function applyLine(tranche, intercept, slope, isMinimum = null) { export function applyLine2(tranche, isMinimum, intercept, slope, poolDecimals, inverted) { - // console.log('intercept, slope', intercept, slope) + console.log('intercept, slope', intercept, slope) // intercept and slope are still in "human" units of decimal-adjusted prices const scale = 10 ** -poolDecimals - let m = inverted ? -scale / slope : slope / scale - let b = inverted ? scale / intercept : intercept / scale + let m = slope === 0 ? 0 : inverted ? -scale / slope : scale * slope + let b = inverted ? scale / intercept : scale * intercept const cur = b + timestamp() * m console.log('inverted b, m, cur', inverted, b, m, cur) m = encodeIEE754(m) b = encodeIEE754(b) + if (inverted) + isMinimum = !isMinimum if (isMinimum) { tranche.minIntercept = b; tranche.minSlope = m;