diff --git a/contracts/interfaces/IBlockReward.sol b/contracts/interfaces/IBlockReward.sol index eaf0c533b..c869ce8be 100644 --- a/contracts/interfaces/IBlockReward.sol +++ b/contracts/interfaces/IBlockReward.sol @@ -5,7 +5,7 @@ interface IBlockReward { function mintedTotally() external view returns (uint256); function mintedTotallyByBridge(address _bridge) external view returns (uint256); function bridgesAllowedLength() external view returns (uint256); - function addBridgeTokenFeeReceivers(uint256 _amount) external; - function addBridgeNativeFeeReceivers(uint256 _amount) external; + function addBridgeTokenRewardReceivers(uint256 _amount) external; + function addBridgeNativeRewardReceivers(uint256 _amount) external; function blockRewardContractId() external pure returns (bytes4); } diff --git a/contracts/mocks/BlockReward.sol b/contracts/mocks/BlockReward.sol index af7716d91..6c5d0a69b 100644 --- a/contracts/mocks/BlockReward.sol +++ b/contracts/mocks/BlockReward.sol @@ -48,7 +48,7 @@ contract BlockReward { token = _token; } - function addBridgeNativeFeeReceivers(uint256 _amount) external { + function addBridgeNativeRewardReceivers(uint256 _amount) external { feeAmount = _amount; uint256 feePerValidator = _amount.div(validatorList.length); @@ -67,7 +67,7 @@ contract BlockReward { } } - function addBridgeTokenFeeReceivers(uint256 _amount) external { + function addBridgeTokenRewardReceivers(uint256 _amount) external { validatorRewardList = new uint256[](validatorList.length); feeAmount = _amount; uint256 feePerValidator = _amount.div(validatorList.length); diff --git a/contracts/mocks/ForeignBridgeErcToNativeMock.sol b/contracts/mocks/ForeignBridgeErcToNativeMock.sol index d33388f1e..0306e9ef5 100644 --- a/contracts/mocks/ForeignBridgeErcToNativeMock.sol +++ b/contracts/mocks/ForeignBridgeErcToNativeMock.sol @@ -27,4 +27,8 @@ contract ForeignBridgeErcToNativeMock is ForeignBridgeErcToNative { function chaiToken() public view returns (IChai) { return IChai(addressStorage[CHAI_TOKEN_MOCK]); } + + function convertChaiToDai(uint256 amount) external { + _convertChaiToDai(amount); + } } diff --git a/contracts/upgradeable_contracts/ChaiConnector.sol b/contracts/upgradeable_contracts/ChaiConnector.sol index f58db1458..8e1d5c7c7 100644 --- a/contracts/upgradeable_contracts/ChaiConnector.sol +++ b/contracts/upgradeable_contracts/ChaiConnector.sol @@ -16,7 +16,7 @@ contract ChaiConnector is Ownable, ERC20Bridge { bytes32 internal constant CHAI_TOKEN_ENABLED = 0x2ae87563606f93f71ad2adf4d62661ccdfb63f3f508f94700934d5877fb92278; // keccak256(abi.encodePacked("chaiTokenEnabled")) bytes32 internal constant INTEREST_RECEIVER = 0xd88509eb1a8da5d5a2fc7b9bad1c72874c9818c788e81d0bc46b29bfaa83adf6; // keccak256(abi.encodePacked("interestReceiver")) bytes32 internal constant INTEREST_COLLECTION_PERIOD = 0x68a6a652d193e5d6439c4309583048050a11a4cfb263a220f4cd798c61c3ad6e; // keccak256(abi.encodePacked("interestCollectionPeriod")) - bytes32 internal constant LAST_TIME_INTEREST_PAYED = 0x120db89f168bb39d737b6a1d240da847e2ead5ecca5b2e4c5e94edbe39d614d9; // keccak256(abi.encodePacked("lastTimeInterestPayed")) + bytes32 internal constant LAST_TIME_INTEREST_PAID = 0xcabd46177a706f95f4bb3e2c2ba45ac4aa1eac9c545425a19c62ab6de4aeea26; // keccak256(abi.encodePacked("lastTimeInterestPaid")) bytes32 internal constant INVESTED_AMOUNT = 0xb6afb3323c9d7dc0e9dab5d34c3a1d1ae7739d2224c048d4ee7675d3c759dd1b; // keccak256(abi.encodePacked("investedAmount")) bytes32 internal constant MIN_DAI_TOKEN_BALANCE = 0xce70e1dac97909c26a87aa4ada3d490673a153b3a75b22ea3364c4c7df7c551f; // keccak256(abi.encodePacked("minDaiTokenBalance")) bytes4 internal constant ON_TOKEN_TRANSFER = 0xa4c0ed36; // onTokenTransfer(address,uint256,bytes) @@ -57,7 +57,7 @@ contract ChaiConnector is Ownable, ERC20Bridge { /** * @dev Initializes chai token */ - function initializeChaiToken() external onlyOwner { + function initializeChaiToken() public onlyOwner { require(!isChaiTokenEnabled()); require(address(chaiToken().daiToken()) == address(erc20token())); boolStorage[CHAI_TOKEN_ENABLED] = true; @@ -65,6 +65,17 @@ contract ChaiConnector is Ownable, ERC20Bridge { uintStorage[INTEREST_COLLECTION_PERIOD] = 1 weeks; } + /** + * @dev Initializes chai token, with interestReceiver + * @param _interestReceiver Receiver address + */ + function initializeChaiToken(address _interestReceiver) external { + require(_interestReceiver != address(0)); + // onlyOwner condition is checked inside this call, so it can be excluded from function definition + initializeChaiToken(); + addressStorage[INTEREST_RECEIVER] = _interestReceiver; + } + /** * @dev Sets minimum DAI limit, needed for converting DAI into CHAI */ @@ -97,8 +108,8 @@ contract ChaiConnector is Ownable, ERC20Bridge { } /** - * Updates interest receiver contract address - * @param receiver New receiver contract address + * Updates interest receiver address + * @param receiver New receiver address */ function setInterestReceiver(address receiver) external onlyOwner { addressStorage[INTEREST_RECEIVER] = receiver; @@ -108,7 +119,7 @@ contract ChaiConnector is Ownable, ERC20Bridge { * @return Timestamp of last interest payment */ function lastInterestPayment() public view returns (uint256) { - return uintStorage[LAST_TIME_INTEREST_PAYED]; + return uintStorage[LAST_TIME_INTEREST_PAID]; } /** @@ -132,15 +143,13 @@ contract ChaiConnector is Ownable, ERC20Bridge { * for others, the method can be called only once a specified period. */ function payInterest() external chaiTokenEnabled { - // solhint-disable not-rely-on-time if ( + // solhint-disable-next-line not-rely-on-time lastInterestPayment() + interestCollectionPeriod() < now || IUpgradeabilityOwnerStorage(this).upgradeabilityOwner() == msg.sender ) { - uintStorage[LAST_TIME_INTEREST_PAYED] = now; _payInterest(); } - // solhint-enable not-rely-on-time } /** @@ -156,6 +165,9 @@ contract ChaiConnector is Ownable, ERC20Bridge { chaiToken().exit(address(this), chaiBalance().sub(investedAmountInChai())); uint256 interestInDai = daiBalance().sub(balanceBefore); + // solhint-disable-next-line not-rely-on-time + uintStorage[LAST_TIME_INTEREST_PAID] = now; + erc20token().transfer(interestReceiver(), interestInDai); interestReceiver().call(abi.encodeWithSelector(ON_TOKEN_TRANSFER, address(this), interestInDai, "")); @@ -188,7 +200,7 @@ contract ChaiConnector is Ownable, ERC20Bridge { } /** - * @dev Evaluates exact current invested amount, id DAI + * @dev Evaluates exact current invested amount, in DAI * @return Value in DAI */ function investedAmountInDai() public view returns (uint256) { @@ -196,10 +208,10 @@ contract ChaiConnector is Ownable, ERC20Bridge { } /** - * @dev Updates current invested amount, id DAI + * @dev Updates current invested amount, in DAI * @return Value in DAI */ - function setInvestedAmointInDai(uint256 amount) internal { + function setInvestedAmountInDai(uint256 amount) internal { uintStorage[INVESTED_AMOUNT] = amount; } @@ -234,16 +246,20 @@ contract ChaiConnector is Ownable, ERC20Bridge { // there is not need to consider overflow when performing a + operation, // since both values are controlled by the bridge and can't take extremely high values uint256 amount = daiBalance().sub(minDaiTokenBalance()); - setInvestedAmointInDai(investedAmountInDai() + amount); + uint256 newInvestedAmountInDai = investedAmountInDai() + amount; + setInvestedAmountInDai(newInvestedAmountInDai); erc20token().approve(chaiToken(), amount); chaiToken().join(address(this), amount); // When evaluating the amount of DAI kept in Chai using dsrBalance(), there are some fixed point truncations. // The dependency between invested amount of DAI - value and returned value of dsrBalance() - res is the following: - // res = floor(floor(value / chi) * chi)), where chi is the coefficient from MakerDAO Pot contract - // This can lead up to losses of ceil(chi) DAI in this balance evaluation. + // res = floor(floor(value / K) * K)), where K is the fixed-point coefficient + // from MakerDAO Pot contract (K = pot.chi() / 10**27). + // This can lead up to losses of ceil(K) DAI in this balance evaluation. // The constant is needed here for making sure that everything works fine, and this error is small enough - require(dsrBalance() + 10000 >= investedAmountInDai()); + // The 10000 constant is considered to be small enough when decimals = 18, however, + // it is not recommended to use it for smaller values of decimals, since it won't be negligible anymore + require(dsrBalance() + 10000 >= newInvestedAmountInDai); } /** @@ -251,26 +267,24 @@ contract ChaiConnector is Ownable, ERC20Bridge { * @param amount Amount of DAI to redeem */ function _convertChaiToDai(uint256 amount) internal { + if (amount == 0) return; + uint256 invested = investedAmountInDai(); uint256 initialDaiBalance = daiBalance(); - if (amount >= invested) { - // onExecuteMessage can call a convert operation with argument greater than the current invested amount, - // in this case bridge should withdraw all invested funds - chaiToken().draw(address(this), invested); - setInvestedAmointInDai(0); - - // Make sure all invested tokens were withdrawn - require(daiBalance() - initialDaiBalance >= invested); - } else if (amount > 0) { - chaiToken().draw(address(this), amount); - uint256 redeemed = daiBalance() - initialDaiBalance; - - // Make sure that at least requested amount was withdrawn - require(redeemed >= amount); - - setInvestedAmointInDai(redeemed < invested ? invested - redeemed : 0); - } - require(dsrBalance() >= investedAmountInDai()); + // onExecuteMessage can call a convert operation with argument greater than the current invested amount, + // in this case bridge should withdraw all invested funds + uint256 withdrawal = amount >= invested ? invested : amount; + + chaiToken().draw(address(this), withdrawal); + uint256 redeemed = daiBalance() - initialDaiBalance; + + // Make sure that at least withdrawal amount was withdrawn + require(redeemed >= withdrawal); + + uint256 newInvested = invested > redeemed ? invested - redeemed : 0; + setInvestedAmountInDai(newInvested); + + require(dsrBalance() >= newInvested); } } diff --git a/contracts/upgradeable_contracts/erc20_to_erc20/FeeManagerErcToErcPOSDAO.sol b/contracts/upgradeable_contracts/erc20_to_erc20/FeeManagerErcToErcPOSDAO.sol index 5573c64c1..ce0e30964 100644 --- a/contracts/upgradeable_contracts/erc20_to_erc20/FeeManagerErcToErcPOSDAO.sol +++ b/contracts/upgradeable_contracts/erc20_to_erc20/FeeManagerErcToErcPOSDAO.sol @@ -17,6 +17,6 @@ contract FeeManagerErcToErcPOSDAO is BlockRewardFeeManager { function distributeFeeFromBlockReward(uint256 _fee) internal { IBlockReward blockReward = _blockRewardContract(); - blockReward.addBridgeTokenFeeReceivers(_fee); + blockReward.addBridgeTokenRewardReceivers(_fee); } } diff --git a/contracts/upgradeable_contracts/erc20_to_native/FeeManagerErcToNativePOSDAO.sol b/contracts/upgradeable_contracts/erc20_to_native/FeeManagerErcToNativePOSDAO.sol index a4a43b3a8..d983de48b 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/FeeManagerErcToNativePOSDAO.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/FeeManagerErcToNativePOSDAO.sol @@ -10,7 +10,7 @@ contract FeeManagerErcToNativePOSDAO is BlockRewardFeeManager { function distributeFeeFromBlockReward(uint256 _fee) internal { IBlockReward blockReward = _blockRewardContract(); - blockReward.addBridgeNativeFeeReceivers(_fee); + blockReward.addBridgeNativeRewardReceivers(_fee); } function getAmountToBurn(uint256 _value) public view returns (uint256) { diff --git a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol index 4d5c457a4..2290455a7 100644 --- a/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol +++ b/contracts/upgradeable_contracts/erc20_to_native/ForeignBridgeErcToNative.sol @@ -85,7 +85,7 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge, OtherSideB uint256 currentBalance = tokenBalance(erc20token()); - // Convert part of Chai tokens back to DAI, is DAI balance is insufficient. + // Convert part of Chai tokens back to DAI, if DAI balance is insufficient. // If Chai token is disabled, bridge will keep all funds directly in DAI token, // so it will have enough funds to cover any xDai => Dai transfer, // and currentBalance >= amount will always hold. diff --git a/test/erc_to_native/foreign_bridge.test.js b/test/erc_to_native/foreign_bridge.test.js index 429bf96c9..95e886c07 100644 --- a/test/erc_to_native/foreign_bridge.test.js +++ b/test/erc_to_native/foreign_bridge.test.js @@ -401,7 +401,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { }) it('should executeSignatures with enabled chai token, enough dai', async () => { - await foreignBridge.initializeChaiToken() + await foreignBridge.methods['initializeChaiToken()']() expect(await chaiToken.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(value) @@ -430,7 +430,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { }) it('should executeSignatures with enabled chai token, not enough dai, low dai limit', async () => { - await foreignBridge.initializeChaiToken({ from: owner }) + await foreignBridge.methods['initializeChaiToken()']({ from: owner }) await token.mint(foreignBridge.address, ether('1'), { from: owner }) // in case of low limit, bridge should withdraw tokens up to specified DAI limit await foreignBridge.setMinDaiTokenBalance(ether('0.1'), { from: owner }) @@ -464,7 +464,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { }) it('should executeSignatures with enabled chai token, not enough dai, high dai limit', async () => { - await foreignBridge.initializeChaiToken({ from: owner }) + await foreignBridge.methods['initializeChaiToken()']({ from: owner }) await token.mint(foreignBridge.address, ether('1'), { from: owner }) await foreignBridge.setMinDaiTokenBalance(ether('0.1'), { from: owner }) await foreignBridge.convertDaiToChai() @@ -1078,7 +1078,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { }) it('should allow to bridge tokens with chai token enabled', async () => { - await foreignBridge.initializeChaiToken() + await foreignBridge.methods['initializeChaiToken()']() expect(await chaiToken.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) const currentDay = await foreignBridge.getCurrentDay() @@ -1114,7 +1114,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { }) it('should allow to bridge tokens with chai token enabled, excess tokens', async () => { - await foreignBridge.initializeChaiToken() + await foreignBridge.methods['initializeChaiToken()']() await token.mint(foreignBridge.address, ether('201')) expect(await chaiToken.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) @@ -1481,7 +1481,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { it('should allow to bridge tokens specifying the token address with chai token enabled', async () => { // Given const chaiToken = await createChaiToken(dai, foreignBridge, owner) - await foreignBridge.initializeChaiToken() + await foreignBridge.methods['initializeChaiToken()']() expect(await chaiToken.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ZERO) const balance = await dai.balanceOf(user) @@ -1619,16 +1619,37 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { describe('initializeChaiToken', () => { it('should be initialized', async () => { - await foreignBridge.initializeChaiToken().should.be.fulfilled + await foreignBridge.methods['initializeChaiToken()']().should.be.fulfilled }) it('should fail to initialize twice', async () => { - await foreignBridge.initializeChaiToken().should.be.fulfilled - await foreignBridge.initializeChaiToken().should.be.rejected + await foreignBridge.methods['initializeChaiToken()']().should.be.fulfilled + await foreignBridge.methods['initializeChaiToken()']().should.be.rejected }) it('should fail if not an owner', async () => { - await foreignBridge.initializeChaiToken({ from: accounts[1] }).should.be.rejected + await foreignBridge.methods['initializeChaiToken()']({ from: accounts[1] }).should.be.rejected + }) + }) + + describe('initializeChaiToken with interest receiver', () => { + it('should be initialized', async () => { + await foreignBridge.methods['initializeChaiToken(address)'](accounts[3]).should.be.fulfilled + }) + + it('should fail to initialize twice', async () => { + await foreignBridge.methods['initializeChaiToken(address)'](accounts[3]).should.be.fulfilled + await foreignBridge.methods['initializeChaiToken(address)'](accounts[3]).should.be.rejected + }) + + it('should fail if not an owner', async () => { + await foreignBridge.methods['initializeChaiToken(address)'](accounts[3], { from: accounts[1] }).should.be + .rejected + }) + + it('should fail if zero address', async () => { + await foreignBridge.methods['initializeChaiToken(address)'](ZERO_ADDRESS, { from: accounts[1] }).should.be + .rejected }) }) @@ -1638,14 +1659,14 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { }) it('should return true', async () => { - await foreignBridge.initializeChaiToken().should.be.fulfilled + await foreignBridge.methods['initializeChaiToken()']().should.be.fulfilled expect(await foreignBridge.isChaiTokenEnabled()).to.be.equal(true) }) }) describe('removeChaiToken', () => { beforeEach(async () => { - await foreignBridge.initializeChaiToken().should.be.fulfilled + await foreignBridge.methods['initializeChaiToken()']().should.be.fulfilled await foreignBridge.setInterestReceiver(interestRecipient.address).should.be.fulfilled }) @@ -1684,7 +1705,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { describe('min dai limit', () => { beforeEach(async () => { - await foreignBridge.initializeChaiToken({ from: owner }) + await foreignBridge.methods['initializeChaiToken()']({ from: owner }) }) it('should return minDaiTokenBalance', async () => { @@ -1703,7 +1724,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { describe('interestReceiver', () => { beforeEach(async () => { - await foreignBridge.initializeChaiToken({ from: owner }) + await foreignBridge.methods['initializeChaiToken()']({ from: owner }) }) it('should return interestReceiver', async () => { @@ -1722,7 +1743,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { describe('interestCollectionPeriod', () => { beforeEach(async () => { - await foreignBridge.initializeChaiToken({ from: owner }) + await foreignBridge.methods['initializeChaiToken()']({ from: owner }) }) it('should return interestCollectionPeriod', async () => { @@ -1741,18 +1762,18 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { describe('isDaiNeedsToBeInvested', () => { it('should return false on empty balance', async () => { - await foreignBridge.initializeChaiToken() + await foreignBridge.methods['initializeChaiToken()']() expect(await foreignBridge.isDaiNeedsToBeInvested()).to.be.equal(false) }) it('should return false on insufficient balance', async () => { - await foreignBridge.initializeChaiToken() + await foreignBridge.methods['initializeChaiToken()']() await token.mint(foreignBridge.address, ether('101'), { from: owner }) expect(await foreignBridge.isDaiNeedsToBeInvested()).to.be.equal(false) }) it('should return true on sufficient balance', async () => { - await foreignBridge.initializeChaiToken() + await foreignBridge.methods['initializeChaiToken()']() await token.mint(foreignBridge.address, ether('201'), { from: owner }) expect(await foreignBridge.isDaiNeedsToBeInvested()).to.be.equal(true) }) @@ -1765,7 +1786,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { describe('convertDaiToChai', () => { it('should convert all dai except defined limit', async () => { - await foreignBridge.initializeChaiToken() + await foreignBridge.methods['initializeChaiToken()']() await token.mint(foreignBridge.address, ether('101')) await foreignBridge.convertDaiToChai({ from: accounts[1] }).should.be.fulfilled @@ -1779,9 +1800,56 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { }) }) + describe('_convertChaiToDai', async () => { + beforeEach(async () => { + await foreignBridge.methods['initializeChaiToken()']() + await token.mint(foreignBridge.address, ether('5')) + await foreignBridge.setMinDaiTokenBalance(ether('1'), { from: owner }) + await foreignBridge.convertDaiToChai() + + await delay(1500) + + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ether('1')) + expect(await foreignBridge.investedAmountInDai()).to.be.bignumber.equal(ether('4')) + expect(await chaiToken.balanceOf(foreignBridge.address)).to.be.bignumber.gt(ether('3.9')) + }) + + it('should handle 0 amount', async () => { + await foreignBridge.convertChaiToDai('0', { from: accounts[1] }).should.be.fulfilled + + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ether('1')) + expect(await foreignBridge.investedAmountInDai()).to.be.bignumber.equal(ether('4')) + expect(await chaiToken.balanceOf(foreignBridge.address)).to.be.bignumber.gt(ether('3.9')) + }) + + it('should handle overestimated amount', async () => { + await foreignBridge.convertChaiToDai(ether('10'), { from: accounts[1] }).should.be.fulfilled + + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ether('5')) + expect(await foreignBridge.investedAmountInDai()).to.be.bignumber.equal(ether('0')) + expect(await chaiToken.balanceOf(foreignBridge.address)).to.be.bignumber.lt(ether('0.1')) + }) + + it('should handle amount == invested', async () => { + await foreignBridge.convertChaiToDai(ether('4'), { from: accounts[1] }).should.be.fulfilled + + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ether('5')) + expect(await foreignBridge.investedAmountInDai()).to.be.bignumber.equal(ether('0')) + expect(await chaiToken.balanceOf(foreignBridge.address)).to.be.bignumber.lt(ether('0.1')) + }) + + it('should handle 0 < amount < invested', async () => { + await foreignBridge.convertChaiToDai(ether('3'), { from: accounts[1] }).should.be.fulfilled + + expect(await token.balanceOf(foreignBridge.address)).to.be.bignumber.equal(ether('4')) + expect(await foreignBridge.investedAmountInDai()).to.be.bignumber.equal(ether('1')) + expect(await chaiToken.balanceOf(foreignBridge.address)).to.be.bignumber.gt(ether('0.9')) + }) + }) + describe('payInterest', () => { beforeEach(async () => { - await foreignBridge.initializeChaiToken() + await foreignBridge.methods['initializeChaiToken()']() await token.mint(foreignBridge.address, halfEther) await foreignBridge.setMinDaiTokenBalance(ether('0.1'), { from: owner }) await foreignBridge.convertDaiToChai() @@ -1877,7 +1945,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { { from: accounts[2] } ) - await foreignBridgeProxy.initializeChaiToken() + await foreignBridgeProxy.methods['initializeChaiToken()']() await token.mint(foreignBridgeProxy.address, halfEther) await foreignBridgeProxy.setMinDaiTokenBalance(ether('0.1'), { from: owner }) await foreignBridgeProxy.convertDaiToChai() @@ -1921,7 +1989,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => { }) it('should not allow to claim Chai, if it is enabled', async () => { - await foreignBridgeProxy.initializeChaiToken({ from: owner }) + await foreignBridgeProxy.methods['initializeChaiToken()']({ from: owner }) await token.mint(foreignBridgeProxy.address, halfEther) await foreignBridgeProxy.setMinDaiTokenBalance(ether('0.1'), { from: owner }) await foreignBridgeProxy.convertDaiToChai()