Skip to content

Commit 4a4e42a

Browse files
authored
Merge pull request #58 from hackbg/feature/configurable-dssvest
feat: configurable dssVest address
2 parents 67fa11c + 68870f4 commit 4a4e42a

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

contracts/DssVestTopUp.sol

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ interface KeeperRegistryLike {
4242
* funds an upkeep after swapping the payment tokens for LINK
4343
*/
4444
contract DssVestTopUp is IUpkeepRefunder, Ownable {
45-
DssVestLike public immutable dssVest;
4645
DaiJoinLike public immutable daiJoin;
4746
ISwapRouter public immutable swapRouter;
4847
address public immutable vow;
4948
address public immutable paymentToken;
5049
address public immutable linkToken;
5150
address public immutable paymentUsdPriceFeed;
5251
address public immutable linkUsdPriceFeed;
52+
DssVestLike public dssVest;
5353
KeeperRegistryLike public keeperRegistry;
5454
uint24 public uniswapPoolFee = 3000;
5555
uint24 public uniswapSlippageTolerancePercent = 2;
@@ -66,6 +66,7 @@ contract DssVestTopUp is IUpkeepRefunder, Ownable {
6666
event ThresholdSet(uint256 newThreshold);
6767
event UniswapPoolFeeSet(uint24 poolFee);
6868
event UniswapSlippageToleranceSet(uint24 slippageTolerancePercent);
69+
event DssVestSet(address dssVest);
6970
event KeeperRegistrySet(address keeperRegistry);
7071
event VestedTokensWithdrawn(uint256 amount);
7172
event ExcessPaymentReturned(uint256 amount);
@@ -87,7 +88,6 @@ contract DssVestTopUp is IUpkeepRefunder, Ownable {
8788
uint256 _maxDepositAmt,
8889
uint256 _threshold
8990
) {
90-
require(_dssVest != address(0), "invalid dssVest address");
9191
require(_daiJoin != address(0), "invalid daiJoin address");
9292
require(_vow != address(0), "invalid vow address");
9393
require(_paymentToken != address(0), "invalid paymentToken address");
@@ -96,14 +96,14 @@ contract DssVestTopUp is IUpkeepRefunder, Ownable {
9696
require(_paymentUsdPriceFeed != address(0), "invalid paymentUsdPriceFeed address");
9797
require(_linkUsdPriceFeed != address(0), "invalid linkUsdPriceFeed address");
9898

99-
dssVest = DssVestLike(_dssVest);
10099
daiJoin = DaiJoinLike(_daiJoin);
101100
vow = _vow;
102101
paymentToken = _paymentToken;
103102
swapRouter = ISwapRouter(_swapRouter);
104103
linkToken = _linkToken;
105104
paymentUsdPriceFeed = _paymentUsdPriceFeed;
106105
linkUsdPriceFeed = _linkUsdPriceFeed;
106+
setDssVest(_dssVest);
107107
setKeeperRegistry(_keeperRegistry);
108108
setMinWithdrawAmt(_minWithdrawAmt);
109109
setMaxDepositAmt(_maxDepositAmt);
@@ -289,6 +289,12 @@ contract DssVestTopUp is IUpkeepRefunder, Ownable {
289289
emit ThresholdSet(_threshold);
290290
}
291291

292+
function setDssVest(address _dssVest) public onlyOwner {
293+
require(_dssVest != address(0), "invalid dssVest address");
294+
dssVest = DssVestLike(_dssVest);
295+
emit DssVestSet(_dssVest);
296+
}
297+
292298
function setKeeperRegistry(address _keeperRegistry) public onlyOwner {
293299
require(_keeperRegistry != address(0), "invalid keeperRegistry address");
294300
keeperRegistry = KeeperRegistryLike(_keeperRegistry);

test/DssVestTopUp.test.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,25 @@ describe("DssVestTopUp", function () {
260260
expect(oldKeeperRegistry).to.not.eq(newKeeperRegistry);
261261
});
262262

263-
it("should not allow owner change keeper registry", async function () {
263+
it("should not allow user to change keeper registry", async function () {
264264
await expect(
265265
topUp.connect(user).setKeeperRegistry(admin.address)
266266
).to.be.revertedWith("Ownable: caller is not the owner");
267267
});
268+
269+
it("should change dssVest", async function () {
270+
const oldDssVest = await topUp.dssVest();
271+
272+
await topUp.setDssVest(admin.address);
273+
const newDssVest = await topUp.dssVest();
274+
275+
expect(oldDssVest).to.not.eq(newDssVest);
276+
});
277+
278+
it("should not allow user to change dssVest", async function () {
279+
await expect(
280+
topUp.connect(user).setDssVest(admin.address)
281+
).to.be.revertedWith("Ownable: caller is not the owner");
282+
});
268283
});
269284
});

0 commit comments

Comments
 (0)