A local simulation environment for the Cork Protocol using the Ape Framework.
This repository contains a development and testing environment that forks the Ethereum Mainnet state to a local sandbox. Utilizing ApeWorX (Ape Framework), this project allows developers to interact with the Cork Protocol contracts in a deterministic, risk-free environment, through simple python method calls.
It is designed to:
- Fork Mainnet at a specific block height to capture the real-world state of the Cork Protocol.
- Simulate Transactions (swaps, stakes, governance votes) against the protocol without spending gas.
- Impersonate Accounts (Whales/Admin/Multisig) to test privileged functions or edge cases.
- Clone the Repository
git clone https://github.com/JoaoBarbara5/CorkSim.git
cd CorkSim- Set environment variables in compose file
in "docker-compose.yaml" set the environment variables with personal api keys:
ETHERSCAN_API_KEY: #Insert your Etherscan API key here
WEB3_ALCHEMY_PROJECT_ID: #Insert your Alchemy API key here
BITQUERY_API_KEY: #Insert your Bitquery API key here (free option expires after 30 days)- Build the Docker Image
docker compose build #only on to build on first use
docker compose up- Execute the container
in a new terminal execute the command
docker exec -it ape-test /bin/bash- Run the ape console from working directory "cork_project"
ape console --network ethereum:mainnet-fork:foundry #you can add preffered block number if needed(inside container)
- Execute the python scripts inside the ape-python console
exec(open("scripts/script_setup.py").read())- Interact with the environment by calling the python functions with set arguemnts
Example of a live market: wallet address: 0x22a709eece6ee82293e5fcdeea7ceefdefd499cd pair id: 0xd8fe1a67a9683a3f577895ea834b1711e759b490c308d25417802eb2a50a59c9