generated from ZumZoom/solidity-template
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #107 from 1inch/chore/SC-1245-Deploy-test-stand
[SC-1245][SC-1256] Deploy test stand
- Loading branch information
Showing
21 changed files
with
770 additions
and
290 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
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,3 +1,4 @@ | ||
ignore: | ||
- "test" | ||
- "contracts/mocks" | ||
- "script" |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 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,51 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.23; | ||
|
||
import { Script } from "forge-std/Script.sol"; | ||
|
||
import { ICreate3Deployer } from "solidity-utils/contracts/interfaces/ICreate3Deployer.sol"; | ||
|
||
import { EscrowFactory } from "contracts/EscrowFactory.sol"; | ||
|
||
// solhint-disable no-console | ||
import { console } from "forge-std/console.sol"; | ||
|
||
contract DeployEscrowFactory is Script { | ||
uint32 public constant RESCUE_DELAY = 691200; // 8 days | ||
bytes32 public constant CROSSCHAIN_SALT = keccak256("1inch EscrowFactory"); | ||
|
||
address public constant LOP = 0x111111125421cA6dc452d289314280a0f8842A65; // All chains | ||
address public constant ACCESS_TOKEN = 0xACCe550000159e70908C0499a1119D04e7039C28; // All chains | ||
ICreate3Deployer public constant CREATE3_DEPLOYER = ICreate3Deployer(0x65B3Db8bAeF0215A1F9B14c506D2a3078b2C84AE); // All chains | ||
|
||
mapping(uint256 => address) public FEE_TOKEN; | ||
|
||
function run() external { | ||
FEE_TOKEN[1] = 0x6B175474E89094C44Da98b954EedeAC495271d0F; // Mainnet (DAI) | ||
FEE_TOKEN[56] = 0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3; // BSC (DAI) | ||
FEE_TOKEN[137] = 0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063; // Polygon (DAI) | ||
FEE_TOKEN[43114] = 0xd586E7F844cEa2F87f50152665BCbc2C279D8d70; // Avalanche (DAI) | ||
FEE_TOKEN[100] = 0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d; // Gnosis (wXDAI) | ||
FEE_TOKEN[42161] = 0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1; // Arbitrum One (DAI) | ||
FEE_TOKEN[10] = 0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1; // Optimism (DAI) | ||
FEE_TOKEN[8453] = 0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb; // Base (DAI) | ||
|
||
address deployer = vm.envAddress("DEPLOYER_ADDRESS"); | ||
address feeBankOwner = deployer; | ||
address feeToken = FEE_TOKEN[block.chainid]; | ||
|
||
vm.startBroadcast(); | ||
address escrowFactory = CREATE3_DEPLOYER.deploy( | ||
CROSSCHAIN_SALT, | ||
abi.encodePacked( | ||
type(EscrowFactory).creationCode, | ||
abi.encode(LOP, feeToken, ACCESS_TOKEN, feeBankOwner, RESCUE_DELAY, RESCUE_DELAY) | ||
) | ||
); | ||
vm.stopBroadcast(); | ||
|
||
console.log("Escrow Factory deployed at: ", escrowFactory); | ||
} | ||
} | ||
// solhint-enable no-console |
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,52 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.23; | ||
|
||
import { Script } from "forge-std/Script.sol"; | ||
import { Address } from "solidity-utils/contracts/libraries/AddressLib.sol"; | ||
|
||
import { IBaseEscrow } from "contracts/interfaces/IBaseEscrow.sol"; | ||
import { IResolverExample } from "contracts/interfaces/IResolverExample.sol"; | ||
import { Timelocks, TimelocksLib } from "contracts/libraries/TimelocksLib.sol"; | ||
|
||
contract CancelDst is Script { | ||
function run() external { | ||
address deployer = vm.envAddress("DEPLOYER_ADDRESS"); | ||
uint256 deployerPK = vm.envUint("DEPLOYER_PRIVATE_KEY"); | ||
IResolverExample resolver = IResolverExample(vm.envAddress("RESOLVER")); | ||
// address srcToken = vm.envAddress("TOKEN_SRC"); | ||
address dstToken = address(0); // ETH | ||
bytes32 orderHash = vm.envBytes32("ORDER_HASH"); | ||
Timelocks timelocks = Timelocks.wrap(vm.envUint("TIMELOCKS")); | ||
uint256 deployedAt = vm.envUint("DEPLOYED_AT"); | ||
|
||
timelocks = TimelocksLib.setDeployedAt(timelocks, deployedAt); | ||
bytes32 secret = keccak256(abi.encodePacked("secret")); | ||
bytes32 hashlock = keccak256(abi.encode(secret)); | ||
uint256 dstAmount = 1; // 1 USDC | ||
uint256 safetyDeposit = 1; | ||
|
||
IBaseEscrow.Immutables memory immutables = IBaseEscrow.Immutables({ | ||
orderHash: orderHash, | ||
amount: dstAmount, | ||
maker: Address.wrap(uint160(deployer)), | ||
taker: Address.wrap(uint160(address(resolver))), | ||
token: Address.wrap(uint160(dstToken)), | ||
hashlock: hashlock, | ||
safetyDeposit: safetyDeposit, | ||
timelocks: timelocks | ||
}); | ||
|
||
address escrow = vm.envAddress("ESCROW_DST"); | ||
// address escrow = IEscrowFactory(escrowFactory).addressOfEscrowDst(immutables); | ||
|
||
address[] memory targets = new address[](1); | ||
bytes[] memory data = new bytes[](1); | ||
targets[0] = escrow; | ||
data[0] = abi.encodeWithSelector(IBaseEscrow(escrow).cancel.selector, immutables); | ||
|
||
vm.startBroadcast(deployerPK); | ||
resolver.arbitraryCalls(targets, data); | ||
vm.stopBroadcast(); | ||
} | ||
} |
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,54 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.23; | ||
|
||
import { Script } from "forge-std/Script.sol"; | ||
import { Address } from "solidity-utils/contracts/libraries/AddressLib.sol"; | ||
|
||
import { IBaseEscrow } from "contracts/interfaces/IBaseEscrow.sol"; | ||
import { IEscrowFactory } from "contracts/interfaces/IEscrowFactory.sol"; | ||
import { IResolverExample } from "contracts/interfaces/IResolverExample.sol"; | ||
import { Timelocks, TimelocksLib } from "contracts/libraries/TimelocksLib.sol"; | ||
|
||
|
||
contract CancelSrc is Script { | ||
function run() external { | ||
address deployer = vm.envAddress("DEPLOYER_ADDRESS"); | ||
uint256 deployerPK = vm.envUint("DEPLOYER_PRIVATE_KEY"); | ||
IResolverExample resolver = IResolverExample(vm.envAddress("RESOLVER")); | ||
address escrowFactory = vm.envAddress("ESCROW_FACTORY"); | ||
address srcToken = vm.envAddress("TOKEN_SRC"); | ||
bytes32 orderHash = vm.envBytes32("ORDER_HASH"); | ||
Timelocks timelocks = Timelocks.wrap(vm.envUint("TIMELOCKS")); | ||
uint256 deployedAt = vm.envUint("DEPLOYED_AT"); | ||
|
||
timelocks = TimelocksLib.setDeployedAt(timelocks, deployedAt); | ||
bytes32 secret = keccak256(abi.encodePacked("secret")); | ||
bytes32 hashlock = keccak256(abi.encode(secret)); | ||
uint256 srcAmount = 1; // 1 USDC | ||
uint256 safetyDeposit = 1; | ||
|
||
IBaseEscrow.Immutables memory immutables = IBaseEscrow.Immutables({ | ||
orderHash: orderHash, | ||
amount: srcAmount, | ||
maker: Address.wrap(uint160(deployer)), | ||
taker: Address.wrap(uint160(address(resolver))), | ||
token: Address.wrap(uint160(srcToken)), | ||
hashlock: hashlock, | ||
safetyDeposit: safetyDeposit, | ||
timelocks: timelocks | ||
}); | ||
|
||
// address escrow = vm.envAddress("ESCROW_SRC"); | ||
address escrow = IEscrowFactory(escrowFactory).addressOfEscrowSrc(immutables); | ||
|
||
address[] memory targets = new address[](1); | ||
bytes[] memory data = new bytes[](1); | ||
targets[0] = escrow; | ||
data[0] = abi.encodeWithSelector(IBaseEscrow(escrow).cancel.selector, immutables); | ||
|
||
vm.startBroadcast(deployerPK); | ||
resolver.arbitraryCalls(targets, data); | ||
vm.stopBroadcast(); | ||
} | ||
} |
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,51 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.23; | ||
|
||
import { Script } from "forge-std/Script.sol"; | ||
|
||
import { Timelocks } from "contracts/libraries/TimelocksLib.sol"; | ||
import { IBaseEscrow } from "contracts/interfaces/IBaseEscrow.sol"; | ||
import { IResolverExample } from "contracts/interfaces/IResolverExample.sol"; | ||
|
||
import { CrossChainTestLib } from "test/utils/libraries/CrossChainTestLib.sol"; | ||
|
||
contract DeployEscrowDst is Script { | ||
function run() external { | ||
address deployer = vm.envAddress("DEPLOYER_ADDRESS"); | ||
uint256 deployerPK = vm.envUint("DEPLOYER_PRIVATE_KEY"); | ||
IResolverExample resolver = IResolverExample(vm.envAddress("RESOLVER")); | ||
bytes32 orderHash = vm.envBytes32("ORDER_HASH"); | ||
Timelocks timelocks = Timelocks.wrap(vm.envUint("TIMELOCKS")); | ||
|
||
// Prepare data to deploy escrow | ||
address maker = deployer; | ||
address dstToken = address(0); // ETH | ||
uint256 dstAmount = 1; // ETH | ||
uint256 safetyDeposit = 1; | ||
bytes32 secret = keccak256(abi.encodePacked("secret")); | ||
bytes32 hashlock = keccak256(abi.encode(secret)); | ||
|
||
IBaseEscrow.Immutables memory escrowImmutables = CrossChainTestLib.buildDstEscrowImmutables( | ||
orderHash, | ||
hashlock, | ||
dstAmount, | ||
maker, | ||
address(resolver), | ||
dstToken, | ||
safetyDeposit, | ||
timelocks | ||
); | ||
|
||
uint256 srcCancellationTimestamp = type(uint32).max; | ||
|
||
{ | ||
vm.startBroadcast(deployerPK); | ||
resolver.deployDst{ value: dstAmount + safetyDeposit }( | ||
escrowImmutables, | ||
srcCancellationTimestamp | ||
); | ||
vm.stopBroadcast(); | ||
} | ||
} | ||
} |
Oops, something went wrong.