-
Notifications
You must be signed in to change notification settings - Fork 0
feat: enable cctp transfer #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 38 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
9b4c534
feat: init forge
SidestreamStrongStrawberry e009312
feat: add dss allocator and dss test modules
SidestreamStrongStrawberry c15b60b
feat: add allocator script
SidestreamStrongStrawberry c4ae984
feat: add spark-alm-controller module
SidestreamStrongStrawberry 0dec0f6
feat: add deploy alm controller
SidestreamStrongStrawberry 441e1c2
chore: cleanup
SidestreamStrongStrawberry f9d879c
feat: setup allocator and alm controller
SidestreamStrongStrawberry c123f78
chore: cleanup
SidestreamStrongStrawberry 03f568c
refactor: use lib
SidestreamStrongStrawberry da49004
feat: add test mint, burn test
SidestreamStrongStrawberry 6a1ee10
chore: update comment
SidestreamStrongStrawberry 44a3df8
feat: add erc4626 functions
SidestreamStrongStrawberry 3197509
chore: add test command
SidestreamStrongStrawberry ddfa7a8
refactor: remove unused instances
SidestreamStrongStrawberry a646714
feat: update lib
SidestreamStrongStrawberry c1611a4
feat: deploy daiJoin
SidestreamStrongStrawberry 0f7d58c
feat: use controller with updated constructor
SidestreamStrongStrawberry 93e29d4
feat: rely dai on daiJoin
SidestreamStrongStrawberry 3550850
feat: update foundry.toml and more
SidestreamStrongStrawberry 08cd561
refactor: remove makefile, cleanup submodules and more
SidestreamStrongStrawberry 69f64b3
feat: update readme and comment
SidestreamStrongStrawberry fdf12c2
refactor: merge tests
SidestreamStrongStrawberry f7fc638
feat: add separate relayer
SidestreamStrongStrawberry 9417990
refactor: remove redundant code
SidestreamStrongStrawberry abf0e48
refactor: cleanup mock
SidestreamStrongStrawberry 704a049
refactor: merge setup functions & update test setup
SidestreamStrongStrawberry e4e4d8b
chore: update README.md
SidestreamStrongStrawberry e97ef0c
chore: update README.md
SidestreamStrongStrawberry 00dcb40
lint: fmt
SidestreamStrongStrawberry 7dc9f9f
feat: setting chainId in test
SidestreamStrongStrawberry eb2b545
refactor: cleanup unused import
SidestreamStrongStrawberry acbec06
sepolia deployment
SidestreamStrongStrawberry ebbcb88
feat: allow multi collateral
SidestreamStrongStrawberry d51d72a
feat: enable swapping usds to usdc and back
SidestreamStrongStrawberry fcdaeb3
feat: enable transferUSDCToCCTP
SidestreamStrongStrawberry b319326
chore: update readme
SidestreamStrongStrawberry 2196b31
chore: format
SidestreamStrongStrawberry 35893e4
chore: update readme and add amount check before function call
SidestreamStrongStrawberry 943d05b
chore: update readme & remove redundant set
SidestreamStrongStrawberry 07ae5d1
chore: update readme & cleanup
SidestreamStrongStrawberry 61ff19f
add deployment
SidestreamStrongStrawberry c41febc
chore: format
SidestreamStrongStrawberry 060fd7e
chore: update output log
SidestreamStrongStrawberry 5f63b8a
Merge branch 'main' into add-cctp-support
SidestreamStrongStrawberry 1f62b11
chore: update readme
SidestreamStrongStrawberry 4f0f7da
chore: fmt
SidestreamStrongStrawberry 9d6b5be
refactor: use separate mock for each contract
SidestreamStrongStrawberry f93b9ee
chore: bring import back
SidestreamStrongStrawberry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | | ||
SidestreamColdMelon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| ### 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
1,862
broadcast/SetUpAll.s.sol/11155111/run-latest.json
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Submodule dss-allocator
added at
226584
Submodule sky-star-alm-controller
added at
ea55ad
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.