order building fixes

This commit is contained in:
Tim
2024-03-27 16:11:12 -04:00
parent fb82f23d88
commit 204c63f1b9
3 changed files with 10 additions and 20 deletions

View File

@@ -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;