Skip to content

Commit 6d49692

Browse files
authored
Merge pull request #70 from Merit-Systems/feat/create-test-payments
Create Test Payments
2 parents ab90f92 + 36e7c69 commit 6d49692

File tree

10 files changed

+271
-310
lines changed

10 files changed

+271
-310
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ deploy-sepolia:
5252
$(FORGE_COMMON_FLAGS)
5353

5454
# ----------------------
55-
# Deploy base -> Sepolia
55+
# Deploy to Base Sepolia
5656
# ----------------------
5757
deploy-base-sepolia:
5858
forge script script/Deploy.BaseSepolia.s.sol \
@@ -61,13 +61,13 @@ deploy-base-sepolia:
6161
$(FORGE_COMMON_FLAGS)
6262

6363
# ----------------------
64-
# Deploy to Base mainnet
64+
# Deploy to Base Mainnet
6565
# ----------------------
6666
deploy-base:
6767
forge clean
6868
forge script script/Deploy.Base.s.sol \
6969
--rpc-url $(BASE_RPC) \
70-
--sender $(SEPOLIA_SENDER) \
70+
--sender $(BASE_SENDER) \
7171
$(FORGE_COMMON_FLAGS)
7272

7373
# ---------------------------------------------------------------------------

broadcast/Deploy.Base.s.sol/8453/run-latest.json

Lines changed: 11 additions & 35 deletions
Large diffs are not rendered by default.

broadcast/Deploy.Sepolia.sol/11155111/run-latest.json

Lines changed: 90 additions & 210 deletions
Large diffs are not rendered by default.

libraries/Params.sol

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ library Params {
1818
address constant SEPOLIA_TESTER_SHAFU = 0x39053B170bBD9580d0b86e8317c685aEFB65f1ec;
1919

2020
// BASE SEPOLIA
21-
address constant BASE_SEPOLIA_WETH = 0x4200000000000000000000000000000000000006;
22-
address constant BASE_SEPOLIA_USDC = 0x081827b8C3Aa05287b5aA2bC3051fbE638F33152;
23-
address constant BASE_SEPOLIA_TESTER = 0x5C87eA705eE49a96532F45f5db606A5f5fEF9780;
21+
address constant BASESEPOLIA_WETH = 0x4200000000000000000000000000000000000006;
22+
address constant BASESEPOLIA_USDC = 0x081827b8C3Aa05287b5aA2bC3051fbE638F33152;
23+
address constant BASESEPOLIA_TESTER = 0x5C87eA705eE49a96532F45f5db606A5f5fEF9780;
24+
address constant BASESEPOLIA_TESTER_SHAFU = 0x39053B170bBD9580d0b86e8317c685aEFB65f1ec;
25+
address constant BASESEPOLIA_TESTER_JSON = 0x5C87eA705eE49a96532F45f5db606A5f5fEF9780;
2426
}

script/Deploy.Base.s.sol

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
// SPDX-License-Identifier: MIT
2-
pragma solidity ^0.8.26;
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.26;
33

4-
import {Deploy} from "./Deploy.s.sol";
5-
import {Params} from "../libraries/Params.sol";
6-
import {Script} from "forge-std/Script.sol";
4+
import {Deploy} from "./Deploy.s.sol";
5+
import {Params} from "../libraries/Params.sol";
6+
import {Script} from "forge-std/Script.sol";
7+
import {Escrow} from "../src/Escrow.sol";
78

