USD marks
This commit is contained in:
@@ -56,6 +56,7 @@ export const useWalletStore = defineStore('wallet', ()=>{
|
|||||||
export function onChainChanged(chainId) {
|
export function onChainChanged(chainId) {
|
||||||
console.log('onChainChanged', chainId)
|
console.log('onChainChanged', chainId)
|
||||||
chainId = Number(chainId)
|
chainId = Number(chainId)
|
||||||
|
socket.emit('chain', chainId)
|
||||||
const store = useStore()
|
const store = useStore()
|
||||||
const ws = useWalletStore()
|
const ws = useWalletStore()
|
||||||
if( chainId !== ws.chainId ) {
|
if( chainId !== ws.chainId ) {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
export const NATIVE_TOKEN = '0x0000000000000000000000000000000000000001'
|
||||||
|
|
||||||
export function mixin(child, ...parents) {
|
export function mixin(child, ...parents) {
|
||||||
// child is modified directly, assigning fields from parents that are missing in child. parents fields are
|
// child is modified directly, assigning fields from parents that are missing in child. parents fields are
|
||||||
// assigned by parents order, highest priority first
|
// assigned by parents order, highest priority first
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ import Color from "color";
|
|||||||
import OrderAmount from "@/components/chart/OrderAmount.vue";
|
import OrderAmount from "@/components/chart/OrderAmount.vue";
|
||||||
import {MAX_FRACTION, newTranche} from "@/blockchain/orderlib.js";
|
import {MAX_FRACTION, newTranche} from "@/blockchain/orderlib.js";
|
||||||
import {getFeeSchedule} from "@/fees.js";
|
import {getFeeSchedule} from "@/fees.js";
|
||||||
|
import {NATIVE_TOKEN} from "@/common.js";
|
||||||
|
|
||||||
const s = useStore()
|
const s = useStore()
|
||||||
const co = useChartOrderStore()
|
const co = useChartOrderStore()
|
||||||
@@ -126,7 +127,12 @@ const partsGasHint = computed(()=>{
|
|||||||
schedFetcher.invoke(s.vault)
|
schedFetcher.invoke(s.vault)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
return toPrecision(Number(sched.value.gasFee) * parts.value / 1e18) + ' ETH gas fee'
|
const ethFee = Number(sched.value.gasFee) * parts.value / 1e18;
|
||||||
|
const mark = s.markPrice(NATIVE_TOKEN)
|
||||||
|
if (mark)
|
||||||
|
return '$' + Number(ethFee*mark).toFixed(2) + ' gas fee'
|
||||||
|
else
|
||||||
|
return toPrecision(ethFee) + ' ETH gas fee'
|
||||||
})
|
})
|
||||||
|
|
||||||
const intervalIsTotal = ref(false)
|
const intervalIsTotal = ref(false)
|
||||||
|
|||||||
@@ -73,6 +73,11 @@ socket.on('vaults', (chainId, owner, vaults)=>{
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
socket.on('mark.usd', (chainId, token, value)=>{
|
||||||
|
const s = useStore()
|
||||||
|
s.markPrices[`${chainId}|${token}`] = Number(value)
|
||||||
|
// console.log('mark.usd', token, value)
|
||||||
|
})
|
||||||
|
|
||||||
function handleOrderStatus(chainId, vault, orderIndex, status) {
|
function handleOrderStatus(chainId, vault, orderIndex, status) {
|
||||||
const s = useStore()
|
const s = useStore()
|
||||||
|
|||||||
@@ -107,6 +107,8 @@ export const useStore = defineStore('app', ()=> {
|
|||||||
const balances = computed( () => vault.value === null ? {} : vaultBalances.value[vault.value] || {} )
|
const balances = computed( () => vault.value === null ? {} : vaultBalances.value[vault.value] || {} )
|
||||||
const vaultOrders = computed(()=> vault.value === null || (!vault.value in orders.value) ? {} : orders.value[vault.value] ? orders.value[vault.value] : [] )
|
const vaultOrders = computed(()=> vault.value === null || (!vault.value in orders.value) ? {} : orders.value[vault.value] ? orders.value[vault.value] : [] )
|
||||||
const tokens = computed(getTokens)
|
const tokens = computed(getTokens)
|
||||||
|
const markPrices = ref({}) // key: `${chainId}|${tokenAddr}` value: USD value
|
||||||
|
function markPrice(token) { return markPrices.value[`${chainId.value}|${token}`] }
|
||||||
const factory = computed(() => !chain.value ? null : chain.value.factory)
|
const factory = computed(() => !chain.value ? null : chain.value.factory)
|
||||||
const helper = computed(() => {console.log('chain helper', chain.value); return !chain.value ? null : chain.value.helper})
|
const helper = computed(() => {console.log('chain helper', chain.value); return !chain.value ? null : chain.value.helper})
|
||||||
const mockenv = computed(() => !chain.value ? null : chain.value.mockenv)
|
const mockenv = computed(() => !chain.value ? null : chain.value.mockenv)
|
||||||
@@ -147,6 +149,7 @@ export const useStore = defineStore('app', ()=> {
|
|||||||
removeTransactionSender, error, closeError, addToken, clock, balances,
|
removeTransactionSender, error, closeError, addToken, clock, balances,
|
||||||
approved, regionApproved, walletApproved,
|
approved, regionApproved, walletApproved,
|
||||||
getBalance, creatingVault,
|
getBalance, creatingVault,
|
||||||
|
markPrices, markPrice,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user