add protocol fee check

This commit is contained in:
Drygin 2022-04-26 18:55:34 +03:00
parent 0321d448e8
commit 1d2105d8d8
3 changed files with 16 additions and 1 deletions

View File

@ -62,7 +62,7 @@ Check config.js for actual values.
With `salt` = `0x0000000000000000000000000000000000000000000000000000000047941987` address must be: With `salt` = `0x0000000000000000000000000000000000000000000000000000000047941987` address must be:
1. `MultipleInstanceFactory` - `0x49Be4c1dF49268066f97eD15fe4b4B90cc68d1A6` 1. `MultipleInstanceFactory` - `0x49Be4c1dF49268066f97eD15fe4b4B90cc68d1A6`
2. `InstanceFactoryWithRegistry` - `0x19231EBeD3F2228e7894F4cc20161e39e031F07C` 2. `InstanceFactoryWithRegistry` - `0x7D4a76AF4b2d765D1D62Ac87Cc2aea0b7ECF6102`
Check addresses with current config: Check addresses with current config:

View File

@ -121,6 +121,7 @@ contract InstanceFactoryWithRegistry is InstanceFactory {
// check Uniswap Pool // check Uniswap Pool
for (uint8 i = 0; i < _protocolFees.length; i++) { for (uint8 i = 0; i < _protocolFees.length; i++) {
if (_protocolFees[i] > 0) { if (_protocolFees[i] > 0) {
require(_protocolFees[i] <= 10000, "Protocol fee is more than 100%");
// pool exists // pool exists
address poolAddr = UniswapV3Factory.getPool(_token, WETH, _uniswapPoolSwappingFee); address poolAddr = UniswapV3Factory.getPool(_token, WETH, _uniswapPoolSwappingFee);
require(poolAddr != address(0), "Uniswap pool is not exist"); require(poolAddr != address(0), "Uniswap pool is not exist");

View File

@ -493,4 +493,18 @@ describe('Instance Factory With Registry Tests', () => {
.createProposalApprove(config.COMP, 10000, [ethers.utils.parseEther('100')], [30]), .createProposalApprove(config.COMP, 10000, [ethers.utils.parseEther('100')], [30]),
).to.be.revertedWith('Uniswap pool TWAP slots number is low') ).to.be.revertedWith('Uniswap pool TWAP slots number is low')
}) })
it('Should not deploy proposal with incorrect protocol fee', async function () {
let { sender, instanceFactory, tornWhale, tornToken } = await loadFixture(fixture)
// deploy proposal ----------------------------------------------
await tornToken.connect(tornWhale).transfer(sender.address, config.creationFee)
await tornToken.approve(instanceFactory.address, config.creationFee)
await expect(
instanceFactory
.connect(sender)
.createProposalApprove(config.COMP, 3000, [ethers.utils.parseEther('100')], [10300]),
).to.be.revertedWith('Protocol fee is more than 100%')
})
}) })