Skip to content
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
48 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
ebbcb88
feat: allow multi collateral
SidestreamStrongStrawberry Jul 7, 2025
d51d72a
feat: enable swapping usds to usdc and back
SidestreamStrongStrawberry Jul 7, 2025
fcdaeb3
feat: enable transferUSDCToCCTP
SidestreamStrongStrawberry Jul 7, 2025
b319326
chore: update readme
SidestreamStrongStrawberry Jul 7, 2025
2196b31
chore: format
SidestreamStrongStrawberry Jul 7, 2025
35893e4
chore: update readme and add amount check before function call
SidestreamStrongStrawberry Jul 8, 2025
943d05b
chore: update readme & remove redundant set
SidestreamStrongStrawberry Jul 8, 2025
07ae5d1
chore: update readme & cleanup
SidestreamStrongStrawberry Jul 8, 2025
61ff19f
add deployment
SidestreamStrongStrawberry Jul 8, 2025
c41febc
chore: format
SidestreamStrongStrawberry Jul 8, 2025
060fd7e
chore: update output log
SidestreamStrongStrawberry Jul 14, 2025
5f63b8a
Merge branch 'main' into add-cctp-support
SidestreamStrongStrawberry Jul 14, 2025
1f62b11
chore: update readme
SidestreamStrongStrawberry Jul 14, 2025
4f0f7da
chore: fmt
SidestreamStrongStrawberry Jul 14, 2025
9d6b5be
refactor: use separate mock for each contract
SidestreamStrongStrawberry Jul 14, 2025
f93b9ee
chore: bring import back
SidestreamStrongStrawberry Jul 14, 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
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "lib/dss-allocator"]
path = lib/dss-allocator
url = https://github.com/sky-ecosystem/dss-allocator
[submodule "lib/sky-star-alm-controller"]
path = lib/sky-star-alm-controller
url = https://github.com/sidestream-tech/sky-star-alm-controller
102 changes: 101 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,101 @@
# 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`, `daiJoin`, `psmLite`

## Prerequisites

