Skip to content

Commit

Permalink
chore: add optimism deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
0xChin committed Nov 20, 2024
1 parent f707bd3 commit 52001de
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 21 deletions.
8 changes: 7 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ runs = 10
mainnet = "${MAINNET_RPC}"
sepolia = "${SEPOLIA_RPC}"
optimism-sepolia = "${OPTIMISM_SEPOLIA_RPC}"
arb-sepolia = "${ARBITRUM_SEPOLIA_RPC}"
arbitrum-sepolia = "${ARBITRUM_SEPOLIA_RPC}"
optimism = "${OPTIMISM_RPC}"
polygon = "${POLYGON_RPC}"
base = "${BASE_RPC}"
arbitrum = "${ARBITRUM_RPC}"
bnb = "${BNB_RPC}"


[etherscan]
mainnet = { key = "${ETHERSCAN_API_KEY}", chain = "mainnet" }
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"coverage": "forge coverage --report summary --report lcov --match-path 'test/unit/*'",
"deploy:arbitrum-sepolia": "bash -c 'source .env && forge script Deploy -vvvvv --rpc-url $ARBITRUM_SEPOLIA_RPC --broadcast --chain arbitrum-sepolia --account dev --verify --verifier blockscout --verifier-url https://arbitrum-sepolia.blockscout.com/api/'",
"deploy:mainnet": "bash -c 'source .env && forge script Deploy -vvvvv --rpc-url $MAINNET_RPC --broadcast --chain mainnet --account dev'",
"deploy:optimism": "bash -c 'source .env && forge script Deploy -vvvvv --rpc-url $OPTIMISM_RPC --broadcast --chain optimism --account dev --verify'",
"deploy:optimism": "bash -c 'source .env && TESTING=false forge script Deploy -vvvvv --rpc-url $OPTIMISM_RPC --broadcast --chain optimism --account dev --verify'",
"deploy:optimism-sepolia": "bash -c 'source .env && forge script Deploy -vvvvv --rpc-url $OPTIMISM_SEPOLIA_RPC --broadcast --chain optimism-sepolia --account dev --verify --verifier blockscout --verifier-url https://optimism-sepolia.blockscout.com/api/'",
"deploy:sepolia": "bash -c 'source .env && forge script Deploy -vvvvv --rpc-url $SEPOLIA_RPC --broadcast --chain sepolia --account dev'",
"deploy:v-optimism": "bash -c 'source .env && forge script Deploy -vvvvv --rpc-url $VIRTUAL_OPTIMISM_RPC --broadcast --account dev --verify'",
Expand All @@ -26,9 +26,10 @@
"lint:sol-tests": "solhint -c .solhint.tests.json 'test/**/*.sol'",
"prepare": "husky install",
"test": "TESTING=true FORKED_NETWORK=mainnet FORK_BLOCK=18920905 forge test -vvv ",
"test:arbitrum-sepolia": "TESTING=true FORKED_NETWORK=arb-sepolia FORK_BLOCK=98684306 forge test -vvv ",
"test:arbitrum-sepolia": "TESTING=true FORKED_NETWORK=arbitrum-sepolia FORK_BLOCK=98684306 forge test -vvv ",
"test:fuzz": "echidna test/invariants/fuzz/Greeter.t.sol --contract InvariantGreeter --corpus-dir test/invariants/fuzz/echidna_coverage/ --test-mode assertion",
"test:integration": "TESTING=true FORKED_NETWORK=mainnet FORK_BLOCK=18920905 forge test --match-contract Integration -vvv",
"test:optimism": "TESTING=true FORKED_NETWORK=optimism FORK_BLOCK=128238511 forge test -vvv ",
"test:optimism-sepolia": "TESTING=true FORKED_NETWORK=optimism-sepolia FORK_BLOCK=20113040 forge test -vvv ",
"test:symbolic": "halmos",
"test:unit": "forge test --match-contract Unit -vvv",
Expand Down
60 changes: 42 additions & 18 deletions script/Deploy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {Grateful} from "contracts/Grateful.sol";
import {TestToken} from "contracts/external/TestToken.sol";
import {AaveV3Vault} from "contracts/vaults/AaveV3Vault.sol";
import {Script} from "forge-std/Script.sol";

import {console} from "forge-std/console.sol";
import {ERC20} from "solmate/tokens/ERC20.sol";
import {IPool, IRewardsController} from "yield-daddy/aave-v3/AaveV3ERC4626.sol";

