Skip to content

Commit

Permalink
Merge pull request #67 from MorpheusAIs/fix/modal-text-content
Browse files Browse the repository at this point in the history
fix/multiplier texts
  • Loading branch information
Sorizen committed Jul 25, 2024
2 parents 69581d1 + dac719f commit 4d3e940
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 35 deletions.
28 changes: 17 additions & 11 deletions src/common/modals/compositions/ChangeLockModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@
@blur="touchField('payoutStartAt')"
/>
</div>
<div class="deposit-form__buttons-wrp">
<div class="change-lock-modal__buttons-wrp">
<app-button
class="deposit-form__btn"
class="change-lock-modal__btn"
color="secondary"
:text="$t('change-lock-modal.cancel-btn')"
:disabled="isSubmitting"
@click="modal.close()"
/>
<app-button
class="deposit-form__btn"
class="change-lock-modal__btn"
:text="$t('change-lock-modal.submit-btn')"
:disabled="!isFieldsValid || isSubmitting || !form.lockPeriod"
@click="submit"
Expand All @@ -52,16 +52,16 @@
<script lang="ts" setup>
import BasicModal from '../BasicModal.vue'
import { DatetimeField } from '@/fields'
import { computed, reactive, watch, ref } from 'vue'
import { computed, reactive, ref, watch } from 'vue'
import { minValue } from '@/validators'
import { Time } from '@/utils'
import { useFormValidation } from '@/composables'
import { useFormValidation, useI18n, usePool } from '@/composables'
import { AppButton } from '@/common'
import { usePool } from '@/composables'
import { useWeb3ProvidersStore } from '@/store'
import { bus, BUS_EVENTS, getEthExplorerTxUrl, ErrorHandler } from '@/helpers'
import { config } from '@config'
import { useI18n } from '@/composables'
import { bus, BUS_EVENTS, ErrorHandler, getEthExplorerTxUrl } from '@/helpers'
import { config, NETWORK_IDS } from '@config'
import { ETHEREUM_CHAIN_IDS } from '@/enums'
import { sleep } from '@/helpers'
const emit = defineEmits<{
(e: 'update:is-shown', v: boolean): void
Expand Down Expand Up @@ -124,6 +124,12 @@ const submit = async () => {
return
}
try {
await web3ProvidersStore.provider.switchChain(
web3ProvidersStore.networkId === NETWORK_IDS.mainnet
? ETHEREUM_CHAIN_IDS.ethereum
: ETHEREUM_CHAIN_IDS.sepolia,
)
await sleep(500)
const tx =
await web3ProvidersStore.erc1967ProxyContract.signerBased.value.lockClaim(
props.poolId,
Expand Down Expand Up @@ -191,7 +197,7 @@ watch(
}
}
.deposit-form__buttons-wrp {
.change-lock-modal__buttons-wrp {
margin-top: toRem(40);
display: flex;
align-items: center;
Expand All @@ -203,7 +209,7 @@ watch(
}
}
.deposit-form .deposit-form__btn {
.change-lock-modal .change-lock-modal__btn {
min-width: toRem(200);
@include respond-to(medium) {
Expand Down
6 changes: 3 additions & 3 deletions src/composables/use-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,12 @@ export const usePool = (poolId: number) => {
const fetchExpectedMultiplier = async (lockPeriod: string) => {
try {
const multiplier =
// eslint-disable-next-line max-len
//eslint-disable-next-line max-len
await web3ProvidersStore.erc1967ProxyContract.providerBased.value.getClaimLockPeriodMultiplier(
poolId,
0,
lockPeriod || 0,
)

expectedRewardsMultiplier.value = humanizeRewards(multiplier)
} catch (error) {
ErrorHandler.processWithoutFeedback(error)
Expand Down Expand Up @@ -265,14 +264,15 @@ export const usePool = (poolId: number) => {
() => [
web3ProvidersStore.provider.selectedAddress,
web3ProvidersStore.isConnected,
web3ProvidersStore.networkId,
],
async ([newAddress, isConnected]) => {
currentUserReward.value = null
userPoolData.value = null

if (newAddress && isConnected) {
try {
await Promise.all([updateUserReward(), updateUserData()])
await Promise.all([updateUserData(), updateUserReward()])
} catch (error) {
ErrorHandler.process(error)
}
Expand Down
14 changes: 10 additions & 4 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
InMemoryCache,
NormalizedCacheObject,
} from '@apollo/client/core'
import { providers, utils } from 'ethers'
import { ethers, providers, utils } from 'ethers'
import { pickBy, mapKeys } from 'lodash'
import { LogLevelDesc } from 'loglevel'
import packageJson from '../package.json'
Expand Down Expand Up @@ -130,14 +130,17 @@ config.networksMap = {
layerZeroEndpointId: LAYER_ZERO_ENDPOINT_IDS.ethereum,
provider: new providers.FallbackProvider(
[
'https://eth.llamarpc.com',
'https://rpc.mevblocker.io',
'https://rpc.mevblocker.io',
'https://eth-pokt.nodies.app',
'https://eth.drpc.org',
'https://rpc.payload.de',
'https://eth.merkle.io',
].map((rpcUrl, idx) => ({
provider: new providers.StaticJsonRpcProvider(rpcUrl),
provider: new providers.StaticJsonRpcProvider(
rpcUrl,
ethers.providers.getNetwork(Number(ETHEREUM_CHAIN_IDS.ethereum)),
),
priority: idx,
})),
1,
Expand Down Expand Up @@ -166,7 +169,10 @@ config.networksMap = {
chainId: ETHEREUM_CHAIN_IDS.sepolia,
chainTitle: 'Ethereum Sepolia',
layerZeroEndpointId: LAYER_ZERO_ENDPOINT_IDS.sepolia,
provider: new providers.StaticJsonRpcProvider(ETHEREUM_RPC_URLS.sepolia),
provider: new providers.StaticJsonRpcProvider(
ETHEREUM_RPC_URLS.sepolia,
ethers.providers.getNetwork(Number(ETHEREUM_CHAIN_IDS.sepolia)),
),
explorerUrl: ETHEREUM_EXPLORER_URLS.sepolia,
},
l2: {
Expand Down
10 changes: 5 additions & 5 deletions src/localization/resources/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"amount-placeholder": "Enter {currency} amount",
"lock-period-placeholder": "Lock your claim until",
"cancel-btn": "Cancel",
"expected-multiplier-lbl": "Expected multiplier:",
"expected-multiplier-lbl": "Expected Power Factor:",
"submit-btn": {
"deposit": "Deposit",
"approve": "Approve"
Expand Down Expand Up @@ -136,8 +136,8 @@
"title--0": "Capital",
"subtitle--0": "Group 1"
},
"change-lock-btn": "Change lock period",
"multiplier-title": "Your reward multiplier",
"change-lock-btn": "Set lock period",
"multiplier-title": "Your Power Factor",
"total-deposits-title": "Total deposits",
"daily-reward-title": "Current daily reward",
"started-at-title": "Started at",
Expand Down Expand Up @@ -294,9 +294,9 @@
},
"change-lock-modal": {
"title": "Lock Claim",
"subtitle": "You can postpone the withdrawal of MOR tokens for a period of your choice and get increased yield. The longer the period, the higher the yield multiplier.",
"subtitle": "You can postpone the claim of MOR tokens for a period of your choice and get increased yield. The longer the period, the higher the yield power factor.",
"lock-period-placeholder": "Lock your claim until",
"expected-multiplier-title": "Expected reward multiplier:",
"expected-multiplier-title": "Expected Power Factor:",
"tx-sent-message": "The transaction was sent, you can view it in the explorer <a class=\"link\" href={explorerTxUrl} target=\"blank\" rel=\"noopener noreferrer\">here</a>",
"success-message": "The transaction was confirmed, you can view it in the explorer <a class=\"link\" href={explorerTxUrl} target=\"blank\" rel=\"noopener noreferrer\">here</a>",
"cancel-btn": "Cancel",
Expand Down
33 changes: 21 additions & 12 deletions src/pages/HomePage/views/PublicPoolView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
]"
:text="$t('home-page.public-pool-view.change-lock-btn')"
:is-loading="isInitializing || isUserDataUpdating"
:disabled="userPoolData?.deposited?.isZero()"
@click="isChangeLockModalShown = true"
/>
<p class="public-pool-view__dashboard-description">
Expand Down Expand Up @@ -165,7 +166,7 @@ const claimLockTime = computed(() => {
)
}
if (poolData.value) {
return new Time(
const lockTime = new Time(
userPoolData.value && !userPoolData.value.lastStake.isZero()
? userPoolData.value.lastStake
.add(poolData.value.withdrawLockPeriodAfterStake)
Expand All @@ -174,10 +175,28 @@ const claimLockTime = computed(() => {
.add(poolData.value.withdrawLockPeriod)
.toNumber(),
).format(DEFAULT_TIME_FORMAT)
return new Time().isAfter(lockTime) ? '-' : lockTime
}
return ''
})
const withdrawAtTime = computed(() => {
if (poolData.value) {
const withdrawTime = new Time(
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)
return new Time().isAfter(withdrawTime) ? '-' : withdrawTime
}
return '-'
})
const barIndicators = computed<InfoBarType.Indicator[]>(() => [
{
title: t('home-page.public-pool-view.total-deposits-title'),
Expand All @@ -199,17 +218,7 @@ const barIndicators = computed<InfoBarType.Indicator[]>(() => [
},
{
title: t('home-page.public-pool-view.withdraw-at-title'),
value: poolData.value
? new Time(
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)
: '',
value: withdrawAtTime.value,
note: t('home-page.public-pool-view.withdraw-at-note'),
},
{
Expand Down

0 comments on commit 4d3e940

Please sign in to comment.