line building fixes

This commit is contained in:
tim
2024-09-11 01:09:07 -04:00
parent 84cadc6e6f
commit 80e03f648b
5 changed files with 24 additions and 39 deletions

View File

@@ -280,7 +280,7 @@ function describeTrancheTime(st, trancheIndex, isStart) {
let result = ''
if( t.minIsBarrier || t.maxIsBarrier )
return 'barrier'
const now = Math.round(Date.now()/1000)
const now = s.clock
if( isStart && t.startTime > 0 ) {
const start = t.startTimeIsRelative ? st.startTime + t.startTime : t.startTime
result += now < start ? ts.activationTime < now ? 'Rate Limited ' : 'Activates ' : 'Activated '

View File

@@ -41,7 +41,7 @@
<v-table>
<tbody>
<suspense>
<native-row :chain-id="s.chainId" :addr="s.vault" :amount="nativeBalance"
<native-row v-if="nativeBalance" :chain-id="s.chainId" :addr="s.vault" :amount="nativeBalance"
:on-withdraw="onWithdrawNative" :on-wrap="()=>wrapShow=true"/>
</suspense>
<suspense v-for="(amount,addr) of balances">

View File

@@ -2,9 +2,8 @@
<toolbar-pane title="Status" icon="mdi-format-list-bulleted-square">
<template #toolbar>
<v-btn variant="text" v-if="s.vault" prepend-icon="mdi-delete-alert" color="red"
@click="cancelAll(s.vault)" disabled
@click="cancelAll(s.vault)" :disabled="!anyOrdersOpen"
text="Cancel All"/>
<!--:disabled="!anyOrdersOpen"-->
</template>
<needs-signer>
<orders/>

View File

@@ -41,7 +41,7 @@
</template>
<script setup>
import {allocationText, applyLine, builderDefaults, useChartOrderStore} from "@/orderbuild.js";
import {allocationText, applyLinePoint, builderDefaults, useChartOrderStore} from "@/orderbuild.js";
import {sideColor} from "@/misc.js";
import {useOrderStore, useStore} from "@/store/store.js";
import {MAX_FRACTION, newTranche} from "@/blockchain/orderlib.js";
@@ -90,7 +90,7 @@ function buildTranches() {
})
const symbol = co.selectedSymbol
console.log('symbol', symbol, p)
applyLine(t, symbol, order.buy, p, 0)
applyLinePoint(t, symbol, order.buy, p)
tranches.push(t)
}
return tranches

View File

@@ -138,45 +138,31 @@ export function linePointsValue(time0, price0, time1, price1, unixTime = null) {
}
export function applyLinePoint(tranche, symbol, buy, price0) {
price0 *= 10 ** symbol.decimals
if (symbol.inverted)
price0 = 1/price0
applyLine(tranche, symbol, buy, price0, 0)
}
export function applyLinePoints(tranche, symbol, buy, time0, price0, time1, price1) {
const scale = 10 ** symbol.decimals
price0 *= scale
price1 *= scale
if (symbol.inverted) {
price0 = 1/price0
price1 = 1/price1
}
const [intercept, slope] = computeInterceptSlope(time0, price0, time1, price1);
applyLine(tranche, symbol, buy, intercept, slope)
}
export function applyLineOld(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 applyLine(tranche, symbol, buy, intercept, slope) {
console.log('applyLine', tranche, symbol, buy, intercept, slope)
const scale = 10 ** symbol.decimals
const inverted = symbol.inverted
let m = inverted ? -scale / slope : slope / scale
let b = inverted ? scale / intercept : intercept / scale
function applyLine(tranche, symbol, buy, intercept, slope) {
let m = slope
let b = intercept
console.log('applyLine current line value', m*timestamp()+b, 1./(m*timestamp()+b))
m = encodeIEE754(m)
b = encodeIEE754(b)
const isMinimum = symbol.inverted===buy;