Skip to content

Commit

Permalink
require more than 6 months on lock
Browse files Browse the repository at this point in the history
  • Loading branch information
jaderiverstokes committed Dec 16, 2024
1 parent d35a3a4 commit 64448ff
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions ui/pages/withdraw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ export default function Withdraw() {
!VMOONEYLockLoading && setHasLock(VMOONEYLock && VMOONEYLock[0] != 0)
}, [VMOONEYLock, VMOONEYLockLoading, userAddress])

const [hasMoreThanSixMonths, setHasMoreThanSixMonths] =
useState<boolean>(false)
const sixMonths = 6 * 30 * 24 * 60 * 60 * 1000
useEffect(() => {
!VMOONEYLockLoading &&
setHasMoreThanSixMonths(
VMOONEYLock &&
VMOONEYLock[1] != 0 &&
BigNumber.from(+new Date() + sixMonths).lte(VMOONEYLock[1] * 1000)
)
}, [VMOONEYLock, VMOONEYLockLoading, userAddress])

const handleWithdraw = async () => {
try {
await mooneyContract?.call('approve', [
Expand Down Expand Up @@ -105,11 +117,13 @@ export default function Withdraw() {
>
<Asset
name="vMOONEY"
amount={String((Number(withdrawable) / MOONEY_DECIMALS).toFixed(2))}
amount={String(
(Number(withdrawable) / MOONEY_DECIMALS).toFixed(2)
)}
usd=""
/>
</section>
{userAddress && hasLock ? (
{userAddress && hasLock && hasMoreThanSixMonths ? (
<StandardButton
className="gradient-2 rounded-full"
onClick={handleWithdraw}
Expand All @@ -122,7 +136,7 @@ export default function Withdraw() {
className="gradient-2 rounded-full"
link={`/lock`}
>
Lock MOONEY
{hasLock ? 'Extend Lock' : 'Lock MOONEY'}
</StandardButton>
)}
</div>
Expand Down

0 comments on commit 64448ff

Please sign in to comment.