Skip to content

Commit

Permalink
Merge pull request #61 from MorpheusAIs/fix/claim-data
Browse files Browse the repository at this point in the history
Fix/claim data view
  • Loading branch information
Sorizen committed Jul 24, 2024
2 parents 4159e8a + a19f09b commit 86a0429
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 22 deletions.
12 changes: 6 additions & 6 deletions src/composables/use-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import { useTimestamp } from '@vueuse/core'
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
import { ethers } from 'ethers'

const MULTIPLIER_SCALE = 25 //digits

const MULTIPLIER_SCALE = 21 //digits
const REWARDS_DIVIDER = 10000
export const usePool = (poolId: number) => {
let _currentUserRewardUpdateIntervalId: NodeJS.Timeout

const currentUserReward = ref<BigNumber | null>(null)
const dailyReward = ref<BigNumber | null>(null)
const poolData = ref<Erc1967ProxyType.PoolData | null>(null)
const userPoolData = ref<Erc1967ProxyType.UserData | null>(null)
const rewardsMultiplier = ref(1)
const rewardsMultiplier = ref('1')

const isInitializing = ref(false)
const isUserDataUpdating = ref(false)
Expand Down Expand Up @@ -177,9 +177,9 @@ export const usePool = (poolId: number) => {
const scaleFactor = ethers.BigNumber.from(10).pow(MULTIPLIER_SCALE)
const scaledNumber = response.div(scaleFactor)

rewardsMultiplier.value = Number(
parseFloat(scaledNumber.toString()).toFixed(2),
)
rewardsMultiplier.value = (
scaledNumber.toNumber() / REWARDS_DIVIDER
).toFixed(4)
} catch (e) {
ErrorHandler.processWithoutFeedback(e)
}
Expand Down
15 changes: 10 additions & 5 deletions src/fields/DatetimeField/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ import type { Options } from 'flatpickr/dist/types/options'
import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue'
import arrowIconHTML from '@/assets/icons/chevron-down-icon.svg?raw'
enum POSITION {
bottom = 'bottom',
leftBottom = 'bottom-left',
}
type POSITION = 'bottom' | 'bottom-left' | 'bottom-right' | 'top'
const emit = defineEmits<{
(event: 'update:model-value', value: string): void
Expand All @@ -76,7 +73,7 @@ const props = withDefaults(
}>(),
{
disabled: false,
position: POSITION.leftBottom,
position: 'bottom-right',
},
)
Expand Down Expand Up @@ -116,6 +113,7 @@ const initFlatpickr = (): void => {
onChange: dates => {
if (!dates.length) return
emit('update:model-value', String(dates[0].getTime() / 1000))
isOpen.value = false
},
}
Expand Down Expand Up @@ -218,6 +216,13 @@ $z-index: 1;
position: static;
}
&--top {
bottom: 120%;
top: auto;
right: 50%;
transform: translateX(50%);
}
&--bottom {
top: 120%;
right: 50%;
Expand Down
1 change: 1 addition & 0 deletions src/forms/DepositForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
</input-field>
<datetime-field
v-model="form.lockPeriod"
position="top"
:placeholder="$t(`deposit-form.lock-period-placeholder`)"
:error-message="getFieldErrorMessage('lockPeriod')"
:is-loading="isInitializing"
Expand Down
3 changes: 2 additions & 1 deletion src/pages/HomePage/components/ZeroPoolDescription.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ const { t } = useI18n()
const listItems = computed<string[]>(() => [
t('zero-pool-description.list.1'),
t('zero-pool-description.list.2'),
t('zero-pool-description.list.3'),
// TODO: HIDDEN BEFORE PROD
// t('zero-pool-description.list.3'),
t('zero-pool-description.list.4'),
])
</script>
Expand Down
24 changes: 14 additions & 10 deletions src/pages/HomePage/views/PublicPoolView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const claimLockTime = computed(() => {
: poolData.value.payoutStart
.add(poolData.value.withdrawLockPeriod)
.toNumber(),
)
).format(DEFAULT_TIME_FORMAT)
}
return ''
})
Expand All @@ -184,18 +184,22 @@ const barIndicators = computed<InfoBarType.Indicator[]>(() => [
},
{
title: t('home-page.public-pool-view.withdraw-at-title'),
value: claimLockTime.value.toString(),
note: t('home-page.public-pool-view.withdraw-at-note'),
},
{
title: t('home-page.public-pool-view.claim-at-title'),
value: poolData.value
? new Time(
poolData.value.payoutStart
.add(poolData.value.claimLockPeriod)
.toNumber(),
userPoolData.value && !userPoolData.value.lastStake.isZero()
? userPoolData.value.lastStake
.add(poolData.value.withdrawLockPeriodAfterStake)
.toNumber()
: poolData.value.payoutStart
.add(poolData.value.withdrawLockPeriod)
.toNumber(),
).format(DEFAULT_TIME_FORMAT)
: '',
note: t('home-page.public-pool-view.withdraw-at-note'),
},
{
title: t('home-page.public-pool-view.claim-at-title'),
value: claimLockTime.value.toString(),
note: t('home-page.public-pool-view.claim-at-note'),
},
])
Expand All @@ -217,7 +221,7 @@ const dashboardIndicators = computed<InfoDashboardType.Indicator[]>(() => [
},
{
title: t('home-page.public-pool-view.multiplier-title'),
value: `${rewardsMultiplier.value}X`,
value: `x${rewardsMultiplier.value}`,
},
])
</script>
Expand Down

0 comments on commit 86a0429

Please sign in to comment.