From b74f341a48ffe8d730364aa5a343df505d50477e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Venturo?= Date: Tue, 3 Dec 2024 14:34:23 -0300 Subject: [PATCH] feat: AMM (#10153) Opening in favor of https://github.com/AztecProtocol/aztec-packages/pull/8644 due to @benesjan being away on vacation, and that PR using Graphite. Work here starts from commit a404b58e7d049ee7a56310702046f03a624fd1ee, which has been squashed into 81d7607d9d551aea4d6de78ec3ff535ec5d5a29a. This is the first implementation of Uniswap v2 style AMM that provides identity privacy. The contract is a single pool for two tokens with a fixed 0.3% swap fee. Adding and removing liquidity is done proportionally to the current ratio, resulting in no price impact and therefore no fees. Swaps can be performed by specifying either the amount in or the amount out. All three operations are completed in a single transaction each by leveraging partial notes. I created https://github.com/AztecProtocol/aztec-packages/issues/10225 to track pending work. Some of the tasks in that epic are only work that arises from the AMM, but are not technically required to have a fully functioning system: this PR already achieves that. Only a happy-path end to end test is included here, since TXE currently lacks some of the features required in order to properly deal with partial notes. We should later write those as this will be a good test of TXE's capabilities and user experience, given the complexity of the setup. --- I added the e2e to be run on CI on all branches since it combines multiple complex features, and likely contains our largest transactions yet. --- aztec/src/macros/mod.nr | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aztec/src/macros/mod.nr b/aztec/src/macros/mod.nr index 924c5bc..883a202 100644 --- a/aztec/src/macros/mod.nr +++ b/aztec/src/macros/mod.nr @@ -78,9 +78,9 @@ comptime fn generate_contract_interface(m: Module) -> Quoted { $fn_stubs_quote pub fn at( - target_contract: aztec::protocol_types::address::AztecAddress + addr: aztec::protocol_types::address::AztecAddress ) -> Self { - Self { target_contract } + Self { target_contract: addr } } pub fn interface() -> Self { @@ -92,9 +92,9 @@ comptime fn generate_contract_interface(m: Module) -> Quoted { #[contract_library_method] pub fn at( - target_contract: aztec::protocol_types::address::AztecAddress + addr: aztec::protocol_types::address::AztecAddress ) -> $module_name { - $module_name { target_contract } + $module_name { target_contract: addr } } #[contract_library_method]