-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from smart-transaction/scripts/deploy-mev-time…
…-compute-and-flash-liquidity Deploy scripts for MEV time compute and flash liquidity
- Loading branch information
Showing
25 changed files
with
177 additions
and
45 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,60 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
pragma solidity 0.8.26; | ||
|
||
import {Script} from "forge-std/Script.sol"; | ||
import {BaseDeployer} from "../BaseDeployer.s.sol"; | ||
import {FlashLiquidity} from "test/examples/DeFi/FlashLiquidity.sol"; | ||
|
||
/* solhint-disable no-console*/ | ||
import {console2} from "forge-std/console2.sol"; | ||
|
||
contract DeployFlashLiquidity is Script, BaseDeployer { | ||
address private _callBreaker; | ||
|
||
/// @dev Compute the CREATE2 addresses for contracts (proxy, counter). | ||
/// @param salt The salt for the FlashLiquidity contract. | ||
modifier computeCreate2(bytes32 salt) { | ||
_callBreaker = vm.envAddress("CALL_BREAKER_ADDRESS"); | ||
|
||
_create2addr = computeCreate2Address( | ||
salt, hashInitCode(type(FlashLiquidity).creationCode, abi.encode(_callBreaker, _ownerAddress)) | ||
); | ||
|
||
_; | ||
} | ||
|
||
/// @dev Helper to iterate over chains and select fork. | ||
/// @param deployForks The chains to deploy to. | ||
/// @return address of the deployed contract | ||
function createDeployMultichain(Chains[] memory deployForks) | ||
internal | ||
override | ||
computeCreate2(_salt) | ||
returns (address) | ||
{ | ||
console2.log("FlashLiquidity create2 address:", _create2addr, "\n"); | ||
|
||
for (uint256 i; i < deployForks.length;) { | ||
console2.log("Deploying FlashLiquidity to chain: ", uint256(deployForks[i]), "\n"); | ||
|
||
createSelectFork(deployForks[i]); | ||
|
||
chainDeploySmartedContract(); | ||
|
||
unchecked { | ||
++i; | ||
} | ||
} | ||
return _create2addr; | ||
} | ||
|
||
/// @dev Function to perform actual deployment. | ||
function chainDeploySmartedContract() private broadcast(_deployerPrivateKey) { | ||
address flashLiquidity = address(new FlashLiquidity{salt: _salt}(_callBreaker, _ownerAddress)); | ||
|
||
require(_create2addr == flashLiquidity, "Address mismatch FlashLiquidity"); | ||
|
||
console2.log("FlashLiquidity deployed at address:", flashLiquidity, "\n"); | ||
} | ||
} |
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,62 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
pragma solidity 0.8.26; | ||
|
||
import {Script} from "forge-std/Script.sol"; | ||
import {BaseDeployer} from "../BaseDeployer.s.sol"; | ||
import {MEVTimeCompute} from "test/examples/MEVOracle/MEVTimeCompute.sol"; | ||
|
||
/* solhint-disable no-console*/ | ||
import {console2} from "forge-std/console2.sol"; | ||
|
||
contract DeployMEVTimeCompute is Script, BaseDeployer { | ||
address private _callBreaker; | ||
|
||
/// @dev Compute the CREATE2 addresses for contracts (proxy, counter). | ||
/// @param salt The salt for the MEVTimeCompute contract. | ||
modifier computeCreate2(bytes32 salt) { | ||
_callBreaker = vm.envAddress("CALL_BREAKER_ADDRESS"); | ||
|
||
// passing 8 as a random divisor value for this example, can be updated with setters | ||
_create2addr = computeCreate2Address( | ||
salt, hashInitCode(type(MEVTimeCompute).creationCode, abi.encode(_callBreaker, 8)) | ||
); | ||
|
||
_; | ||
} | ||
|
||
/// @dev Helper to iterate over chains and select fork. | ||
/// @param deployForks The chains to deploy to. | ||
/// @return address of the deployed contract | ||
function createDeployMultichain(Chains[] memory deployForks) | ||
internal | ||
override | ||
computeCreate2(_salt) | ||
returns (address) | ||
{ | ||
console2.log("MEVTimeCompute create2 address:", _create2addr, "\n"); | ||
|
||
for (uint256 i; i < deployForks.length;) { | ||
console2.log("Deploying MEVTimeCompute to chain: ", uint256(deployForks[i]), "\n"); | ||
|
||
createSelectFork(deployForks[i]); | ||
|
||
chainDeploySmartedContract(); | ||
|
||
unchecked { | ||
++i; | ||
} | ||
} | ||
return _create2addr; | ||
} | ||
|
||
/// @dev Function to perform actual deployment. | ||
function chainDeploySmartedContract() private broadcast(_deployerPrivateKey) { | ||
// passing 8 as a random divisor value for this example, can be updated with setters | ||
address mevTimeCompute = address(new MEVTimeCompute{salt: _salt}(_callBreaker, 8)); | ||
|
||
require(_create2addr == mevTimeCompute, "Address mismatch MEVTimeCompute"); | ||
|
||
console2.log("MEVTimeCompute contract deployed at address:", mevTimeCompute, "\n"); | ||
} | ||
} |
File renamed without changes.
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
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
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
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
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
Oops, something went wrong.