arb1 redeploy

This commit is contained in:
tim
2024-10-29 21:08:56 -04:00
parent 5d3d1d6f5a
commit a3bfaa2b08
5 changed files with 43 additions and 25 deletions

View File

@@ -1,4 +1,4 @@
import {ethers, FixedNumber} from "ethers";
import {FixedNumber} from "ethers";
import {usePrefStore, useStore} from "@/store/store.js";
import {token} from "@/blockchain/token.js";
import Color from "color";
@@ -242,3 +242,14 @@ export function interpolate(a, b, zeroToOne) {
return a + d * zeroToOne
}
export function computeInterceptSlope(time0, price0, time1, price1) {
if (!time0 || !price0 && price0 !== 0 || !time1 || !price1 && price1 !== 0)
throw Error(`invalid line points data ${time0} ${price0} ${time1} ${price1}`)
const t0 = time0
const t1 = time1
if (t0 === t1)
throw Error("line points' times must be different")
const slope = (price1 - price0) / (t1 - t0)
const intercept = price1 - slope * t1
return [intercept, slope]
}