Skip to content

Axis-Fi/axis-periphery

Repository files navigation

axis-periphery

This repository contains non-core contracts from the Axis Finance system.

Developer Guide

Axis is built in Solidity using Foundry as the development and test environment. The following commands are available for development:

First-Run

pnpm install

Build

forge build

Test

The test suite can be run with:

pnpm run test

Address Mismatch

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.

Format

Combines forge fmt and solhint

pnpm run lint

To run linting on all files (including tests and scripts):

pnpm run lint:all

Scripts

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

Deployments are listed in the env.json file and periodically updated in the Axis documentation.

Dependencies

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.

Updating Dependencies

When updating the version of a dependency provided through soldeer, the following must be performed:

  1. Update the version of the dependency in foundry.toml or through forge soldeer
  2. Re-run the installation script
  3. 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 axis-core

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:

  1. Update the version in the axis-core entry for the fs_permissions key in foundry.toml
  2. Update the version mentioned in _loadEnv() in the WithEnvironment contract

Packaging

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published