-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zero distribution #878
Zero distribution #878
Changes from 3 commits
a35ce5c
b7d1986
7ffc7b5
0f98260
1d1005b
0115467
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -636,6 +636,114 @@ describe(`Revenues - P${IMPLEMENTATION}`, () => { | |
expect(await rsr.balanceOf(stRSR.address)).to.be.closeTo(expectedAmount, 100) | ||
}) | ||
|
||
it('Should return tokens to BackingManager correctly - rsrTrader.returnTokens()', async () => { | ||
// Mint tokens | ||
await rsr.connect(owner).mint(rsrTrader.address, issueAmount) | ||
await token0.connect(owner).mint(rsrTrader.address, issueAmount.add(1)) | ||
await token1.connect(owner).mint(rsrTrader.address, issueAmount.add(2)) | ||
|
||
// Should fail when trading paused or frozen | ||
await main.connect(owner).pauseIssuance() | ||
await main.connect(owner).pauseTrading() | ||
await main.connect(owner).freezeForever() | ||
await expect( | ||
rsrTrader.returnTokens([rsr.address, token0.address, token1.address]) | ||
).to.be.revertedWith('frozen or trading paused') | ||
await main.connect(owner).unfreeze() | ||
await expect( | ||
rsrTrader.returnTokens([rsr.address, token0.address, token1.address]) | ||
).to.be.revertedWith('frozen or trading paused') | ||
await main.connect(owner).unpauseTrading() | ||
|
||
// Should fail when distribution is nonzero | ||
await expect( | ||
rsrTrader.returnTokens([rsr.address, token0.address, token1.address]) | ||
).to.be.revertedWith('rsrTotal > 0') | ||
await distributor.setDistribution(STRSR_DEST, { rTokenDist: bn('0'), rsrDist: bn('0') }) | ||
|
||
// Should fail for unregistered token | ||
await assetRegistry.connect(owner).unregister(collateral1.address) | ||
await expect( | ||
rsrTrader.returnTokens([rsr.address, token0.address, token1.address]) | ||
).to.be.revertedWith('unregistered erc20') | ||
|
||
// Succeed on just token0 + rsr | ||
await expectEvents(rsrTrader.returnTokens([rsr.address, token0.address]), [ | ||
{ | ||
contract: rsr, | ||
name: 'Transfer', | ||
args: [rsrTrader.address, backingManager.address, issueAmount], | ||
emitted: true, | ||
}, | ||
{ | ||
contract: token0, | ||
name: 'Transfer', | ||
args: [rsrTrader.address, backingManager.address, issueAmount.add(1)], | ||
emitted: true, | ||
}, | ||
{ | ||
contract: token1, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i dont think this should fire? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, it has There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We dont need the |
||
name: 'Transfer', | ||
args: [anyValue, anyValue, anyValue], | ||
emitted: false, | ||
}, | ||
]) | ||
}) | ||
|
||
it('Should return tokens to BackingManager correctly - rTokenTrader.returnTokens()', async () => { | ||
// Mint tokens | ||
await rsr.connect(owner).mint(rTokenTrader.address, issueAmount) | ||
await token0.connect(owner).mint(rTokenTrader.address, issueAmount.add(1)) | ||
await token1.connect(owner).mint(rTokenTrader.address, issueAmount.add(2)) | ||
|
||
// Should fail when trading paused or frozen | ||
await main.connect(owner).pauseIssuance() | ||
await main.connect(owner).pauseTrading() | ||
await main.connect(owner).freezeForever() | ||
await expect( | ||
rTokenTrader.returnTokens([rsr.address, token0.address, token1.address]) | ||
).to.be.revertedWith('frozen or trading paused') | ||
await main.connect(owner).unfreeze() | ||
await expect( | ||
rTokenTrader.returnTokens([rsr.address, token0.address, token1.address]) | ||
).to.be.revertedWith('frozen or trading paused') | ||
await main.connect(owner).unpauseTrading() | ||
|
||
// Should fail when distribution is nonzero | ||
await expect( | ||
rTokenTrader.returnTokens([rsr.address, token0.address, token1.address]) | ||
).to.be.revertedWith('rTokenTotal > 0') | ||
await distributor.setDistribution(FURNACE_DEST, { rTokenDist: bn('0'), rsrDist: bn('0') }) | ||
|
||
// Should fail for unregistered token | ||
await assetRegistry.connect(owner).unregister(collateral1.address) | ||
await expect( | ||
rTokenTrader.returnTokens([rsr.address, token0.address, token1.address]) | ||
).to.be.revertedWith('unregistered erc20') | ||
|
||
// Succeed on just token0 + rsr | ||
await expectEvents(rTokenTrader.returnTokens([rsr.address, token0.address]), [ | ||
{ | ||
contract: rsr, | ||
name: 'Transfer', | ||
args: [rTokenTrader.address, backingManager.address, issueAmount], | ||
emitted: true, | ||
}, | ||
{ | ||
contract: token0, | ||
name: 'Transfer', | ||
args: [rTokenTrader.address, backingManager.address, issueAmount.add(1)], | ||
emitted: true, | ||
}, | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i don't think this should fire? |
||
contract: token1, | ||
name: 'Transfer', | ||
args: [anyValue, anyValue, anyValue], | ||
emitted: false, | ||
}, | ||
]) | ||
}) | ||
|
||
it('Should launch multiple auctions -- has tokenToBuy', async () => { | ||
// Mint AAVE, token0, and RSR to the RSRTrader | ||
await aaveToken.connect(owner).mint(rsrTrader.address, issueAmount) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not going to be covered with our default tests. So we can either deploy a standalone mock case with a RevTrader initialized to another
tokenToBuy
(not generally what we do in most tests as it would not be our "interface") or we add theuntestable
commentThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the comment