From 7dc58ef3911d6d07d8f0aa0416d19c52ef6fc5d5 Mon Sep 17 00:00:00 2001 From: Evgeni B Date: Wed, 13 Sep 2023 16:32:26 +0300 Subject: [PATCH 1/3] fix(tokens): tokens multipliers --- src/components/common/payout-amounts.vue | 13 ++++++++++++- src/pages/proposals/create/StepPayout.vue | 6 +++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/components/common/payout-amounts.vue b/src/components/common/payout-amounts.vue index 05afe2ee7..369e0689d 100644 --- a/src/components/common/payout-amounts.vue +++ b/src/components/common/payout-amounts.vue @@ -41,6 +41,17 @@ export default defineComponent({ } else { return true } + }, + + settingsMultiplier(label) { + switch (label) { + case 'Cash Token': + return this.$store.state.dao.settings.settings_treasuryTokenMultiplier_i + case 'Voice Token': + return this.$store.state.dao.settings.settings_voiceTokenMultiplier_i + case 'Utility Token': + return this.$store.state.dao.settings.settings_utilityTokenMultiplier_i + } } } }) @@ -50,5 +61,5 @@ export default defineComponent({ .full-width(:class="{row: $q.platform.is.desktop}") template(v-for="token in tokens") .col(v-if="token.value" :class="{'col-12': stacked, 'q-mb-md': $q.platform.is.mobile}") - token-value(v-if="settingsHasToken(token.label)" :daoLogo="daoLogo" :multiplier="multiplier" v-bind="token") + token-value(:daoLogo="daoLogo" :multiplier="settingsMultiplier(token.label)" v-bind="token") diff --git a/src/pages/proposals/create/StepPayout.vue b/src/pages/proposals/create/StepPayout.vue index 8a21a5a6d..935476095 100644 --- a/src/pages/proposals/create/StepPayout.vue +++ b/src/pages/proposals/create/StepPayout.vue @@ -258,13 +258,13 @@ export default { return (this.cycleDurationSec / this.daoSettings.periodDurationSec).toFixed(2) }, cashToken () { - return !this.toggle ? this.getFormatedTokenAmount(this.peg, Number.MAX_VALUE) : this.getFormatedTokenAmount((this.peg / this.periodsOnCycle).toFixed(2), Number.MAX_VALUE) + return !this.toggle ? this.getFormatedTokenAmount(this.peg * this.$store.state.dao.settings.settings_treasuryTokenMultiplier_i, Number.MAX_VALUE) : this.getFormatedTokenAmount((this.peg * this.$store.state.dao.settings.settings_treasuryTokenMultiplier_i / this.periodsOnCycle).toFixed(2), Number.MAX_VALUE) }, utilityToken () { - return !this.toggle ? this.getFormatedTokenAmount(this.reward, Number.MAX_VALUE) : this.getFormatedTokenAmount((this.reward / this.periodsOnCycle).toFixed(2), Number.MAX_VALUE) + return !this.toggle ? this.getFormatedTokenAmount(this.reward * this.$store.state.dao.settings.settings_utilityTokenMultiplier_i, Number.MAX_VALUE) : this.getFormatedTokenAmount((this.reward * this.$store.state.dao.settings.settings_utilityTokenMultiplier_i / this.periodsOnCycle).toFixed(2), Number.MAX_VALUE) }, voiceToken () { - return !this.toggle ? this.getFormatedTokenAmount(this.voice, Number.MAX_VALUE) : this.getFormatedTokenAmount((this.voice / this.periodsOnCycle).toFixed(2), Number.MAX_VALUE) + return !this.toggle ? this.getFormatedTokenAmount(this.voice * this.$store.state.dao.settings.settings_voiceTokenMultiplier_i, Number.MAX_VALUE) : this.getFormatedTokenAmount((this.voice * this.$store.state.dao.settings.settings_voiceTokenMultiplier_i / this.periodsOnCycle).toFixed(2), Number.MAX_VALUE) }, isAssignment () { const proposalType = this.$store.state.proposals.draft.category.key From bf5dbd5e47ab82cd8b2e6e1b1978e6bf42eca0a2 Mon Sep 17 00:00:00 2001 From: Evgeni B Date: Thu, 14 Sep 2023 15:19:52 +0300 Subject: [PATCH 2/3] fix(payout-amounts): change strings to const vars --- src/components/common/payout-amounts.vue | 9 +++++---- src/const.js | 6 ++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/common/payout-amounts.vue b/src/components/common/payout-amounts.vue index 369e0689d..f72d46680 100644 --- a/src/components/common/payout-amounts.vue +++ b/src/components/common/payout-amounts.vue @@ -2,6 +2,7 @@ import { defineComponent } from 'vue' import { PropType } from 'vue/types/v3-component-props' import TokenValue from './token-value.vue' +import { TOKEN_TYPES } from '~/const' type TokenProps = Omit< InstanceType['$props'], @@ -35,7 +36,7 @@ export default defineComponent({ methods: { settingsHasToken(token) { - if (token !== 'Voice Token') { + if (token !== TOKEN_TYPES.VOICE_TOKEN) { const cleanTokenName = token.split(' ')?.[2]?.replace('(', '').replace(')', '') return cleanTokenName === this.$store.state.dao.settings.pegToken || cleanTokenName === this.$store.state.dao.settings.rewardToken } else { @@ -45,11 +46,11 @@ export default defineComponent({ settingsMultiplier(label) { switch (label) { - case 'Cash Token': + case TOKEN_TYPES.CASH_TOKEN: return this.$store.state.dao.settings.settings_treasuryTokenMultiplier_i - case 'Voice Token': + case TOKEN_TYPES.VOICE_TOKEN: return this.$store.state.dao.settings.settings_voiceTokenMultiplier_i - case 'Utility Token': + case TOKEN_TYPES.UTILITY_TOKEN: return this.$store.state.dao.settings.settings_utilityTokenMultiplier_i } } diff --git a/src/const.js b/src/const.js index bb2d171aa..18ba1602f 100644 --- a/src/const.js +++ b/src/const.js @@ -90,3 +90,9 @@ export const PERIOD_NUMBERS = Object.freeze({ }) export const DEFAULT_TIER = 'Custom Reward' + +export const TOKEN_TYPES = Object.freeze({ + CASH_TOKEN: 'Cash Token', + UTILITY_TOKEN: 'Utility Token', + VOICE_TOKEN: 'Voice Token' +}) From 5f3a45f0bcf8cc53e65d51206a88ed28027bcce1 Mon Sep 17 00:00:00 2001 From: Evgeni B Date: Fri, 15 Sep 2023 09:51:58 +0300 Subject: [PATCH 3/3] fix(step-payout): added multipliers check --- src/pages/proposals/create/StepPayout.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/proposals/create/StepPayout.vue b/src/pages/proposals/create/StepPayout.vue index 02e65eb48..a2b958bf8 100644 --- a/src/pages/proposals/create/StepPayout.vue +++ b/src/pages/proposals/create/StepPayout.vue @@ -265,13 +265,13 @@ export default { return (this.cycleDurationSec / this.daoSettings.periodDurationSec).toFixed(2) }, cashToken () { - return !this.toggle ? this.getFormatedTokenAmount(this.peg * this.$store.state.dao.settings.settings_treasuryTokenMultiplier_i, Number.MAX_VALUE) : this.getFormatedTokenAmount((this.peg * this.$store.state.dao.settings.settings_treasuryTokenMultiplier_i / this.periodsOnCycle).toFixed(2), Number.MAX_VALUE) + return !this.toggle ? this.getFormatedTokenAmount(this.peg * (this.$store.state.dao.settings.settings_treasuryTokenMultiplier_i ? this.$store.state.dao.settings.settings_treasuryTokenMultiplier_i : 1), Number.MAX_VALUE) : this.getFormatedTokenAmount((this.peg * (this.$store.state.dao.settings.settings_treasuryTokenMultiplier_i ? this.$store.state.dao.settings.settings_treasuryTokenMultiplier_i : 1) / this.periodsOnCycle).toFixed(2), Number.MAX_VALUE) }, utilityToken () { - return !this.toggle ? this.getFormatedTokenAmount(this.reward * this.$store.state.dao.settings.settings_utilityTokenMultiplier_i, Number.MAX_VALUE) : this.getFormatedTokenAmount((this.reward * this.$store.state.dao.settings.settings_utilityTokenMultiplier_i / this.periodsOnCycle).toFixed(2), Number.MAX_VALUE) + return !this.toggle ? this.getFormatedTokenAmount(this.reward * (this.$store.state.dao.settings.settings_utilityTokenMultiplier_i ? this.$store.state.dao.settings.settings_utilityTokenMultiplier_i : 1), Number.MAX_VALUE) : this.getFormatedTokenAmount((this.reward * (this.$store.state.dao.settings.settings_utilityTokenMultiplier_i ? this.$store.state.dao.settings.settings_utilityTokenMultiplier_i : 1) / this.periodsOnCycle).toFixed(2), Number.MAX_VALUE) }, voiceToken () { - return !this.toggle ? this.getFormatedTokenAmount(this.voice * this.$store.state.dao.settings.settings_voiceTokenMultiplier_i, Number.MAX_VALUE) : this.getFormatedTokenAmount((this.voice * this.$store.state.dao.settings.settings_voiceTokenMultiplier_i / this.periodsOnCycle).toFixed(2), Number.MAX_VALUE) + return !this.toggle ? this.getFormatedTokenAmount(this.voice * (this.$store.state.dao.settings.settings_voiceTokenMultiplier_i ? this.$store.state.dao.settings.settings_voiceTokenMultiplier_i : 1), Number.MAX_VALUE) : this.getFormatedTokenAmount((this.voice * (this.$store.state.dao.settings.settings_voiceTokenMultiplier_i ? this.$store.state.dao.settings.settings_voiceTokenMultiplier_i : 1) / this.periodsOnCycle).toFixed(2), Number.MAX_VALUE) }, isAssignment () { const proposalType = this.$store.state.proposals.draft.category.key