@@ -178,7 +198,7 @@
:key="`d-${i}`"
class="d-flex justify-content-between align-items-center"
>
-
+
{{ formatDenom(b.denom) }}
+ {{ formatChanges(b.denom) }}
{{ formatAmount(b.amount, b.denom) }}
@@ -348,13 +372,30 @@ export default {
}
return parseFloat(total.toFixed(2))
},
+ calculateTotalChange() {
+ const v = Object.values(this.balances)
+ let total = 0
+ if (v) {
+ v.forEach(tokens => {
+ const subtotal = tokens.map(x => this.formatCurrency(x.amount, x.denom) * this.getChanges(x.denom) * 0.01).reduce((t, c) => t + c)
+ total += subtotal
+ })
+ }
+ const d = Object.values(this.delegations)
+ if (d) {
+ d.forEach(tokens => {
+ const subtotal = tokens.map(x => this.formatCurrency(x.amount, x.denom) * this.getChanges(x.denom) * 0.01).reduce((t, c) => t + c, 0)
+ total += subtotal
+ })
+ }
+ return parseFloat(total.toFixed(2))
+ },
calculateByDenom() {
const v = Object.values(this.balances)
const total = {}
const qty = {}
if (v) {
v.forEach(tokens => {
- // const subtotal = tokens.map(x => ({ denom: x.denom, sub: this.formatCurrency(x.amount, x.denom) }))
tokens.forEach(x => {
const denom = this.formatDenom(x.denom)
if (total[denom]) {
@@ -373,7 +414,6 @@ export default {
const d = Object.values(this.delegations)
if (d) {
d.forEach(tokens => {
- // const subtotal = tokens.map(x => ({ denom: x.denom, sub: this.formatCurrency(x.amount, x.denom) }))
tokens.forEach(x => {
const denom = this.formatDenom(x.denom)
if (total[denom]) {
@@ -496,6 +536,28 @@ export default {
}
return 0
},
+ priceColor(denom) {
+ const d2 = this.formatDenom(denom)
+ const quote = this.$store.state.chains.quotes[d2]
+ if (quote) {
+ const price = quote[`${this.currency2}_24h_change`]
+ return price > 0 ? 'text-success' : 'text-danger'
+ }
+ return ''
+ },
+ getChanges(denom) {
+ const d2 = this.formatDenom(denom)
+ const quote = this.$store.state.chains.quotes[d2]
+ if (quote) {
+ const price = quote[`${this.currency2}_24h_change`]
+ return price
+ }
+ return 0
+ },
+ formatChanges(denom) {
+ const price = this.getChanges(denom)
+ return `${parseFloat(price.toFixed(2))}%`
+ },
formatBalance(v) {
let total = 0
const balance = this.balances[v]
@@ -510,6 +572,24 @@ export default {
}
return parseFloat(total.toFixed(2))
},
+ formatBalanceChanges(v) {
+ let total = 0
+ const balance = this.balances[v]
+ if (balance) {
+ const ret = balance.map(x => this.formatCurrency(x.amount, x.denom) * this.getChanges(x.denom) * 0.01).reduce((t, c) => t + c)
+ total += ret
+ }
+ const delegations = this.delegations[v]
+ if (delegations) {
+ const ret = delegations.map(x => this.formatCurrency(x.amount, x.denom) * this.getChanges(x.denom) * 0.01).reduce((t, c) => t + c, 0)
+ total += ret
+ }
+ return parseFloat(total.toFixed(2))
+ },
+ formatBalanceChangesColor(v) {
+ const total = this.formatBalanceChanges(v)
+ return total > 0 ? 'text-success' : 'text-danger'
+ },
removeAddress(v) {
Object.keys(this.accounts).forEach(key => {
const item = this.accounts[key]