Expand All @@ -13,8 +15,15 @@ contract Deploy is Script {
CONSTANTS
//////////////////////////////////////////////////////////////*/

uint256 public constant CHAIN_MAINNET = 1;
// Mainnets
uint256 public constant CHAIN_ETHEREUM = 1;
uint256 public constant CHAIN_OPTIMISM = 10;
uint256 public constant CHAIN_POLYGON = 137;
uint256 public constant CHAIN_BASE = 8453;
uint256 public constant CHAIN_ARBITRUM = 42_161;
uint256 public constant CHAIN_BNB = 56;

// Testnets
uint256 public constant CHAIN_OPTIMISM_SEPOLIA = 11_155_420;
uint256 public constant CHAIN_ARBITRUM_SEPOLIA = 421_614;

Expand Down Expand Up @@ -47,8 +56,7 @@ contract Deploy is Script {
function getDeploymentParams(
uint256 chainId
) internal pure returns (DeploymentParams memory params) {
if (chainId == CHAIN_MAINNET) {
// Mainnet
if (chainId == CHAIN_ETHEREUM) {
address[] memory _tokens = new address[](3);
_tokens[0] = address(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48); // USDC
_tokens[1] = address(0xdAC17F958D2ee523a2206206994597C13D831ec7); // USDT
Expand Down Expand Up @@ -82,12 +90,30 @@ contract Deploy is Script {
vaults: _vaults
});
} else if (chainId == CHAIN_OPTIMISM) {
// Optimism
address[] memory _tokens = new address[](2);
_tokens[0] = address(0x94b008aA00579c1307B0EF2c499aD98a8ce58e58);
_tokens[1] = address(0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1);
address[] memory _tokens = new address[](3);
_tokens[0] = address(0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85); // USDC
_tokens[1] = address(0x94b008aA00579c1307B0EF2c499aD98a8ce58e58); // USDT
_tokens[2] = address(0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1); // DAI

VaultDeploymentParams[] memory _vaults = new VaultDeploymentParams[](3);

_vaults[0] = VaultDeploymentParams({
token: address(0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85), // USDC
aToken: address(0x38d693cE1dF5AaDF7bC62595A37D667aD57922e5), // aUSDC
rewardsController: address(0x929EC64c34a17401F460460D4B9390518E5B473e) // Rewards Controller
});

VaultDeploymentParams[] memory _vaults;
_vaults[1] = VaultDeploymentParams({
token: address(0x94b008aA00579c1307B0EF2c499aD98a8ce58e58), // USDT
aToken: address(0x6ab707Aca953eDAeFBc4fD23bA73294241490620), // aUSDT
rewardsController: address(0x929EC64c34a17401F460460D4B9390518E5B473e) // Rewards Controller
});

_vaults[2] = VaultDeploymentParams({
token: address(0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1), // DAI
aToken: address(0x82E64f49Ed5EC1bC6e43DAD4FC8Af9bb3A2312EE), // aDAI
rewardsController: address(0x929EC64c34a17401F460460D4B9390518E5B473e) // Rewards Controller
});

params = DeploymentParams({
tokens: _tokens,
Expand All @@ -97,15 +123,14 @@ contract Deploy is Script {
vaults: _vaults
});
} else if (chainId == CHAIN_OPTIMISM_SEPOLIA) {
// Optimism Sepolia
address[] memory _tokens = new address[](1);
_tokens[0] = address(0x5fd84259d66Cd46123540766Be93DFE6D43130D7);

VaultDeploymentParams[] memory _vaults = new VaultDeploymentParams[](1);
_vaults[0] = VaultDeploymentParams({
token: address(0x5fd84259d66Cd46123540766Be93DFE6D43130D7), // Token address
aToken: address(0xa818F1B57c201E092C4A2017A91815034326Efd1), // aToken address
rewardsController: address(0xaD4F91D26254B6B0C6346b390dDA2991FDE2F20d) // Rewards Controller address
token: address(0x5fd84259d66Cd46123540766Be93DFE6D43130D7),
aToken: address(0xa818F1B57c201E092C4A2017A91815034326Efd1),
rewardsController: address(0xaD4F91D26254B6B0C6346b390dDA2991FDE2F20d)
});

params = DeploymentParams({
Expand All @@ -116,15 +141,14 @@ contract Deploy is Script {
vaults: _vaults
});
} else if (chainId == CHAIN_ARBITRUM_SEPOLIA) {
// Arbitrum Sepolia
address[] memory _tokens = new address[](1);
_tokens[0] = address(0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d); // usdc

VaultDeploymentParams[] memory _vaults = new VaultDeploymentParams[](1);
_vaults[0] = VaultDeploymentParams({
token: address(0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d), // Token address
aToken: address(0x460b97BD498E1157530AEb3086301d5225b91216), // aToken address
rewardsController: address(0x3A203B14CF8749a1e3b7314c6c49004B77Ee667A) // Rewards Controller address
token: address(0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d),
aToken: address(0x460b97BD498E1157530AEb3086301d5225b91216),
rewardsController: address(0x3A203B14CF8749a1e3b7314c6c49004B77Ee667A)
});

params = DeploymentParams({
Expand All @@ -145,7 +169,7 @@ contract Deploy is Script {
if (!vm.envBool("TESTING")) {
vm.startBroadcast();
}
// Deploy Grateful contract

grateful = new Grateful(_params.tokens, _params.aavePool, _params.initialFee, _params.initialPerformanceFee);
grateful.transferOwnership(GRATEFUL_MULTISIG);

Expand All @@ -159,7 +183,7 @@ contract Deploy is Script {
ERC20(vaultParams.token),
ERC20(vaultParams.aToken),
_params.aavePool,
grateful.owner(), // rewardRecipient_ (set to desired address)
grateful.owner(),
IRewardsController(vaultParams.rewardsController),
address(grateful) // newOwner
);
Expand Down

0 comments on commit 52001de

Please sign in to comment.