From 73c91bbbe44bf9597ccecb2f58f95ac1290db41f Mon Sep 17 00:00:00 2001 From: toniocodo Date: Thu, 25 Jul 2024 09:28:16 +0200 Subject: [PATCH] feat: time based delay check, switch width fix --- .../oeth/src/redeem/components/ClaimForm.tsx | 12 +++++++--- libs/defi/oeth/src/redeem/hooks.ts | 23 ++++++++----------- .../components/src/Switches/SliderSwitch.tsx | 1 + 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/libs/defi/oeth/src/redeem/components/ClaimForm.tsx b/libs/defi/oeth/src/redeem/components/ClaimForm.tsx index a6664ac9e..fce1f9a77 100644 --- a/libs/defi/oeth/src/redeem/components/ClaimForm.tsx +++ b/libs/defi/oeth/src/redeem/components/ClaimForm.tsx @@ -57,7 +57,7 @@ export const ClaimForm = (props: StackProps) => { : { contract: contracts.mainnet.OETHVault, functionName: 'claimWithdrawals', - args: selectedClaimIds, + args: [selectedClaimIds], }; const selectedAmount = useMemo( @@ -101,7 +101,7 @@ export const ClaimForm = (props: StackProps) => { }; return ( - + { spacing={1} p={2} justifyContent="space-between" + {...rest} > } label={ - + {format(amt, getFormatPrecision(amt))} diff --git a/libs/defi/oeth/src/redeem/hooks.ts b/libs/defi/oeth/src/redeem/hooks.ts index b5ca6dcf9..e7c736ca7 100644 --- a/libs/defi/oeth/src/redeem/hooks.ts +++ b/libs/defi/oeth/src/redeem/hooks.ts @@ -3,8 +3,8 @@ import { useMemo } from 'react'; import { contracts } from '@origin/shared/contracts'; import { isFulfilled, ZERO_ADDRESS } from '@origin/shared/utils'; import { useQuery, useQueryClient } from '@tanstack/react-query'; -import { getBlock, readContract } from '@wagmi/core'; -import { addMinutes, fromUnixTime, isAfter } from 'date-fns'; +import { readContract } from '@wagmi/core'; +import { addMinutes, isAfter } from 'date-fns'; import { useSearchParams } from 'react-router-dom'; import { useAccount, useConfig } from 'wagmi'; @@ -69,27 +69,24 @@ export const useWithdrawalRequests = ( address: address ?? ZERO_ADDRESS, }), }), - getBlock(config, { - blockTag: 'finalized', - chainId: contracts.mainnet.OETHVault.chainId, - }), ]); const queueData = isFulfilled(res[0]) ? res[0].value : null; const requests = isFulfilled(res[1]) ? (res[1].value?.oethWithdrawalRequests ?? []) : []; - const block = isFulfilled(res[2]) ? res[2].value : null; - + console.log(queueData); return requests.map((r) => { + console.log( + r.queued, + queueData?.claimable, + BigInt(r.queued) <= BigInt(queueData?.claimable ?? 0), + ); const claimable = !r.claimed && BigInt(r.queued) <= BigInt(queueData?.claimable ?? 0) && isAfter( - new Date(r.timestamp), - addMinutes( - fromUnixTime(Number(block?.timestamp ?? 0)), - WITHDRAW_DELAY + 1, - ), + new Date(), + addMinutes(new Date(r.timestamp), WITHDRAW_DELAY + 1), ); return { diff --git a/libs/shared/components/src/Switches/SliderSwitch.tsx b/libs/shared/components/src/Switches/SliderSwitch.tsx index 807908706..8026293bb 100644 --- a/libs/shared/components/src/Switches/SliderSwitch.tsx +++ b/libs/shared/components/src/Switches/SliderSwitch.tsx @@ -81,6 +81,7 @@ export const SliderSwitch = ({ zIndex: 1, top: 0, left: 0, + right: 0, width: itemsWidth[idx], height: 1, transform: `translateX(${translateX}px)`,