Skip to content

Commit

Permalink
refactor: update deployment script (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
aquariuslt authored Jul 15, 2024
1 parent 55de92e commit 0ae7aef
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 43 deletions.
35 changes: 25 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
SHELL := /bin/bash
.PHONY: deploy-testnet deploy-mainnet deploy-aave-mainnet
.PHONY: deploy-core-optimism-sepolia deploy-aave-optimism-sepolia deploy-core-optimism deploy-aave-optimism deploy-core-cyber-testnet deploy-aave-cyber-testnet deploy-core-cyber deploy-aave-cyber

DEPLOY_CMD=source .env && forge script scripts/Deploy.s.sol:DeployScript
DEPLOY_CMD=source .env && forge script scripts/DeployCore.s.sol:DeployCoreScript
DEPLOY_AAVE_CMD=source .env && forge script scripts/DeployAave.s.sol:DeployAaveScript
VERIFY_CMD=--etherscan-api-key $$OPTIMISM_ETHERSCAN_API_KEY --verify

deploy-testnet:
${DEPLOY_CMD} --rpc-url $$OPTIMISM_TESTNET_RPC --broadcast ${VERIFY_CMD} -vvvv
#${DEPLOY_CMD} --rpc-url $$CYBER_TESTNET_RPC --broadcast -vvvv

deploy-mainnet:
${DEPLOY_CMD} --rpc-url $$OPTIMISM_MAINNET_RPC --broadcast ${VERIFY_CMD} -vvvv
#${DEPLOY_CMD} --rpc-url $$CYBER_MAINNET_RPC --broadcast -vvvv
## network: optimism-sepolia
deploy-core-optimism-sepolia:
${DEPLOY_CMD} --rpc-url $$OPTIMISM_TESTNET_RPC --broadcast ${VERIFY_CMD} -vvvv

deploy-aave-testnet:
deploy-aave-optimism-sepolia:
${DEPLOY_AAVE_CMD} --rpc-url $$OPTIMISM_TESTNET_RPC --broadcast ${VERIFY_CMD} -vvvv

deploy-aave-mainnet:
## network: optimism
deploy-core-optimism:
${DEPLOY_CMD} --rpc-url $$OPTIMISM_MAINNET_RPC --broadcast ${VERIFY_CMD} -vvvv

deploy-aave-optimism:
${DEPLOY_AAVE_CMD} --rpc-url $$OPTIMISM_MAINNET_RPC --broadcast ${VERIFY_CMD} -vvvv

## network: cyber-testnet
deploy-core-cyber-testnet:
${DEPLOY_CMD} --rpc-url $$CYBER_TESTNET_RPC --broadcast ${VERIFY_CMD} -vvvv

deploy-aave-cyber-testnet:
${DEPLOY_AAVE_CMD} --rpc-url $$CYBER_TESTNET_RPC --broadcast ${VERIFY_CMD} -vvvv

## network: cyber-mainnet
deploy-core-cyber:
${DEPLOY_CMD} --rpc-url $$CYBER_MAINNET_RPC --broadcast ${VERIFY_CMD} -vvvv

deploy-aave-cyber:
${DEPLOY_AAVE_CMD} --rpc-url $$CYBER_MAINNET_RPC --broadcast ${VERIFY_CMD} -vvvv
28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ generate sustainable rewards, which are then redistributed to the creators.
| Network | Address |
|------------------|----------------------------------------------------------------------------------------------------------------------------------------|
| Optimism Mainnet | N/A |
| Optimism Sepolia | [0x02a04ee779587afbbe7f844180ff760bc5e73039](https://sepolia-optimism.etherscan.io/address/0x02a04ee779587afbbe7f844180ff760bc5e73039) |
| Optimism Sepolia | [0x6582281f6fb0adb509ffd7d5e7e6ae957cb3e500](https://sepolia-optimism.etherscan.io/address/0x6582281f6fb0adb509ffd7d5e7e6ae957cb3e500) |
| Cyber Mainnet | N/A |
| Cyber Sepolia | |

Expand All @@ -75,7 +75,7 @@ generate sustainable rewards, which are then redistributed to the creators.
| Network | Address |
|------------------|----------------------------------------------------------------------------------------------------------------------------------------|
| Optimism Mainnet | N/A |
| Optimism Sepolia | [0x4509932e2f18b622f454cf73fac8069901fbbebc](https://sepolia-optimism.etherscan.io/address/0x4509932e2f18b622f454cf73fac8069901fbbebc) |
| Optimism Sepolia | [0x1637a51717db3f62f836944fde09bfa4c673b2d9](https://sepolia-optimism.etherscan.io/address/0x1637a51717db3f62f836944fde09bfa4c673b2d9) |
| Cyber Mainnet | N/A |
| Cyber Sepolia | 0x1b05f188388b49ee9053914d3109119d228060b5 |

Expand All @@ -89,7 +89,7 @@ generate sustainable rewards, which are then redistributed to the creators.
| Network | Address |
|------------------|----------------------------------------------------------------------------------------------------------------------------------------|
| Optimism Mainnet | N/A |
| Optimism Sepolia | [0xa77fc72fbb2e7f6c4ba4f97f0f6eeee9f46a2b97](https://sepolia-optimism.etherscan.io/address/0xa77fc72fbb2e7f6c4ba4f97f0f6eeee9f46a2b97) |
| Optimism Sepolia | [0x1ac43b6530f86a8b07bca8fe29d37ff3a7d84c5d](https://sepolia-optimism.etherscan.io/address/0x1ac43b6530f86a8b07bca8fe29d37ff3a7d84c5d) |
| Cyber Mainnet | N/A |
| Cyber Sepolia | 0xba2553060e90551c797bebd48ee04909606bb04f |

Expand All @@ -98,17 +98,21 @@ generate sustainable rewards, which are then redistributed to the creators.
We use foundry to build tests and deploy.

```bash
install
yarn install
test
yarn run test
coverage
yarn run coverage
deploy
yarn run deploy:testnet
yarn run deploy:mainnet
# install
yarn install
# test
yarn run test
# coverage
yarn run coverage
# deploy
yarn run deploy:core:optimism-sepolia
yarn run deploy:core:optimism
yarn run deploy:core:cyber-testnet
yarn run deploy:core:cyber
```

for more details, please refer to the package.json npm scripts & Makefile

## Acknowledgement

Thanks to [Simon de la Rouviere](https://docs.google.com/document/d/1VNkBjjGhcZUV9CyC0ccWYbqeOoVKT2maqX0rK3yXB20), whose
Expand Down
2 changes: 1 addition & 1 deletion contracts/core/SharesERC1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { IShare } from "../interface/IShare.sol";
contract SharesERC1155 is ERC1155Supply, Ownable, IShare {
address public _FACTORY_;
string private _baseURI;
mapping(uint256 => string) public tokenURIs;
mapping(uint256 tokenId => string tokenURI) public tokenURIs;

event Mint(address indexed user, uint256 indexed id, uint256 amount);
event Burn(address indexed user, uint256 indexed id, uint256 amount);
Expand Down
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@
"test:invariant": "forge test -vvv --mc BaseInvariantTest --fork-url https://optimism.llamarpc.com/sk_llama_3f92d666a172604faf69e469a67ec6ea ",
"test:income": "forge test -vv --mp \"test/integration/IncomeSimulator.t.sol\" --fork-url https://mainnet.optimism.io ",
"coverage": "forge coverage --mp \"test/unit/**/*.sol\" --fork-url https://mainnet.optimism.io ",
"deploy:testnet": "make deploy-testnet",
"deploy:mainnet": "make deploy-mainnet",
"fmt": "forge fmt --check && solhint \"{scripts,contracts,test}/**/*.sol\"",
"lint": "solhint 'contracts/**/*.sol'",
"clean": "rm -rf artifacts broadcast cache cache-foundry docs out-optimized out"
"clean": "rm -rf artifacts broadcast cache cache-foundry docs out-optimized out",
"deploy:core:optimism-sepolia": "make deploy-core-optimism-sepolia",
"deploy:aave:optimism-sepolia": "make deploy-aave-optimism-sepolia",
"deploy:core:optimism": "make deploy-core-optimism",
"deploy:aave:optimism": "make deploy-aave-optimism",
"deploy:core:cyber-testnet": "make deploy-core-cyber-testnet",
"deploy:aave:cyber-testnet": "make deploy-aave-cyber-testnet",
"deploy:core:cyber": "make deploy-core-cyber",
"deploy:aave:cyber": "make deploy-aave-cyber"
},
"devDependencies": {
"ds-test": "github:dapphub/ds-test#master",
Expand Down
20 changes: 10 additions & 10 deletions scripts/Base.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ pragma solidity 0.8.25;
import { Script } from "forge-std/Script.sol";

contract BaseScript is Script {
// TEMPORARY
// It will be replaced with multi-sig wallet.
address public OWNER = 0xdA1d0C7f174effBA98Ea1E31424418DC9aeaEa22;

// multi-sig wallet as owner.
address public OWNER = 0xb2dDDBdD1EB4EcF95BA63f271e40073860929a46;

uint256 public constant OPTIMISM_MAINNET = 10;
uint256 public constant OPTIMISM_TESTNET = 11155420;
uint256 public constant OPTIMISM_SEPOLIA = 11155420;
uint256 public constant CYBER_MAINNET = 7560;
uint256 public constant CYBER_TESTNET = 111557560;

Expand All @@ -24,20 +24,20 @@ contract BaseScript is Script {
// set the factory address here so that the yieldAggregator can be deployed.

// Optimism Sepolia
SHARES_FACTORY[OPTIMISM_TESTNET] = 0x4509932e2f18b622F454cf73FAc8069901fbbebC;
WETH[OPTIMISM_TESTNET] = 0x4200000000000000000000000000000000000006;
AAVE_POOL[OPTIMISM_TESTNET] = 0xb50201558B00496A145fE76f7424749556E326D8;
AAVE_WETH_GATEWAY[OPTIMISM_TESTNET] = 0x589750BA8aF186cE5B55391B0b7148cAD43a1619;
SHARES_FACTORY[OPTIMISM_SEPOLIA] = 0x1637A51717db3F62f836944FdE09BFA4C673b2D9;
WETH[OPTIMISM_SEPOLIA] = 0x4200000000000000000000000000000000000006;
AAVE_POOL[OPTIMISM_SEPOLIA] = 0xb50201558B00496A145fE76f7424749556E326D8;
AAVE_WETH_GATEWAY[OPTIMISM_SEPOLIA] = 0x589750BA8aF186cE5B55391B0b7148cAD43a1619;

// Optimism Mainnet
SHARES_FACTORY[OPTIMISM_MAINNET] = 0x3eC4241152E5CEc606E1F0FB45448251221104E7;
SHARES_FACTORY[OPTIMISM_MAINNET] = 0xc2BDb7510CDD65a1bA7aD9b490033563b24f141F;
WETH[OPTIMISM_MAINNET] = 0x4200000000000000000000000000000000000006;
AAVE_POOL[OPTIMISM_MAINNET] = 0x794a61358D6845594F94dc1DB02A252b5b4814aD;
AAVE_WETH_GATEWAY[OPTIMISM_MAINNET] = 0xe9E52021f4e11DEAD8661812A0A6c8627abA2a54;

// Cyber Testnet
WETH[CYBER_TESTNET] = 0x4200000000000000000000000000000000000006;
SHARES_FACTORY[CYBER_TESTNET] = address(0);
WETH[CYBER_TESTNET] = 0x4200000000000000000000000000000000000006;
AAVE_POOL[CYBER_TESTNET] = address(0);
AAVE_WETH_GATEWAY[CYBER_TESTNET] = address(0);

Expand Down
6 changes: 3 additions & 3 deletions scripts/DeployAave.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ contract DeployAaveScript is BaseScript {
AaveYieldAggregator public aaveYieldAggregator;

function run() public virtual broadcast {
require(SHARES_FACTORY[block.chainid] != address(0), "SAHRES_FACTORY not set");
require(SHARES_FACTORY[block.chainid] != address(0), "SHARES_FACTORY not set");
require(WETH[block.chainid] != address(0), "WETH not set");
require(AAVE_POOL[block.chainid] != address(0), "AAVE_POOL not set");
require(AAVE_WETH_GATEWAY[block.chainid] != address(0), "AAVE_WETH_GATEWAY not set");

if (
block.chainid == OPTIMISM_MAINNET ||
block.chainid == OPTIMISM_TESTNET
block.chainid == OPTIMISM_SEPOLIA
) {
aaveYieldAggregator = new AaveYieldAggregator(
SHARES_FACTORY[block.chainid],
Expand All @@ -31,7 +31,7 @@ contract DeployAaveScript is BaseScript {

/*
********************************************************************************
* Mauunal steps to be executed after deploying this script
* Manual steps to be executed after deploying this script
********************************************************************************
*/

Expand Down
12 changes: 8 additions & 4 deletions scripts/Deploy.s.sol → scripts/DeployCore.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ import { SharesFactoryV1 } from "contracts/core/SharesFactoryV1.sol";
import { SharesERC1155 } from "contracts/core/SharesERC1155.sol";
import { BlankYieldAggregator } from "contracts/core/aggregator/BlankYieldAggregator.sol";

contract DeployScript is BaseScript {
contract DeployCoreScript is BaseScript {
SharesFactoryV1 public sharesFactory;
SharesERC1155 public sharesNFT;
BlankYieldAggregator public blankYieldAggregator;

string public constant BASE_URI = "https://vv.meme/shares/uri/";
// ERC1155 Base URI
// should be set to `https://api.vv.meme/api/v1/metadata/` in mainnet
string public constant BASE_URI = "https://dev-api.vv.meme/api/v1/metadata/";

// Curve Params
uint96 public constant BASE_PRICE = 0.001 ether;
uint32 public constant INFLECTION_POINT = 1000;
uint128 public constant INFLECTION_PRICE = 0.1 ether;
Expand All @@ -24,7 +28,7 @@ contract DeployScript is BaseScript {
sharesNFT = new SharesERC1155(BASE_URI);
sharesFactory = new SharesFactoryV1(address(sharesNFT), BASE_PRICE, INFLECTION_POINT, INFLECTION_PRICE, LINEAR_PRICE_SLOPE);
blankYieldAggregator = new BlankYieldAggregator(address(sharesFactory), WETH[block.chainid]);

// initialize
sharesFactory.resetYield(address(blankYieldAggregator));
sharesNFT.setFactory(address(sharesFactory));
Expand All @@ -34,7 +38,7 @@ contract DeployScript is BaseScript {

/*
********************************************************************************
* Mauunal steps to be executed after deploying this script
* Manual steps to be executed after deploying this script
********************************************************************************
*/

Expand Down

0 comments on commit 0ae7aef

Please sign in to comment.