Skip to content

Commit

Permalink
update for estimate withdray delay time
Browse files Browse the repository at this point in the history
  • Loading branch information
MickWang committed Apr 22, 2024
1 parent 9889827 commit 54c2960
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion store/zksync/transactionStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export async function retry<T>(func: () => Promise<T>, options: RetryOptions = {
}
}

export const getEstimateWithdrawalDelayDays = (txTime: string) => {
export const getEstimateWithdrawalDelayDays = (txTime: string | number) => {
const transactionTime = new Date(txTime).getTime();
if (transactionTime < LAST_BLAST_SYNCL2_TIME) {
return 14;
Expand Down
22 changes: 10 additions & 12 deletions views/transactions/Withdraw.vue
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,12 @@
class="mb-block-padding-1/2 sm:mb-block-gap"
>
<p v-if="withdrawalManualFinalizationRequired">
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.
<!-- <a class="underline underline-offset-2" :href="ZKSYNC_WITHDRAWAL_DELAY" target="_blank">Learn more</a> -->
</p>
<p v-else>
You will receive funds only after a {{ WITHDRAWAL_DELAY_DAYS }}-day withdrawal delay.
You will receive funds only after a {{ displayEstimateWithdrawalDelayDays }}-day withdrawal delay.
<!-- <a class="underline underline-offset-2" :href="ZKSYNC_WITHDRAWAL_DELAY" target="_blank">Learn more</a> -->
</p>
</CommonAlert>
Expand Down Expand Up @@ -487,20 +488,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";
Expand Down Expand Up @@ -595,6 +589,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") {
Expand Down Expand Up @@ -1067,7 +1063,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,
},
Expand Down
2 changes: 0 additions & 2 deletions views/transactions/WithdrawalSubmitted.vue
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ import { useNetworkStore } from "@/store/network";
import { useOnboardStore } from "@/store/onboard";
import { useZkSyncProviderStore } from "@/store/zksync/provider";
import { useZkSyncTransactionStatusStore } from "@/store/zksync/transactionStatus";
import { LAST_BLAST_SYNCL2_TIME, WITHDRAWAL_DELAY_DAYS } from "@/utils/constants";
import { getEstimateWithdrawalDelayDays } from "@/utils/helpers";
const props = defineProps({
Expand Down

0 comments on commit 54c2960

Please sign in to comment.