Skip to content

Commit e080796

Browse files
committed
adopts scripts and tests to new TokenLocking template contract
adds staking duration parameters to all staking tests drops old V23 sale rollout script Signed-off-by: Stefan Adolf <[email protected]>
1 parent 4780b1a commit e080796

File tree

7 files changed

+47
-31
lines changed

7 files changed

+47
-31
lines changed

script/DeployTokenizer.s.sol

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { BioPriceFeed } from "../src/BioPriceFeed.sol";
1111
import { IPermissioner, TermsAcceptedPermissioner } from "../src/Permissioner.sol";
1212
import { CrowdSale } from "../src/crowdsale/CrowdSale.sol";
1313
import { StakedLockingCrowdSale } from "../src/crowdsale/StakedLockingCrowdSale.sol";
14+
import { TimelockedToken } from "../src/TimelockedToken.sol";
1415

1516
contract DeployTokenizerInfrastructure is Script {
1617
function run() public {
@@ -27,13 +28,16 @@ contract DeployTokenizerInfrastructure is Script {
2728
tokenizer.setIPTokenImplementation(initialIpTokenImplementation);
2829

2930
CrowdSale crowdSale = new CrowdSale();
30-
StakedLockingCrowdSale stakedLockingCrowdSale = new StakedLockingCrowdSale();
31+
//this allows the default TimelockedToken implementation to be verified on chain explorers
32+
TimelockedToken timelockedTokenImplementation = new TimelockedToken();
33+
StakedLockingCrowdSale stakedLockingCrowdSale = new StakedLockingCrowdSale(timelockedTokenImplementation);
3134
vm.stopBroadcast();
3235

3336
console.log("TERMS_ACCEPTED_PERMISSIONER_ADDRESS=%s", address(permissioner));
3437
console.log("TOKENIZER_ADDRESS=%s", address(tokenizer));
3538
console.log("CROWDSALE_ADDRESS=%s", address(crowdSale));
3639
console.log("STAKED_LOCKING_CROWDSALE_ADDRESS=%s", address(stakedLockingCrowdSale));
40+
console.log("timelocked token implementation=%s", address(timelockedTokenImplementation));
3741
console.log("initial IP Token implementation=%s", address(initialIpTokenImplementation));
3842
}
3943
}

script/dev/CrowdSale.s.sol

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,13 @@ contract DeployCrowdSale is CommonScript {
3131
}
3232
}
3333

