This repository contains the core smart contracts for the Affine Protocol.
The primary license for Affine Protocol is the Business Source License 1.1, see LICENSE.
The Protocol currently controls access to these two multi-sig addresses:
- Polygon: 0x47C43be6e8B0a171eab00e42226aE2d1cEFC00fB
- Ethereum: 0x67Ec3Bb25a5DB6eB7Ba74f6C0b2bA193A3983FB8
The master branch is what is currently deployed. The last audit was conducted against the contents of the branch audit-v4.
See instructions for installation here.
- Install nvm with these instructions. Then run
nvm use- Install yarn with
npm install -g yarn- Install the dependencies:
yarn installInstall slither with these instructions. Install solc-select. Update your solc version with:
solc-select install 0.8.16
solc-select use 0.8.16Install pre-commit hooks: yarn husky install
Create a .env file in the root of this repo. It should contain the same variables seen in .env.example.
Compile the smart contracts:
$ yarn buildRun the solidity tests
$ yarn testUpdate all gas snapshots
$ yarn snapRun solhint:
$ yarn lintRun slither:
$ slither .To run a script run yarn script <script>. Pass in the ethereum and polygon networks you want to use with the -eth and -p flags. The two network names will be in the ETH_NETWORK and POLYGON_NETWORK environment variables. In the script, use hre.changeNetwork to change the current network. If run without the --no-fork flag yarn script will bring up two anvil nodes, one which forks the selected ethereum network, and one which forks the selected polygon network. If run with --relay then OZ Relayer will be used to send any transactions.
To run the rebalance script against testnets:
$ yarn script scripts/rebalance.ts -eth goerli -p mumbai --no-forkTestnet: yarn ts-node scripts/deploy.ts -l <1 or 2> -t
Mainnet: yarn ts-node scripts/deploy.ts -l <1 or 2>
Add -b to actually deploy the contracts
You can find documentation in the docs/ folder.