- [Foundry](https://book.getfoundry.sh/) must be installed.


## Quick Start

To deploy and configure contracts to the Avalanche Fuji public testnet:

1. Set environment variables
- Copy the example environment via `cp .env.dev .env`
- Edit `.env` to update the variables as described in the "Environment Variables" section below

2. Set the desired ALM `relayer` address inside `script/input/{CHAIN_ID}/input.json`

3. Set the desired CCTP `recipient` address inside `script/input/{CHAIN_ID}/input.json`

4. Dry-run a transaction to determine the amount of required gas
```sh
forge script script/SetUpAll.s.sol:SetUpAll --fork-url fuji -vv
```

5. Get enough gas tokens using a faucet

6. (optional) Required for CCTP testing: Get enough testnet USDC from [Circle USDC faucet](https://faucet.circle.com/). This is required by the LitePSM mock contract which expects USDC to be present on the deployer wallet.

7. Deploy, configure and verify contracts
```sh
forge script script/SetUpAll.s.sol:SetUpAll --fork-url fuji -vv --broadcast --verify --slow
```

8. (optional) Commit 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` 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`
2. Add new `*_RPC_URL` to the `.env` pointing to the PRC endpoint for the chain specified above, e.g:
```toml
SEPOLIA_RPC_URL = "https://..."
```
3. Create `script/input/{CHAIN_ID}/input.json` file with relevant content
4. Add the new verification endpoint to the [`foundry.toml`](./foundry.toml), e.g:
```toml
sepolia = { key = "${ETHERSCAN_API_KEY}", chain = 11155111 }
```
5. Add the new `rpc_endpoints` in [`foundry.toml`](./foundry.toml), e.g.:
```toml
sepolia = "${SEPOLIA_RPC_URL}"
```
6. Follow the "Quick start" section, while specifying the chain name under `--fork-url` (e.g. `sepolia`) when running the script, e.g.:
```sh
forge script script/SetUpAll.s.sol:SetUpAll --fork-url ${CHAIN} -vv
`````

### `input.json` Configuration Variables

| Variable | Description |
|-------------------------|------------------------------------------------------------------------------------------------------------------------------------|
| `ilk` | Collateral type identifier (e.g., `"ALLOCATOR_STAR_A"`) |
| `usdcUnitSize` | Amount of USDC (in smallest units, e.g., wei) to use for testing (default: 10) |
| `cctpDestinationDomain` | CCTP destination domain ID for cross-chain messaging ([see supported domains](https://developers.circle.com/cctp/supported-domains))|
| `usdc` | Address of the USDC token contract on the target chain ([see contract addresses](https://developers.circle.com/stablecoins/usdc-contract-addresses)) |
| `cctpTokenMessenger` | Address of the CCTP Token Messenger contract on the target chain ([see EVM contracts](https://developers.circle.com/cctp/evm-smart-contracts)) |
| `relayer` | Address of the relayer to be used by the ALM controller |
| `cctpRecipient` | Address of the CCTP transfer recipient (should correspond to the destination domain) |




### Running Tests

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

- Run a specific test by name:
```sh
forge test --match-test ${YourTestName} -vvv
```
1,862 changes: 1,862 additions & 0 deletions broadcast/SetUpAll.s.sol/11155111/run-latest.json

Large diffs are not rendered by default.

1,898 changes: 1,898 additions & 0 deletions broadcast/SetUpAll.s.sol/43113/run-latest.json

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[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}"
sepolia = "${SEPOLIA_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" }
sepolia = {key = "${ETHERSCAN_API_KEY}", chain = 11155111 }

# 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/sky-star-alm-controller
68 changes: 68 additions & 0 deletions script/SetUpAll.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// 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 {SetUpAllLib, MockContracts, ControllerInstance} from "src/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 {
VmSafe.Wallet memory deployer = vm.createWallet(vm.envUint("PRIVATE_KEY"));
address admin = deployer.addr;

string memory config = ScriptTools.loadConfig("input");
bytes32 ilk = ScriptTools.stringToBytes32(config.readString(".ilk"));
address usdc = config.readAddress(".usdc");

vm.startBroadcast(deployer.privateKey);

// 1. Deploy mock contracts
MockContracts memory mocks = SetUpAllLib.deployMockContracts(usdc, admin);

// 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));

// 3. Set up AllocatorSystem and Deploy and set up ALM controller
address[] memory relayers = new address[](1);
relayers[0] = config.readAddress(".relayer");

SetUpAllLib.AllocatorSetupParams memory params = SetUpAllLib.AllocatorSetupParams({
ilk: ilk,
ilkInstance: ilkInstance,
sharedInstance: sharedInstance,
admin: admin,
mocks: mocks,
cctp: config.readAddress(".cctpTokenMessenger"),
relayers: relayers
});
ControllerInstance memory controllerInstance = SetUpAllLib.setUpAllocatorAndALMController(params);

// 4. Set up rate limits for the controller
SetUpAllLib.setMainnetControllerRateLimits(
SetUpAllLib.RateLimitParams({
controllerInstance: controllerInstance,
usdcUnitSize: config.readUint(".usdcUnitSize"),
susds: address(mocks.susds),
cctpDestinationDomain: uint32(config.readUint(".cctpDestinationDomain")),
cctpRecipient: ScriptTools.stringToBytes32(config.readString(".cctpRecipient"))
})
);

vm.stopBroadcast();
}
}
9 changes: 9 additions & 0 deletions script/input/11155111/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"ilk": "ALLOCATOR_STAR_A",
"usdcUnitSize": 10,
"cctpDestinationDomain": "5",
"usdc": "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
"cctpTokenMessenger": "0x9f3B8679c73C2Fef8b59B4f3444d4e156fb70AA5",
"relayer": "0x5B4724De84203cB05F126a29D92065Ad08f7F34B",
"cctpRecipient": "6gypsJcUpikWPNdaisLCUKdbL4aeGv2Zs1bx3wLnv4iP"
}
9 changes: 9 additions & 0 deletions script/input/43113/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"ilk": "ALLOCATOR_STAR_A",
"usdcUnitSize": 10,
"cctpDestinationDomain": "5",
"usdc": "0x5425890298aed601595a70ab815c96711a31bc65",
"cctpTokenMessenger": "0xeb08f243E5d3FCFF26A9E38Ae5520A669f4019d0",
"relayer": "0x1234567890abcdef1234567890abcdef12345678",
"cctpRecipient": "6gypsJcUpikWPNdaisLCUKdbL4aeGv2Zs1bx3wLnv4iP"
}
Loading