Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deploy: add forge deploy script #16

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions deploy/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"optimism-sepolia": {
"rpcUrl": "https://public.stackup.sh/api/v1/node/optimism-sepolia",
"mestBaseUrl": "https://mest.io/share/",
"weth": "0x4200000000000000000000000000000000000006",
"scanUrl": "https://api-sepolia-optimism.etherscan.io/api",
"aavePool": "0xb50201558B00496A145fE76f7424749556E326D8",
"aaveGateWay": "0x589750BA8aF186cE5B55391B0b7148cAD43a1619",
"curveSetting": {
"basePrice": "5000000000000000",
"inflectionPoint": "1500",
"inflectionPrice": "102500000000000000",
"linearPriceSlope": "0"
}
}
}
117 changes: 117 additions & 0 deletions deploy/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#!/bin/bash

# run from top level:mest-protocol

# receive command line parameter, setting network name
# use: ./deploy/deploy.sh optimism-sepolia
NETWORK_NAME=$1

OUTPUT_JSON="./deploy/deployed_addresses.json"

RPC_URL=$(jq -r --arg net "$NETWORK_NAME" '.[$net].rpcUrl' ./deploy/config.json)
MEST_BASE_URL=$(jq -r --arg net "$NETWORK_NAME" '.[$net].mestBaseUrl' ./deploy/config.json)
WETH=$(jq -r --arg net "$NETWORK_NAME" '.[$net].weth' ./deploy/config.json)
SCAN_URL=$(jq -r --arg net "$NETWORK_NAME" '.[$net].scanUrl' ./deploy/config.json)
AAVE_POOL=$(jq -r --arg net "$NETWORK_NAME" '.[$net].aavePool' ./deploy/config.json)
AAVE_GATEWAY=$(jq -r --arg net "$NETWORK_NAME" '.[$net].aaveGateWay' ./deploy/config.json)

# curve setting
BASE_PRICE=$(jq -r --arg net "$NETWORK_NAME" '.[$net].curveSetting.basePrice' ./deploy/config.json)
INFLECTION_POINT=$(jq -r --arg net "$NETWORK_NAME" '.[$net].curveSetting.inflectionPoint' ./deploy/config.json)
INFLECTION_PRICE=$(jq -r --arg net "$NETWORK_NAME" '.[$net].curveSetting.inflectionPrice' ./deploy/config.json)
LINEAR_PRICE_SLOPE=$(jq -r --arg net "$NETWORK_NAME" '.[$net].curveSetting.linearPriceSlope' ./deploy/config.json)

# deploy mestERC1155
MESTERC1155_ADDRESS=$(forge create contracts/core/MestERC1155.sol:MestERC1155 \
--rpc-url $RPC_URL \
--private-key $PRIVATE_KEY \
--constructor-args $MEST_BASE_URL \
--etherscan-api-key $API_KEY \
--verifier-url $SCAN_URL \
--json | jq -r '.deployedTo')
echo "MestERC1155 deployed at address: $MESTERC1155_ADDRESS"
echo "Using RPC URL: $RPC_URL"

# deploy mestFactory
MESTFACTORY_ADDRESS=$(forge create contracts/core/MestSharesFactoryV1.sol:MestSharesFactoryV1 \
--constructor-args $MESTERC1155_ADDRESS $BASE_PRICE $INFLECTION_POINT $INFLECTION_PRICE $LINEAR_PRICE_SLOPE\
--rpc-url $RPC_URL \
--private-key $PRIVATE_KEY \
--etherscan-api-key $API_KEY \
--verifier-url $SCAN_URL \
--json | jq -r '.deployedTo')
echo "MestFactory deployed at address: $MESTFACTORY_ADDRESS"
echo "Using RPC URL: $RPC_URL"

# deploy aave yieldAggregator
AAVE_YIELDAGGREGATOR_ADDRESS=$(forge create contracts/core/aggregator/AaveYieldAggregator.sol:AaveYieldAggregator \
--constructor-args $MESTFACTORY_ADDRESS $WETH $AAVE_POOL $AAVE_GATEWAY \
--rpc-url $RPC_URL \
--private-key $PRIVATE_KEY \
--etherscan-api-key $API_KEY \
--verifier-url $SCAN_URL \
--json | jq -r '.deployedTo')
echo "Aave YieldAggregator deployed at address: $AAVE_YIELDAGGREGATOR_ADDRESS"
echo "Using RPC URL: $RPC_URL"

