diff --git a/contracts/core/index-fund/IndexFund.sol b/contracts/core/index-fund/IndexFund.sol index a1184e1f6..f46363750 100644 --- a/contracts/core/index-fund/IndexFund.sol +++ b/contracts/core/index-fund/IndexFund.sol @@ -262,7 +262,10 @@ contract IndexFund is IIndexFund, Storage, OwnableUpgradeable, ReentrancyGuard { // tokens must be transfered from the sender to this contract IERC20(token).safeTransferFrom(msg.sender, address(this), amount); // we give allowance to accounts contract - IERC20(token).safeApprove(registrarConfig.accountsContract, amount); + require( + IERC20(token).approve(registrarConfig.accountsContract, amount), + "Approval needed for Accounts Contract to spend" + ); if (fundId != 0) { // Depositor has chosen a specific fund to send tokens to. Send 100% to that fund. @@ -305,7 +308,7 @@ contract IndexFund is IIndexFund, Storage, OwnableUpgradeable, ReentrancyGuard { ); } else if (state.config.fundRotation == 0 && state.config.fundingGoal > 0) { // Fundraising Goal-based rotation of Funds - // Check if funding goal is met for current active fund and rotate funds + // Check if funding goal is met for current active fund and rotate funds // until all donated tokens are depleted uint256 loopDonation = 0; uint256 goalLeftover = state.config.fundingGoal - state.roundDonations; diff --git a/test/core/IndexFund.ts b/test/core/IndexFund.ts index 4be92615f..adee74218 100644 --- a/test/core/IndexFund.ts +++ b/test/core/IndexFund.ts @@ -437,6 +437,12 @@ describe("IndexFund", function () { ); }); + it("reverts when amount donated, on a per endowment-basis for a fund, would be < 100 units", async function () { + expect(indexFund.depositERC20(1, token1.address, 100)).to.be.revertedWith( + "Amount must be greater than 100 units per endowment" + ); + }); + it("reverts when target fund is expired", async function () { expect(indexFund.depositERC20(2, token1.address, 100)).to.be.revertedWith("Fund expired"); }); @@ -496,9 +502,11 @@ describe("IndexFund", function () { expect( await indexFund.depositERC20(4, token1.address, 500, { gasPrice: 3000, - gasLimit: 10000000 + gasLimit: 10000000, }) - ).to.emit(indexFund, "DonationProcessed").withArgs(4); + ) + .to.emit(indexFund, "DonationProcessed") + .withArgs(4); }); it("passes for an active fund donation(amount-based rotation), amount > zero & token is valid", async function () { @@ -511,11 +519,14 @@ describe("IndexFund", function () { .to.emit("FundCreated") .withArgs(5); - expect(await indexFund.depositERC20(0, token1.address, 10000, { + expect( + await indexFund.depositERC20(0, token1.address, 10000, { gasPrice: 3000, - gasLimit: 10000000 + gasLimit: 10000000, }) - ).to.emit(indeFund, "DonationProcessed").withArgs(4); + ) + .to.emit(indexFund, "DonationProcessed") + .withArgs(4); }); }); });