2020-05-14 05:15:18 +00:00
|
|
|
<template>
|
2020-05-22 18:04:27 +00:00
|
|
|
<div>
|
|
|
|
<div class="mb-2">
|
2022-10-30 13:26:23 +00:00
|
|
|
<label class="me-auto h3">Balance</label>
|
2022-12-24 09:53:01 +00:00
|
|
|
<div class="float-end d-flex flex-row">
|
|
|
|
<b-button
|
2023-04-22 15:31:54 +00:00
|
|
|
v-if="canUseBotBalance"
|
2022-12-24 09:53:01 +00:00
|
|
|
size="sm"
|
2023-04-22 15:10:22 +00:00
|
|
|
:title="!showBotOnly ? 'Showing Account balance' : 'Showing Bot balance'"
|
|
|
|
@click="showBotOnly = !showBotOnly"
|
|
|
|
>
|
|
|
|
<RobotIcon v-if="showBotOnly" :size="16" />
|
|
|
|
<AccountIcon v-else :size="16" />
|
|
|
|
</b-button>
|
|
|
|
<b-button
|
|
|
|
size="sm"
|
|
|
|
:title="!hideSmallBalances ? 'Hide small balances' : 'Show all balances'"
|
2022-12-24 09:53:01 +00:00
|
|
|
@click="hideSmallBalances = !hideSmallBalances"
|
|
|
|
>
|
|
|
|
<HideIcon v-if="hideSmallBalances" :size="16" />
|
|
|
|
<ShowIcon v-else :size="16" />
|
|
|
|
</b-button>
|
|
|
|
|
|
|
|
<b-button class="float-end" size="sm" @click="botStore.activeBot.getBalance"
|
|
|
|
>↻</b-button
|
|
|
|
>
|
|
|
|
</div>
|
2020-05-17 18:52:14 +00:00
|
|
|
</div>
|
2023-04-22 15:45:05 +00:00
|
|
|
<BalanceChart v-if="balanceCurrencies" :currencies="chartValues" />
|
2020-05-22 18:04:27 +00:00
|
|
|
<div>
|
2022-04-18 17:54:17 +00:00
|
|
|
<p v-if="botStore.activeBot.balance.note">
|
|
|
|
<strong>{{ botStore.activeBot.balance.note }}</strong>
|
2020-05-14 05:22:27 +00:00
|
|
|
</p>
|
2021-05-08 07:47:31 +00:00
|
|
|
<b-table class="table-sm" :items="balanceCurrencies" :fields="tableFields">
|
2022-12-17 14:03:04 +00:00
|
|
|
<template #custom-foot>
|
2020-05-14 05:16:07 +00:00
|
|
|
<td><strong>Total</strong></td>
|
2022-02-07 19:06:14 +00:00
|
|
|
<td>
|
2022-07-21 05:13:18 +00:00
|
|
|
<span
|
|
|
|
class="font-italic"
|
|
|
|
:title="`Increase over initial capital of ${formatCurrency(
|
|
|
|
botStore.activeBot.balance.starting_capital,
|
|
|
|
)} ${botStore.activeBot.balance.stake}`"
|
|
|
|
>{{ formatPercent(botStore.activeBot.balance.starting_capital_ratio) }}</span
|
|
|
|
>
|
2022-02-07 19:06:14 +00:00
|
|
|
</td>
|
2020-05-14 05:15:18 +00:00
|
|
|
<!-- this is a computed prop that adds up all the expenses in the visible rows -->
|
2020-05-14 05:16:07 +00:00
|
|
|
<td>
|
2023-04-22 15:10:22 +00:00
|
|
|
<strong>{{
|
2023-04-22 15:31:54 +00:00
|
|
|
showBotOnly && canUseBotBalance
|
2023-04-22 15:10:22 +00:00
|
|
|
? formatCurrency(botStore.activeBot.balance.total_bot)
|
|
|
|
: formatCurrency(botStore.activeBot.balance.total)
|
|
|
|
}}</strong>
|
2020-05-14 05:16:07 +00:00
|
|
|
</td>
|
2020-05-14 05:15:18 +00:00
|
|
|
</template>
|
|
|
|
</b-table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2023-03-18 16:14:14 +00:00
|
|
|
<script setup lang="ts">
|
2021-05-08 07:47:31 +00:00
|
|
|
import HideIcon from 'vue-material-design-icons/EyeOff.vue';
|
|
|
|
import ShowIcon from 'vue-material-design-icons/Eye.vue';
|
2023-04-22 15:10:22 +00:00
|
|
|
import RobotIcon from 'vue-material-design-icons/Robot.vue';
|
|
|
|
import AccountIcon from 'vue-material-design-icons/Bank.vue';
|
2021-12-19 19:06:25 +00:00
|
|
|
import BalanceChart from '@/components/charts/BalanceChart.vue';
|
2023-03-18 16:47:23 +00:00
|
|
|
import { formatPercent, formatPrice } from '@/shared/formatters';
|
2023-03-18 16:14:14 +00:00
|
|
|
import { computed, ref } from 'vue';
|
2022-04-18 17:54:17 +00:00
|
|
|
import { useBotStore } from '@/stores/ftbotwrapper';
|
2023-04-22 15:10:22 +00:00
|
|
|
import { TableField } from 'bootstrap-vue-next';
|
2023-04-22 15:45:05 +00:00
|
|
|
import { BalanceValues } from '@/types';
|
2020-08-09 13:07:09 +00:00
|
|
|
|
2023-03-18 16:14:14 +00:00
|
|
|
const botStore = useBotStore();
|
|
|
|
const hideSmallBalances = ref(true);
|
2023-04-22 15:10:22 +00:00
|
|
|
const showBotOnly = ref(true);
|
2020-08-09 13:07:09 +00:00
|
|
|
|
2023-04-22 15:10:22 +00:00
|
|
|
const smallBalance = computed<number>(() => {
|
|
|
|
return Number((1.1 ** botStore.activeBot.stakeCurrencyDecimals).toFixed(8));
|
2023-03-18 16:14:14 +00:00
|
|
|
});
|
2022-01-24 18:36:32 +00:00
|
|
|
|
2023-04-22 15:31:54 +00:00
|
|
|
const canUseBotBalance = computed(() => {
|
|
|
|
return botStore.activeBot.botApiVersion >= 2.26;
|
|
|
|
});
|
|
|
|
|
2023-03-18 16:14:14 +00:00
|
|
|
const balanceCurrencies = computed(() => {
|
2023-04-22 15:10:22 +00:00
|
|
|
return botStore.activeBot.balance.currencies?.filter(
|
|
|
|
(v) =>
|
|
|
|
(!hideSmallBalances.value || v.est_stake >= smallBalance.value) &&
|
2023-04-22 15:31:54 +00:00
|
|
|
(!canUseBotBalance.value || !showBotOnly.value || (v.is_bot_managed ?? true) === true),
|
2023-04-22 15:10:22 +00:00
|
|
|
);
|
2023-03-18 16:14:14 +00:00
|
|
|
});
|
2021-05-08 07:47:31 +00:00
|
|
|
|
2023-03-18 16:14:14 +00:00
|
|
|
const formatCurrency = (value) => {
|
2023-04-22 12:39:50 +00:00
|
|
|
return value ? formatPrice(value, botStore.activeBot.stakeCurrencyDecimals) : '';
|
2023-03-18 16:14:14 +00:00
|
|
|
};
|
2021-05-08 07:47:31 +00:00
|
|
|
|
2023-04-22 15:45:05 +00:00
|
|
|
const chartValues = computed<BalanceValues[]>(() => {
|
|
|
|
return balanceCurrencies.value?.map((v) => {
|
|
|
|
return {
|
|
|
|
balance: v.balance,
|
|
|
|
currency: v.currency,
|
|
|
|
est_stake:
|
|
|
|
showBotOnly.value && canUseBotBalance.value ? v.est_stake_bot ?? v.est_stake : v.est_stake,
|
|
|
|
free: showBotOnly.value && canUseBotBalance.value ? v.bot_owned ?? v.free : v.free,
|
|
|
|
used: v.used,
|
|
|
|
stake: v.stake,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2023-04-22 15:10:22 +00:00
|
|
|
const tableFields = computed<TableField[]>(() => {
|
2023-03-18 16:14:14 +00:00
|
|
|
return [
|
|
|
|
{ key: 'currency', label: 'Currency' },
|
|
|
|
{
|
2023-04-22 15:31:54 +00:00
|
|
|
key: showBotOnly.value && canUseBotBalance.value ? 'bot_owned' : 'free',
|
2023-04-22 15:10:22 +00:00
|
|
|
label: 'Available',
|
|
|
|
formatter: formatCurrency,
|
|
|
|
},
|
|
|
|
{
|
2023-04-22 15:31:54 +00:00
|
|
|
key: showBotOnly.value && canUseBotBalance.value ? 'est_stake_bot' : 'est_stake',
|
2023-03-18 16:14:14 +00:00
|
|
|
label: `in ${botStore.activeBot.balance.stake}`,
|
|
|
|
formatter: formatCurrency,
|
|
|
|
},
|
|
|
|
];
|
2022-04-15 18:02:27 +00:00
|
|
|
});
|
2020-05-14 05:15:18 +00:00
|
|
|
</script>
|