# deploy blank yieldAggregator
BLANK_YIELDAGGREGATOR_ADDRESS=$(forge create contracts/core/aggregator/BlankYieldAggregator.sol:BlankYieldAggregator \
--constructor-args $MESTFACTORY_ADDRESS $WETH \
--rpc-url $RPC_URL \
--private-key $PRIVATE_KEY \
--etherscan-api-key $API_KEY \
--verifier-url $SCAN_URL \
--json | jq -r '.deployedTo')
echo "Blank YieldAggregator deployed at address: $BLANK_YIELDAGGREGATOR_ADDRESS"
echo "Using RPC URL: $RPC_URL"

# record address
echo "{
\"$NETWORK_NAME\" : {
\"MestERC1155\": \"$MESTERC1155_ADDRESS\",
\"MestFactory\": \"$MESTFACTORY_ADDRESS\",
\"YieldAggregator For Aave\": \"$AAVE_YIELDAGGREGATOR_ADDRESS\",
\"YieldAggregator For Blank\": \"$BLANK_YIELDAGGREGATOR_ADDRESS\"
}
}" > $OUTPUT_JSON

# set factory for 1155
cast send $MESTERC1155_ADDRESS "setFactory(address)" $MESTFACTORY_ADDRESS --rpc-url $RPC_URL --private-key $PRIVATE_KEY
echo "Erc1155 set factory: $MESTFACTORY_ADDRESS"

# set yieldTool for factory
cast send $MESTFACTORY_ADDRESS "migrate(address)" $AAVE_YIELDAGGREGATOR_ADDRESS --rpc-url $RPC_URL --private-key $PRIVATE_KEY
echo "Factory set yield tool: $AAVE_YIELDAGGREGATOR_ADDRESS"

# verify, if verifier in create didn't work.
forge verify-contract \
--verifier-url $SCAN_URL \
--watch \
--constructor-args $(cast abi-encode "constructor(string)" $MEST_BASE_URL) \
--etherscan-api-key $API_KEY \
$MESTERC1155_ADDRESS \
contracts/core/MestERC1155.sol:MestERC1155

forge verify-contract \
--verifier-url $SCAN_URL \
--watch \
--constructor-args $(cast abi-encode "constructor(address,uint256,uint256,uint256,uint256)" $MESTERC1155_ADDRESS $BASE_PRICE $INFLECTION_POINT $INFLECTION_PRICE $LINEAR_PRICE_SLOPE) \
--etherscan-api-key $API_KEY \
$MESTFACTORY_ADDRESS \
contracts/core/MestSharesFactoryV1.sol:MestSharesFactoryV1

forge verify-contract \
--verifier-url $SCAN_URL \
--watch \
--constructor-args $(cast abi-encode "constructor(address,address,address,address)" $MESTFACTORY_ADDRESS $WETH $AAVE_POOL $AAVE_GATEWAY) \
--etherscan-api-key $API_KEY \
$AAVE_YIELDAGGREGATOR_ADDRESS \
contracts/core/aggregator/AaveYieldAggregator.sol:AaveYieldAggregator

forge verify-contract \
--verifier-url $SCAN_URL \
--watch \
--constructor-args $(cast abi-encode "constructor(address,address)" $MESTFACTORY_ADDRESS $WETH) \
--etherscan-api-key $API_KEY \
$BLANK_YIELDAGGREGATOR_ADDRESS \
contracts/core/aggregator/BlankYieldAggregator.sol:BlankYieldAggregator
8 changes: 8 additions & 0 deletions deploy/deployed_addresses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"optimism-sepolia" : {
"MestERC1155": "0x27DB12865d94288F97f6d8c9a4865e8207a23D05",
"MestFactory": "0x26c6f7FA1Fe03193D1Fb759Aac5Bda8e4b5fB4F8",
"YieldAggregator For Aave": "0x41a710CfB2CC4641FEabCDe8D882D2B476953418",
"YieldAggregator For Blank": "0x4Cbc4f4228eB3a2293CF7e746C6A5d0D5CaA286e"
}
}
Loading