Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uniswap: L2 to L1 to L2 #873

Merged
merged 7 commits into from
Jun 21, 2023
Merged

Uniswap: L2 to L1 to L2 #873

merged 7 commits into from
Jun 21, 2023

Conversation

rahul-kothari
Copy link
Contributor

@rahul-kothari rahul-kothari commented Jun 16, 2023

Description

Y'all personal aztec connect is here!!
Close #875 (builds on #843)

Goal -> Deposit WETH into L2 and then swap to DAI using L1 Uniswap i.e.

  1. Deploy WETH, DAI and Uniswap Portal contracts respectively (on L1 and L2)
  2. Deposit WETH to L2 (using familiar L1 to L2 messaging)
  3. Create an L2 to L1 message to withdraw WETH to the UniswapPortal. Also create an L2 to L1 message to signal that I want to swap WETH to DAI to my address (latter is necessary to ensure no one can change params and execute the swap)
  4. User now calls the Uniswap portal which consumes the two messages, executes the swap and then sends a L1->L2 message to mint DAI on L2 back to the user!
  5. Mint the DAI on L2 to the right user!

Some things were updated to make it all work:

  • Update MAX_ARGS in a noir function to 16!
  • Archiver sets lastProcessedBlockNumber to config.searchStartBlock - this ensures that we skip processing blocks based on what the config wants! Useful when forking mainnet (like we have to) and only process blocks from current block.
  • The above test can only run in a fork of mainnet. (Same is true for the solidity tests) so that we can use uniswap. For this to run in CI, appropriate modifications have been made
  • Create a noir contract (for uniswap portal) that takes in the input asset (DAI), sends message to withdraw it to L1 (so L1 uniswap can execute a trade) and builds the L2 to L1 swap() message.
  • create uniswap portal solidity contract which can consume DAI from its portal, consume a swap() message request from L2, execute the swap and then push the swapped asset (here WETH) to its portal so it can be minted on L
  • A loooong script in E2E that does the flow explained above

Checklist:

  • I have reviewed my diff in github, line by line.
  • Every change is related to the PR description.
  • I have linked this pull request to the issue(s) that it resolves.
  • There are no unexpected formatting changes, superfluous debug logs, or commented-out code.
  • The branch has been merged or rebased against the head of its merge target.
  • I'm happy for the PR to be merged at the reviewer's next convenience.

@LHerskind LHerskind self-requested a review June 16, 2023 21:24
@rahul-kothari rahul-kothari force-pushed the rk/uniswap_l1l2 branch 5 times, most recently from 57e0983 to b92a4e5 Compare June 19, 2023 15:37
@rahul-kothari rahul-kothari marked this pull request as ready for review June 19, 2023 15:48
@rahul-kothari rahul-kothari force-pushed the rk/uniswap_l1l2 branch 3 times, most recently from 5e7c6cf to ab0ca0c Compare June 19, 2023 16:37
Copy link
Contributor

@LHerskind LHerskind left a comment

Choose a reason for hiding this comment

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

Added some nits, otherwise good. If you create the extra issue for cancellations on uniswap portal

l1-contracts/test/portals/UniswapPortal.sol Outdated Show resolved Hide resolved
l1-contracts/test/portals/UniswapPortal.t.sol Outdated Show resolved Hide resolved
l1-contracts/test/portals/UniswapPortal.t.sol Outdated Show resolved Hide resolved
l1-contracts/test/portals/UniswapPortal.t.sol Show resolved Hide resolved
l1-contracts/test/portals/UniswapPortal.sol Outdated Show resolved Hide resolved
@rahul-kothari rahul-kothari force-pushed the rk/uniswap_l1l2 branch 3 times, most recently from 9d6898a to e98d14b Compare June 20, 2023 13:55
@rahul-kothari rahul-kothari requested a review from LHerskind June 20, 2023 13:56
rahul-kothari and others added 6 commits June 20, 2023 15:38
@rahul-kothari rahul-kothari force-pushed the rk/uniswap_l1l2 branch 3 times, most recently from 79fd692 to c6b5712 Compare June 20, 2023 16:25
@rahul-kothari rahul-kothari merged commit db7183f into master Jun 21, 2023
@rahul-kothari rahul-kothari deleted the rk/uniswap_l1l2 branch June 21, 2023 09:34
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.

feat: Uniswap trade private flow
2 participants