Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ out/
/broadcast/*/*/run-[0-9]*.json
/broadcast/**/dry-run/

# Ignores development address logs
!/script/output
/script/output/*/output-[0-9]*.json
/script/output/*/dry-run/*.json

# Docs
docs/

Expand Down
28 changes: 22 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Easily deploy the Sky allocation system and Spark ALM controller to any EVM-comp

- [`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`
- Mock contracts: `vat`, `usdsJoin`, `usds`, `sUsds`, `jug`, `usdsDai`, `dai`, `daiJoin`, `psmLite`

## Prerequisites

Expand All @@ -21,21 +21,25 @@ To deploy and configure contracts to the Avalanche Fuji public testnet:
- 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`
2. Set correct variables inside `script/input/{CHAIN_ID}/input.json` based on the "Configuration Variables" section below

3. Dry-run a transaction to determine the amount of required gas
3. Create correct output folders in `script` (`script/output/{CHAIN_ID}/dry-run/`) to log created contracts address correctly

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

4. Get enough gas tokens using a faucet
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.

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

6. (optional) Commit generated output folder to record deployed contract addresses
8. (optional) Commit generated `broadcast/SetUpAll.s.sol/11155111/run-latest.json` and `script/output/11155111/output-latest.json` to record deployed contract addresses


## Environment Variables
Expand Down Expand Up @@ -69,6 +73,18 @@ To deploy and configure contracts to the Avalanche Fuji public testnet:
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/solana-programs#devnet-program-addresses))|
| `cctpTokenMessenger` | Address of the CCTP Token Messenger contract on the target chain ([see EVM contracts](https://developers.circle.com/cctp/evm-smart-contracts#tokenmessenger-testnet)) |
| `cctpRecipient` | USDC token account of the CCTP transfer recipient in HEX, decode can be done using tools like [this](https://appdevtools.com/base58-encoder-decoder). _It should correspond to the destination domain_ |
| `usdc` | Address of the USDC token contract on the target chain ([see contract addresses](https://developers.circle.com/stablecoins/usdc-contract-addresses)) |
| `relayer` | Address of the relayer to be used by the ALM controller |


### Running Tests

Expand Down
2,026 changes: 1,273 additions & 753 deletions broadcast/SetUpAll.s.sol/11155111/run-latest.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ optimizer = true
optimizer_runs = 200
verbosity = 1
fs_permissions = [
{ access = "read", path = "./script/input/"}
{ access = "read", path = "./script/input/"},
{ access = "read-write", path = "./script/output/"}
]
[rpc_endpoints]
fuji = "${FUJI_RPC_URL}"
Expand Down
41 changes: 33 additions & 8 deletions script/SetUpAll.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,20 @@ contract SetUpAll is Script {
function setUp() public {}

function run() public {
vm.setEnv("FOUNDRY_EXPORTS_OVERWRITE_LATEST", "true");

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();
MockContracts memory mocks = SetUpAllLib.deployMockContracts(usdc, admin);

// 2. Deploy AllocatorSystem
AllocatorSharedInstance memory sharedInstance = AllocatorDeploy.deployShared(deployer.addr, admin);
Expand All @@ -40,23 +44,44 @@ contract SetUpAll is Script {
address[] memory relayers = new address[](1);
relayers[0] = config.readAddress(".relayer");

ControllerInstance memory controllerInstance = SetUpAllLib.setUpAllocatorAndALMController({
SetUpAllLib.AllocatorSetupParams memory params = SetUpAllLib.AllocatorSetupParams({
ilk: ilk,
ilkInstance: ilkInstance,
sharedInstance: sharedInstance,
mocks: mocks,
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({
controllerInstance: controllerInstance,
usdcUnitSize: config.readUint(".usdcUnitSize"),
susds: address(mocks.susds)
});
SetUpAllLib.setMainnetControllerRateLimits(
SetUpAllLib.RateLimitParams({
controllerInstance: controllerInstance,
usdcUnitSize: config.readUint(".usdcUnitSize"),
susds: address(mocks.susds),
cctpDestinationDomain: uint32(config.readUint(".cctpDestinationDomain")),
cctpRecipient: config.readBytes32(".cctpRecipient")
})
);

vm.stopBroadcast();

// 5. Log contract addresses
bool isBroadCast = vm.isContext(VmSafe.ForgeContext.ScriptBroadcast);
string memory outputSlug = isBroadCast ? "output" : "dry-run/output";
ScriptTools.exportContract(outputSlug, "almProxy", controllerInstance.almProxy);
ScriptTools.exportContract(outputSlug, "controller", controllerInstance.controller);
ScriptTools.exportContract(outputSlug, "rateLimits", controllerInstance.rateLimits);
ScriptTools.exportContract(outputSlug, "dai", mocks.dai);
ScriptTools.exportContract(outputSlug, "daiJoin", mocks.daiJoin);
ScriptTools.exportContract(outputSlug, "daiUsds", mocks.daiUsds);
ScriptTools.exportContract(outputSlug, "usds", mocks.usds);
ScriptTools.exportContract(outputSlug, "usdsJoin", mocks.usdsJoin);
ScriptTools.exportContract(outputSlug, "susds", mocks.susds);
ScriptTools.exportContract(outputSlug, "vat", mocks.vat);
ScriptTools.exportContract(outputSlug, "jug", mocks.jug);
ScriptTools.exportContract(outputSlug, "psm", mocks.psm);
}
}
9 changes: 6 additions & 3 deletions script/input/11155111/input.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"relayer": "0x5B4724De84203cB05F126a29D92065Ad08f7F34B",
"cctpTokenMessenger": "0x9f3B8679c73C2Fef8b59B4f3444d4e156fb70AA5",
"ilk": "ALLOCATOR_STAR_A",
"usdcUnitSize": 10
"usdcUnitSize": 10,
"cctpDestinationDomain": "5",
"cctpTokenMessenger": "0x9f3B8679c73C2Fef8b59B4f3444d4e156fb70AA5",
"cctpRecipient": "0x98997f46cd297f909c83b8b140d7725d00e61413ad5942760e8cb819acbcd7ce",
"usdc": "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
"relayer": "0x9b688229dfdf12dbc98d3096cc66c13fe11c81f4"
}
9 changes: 6 additions & 3 deletions script/input/43113/input.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"relayer": "0x1234567890abcdef1234567890abcdef12345678",
"cctpTokenMessenger": "0xeb08f243E5d3FCFF26A9E38Ae5520A669f4019d0",
"ilk": "ALLOCATOR_STAR_A",
"usdcUnitSize": 10
"usdcUnitSize": 10,
"cctpDestinationDomain": "5",
"cctpTokenMessenger": "0xeb08f243E5d3FCFF26A9E38Ae5520A669f4019d0",
"cctpRecipient": "0x98997f46cd297f909c83b8b140d7725d00e61413ad5942760e8cb819acbcd7ce",
"usdc": "0x5425890298aed601595a70AB815c96711a31Bc65",
"relayer": "0x9b688229dfdf12dbc98d3096cc66c13fe11c81f4"
}
14 changes: 14 additions & 0 deletions script/output/11155111/output-latest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"almProxy": "0xa2124b543565174b43ba8a16ED017967B1d6738F",
"controller": "0x2eE1fC29649f12bD924FE30084EeA6f55BB6C1f1",
"dai": "0x497950ad3b4D39375dB7Ae26a22C0455068e8304",
"daiJoin": "0x52F3E481DE4DfD63042e80ba56f38B923145D6C1",
"daiUsds": "0xC675c2a38a7221a441B702DA1863e7Cc9B234845",
"jug": "0x4a05900747c408467b4d8667589190b1a3bA2AB5",
"psm": "0xF5c24AfD262297DC304Af4827053a12E66E18974",
"rateLimits": "0x7DebC9036aC033a75fB466e97368f4613B92E8d0",
"susds": "0xF0214867b8004f12D254d2261aB066D3E1C0272c",
"usds": "0x43C22430f8B017650553752f1924A2550185d051",
"usdsJoin": "0xA857e55a12868a0E9F73b0b8B0afD1f81c7F6579",
"vat": "0x10E15DD253d0F5981D1860C8151dfDBb8BbF802C"
}
Loading