Skip to content

Commit

Permalink
Merge branch 'feat/dapp-staking-v3' into feat/project-color-background
Browse files Browse the repository at this point in the history
  • Loading branch information
ayumitk committed Jan 5, 2024
2 parents 7238bc0 + 9576d94 commit 249338c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/i18n/en-US/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default {
claimRewards:
'DApp Staking V3 is coming early 2024! Make sure to claim your rewards and stay tuned for the release date.',
underDevelopmentShibuyaWarning:
'dApp Staking V3 is beta. We are adding fixes and improves everyday to get ready for the launch.',
'dApp Staking V3 is in beta. We are adding fixes and improves everyday to get ready for the launch.',
},
toast: {
transactionFailed: 'Transaction failed with error: {message}',
Expand Down
6 changes: 5 additions & 1 deletion src/staking-v3/components/Vote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,11 @@ export default defineComponent({
const canConfirm = (): boolean => {
// TODO use canStake from useDappStaking after multiple stakes will be supported.
return totalStakeAmount.value > 0;
return (
totalStakeAmount.value > 0 &&
availableToVote.value >
ethers.utils.parseEther(totalStakeAmount.value.toString()).toBigInt()
);
};
const handleDappsSelected = (dapps: Dapp[]): void => {
Expand Down
7 changes: 6 additions & 1 deletion src/staking-v3/hooks/usePeriod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ export function usePeriod() {
);

const periodCurrentDay = computed<number | undefined>(() => {
if (!protocolState.value || !constants.value) {
if (
!protocolState.value ||
!constants.value ||
!currentBlock.value ||
eraLengths.value.standardErasPerVotingPeriod === 0
) {
return undefined;
}

Expand Down
11 changes: 2 additions & 9 deletions src/staking-v3/hooks/useVotingCountdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useDappStaking } from './useDappStaking';
import { PeriodType } from '../logic';

export function useVotingCountdown() {
const { protocolState, currentBlock, eraLengths } = useDappStaking();
const { protocolState, currentBlock } = useDappStaking();
const blockTimeInSeconds = 12;

const secondsLeft = computed<number>(() => {
Expand All @@ -15,14 +15,7 @@ export function useVotingCountdown() {
return 0;
}

const blocksUntilNextEra = protocolState.value.nextEraStart - currentBlock.value;
const blocksUntilNextSubperiod =
blocksUntilNextEra +
(protocolState.value.periodInfo.nextSubperiodStartEra - protocolState.value.era - 1) *
eraLengths.value.standardEraLength;
const secondsUntilNextSubperiod = blocksUntilNextSubperiod * blockTimeInSeconds;

return secondsUntilNextSubperiod;
return (protocolState.value.nextEraStart - currentBlock.value) * blockTimeInSeconds;
});

const timeLeftFormatted = computed<string>(() => {
Expand Down

0 comments on commit 249338c

Please sign in to comment.