Skip to content

Commit

Permalink
#5 minter can burn amount exceeds itself mint
Browse files Browse the repository at this point in the history
minter should do this by calling 'setComintCap'
  • Loading branch information
jowenshaw committed May 17, 2022
1 parent 1bd0f3f commit b1089dc
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions contracts/wrapper/MintBurnWrapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ contract MintBurnWrapper is IBridge, IRouter, AccessControlEnumerable, PausableC
uint256 max; // single limit of each mint
uint256 cap; // total limit of all mint
uint256 total; // total minted minus burned
uint256 comintcap; // total limit of cominters which is burned by this minter
}

mapping(address => Supply) public minterSupply;
Expand Down Expand Up @@ -154,8 +155,15 @@ contract MintBurnWrapper is IBridge, IRouter, AccessControlEnumerable, PausableC

if (hasRole(MINTER_ROLE, msg.sender)) {
Supply storage s = minterSupply[msg.sender];
require(s.total >= amount, "minter burn amount exceeded");
s.total -= amount;
require(s.total + s.comintcap >= amount, "minter burn amount exceeded");
if (s.total >= amount) {
s.total -= amount;
} else if (s.total == 0) {
s.comintcap -= amount;
} else {
s.comintcap -= (amount - s.total);
s.total = 0;
}
}

require(totalMinted >= amount, "total burn amount exceeded");
Expand Down Expand Up @@ -272,4 +280,9 @@ contract MintBurnWrapper is IBridge, IRouter, AccessControlEnumerable, PausableC
require(force || hasRole(MINTER_ROLE, minter), "not minter");
minterSupply[minter].total = total;
}

function setComintCap(uint256 cap) external {
require(hasRole(MINTER_ROLE, msg.sender), "not minter");
minterSupply[msg.sender].comintcap = cap;
}
}

0 comments on commit b1089dc

Please sign in to comment.