-
Notifications
You must be signed in to change notification settings - Fork 0
feat: create deploy script #1
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
Merged
Merged
Changes from 19 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
9b4c534
feat: init forge
SidestreamStrongStrawberry e009312
feat: add dss allocator and dss test modules
SidestreamStrongStrawberry c15b60b
feat: add allocator script
SidestreamStrongStrawberry c4ae984
feat: add spark-alm-controller module
SidestreamStrongStrawberry 0dec0f6
feat: add deploy alm controller
SidestreamStrongStrawberry 441e1c2
chore: cleanup
SidestreamStrongStrawberry f9d879c
feat: setup allocator and alm controller
SidestreamStrongStrawberry c123f78
chore: cleanup
SidestreamStrongStrawberry 03f568c
refactor: use lib
SidestreamStrongStrawberry da49004
feat: add test mint, burn test
SidestreamStrongStrawberry 6a1ee10
chore: update comment
SidestreamStrongStrawberry 44a3df8
feat: add erc4626 functions
SidestreamStrongStrawberry 3197509
chore: add test command
SidestreamStrongStrawberry ddfa7a8
refactor: remove unused instances
SidestreamStrongStrawberry a646714
feat: update lib
SidestreamStrongStrawberry c1611a4
feat: deploy daiJoin
SidestreamStrongStrawberry 0f7d58c
feat: use controller with updated constructor
SidestreamStrongStrawberry 93e29d4
feat: rely dai on daiJoin
SidestreamStrongStrawberry 3550850
feat: update foundry.toml and more
SidestreamStrongStrawberry 08cd561
refactor: remove makefile, cleanup submodules and more
SidestreamStrongStrawberry 69f64b3
feat: update readme and comment
SidestreamStrongStrawberry fdf12c2
refactor: merge tests
SidestreamStrongStrawberry f7fc638
feat: add separate relayer
SidestreamStrongStrawberry 9417990
refactor: remove redundant code
SidestreamStrongStrawberry abf0e48
refactor: cleanup mock
SidestreamStrongStrawberry 704a049
refactor: merge setup functions & update test setup
SidestreamStrongStrawberry e4e4d8b
chore: update README.md
SidestreamStrongStrawberry e97ef0c
chore: update README.md
SidestreamStrongStrawberry 00dcb40
lint: fmt
SidestreamStrongStrawberry 7dc9f9f
feat: setting chainId in test
SidestreamStrongStrawberry eb2b545
refactor: cleanup unused import
SidestreamStrongStrawberry acbec06
sepolia deployment
SidestreamStrongStrawberry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| FOUNDRY_ROOT_CHAINID = "43113" # Avalanche Fuji Testnet Chain ID | ||
| PRIVATE_KEY = PRIVATE_KEY_PLACEHOLDER | ||
| FUJI_RPC_URL = FUJI_RPC_URL_PLACEHOLDER |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| pull_request: | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| env: | ||
| FOUNDRY_PROFILE: ci | ||
|
|
||
| jobs: | ||
| check: | ||
| name: Foundry project | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive | ||
|
|
||
| - name: Install Foundry | ||
| uses: foundry-rs/foundry-toolchain@v1 | ||
|
|
||
| - name: Run Forge fmt | ||
| run: | | ||
| forge fmt --check | ||
| id: fmt | ||
|
|
||
| - name: Run Forge build | ||
| run: | | ||
| forge build --sizes | ||
| id: build | ||
|
|
||
| - name: Run Forge tests | ||
| run: | | ||
| forge test -vvv | ||
| id: test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Compiler files | ||
| cache/ | ||
| out/ | ||
|
|
||
| # Ignores development broadcast logs | ||
| !/broadcast | ||
| /broadcast/*/*/run-[0-9]*.json | ||
| /broadcast/**/dry-run/ | ||
|
|
||
| # Docs | ||
| docs/ | ||
|
|
||
| # Dotenv file | ||
| .env |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| [submodule "lib/forge-std"] | ||
| path = lib/forge-std | ||
| url = https://github.com/foundry-rs/forge-std | ||
| [submodule "lib/dss-allocator"] | ||
| path = lib/dss-allocator | ||
| url = https://github.com/sky-ecosystem/dss-allocator | ||
| [submodule "lib/dss-test"] | ||
| path = lib/dss-test | ||
| url = https://github.com/sky-ecosystem/dss-test | ||
| [submodule "lib/sky-star-alm-controller"] | ||
| path = lib/sky-star-alm-controller | ||
| url = https://github.com/sidestream-tech/sky-star-alm-controller |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| set-up-dry-run: | ||
| @CHAIN=${chain}; \ | ||
| if [ -z "$$CHAIN" ]; then CHAIN=fuji; fi; \ | ||
| echo "Current chain: $$CHAIN"; \ | ||
| forge script script/SetUpAll.s.sol:SetUpAll --fork-url $$CHAIN -vv | ||
|
|
||
| set-up-run: | ||
| @CHAIN=${chain}; \ | ||
| if [ -z "$$CHAIN" ]; then CHAIN=fuji; fi; \ | ||
| echo "Current chain: $$CHAIN"; \ | ||
| forge script script/SetUpAll.s.sol:SetUpAll --fork-url $$CHAIN -vv --broadcast --verify --slow | ||
|
|
||
|
|
||
| test-all:; forge test | ||
|
|
||
| test-match:; forge test --match-test ${match} -vvv |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,83 @@ | ||
| # sky-star-test-setup | ||
| # Sky Star Test Setup | ||
|
|
||
| Easily deploy the Sky allocation system and Spark ALM controller to any EVM-compatible chain, including all required mock contracts. This repository is designed to help Sky Stars test and validate contracts quickly. | ||
|
|
||
| ## Included Deployments | ||
|
|
||
| - [`dss-allocator`](https://github.com/sky-ecosystem/dss-allocator) | ||
| - [`spark-alm-controller`](https://github.com/sparkdotfi/spark-alm-controller) | ||
| - Mock contracts: `vat`, `usdsJoin`, `usds`, `sUsds`, `jug`, `usdsDai`, `dai`, `psmLite` | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - [Foundry](https://book.getfoundry.sh/) must be installed. | ||
|
|
||
|
|
||
| ## Quick Start | ||
|
|
||
| ### 1. Prepare Environment | ||
|
|
||
| - Copy the example environment file: | ||
| ```sh | ||
| cp .env.dev .env | ||
| ``` | ||
| - Edit `.env` and update the variables as described below. | ||
|
|
||
| ### 2. Update ilk name | ||
|
|
||
| - Update `ilk` in [input.json](/script/input/43113/input.json) | ||
|
|
||
| ### 3. Simulate Transaction | ||
|
|
||
| - Run a dry run (default: Avalanche Fuji): | ||
| ```sh | ||
| make set-up-dry-run | ||
| ``` | ||
SidestreamStrongStrawberry marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### 4. Execute transaction on Network | ||
|
|
||
| - Broadcast the deployment and setup (default: Avalanche Fuji): | ||
| ```sh | ||
| make set-up-run | ||
| ``` | ||
|
|
||
| ### 5. Document Results | ||
|
|
||
| - Commit the generated output folder to record deployed contract addresses. | ||
|
|
||
|
|
||
| ## Environment Variables | ||
|
|
||
| | Variable | Description | | ||
| |-----------------------|-----------------------------------------------------------------------------| | ||
| | `PRIVATE_KEY` | Deployer's private key (used as admin for all contracts) | | ||
| | `FOUNDRY_ROOT_CHAINID`| Chain ID for deployment | | ||
| | `FUJI_RPC_URL` | RPC URL for Avalanche Fuji | | ||
|
|
||
|
|
||
|
|
||
| ## Deploying to Other Chains | ||
|
|
||
| 1. Update `FOUNDRY_ROOT_CHAINID` in `.env`. | ||
| 2. Add the new RPC URL in `.env`. | ||
| 3. Add the new `rpc_endpoints` in [`foundry.toml`](./foundry.toml), e.g.: | ||
| ```toml | ||
| mainnet = "${MAINNET_RPC_URL}" | ||
| ``` | ||
| 4. Specify the chain when running the script, e.g.: | ||
| ```sh | ||
| make deploy-dry-run chain='mainnet' | ||
| ``` | ||
SidestreamColdMelon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| ### Running Tests | ||
|
|
||
| - Run all tests: | ||
| ```sh | ||
| make test-all | ||
| ``` | ||
|
|
||
| - Run a specific test by name: | ||
| ```sh | ||
| make test-match match="YourTestName" | ||
| ``` | ||
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| [profile.default] | ||
| src = "src" | ||
| out = "out" | ||
| libs = ["lib"] | ||
| solc = "0.8.21" | ||
| optimizer = true | ||
| optimizer_runs = 200 | ||
| verbosity = 1 | ||
| fs_permissions = [ | ||
| { access = "read", path = "./script/input/"} | ||
| ] | ||
| [rpc_endpoints] | ||
| fuji = "${FUJI_RPC_URL}" | ||
| [etherscan] | ||
| # https://testnet.snowtrace.io/documentation/recipes/foundry-verification | ||
| fuji = { key = "verifyContract", chain = 43113, url = "https://api.routescan.io/v2/network/testnet/evm/43113/etherscan" } | ||
|
|
||
| # See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options |
Submodule dss-allocator
added at
226584
SidestreamStrongStrawberry marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
Submodule sky-star-alm-controller
added at
ea55ad
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| // SPDX-License-Identifier: UNLICENSED | ||
| pragma solidity ^0.8.21; | ||
|
|
||
| import {Script, stdJson} from "forge-std/Script.sol"; | ||
| import {VmSafe} from "forge-std/Vm.sol"; | ||
| import {ScriptTools} from "dss-test/ScriptTools.sol"; | ||
| import {AllocatorDeploy} from "dss-allocator/deploy/AllocatorDeploy.sol"; | ||
| import {AllocatorSharedInstance, AllocatorIlkInstance} from "dss-allocator/deploy/AllocatorInstances.sol"; | ||
| import {MainnetControllerDeploy} from "sky-star-alm-controller/deploy/ControllerDeploy.sol"; | ||
| import {SetUpAllLib, MockContracts, ControllerInstance} from "script/libraries/SetUpAllLib.sol"; | ||
|
|
||
| interface MainnetControllerLike { | ||
| function LIMIT_USDS_MINT() external returns (bytes32); | ||
| } | ||
|
|
||
| contract SetUpAll is Script { | ||
| using stdJson for string; | ||
|
|
||
| uint256 internal constant WAD = 10 ** 18; | ||
|
|
||
| function setUp() public {} | ||
|
|
||
| function run() public { | ||
| string memory config = ScriptTools.loadConfig("input"); | ||
| VmSafe.Wallet memory deployer = vm.createWallet(vm.envUint("PRIVATE_KEY")); | ||
| bytes32 ilk = ScriptTools.stringToBytes32(config.readString(".ilk")); | ||
| address admin = config.readAddress(".admin"); | ||
SidestreamStrongStrawberry marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| address cctpTokenMessenger = config.readAddress(".cctpTokenMessenger"); | ||
|
|
||
| vm.startBroadcast(deployer.privateKey); | ||
| // 1. Deploy mock contracts | ||
| MockContracts memory mocks = SetUpAllLib.deployMockContracts(); | ||
|
|
||
| // 2. Deploy AllocatorSystem | ||
| AllocatorSharedInstance memory sharedInstance = AllocatorDeploy.deployShared(deployer.addr, admin); | ||
| AllocatorIlkInstance memory ilkInstance = | ||
| AllocatorDeploy.deployIlk(deployer.addr, admin, sharedInstance.roles, ilk, address(mocks.usdsJoin)); | ||
|
|
||
| // 2. Set up AllocatorSystem and set up | ||
| SetUpAllLib.setUpAllocatorSystem({ | ||
| ilk: ilk, | ||
| ilkInstance: ilkInstance, | ||
| sharedInstance: sharedInstance, | ||
| mocks: mocks, | ||
| admin: admin | ||
| }); | ||
|
|
||
| // 3. Deploy MainnetController | ||
| ControllerInstance memory controllerInstance = SetUpAllLib.deployAlmController({ | ||
| admin: admin, | ||
| vault: ilkInstance.vault, | ||
| psm: mocks.psm, | ||
| daiUsds: mocks.daiUsds, | ||
| cctp: cctpTokenMessenger, | ||
| usds: mocks.usds | ||
| }); | ||
|
|
||
| // 4. Set up ALM controller | ||
| address[] memory relayers = new address[](1); | ||
| relayers[0] = deployer.addr; | ||
| SetUpAllLib.setUpAlmController({ | ||
| controllerInstance: controllerInstance, | ||
| ilkInstance: ilkInstance, | ||
| mocks: mocks, | ||
| admin: admin, | ||
| relayers: relayers, | ||
| cctpTokenMessenger: cctpTokenMessenger | ||
| }); | ||
|
|
||
| // 5. Set up rate limits for the controller | ||
| SetUpAllLib.setMainnetControllerRateLimits({ | ||
| controllerInstance: controllerInstance, | ||
| usdcUnitSize: config.readUint(".usdcUnitSize"), | ||
| susds: address(mocks.susds) | ||
| }); | ||
|
|
||
| vm.stopBroadcast(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "admin": "0x05c60a7Ea994964CF1D56c1E77B43A02afB33cCD", | ||
SidestreamStrongStrawberry marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "cctpTokenMessenger": "0xeb08f243E5d3FCFF26A9E38Ae5520A669f4019d0", | ||
| "ilk": "ALLOCATOR_STAR_A", | ||
| "usdcUnitSize": 10 | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.