diff --git a/.env.example b/.env.example index d8a5fe0..da57f4c 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,6 @@ # Wallet Management -export PRIVATE_KEY= +export KEYSTORE= +export KEYSTORE_PASSWORD="" # RPC URL export RPC_URL= @@ -9,15 +10,21 @@ export ETHERSCAN_API_URL= export ETHERSCAN_API_KEY= # Deployment Configurations -export GREENHOUSE= -export SALT= export INITIAL_AUTHED= - -# Management Configurations -export AGGOR= +export BUD= +export CHRONICLE= +export CHAINLINK= +export UNISWAP_POOL= +export UNISWAP_BASE_TOKEN= +export UNISWAP_QUOTE_TOKEN= +export UNISWAP_BASE_TOKEN_DECIMALS= +export UNISWAP_LOOKBACK= ## IAggor::setAgreementDistance export AGREEMENT_DISTANCE= ## IAggor::setAgeThreshold export AGE_THRESHOLD= -## IAuth::{rely,deny}, IToll::{kiss,diss} + +# Management Configurations +export AGGOR= +## IAuth::{rely,deny} export WHO= diff --git a/.gitmodules b/.gitmodules index f587bb8..4e6eaf0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,10 +6,6 @@ path = lib/chronicle-std url = https://github.com/chronicleprotocol/chronicle-std branch = v2 -[submodule "lib/greenhouse"] - path = lib/greenhouse - url = https://github.com/chronicleprotocol/greenhouse - branch = v1 [submodule "lib/uniswap/v3-periphery"] path = lib/uniswap/v3-periphery url = https://github.com/Uniswap/v3-periphery.git diff --git a/README.md b/README.md index 022dfa3..371fb4c 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,3 @@ $ forge fmt [--check] - [chronicleprotocol/chronicle-std@v2](https://github.com/chronicleprotocol/chronicle-std/tree/v2) - [uniswap/v3-periphery@0.8](https://github.com/Uniswap/v3-periphery/tree/0.8) - [uniswap/v3-core@0.8](https://github.com/Uniswap/v3-core/tree/0.8) - -Deployment via: - -- [chronicleprotocol/greenhouse@v1](https://github.com/chronicleprotocol/greenhouse/tree/v1) diff --git a/docs/Deployment.md b/docs/Deployment.md index c348aef..f1a66cb 100644 --- a/docs/Deployment.md +++ b/docs/Deployment.md @@ -1,22 +1,19 @@ # Deployment -This document describes how to deploy a new `Aggor` instance via _Chronicle Protocol_'s [`Greenhouse`](https://github.com/chronicleprotocol/greenhouse) contract factory. +This document describes how to deploy a new `Aggor` instance. ## Environment Variables The following environment variables must be set: - `RPC_URL`: The RPC URL of an EVM node -- `PRIVATE_KEY`: The private key to use +- `KEYSTORE`: The path to the keystore file containing the encrypted private key + - Note that password can either be entered on request or set via the `KEYSTORE_PASSWORD` environment variable +- `KEYSTORE_PASSWORD`: The password for the keystore file - `ETHERSCAN_API_URL`: The Etherscan API URL for the Etherscan's chain instance - Note that the API endpoint varies per Etherscan chain instance - Note to point to actual API endpoint (e.g. `/api`) and not just host - `ETHERSCAN_API_KEY`: The Etherscan API key for the Etherscan's chain instance -- `GREENHOUSE`: The `Greenhouse` instance to use for deployment -- `SALT`: The salt to deploy the `Aggor` instance to - - Note to use the salt's string representation - - Note that the salt must not exceed 32 bytes in length - - Note that the salt should match the name of the contract deployed! - `INITIAL_AUTHED`: The address being auth'ed on the newly deployed `Aggor` instance Note that an `.env.example` file is provided in the project root. To set all environment variables at once, create a copy of the file and rename the copy to `.env`, adjust the variables' values, and run `source .env`. @@ -24,22 +21,23 @@ Note that an `.env.example` file is provided in the project root. To set all env To easily check the environment variables, run: ```bash -$ env | grep -e "RPC_URL" -e "PRIVATE_KEY" -e "ETHERSCAN_API_URL" -e "ETHERSCAN_API_KEY" -e "GREENHOUSE" -e "SALT" -e "INITIAL_AUTHED" +$ env | grep -e "RPC_URL" -e "KEYSTORE" -e "KEYSTORE_PASSWORD" -e "ETHERSCAN_API_URL" -e "ETHERSCAN_API_KEY" -e "INITIAL_AUTHED" ``` ## Configuration Setting -The following variables inside `script/Aggor.s.sol` need to be set: -- `bud`: The address allowed to read Aggor -- `chronicle`: The Chronicle oracle -- `chainlink`: The Chainlink oracle -- `uniswapPool`: The Uniswap pool to use as TWAP -- `uniswapBaseToken`: The Uniswap pool's base token -- `uniswapQuoteToken`: The Uniswap pool's quote token -- `uniswapBaseTokenDecimals`: The Uniswap pool's base token's decimals -- `uniswapLookback`: The TWAP lookback argument in seconds -- `agreementDistance`: The agreement distance in WAD -- `ageThreshold`: The age staleness threshold in seconds +The following additional environment variables must be set: + +- `BUD`: The address allowed to read Aggor +- `CHRONICLE`: The Chronicle oracle +- `CHAINLINK`: The Chainlink oracle +- `UNISWAP_POOL`: The Uniswap pool to use as TWAP +- `UNISWAP_BASE_TOKEN`: The Uniswap pool's base token +- `UNISWAP_QUOTE_TOKEN`: The Uniswap pool's quote token +- `UNISWAP_BASE_TOKEN_DECIMALS`: The Uniswap pool's base token's decimals +- `UNISWAP_LOOKBACK`: The TWAP lookback argument in seconds +- `AGREEMENT_DISTANCE`: The agreement distance in WAD +- `AGE_THRESHOLD`: The age staleness threshold in seconds ## Code Adjustments @@ -55,12 +53,12 @@ The deployment process consists of two steps - the actual deployment and the sub Deployment: ```bash -$ SALT_BYTES32=$(cast format-bytes32-string $SALT) && \ - forge script \ - --private-key "$PRIVATE_KEY" \ +$ forge script \ + --keystore "$KEYSTORE" \ + --password "$KEYSTORE_PASSWORD" \ --broadcast \ --rpc-url "$RPC_URL" \ - --sig "$(cast calldata "deploy(address,bytes32,address)" "$GREENHOUSE" "$SALT_BYTES32" "$INITIAL_AUTHED")" \ + --sig "$(cast calldata "deploy(address,address,address,address,address,address,address,uint8,uint32,uint128,uint32)" "$INITIAL_AUTHED" "$BUD" "$CHRONICLE" "$CHAINLINK" "$UNISWAP_POOL" "$UNISWAP_BASE_TOKEN" "$UNISWAP_QUOTE_TOKEN" "$UNISWAP_BASE_TOKEN_DECIMALS" "$UNISWAP_LOOKBACK" "$AGREEMENT_DISTANCE" "$AGE_THRESHOLD")" \ -vvv \ script/Aggor.s.sol:AggorScript ``` diff --git a/lib/greenhouse b/lib/greenhouse deleted file mode 160000 index 88d3ef6..0000000 --- a/lib/greenhouse +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 88d3ef63d0ef5a75642c3daf2a7be3e807d6fea1 diff --git a/remappings.txt b/remappings.txt index 33778d6..e45e5cf 100644 --- a/remappings.txt +++ b/remappings.txt @@ -2,6 +2,3 @@ ds-test/=lib/forge-std/lib/ds-test/src/ forge-std/=lib/forge-std/src/ chronicle-std/=lib/chronicle-std/src/ - -greenhouse/=lib/greenhouse/src - diff --git a/script/Aggor.s.sol b/script/Aggor.s.sol index ce10f15..3a4582c 100644 --- a/script/Aggor.s.sol +++ b/script/Aggor.s.sol @@ -6,8 +6,6 @@ import {console2 as console} from "forge-std/console2.sol"; import {IAuth} from "chronicle-std/auth/IAuth.sol"; -import {IGreenhouse} from "greenhouse/IGreenhouse.sol"; - import {IAggor} from "src/IAggor.sol"; import {Aggor_BASE_QUOTE_COUNTER as Aggor} from "src/Aggor.sol"; // @todo ^^^^ ^^^^^ ^^^^^^^ Adjust name of Aggor instance @@ -16,36 +14,24 @@ import {Aggor_BASE_QUOTE_COUNTER as Aggor} from "src/Aggor.sol"; * @notice Aggor Management Script */ contract AggorScript is Script { - // -- Deployment Configuration -- - - // -- Immutable - - address bud; - address chronicle; - address chainlink; - address uniswapPool; - address uniswapBaseToken; - address uniswapQuoteToken; - uint8 uniswapBaseTokenDecimals; - uint32 uniswapLookback; - - // -- Mutable - - uint128 agreementDistance; - uint32 ageThreshold; - - // -- Deployment Function -- - - /// @dev Deploys a new Aggor instance via Greenhouse instance - /// `greenhouse` and salt `salt` with `initialAuthed` being the - /// address initially auth'ed. - function deploy(address greenhouse, bytes32 salt, address initialAuthed) - public - { - // Create creation code with constructor arguments. - bytes memory creationCode = abi.encodePacked( - type(Aggor).creationCode, - abi.encode( + /// @dev Deploys a new Aggor instance with `initialAuthed` being the address + /// initially auth'ed. + function deploy( + address initialAuthed, + address bud, + address chronicle, + address chainlink, + address uniswapPool, + address uniswapBaseToken, + address uniswapQuoteToken, + uint8 uniswapBaseTokenDecimals, + uint32 uniswapLookback, + uint128 agreementDistance, + uint32 ageThreshold + ) public { + vm.startBroadcast(); + address deployed = address( + new Aggor( initialAuthed, bud, chronicle, @@ -59,14 +45,6 @@ contract AggorScript is Script { ageThreshold ) ); - - // Ensure salt not yet used. - address deployed = IGreenhouse(greenhouse).addressOf(salt); - require(deployed.code.length == 0, "Salt already used"); - - // Plant creation code via greenhouse. - vm.startBroadcast(); - IGreenhouse(greenhouse).plant(salt, creationCode); vm.stopBroadcast(); console.log("Deployed at", deployed); diff --git a/slither.config.json b/slither.config.json index de5de02..1cf4801 100644 --- a/slither.config.json +++ b/slither.config.json @@ -2,7 +2,6 @@ "filter_paths": "lib,test,script", "solc_remaps": [ "chronicle-std/=lib/chronicle-std/src", - "greenhouse/=lib/greenhouse/src", "ds-test/=lib/forge-std/lib/ds-test/src/", "forge-std/=lib/forge-std/src/" ]