Skip to content

Commit

Permalink
Merge pull request #58 from hackbg/feature/configurable-dssvest
Browse files Browse the repository at this point in the history
feat: configurable dssVest address
  • Loading branch information
imollov authored Oct 24, 2022
2 parents 67fa11c + 68870f4 commit 4a4e42a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
12 changes: 9 additions & 3 deletions contracts/DssVestTopUp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ interface KeeperRegistryLike {
* funds an upkeep after swapping the payment tokens for LINK
*/
contract DssVestTopUp is IUpkeepRefunder, Ownable {
DssVestLike public immutable dssVest;
DaiJoinLike public immutable daiJoin;
ISwapRouter public immutable swapRouter;
address public immutable vow;
address public immutable paymentToken;
address public immutable linkToken;
address public immutable paymentUsdPriceFeed;
address public immutable linkUsdPriceFeed;
DssVestLike public dssVest;
KeeperRegistryLike public keeperRegistry;
uint24 public uniswapPoolFee = 3000;
uint24 public uniswapSlippageTolerancePercent = 2;
Expand All @@ -66,6 +66,7 @@ contract DssVestTopUp is IUpkeepRefunder, Ownable {
event ThresholdSet(uint256 newThreshold);
event UniswapPoolFeeSet(uint24 poolFee);
event UniswapSlippageToleranceSet(uint24 slippageTolerancePercent);
event DssVestSet(address dssVest);
event KeeperRegistrySet(address keeperRegistry);
event VestedTokensWithdrawn(uint256 amount);
event ExcessPaymentReturned(uint256 amount);
Expand All @@ -87,7 +88,6 @@ contract DssVestTopUp is IUpkeepRefunder, Ownable {
uint256 _maxDepositAmt,
uint256 _threshold
) {
require(_dssVest != address(0), "invalid dssVest address");
require(_daiJoin != address(0), "invalid daiJoin address");
require(_vow != address(0), "invalid vow address");
require(_paymentToken != address(0), "invalid paymentToken address");
Expand All @@ -96,14 +96,14 @@ contract DssVestTopUp is IUpkeepRefunder, Ownable {
require(_paymentUsdPriceFeed != address(0), "invalid paymentUsdPriceFeed address");
require(_linkUsdPriceFeed != address(0), "invalid linkUsdPriceFeed address");

dssVest = DssVestLike(_dssVest);
daiJoin = DaiJoinLike(_daiJoin);
vow = _vow;
paymentToken = _paymentToken;
swapRouter = ISwapRouter(_swapRouter);
linkToken = _linkToken;
paymentUsdPriceFeed = _paymentUsdPriceFeed;
linkUsdPriceFeed = _linkUsdPriceFeed;
setDssVest(_dssVest);
setKeeperRegistry(_keeperRegistry);
setMinWithdrawAmt(_minWithdrawAmt);
setMaxDepositAmt(_maxDepositAmt);
Expand Down Expand Up @@ -289,6 +289,12 @@ contract DssVestTopUp is IUpkeepRefunder, Ownable {
emit ThresholdSet(_threshold);
}

function setDssVest(address _dssVest) public onlyOwner {
require(_dssVest != address(0), "invalid dssVest address");
dssVest = DssVestLike(_dssVest);
emit DssVestSet(_dssVest);
}

function setKeeperRegistry(address _keeperRegistry) public onlyOwner {
require(_keeperRegistry != address(0), "invalid keeperRegistry address");
keeperRegistry = KeeperRegistryLike(_keeperRegistry);
Expand Down
17 changes: 16 additions & 1 deletion test/DssVestTopUp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,25 @@ describe("DssVestTopUp", function () {
expect(oldKeeperRegistry).to.not.eq(newKeeperRegistry);
});

it("should not allow owner change keeper registry", async function () {
it("should not allow user to change keeper registry", async function () {
await expect(
topUp.connect(user).setKeeperRegistry(admin.address)
).to.be.revertedWith("Ownable: caller is not the owner");
});

it("should change dssVest", async function () {
const oldDssVest = await topUp.dssVest();

await topUp.setDssVest(admin.address);
const newDssVest = await topUp.dssVest();

expect(oldDssVest).to.not.eq(newDssVest);
});

it("should not allow user to change dssVest", async function () {
await expect(
topUp.connect(user).setDssVest(admin.address)
).to.be.revertedWith("Ownable: caller is not the owner");
});
});
});

0 comments on commit 4a4e42a

Please sign in to comment.