Skip to content

Commit

Permalink
prevent distributor configuration to RToken/RSR contracts directly (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrent authored Sep 10, 2024
1 parent f90e0e0 commit f8e5f5c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
6 changes: 5 additions & 1 deletion contracts/p0/Distributor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,11 @@ contract DistributorP0 is ComponentP0, IDistributor {
require(dest != address(0), "dest cannot be zero");
require(
dest != address(main.furnace()) && dest != address(main.stRSR()),
"destination can not be furnace or strsr directly"
"destination cannot be furnace or strsr directly"
);
require(
dest != address(main.rsr()) && dest != address(main.rToken()),
"destination cannot be rsr or rToken"
);
require(dest != address(main.daoFeeRegistry()), "destination cannot be daoFeeRegistry");
if (dest == FURNACE) require(share.rsrDist == 0, "Furnace must get 0% of RSR");
Expand Down
6 changes: 5 additions & 1 deletion contracts/p1/Distributor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,11 @@ contract DistributorP1 is ComponentP1, IDistributor {
require(dest != address(0), "dest cannot be zero");
require(
dest != address(furnace) && dest != address(stRSR),
"destination can not be furnace or strsr directly"
"destination cannot be furnace or strsr directly"
);
require(
dest != address(rsr) && dest != address(rToken),
"destination cannot be rsr or rToken"
);
require(dest != address(main.daoFeeRegistry()), "destination cannot be daoFeeRegistry");
if (dest == FURNACE) require(share.rsrDist == 0, "Furnace must get 0% of RSR");
Expand Down
18 changes: 16 additions & 2 deletions test/Revenues.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,14 +361,28 @@ describe(`Revenues - P${IMPLEMENTATION}`, () => {
distributor
.connect(owner)
.setDistribution(furnace.address, { rTokenDist: bn(5), rsrDist: bn(5) })
).to.be.revertedWith('destination can not be furnace or strsr directly')
).to.be.revertedWith('destination cannot be furnace or strsr directly')

// Cannot set StRSR as beneficiary
await expect(
distributor
.connect(owner)
.setDistribution(stRSR.address, { rTokenDist: bn(5), rsrDist: bn(5) })
).to.be.revertedWith('destination can not be furnace or strsr directly')
).to.be.revertedWith('destination cannot be furnace or strsr directly')

// Cannot set RSR as beneficiary
await expect(
distributor
.connect(owner)
.setDistribution(rsr.address, { rTokenDist: bn(5), rsrDist: bn(5) })
).to.be.revertedWith('destination cannot be rsr or rToken')

// Cannot set RToken as beneficiary
await expect(
distributor
.connect(owner)
.setDistribution(rToken.address, { rTokenDist: bn(5), rsrDist: bn(5) })
).to.be.revertedWith('destination cannot be rsr or rToken')
})

itP1('Should not allow to set Dao fee explicitly', async () => {
Expand Down

0 comments on commit f8e5f5c

Please sign in to comment.