8-
contract DeployBase is Script {
9-
function run() public {
10-
address[] memory initialWhitelistedTokens = new address[](1);
11-
initialWhitelistedTokens[0] = Params.BASE_USDC;
9+
contract DeployBase is Deploy {
10+
function run() public returns (Escrow escrow) {
11+
address[] memory initialWhitelistedTokens = new address[](1);
12+
initialWhitelistedTokens[0] = Params.BASE_USDC;
1213

13-
vm.startBroadcast();
14-
new Deploy().deploy(Params.OWNER, initialWhitelistedTokens, Params.BASE_FEE_BPS);
15-
vm.stopBroadcast();
16-
}
14+
escrow = deploy(Params.OWNER, initialWhitelistedTokens, Params.BASE_FEE_BPS);
15+
}
1716
}

script/Deploy.BaseSepolia.s.sol

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.26;
33

4-
import {Deploy} from "./Deploy.s.sol";
5-
import {Params} from "../libraries/Params.sol";
6-
import {MockERC20} from "solmate/test/utils/mocks/MockERC20.sol";
7-
import {Script} from "forge-std/Script.sol";
4+
import {DeployTestBase} from "./Deploy.Test.Base.s.sol";
5+
import {Params} from "../libraries/Params.sol";
6+
import {Script} from "forge-std/Script.sol";
7+
import {CreatePayments} from "./utils/CreatePayments.s.sol";
8+
import {Escrow} from "../src/Escrow.sol";
89

9-
contract DeployBaseSepolia is Script {
10+
contract DeployBaseSepolia is DeployTestBase {
1011
function run() public {
11-
vm.startBroadcast();
12+
address[] memory testers = new address[](3);
13+
testers[0] = Params.BASESEPOLIA_TESTER;
14+
testers[1] = Params.BASESEPOLIA_TESTER_JSON;
15+
testers[2] = Params.BASESEPOLIA_TESTER_SHAFU;
1216

13-
MockERC20 mockUSDC = new MockERC20("USD Coin", "USDC", 6);
14-
mockUSDC.mint(Params.BASE_SEPOLIA_TESTER, 1000000000000000 * 10**6);
17+
deployTestEnvironment(
18+
testers,
19+
Params.BASESEPOLIA_WETH,
20+
Params.BASESEPOLIA_USDC,
21+
Params.OWNER
22+
);
1523

16-
vm.stopBroadcast();
17-
18-
address[] memory initialWhitelistedTokens = new address[](3);
19-
initialWhitelistedTokens[0] = Params.BASE_SEPOLIA_WETH;
20-
initialWhitelistedTokens[1] = Params.BASE_SEPOLIA_USDC;
21-
initialWhitelistedTokens[2] = address(mockUSDC);
22-
23-
new Deploy().deploy(Params.OWNER, initialWhitelistedTokens, 0);
24+
createTestPayments(
25+
Params.BASESEPOLIA_TESTER_SHAFU,
26+
Params.BASESEPOLIA_TESTER_JSON
27+
);
2428
}
2529
}

script/Deploy.Sepolia.sol

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.26;
33

4-
import {Deploy} from "./Deploy.s.sol";
5-
import {Params} from "../libraries/Params.sol";
6-
import {MockERC20} from "solmate/test/utils/mocks/MockERC20.sol";
7-
import {Script} from "forge-std/Script.sol";
4+
import {DeployTestBase} from "./Deploy.Test.Base.s.sol";
5+
import {Params} from "../libraries/Params.sol";
6+
import {Script} from "forge-std/Script.sol";
7+
import {CreatePayments} from "./utils/CreatePayments.s.sol";
8+
import {Escrow} from "../src/Escrow.sol";
89

9-
contract DeploySepolia is Script {
10-
function run() public {
11-
vm.startBroadcast();
10+
contract DeploySepolia is DeployTestBase {
11+
function run() public {
12+
address[] memory testers = new address[](3);
13+
testers[0] = Params.SEPOLIA_TESTER;
14+
testers[1] = Params.SEPOLIA_TESTER_JSON;
15+
testers[2] = Params.SEPOLIA_TESTER_SHAFU;
1216

13-
MockERC20 mockUSDC = new MockERC20("USD Coin", "USDC", 6);
14-
mockUSDC.mint(Params.SEPOLIA_TESTER, 1000000000000000 * 10**6);
15-
mockUSDC.mint(Params.SEPOLIA_TESTER_JSON, 1000000000000000 * 10**6);
16-
mockUSDC.mint(Params.SEPOLIA_TESTER_SHAFU, 1000000000000000 * 10**6);
17+
deployTestEnvironment(
18+
testers,
19+
Params.SEPOLIA_WETH,
20+
Params.SEPOLIA_USDC,
21+
Params.OWNER
22+
);
1723

18-
vm.stopBroadcast();
19-
20-
address[] memory initialWhitelistedTokens = new address[](3);
21-
initialWhitelistedTokens[0] = Params.SEPOLIA_WETH;
22-
initialWhitelistedTokens[1] = Params.SEPOLIA_USDC;
23-
initialWhitelistedTokens[2] = address(mockUSDC);
24-
25-
new Deploy().deploy(Params.OWNER, initialWhitelistedTokens, 0);
26-
}
24+
createTestPayments(
25+
Params.SEPOLIA_TESTER_SHAFU,
26+
Params.SEPOLIA_TESTER_JSON
27+
);
28+
}
2729
}

script/Deploy.Test.Base.s.sol

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.26;
3+
4+
import {Deploy} from "./Deploy.s.sol";
5+
import {Params} from "../libraries/Params.sol";
6+
import {MockERC20} from "solmate/test/utils/mocks/MockERC20.sol";
7+
import {Script} from "forge-std/Script.sol";
8+
import {CreatePayments} from "./utils/CreatePayments.s.sol";
9+
import {Escrow} from "../src/Escrow.sol";
10+
11+
abstract contract DeployTestBase is Deploy {
12+
uint constant AMOUNT_TO_MINT = 100_000_000 * 10**6;
13+
14+
Escrow public escrow;
15+
MockERC20 public mockUSDC;
16+
17+
function deployTestEnvironment(
18+
address[] memory testers,
19+
address weth,
20+
address usdc,
21+
address owner
22+
) internal {
23+
vm.startBroadcast();
24+
25+
mockUSDC = new MockERC20("USD Coin", "USDC", 6);
26+
for (uint i = 0; i < testers.length; i++) {
27+
mockUSDC.mint(testers[i], AMOUNT_TO_MINT);
28+
}
29+
30+
vm.stopBroadcast();
31+
32+
address[] memory initialWhitelistedTokens = new address[](3);
33+
initialWhitelistedTokens[0] = weth;
34+
initialWhitelistedTokens[1] = usdc;
35+
initialWhitelistedTokens[2] = address(mockUSDC);
36+
37+
escrow = deploy(owner, initialWhitelistedTokens, 0);
38+
}
39+
40+
function createTestPayments(
41+
address sender,
42+
address recipient
43+
) internal {
44+
new CreatePayments().deploy(
45+
address(escrow),
46+
address(mockUSDC),
47+
5,
48+
100 * 10**6,
49+
sender,
50+
recipient
51+
);
52+
}
53+
}

script/utils/CreatePayments.s.sol

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,46 @@ contract CreatePayments is Script {
1616
address constant TOKEN = 0x883066fabE2CC5b8f5dC626bF2eb47C6FBD4BE03;
1717

1818
function run() public {
19-
MockERC20 mockUSDC = MockERC20(TOKEN);
20-
Escrow escrow = Escrow (ESCROW_ADDRESS);
19+
deploy(
20+
ESCROW_ADDRESS,
21+
TOKEN,
22+
NUMBER_OF_DEPOSITS,
23+
AMOUNT_PER_DEPOSIT,
24+
Params.SEPOLIA_TESTER_SHAFU,
25+
Params.SEPOLIA_TESTER_JSON
26+
);
27+
}
28+
29+
function deploy(
30+
address escrowAddress,
31+
address token,
32+
uint256 numberOfDeposits,
33+
uint256 amountPerDeposit,
34+
address sender,
35+
address recipient
36+
) public {
37+
MockERC20 mockUSDC = MockERC20(token);
38+
Escrow escrow = Escrow(escrowAddress);
2139

22-
DepositParams[] memory depositParams = new DepositParams[](NUMBER_OF_DEPOSITS);
40+
DepositParams[] memory depositParams = new DepositParams[](numberOfDeposits);
2341

24-
for (uint256 i = 0; i < NUMBER_OF_DEPOSITS; i++) {
42+
for (uint256 i = 0; i < numberOfDeposits; i++) {
2543
depositParams[i] = DepositParams({
2644
token: mockUSDC,
27-
sender: Params.SEPOLIA_TESTER_SHAFU,
28-
recipient: Params.SEPOLIA_TESTER_JSON,
29-
amount: AMOUNT_PER_DEPOSIT,
45+
sender: sender,
46+
recipient: recipient,
47+
amount: amountPerDeposit,
3048
claimPeriod: 10000
3149
});
3250
}
3351

3452
vm.startBroadcast();
3553

36-
mockUSDC.mint(Params.SEPOLIA_TESTER_SHAFU, AMOUNT_PER_DEPOSIT * NUMBER_OF_DEPOSITS);
37-
mockUSDC.approve(address(escrow), AMOUNT_PER_DEPOSIT * NUMBER_OF_DEPOSITS);
38-
escrow.batchDeposit(depositParams, NUMBER_OF_DEPOSITS, block.timestamp);
54+
mockUSDC.mint(sender, amountPerDeposit * numberOfDeposits);
55+
mockUSDC.approve(address(escrow), amountPerDeposit * numberOfDeposits);
56+
escrow.batchDeposit(depositParams, numberOfDeposits, block.timestamp);
3957

4058
vm.stopBroadcast();
59+
4160
}
4261
}

test/Deploy.t.sol

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity =0.8.26;
3+
4+
import "forge-std/Test.sol";
5+
import {MockERC20} from "solmate/test/utils/mocks/MockERC20.sol";
6+
import {DeployBase} from "../script/Deploy.Base.s.sol";
7+
import {Params} from "../libraries/Params.sol";
8+
import {Escrow} from "../src/Escrow.sol";
9+
10+
contract Deploy_Test is Test {
11+
DeployBase deployer;
12+
13+
function setUp() public {
14+
deployer = new DeployBase();
15+
}
16+
17+
function test_deploy() public {
18+
Escrow escrow = deployer.run();
19+
20+
assertTrue(address(escrow) != address(0), "Escrow not deployed");
21+
assertTrue(escrow.isTokenWhitelisted(Params.BASE_USDC), "WETH not whitelisted");
22+
assertEq (escrow.owner(), Params.OWNER, "Incorrect owner");
23+
assertEq (escrow.feeRecipient(), Params.OWNER, "Incorrect fee recipient");
24+
assertEq (escrow.protocolFeeBps(), Params.BASE_FEE_BPS, "Incorrect fee");
25+
}
26+
}

0 commit comments

Comments
 (0)