This repository contains the Move implementation of Aftermath's Automated Market Maker (AMM). Aftermath's AMM allows for the creation of Pool
s with (1) sizes between two to eight supported Coin
s and with (2) granular weighting. Each Pool
can also support one of two different invariant functions: geometric mean (i.e., uncorrelated) or stable. For more detailed information, please refer to our documentation.
- Sui 1.45.0 or later
Important
Sui 1.45.X implicitly adds the system packages as dependencies, prior version swill not be able to build this package as it requires the Sui
dependency.
packages/amm
contains the core package: AftermathAmm
. This package defines the Pool
struct and its associated api. The API is defined below.
The geometric-mean-market package provides the create_pool_n_assets
functions which allow you to create Pools of size 2 - 7.
sui client call --function swap --module interface --package $POOLS 30000 --args <POOL_ADDRESS> <COIN_IN_ID> <AMOUNT_OUT_MIN> --type_args <LP_TYPE> <COIN_TYPE_IN> <COIN_TYPE_OUT>
sui client call --function single_asset_deposit --module interface --package $POOLS 30000 --args <POOL_ADDRESS> <COIN_ID> <LP_MINT_MIN> --type_args <LP_TYPE> <COIN_TYPE>
sui client call --function single_asset_withdraw --module interface --package $POOLS 30000 --args <POOL_ADDRESS> <LP_COIN_ID> <AMOUNT_OUT_MIN> --type_args <LP_TYPE> <COIN_TYPE>
You can deposit N Coins
into a Pool of size M where (N <= M) by calling the multi_asset_deposit_n_asset
functions.
Here is an example of depositing 2 assets into the USDC_USDT_DAI Pool:
sui client call --function multi_asset_deposit_2_assets --module interface --package $POOLS 30000 --args $USDC_USDT_DAI <COIN_1_ID> <COIN_2_ID> <LP_MINT_MIN> --type_args <LP_TYPE> <COIN_1_TYPE> <COIN_2_TYPE>
Similarly, you can withdraw N Coins
from a Pool of size M where (N <= M) by calling the multi_asset_withdraw_n_asset
functions and supplying your desired withdraw value for each of the Pool's underlying Coins.
Here is a similar example of withdrawing 1_000_000 AF and 5_000_000 of the USDC_USDT_DAI_LP from the WETH<>WBTC<>AF<>[USDC_USDT_DAI_LP] Pool:
sui client call --function multi_asset_withdraw_2_assets --module interface --package $POOLS --gas-budget 30000 --args $WETH_WBTC_AF_LP <LP_COIN_ID> \[0,0,1000000,5000000\] --type_args 0x2e06a2ab02dea22681c1857a227abb1ce78e7df7::create_balancer_pools::LP4 $AF 0x3ba5117c44156d0cdf54b6d30935f3dfb54f5c62::pool::LP<0x2e06a2ab02dea22681c1857a227abb1ce78e7df7::create_balancer_pools::LP3>