arb1 redeploy
This commit is contained in:
13
src/misc.js
13
src/misc.js
@@ -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]
|
||||
}
|
||||
Reference in New Issue
Block a user