Skip to content

Commit

Permalink
feat: AMM (#10153)
Browse files Browse the repository at this point in the history
Opening in favor of
AztecProtocol/aztec-packages#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 AztecProtocol/aztec-packages#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.
  • Loading branch information
nventuro authored and AztecBot committed Dec 4, 2024
1 parent 5cb9b9a commit b74f341
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions aztec/src/macros/mod.nr
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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]
Expand Down

0 comments on commit b74f341

Please sign in to comment.