Skip to content

Commit

Permalink
Merge pull request #218 from Axis-Fi/develop
Browse files Browse the repository at this point in the history
Staging: Develop -> Master
  • Loading branch information
Oighty authored Jul 11, 2024
2 parents 3bb940f + 4171e11 commit 9d76410
Show file tree
Hide file tree
Showing 145 changed files with 9,595 additions and 1,176 deletions.
21 changes: 12 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ jobs:
name: Foundry project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions/checkout@v4

- uses: actions/setup-node@v2
- name: Install Node.js
uses: actions/setup-node@v2

- uses: pnpm/action-setup@v2
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 8

- name: Install Node dependencies
run: pnpm install
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

# From: https://www.uffizzi.com/blog/optimizing-rust-builds-for-faster-github-actions-pipelines
- name: Install Rust
Expand All @@ -51,8 +51,11 @@ jobs:
- name: Build local ecies-cli for use with testing
run: cd crates/ecies-cli && cargo build && cd ../..

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Repo Install Script
run: |
chmod +x ./install.sh
./install.sh
shell: bash

- name: Run lint check
run: pnpm run lint:check
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ docs/

# Dotenv file
.env
.env.*
!.env.example

node_modules/

Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ Then, 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/salts/test/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 run full-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`
Expand Down
2 changes: 1 addition & 1 deletion deployments/.arbitrum-sepolia-v0.4.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"axis.BatchMerkleAllowlist": "0x9837cA34C444cEbd07C699036D1D174C6392D9fa",
"axis.BatchTokenAllowlist": "0x988c61b36F7898e464a0Bf477d2dc06aC4E95F95",
"axis.BatchAllocatedMerkleAllowlist": "0x98B59b4BF62b0316D9B0f89D28A28d5D75BB8B46",
"axis.BatchUniswapV2DirectToLiquidity": "0xE64E0807E5a0d789dB2fABB3345aB763f879521C",
"axis.BatchUniswapV2DirectToLiquidity": "0xE676907Fa9a09dC1E3b67De11816665A1313524f",
"axis.BatchUniswapV3DirectToLiquidity": "0xE6ECF0f655E642834c79F30323e7ae941883ac00"
}
13 changes: 13 additions & 0 deletions deployments/.arbitrum-sepolia-v0.5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"axis.BatchAuctionHouse": "0xBA00003622ee11Ffac8a07cf8D207b19c95F1FFf",
"axis.BatchCatalogue": "0x265aB5FABa5D855CFA46Af61936ca212CEb71146",
"axis.EncryptedMarginalPrice": "0x81661B3CC47218327cE17bAd69d9246FCC321667",
"axis.FixedPriceBatch": "0x0107DeD7dCD989470268eaeae2Aa2711Efa2597c",
"axis.BatchLinearVesting": "0x056ed71c999bDdF489d34eD767a50c608Ae16Bf9",
"axis.BatchCappedMerkleAllowlist": "0x9868c93CDec64f471b1DFf60f5e8249249dBa126",
"axis.BatchMerkleAllowlist": "0x989F7525b5e0c804e5A2707F14d34C523D56B43b",
"axis.BatchTokenAllowlist": "0x982598d92BBB2a2E54EdCd262EeF114a517fEeCE",
"axis.BatchAllocatedMerkleAllowlist": "0x98765dB6F0c4334075FB06d8D2998749b8CF604e",
"axis.BatchUniswapV2DirectToLiquidity": "0xE6c6B510E4b0e442BF01fabDc93d4bf032683C3C",
"axis.BatchUniswapV3DirectToLiquidity": "0xE6f7888cfc8219C93E70Ca528195b4afD80D7894"
}
2 changes: 1 addition & 1 deletion deployments/.base-sepolia-v0.4.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"axis.BatchMerkleAllowlist": "0x9837cA34C444cEbd07C699036D1D174C6392D9fa",
"axis.BatchTokenAllowlist": "0x988c61b36F7898e464a0Bf477d2dc06aC4E95F95",
"axis.BatchAllocatedMerkleAllowlist": "0x98B59b4BF62b0316D9B0f89D28A28d5D75BB8B46",
"axis.BatchUniswapV2DirectToLiquidity": "0xE650A43485b89F26FB98ad16811BF45BD52ad014",
"axis.BatchUniswapV2DirectToLiquidity": "0xE66538D4EEbf830b1Dc791894af4709Af257764d",
"axis.BatchUniswapV3DirectToLiquidity": "0xE661c46d94c53584095A8240958695bAD6d6fC2F"
}
13 changes: 13 additions & 0 deletions deployments/.base-sepolia-v0.5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"axis.BatchAuctionHouse": "0xBA00000D23A0793d5601d1e8E7B32aE88642cbEF",
"axis.BatchCatalogue": "0xcE56d3E3E145b44597B61E99c64cb82FB209Da04",
"axis.EncryptedMarginalPrice": "0xA7413717C633175Bc5B669E94625a4d3FE009870",
"axis.FixedPriceBatch": "0xC818f1f000f9C24D014BCe2c5334e14B1360d9CD",
"axis.BatchLinearVesting": "0x4042D4F2236D055212d485E028E8FE4939252F88",
"axis.BatchCappedMerkleAllowlist": "0x98a27160E2879334AaE4415E24C1feaa3D111392",
"axis.BatchMerkleAllowlist": "0x987e7515985887092582Cc4ea94be837a99C0b02",
"axis.BatchTokenAllowlist": "0x989a21D82D86e4934D3B8E94043F13Fb1C312F8a",
"axis.BatchAllocatedMerkleAllowlist": "0x987E2DB8E83c57Ad9aDf808e5394d77f72b49ab4",
"axis.BatchUniswapV2DirectToLiquidity": "0xE6F478d800e9807efAb601a1CD60BBd7CBA1c0b8",
"axis.BatchUniswapV3DirectToLiquidity": "0xE6BC347aA7Ce46bDb45F938605C5d4b88881bB1c"
}
2 changes: 1 addition & 1 deletion deployments/.blast-sepolia-v0.4.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"axis.BatchMerkleAllowlist": "0x9859c6FA2594e93149bd76415cE3982f39888CCb",
"axis.BatchTokenAllowlist": "0x984B6165fC87c682441E81B4aa23A017cdbFba18",
"axis.BatchAllocatedMerkleAllowlist": "0x986455Ab4f64303E8F51e72F6BF1789182563F65",
"axis.BatchUniswapV2DirectToLiquidity": "0xE6282DDB61f81F4d769FE511676dC21E570AF815",
"axis.BatchUniswapV2DirectToLiquidity": "0xE60007A0721A92f0eb538c360317d4808238700D",
"axis.BatchUniswapV3DirectToLiquidity": "0xE6b1113d108f86Fb7eF662ecF235dB6dB8978Cc3"
}
13 changes: 13 additions & 0 deletions deployments/.blast-sepolia-v0.5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"axis.BatchAuctionHouse": "0xBA0000ac450437406583980336fE93AB2752999F",
"axis.BatchCatalogue": "0xCCDF364E4a5D51437FF2885C86205Cfe2d90087a",
"axis.EncryptedMarginalPrice": "0x3ae8dD1ee2752883459C4c33c2f7Aeb8a56669f0",
"axis.FixedPriceBatch": "0x9C5dF80078066a49E77537c4cc728a5e788e671F",
"axis.BatchLinearVesting": "0xAd21cD6Cea90e46436002e79B12247eCe16110B3",
"axis.BatchCappedMerkleAllowlist": "0x98e72F243db7CDfDB015865415A0AE1bFb071507",
"axis.BatchMerkleAllowlist": "0x9824De4B9A917D30a5427813E43e5DF968e19066",
"axis.BatchTokenAllowlist": "0x986e7E24A33Ef6fbDc6C3a94657fBb59d85AbE1C",
"axis.BatchAllocatedMerkleAllowlist": "0x9895D556E8d1be6C909EC88D43Dd0F6Ae6f7f4D7",
"axis.BatchUniswapV2DirectToLiquidity": "0xE6F7049c79AA674D1E7b709C3Dc42C614359956A",
"axis.BatchUniswapV3DirectToLiquidity": "0xE6EDA80884CF4D44841fF33a3162A68EebBa2b7b"
}
13 changes: 13 additions & 0 deletions deployments/.mantle-sepolia-v0.4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"axis.BatchAuctionHouse": "0xBA00002999aBfa63cA25B3A7aD4c8F3a578aBe28",
"axis.BatchCatalogue": "0xb5a822eaA5803Ac5b8Ed2DC4De3D5916b3F46605",
"axis.EncryptedMarginalPrice": "0x30c356DFBAc808BC62c860A9B285f024b40dF1fc",
"axis.FixedPriceBatch": "0x13B299062c5E613C304145D78dA733bF9711DfC9",
"axis.BatchLinearVesting": "0xA9AEAe1d42bbfa591F4a06945a895d75011bE6e8",
"axis.BatchCappedMerkleAllowlist": "0x98A9b42b2eCF9B1A6de9d2D2fA6929a93A094957",
"axis.BatchMerkleAllowlist": "0x982b5C065CE01507aBfEda487FC19275aaF95EB1",
"axis.BatchTokenAllowlist": "0x98E0306bAf959791211f7324A99B5094548aba72",
"axis.BatchAllocatedMerkleAllowlist": "0x98fEC87d19AF5e7bda897a644c9A06C0044F2c21",
"axis.BatchUniswapV2DirectToLiquidity": "0xE6F33CdB98B3D249002F2FCd12805Fccf7d78351",
"axis.BatchUniswapV3DirectToLiquidity": "0xE6755a98C6a89331bee40EBbCA35750Daac55aC5"
}
13 changes: 13 additions & 0 deletions deployments/.mantle-sepolia-v0.5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"axis.BatchAuctionHouse": "0xBA00000D23A0793d5601d1e8E7B32aE88642cbEF",
"axis.BatchCatalogue": "0x6c80F20C5C0404a3D5349F71F9B25c0654884092",
"axis.EncryptedMarginalPrice": "0xaC9957282BeA578f371078ddc4cD12A135B105d6",
"axis.FixedPriceBatch": "0x8b7e483d96004ca7893EfB14E049f7648b62322b",
"axis.BatchLinearVesting": "0x16D5Aab9d35f8B3ac7BD086eEDcCe5343682D5F0",
"axis.BatchCappedMerkleAllowlist": "0x98a27160E2879334AaE4415E24C1feaa3D111392",
"axis.BatchMerkleAllowlist": "0x987e7515985887092582Cc4ea94be837a99C0b02",
"axis.BatchTokenAllowlist": "0x989a21D82D86e4934D3B8E94043F13Fb1C312F8a",
"axis.BatchAllocatedMerkleAllowlist": "0x987E2DB8E83c57Ad9aDf808e5394d77f72b49ab4",
"axis.BatchUniswapV2DirectToLiquidity": "0xE6feE7a689Ff7493032Ba48B15fE841c6cC30DB9",
"axis.BatchUniswapV3DirectToLiquidity": "0xE6c1ab82a2b4a194C87e643668bb715619766F0B"
}
2 changes: 1 addition & 1 deletion deployments/.mode-sepolia-v0.4.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"axis.BatchMerkleAllowlist": "0x9837cA34C444cEbd07C699036D1D174C6392D9fa",
"axis.BatchTokenAllowlist": "0x988c61b36F7898e464a0Bf477d2dc06aC4E95F95",
"axis.BatchAllocatedMerkleAllowlist": "0x98B59b4BF62b0316D9B0f89D28A28d5D75BB8B46",
"axis.BatchUniswapV2DirectToLiquidity": "0xE60f928d399782836540752Eb3fCfE46b0Cb4E24",
"axis.BatchUniswapV2DirectToLiquidity": "0xE60FD6203AF5D5d43433952a033Cb70Ba21784E9",
"axis.BatchUniswapV3DirectToLiquidity": "0xE6ce65C413a5Fc10Fa77B26032B33DCD68F8474a"
}
13 changes: 13 additions & 0 deletions deployments/.mode-sepolia-v0.5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"axis.BatchAuctionHouse": "0xBA00000D23A0793d5601d1e8E7B32aE88642cbEF",
"axis.BatchCatalogue": "0x3fF930D77CD37eB7d4960F5D10ec415978f90aeA",
"axis.EncryptedMarginalPrice": "0x8b47F82a58d8AFBE5167feBf0D3F3Bb509aaf2bd",
"axis.FixedPriceBatch": "0xFB1113E170CA6d95f3a91121BDD2370a822598E9",
"axis.BatchLinearVesting": "0xF170C78a493d9245d125e05bBEc35c98735f5277",
"axis.BatchCappedMerkleAllowlist": "0x98a27160E2879334AaE4415E24C1feaa3D111392",
"axis.BatchMerkleAllowlist": "0x987e7515985887092582Cc4ea94be837a99C0b02",
"axis.BatchTokenAllowlist": "0x989a21D82D86e4934D3B8E94043F13Fb1C312F8a",
"axis.BatchAllocatedMerkleAllowlist": "0x987E2DB8E83c57Ad9aDf808e5394d77f72b49ab4",
"axis.BatchUniswapV2DirectToLiquidity": "0xE6F478d800e9807efAb601a1CD60BBd7CBA1c0b8",
"axis.BatchUniswapV3DirectToLiquidity": "0xE6BB80a6B8628F150E340BdE2e0C49fA17E1e566"
}
3 changes: 3 additions & 0 deletions lib/g-uni-v1-core/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Wallets
ANVIL_PRIVATE_KEY=
DEPLOYER_PRIVATE_KEY=
41 changes: 41 additions & 0 deletions lib/g-uni-v1-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,44 @@ Arguments:
yarn

yarn test

## Setup

```shell
yarn install
```

Set up environment variables:

- Copy `.env.example` to `.env`
- Fill out environment variables

## Deployment

1. Ensure that the `Gelato`, `GelatoDevMultiSig` and `UniswapV3Factory` addresses are set in `src/addresses.ts` for the target chain.
1. Deploy the GUniPool, as that will serve as input to the GUniFactory:

```shell
HARDHAT_NETWORK="<chain name>" yarn run deploy:pool
```

1. Copy the address of the GUniPool (output to the terminal) into the value of the `GUniImplementation` key in `src/addresses.ts` for the target chain.
1. Deploy the GUniFactory:

```shell
HARDHAT_NETWORK="<chain name>" yarn run deploy:factory
```

Note that these scripts will not deploy to a particular chain if there have been no changes to the contracts since the last deployment on that chain. To override this, pass the `--reset` flag.

## Verification

1. Verify the contracts:

```shell
HARDHAT_NETWORK="<chain name>" yarn run verify
```

- If hardhat reports that a network is not supported, specify the API url using `--api-url <url>`

NOTE: The GUniFactory contract will require additional steps to enable it to be viewed as a proxy.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.19;
import {OwnableUninitialized} from "./OwnableUninitialized.sol";
import {
Initializable
} from "@openzeppelin/contracts-upgradeable/utils/Initializable.sol";
} from "contracts/lib/Initializable.sol";
import {
EnumerableSet
} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
Expand Down
50 changes: 50 additions & 0 deletions lib/g-uni-v1-core/contracts/lib/Initializable.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// SPDX-License-Identifier: MIT

// solhint-disable-next-line compiler-version
pragma solidity ^0.8.0;

/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* @dev Copied into repo from OpenZeppelin Contracts v4.1.0
*/
abstract contract Initializable {

/**
* @dev Indicates that the contract has been initialized.
*/
bool private _initialized;

/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;

/**
* @dev Modifier to protect an initializer function from being invoked twice.
*/
modifier initializer() {
require(_initializing || !_initialized, "Initializable: contract is already initialized");

bool isTopLevelCall = !_initializing;
if (isTopLevelCall) {
_initializing = true;
_initialized = true;
}

_;

if (isTopLevelCall) {
_initializing = false;
}
}
}
16 changes: 15 additions & 1 deletion lib/g-uni-v1-core/deploy/GUniFactory.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { deployments, getNamedAccounts } from "hardhat";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import { getAddresses } from "../src/addresses";
import { isZeroAddress } from "./address";

const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
if (
Expand All @@ -19,7 +20,18 @@ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { deployer } = await getNamedAccounts();
const addresses = getAddresses(hre.network.name);

await deploy("GUniFactory", {
// Validate input addresses
if (isZeroAddress(addresses.UniswapV3Factory)) {
throw new Error("UniswapV3Factory address not set");
}
if (isZeroAddress(addresses.GelatoDevMultiSig)) {
throw new Error("GelatoDevMultiSig address not set");
}
if (isZeroAddress(addresses.GUniImplementation)) {
throw new Error("GUniImplementation (pool implementation) address not set");
}

const result = await deploy("GUniFactory", {
from: deployer,
proxy: {
proxyContract: "EIP173Proxy",
Expand All @@ -37,6 +49,8 @@ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
},
args: [addresses.UniswapV3Factory],
});

console.log("GUniFactory deployed to:", result.address);
};

func.skip = async (hre: HardhatRuntimeEnvironment) => {
Expand Down
13 changes: 12 additions & 1 deletion lib/g-uni-v1-core/deploy/GUniPool.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { deployments, getNamedAccounts } from "hardhat";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import { getAddresses } from "../src/addresses";
import { isZeroAddress } from "./address";

const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
if (
Expand All @@ -19,10 +20,20 @@ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { deployer } = await getNamedAccounts();
const addresses = getAddresses(hre.network.name);

await deploy("GUniPool", {
// Validate input addresses
if (isZeroAddress(addresses.Gelato)) {
throw new Error("Gelato address not set");
}
if (isZeroAddress(deployer)) {
throw new Error("Deployer address not set");
}

const result = await deploy("GUniPool", {
from: deployer,
args: [addresses.Gelato],
});

console.log("GUniPool deployed to:", result.address);
};

func.skip = async (hre: HardhatRuntimeEnvironment) => {
Expand Down
2 changes: 2 additions & 0 deletions lib/g-uni-v1-core/deploy/address.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

export const isZeroAddress = (address: string): boolean => !address || address === "" || address === "0x0000000000000000000000000000000000000000";
1 change: 1 addition & 0 deletions lib/g-uni-v1-core/deployments/mantleSepolia/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5003
Loading

0 comments on commit 9d76410

Please sign in to comment.