Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Tests Format Docs

Async Swap AMM

Install

To install dependencies in all our packages in packages/*

bun install

Install foundry dependencies (v4-periphery)

forge install

Setup

[!TIP] We suggest you set up local anvil account with cast.

cast wallet import --mnemonic "test test test test test test test test test test test junk" anvil

Run local anvil node with Unichain fork

anvil --fork-url https://unichain.drpc.org
# or simulate block mining and finality
anvil --block-time 13

Local Deployment

Run deployment script

./dev/start_script.sh # scripts that you use --account setup of you choice

[!NOTE]

The start scripts will do the following:

  1. Deploy local PoolManger ./script/00_DeployPoolManager.s.sol
  2. Deploy Hook & Router contracts ./script/01_DeployHook.s.sol
  3. Initialize a pool with your hook attached ./script/02_InitilizePool.s.sol
  4. Add liqudity to previously initialized pool ./script/03_AddLiquidity.s.sol
  5. Submit an async swap transaction through custom router ./script/04_Swap.s.sol
  6. Fill previously submitted swap transaction ./script/05_ExecuteOrder.s.sol

Testing

Run tests

forge test -vvvv

Huff tests:

# sender is poolManager address
hnc src/AsyncSwap.huff test --sender 0x0000000000000000000000000000000000000000

Offchain Indexer

Start local indexer

bun run dev

[!Tip]

  • If you need typescript abi for your contracts on frontend or indexer use this script ./dev/generateAbi.sh
./dev/generateAbi.sh

Go to http://localhost:42069 to query orders from hook events

Docs

View documentation:

forge doc --serve --port 4000 --watch

Acknowledgment

Thanks to Atrium Academy, over the past 2 months we build this project during Uniswap Hook incubator program.

Team Socials: