limit price display fix

This commit is contained in:
tim
2024-10-11 17:32:47 -04:00
parent 5b23864c2e
commit 43a11b057b
5 changed files with 21 additions and 21 deletions

View File

@@ -138,7 +138,7 @@ export function initWidget(el) {
enabled_features: ['saveload_separate_drawings_storage'],
drawings_access: {type: 'white', tools: [],}, // show no tools
custom_themes: tvCustomThemes,
theme: 'dark',
theme: useStore().theme,
});
// debug dump all events

View File

@@ -174,7 +174,7 @@ function buildSymbolIndex() {
// return str
// }
function invertedDefault(tokenAddrA, tokenAddrB) {
export function invertedDefault(tokenAddrA, tokenAddrB) {
// lower priority is more important (earlier in the list)
const a = tokenMap[tokenAddrA];
const b = tokenMap[tokenAddrB];

View File

@@ -13,7 +13,7 @@
import {usePrefStore, useStore} from "@/store/store";
import {computed} from "vue";
import {getToken} from "@/blockchain/token.js";
import {flipInversionPreference, inversionPreference, pairPrice} from "@/misc.js";
import {flipInversionPreference, inversionPreference} from "@/misc.js";
const props = defineProps(['value', 'base', 'quote', 'showBtn'])
@@ -35,6 +35,23 @@ const pair = computed(() => {
})
function pairPrice(chainId, baseToken, quoteToken, price) {
if (price === null || price === undefined)
return null
const decimals = baseToken.d - quoteToken.d
// console.log('pairPrice', chainId, baseToken, quoteToken, price, decimals)
// console.log('adjusted pairPrice', price)
if (decimals >= 0)
price /= 10 ** decimals
else
price *= 10 ** -decimals
if (inversionPreference(chainId, baseToken, quoteToken))
price = 1 / price
// console.log('inverted?', price)
return price
}
</script>
<style scoped lang="scss">

View File

@@ -163,23 +163,6 @@ export function inversionPreference(chainId, base, quote) {
return prefs.inverted[key] !== inputInverted
}
export function pairPrice(chainId, baseToken, quoteToken, price) {
if (price === null || price === undefined)
return null
const decimals = quoteToken.d - baseToken.d
// console.log('pairPrice', chainId, baseToken, quoteToken, price, decimals)
if (decimals >= 0)
price /= 10 ** decimals
else
price *= 10 ** -decimals
// console.log('adjusted pairPrice', price)
if (inversionPreference(chainId, baseToken, quoteToken))
price = 1 / price
// console.log('inverted?', price)
return price
}
export const sleep = ms => new Promise(r => setTimeout(r, ms))
export function uuid() {

View File

@@ -41,7 +41,7 @@ export const useStore = defineStore('app', ()=> {
const timeZone = ref('Etc/UTC')
const nav = ref(false) // controls opening navigation drawer
const theme = ref('dark')
const theme = ref('light') // todo 'dark'
const connected = ref(false)
const allowed = ref(!REQUIRE_AUTH)