Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9b4c534
feat: init forge
SidestreamStrongStrawberry Jun 23, 2025
e009312
feat: add dss allocator and dss test modules
SidestreamStrongStrawberry Jun 23, 2025
c15b60b
feat: add allocator script
SidestreamStrongStrawberry Jun 23, 2025
c4ae984
feat: add spark-alm-controller module
SidestreamStrongStrawberry Jun 23, 2025
0dec0f6
feat: add deploy alm controller
SidestreamStrongStrawberry Jun 23, 2025
441e1c2
chore: cleanup
SidestreamStrongStrawberry Jun 23, 2025
f9d879c
feat: setup allocator and alm controller
SidestreamStrongStrawberry Jun 24, 2025
c123f78
chore: cleanup
SidestreamStrongStrawberry Jun 24, 2025
03f568c
refactor: use lib
SidestreamStrongStrawberry Jun 25, 2025
da49004
feat: add test mint, burn test
SidestreamStrongStrawberry Jun 25, 2025
6a1ee10
chore: update comment
SidestreamStrongStrawberry Jun 25, 2025
44a3df8
feat: add erc4626 functions
SidestreamStrongStrawberry Jun 25, 2025
3197509
chore: add test command
SidestreamStrongStrawberry Jun 25, 2025
ddfa7a8
refactor: remove unused instances
SidestreamStrongStrawberry Jun 25, 2025
a646714
feat: update lib
SidestreamStrongStrawberry Jun 25, 2025
c1611a4
feat: deploy daiJoin
SidestreamStrongStrawberry Jun 25, 2025
0f7d58c
feat: use controller with updated constructor
SidestreamStrongStrawberry Jun 25, 2025
93e29d4
feat: rely dai on daiJoin
SidestreamStrongStrawberry Jun 25, 2025
3550850
feat: update foundry.toml and more
SidestreamStrongStrawberry Jun 25, 2025
08cd561
refactor: remove makefile, cleanup submodules and more
SidestreamStrongStrawberry Jun 26, 2025
69f64b3
feat: update readme and comment
SidestreamStrongStrawberry Jun 26, 2025
fdf12c2
refactor: merge tests
SidestreamStrongStrawberry Jun 26, 2025
f7fc638
feat: add separate relayer
SidestreamStrongStrawberry Jun 26, 2025
9417990
refactor: remove redundant code
SidestreamStrongStrawberry Jun 26, 2025
abf0e48
refactor: cleanup mock
SidestreamStrongStrawberry Jun 26, 2025
704a049
refactor: merge setup functions & update test setup
SidestreamStrongStrawberry Jun 26, 2025
e4e4d8b
chore: update README.md
SidestreamStrongStrawberry Jun 26, 2025
e97ef0c
chore: update README.md
SidestreamStrongStrawberry Jun 26, 2025
00dcb40
lint: fmt
SidestreamStrongStrawberry Jun 26, 2025
7dc9f9f
feat: setting chainId in test
SidestreamStrongStrawberry Jun 26, 2025
eb2b545
refactor: cleanup unused import
SidestreamStrongStrawberry Jun 26, 2025
acbec06
sepolia deployment
SidestreamStrongStrawberry Jun 26, 2025
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
3 changes: 3 additions & 0 deletions .env.dev
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
38 changes: 38 additions & 0 deletions .github/workflows/test.yml
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
14 changes: 14 additions & 0 deletions .gitignore
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
12 changes: 12 additions & 0 deletions .gitmodules
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
16 changes: 16 additions & 0 deletions Makefile
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
84 changes: 83 additions & 1 deletion README.md
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
```

### 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'
```


### Running Tests

- Run all tests:
```sh
make test-all
```

- Run a specific test by name:
```sh
make test-match match="YourTestName"
```
1,898 changes: 1,898 additions & 0 deletions broadcast/SetUpAll.s.sol/43113/run-latest.json

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions foundry.toml
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
1 change: 1 addition & 0 deletions lib/dss-allocator
Submodule dss-allocator added at 226584
1 change: 1 addition & 0 deletions lib/dss-test
Submodule dss-test added at 61cf29
1 change: 1 addition & 0 deletions lib/forge-std
Submodule forge-std added at 77041d
1 change: 1 addition & 0 deletions lib/sky-star-alm-controller
79 changes: 79 additions & 0 deletions script/SetUpAll.s.sol
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");
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();
}
}
6 changes: 6 additions & 0 deletions script/input/43113/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"admin": "0x05c60a7Ea994964CF1D56c1E77B43A02afB33cCD",
"cctpTokenMessenger": "0xeb08f243E5d3FCFF26A9E38Ae5520A669f4019d0",
"ilk": "ALLOCATOR_STAR_A",
"usdcUnitSize": 10
}
Loading
Loading