Skip to content

Commit

Permalink
fix datetime autofill (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sorizen authored Jul 30, 2024
1 parent 6907b0d commit a8bfe73
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
18 changes: 6 additions & 12 deletions src/common/modals/compositions/ChangeLockModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,6 @@ const clearFields = () => {
form.lockPeriod = ''
}
const init = () => {
if (!props.isShown) {
return
}
form.lockPeriod = new Time().isAfter(
userPoolData.value?.claimLockEnd?.toString() ?? 0,
)
? ''
: userPoolData.value?.claimLockEnd?.toString() ?? ''
}
watch(
() => [
props.poolId,
Expand All @@ -194,7 +183,12 @@ watch(
{ immediate: true },
)
watch(() => props.isShown, init)
watch(
() => props.isShown,
() => {
form.lockPeriod = String(userPoolData.value?.claimLockEnd.toNumber() || '')
},
)
</script>

<style lang="scss" scoped>
Expand Down
8 changes: 7 additions & 1 deletion src/composables/use-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { type BigNumber, type Erc1967ProxyType } from '@/types'
import { useTimestamp } from '@vueuse/core'
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
import { ethers } from 'ethers'
import { Time } from '@distributedlab/tools'

const MULTIPLIER_SCALE = 21 //digits
const REWARDS_DIVIDER = 10000
Expand Down Expand Up @@ -157,11 +158,16 @@ export const usePool = (poolId: number) => {

const fetchExpectedMultiplier = async (lockPeriod: string) => {
try {
const lockStart = new Time().isAfter(
userPoolData.value?.claimLockStart.toString(),
)
? new Time().timestamp
: userPoolData.value?.claimLockStart.toString() ?? 0
const multiplier =
//eslint-disable-next-line max-len
await web3ProvidersStore.erc1967ProxyContract.providerBased.value.getClaimLockPeriodMultiplier(
poolId,
0,
lockStart,
lockPeriod || 0,
)
expectedRewardsMultiplier.value = humanizeRewards(multiplier)
Expand Down
7 changes: 4 additions & 3 deletions src/forms/DepositForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,8 @@ const allowances = reactive<Record<CURRENCIES, BigNumber | null>>({
})
const { t } = useI18n()
const { expectedRewardsMultiplier, fetchExpectedMultiplier } = usePool(
props.poolId,
)
const { expectedRewardsMultiplier, fetchExpectedMultiplier, userPoolData } =
usePool(props.poolId)
const web3ProvidersStore = useWeb3ProvidersStore()
const action = computed<ACTIONS>(() => {
Expand Down Expand Up @@ -305,6 +304,8 @@ const init = async (): Promise<void> => {
ErrorHandler.process(error)
}
form.lockPeriod = String(userPoolData.value?.claimLockEnd.toNumber() || '')
isInitializing.value = false
}
Expand Down

0 comments on commit a8bfe73

Please sign in to comment.