diff --git a/test/DelegationSt1inch.js b/test/DelegationSt1inch.js deleted file mode 100644 index 1741079b..00000000 --- a/test/DelegationSt1inch.js +++ /dev/null @@ -1,129 +0,0 @@ -const { expect, time, ether, constants } = require('@1inch/solidity-utils'); -const { ethers } = require('hardhat'); -const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers'); -const { expBase } = require('./helpers/utils'); - -describe('Delegation st1inch', function () { - let addr, addr1; - let accounts; - const MAX_WHITELISTED = 3; - const commonLockDuration = time.duration.days('40'); - const BALANCE_THRESHOLD = 1000; // 10% - - const stakeAndRegisterInDelegation = async (st1inch, delegation, user, amount, userIndex) => { - await st1inch.connect(user).deposit(0, commonLockDuration); - await st1inch.depositFor(user.address, amount); - await st1inch.connect(user).addPod(delegation.address); - await delegation - .connect(user) - .functions['register(string,string)']( - `${userIndex}DelegatingToken`, - `A${userIndex}DT`, - ); - await delegation.connect(user).delegate(user.address); - }; - - async function initContracts() { - const TokenPermitMock = await ethers.getContractFactory('ERC20PermitMock'); - const oneInch = await TokenPermitMock.deploy('1inch', '1inch', addr.address, ether('200')); - await oneInch.deployed(); - await oneInch.transfer(addr1.address, ether('100')); - - const St1inch = await ethers.getContractFactory('St1inch'); - const st1inch = await St1inch.deploy(oneInch.address, expBase, addr.address); - await st1inch.deployed(); - await oneInch.approve(st1inch.address, ether('100')); - await oneInch.connect(addr1).approve(st1inch.address, ether('100')); - - const PowerPod = await ethers.getContractFactory('PowerPod'); - const delegation = await PowerPod.deploy('PowerPod', 'PP', st1inch.address); - await delegation.deployed(); - const WhitelistRegistry = await ethers.getContractFactory('WhitelistRegistry'); - const whitelistRegistry = await WhitelistRegistry.deploy(delegation.address, BALANCE_THRESHOLD); - await whitelistRegistry.deployed(); - // fill all whitelist into WhitelistRegistry - for (let i = 0; i < MAX_WHITELISTED; ++i) { - const userIndex = i + 2; - const user = accounts[userIndex]; - await stakeAndRegisterInDelegation(st1inch, delegation, user, ether('2') * BigInt(i + 1), userIndex); - await whitelistRegistry.connect(user).register(); - } - await stakeAndRegisterInDelegation(st1inch, delegation, addr, ether('1'), 0); - - return { st1inch, delegation, whitelistRegistry }; - } - - before(async function () { - accounts = await ethers.getSigners(); - addr = accounts[0]; - addr1 = accounts[1]; - }); - - describe('For add to whitelist', function () { - const depositAndDelegateTo = async (st1inch, delegation, from, to, amount, duration = commonLockDuration) => { - await st1inch.connect(from).deposit(amount, duration); - await st1inch.connect(from).addPod(delegation.address); - await delegation.connect(from).delegate(to); - }; - - it('should add account, when sum stacked st1inch and deposit st1inch is sufficient', async function () { - const { st1inch, delegation, whitelistRegistry } = await loadFixture(initContracts); - // addr shouldn't register becouse his st1inch balance less that all of the whitelisted accounts - await expect(whitelistRegistry.register()).to.be.revertedWithCustomError( - whitelistRegistry, - 'BalanceLessThanThreshold', - ); - // create other stake and delegate to addr - await depositAndDelegateTo(st1inch, delegation, addr1, addr.address, ether('2')); - // register addr into whitelistRegistry and chack that - await whitelistRegistry.register(); - expect(await whitelistRegistry.getWhitelist()).to.contain(addr.address); - }); - - it('should add account, when sum stacked st1inch and deposit st1inch is sufficient (delegate before deposit)', async function () { - const { st1inch, delegation, whitelistRegistry } = await loadFixture(initContracts); - // delegate to addr and deposit 1inch - await st1inch.connect(addr1).addPod(delegation.address); - await delegation.connect(addr1).delegate(addr.address); - await st1inch.connect(addr1).deposit(ether('2'), commonLockDuration); - - await whitelistRegistry.register(); - }); - - it('should accrue DelegatedShare token after delegate', async function () { - const { st1inch, delegation } = await loadFixture(initContracts); - const DelegatedShare = await ethers.getContractFactory('DelegatedShare'); - const delegatedShare = await DelegatedShare.attach(await delegation.registration(addr.address)); - const balanceDelegated = await delegatedShare.balanceOf(addr.address); - expect(await delegatedShare.totalSupply()).to.equal(balanceDelegated); - expect(await st1inch.balanceOf(addr.address)).to.equal(balanceDelegated); - - await depositAndDelegateTo(st1inch, delegation, addr1, addr.address, ether('2')); - - const balanceDelegator = await delegatedShare.balanceOf(addr1.address); - expect(balanceDelegated.mul(await st1inch.balanceOf(addr1.address))).to.equal( - balanceDelegator.mul(await st1inch.balanceOf(addr.address)), - ); - }); - - it('should decrease delegatee balance, if delegator undelegate stake', async function () { - const { st1inch, delegation, whitelistRegistry } = await loadFixture(initContracts); - await depositAndDelegateTo(st1inch, delegation, addr1, addr.address, ether('8')); - await whitelistRegistry.register(); - - await delegation.connect(addr1).delegate(constants.ZERO_ADDRESS); - await whitelistRegistry.connect(accounts[2]).register(); - expect(await whitelistRegistry.getWhitelist()).to.not.contain(addr.address); - }); - - it('should decrease delegatee balance, if delegator delegate to other account', async function () { - const { st1inch, delegation, whitelistRegistry } = await loadFixture(initContracts); - await depositAndDelegateTo(st1inch, delegation, addr1, addr.address, ether('8')); - await whitelistRegistry.register(); - - await delegation.connect(addr1).delegate(accounts[2].address); - await whitelistRegistry.connect(accounts[2]).register(); - expect(await whitelistRegistry.getWhitelist()).to.not.contain(addr.address); - }); - }); -}); diff --git a/test/FeeBank.js b/test/FeeBank.js index 2650aee4..b101f692 100644 --- a/test/FeeBank.js +++ b/test/FeeBank.js @@ -1,4 +1,4 @@ -const { expect, ether, getPermit } = require('@1inch/solidity-utils'); +const { expect, ether, getPermit, deployContract } = require('@1inch/solidity-utils'); const { ethers } = require('hardhat'); const { BigNumber: BN } = require('ethers'); const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers'); @@ -15,16 +15,12 @@ describe('FeeBank', function () { }); async function initContracts() { - const TokenPermitMock = await ethers.getContractFactory('ERC20PermitMock'); - const inch = await TokenPermitMock.deploy('1INCH', '1INCH', addr.address, ether('1000')); - await inch.deployed(); + const inch = await deployContract('ERC20PermitMock', ['1INCH', '1INCH', addr.address, ether('1000')]); const { swap } = await deploySwapTokens(); - const SettlementMock = await ethers.getContractFactory('SettlementMock'); - const matcher = await SettlementMock.deploy(swap.address, inch.address); - await matcher.deployed(); + const matcher = await deployContract('SettlementMock', [swap.address, inch.address]); const FeeBank = await ethers.getContractFactory('FeeBank'); - const feeBank = await FeeBank.attach(await matcher.feeBank()); + const feeBank = FeeBank.attach(await matcher.feeBank()); await inch.transfer(addr1.address, ether('100')); await inch.approve(feeBank.address, ether('1000')); diff --git a/test/FeeBankCharger.js b/test/FeeBankCharger.js index 41131ca1..564178dd 100644 --- a/test/FeeBankCharger.js +++ b/test/FeeBankCharger.js @@ -1,4 +1,4 @@ -const { expect, ether } = require('@1inch/solidity-utils'); +const { expect, ether, deployContract } = require('@1inch/solidity-utils'); const { ethers } = require('hardhat'); const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers'); @@ -10,12 +10,9 @@ describe('FeeBankCharger', function () { }); async function initContracts() { - const TokenPermitMock = await ethers.getContractFactory('ERC20PermitMock'); - const inch = await TokenPermitMock.deploy('1INCH', '1INCH', addr.address, ether('1000')); - await inch.deployed(); - const FeeBankCharger = await ethers.getContractFactory('FeeBankCharger'); - const charger = await FeeBankCharger.deploy(inch.address); - await charger.deployed(); + const inch = await deployContract('ERC20PermitMock', ['1INCH', '1INCH', addr.address, ether('1000')]); + + const charger = await deployContract('FeeBankCharger', [inch.address]); const FeeBank = await ethers.getContractFactory('FeeBank'); const feeBank = FeeBank.attach(await charger.feeBank()); diff --git a/test/FusionDetailsMock.js b/test/FusionDetailsMock.js index a38bca46..400a4d76 100644 --- a/test/FusionDetailsMock.js +++ b/test/FusionDetailsMock.js @@ -1,14 +1,11 @@ -const { ethers } = require('hardhat'); const { BigNumber } = require('ethers'); const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers'); -const { expect, constants, time } = require('@1inch/solidity-utils'); +const { expect, constants, time, deployContract } = require('@1inch/solidity-utils'); const { buildFusions } = require('./helpers/fusionUtils'); describe('FusionDetailsMock', function () { async function initContracts() { - const FusionDetailsMock = await ethers.getContractFactory('FusionDetailsMock'); - const fusionDetailsMock = await FusionDetailsMock.deploy(); - await fusionDetailsMock.deployed(); + const fusionDetailsMock = await deployContract('FusionDetailsMock', []); return { fusionDetailsMock }; } diff --git a/test/PowerPod.js b/test/PowerPod.js index 86b57099..1dde35c0 100644 --- a/test/PowerPod.js +++ b/test/PowerPod.js @@ -1,16 +1,15 @@ -const { expect, time, ether } = require('@1inch/solidity-utils'); +const { expect, time, ether, deployContract, constants } = require('@1inch/solidity-utils'); const { ethers } = require('hardhat'); const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers'); const { expBase } = require('./helpers/utils'); describe('PowerPod', function () { - let addr, addr1; - let accounts; - const commonLockDuration = time.duration.days('40'); - const amountToStake = ether('1'); + const COMMON_LOCK_DURATION = time.duration.days('40'); + const MAX_WHITELISTED = 3; + const BALANCE_THRESHOLD = 1000; // 10% const stakeAndRegisterInDelegation = async (st1inch, delegation, user, amount, userIndex) => { - await st1inch.connect(user).deposit(0, commonLockDuration); + await st1inch.connect(user).deposit(0, COMMON_LOCK_DURATION); await st1inch.depositFor(user.address, amount); await st1inch.connect(user).addPod(delegation.address); await delegation @@ -22,39 +21,127 @@ describe('PowerPod', function () { await delegation.connect(user).delegate(user.address); }; + const depositAndDelegateTo = async (st1inch, delegation, from, to, amount, duration = COMMON_LOCK_DURATION) => { + await st1inch.connect(from).deposit(amount, duration); + await st1inch.connect(from).addPod(delegation.address); + await delegation.connect(from).delegate(to); + }; + async function initContracts() { - const TokenPermitMock = await ethers.getContractFactory('ERC20PermitMock'); - const oneInch = await TokenPermitMock.deploy('1inch', '1inch', addr.address, ether('200')); - await oneInch.deployed(); + const accounts = await ethers.getSigners(); + const [owner, alice, whitelistedUser1, /* whitelistedUser2 */, /* whitelistedUser3 */, clearAddress] = accounts; + + const oneInch = await deployContract('ERC20PermitMock', ['1inch', '1inch', owner.address, ether('200')]); + await oneInch.transfer(alice.address, ether('100')); - const St1inch = await ethers.getContractFactory('St1inch'); - const st1inch = await St1inch.deploy(oneInch.address, expBase, addr.address); - await st1inch.deployed(); + const st1inch = await deployContract('St1inch', [oneInch.address, expBase, owner.address]); await oneInch.approve(st1inch.address, ether('100')); + await oneInch.connect(alice).approve(st1inch.address, ether('100')); - const PowerPod = await ethers.getContractFactory('PowerPod'); - const delegation = await PowerPod.deploy('PowerPod', 'PP', st1inch.address); - await delegation.deployed(); - await stakeAndRegisterInDelegation(st1inch, delegation, addr1, amountToStake, 0); + const delegation = await deployContract('PowerPod', ['PowerPod', 'PP', st1inch.address]); - return { st1inch, delegation }; - } + const whitelistRegistry = await deployContract('WhitelistRegistry', [delegation.address, BALANCE_THRESHOLD]); + // fill all whitelist into WhitelistRegistry + for (let i = 0; i < MAX_WHITELISTED; ++i) { + const userIndex = i + 2; + const user = accounts[userIndex]; + await stakeAndRegisterInDelegation(st1inch, delegation, user, ether('2') * BigInt(i + 1), userIndex); + await whitelistRegistry.connect(user).register(); + } + await stakeAndRegisterInDelegation(st1inch, delegation, owner, ether('1'), 0); - before(async function () { - accounts = await ethers.getSigners(); - addr = accounts[0]; - addr1 = accounts[1]; - }); + return { + contracts: { st1inch, delegation, whitelistRegistry }, + accounts: { owner, alice, whitelistedUser1, clearAddress }, + }; + } describe('Should calculate voting power', function () { it('for account with 0 balance', async function () { - const { delegation } = await loadFixture(initContracts); - expect(await delegation.votingPowerOf(addr.address)).to.equal(0); + const { contracts: { delegation }, accounts: { clearAddress } } = await loadFixture(initContracts); + expect(await delegation.votingPowerOf(clearAddress.address)).to.equal(0); }); it('for account with st1inch balance', async function () { - const { st1inch, delegation } = await loadFixture(initContracts); - expect(await delegation.votingPowerOf(addr1.address)).to.equal(await st1inch.votingPowerOf(addr1.address)); + const { contracts: { st1inch, delegation }, accounts: { alice } } = await loadFixture(initContracts); + expect(await delegation.votingPowerOf(alice.address)).to.equal(await st1inch.votingPowerOf(alice.address)); + }); + }); + + describe('For add to whitelist', function () { + it('should add account, when sum stacked st1inch and deposit st1inch is sufficient', async function () { + const { + contracts: { st1inch, delegation, whitelistRegistry }, + accounts: { owner, alice }, + } = await loadFixture(initContracts); + // owner shouldn't register becouse his st1inch balance less that all of the whitelisted accounts + await expect(whitelistRegistry.register()).to.be.revertedWithCustomError( + whitelistRegistry, + 'BalanceLessThanThreshold', + ); + // create other stake and delegate to owner + await depositAndDelegateTo(st1inch, delegation, alice, owner.address, ether('2')); + // register owner into whitelistRegistry and chack that + await whitelistRegistry.register(); + expect(await whitelistRegistry.getWhitelist()).to.contain(owner.address); + }); + + it('should add account, when sum stacked st1inch and deposit st1inch is sufficient (delegate before deposit)', async function () { + const { + contracts: { st1inch, delegation, whitelistRegistry }, + accounts: { owner, alice }, + } = await loadFixture(initContracts); + // delegate to owner and deposit 1inch + await st1inch.connect(alice).addPod(delegation.address); + await delegation.connect(alice).delegate(owner.address); + await st1inch.connect(alice).deposit(ether('2'), COMMON_LOCK_DURATION); + + await whitelistRegistry.register(); + }); + + it('should accrue DelegatedShare token after delegate', async function () { + const { + contracts: { st1inch, delegation }, + accounts: { owner, alice }, + } = await loadFixture(initContracts); + const DelegatedShare = await ethers.getContractFactory('DelegatedShare'); + const delegatedShare = DelegatedShare.attach(await delegation.registration(owner.address)); + const balanceDelegated = await delegatedShare.balanceOf(owner.address); + expect(await delegatedShare.totalSupply()).to.equal(balanceDelegated); + expect(await st1inch.balanceOf(owner.address)).to.equal(balanceDelegated); + + await depositAndDelegateTo(st1inch, delegation, alice, owner.address, ether('2')); + + const balanceDelegator = await delegatedShare.balanceOf(alice.address); + expect(balanceDelegated.mul(await st1inch.balanceOf(alice.address))).to.equal( + balanceDelegator.mul(await st1inch.balanceOf(owner.address)), + ); + }); + + it('should decrease delegatee balance, if delegator undelegate stake', async function () { + const { + contracts: { st1inch, delegation, whitelistRegistry }, + accounts: { owner, alice, whitelistedUser1 }, + } = await loadFixture(initContracts); + await depositAndDelegateTo(st1inch, delegation, alice, owner.address, ether('8')); + await whitelistRegistry.register(); + + await delegation.connect(alice).delegate(constants.ZERO_ADDRESS); + await whitelistRegistry.connect(whitelistedUser1).register(); + expect(await whitelistRegistry.getWhitelist()).to.not.contain(owner.address); + }); + + it('should decrease delegatee balance, if delegator delegate to other account', async function () { + const { + contracts: { st1inch, delegation, whitelistRegistry }, + accounts: { owner, alice, whitelistedUser1 }, + } = await loadFixture(initContracts); + await depositAndDelegateTo(st1inch, delegation, alice, owner.address, ether('8')); + await whitelistRegistry.register(); + + await delegation.connect(alice).delegate(whitelistedUser1.address); + await whitelistRegistry.connect(whitelistedUser1).register(); + expect(await whitelistRegistry.getWhitelist()).to.not.contain(owner.address); }); }); }); diff --git a/test/Settlement.js b/test/Settlement.js index f9486ddd..0642d2cf 100644 --- a/test/Settlement.js +++ b/test/Settlement.js @@ -1,4 +1,4 @@ -const { time, expect, ether, trim0x, timeIncreaseTo, getPermit, getPermit2, compressPermit, permit2Contract } = require('@1inch/solidity-utils'); +const { time, expect, ether, trim0x, timeIncreaseTo, getPermit, getPermit2, compressPermit, permit2Contract, deployContract } = require('@1inch/solidity-utils'); const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers'); const { ethers } = require('hardhat'); const { deploySwapTokens, getChainId } = require('./helpers/fixtures'); @@ -21,12 +21,10 @@ describe('Settlement', function () { await weth.deposit({ value: ether('1') }); await weth.connect(addr1).deposit({ value: ether('1') }); - const SettlementMock = await ethers.getContractFactory('SettlementMock'); - const settlement = await SettlementMock.deploy(swap.address, inch.address); - await settlement.deployed(); + const settlement = await deployContract('SettlementMock', [swap.address, inch.address]); const FeeBank = await ethers.getContractFactory('FeeBank'); - const feeBank = await FeeBank.attach(await settlement.feeBank()); + const feeBank = FeeBank.attach(await settlement.feeBank()); const ResolverMock = await ethers.getContractFactory('ResolverMock'); const resolver = await ResolverMock.deploy(settlement.address, swap.address); diff --git a/test/WhitelistChecker.js b/test/WhitelistChecker.js index b8361f07..948faf63 100644 --- a/test/WhitelistChecker.js +++ b/test/WhitelistChecker.js @@ -1,8 +1,8 @@ const { ethers } = require('hardhat'); const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers'); const { signOrder, buildOrder, compactSignature, fillWithMakingAmount } = require('@1inch/limit-order-protocol-contract/test/helpers/orderUtils'); -const { expect, ether, trim0x } = require('@1inch/solidity-utils'); -const { deploySwapTokens, getChainId, deploySimpleRegistry } = require('./helpers/fixtures'); +const { expect, ether, trim0x, deployContract } = require('@1inch/solidity-utils'); +const { deploySwapTokens, getChainId } = require('./helpers/fixtures'); const { buildFusions } = require('./helpers/fusionUtils'); describe('WhitelistChecker', function () { @@ -27,10 +27,8 @@ describe('WhitelistChecker', function () { await weth.approve(swap.address, ether('1')); await weth.connect(addr1).approve(swap.address, ether('1')); - const whitelistRegistrySimple = await deploySimpleRegistry(); - const Settlement = await ethers.getContractFactory('Settlement'); - const settlement = await Settlement.deploy(swap.address, weth.address); - await settlement.deployed(); + const whitelistRegistrySimple = await deployContract('WhitelistRegistrySimple', []); + const settlement = await deployContract('Settlement', [swap.address, weth.address]); const ResolverMock = await ethers.getContractFactory('ResolverMock'); const resolver = await ResolverMock.deploy(settlement.address, swap.address); diff --git a/test/WhitelistRegistry.js b/test/WhitelistRegistry.js index b5c021a7..938bae33 100644 --- a/test/WhitelistRegistry.js +++ b/test/WhitelistRegistry.js @@ -1,4 +1,4 @@ -const { expect, constants, ether, trackReceivedTokenAndTx } = require('@1inch/solidity-utils'); +const { expect, constants, ether, trackReceivedTokenAndTx, deployContract } = require('@1inch/solidity-utils'); const { ethers } = require('hardhat'); const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers'); const { expBase } = require('./helpers/utils'); @@ -26,21 +26,12 @@ describe('WhitelistRegistry', function () { before(async function () { addrs = await ethers.getSigners(); - const St1inch = await ethers.getContractFactory('St1inch'); - st1inch = await St1inch.deploy(constants.ZERO_ADDRESS, expBase, addrs[0].address); - await st1inch.deployed(); + st1inch = await deployContract('St1inch', [constants.ZERO_ADDRESS, expBase, addrs[0].address]); }); async function initContracts() { - const PowerPodMock = await ethers.getContractFactory('PowerPodMock'); - const rewardableDelegationPod = await PowerPodMock.deploy('reward1INCH', 'reward1INCH', st1inch.address); - await rewardableDelegationPod.deployed(); - const WhitelistRegistry = await ethers.getContractFactory('WhitelistRegistry'); - const whitelistRegistry = await WhitelistRegistry.deploy( - rewardableDelegationPod.address, - PERCENTAGE_THRESHOLD, - ); - await whitelistRegistry.deployed(); + const rewardableDelegationPod = await deployContract('PowerPodMock', ['reward1INCH', 'reward1INCH', st1inch.address]); + const whitelistRegistry = await deployContract('WhitelistRegistry', [rewardableDelegationPod.address, PERCENTAGE_THRESHOLD]); return { rewardableDelegationPod, whitelistRegistry }; } @@ -127,16 +118,16 @@ describe('WhitelistRegistry', function () { whitelistRegistry.connect(addrs[WHITELIST_LIMIT + 1]).register(), ).to.be.revertedWithCustomError(whitelistRegistry, 'BalanceLessThanThreshold'); expect(await whitelistRegistry.getWhitelist()).to.not.contain(addrs[WHITELIST_LIMIT + 1].address); - + await rewardableDelegationPod.burn(addrs[1].address, RESOLVER_BALANCE); await rewardableDelegationPod.mint(addrs[WHITELIST_LIMIT + 1].address, RESOLVER_BALANCE); - + await whitelistRegistry.connect(addrs[WHITELIST_LIMIT + 1]).register(); const whitelist = await whitelistRegistry.getWhitelist(); expect(whitelist).to.contain(addrs[WHITELIST_LIMIT + 1].address); await expectAddrsInWhitelist(whitelistRegistry, 1, WHITELIST_LIMIT + 1, [1]); }); - + it('5/10 addresses, then lower balance, then whitelist +1 successfully', async function () { const { rewardableDelegationPod, whitelistRegistry } = await loadFixture(initContracts); const resolversNumber = WHITELIST_LIMIT / 2; @@ -157,7 +148,7 @@ describe('WhitelistRegistry', function () { expect(whitelist).to.contain(addrs[3].address); expect(whitelist).to.contain(addrs[resolversNumber + 1].address); }); - + it('5/10 addresses, then lower balance, then whitelist instead successfully', async function () { const { rewardableDelegationPod, whitelistRegistry } = await loadFixture(initContracts); const resolversNumber = WHITELIST_LIMIT / 2; @@ -203,7 +194,7 @@ describe('WhitelistRegistry', function () { 'BalanceLessThanThreshold', ); }); - + it('the same address twice', async function () { const { rewardableDelegationPod, whitelistRegistry } = await loadFixture(initContracts); await rewardableDelegationPod.mint(addrs[1].address, RESOLVER_BALANCE); diff --git a/test/helpers/fixtures.js b/test/helpers/fixtures.js index c4ea5a60..0854a215 100644 --- a/test/helpers/fixtures.js +++ b/test/helpers/fixtures.js @@ -1,17 +1,10 @@ const { ethers } = require('hardhat'); -const { ether } = require('@1inch/solidity-utils'); +const { ether, deployContract } = require('@1inch/solidity-utils'); async function getChainId() { return (await ethers.provider.getNetwork()).chainId; } -async function deployContract(contractFactoryName, params = []) { - const Contract = await ethers.getContractFactory(contractFactoryName); - const contract = await Contract.deploy(...params); - await contract.deployed(); - return contract; -} - async function deploySwapTokens() { const [account] = await ethers.getSigners(); const dai = await deployContract('ERC20PermitMock', ['DAI', 'DAI', account.address, ether('1000')]); @@ -21,16 +14,8 @@ async function deploySwapTokens() { return { dai, weth, inch, swap }; } -async function deploySimpleRegistry() { - const WhitelistRegistrySimple = await ethers.getContractFactory('WhitelistRegistrySimple'); - const whitelistRegistrySimple = await WhitelistRegistrySimple.deploy(); - await whitelistRegistrySimple.deployed(); - return whitelistRegistrySimple; -} - module.exports = { deployContract, - deploySimpleRegistry, deploySwapTokens, getChainId, };