Skip to content

Commit 406dd73

Browse files
feat: enable CCTP functionality (#2)
1 parent 8bd04ee commit 406dd73

File tree

20 files changed

+1829
-882
lines changed

20 files changed

+1829
-882
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ out/
77
/broadcast/*/*/run-[0-9]*.json
88
/broadcast/**/dry-run/
99

10+
# Ignores development address logs
11+
!/script/output
12+
/script/output/*/output-[0-9]*.json
13+
/script/output/*/dry-run/*.json
14+
1015
# Docs
1116
docs/
1217

README.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Easily deploy the Sky allocation system and Spark ALM controller to any EVM-comp
66

77
- [`dss-allocator`](https://github.com/sky-ecosystem/dss-allocator)
88
- [`spark-alm-controller`](https://github.com/sparkdotfi/spark-alm-controller)
9-
- Mock contracts: `vat`, `usdsJoin`, `usds`, `sUsds`, `jug`, `usdsDai`, `dai`, `psmLite`
9+
- Mock contracts: `vat`, `usdsJoin`, `usds`, `sUsds`, `jug`, `usdsDai`, `dai`, `daiJoin`, `psmLite`
1010

1111
## Prerequisites
1212

@@ -21,21 +21,25 @@ To deploy and configure contracts to the Avalanche Fuji public testnet:
2121
- Copy the example environment via `cp .env.dev .env`
2222
- Edit `.env` to update the variables as described in the "Environment Variables" section below
2323

24-
2. Set the desired ALM `relayer` address inside `script/input/{CHAIN_ID}/input.json`
24+
2. Set correct variables inside `script/input/{CHAIN_ID}/input.json` based on the "Configuration Variables" section below
2525

26-
3. Dry-run a transaction to determine the amount of required gas
26+
3. Create correct output folders in `script` (`script/output/{CHAIN_ID}/dry-run/`) to log created contracts address correctly
27+
28+
4. Dry-run a transaction to determine the amount of required gas
2729
```sh
2830
forge script script/SetUpAll.s.sol:SetUpAll --fork-url fuji -vv
2931
```
3032

31-
4. Get enough gas tokens using a faucet
33+
5. Get enough gas tokens using a faucet
34+
35+
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.
3236

33-
5. Deploy, configure and verify contracts
37+
7. Deploy, configure and verify contracts
3438
```sh
3539
forge script script/SetUpAll.s.sol:SetUpAll --fork-url fuji -vv --broadcast --verify --slow
3640
```
3741

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

4044

4145
## Environment Variables
@@ -69,6 +73,18 @@ To deploy and configure contracts to the Avalanche Fuji public testnet:
6973
forge script script/SetUpAll.s.sol:SetUpAll --fork-url ${CHAIN} -vv
7074
`````
7175
76+
### `input.json` Configuration Variables
77+
78+
| Variable | Description |
79+
|-------------------------|------------------------------------------------------------------------------------------------------------------------------------|
80+
| `ilk` | Collateral type identifier (e.g., `"ALLOCATOR_STAR_A"`) |
81+
| `usdcUnitSize` | Amount of USDC (in smallest units, e.g., wei) to use for testing (default: 10) |
82+
| `cctpDestinationDomain` | CCTP destination domain ID for cross-chain messaging ([see supported domains](https://developers.circle.com/cctp/solana-programs#devnet-program-addresses))|
83+
| `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)) |
84+
| `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_ |
85+
| `usdc` | Address of the USDC token contract on the target chain ([see contract addresses](https://developers.circle.com/stablecoins/usdc-contract-addresses)) |
86+
| `relayer` | Address of the relayer to be used by the ALM controller |
87+
7288
7389
### Running Tests
7490

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

Lines changed: 1273 additions & 753 deletions
Large diffs are not rendered by default.

foundry.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ optimizer = true
77
optimizer_runs = 200
88
verbosity = 1
99
fs_permissions = [
10-
{ access = "read", path = "./script/input/"}
10+
{ access = "read", path = "./script/input/"},
11+
{ access = "read-write", path = "./script/output/"}
1112
]
1213
[rpc_endpoints]
1314
fuji = "${FUJI_RPC_URL}"

script/SetUpAll.s.sol

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,20 @@ contract SetUpAll is Script {
2020
function setUp() public {}
2121

2222
function run() public {
23+
vm.setEnv("FOUNDRY_EXPORTS_OVERWRITE_LATEST", "true");
24+
2325
VmSafe.Wallet memory deployer = vm.createWallet(vm.envUint("PRIVATE_KEY"));
26+
2427
address admin = deployer.addr;
2528

2629
string memory config = ScriptTools.loadConfig("input");
2730
bytes32 ilk = ScriptTools.stringToBytes32(config.readString(".ilk"));
31+
address usdc = config.readAddress(".usdc");
2832

2933
vm.startBroadcast(deployer.privateKey);
3034

3135
// 1. Deploy mock contracts
32-
MockContracts memory mocks = SetUpAllLib.deployMockContracts();
36+
MockContracts memory mocks = SetUpAllLib.deployMockContracts(usdc, admin);
3337

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

43-
ControllerInstance memory controllerInstance = SetUpAllLib.setUpAllocatorAndALMController({
47+
SetUpAllLib.AllocatorSetupParams memory params = SetUpAllLib.AllocatorSetupParams({
4448
ilk: ilk,
4549
ilkInstance: ilkInstance,
4650
sharedInstance: sharedInstance,
47-
mocks: mocks,
4851
admin: admin,
52+
mocks: mocks,
4953
cctp: config.readAddress(".cctpTokenMessenger"),
5054
relayers: relayers
5155
});
56+
ControllerInstance memory controllerInstance = SetUpAllLib.setUpAllocatorAndALMController(params);
5257

5358
// 4. Set up rate limits for the controller
54-
SetUpAllLib.setMainnetControllerRateLimits({
55-
controllerInstance: controllerInstance,
56-
usdcUnitSize: config.readUint(".usdcUnitSize"),
57-
susds: address(mocks.susds)
58-
});
59+
SetUpAllLib.setMainnetControllerRateLimits(
60+
SetUpAllLib.RateLimitParams({
61+
controllerInstance: controllerInstance,
62+
usdcUnitSize: config.readUint(".usdcUnitSize"),
63+
susds: address(mocks.susds),
64+
cctpDestinationDomain: uint32(config.readUint(".cctpDestinationDomain")),
65+
cctpRecipient: config.readBytes32(".cctpRecipient")
66+
})
67+
);
5968

6069
vm.stopBroadcast();
70+
71+
// 5. Log contract addresses
72+
bool isBroadCast = vm.isContext(VmSafe.ForgeContext.ScriptBroadcast);
73+
string memory outputSlug = isBroadCast ? "output" : "dry-run/output";
74+
ScriptTools.exportContract(outputSlug, "almProxy", controllerInstance.almProxy);
75+
ScriptTools.exportContract(outputSlug, "controller", controllerInstance.controller);
76+
ScriptTools.exportContract(outputSlug, "rateLimits", controllerInstance.rateLimits);
77+
ScriptTools.exportContract(outputSlug, "dai", mocks.dai);
78+
ScriptTools.exportContract(outputSlug, "daiJoin", mocks.daiJoin);
79+
ScriptTools.exportContract(outputSlug, "daiUsds", mocks.daiUsds);
80+
ScriptTools.exportContract(outputSlug, "usds", mocks.usds);
81+
ScriptTools.exportContract(outputSlug, "usdsJoin", mocks.usdsJoin);
82+
ScriptTools.exportContract(outputSlug, "susds", mocks.susds);
83+
ScriptTools.exportContract(outputSlug, "vat", mocks.vat);
84+
ScriptTools.exportContract(outputSlug, "jug", mocks.jug);
85+
ScriptTools.exportContract(outputSlug, "psm", mocks.psm);
6186
}
6287
}

script/input/11155111/input.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
2-
"relayer": "0x5B4724De84203cB05F126a29D92065Ad08f7F34B",
3-
"cctpTokenMessenger": "0x9f3B8679c73C2Fef8b59B4f3444d4e156fb70AA5",
42
"ilk": "ALLOCATOR_STAR_A",
5-
"usdcUnitSize": 10
3+
"usdcUnitSize": 10,
4+
"cctpDestinationDomain": "5",
5+
"cctpTokenMessenger": "0x9f3B8679c73C2Fef8b59B4f3444d4e156fb70AA5",
6+
"cctpRecipient": "0x98997f46cd297f909c83b8b140d7725d00e61413ad5942760e8cb819acbcd7ce",
7+
"usdc": "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
8+
"relayer": "0x9b688229dfdf12dbc98d3096cc66c13fe11c81f4"
69
}

script/input/43113/input.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
2-
"relayer": "0x1234567890abcdef1234567890abcdef12345678",
3-
"cctpTokenMessenger": "0xeb08f243E5d3FCFF26A9E38Ae5520A669f4019d0",
42
"ilk": "ALLOCATOR_STAR_A",
5-
"usdcUnitSize": 10
3+
"usdcUnitSize": 10,
4+
"cctpDestinationDomain": "5",
5+
"cctpTokenMessenger": "0xeb08f243E5d3FCFF26A9E38Ae5520A669f4019d0",
6+
"cctpRecipient": "0x98997f46cd297f909c83b8b140d7725d00e61413ad5942760e8cb819acbcd7ce",
7+
"usdc": "0x5425890298aed601595a70AB815c96711a31Bc65",
8+
"relayer": "0x9b688229dfdf12dbc98d3096cc66c13fe11c81f4"
69
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"almProxy": "0xa2124b543565174b43ba8a16ED017967B1d6738F",
3+
"controller": "0x2eE1fC29649f12bD924FE30084EeA6f55BB6C1f1",
4+
"dai": "0x497950ad3b4D39375dB7Ae26a22C0455068e8304",
5+
"daiJoin": "0x52F3E481DE4DfD63042e80ba56f38B923145D6C1",
6+
"daiUsds": "0xC675c2a38a7221a441B702DA1863e7Cc9B234845",
7+
"jug": "0x4a05900747c408467b4d8667589190b1a3bA2AB5",
8+
"psm": "0xF5c24AfD262297DC304Af4827053a12E66E18974",
9+
"rateLimits": "0x7DebC9036aC033a75fB466e97368f4613B92E8d0",
10+
"susds": "0xF0214867b8004f12D254d2261aB066D3E1C0272c",
11+
"usds": "0x43C22430f8B017650553752f1924A2550185d051",
12+
"usdsJoin": "0xA857e55a12868a0E9F73b0b8B0afD1f81c7F6579",
13+
"vat": "0x10E15DD253d0F5981D1860C8151dfDBb8BbF802C"
14+
}

0 commit comments

Comments
 (0)