Async Swap AMM
- AsyncCSMM - hook contract
- Router - add liquidity, swap & fill async orders
- Live Demo Frontend
- Video Walkthrough
- Transaction Ordering rules walkthorugh video
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
- This will allow you to use
--account anvilin the deploys scripts in.dev/start_script.sh
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:
- Deploy local PoolManger
./script/00_DeployPoolManager.s.sol- Deploy Hook & Router contracts
./script/01_DeployHook.s.sol- Initialize a pool with your hook attached
./script/02_InitilizePool.s.sol- Add liqudity to previously initialized pool
./script/03_AddLiquidity.s.sol- Submit an async swap transaction through custom router
./script/04_Swap.s.sol- 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: