Skip to content

Commit 8bd04ee

Browse files
feat: initial script to deploy and configure Allocator and ALM contracts (#1)
Co-authored-by: SidestreamColdMelon <[email protected]>
1 parent ef92345 commit 8bd04ee

File tree

25 files changed

+4767
-1
lines changed

25 files changed

+4767
-1
lines changed

.env.dev

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FOUNDRY_ROOT_CHAINID = "43113" # Avalanche Fuji Testnet Chain ID
2+
PRIVATE_KEY = PRIVATE_KEY_PLACEHOLDER
3+
FUJI_RPC_URL = FUJI_RPC_URL_PLACEHOLDER

.github/workflows/test.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
10+
env:
11+
FOUNDRY_PROFILE: ci
12+
13+
jobs:
14+
check:
15+
name: Foundry project
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
submodules: recursive
21+
22+
- name: Install Foundry
23+
uses: foundry-rs/foundry-toolchain@v1
24+
25+
- name: Run Forge fmt
26+
run: |
27+
forge fmt --check
28+
id: fmt
29+
30+
- name: Run Forge build
31+
run: |
32+
forge build --sizes
33+
id: build
34+
35+
- name: Run Forge tests
36+
run: |
37+
forge test -vvv
38+
id: test

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Compiler files
2+
cache/
3+
out/
4+
5+
# Ignores development broadcast logs
6+
!/broadcast
7+
/broadcast/*/*/run-[0-9]*.json
8+
/broadcast/**/dry-run/
9+
10+
# Docs
11+
docs/
12+
13+
# Dotenv file
14+
.env

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "lib/dss-allocator"]
2+
path = lib/dss-allocator
3+
url = https://github.com/sky-ecosystem/dss-allocator
4+
[submodule "lib/sky-star-alm-controller"]
5+
path = lib/sky-star-alm-controller
6+
url = https://github.com/sidestream-tech/sky-star-alm-controller

README.md

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,83 @@
1-
# sky-star-test-setup
1+
# Sky Star Test Setup
2+
3+
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.
4+
5+
## Included Deployments
6+
7+
- [`dss-allocator`](https://github.com/sky-ecosystem/dss-allocator)
8+
- [`spark-alm-controller`](https://github.com/sparkdotfi/spark-alm-controller)
9+
- Mock contracts: `vat`, `usdsJoin`, `usds`, `sUsds`, `jug`, `usdsDai`, `dai`, `psmLite`
10+
11+
## Prerequisites
12+
13+
- [Foundry](https://book.getfoundry.sh/) must be installed.
14+
15+
16+
## Quick Start
17+
18+
To deploy and configure contracts to the Avalanche Fuji public testnet:
19+
20+
1. Set environment variables
21+
- Copy the example environment via `cp .env.dev .env`
22+
- Edit `.env` to update the variables as described in the "Environment Variables" section below
23+
24+
2. Set the desired ALM `relayer` address inside `script/input/{CHAIN_ID}/input.json`
25+
26+
3. Dry-run a transaction to determine the amount of required gas
27+
```sh
28+
forge script script/SetUpAll.s.sol:SetUpAll --fork-url fuji -vv
29+
```
30+
31+
4. Get enough gas tokens using a faucet
32+
33+
5. Deploy, configure and verify contracts
34+
```sh
35+
forge script script/SetUpAll.s.sol:SetUpAll --fork-url fuji -vv --broadcast --verify --slow
36+
```
37+
38+
6. (optional) Commit generated output folder to record deployed contract addresses
39+
40+
41+
## Environment Variables
42+
43+
| Variable | Description |
44+
|-----------------------|-----------------------------------------------------------------------------|
45+
| `PRIVATE_KEY` | Deployer's private key (used as admin for all contracts) |
46+
| `FOUNDRY_ROOT_CHAINID`| Chain ID for deployment |
47+
| `FUJI_RPC_URL` | RPC URL for Avalanche Fuji |
48+
49+
50+
51+
## Deploying to Other Chains
52+
53+
1. Update `FOUNDRY_ROOT_CHAINID` in `.env` to use [chain id of the network](https://chainlist.org/) you're trying to deploy to. For example, to deploy to Sepolia that would be `11155111`
54+
2. Add new `*_RPC_URL` to the `.env` pointing to the PRC endpoint for the chain specified above, e.g:
55+
```toml
56+
SEPOLIA_RPC_URL = "https://..."
57+
```
58+
3. Create `script/input/{CHAIN_ID}/input.json` file with relevant content
59+
4. Add the new verification endpoint to the [`foundry.toml`](./foundry.toml), e.g:
60+
```toml
61+
sepolia = { key = "${ETHERSCAN_API_KEY}", chain = 11155111 }
62+
```
63+
5. Add the new `rpc_endpoints` in [`foundry.toml`](./foundry.toml), e.g.:
64+
```toml
65+
sepolia = "${SEPOLIA_RPC_URL}"
66+
```
67+
6. Follow the "Quick start" section, while specifying the chain name under `--fork-url` (e.g. `sepolia`) when running the script, e.g.:
68+
```sh
69+
forge script script/SetUpAll.s.sol:SetUpAll --fork-url ${CHAIN} -vv
70+
`````
71+
72+
73+
### Running Tests
74+
75+
- Run all tests:
76+
```sh
77+
forge test
78+
```
79+
80+
- Run a specific test by name:
81+
```sh
82+
forge test --match-test ${YourTestName} -vvv
83+
```

broadcast/SetUpAll.s.sol/11155111/run-latest.json

Lines changed: 1862 additions & 0 deletions
Large diffs are not rendered by default.

broadcast/SetUpAll.s.sol/43113/run-latest.json

Lines changed: 1898 additions & 0 deletions
Large diffs are not rendered by default.

foundry.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[profile.default]
2+
src = "src"
3+
out = "out"
4+
libs = ["lib"]
5+
solc = "0.8.21"
6+
optimizer = true
7+
optimizer_runs = 200
8+
verbosity = 1
9+
fs_permissions = [
10+
{ access = "read", path = "./script/input/"}
11+
]
12+
[rpc_endpoints]
13+
fuji = "${FUJI_RPC_URL}"
14+
sepolia = "${SEPOLIA_RPC_URL}"
15+
[etherscan]
16+
# https://testnet.snowtrace.io/documentation/recipes/foundry-verification
17+
fuji = { key = "verifyContract", chain = 43113, url = "https://api.routescan.io/v2/network/testnet/evm/43113/etherscan" }
18+
sepolia = {key = "${ETHERSCAN_API_KEY}", chain = 11155111 }
19+
20+
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options

lib/dss-allocator

Submodule dss-allocator added at 226584d

lib/sky-star-alm-controller

Submodule sky-star-alm-controller added at ea55ad8

0 commit comments

Comments
 (0)