This repository contains non-core contracts from the Axis Finance system.
Axis is built in Solidity using Foundry as the development and test environment. The following commands are available for development:
pnpm install
forge build
The test suite can be run with:
pnpm run test
Many of the contracts (e.g. callbacks) require a specific address prefix or have a deterministic address. If tests are failing for this reason, the cause is usually one of:
- The code of a callback contract has been changed
- This requires re-generating the salt for the contract. See the test_salts.sh script.
- There has been a change to the dependencies under
/lib
. The dependencies affect the build output, so any changes will affect the bytecode generated by the Solidity compiler.- If the submodule change was inadvertent, this can be fixed by running
pnpm install
to reset the changes. - In some cases, such as the
g-uni-v1-core
dependency, installing npm packages will result in the remappings being changed. It is best to remove the dependency's respective dependencies in order to fix this. - If the change to dependencies and invalidation of salts is expected, then new salts must be generated. In some cases (such as Uniswap V2 and V3 factories), the new addresses must be recorded in the
Constants.sol
file.
- If the submodule change was inadvertent, this can be fixed by running
Combines forge fmt
and solhint
pnpm run lint
To run linting on all files (including tests and scripts):
pnpm run lint:all
Scripts are written in Solidity using Foundry and are divided into deploy
, salts
and ops
scripts. Specific scripts are written for individual actions and can be found in the scripts
directory along with shell scripts to run them.
Deployments are listed in the env.json file and periodically updated in the Axis documentation.
soldeer is used as the dependency manager, as it solves many of the problems inherent in forge's use of git submodules. Soldeer is integrated into forge
, so should not require any additional installations.
NOTE: The import path of each dependency is versioned. This ensures that any changes to the dependency version result in clear errors to highlight the potentially-breaking change.
When updating the version of a dependency provided through soldeer, the following must be performed:
- Update the version of the dependency in
foundry.toml
or throughforge soldeer
- Re-run the installation script
- If the version number has changed:
- Change the existing entry in remappings.txt to point to the new dependency version
- Update imports to use the new remapping
Updating the version of the axis-core
dependency is a special case, as some files are accessed directly and bypass remappings. Perform the following after following the steps above:
- Update the version in the
axis-core
entry for thefs_permissions
key in foundry.toml - Update the version mentioned in
_loadEnv()
in the WithEnvironment contract
To publish a new package version to soldeer, run the following:
pnpm run publish <version>
On first run, this requires authentication with soldeer: soldeer login
The CHANGELOG file should also be updated.