-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from Axis-Fi/baseline-v2-dtl
Baseline V2 DTL
- Loading branch information
Showing
16 changed files
with
169 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,6 @@ | ||
# axis-utils | ||
|
||
This repository contains utility scripts and contracts related to the [Axis system](https://axis.finance/). This includes: | ||
This monorepo contains two packages: | ||
|
||
- Example scripts (to accompany our [developer guides](https://axis.finance/developer/)) | ||
- TODO: callback salt generation scripts | ||
|
||
## Requirements | ||
|
||
- [foundry](https://getfoundry.sh/) | ||
|
||
## Usage | ||
|
||
### Install Dependencies | ||
|
||
```shell | ||
pnpm install | ||
``` | ||
|
||
### Build | ||
|
||
```shell | ||
forge build | ||
``` | ||
|
||
### Linting | ||
|
||
```shell | ||
pnpm run lint | ||
``` | ||
- [axis-utils](packages/axis-utils/) | ||
- [oz-merkle-tree](packages/oz-merkle-tree/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Chain names based on: https://github.com/alloy-rs/chains/blob/main/src/named.rs | ||
CHAIN=CHANGEME | ||
RPC_URL=CHANGEME | ||
ETHERSCAN_API_KEY=CHANGEME | ||
|
||
DEPLOYER_PRIVATE_KEY=CHANGEME | ||
DEPLOYER_ADDRESS=CHANGEME | ||
|
||
# Set to override the default verifier URL for the chain | ||
#VERIFIER_URL= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# axis-utils | ||
|
||
This package in the monorepo contains: | ||
|
||
- Example scripts (to accompany our [developer guides](https://axis.finance/developer/)) | ||
- Scripts for testing installations of the Axis Finance protocol | ||
|
||
## Developer Guide | ||
|
||
### Requirements | ||
|
||
- [foundry](https://getfoundry.sh/) | ||
|
||
### Usage | ||
|
||
#### Install Dependencies | ||
|
||
```shell | ||
pnpm install | ||
``` | ||
|
||
#### Build | ||
|
||
```shell | ||
forge build | ||
``` | ||
|
||
#### Linting | ||
|
||
```shell | ||
pnpm run lint | ||
``` | ||
|
||
### Dependencies | ||
|
||
[soldeer](https://soldeer.xyz/) 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](#install-dependencies) | ||
3. If the version number has changed: | ||
- Change the existing entry in [remappings.txt](remappings.txt) to point to the new dependency version | ||
- Update imports to use the new remapping | ||
|
||
#### Updating axis-core or axis-periphery | ||
|
||
Updating the version of the `axis-core` or `axis-periphery` dependencies is a special case, as some files are accessed directly and bypass remappings. Perform the following after following the [steps above](#updating-dependencies): | ||
|
||
1. Update the version in the `axis-core` or `axis-periphery` entry (as appropriate) for the `fs_permissions` key in [foundry.toml](foundry.toml) | ||
2. Update the version mentioned in `_loadEnv()` in the [WithEnvironment](script/WithEnvironment.s.sol) contract |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.19; | ||
|
||
// Scripting libraries | ||
import {Script, console2} from "@forge-std-1.9.1/Script.sol"; | ||
import {stdJson} from "@forge-std-1.9.1/StdJson.sol"; | ||
|
||
abstract contract WithEnvironment is Script { | ||
using stdJson for string; | ||
|
||
string public chain; | ||
string public envAxisCore; | ||
string public envAxisPeriphery; | ||
|
||
function _loadEnv(string calldata chain_) internal { | ||
chain = chain_; | ||
console2.log("Using chain:", chain_); | ||
|
||
// Load environment file | ||
envAxisCore = vm.readFile("dependencies/axis-core-1.0.0/script/env.json"); | ||
envAxisPeriphery = vm.readFile("dependencies/axis-periphery-0.9.0/script/env.json"); | ||
} | ||
|
||
/// @notice Get address from environment file | ||
/// @dev First checks in axis-periphery's environment file, then in axis-core's environment file | ||
/// | ||
/// @param key_ The key to look up in the environment file | ||
/// @return address The address from the environment file, or the zero address | ||
function _envAddress(string memory key_) internal view returns (address) { | ||
console2.log(" Checking in axis-periphery/env.json"); | ||
string memory fullKey = string.concat(".current.", chain, ".", key_); | ||
address addr; | ||
bool keyExists = vm.keyExists(envAxisPeriphery, fullKey); | ||
|
||
if (keyExists) { | ||
addr = envAxisPeriphery.readAddress(fullKey); | ||
console2.log(" %s: %s (from axis-periphery/env.json)", key_, addr); | ||
} else { | ||
keyExists = vm.keyExists(envAxisCore, fullKey); | ||
|
||
if (keyExists) { | ||
addr = envAxisCore.readAddress(fullKey); | ||
console2.log(" %s: %s (from axis-core/env.json)", key_, addr); | ||
} else { | ||
console2.log(" %s: *** NOT FOUND ***", key_); | ||
} | ||
} | ||
|
||
return addr; | ||
} | ||
|
||
/// @notice Get a non-zero address from environment file | ||
/// @dev First checks in axis-periphery's environment file, then in axis-core's environment file | ||
/// | ||
/// Reverts if the key is not found | ||
/// | ||
/// @param key_ The key to look up in the environment file | ||
/// @return address The address from the environment file | ||
function _envAddressNotZero(string memory key_) internal view returns (address) { | ||
address addr = _envAddress(key_); | ||
require( | ||
addr != address(0), string.concat("WithEnvironment: key '", key_, "' has zero address") | ||
); | ||
|
||
return addr; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
packages/axis-utils/script/test/FixedPriceBatch-BaseDTL/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# FixedPriceBatch - Uniswap DTL Testing | ||
# FixedPriceBatch - With Optional Uniswap DTL Testing | ||
|
||
## How to Test | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters