Skip to content

econia-labs/amsterdam-2023-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 

Repository files navigation

Econia Workshop: Aptos Hack Holland Amsterdam Hackathon

June 5, 2023

Resources

More documentation

Repos

Pre-cleanup

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

Account setup

  1. Install the Aptos CLI, ideally through brew:

    brew install aptos
  2. Verify you are on version v2.0.0 or higher:

    aptos -h
  3. Navigate to your home directory:

    cd ~
  4. Use the CLI to initialize a new devnet user named user1

    aptos init --profile user1
  5. Type devnet when prompted for a network:

    devnet
  6. Press return when prompted for a private key:

    <return>
    
  7. Store user1's address in a shell variable, and make sure to use a leading 0x (you'll probably have to type 0x manually before you copy-paste the output from the aptos init call):

    user1=0x<copy-paste-your-address-here>
  8. Repeat steps 4 through 7 for user2, econia, and faucet profiles:

    aptos init --profile user2
    aptos init --profile econia
    aptos init --profile faucet
  9. 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
  10. Look up user1 and user2'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]
    
    
    Loading

Econia setup

  1. Navigate to a directory where you would like to download the Econia repo to:

    cd ~/Desktop
  2. 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 have git):

    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
  3. Print out the econia account address:

    echo $econia
  4. Look up the econia account's modules section using a new browser tab on the devnet explorer:

    flowchart TD
    
    econia
    
    Loading
  5. 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 the y 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
    
    Loading
  6. 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

Faucet setup

  1. Navigate to the faucet package:

    cd ../faucet
  2. Look up the faucet account's modules section using a new browser tab on the devnet explorer:

    echo $faucet
    flowchart TD
    
    faucet
    
    Loading
  3. 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
    
    Loading
  4. Mint test USDC to user1's account, generating a new CoinStore with tUSDC 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
    
    Loading

Market account registration

  1. Have user2 register an APT/tUSDC market (lot size 0.01 APT, tick size 0.001 USDC, minimum size 0.05 APT):

    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
  2. 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
  3. Deposit tUSDC to user1'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
    
    Loading

Trading

  1. Have user1 place a bid for 0.5 APT at a price of 10.50 tUSDC per APT:

    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
  2. Have user2 submit a swap sell of 0.5 APT, filling directly into a new tUSDC 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
    
    Loading

Cleanup

You'll probably want to clear out the Move dependencies to free up space on your machine:

rm -rf ~/.move

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published