Skip to content

Commit

Permalink
feat: show locking power relies on duration and token amount
Browse files Browse the repository at this point in the history
  • Loading branch information
galvin96 committed Dec 31, 2024
1 parent 3871175 commit c74d02e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
14 changes: 12 additions & 2 deletions src/pages/DexV2/Lock/components/DurationSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import { Box, Flex } from "rebass"
import styled from "styled-components"
import { TYPE } from "theme"
import { useLock } from "../LockProvider"
import { WEEK } from "../constants"
import { FOUR_YEARS_IN_SECONDS, WEEK } from "../constants"
import { formatAmount } from "utils/formatCurrencyAmount"

const DurationSlider: React.FC = () => {
const {
userInput,
duration,
setDuration,
} = useLock()
Expand All @@ -33,12 +35,14 @@ const DurationSlider: React.FC = () => {
}, ]

const weekToShow = Math.round(duration / WEEK)
const durationLabel = `${weekToShow} ${weekToShow > 1 ? 'weeks' : 'week'}`
const votingPower = +userInput * duration / FOUR_YEARS_IN_SECONDS

return (
<Box>
<Flex justifyContent="space-between" alignItems="center" mb={2}>
<TYPE.subHeader1 color='blue5'>Lock Time</TYPE.subHeader1>
<TYPE.label>{weekToShow} {weekToShow > 1 ? 'weeks' : 'week'}</TYPE.label>
<TYPE.label>{durationLabel}</TYPE.label>
</Flex>

<StyledSlider
Expand All @@ -63,6 +67,12 @@ const DurationSlider: React.FC = () => {
</TYPE.subHeader1>
))}
</Flex>

<Box mt={4}>
<TYPE.body3>
Locking for <strong>{durationLabel}</strong> for {formatAmount(votingPower, 2)} veIXS voting power.
</TYPE.body3>
</Box>
</Box>
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/DexV2/Lock/components/LockContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const LockContent: React.FC = () => {
const votingEscrowContract = useVotingEscrowContract()
const addTransaction = useTransactionAdder()

const [approvalState, approve, refreshAllowance] = useAllowance(
const [approvalState, approve] = useAllowance(
IXS_ADDRESS[chainId],
utils.parseUnits(userInput || '0', currency?.decimals),
VOTING_ESCROW_ADDRESS[chainId]
Expand Down
3 changes: 2 additions & 1 deletion src/pages/DexV2/Lock/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

export const WEEK = 604800
export const WEEK = 604800
export const FOUR_YEARS_IN_SECONDS = 126230400

0 comments on commit c74d02e

Please sign in to comment.