Skip to content

AftermathFinance/move-amm-public

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Aftermath colored logo

move-amm-public

License Documentation Audit

Aftermath AMM implementation written in Sui Move

Overview

This repository contains the Move implementation of Aftermath's Automated Market Maker (AMM). Aftermath's AMM allows for the creation of Pools with (1) sizes between two to eight supported Coins 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.

Getting Started

Requirements

  • 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.

Aftermath AMM

packages/amm contains the core package: AftermathAmm. This package defines the Pool struct and its associated api. The API is defined below.

Features

Pool Creation

The geometric-mean-market package provides the create_pool_n_assets functions which allow you to create Pools of size 2 - 7.

Swap

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>

Single-Asset Deposit

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>

Single-Asset Withdraw

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>

Multi-Asset Deposit

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>

Multi-Asset Withdraw

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>

About

Contains the implementation of Aftermath's AMM for the Sui Blockchain.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages