From 15ad061a4483fce5649063540b116d60073310d3 Mon Sep 17 00:00:00 2001 From: toniocodo Date: Tue, 23 Jul 2024 14:58:12 +0200 Subject: [PATCH] feat: update withdraw delay --- libs/defi/oeth/src/redeem/components/RedeemActionCard.tsx | 3 +++ libs/defi/oeth/src/redeem/constants.ts | 6 +++++- libs/defi/oeth/src/redeem/hooks.ts | 8 ++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/libs/defi/oeth/src/redeem/components/RedeemActionCard.tsx b/libs/defi/oeth/src/redeem/components/RedeemActionCard.tsx index c9dd6b5a3..574781841 100644 --- a/libs/defi/oeth/src/redeem/components/RedeemActionCard.tsx +++ b/libs/defi/oeth/src/redeem/components/RedeemActionCard.tsx @@ -6,6 +6,8 @@ import { isNilOrEmpty } from '@origin/shared/utils'; import { format, from } from 'dnum'; import { useIntl } from 'react-intl'; +import { WITHDRAW_DELAY } from '../constants'; + import type { CardProps, TypographyProps } from '@mui/material'; import type { ValueLabelProps } from '@origin/shared/components'; import type { SwapRoute } from '@origin/shared/providers'; @@ -124,6 +126,7 @@ export const RedeemActionCard = ({ intl.formatMessage( (route as SwapRoute)?.meta ?.waitTime ?? { defaultMessage: '~1 min' }, + { WITHDRAW_DELAY }, ) ) } diff --git a/libs/defi/oeth/src/redeem/constants.ts b/libs/defi/oeth/src/redeem/constants.ts index 45309f004..31d81a092 100644 --- a/libs/defi/oeth/src/redeem/constants.ts +++ b/libs/defi/oeth/src/redeem/constants.ts @@ -6,6 +6,8 @@ import type { SwapRoute } from '@origin/shared/providers'; import type { Meta, OethRedeemAction } from './types'; +export const WITHDRAW_DELAY = 10; // minutes + export const GAS_BUFFER = 10n; // 10% export const redeemRoutes: SwapRoute[] = [ @@ -35,7 +37,9 @@ export const redeemRoutes: SwapRoute[] = [ action: 'redeem-vault-async', meta: { icon: OETH, - waitTime: defineMessage({ defaultMessage: '~30 min - few days' }), + waitTime: defineMessage({ + defaultMessage: `~{WITHDRAW_DELAY} min - few days`, + }), waitTimeColor: 'warning.main', }, }, diff --git a/libs/defi/oeth/src/redeem/hooks.ts b/libs/defi/oeth/src/redeem/hooks.ts index a122f2243..15d7ee199 100644 --- a/libs/defi/oeth/src/redeem/hooks.ts +++ b/libs/defi/oeth/src/redeem/hooks.ts @@ -8,6 +8,7 @@ import { addMinutes, fromUnixTime, isAfter } from 'date-fns'; import { useSearchParams } from 'react-router-dom'; import { useAccount, useConfig } from 'wagmi'; +import { WITHDRAW_DELAY } from './constants'; import { useWithdrawalRequestsQuery } from './queries.generated'; import type { HexAddress } from '@origin/shared/utils'; @@ -75,7 +76,7 @@ export const useWithdrawalRequests = ( ]); const queueData = isFulfilled(res[0]) ? res[0].value : null; const requests = isFulfilled(res[1]) - ? res[1].value?.oethWithdrawalRequests ?? [] + ? (res[1].value?.oethWithdrawalRequests ?? []) : []; const block = isFulfilled(res[2]) ? res[2].value : null; @@ -85,7 +86,10 @@ export const useWithdrawalRequests = ( BigInt(r.queued) <= BigInt(queueData?.claimable ?? 0) && isAfter( new Date(r.timestamp), - addMinutes(fromUnixTime(Number(block?.timestamp ?? 0)), 30), + addMinutes( + fromUnixTime(Number(block?.timestamp ?? 0)), + WITHDRAW_DELAY, + ), ); return {