June 5, 2023
- This walkthrough is on GitHub at https://github.com/econia-labs/amsterdam-2023-demo!
- Pro tip: Search "github econia amsterdam" in your favorite search engine
- Econia Labs' Teach Yourself Move on Aptos guide
- Econia Documentation
- Econia Move DocGen files
- Econia API docs
- Aptos Documentation
- Econia
- Econia indexer (
aptos-core
fork) - Econia Labs'
optivanty
tool - Econia reference front end
- Econia Move scraps
If you've used the aptos
CLI before to initialize user profiles, you'll probably want to save a copy of your config file before trying out this workshop:
mv ~/.aptos/config.yaml ~/Desktop/old_config.yaml
-
Install the Aptos CLI, ideally through
brew
:brew install aptos
-
Verify you are on version
v2.0.0
or higher:aptos -h
-
Navigate to your home directory:
cd ~
-
Use the CLI to initialize a new devnet user named
user1
aptos init --profile user1
-
Type
devnet
when prompted for a network:devnet
-
Press
return
when prompted for a private key:<return>
-
Store
user1
's address in a shell variable, and make sure to use a leading0x
(you'll probably have to type0x
manually before you copy-paste the output from theaptos init
call):user1=0x<copy-paste-your-address-here>
-
Repeat steps 4 through 7 for
user2
,econia
, andfaucet
profiles:aptos init --profile user2
aptos init --profile econia
aptos init --profile faucet
-
Then verify you have stored each address as a shell variable with a leading
0x
:echo $user1 echo $user2 echo $econia echo $faucet
The output should look like:
0x445953fa27471d07027d2d8f0a87fc18e8f9d05bb9a7d673a2269ec2616267aa 0xd572f6c2c9e7df6be78bdfff15bc72d56339b6226f3857d60eef1b9f99a2275f 0xd4ba9f1c60a94f9a8a1349f89267c532195912392938c89f7cd91359aad28cee 0xaaa85c7db25681d9f200e8ddd2bd10eeade20e8af69ae717063ea3405ef04fd2
-
Look up
user1
anduser2
's account resources on the devnet explorer using separate browser tabs, since you will want to look at each one later:flowchart TD user1 --> account1[Account] user1 --> apt_coinstore1[CoinStore] apt_coinstore1 --> apt1[Aptos Coin] user2 --> account2[Account] user2 --> apt_coinstore2[CoinStore] apt_coinstore2 --> apt2[Aptos Coin]
-
Navigate to a directory where you would like to download the Econia repo to:
cd ~/Desktop
-
Clone the Econia repo, checkout the
amsterdam-2023-demo
release, and navigate to the Econia Move package (note you can download the release from the link manually if you don't havegit
):mkdir econia_demo cd econia_demo git clone https://github.com/econia-labs/econia.git cd econia git checkout amsterdam-2023-demo cd src/move/econia
-
Print out the
econia
account address:echo $econia
-
Look up the
econia
account's modules section using a new browser tab on the devnet explorer:flowchart TD econia
-
Publish Econia under the
econia
account (note this might take awhile if you haven't already downloaded the Aptos repo, which is a dependency). Use they
key to accept the transaction once the simulator has provided gas estimates:aptos move publish \ --named-addresses econia=$econia \ --included-artifacts none \ --profile econia
flowchart TD econia --> Econia:::new Econia --> assets:::new Econia --> avl_queue:::new Econia --> incentives:::new Econia --> market:::new Econia --> registry:::new Econia --> resource_account:::new Econia --> tablist:::new Econia --> user:::new classDef new fill:green
-
Lower the fee to register a market (this is used to mitigate denial-of-service attacks on mainnet):
aptos move run \ --function-id $econia::incentives::update_incentives \ --type-args 0x1::aptos_coin::AptosCoin \ --args \ u64:1 \ u64:1 \ u64:1 \ u64:5000 \ u64:"[[10000,0,7],[8333,1,6],[7692,2,5],[7143,3,4],[6667,4,3],[6250,5,2],[5882,6,1]]" \ --profile econia
-
Navigate to the faucet package:
cd ../faucet
-
Look up the
faucet
account's modules section using a new browser tab on the devnet explorer:echo $faucet
flowchart TD faucet
-
Publish the faucet under the
faucet
account:aptos move publish \ --named-addresses econia=$econia,econia_faucet=$faucet \ --profile faucet
flowchart TD faucet_addr[faucet] --> EconiaFaucet:::new EconiaFaucet --> faucet:::new EconiaFaucet --> test_usdc:::new EconiaFaucet --> test_eth:::new classDef new fill:green
-
Mint test USDC to
user1
's account, generating a newCoinStore
withtUSDC
inside:aptos move run \ --function-id $faucet::faucet::mint \ --args u64:1234567890 \ --type-args $faucet::test_usdc::TestUSDC \ --profile user1
flowchart TD user1 --> account[Account] user1 --> apt_coinstore[CoinStore] apt_coinstore --> apt[Aptos Coin] user1 --> usdc_coinstore[CoinStore]:::new usdc_coinstore --> usdc[Test USDC]:::new classDef new fill:green
-
Have
user2
register anAPT
/tUSDC
market (lot size 0.01APT
, tick size 0.001USDC
, minimum size 0.05APT
):aptos move run \ --function-id \ $econia::market::register_market_base_coin_from_coinstore \ --type-args \ 0x1::aptos_coin::AptosCoin \ $faucet::test_usdc::TestUSDC \ 0x1::aptos_coin::AptosCoin \ --args \ u64:1000000 \ u64:1000 \ u64:5 \ --profile user2
-
Have
user1
register a market account:aptos move run \ --function-id \ $econia::user::register_market_account \ --type-args \ 0x1::aptos_coin::AptosCoin \ $faucet::test_usdc::TestUSDC \ --args \ u64:1 \ u64:0 \ --profile user1
-
Deposit
tUSDC
touser1
's market account:aptos move run \ --function-id \ $econia::user::deposit_from_coinstore \ --type-args $faucet::test_usdc::TestUSDC \ --args \ u64:1 \ u64:0 \ u64:1234567890 \ --profile user1
flowchart TD user1 --> account[Account] user1 --> apt_coinstore[CoinStore] apt_coinstore --> apt[Aptos Coin] user1 --> usdc_coinstore[CoinStore] usdc_coinstore --> usdc[Test USDC] user1 --> market_account[Market account]:::new market_account --> usdcma[Test USDC]:::new classDef new fill:green
-
Have
user1
place a bid for 0.5APT
at a price of 10.50tUSDC
perAPT
:aptos move run \ --function-id \ $econia::market::place_limit_order_user_entry \ --type-args \ 0x1::aptos_coin::AptosCoin \ $faucet::test_usdc::TestUSDC \ --args \ u64:1 \ address:"0x0" \ bool:false \ u64:5 \ u64:105 \ u8:0 \ u8:0 \ --profile user1
-
Have
user2
submit a swap sell of 0.5APT
, filling directly into a newtUSDC
coinstore:aptos move run \ --function-id \ $econia::market::swap_between_coinstores_entry \ --type-args \ 0x1::aptos_coin::AptosCoin \ $faucet::test_usdc::TestUSDC \ --args \ u64:1 \ address:"0x0" \ bool:true \ u64:0 \ u64:50000000 \ u64:0 \ u64:124567890 \ u64:0 \ --profile user2
flowchart TD user2 --> account[Account] user2 --> apt_coinstore[CoinStore] apt_coinstore --> apt[Aptos Coin] user2 --> tusdc_coinstore[CoinStore]:::new tusdc_coinstore --> tusdc[Test USDC]:::new classDef new fill:green
You'll probably want to clear out the Move dependencies to free up space on your machine:
rm -rf ~/.move