diff --git a/components/common/Timer.vue b/components/common/Timer.vue index 80f9b3f91..0b2e2e606 100644 --- a/components/common/Timer.vue +++ b/components/common/Timer.vue @@ -49,7 +49,7 @@ const formatTimeDiff = (diff: number, onlyDays = false): string => { if (props.format === "human-readable") { if (onlyDays) { - return `~ ${day} day${day !== 1 ? "s" : ""}` + return `~ ${day + 1} day${day + 1 !== 1 ? "s" : ""}`; } let formattedString = ""; if (hours > 0) formattedString += `${day} day ${hours} hour${hours > 1 ? "s" : ""} `; diff --git a/store/zksync/transactionStatus.ts b/store/zksync/transactionStatus.ts index bf36dd6b8..d85eb85fb 100644 --- a/store/zksync/transactionStatus.ts +++ b/store/zksync/transactionStatus.ts @@ -44,7 +44,7 @@ export const getEstmatdDepositDelay = (networkKey: string): number => { return ESTIMATED_DEPOSIT_DELAY_SECONDARY; } }; -export const WITHDRAWAL_DELAY = 14 * 24 * 60 * 60 * 1000; // 7 * 24 hours +export const WITHDRAWAL_DELAY = 7 * 24 * 60 * 60 * 1000; // 7 * 24 hours export type Address = Hash; export type ForwardL2Request = { gateway: Address; diff --git a/store/zksync/withdrawals.ts b/store/zksync/withdrawals.ts index e2cd29d25..abae0758a 100644 --- a/store/zksync/withdrawals.ts +++ b/store/zksync/withdrawals.ts @@ -33,7 +33,7 @@ export const useZkSyncWithdrawalsStore = defineStore("zkSyncWithdrawals", () => return new Promise((resolve) => setTimeout(resolve, ms)); } const setStatus = async (obj: { transactionHash: ethers.utils.BytesLike; status: string; gateway: string }) => { - const { primaryNetwork, zkSyncNetworks,getNetworkInfo } = useNetworks(); + const { primaryNetwork, zkSyncNetworks, getNetworkInfo } = useNetworks(); const { selectedNetwork } = storeToRefs(useNetworkStore()); let provider: Provider | undefined; @@ -82,7 +82,7 @@ export const useZkSyncWithdrawalsStore = defineStore("zkSyncWithdrawals", () => ); const withdrawals = transfers.items.filter((e) => e.type === "withdrawal" && e.token && e.amount); for (const withdrawal of withdrawals) { - const { primaryNetwork, zkSyncNetworks,getNetworkInfo } = useNetworks(); + const { primaryNetwork, zkSyncNetworks, getNetworkInfo } = useNetworks(); const transactionFromStorage = transactionStatusStore.getTransaction(withdrawal.transactionHash); if (transactionFromStorage) { @@ -156,7 +156,8 @@ export const useZkSyncWithdrawalsStore = defineStore("zkSyncWithdrawals", () => }, info: { expectedCompleteTimestamp: new Date( - new Date(withdrawalTransfer.timestamp).getTime() + WITHDRAWAL_DELAY + new Date(withdrawalTransfer.timestamp).getTime() + + getEstimateWithdrawalDelayDays(withdrawalTransfer.timestamp) * 24 * 3600 * 1000 ).toISOString(), completed: withdrawal.status === "Finalized", withdrawalFinalizationAvailable: transactionDetails.status === "verified", diff --git a/utils/constants.ts b/utils/constants.ts index e1124eaa4..268e4a81d 100644 --- a/utils/constants.ts +++ b/utils/constants.ts @@ -9,7 +9,13 @@ export const ETH_TOKEN: Token = { iconUrl: "/img/eth.svg", }; -export const WITHDRAWAL_DELAY_DAYS = 14; +export const WITHDRAWAL_DELAY_DAYS = 7; + +// Last syncL2Requests tx on blast: Apr-20-2024 09:45:31 AM +UTC; +// deposit before this time , estimate withdraw time is 14 days; +// deposit after this time, estimate withdraw time is : +// ( 14 days - (deposit time - this time)) < 7days ? 7days : ( 14 days - (deposit time - this time)); +export const LAST_BLAST_SYNCL2_TIME = 1713606331000; export const MERGE_TOKENS = [ { diff --git a/utils/helpers.ts b/utils/helpers.ts index c566cc3e5..c04cc2669 100644 --- a/utils/helpers.ts +++ b/utils/helpers.ts @@ -54,3 +54,13 @@ export async function retry(func: () => Promise, options: RetryOptions = { } } } + +export const getEstimateWithdrawalDelayDays = (txTime: string | number) => { + const transactionTime = new Date(txTime).getTime(); + if (transactionTime < LAST_BLAST_SYNCL2_TIME) { + return 14; + } else { + const gap = Math.ceil(14 - (transactionTime - LAST_BLAST_SYNCL2_TIME) / (24 * 3600 * 1000)); + return gap >= 8 ? gap : 8; + } +}; diff --git a/views/transactions/Withdraw.vue b/views/transactions/Withdraw.vue index 20501d273..2dc9dcd50 100644 --- a/views/transactions/Withdraw.vue +++ b/views/transactions/Withdraw.vue @@ -201,11 +201,12 @@ class="mb-block-padding-1/2 sm:mb-block-gap" >

- You will be able to claim your withdrawal only after a {{ WITHDRAWAL_DELAY_DAYS }}-day withdrawal delay. + You will be able to claim your withdrawal only after a {{ displayEstimateWithdrawalDelayDays }}-day + withdrawal delay.

- You will receive funds only after a {{ WITHDRAWAL_DELAY_DAYS }}-day withdrawal delay. + You will receive funds only after a {{ displayEstimateWithdrawalDelayDays }}-day withdrawal delay.

@@ -504,20 +505,13 @@ import { useOnboardStore } from "@/store/onboard"; import { usePreferencesStore } from "@/store/preferences"; import { useZkSyncProviderStore } from "@/store/zksync/provider"; import { useZkSyncTokensStore } from "@/store/zksync/tokens"; -import { WITHDRAWAL_DELAY } from "@/store/zksync/transactionStatus"; import { useZkSyncTransactionStatusStore } from "@/store/zksync/transactionStatus"; import { useZkSyncTransfersHistoryStore } from "@/store/zksync/transfersHistory"; import { useZkSyncWalletStore } from "@/store/zksync/wallet"; -import { - ETH_TOKEN, - isMergeToken, - isSupportedMergeToken, - MergeTokenContractUrl, - WITHDRAWAL_DELAY_DAYS, -} from "@/utils/constants"; +import { ETH_TOKEN, isMergeToken, isSupportedMergeToken } from "@/utils/constants"; import { ZKSYNC_WITHDRAWAL_DELAY } from "@/utils/doc-links"; import { checksumAddress, decimalToBigNumber, formatRawTokenPrice, parseTokenAmount } from "@/utils/formatters"; -import { calculateFee } from "@/utils/helpers"; +import { calculateFee, getEstimateWithdrawalDelayDays } from "@/utils/helpers"; import { silentRouterChange } from "@/utils/helpers"; import { TransitionAlertScaleInOutTransition, TransitionOpacity } from "@/utils/transitions"; import TransferSubmitted from "@/views/transactions/TransferSubmitted.vue"; @@ -612,6 +606,8 @@ const fromNetworkSelected = (networkKey?: string) => { const step = ref<"form" | "withdrawal-finalization-warning" | "confirm" | "submitted">("form"); const destination = computed(() => (props.type === "transfer" ? destinations.value.nova : destinations.value.arbitrum)); +const displayEstimateWithdrawalDelayDays = getEstimateWithdrawalDelayDays(Date.now()); + const availableTokens = computed(() => { if (!tokens.value) return []; if (props.type === "withdrawal") { @@ -1084,7 +1080,9 @@ const makeTransaction = async () => { info: { expectedCompleteTimestamp: transaction.value?.type === "withdrawal" - ? new Date(new Date().getTime() + WITHDRAWAL_DELAY).toISOString() + ? new Date( + new Date().getTime() + getEstimateWithdrawalDelayDays(Date.now()) * 24 * 60 * 60 * 1000 + ).toISOString() : undefined, completed: false, }, diff --git a/views/transactions/WithdrawalSubmitted.vue b/views/transactions/WithdrawalSubmitted.vue index f2e856b4c..c2fa0521b 100644 --- a/views/transactions/WithdrawalSubmitted.vue +++ b/views/transactions/WithdrawalSubmitted.vue @@ -11,8 +11,7 @@