initial diagonal work (unfinished)
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import {routeInverted, timestamp, uuid} from "@/misc.js";
|
||||
import {timestamp, uuid} from "@/misc.js";
|
||||
import {MAX_FRACTION, newTranche} from "@/blockchain/orderlib.js";
|
||||
import {useOrderStore, useStore} from "@/store/store.js";
|
||||
import {encodeIEE754} from "@/common.js";
|
||||
import {defineStore} from "pinia";
|
||||
import {computed, ref} from "vue";
|
||||
import Color from "color";
|
||||
import {chartMeanRange} from "@/charts/chart.js";
|
||||
|
||||
|
||||
export const MIN_EXECUTION_TIME = 60 // give at least one full minute for each tranche to trigger
|
||||
@@ -64,6 +65,7 @@ export const useChartOrderStore = defineStore('chart_orders', () => {
|
||||
return result
|
||||
})
|
||||
|
||||
const meanRange = ref(1)
|
||||
|
||||
const drawing = ref(false)
|
||||
|
||||
@@ -95,7 +97,7 @@ export const useChartOrderStore = defineStore('chart_orders', () => {
|
||||
|
||||
return {
|
||||
chartReady, selectedSymbol, selectedPool, intervalSecs, baseToken, quoteToken, price,
|
||||
orders, drawing, newOrder, removeOrder, resetOrders,
|
||||
orders, drawing, newOrder, removeOrder, resetOrders, meanRange,
|
||||
}
|
||||
})
|
||||
|
||||
@@ -138,40 +140,13 @@ export function linePointsValue(time0, price0, time1, price1, unixTime = null) {
|
||||
}
|
||||
|
||||
|
||||
export function applyLinePoints(tranche, time0, price0, time1, price1, isMinimum = null) {
|
||||
export function applyLinePoints(tranche, buy, time0, price0, time1, price1, poolDecimals, inverted) {
|
||||
const [intercept, slope] = computeInterceptSlope(time0, price0, time1, price1);
|
||||
applyLine(tranche, intercept, slope, isMinimum)
|
||||
applyLine(tranche, buy, intercept, slope, poolDecimals, inverted)
|
||||
}
|
||||
|
||||
|
||||
export function applyLine(tranche, intercept, slope, isMinimum = null) {
|
||||
console.log('intercept, slope', intercept, slope)
|
||||
// intercept and slope are still in "human" units of decimal-adjusted prices
|
||||
const os = useOrderStore()
|
||||
const route = os.route
|
||||
const inverted = routeInverted(route)
|
||||
const scale = 10 ** (os.tokenA.d - os.tokenB.d)
|
||||
let m = inverted ? -scale / slope : slope / scale
|
||||
let b = inverted ? scale / intercept : intercept / scale
|
||||
const cur = b + timestamp() * m
|
||||
console.log('inverted b, m, cur', inverted, b, m, cur)
|
||||
m = encodeIEE754(m)
|
||||
b = encodeIEE754(b)
|
||||
if (isMinimum === null)
|
||||
isMinimum = os.limitIsMinimum
|
||||
console.log('limit is minimum', isMinimum)
|
||||
if (isMinimum) {
|
||||
tranche.minIntercept = b;
|
||||
tranche.minSlope = m;
|
||||
} else {
|
||||
tranche.maxIntercept = b;
|
||||
tranche.maxSlope = m;
|
||||
}
|
||||
tranche.marketOrder = false;
|
||||
}
|
||||
|
||||
|
||||
export function applyLine2(tranche, isMinimum, intercept, slope, poolDecimals, inverted) {
|
||||
export function applyLine(tranche, buy, intercept, slope, poolDecimals, inverted) {
|
||||
console.log('intercept, slope', intercept, slope)
|
||||
// intercept and slope are still in "human" units of decimal-adjusted prices
|
||||
const scale = 10 ** -poolDecimals
|
||||
@@ -181,8 +156,7 @@ export function applyLine2(tranche, isMinimum, intercept, slope, poolDecimals, i
|
||||
console.log('inverted b, m, cur', inverted, b, m, cur)
|
||||
m = encodeIEE754(m)
|
||||
b = encodeIEE754(b)
|
||||
if (inverted)
|
||||
isMinimum = !isMinimum
|
||||
let isMinimum = !(buy ^ inverted)
|
||||
if (isMinimum) {
|
||||
tranche.minIntercept = b;
|
||||
tranche.minSlope = m;
|
||||
|
||||
Reference in New Issue
Block a user