AffineLabs / contracts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Affine Protocol

This repository contains the core smart contracts for the Affine Protocol.

Licensing

The primary license for Affine Protocol is the Business Source License 1.1, see LICENSE.

Governance

The Protocol currently controls access to these two multi-sig addresses:

  • Polygon: 0x47C43be6e8B0a171eab00e42226aE2d1cEFC00fB
  • Ethereum: 0x67Ec3Bb25a5DB6eB7Ba74f6C0b2bA193A3983FB8

Branches and Deployment

The master branch is what is currently deployed. The last audit was conducted against the contents of the branch audit-v4.

Pre Requisites

Foundry

See instructions for installation here.

Update the version with foundryup -v nightly-ca67d15f4abd46394b324c50e21e66f306a1162d.

Hardhat

nvm use
  • Install yarn with
npm install -g yarn
  • Install the dependencies:
yarn install

Slither

Install slither with these instructions. Install solc-select. Update your solc version with:

solc-select install 0.8.16
solc-select use 0.8.16

Husky

Install pre-commit hooks: yarn husky install

Usage

Create a .env file in the root of this repo. It should contain the same variables seen in .env.example.

Compile

Compile the smart contracts:

$ yarn build

Test

Run the solidity tests

$ yarn test

Update all gas snapshots

$ yarn snap

Lint/Analyze

Run solhint:

$ yarn lint

Run slither:

$ slither .

Running a Hardhat Script

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-fork

Deploying the Contracts

Testnet: 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

Documentation

You can find documentation in the docs/ folder.

About

License:Other


Languages

Language:Solidity 97.8%Language:TypeScript 2.1%Language:JavaScript 0.1%Language:Handlebars 0.0%Language:Shell 0.0%