34-
/**
35-
* @title deploy crowdSale
36-
* @author
37-
*/
3834
contract DeployStakedCrowdSale is CommonScript {
3935
function run() public {
4036
prepareAddresses();
4137
vm.startBroadcast(deployer);
42-
StakedLockingCrowdSale stakedLockingCrowdSale = new StakedLockingCrowdSale();
43-
38+
TimelockedToken lockingCrowdsaleImplementation = new TimelockedToken();
39+
StakedLockingCrowdSale stakedLockingCrowdSale = new StakedLockingCrowdSale(lockingCrowdsaleImplementation);
40+
4441
TokenVesting vestedDaoToken = TokenVesting(vm.envAddress("VDAO_TOKEN_ADDRESS"));
4542
vestedDaoToken.grantRole(vestedDaoToken.ROLE_CREATE_SCHEDULE(), address(stakedLockingCrowdSale));
4643
stakedLockingCrowdSale.trustVestingContract(vestedDaoToken);

script/prod/RolloutV23Sale.sol renamed to script/prod/RolloutV25Sale.sol

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@ import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy
77
import { IPNFT } from "../../src/IPNFT.sol";
88
import { IPermissioner, TermsAcceptedPermissioner } from "../../src/Permissioner.sol";
99
import { StakedLockingCrowdSale } from "../../src/crowdsale/StakedLockingCrowdSale.sol";
10+
import { TimelockedToken } from "../../src/TimelockedToken.sol";
1011

11-
contract RolloutV23Sale is Script {
12+
contract RolloutV25Sale is Script {
1213
function run() public {
1314
address moleculeDevMultisig = 0xCfA0F84660fB33bFd07C369E5491Ab02C449f71B;
1415
vm.startBroadcast();
1516

16-
StakedLockingCrowdSale stakedLockingCrowdSale = new StakedLockingCrowdSale();
17+
TimelockedToken timelockedTokenImplementation = new TimelockedToken();
18+
StakedLockingCrowdSale stakedLockingCrowdSale = new StakedLockingCrowdSale(timelockedTokenImplementation);
1719
stakedLockingCrowdSale.transferOwnership(moleculeDevMultisig);
1820
vm.stopBroadcast();
1921

2022
console.log("STAKED_LOCKING_CROWDSALE_ADDRESS=%s", address(stakedLockingCrowdSale));
23+
console.log("timelocked token implementation=%s", address(timelockedTokenImplementation));
2124
// 0x7c36c64DA1c3a2065074caa9C48e7648FB733aAB
2225
// vestedDaoToken.grantRole(vestedDaoToken.ROLE_CREATE_SCHEDULE(), address(stakedLockingCrowdSale));
2326
// stakedLockingCrowdSale.trustVestingContract(vestedDaoToken);

test/CrowdSaleLockedStakedTest.t.sol

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ contract CrowdSaleLockedStakedTest is Test {
5555
// // 1=1 is the trivial case
5656
// priceFeed.signal(address(biddingToken), address(daoToken), 1e18);
5757

58-
crowdSale = new StakedLockingCrowdSale();
59-
58+
TimelockedToken timelockedTokenImplementation = new TimelockedToken();
59+
crowdSale = new StakedLockingCrowdSale(timelockedTokenImplementation);
60+
6061
vestedDao = new TokenVesting(
6162
daoToken,
6263
string(abi.encodePacked("Vested ", daoToken.name())),
@@ -92,13 +93,13 @@ contract CrowdSaleLockedStakedTest is Test {
9293
auctionToken.approve(address(crowdSale), 400_000 ether);
9394

9495
vm.expectRevert(); //cannot call .decimals() on 0x0
95-
crowdSale.startSale(_sale, IERC20Metadata(address(0)), TokenVesting(address(0)), 0, 60 days);
96+
crowdSale.startSale(_sale, IERC20Metadata(address(0)), TokenVesting(address(0)), 0, 3 days, 7 days);
9697

9798
vm.expectRevert(); //need to bring a stake vesting contract
98-
crowdSale.startSale(_sale, daoToken, TokenVesting(address(0)), 0, 60 days);
99+
crowdSale.startSale(_sale, daoToken, TokenVesting(address(0)), 0, 3 days, 7 days);
99100

100101
vm.expectRevert(UnsupportedVestingContract.selector);
101-
crowdSale.startSale(_sale, daoToken, wrongStakeVestingContract, 0, 60 days);
102+
crowdSale.startSale(_sale, daoToken, wrongStakeVestingContract, 0, 3 days, 7 days);
102103
vm.stopPrank();
103104

104105
vm.startPrank(deployer);
@@ -111,12 +112,15 @@ contract CrowdSaleLockedStakedTest is Test {
111112

112113
vm.startPrank(emitter);
113114
vm.expectRevert(IncompatibleVestingContract.selector);
114-
crowdSale.startSale(_sale, daoToken, wrongStakeVestingContract, 0, 60 days);
115+
crowdSale.startSale(_sale, daoToken, wrongStakeVestingContract, 0, 3 days, 7 days);
115116

116117
vm.expectRevert(BadPrice.selector);
117-
crowdSale.startSale(_sale, daoToken, vestedDao, 0, 60 days);
118+
crowdSale.startSale(_sale, daoToken, vestedDao, 0, 3 days, 7 days);
118119

119-
crowdSale.startSale(_sale, daoToken, vestedDao, 1e18, 60 days);
120+
vm.expectRevert(InvalidDuration.selector);
121+
crowdSale.startSale(_sale, daoToken, vestedDao, 1e18, 3 days, 6 days);
122+
123+
crowdSale.startSale(_sale, daoToken, vestedDao, 1e18, 3 days, 7 days);
120124
}
121125

122126
function testCannotSetupCrowdSaleWithParentFunctions() public {
@@ -137,7 +141,7 @@ contract CrowdSaleLockedStakedTest is Test {
137141
Sale memory _sale = CrowdSaleHelpers.makeSale(emitter, auctionToken, biddingToken);
138142

139143
auctionToken.approve(address(crowdSale), 400_000 ether);
140-
uint256 saleId = crowdSale.startSale(_sale, daoToken, vestedDao, 1e18, 60 days);
144+
uint256 saleId = crowdSale.startSale(_sale, daoToken, vestedDao, 1e18, 60 days, 60 days);
141145

142146
vm.stopPrank();
143147

@@ -174,7 +178,7 @@ contract CrowdSaleLockedStakedTest is Test {
174178
vm.startPrank(emitter);
175179
Sale memory _sale = CrowdSaleHelpers.makeSale(emitter, auctionToken, biddingToken);
176180
auctionToken.approve(address(crowdSale), 400_000 ether);
177-
uint256 saleId = crowdSale.startSale(_sale, daoToken, vestedDao, 1e18, 60 days);
181+
uint256 saleId = crowdSale.startSale(_sale, daoToken, vestedDao, 1e18, 60 days, 60 days);
178182

179183
vm.stopPrank();
180184

@@ -287,7 +291,7 @@ contract CrowdSaleLockedStakedTest is Test {
287291
Sale memory _sale = CrowdSaleHelpers.makeSale(emitter, auctionToken, biddingToken);
288292
auctionToken.approve(address(crowdSale), 400_000 ether);
289293
// 1 DAO = 4 $
290-
uint256 saleId = crowdSale.startSale(_sale, daoToken, vestedDao, 25e16, 60 days);
294+
uint256 saleId = crowdSale.startSale(_sale, daoToken, vestedDao, 25e16, 60 days, 60 days);
291295

292296
vm.stopPrank();
293297

@@ -348,7 +352,7 @@ contract CrowdSaleLockedStakedTest is Test {
348352
Sale memory _sale = CrowdSaleHelpers.makeSale(emitter, auctionToken, biddingToken);
349353
auctionToken.approve(address(crowdSale), 400_000 ether);
350354

351-
uint256 saleId = crowdSale.startSale(_sale, daoToken, vestedDao, 25e16, 60 days);
355+
uint256 saleId = crowdSale.startSale(_sale, daoToken, vestedDao, 25e16, 60 days, 60 days);
352356
vm.stopPrank();
353357

354358
vm.startPrank(bidder);
@@ -393,7 +397,11 @@ contract CrowdSaleLockedStakedTest is Test {
393397
Sale memory _sale = CrowdSaleHelpers.makeSale(emitter, auctionToken, biddingToken);
394398
_sale.closingTime = uint64(block.timestamp + 3 days);
395399
auctionToken.approve(address(crowdSale), 400_000 ether);
396-
uint256 saleId = crowdSale.startSale(_sale, daoToken, vestedDao, 1e18, 3 days);
400+
401+
vm.expectRevert(InvalidDuration.selector);
402+
uint256 saleId = crowdSale.startSale(_sale, daoToken, vestedDao, 1e18, 3 days, 3 days);
403+
404+
saleId = crowdSale.startSale(_sale, daoToken, vestedDao, 1e18, 3 days, 7 days);
397405

398406
vm.stopPrank();
399407

test/CrowdSaleLockedTest.t.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ contract CrowdSaleLockedTest is Test {
2525
LockingCrowdSale internal crowdSale;
2626

2727
function setUp() public {
28-
crowdSale = new LockingCrowdSale();
28+
TimelockedToken timelockedTokenImplementation = new TimelockedToken();
29+
crowdSale = new LockingCrowdSale(timelockedTokenImplementation);
30+
2931
auctionToken = new FakeERC20("IPTOKENS","IPT");
3032
biddingToken = new FakeERC20("USD token", "USDC");
3133

test/CrowdSalePermissioned.t.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ contract CrowdSalePermissionedTest is Test {
6666
biddingToken = new FakeERC20("USD token", "USDC");
6767
daoToken = new FakeERC20("DAO token", "DAO");
6868

69-
crowdSale = new StakedLockingCrowdSale();
69+
TimelockedToken timelockedTokenImplementation = new TimelockedToken();
70+
crowdSale = new StakedLockingCrowdSale(timelockedTokenImplementation);
7071

7172
vestedDao = new TokenVesting(daoToken, string(abi.encodePacked("Vested ", daoToken.name())), string(abi.encodePacked("v", daoToken.symbol())));
7273
vestedDao.grantRole(vestedDao.ROLE_CREATE_SCHEDULE(), address(crowdSale));
@@ -103,7 +104,7 @@ contract CrowdSalePermissionedTest is Test {
103104
_sale.permissioner = permissioner;
104105
auctionToken.approve(address(crowdSale), 400_000 ether);
105106

106-
uint256 saleId = crowdSale.startSale(_sale, daoToken, vestedDao, 1e18, 60 days);
107+
uint256 saleId = crowdSale.startSale(_sale, daoToken, vestedDao, 1e18, 60 days, 60 days);
107108
vm.stopPrank();
108109

109110
string memory terms = permissioner.specificTermsV1(auctionToken);

test/CrowdSaleWithNonStandardERC20Test.t.sol

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ contract CrowdSaleWithNonStandardERC20Test is Test {
5050
// // 1=1 is the trivial case
5151
// priceFeed.signal(address(biddingToken), address(daoToken), 1e18);
5252

53-
crowdSale = new StakedLockingCrowdSale();
53+
TimelockedToken timelockedTokenImplementation = new TimelockedToken();
54+
crowdSale = new StakedLockingCrowdSale(timelockedTokenImplementation);
5455

5556
auctionToken.mint(emitter, 500_000 ether);
5657

@@ -83,7 +84,7 @@ contract CrowdSaleWithNonStandardERC20Test is Test {
8384
Sale memory _sale = CrowdSaleHelpers.makeSale(emitter, auctionToken, biddingToken);
8485
_sale.fundingGoal = 200_000e6;
8586
auctionToken.approve(address(crowdSale), 400_000 ether);
86-
uint256 saleId = crowdSale.startSale(_sale, daoToken, vestedDao, 1e18, 60 days);
87+
uint256 saleId = crowdSale.startSale(_sale, daoToken, vestedDao, 1e18, 60 days, 60 days);
8788
vm.stopPrank();
8889

8990
vm.startPrank(bidder);
@@ -121,7 +122,7 @@ contract CrowdSaleWithNonStandardERC20Test is Test {
121122
Sale memory _sale = CrowdSaleHelpers.makeSale(emitter, auctionToken, biddingToken);
122123
_sale.fundingGoal = 200_000e6;
123124
auctionToken.approve(address(crowdSale), 400_000 ether);
124-
uint256 saleId = crowdSale.startSale(_sale, daoToken, vestedDao, 1e18, 60 days);
125+
uint256 saleId = crowdSale.startSale(_sale, daoToken, vestedDao, 1e18, 60 days, 60 days);
125126

126127
vm.stopPrank();
127128

@@ -179,7 +180,7 @@ contract CrowdSaleWithNonStandardERC20Test is Test {
179180
_sale.fundingGoal = 200_000e6;
180181
auctionToken.approve(address(crowdSale), 400_000 ether);
181182
// 1 DAO = 4 $ <=> 1$ = 0.25 DAO, the price is always expressed as 1e18 decimal
182-
uint256 saleId = crowdSale.startSale(_sale, daoToken, vestedDao, 25e16, 60 days);
183+
uint256 saleId = crowdSale.startSale(_sale, daoToken, vestedDao, 25e16, 60 days, 60 days);
183184
vm.stopPrank();
184185

185186
vm.startPrank(bidder);
@@ -241,7 +242,7 @@ contract CrowdSaleWithNonStandardERC20Test is Test {
241242
_sale.fundingGoal = 200_000e6;
242243
auctionToken.approve(address(crowdSale), 400_000 ether);
243244
//0.25 DAO (18dec) / USDC (6dec)
244-
uint256 saleId = crowdSale.startSale(_sale, daoToken, vestedDao, 25e16, 60 days);
245+
uint256 saleId = crowdSale.startSale(_sale, daoToken, vestedDao, 25e16, 60 days, 60 days);
245246

246247
vm.stopPrank();
247248

@@ -306,7 +307,7 @@ contract CrowdSaleWithNonStandardERC20Test is Test {
306307
Sale memory _sale = CrowdSaleHelpers.makeSale(emitter, auctionToken, biddingToken);
307308
_sale.fundingGoal = 50_000e2;
308309
auctionToken.approve(address(crowdSale), 400_000 ether);
309-
uint256 saleId = crowdSale.startSale(_sale, daoToken, vestedDao, 4e18, 7 days);
310+
uint256 saleId = crowdSale.startSale(_sale, daoToken, vestedDao, 4e18, 7 days, 7 days);
310311
vm.stopPrank();
311312

312313
vm.startPrank(bidder);

0 commit comments

Comments
 (0)