Skip to content

Conversation

@JackHamer09
Copy link
Member

  • Fix withdrawals, withdrawal finalization status, and finalization
  • Uses new SDK for all of these actions
  • Curretntly finalization gas limit is hardcoded since finalization estimation methods are missing

@JackHamer09
Copy link
Member Author

#295

@github-actions
Copy link

github-actions bot commented Nov 13, 2025

Visit the preview URL for this PR (updated for commit 4c8e131):

(expires Thu, 20 Nov 2025 17:47:24 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 9fec89135cb37683b693c65a4a317d1b3c49cd82

@JackHamer09
Copy link
Member Author

#294

@JackHamer09 JackHamer09 changed the title fix: withdrawals and finalization fix: zksyncos withdrawals and finalization Nov 13, 2025
dutterbutter
dutterbutter previously approved these changes Nov 13, 2025
Copy link

@dutterbutter dutterbutter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose you could maintain createEthersClient / createEthersSdk similar to wallet store instead of initializing as frequent but more of an improvement suggestion.

const quote = await sdk.withdrawals.quote({
to: params!.to,
token: params!.tokenAddress,
amount: 1n, // TODO: estimation fails if we pass actual user balance

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would you pass user balance here and not the provided amount the user wants to withdrawal?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it worked on previous protocol version, we were basically estimating max possible fee by passing max possible amount. This would allow to not have to recalculate on amount value change (slightly better UX, less waiting). But not it fails because it needs value to be (balance - total fee).

Comment on lines +74 to +77
const transaction = await sdk.withdrawals.finalize(transactionInfo.value!.transactionHash as Hash);
if (!transaction.receipt) {
throw new Error("Finalization transaction failed");
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest using the try-variant (tryFinalize) here but more a preference.

completed: isFinalized,
withdrawalFinalizationAvailable: isFinalized,
completed: status.phase === "FINALIZED",
withdrawalFinalizationAvailable: ["FINALIZE_FAILED", "READY_TO_FINALIZE"].includes(status.phase),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is including FINALIZE_FAILED intentional here?

Copy link
Member Author

@JackHamer09 JackHamer09 Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know if its failed its possible to retry if it has failed before?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know if its failed its possible to retry if it has failed before

If finalizeDeposit tx failed you can try again, the status of it will remain READY_TO_FINALIZE.

Comment on lines +5 to +7
export const L2_BASE_TOKEN_ADDRESS = utils.ETH_ADDRESS_IN_CONTRACTS as Address;
export const L2_NATIVE_TOKEN_VAULT_ADDRESS = utils.L2_NATIVE_TOKEN_VAULT_ADDRESS as Address;
export const L2_ASSET_ROUTER_ADDRESS = utils.L2_ASSET_ROUTER_ADDRESS as Address;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can get these address from the sdk as well fyi

return;
}

const [price, limit] = await Promise.all([

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need price? For zksync os chains we are 1559 complaint which does not use price? Is this just here for legacy?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, legacy code. I really didn't have time to rewrite everything properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants