-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
172 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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 @@ | ||
PRIVATE_KEY= | ||
|
||
MAINNET_RPC_URL= | ||
SEPOLIA_RPC_URL= | ||
|
||
ETHERSCAN_API_KEY= |
This file contains 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,27 +1,56 @@ | ||
## Splits v2 | ||
|
||
## Usage | ||
|
||
### Build | ||
|
||
```shell | ||
$ forge build | ||
``` | ||
`pnpm build` | ||
|
||
### Test | ||
|
||
```shell | ||
$ forge test | ||
``` | ||
`pnpm test` | ||
|
||
#### Coverage | ||
|
||
`pnpm test:coverage` | ||
|
||
#### Coverage Report | ||
|
||
`pnpm test:coverage:report` | ||
|
||
### lint | ||
|
||
`pnpm lint` | ||
|
||
### Format | ||
|
||
```shell | ||
$ forge fmt | ||
``` | ||
`pnpm format` | ||
|
||
### Deployment | ||
|
||
To deploy contracts, please ensure you have the environment variables set in `.env` file. Please refer to `.env.sample` | ||
for the required environment variables. | ||
|
||
For a chain not present in .env.sample, add the rpc url and etherscan API key to the .env.sample file and | ||
[foundry.toml](./foundry.toml) file. | ||
|
||
To understand how the configuration works, please refer to [foundry docs](https://book.getfoundry.sh/cheatcodes/rpc). | ||
|
||
Each contract has its own deployment script. A config file is present in the `config` folder for each chain. The config | ||
files contains the input needed for the constructors of the contracts. | ||
|
||
To deploy contracts and verify contracts, run the following command: | ||
|
||
#### Splits Warehouse | ||
|
||
`pnpm deploy:SplitsWarehouse` | ||
|
||
For a test run, use the following command: | ||
|
||
`pnpm deploy:SplitsWarehouse:test` | ||
|
||
#### Split Factory V2 | ||
|
||
`pnpm deploy:SplitFactoryV2` | ||
|
||
### Gas Snapshots | ||
For a test run, use the following command: | ||
|
||
```shell | ||
$ forge snapshot | ||
``` | ||
`pnpm deploy:SplitFactoryV2:test` |
This file contains 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
This file contains 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
This file contains 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
This file contains 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,27 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.18; | ||
|
||
import { SplitFactoryV2 } from "../src/splitters/SplitFactoryV2.sol"; | ||
|
||
import { BaseScript } from "./Base.s.sol"; | ||
import { console2 } from "forge-std/console2.sol"; | ||
|
||
contract SplitFactoryV2Script is BaseScript { | ||
uint88 constant DEPLOYMENT_SALT = 1; | ||
|
||
function run() public { | ||
address warehouse = getAddressFromConfig("splitsWarehouse"); | ||
|
||
bytes memory args = abi.encode(warehouse); | ||
|
||
uint256 privateKey = vm.envUint("PRIVATE_KEY"); | ||
address deployer = vm.addr(privateKey); | ||
|
||
bytes32 salt = computeSalt(deployer, bytes11(DEPLOYMENT_SALT)); | ||
|
||
vm.startBroadcast(privateKey); | ||
address factory = create3(salt, abi.encodePacked(type(SplitFactoryV2).creationCode, args)); | ||
vm.stopBroadcast(); | ||
updateDeployment(factory, "SplitFactoryV2"); | ||
} | ||
} |
This file contains 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,28 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.18; | ||
|
||
import { SplitsWarehouse } from "../src/SplitsWarehouse.sol"; | ||
|
||
import { BaseScript } from "./Base.s.sol"; | ||
import { console2 } from "forge-std/console2.sol"; | ||
|
||
contract SplitsWarehouseScript is BaseScript { | ||
uint88 constant DEPLOYMENT_SALT = 0; | ||
|
||
function run() public { | ||
string memory name = getStringFromConfig("nativeTokenName"); | ||
string memory symbol = getStringFromConfig("nativeTokenSymbol"); | ||
|
||
bytes memory args = abi.encode(name, symbol); | ||
|
||
uint256 privateKey = vm.envUint("PRIVATE_KEY"); | ||
address deployer = vm.addr(privateKey); | ||
|
||
bytes32 salt = computeSalt(deployer, bytes11(DEPLOYMENT_SALT)); | ||
|
||
vm.startBroadcast(privateKey); | ||
address warehouse = create3(salt, abi.encodePacked(type(SplitsWarehouse).creationCode, args)); | ||
vm.stopBroadcast(); | ||
updateDeployment(warehouse, "SplitsWarehouse"); | ||
} | ||
} |
This file contains 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,4 @@ | ||
{ | ||
"nativeTokenName": "Splits Wrapped Ether", | ||
"nativeTokenSymbol": "SplitsETH" | ||
} |
This file contains 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,4 @@ | ||
{ | ||
"nativeTokenName": "Splits Wrapped Ether", | ||
"nativeTokenSymbol": "SplitsETH" | ||
} |