Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VEN-2240]: Certik audit fixes on token bridge #8

Merged
merged 19 commits into from
Dec 20, 2023
1 change: 1 addition & 0 deletions contracts/Bridge/token/TokenController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ contract TokenController is Ownable, Pausable {
*/
function setMintCap(address minter_, uint256 amount_) external {
_ensureAllowed("setMintCap(address,uint256)");
require(amount_ > minterToMintedAmount[minter_], "New cap should be greater than minted tokens");
chechu marked this conversation as resolved.
Show resolved Hide resolved
minterToCap[minter_] = amount_;
emit MintCapChanged(minter_, amount_);
}
Expand Down
27 changes: 27 additions & 0 deletions test/proxyOFT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,33 @@ describe("Proxy OFTV2: ", function () {
accessControlManager.isAllowedToCall.returns(true);
});

it("Reverts if try to set cap less than already minted tokens", async function () {
const initialAmount = ethers.utils.parseEther("20", 18);
await localToken.connect(acc2).faucet(initialAmount);
await localToken.connect(acc2).approve(localOFT.address, initialAmount);
const amount = ethers.utils.parseEther("10", 18);
const acc3AddressBytes32 = ethers.utils.defaultAbiCoder.encode(["address"], [acc3.address]);
const nativeFee = (
await localOFT.estimateSendFee(remoteChainId, acc3AddressBytes32, amount, false, defaultAdapterParams)
).nativeFee;

await localOFT
.connect(acc2)
.sendFrom(
acc2.address,
remoteChainId,
acc3AddressBytes32,
amount,
[acc2.address, ethers.constants.AddressZero, defaultAdapterParams],
{ value: nativeFee },
),
// Msg should reach remote chain
expect(await remoteEndpoint.inboundNonce(localChainId, localPath)).equals(1);
await expect(remoteToken.connect(acc1).setMintCap(remoteOFT.address, convertToUnit(1, 18))).to.be.revertedWith(
"New cap should be greater than minted tokens",
);
});

it("Reverts on remote chain if minting cap is reached", async function () {
await remoteToken.connect(acc1).setMintCap(remoteOFT.address, convertToUnit(10, 18));
expect(await remoteEndpoint.inboundNonce(localChainId, localPath)).lessThanOrEqual(0);
Expand Down