diagonal line support
This commit is contained in:
@@ -24,8 +24,8 @@
|
||||
</suspense>
|
||||
</template>
|
||||
<template v-slot:item.avg="{ item }">
|
||||
{{ pairPrice(item.order.tokenIn, item.order.tokenOut, vaultAddr, item.avg) }}
|
||||
<btn v-if="pairPrice(item.order.tokenIn, item.order.tokenOut, vaultAddr, item.avg)!==''" size="small"
|
||||
{{ pairPrice(item.order.tokenIn, item.order.tokenOut, item.avg) }}
|
||||
<btn v-if="pairPrice(item.order.tokenIn, item.order.tokenOut, item.avg)!==''" size="small"
|
||||
variant="plain"
|
||||
@click="inverted[[vaultAddr,item.index]] = !inverted[[vaultAddr,item.index]]">
|
||||
{{ pair(item.order.tokenIn, item.order.tokenOut, vaultAddr, item.index) }}
|
||||
@@ -117,7 +117,7 @@ const inverted = reactive({})
|
||||
|
||||
|
||||
// todo create a Price component that keeps inversion flags in the store and defaults to stablecoins as the quote
|
||||
function pairPrice(inTokenAddr, outTokenAddr, vaultAddr, price) {
|
||||
function pairPrice(inTokenAddr, outTokenAddr, price) {
|
||||
if( price === null )
|
||||
return ''
|
||||
const inToken = token(inTokenAddr)
|
||||
@@ -125,7 +125,7 @@ function pairPrice(inTokenAddr, outTokenAddr, vaultAddr, price) {
|
||||
if( !inToken || !outToken )
|
||||
return ''
|
||||
|
||||
const decimals = outToken.decimals-inToken.decimals
|
||||
const decimals = inToken.decimals-outToken.decimals
|
||||
if( decimals > 0 )
|
||||
price /= 10 ** decimals
|
||||
else
|
||||
@@ -268,11 +268,14 @@ function describeTrancheTime(st, isStart, t) {
|
||||
}
|
||||
|
||||
function describeTrancheLine(st, isMin, b, m) {
|
||||
if( b===0 && m===0 ) return ''
|
||||
// todo slopes
|
||||
console.log('tranche line', isMin, b, m)
|
||||
// todo make this a PairPrice
|
||||
return (isMin === st.order.amountIsInput ? 'dont-chase ' : 'limit ') + pairPrice(st.order.tokenIn, st.order.tokenOut, s.vault, b)
|
||||
if( b===0 && m===0 ) return ''
|
||||
// console.log('tranche line', isMin, b, m)
|
||||
if( m !== 0 ) {
|
||||
const limit = b + m * s.time
|
||||
return 'diagonal ' + pairPrice(st.order.tokenIn, st.order.tokenOut, limit)
|
||||
}
|
||||
return (isMin === st.order.amountIsInput ? 'dont-chase ' : 'limit ') + pairPrice(st.order.tokenIn, st.order.tokenOut, b)
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user