|
| 1 | +// SPDX-License-Identifier: UNLICENSED |
| 2 | +pragma solidity 0.8.25; |
| 3 | + |
| 4 | +import {Test, console} from "forge-std/Test.sol"; |
| 5 | +import {DealNFT} from "../../src/DealNFT.sol"; |
| 6 | +import {AccountV3TBD} from "../../src/AccountV3TBD.sol"; |
| 7 | + |
| 8 | +import "multicall-authenticated/Multicall3.sol"; |
| 9 | +import "erc6551/ERC6551Registry.sol"; |
| 10 | +import "tokenbound/src/AccountGuardian.sol"; |
| 11 | + |
| 12 | +import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol"; |
| 13 | +import {ERC20PresetFixedSupply} from "openzeppelin/token/ERC20/presets/ERC20PresetFixedSupply.sol"; |
| 14 | +import {IERC20Metadata} from "openzeppelin/token/ERC20/extensions/IERC20Metadata.sol"; |
| 15 | + |
| 16 | +contract DealSetupAmountBased is Test { |
| 17 | + DealNFT public deal; |
| 18 | + IERC20Metadata public escrowToken; |
| 19 | + |
| 20 | + uint256 tokenId = 0; |
| 21 | + uint256 amount = 1000000; |
| 22 | + address sponsor; |
| 23 | + address treasury; |
| 24 | + address arbitrator; |
| 25 | + address staker1; |
| 26 | + address staker2; |
| 27 | + |
| 28 | + function _init() internal { |
| 29 | + sponsor = vm.addr(1); |
| 30 | + treasury = vm.addr(2); |
| 31 | + arbitrator = vm.addr(3); |
| 32 | + |
| 33 | + staker1 = vm.addr(4); |
| 34 | + staker2 = vm.addr(5); |
| 35 | + |
| 36 | + escrowToken = new ERC20PresetFixedSupply("escrow", "escrow", 50000000, address(this)); |
| 37 | + escrowToken.transfer(address(staker1), amount); |
| 38 | + escrowToken.transfer(address(staker2), amount); |
| 39 | + escrowToken.transfer(address(sponsor), amount*3); |
| 40 | + escrowToken.transfer(address(arbitrator), amount*3); |
| 41 | + |
| 42 | + ERC6551Registry registry = new ERC6551Registry(); |
| 43 | + Multicall3 forwarder = new Multicall3(); |
| 44 | + AccountGuardian guardian = new AccountGuardian(address(this)); |
| 45 | + |
| 46 | + AccountV3TBD implementation = new AccountV3TBD( |
| 47 | + address(1), |
| 48 | + address(forwarder), |
| 49 | + address(registry), |
| 50 | + address(guardian) |
| 51 | + ); |
| 52 | + |
| 53 | + DealNFT.Configuration memory dealConfig = DealNFT.Configuration({ |
| 54 | + escrowToken: address(0), |
| 55 | + sponsor: sponsor, |
| 56 | + arbitrator: arbitrator, |
| 57 | + image: "https://image.jpg", |
| 58 | + description: "", |
| 59 | + social: "", |
| 60 | + website: "", |
| 61 | + multiple: 1e18, |
| 62 | + closingDelay: 0, |
| 63 | + unstakingFee: 0, |
| 64 | + closingTime: 0, |
| 65 | + dealMinimum: 0, |
| 66 | + dealMaximum: 0, |
| 67 | + deliveryType: 0, |
| 68 | + active: false, |
| 69 | + cancelled: false, |
| 70 | + transferable: false, |
| 71 | + timeBasedClosing: false |
| 72 | + }); |
| 73 | + |
| 74 | + deal = new DealNFT( |
| 75 | + treasury, |
| 76 | + address(registry), |
| 77 | + payable(address(implementation)), |
| 78 | + "https://test.com/chain/1/deal/", |
| 79 | + "SurgeDealTEST", |
| 80 | + "SRGTEST", |
| 81 | + dealConfig |
| 82 | + ); |
| 83 | + |
| 84 | + vm.prank(treasury); |
| 85 | + deal.setArbitrator(arbitrator); |
| 86 | + |
| 87 | + vm.prank(staker1); |
| 88 | + escrowToken.approve(address(deal), amount); |
| 89 | + |
| 90 | + vm.prank(staker2); |
| 91 | + escrowToken.approve(address(deal), amount); |
| 92 | + |
| 93 | + } |
| 94 | + |
| 95 | + function _stake(address staker) internal { |
| 96 | + vm.prank(staker); |
| 97 | + deal.stake(staker, amount); |
| 98 | + } |
| 99 | + |
| 100 | + function _setup() internal { |
| 101 | + vm.prank(sponsor); |
| 102 | + deal.setup(address(escrowToken), 30 minutes, 50000, 2000000, 2000000, "https://social", "https://website", "https://image", "", 1); |
| 103 | + } |
| 104 | + |
| 105 | + function _configure() internal { |
| 106 | + vm.prank(sponsor); |
| 107 | + deal.configure("desc", "https://social", "https://website", 0, 0, 0, 5e18); |
| 108 | + } |
| 109 | + |
| 110 | + function _activate() internal { |
| 111 | + vm.prank(sponsor); |
| 112 | + deal.activate(); |
| 113 | + } |
| 114 | + |
| 115 | + function _depositDeliveryTokens() internal { |
| 116 | + vm.startPrank(arbitrator); |
| 117 | + escrowToken.approve(address(deal), amount*3); |
| 118 | + deal.depositDeliveryTokens(address(escrowToken), amount*3); |
| 119 | + vm.stopPrank(); |
| 120 | + } |
| 121 | +} |
0 commit comments