Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
prateek105 committed Aug 9, 2023
1 parent b8662da commit d50335b
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/grants/Deployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,33 @@ import { GrantFund } from "./GrantFund.sol";

contract Deployer {

error IncorrectTreasuryBalance();

error DistributionNotStarted();

GrantFund public grantFund;

function deployGrantFund(address ajnaToken_, uint256 treasury_) public returns (GrantFund) {
function deployGrantFund(address ajnaToken_, uint256 treasury_) public returns (GrantFund grantFund_) {

// deploy grant Fund
grantFund_ = new GrantFund(ajnaToken_);

// Approve ajna token to fund treasury
IERC20(ajnaToken_).approve(address(grantFund_), treasury_);

// Transfer treasury ajna tokens to Deployer contract
IERC20(ajnaToken_).transferFrom(msg.sender, address(this), treasury_);

grantFund = new GrantFund(ajnaToken_);
// Fund treasury and start new distribution
grantFund_.fundTreasury(treasury_);
grantFund_.startNewDistributionPeriod();

IERC20(ajnaToken_).approve(address(grantFund), treasury_);
// check treasury balance is correct
if(IERC20(ajnaToken_).balanceOf(address(grantFund_)) != treasury_) revert IncorrectTreasuryBalance();

grantFund.fundTreasury(treasury_);
// check new distribution started
if(grantFund_.getDistributionId() != 1) revert DistributionNotStarted();

grantFund.startNewDistributionPeriod();
return grantFund;
grantFund = grantFund_;
}
}

0 comments on commit d50335b

Please sign in to comment.