orders view fixes
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
<template>
|
||||
<span>
|
||||
{{adjValue}}
|
||||
<btn v-if="showBtn && adjValue!==null" size="small" variant="plain" @click="invert()">{{pair.value?pair.value.toPrecision(5):''}}</btn>
|
||||
{{adjValue === null ? '' : adjValue.toPrecision(5)}}
|
||||
<v-btn v-if="showBtn && adjValue!==null" size="small" variant="text" class="ml-0 px-0"
|
||||
@click="flipInversionPreference(s.chainId, base, quote)">
|
||||
{{pair}}
|
||||
</v-btn>
|
||||
</span>
|
||||
<!-- todo optional pair label and inversion button -->
|
||||
</template>
|
||||
@@ -9,30 +12,25 @@
|
||||
<script setup>
|
||||
import {usePrefStore, useStore} from "@/store/store";
|
||||
import {computed} from "vue";
|
||||
import {token} from "@/blockchain/token.js";
|
||||
import {pairKey, pairPrice} from "@/misc.js";
|
||||
import Btn from "@/components/Btn.vue";
|
||||
import {getToken} from "@/blockchain/token.js";
|
||||
import {flipInversionPreference, inversionPreference, pairPrice} from "@/misc.js";
|
||||
|
||||
const props = defineProps(['value', 'baseToken', 'quoteToken', 'baseAddr', 'quoteAddr', 'showBtn', 'decimals'])
|
||||
const props = defineProps(['value', 'base', 'quote', 'showBtn'])
|
||||
|
||||
const s = useStore()
|
||||
const prefs = usePrefStore()
|
||||
|
||||
const base = computed(() => props.baseToken ? props.baseToken : token(s.chainId, props.baseAddr))
|
||||
const quote = computed(() => props.quoteToken ? props.quoteToken : token(s.chainId, props.quoteAddr))
|
||||
|
||||
function invert() {
|
||||
const k = pairKey(base.value,quote.value)
|
||||
prefs.inverted[k] = !prefs.inverted[k]
|
||||
async function token(obj) {
|
||||
return obj.a ? obj : await getToken(s.chainId, obj)
|
||||
}
|
||||
|
||||
const adjValue = computed(() => props.value === null || props.value === undefined || !base.value || !quote.value ? null : pairPrice(s.chainId, base.value, quote.value, props.value, props.decimals))
|
||||
const base = await token(props.base)
|
||||
const quote = await token(props.quote)
|
||||
|
||||
const adjValue = computed(() => props.value === null || props.value === undefined ? null : pairPrice(s.chainId, base, quote, props.value))
|
||||
|
||||
const pair = computed(() => {
|
||||
const inToken = props.baseToken ? props.baseToken : token(s.chainId, props.baseAddr)
|
||||
const outToken = props.quoteToken ? props.quoteToken : token(s.chainId, props.quoteAddr)
|
||||
return !inToken || !outToken ? '___\\___' : prefs.inverted[pairKey(s.chainId, inToken, outToken)] ?
|
||||
outToken.symbol + '\\' + inToken.symbol : inToken.symbol + '\\' + outToken.symbol
|
||||
return inversionPreference(s.chainId, base, quote) ? quote.s + '/' + base.s : base.s + '/' + quote.s
|
||||
})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user