Skip to content

Commit

Permalink
fix(tokens): add correct mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
arsenijesavic committed Sep 15, 2023
1 parent d25ec76 commit 466f16f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
11 changes: 3 additions & 8 deletions src/components/dao/settings-tokens.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { mapActions, mapGetters } from 'vuex'
import { validation } from '~/mixins/validation'
import currency from 'src/data/currency.json'
import map from '~/utils/map'
import { MIN_TOKEN_MULTIPLIER, MAX_TOKEN_MULTIPLIER } from '~/const'
const mapCurrency = (currency) => (_) => ({
label: `${currency[_]?.symbol} - ${currency[_]?.name}`,
Expand Down Expand Up @@ -87,10 +86,6 @@ export default {
await this.createTokens({
...this.tokens,
utilityTokenMultiplier: map(this.tokens.utilityTokenMultiplier, 0, 100, MIN_TOKEN_MULTIPLIER, MAX_TOKEN_MULTIPLIER),
voiceTokenMultiplier: map(this.tokens.voiceTokenMultiplier, 0, 100, MIN_TOKEN_MULTIPLIER, MAX_TOKEN_MULTIPLIER),
treasuryTokenMultiplier: map(this.tokens.treasuryTokenMultiplier, 0, 100, MIN_TOKEN_MULTIPLIER, MAX_TOKEN_MULTIPLIER),
voiceDecayPercent: map(this.tokens.voiceDecayPercent, 0, 100, MIN_DECAY, MAX_DECAY)
})
}
Expand All @@ -113,20 +108,20 @@ export default {
treasuryName: this.daoSettings.settings_pegTokenName_s || treasurySymbol,
treasurySymbol,
treasuryDigits: treasuryDigits.split('.')[1].length, // 1.0, 1.00, 1.000
treasuryTokenMultiplier: this.daoSettings.settings_treasuryTokenMultiplier_i,
treasuryTokenMultiplier: this.daoSettings.settings_treasuryTokenMultiplier_i / 100,
// // Utility token
utilityName: this.daoSettings.settings_rewardTokenName_s || utilitySymbol,
utilitySymbol,
utilityDigits: utilityDigits.split('.')[1].length, // 1.0, 1.00, 1.000, // 1.0, 1.00, 1.000
utilityTokenMultiplier: this.daoSettings.settings_utilityTokenMultiplier_i,
utilityTokenMultiplier: this.daoSettings.settings_utilityTokenMultiplier_i / 100,
utilityAmount: parseInt(utilityAmount) === -1 ? '∞' : utilityAmount, // i.e 100000 or -1 for infinite supply
// // Voice token
voiceName: voiceSymbol,
voiceSymbol,
voiceDigits: voiceDigits.split('.')[1].length,
voiceTokenMultiplier: this.daoSettings.settings_voiceTokenMultiplier_i,
voiceTokenMultiplier: this.daoSettings.settings_voiceTokenMultiplier_i / 100,
voiceDecayPeriod: this.daoSettings.settings_voiceTokenDecayPeriod_i,
voiceDecayPercent: map(this.daoSettings.settings_voiceTokenDecayPerPeriodX10M_i, MIN_DECAY, MAX_DECAY, 0, 100)
Expand Down
6 changes: 3 additions & 3 deletions src/store/dao/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ export const createTokens = async function ({ state, rootState }, data) {
{ label: 'peg_token_name', value: ['string', data?.treasuryName] }, // -> Optional, if omitted, name will be taken from reward_token symbol
{ label: 'peg_token', value: ['asset', `${parseFloat(1).toFixed(data?.treasuryDigits)} ${data?.treasurySymbol}`] },
{ label: 'treasury_currency', value: ['string', data?.treasuryCurrency.value] },
{ label: 'treasury_token_multiplier', value: ['int64', data?.treasuryTokenMultiplier] }
{ label: 'treasury_token_multiplier', value: ['int64', data?.treasuryTokenMultiplier * 100] }
],

// utility token
Expand All @@ -1069,15 +1069,15 @@ export const createTokens = async function ({ state, rootState }, data) {
{ label: 'reward_token', value: ['asset', `${parseFloat(1).toFixed(data?.utilityDigits)} ${data?.utilitySymbol}`] },
{ label: 'reward_token_max_supply', value: ['asset', `${parseFloat(-1).toFixed(data?.utilityDigits)} ${data?.utilitySymbol}`] },
{ label: 'reward_to_peg_ratio', value: ['asset', `${parseFloat(1).toFixed(data?.treasuryDigits)} ${data?.treasurySymbol}`] },
{ label: 'utility_token_multiplier', value: ['int64', data?.utilityTokenMultiplier] }
{ label: 'utility_token_multiplier', value: ['int64', data?.utilityTokenMultiplier * 100] }
],

// voice token
[
{ label: 'content_group_label', value: ['string', 'voice_details'] },
{ label: 'voice_token_decay_period', value: ['int64', data?.voiceDecayPeriod] },
{ label: 'voice_token_decay_per_period_x10M', value: ['int64', data?.voiceDecayPercent] },
{ label: 'voice_token_multiplier', value: ['int64', data?.voiceTokenMultiplier] }
{ label: 'voice_token_multiplier', value: ['int64', data?.voiceTokenMultiplier * 100] }
]
]
}
Expand Down

0 comments on commit 466f16f

Please sign in to comment.