Skip to content

Commit

Permalink
feat: update withdraw delay
Browse files Browse the repository at this point in the history
  • Loading branch information
toniocodo committed Jul 23, 2024
1 parent 062caa4 commit 15ad061
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions libs/defi/oeth/src/redeem/components/RedeemActionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -124,6 +126,7 @@ export const RedeemActionCard = ({
intl.formatMessage(
(route as SwapRoute<OethRedeemAction, Meta>)?.meta
?.waitTime ?? { defaultMessage: '~1 min' },
{ WITHDRAW_DELAY },
)
)
}
Expand Down
6 changes: 5 additions & 1 deletion libs/defi/oeth/src/redeem/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<OethRedeemAction, Meta>[] = [
Expand Down Expand Up @@ -35,7 +37,9 @@ export const redeemRoutes: SwapRoute<OethRedeemAction, Meta>[] = [
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',
},
},
Expand Down
8 changes: 6 additions & 2 deletions libs/defi/oeth/src/redeem/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;

Expand All @@ -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 {
Expand Down

0 comments on commit 15ad061

Please sign in to comment.