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

Tracking issue: Trading on Uniswap L1 from L2 #843

Closed
8 tasks done
LHerskind opened this issue Jun 13, 2023 · 1 comment
Closed
8 tasks done

Tracking issue: Trading on Uniswap L1 from L2 #843

LHerskind opened this issue Jun 13, 2023 · 1 comment
Labels
T-tracking Type: Tracking Issue. This contains tasklists.

Comments

@LHerskind
Copy link
Contributor

LHerskind commented Jun 13, 2023

Goal: To perform a swap on L1 Uniswap that is initiated from L2 using assets from L2 where the output assets are bridged back into L2 after execution. Support both private and public variants (public can be extended to support Aztec connect like functionality).

The series of high-level actions required for such a "feat":

  1. Deploy a Dai token portal (similar to TokenPortal), but where the noir part also support an open version of withdraw and deposit, along with a shield and unshield moving funds between private and public domains. Should also support designated caller.
  2. Deploy a WETH token portal similar to above.
  3. Deploy a Uniswap portal (similar to UniswapPortal) that allow execution and enforced ordering with designated caller.
  4. Approve Dai token portal to pull funds using dai::approve
  5. Deposit Dai into the rollup
  6. Claim Dai on L2, in private or public depending on test case.
  7. Initiate a swap of Dai to Weth on L2, this should create a bundle that:
    1. Make a call to withdraws Dai from L2 with the Uniswap portal as the recipient and designated caller. This will emit an L2 -> L1 message from the L2 Dai contract.
    2. Initiate a swap of Dai to Weth on the Uniswap Portal. This will emit an L2 -> L1 message from the Uniswap contract. The message specifies input asset, output asset, minimum amount out, amount in, the Aztec address of the recipient and a secretHash, all provided by the user.
  8. Anyone can on the Uniswap portal execute swap with sufficient arguments to:
    1. call InputAssetPortal::withdraw to consume the first message, and receive InputAsset (Dai)
    2. consume the second message from the outbox
    3. execute a swap on Uniswap using the content of the second message
    4. call weth::approve to approve the Weth to the Weth portal
    5. take the output from the trade, and call OutputAssetPortal::deposit using values from the content of the second message, such that Weth is pulled into the portal and it emits an L1 -> L2 message
  9. The user can claim Weth on L2, in private or public depending on test case.
  10. If 9 is public, shield the funds, if 9 is private unshield the funds.

Visualization:
uniswap

This covers a single individual trading on Uniswap from within L2. If building both public and private flows we should cover the following features:

  • Private functions consuming L1 -> L2 messages for moving funds into the rollup
  • Private functions emitting L2 -> L1 messages for moving funds into the rollup
  • Public functions consuming L1 -> L2 messages for moving funds into the rollup
  • Public functions emitting L2 -> L1 messages for moving funds into the rollup
  • Public functions calling private functions (shielding)
  • Private functions calling public functions (unshielding)
  • Private functions calling private functions (swapping from private)
  • Public functions calling public functions (swapping from public)

The tasks at the top of my head:

For the private execution:

Private Flow

Preview Give feedback
  1. T-feature-request
    rahul-kothari
  2. T-feature-request
    rahul-kothari
  3. 1 of 1
    T-feature-request
    rahul-kothari
  4. rahul-kothari

Public Flow

Preview Give feedback
  1. T-feature-request
    rahul-kothari
  2. T-feature-request
    LHerskind

Syntax Improvements

Preview Give feedback
  1. A-internal-devex
    Maddiaa0
  2. A-internal-devex
    Maddiaa0
@LHerskind
Copy link
Contributor Author

Track in #2167 instead for the AC functionality and #2493 to address failure cases.

@github-project-automation github-project-automation bot moved this from Todo to Done in A3 Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-tracking Type: Tracking Issue. This contains tasklists.
Projects
Archived in project
Development

No branches or pull requests

1 participant