Skip to content
This repository was archived by the owner on Oct 21, 2025. It is now read-only.

Commit d9a89ef

Browse files
authored
fix: Bump aave v3 dependencies (#186)
* fix: Remove unneccesary waffle dependency * fix: Bump aave-v3 deploy and core dependencies * test: Fix tests with new faucet mintable contracts
1 parent 551c497 commit d9a89ef

14 files changed

+14349
-27374
lines changed

contracts/mocks/WETH9Mock.sol

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,37 @@ import {WETH9} from '@aave/core-v3/contracts/dependencies/weth/WETH9.sol';
55
import {Ownable} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/Ownable.sol';
66

77
contract WETH9Mock is WETH9, Ownable {
8+
bool internal _protected;
9+
10+
/**
11+
* @dev Function modifier, if _protected is enabled then msg.sender is required to be the owner
12+
*/
13+
modifier onlyOwnerIfProtected() {
14+
if (_protected == true) {
15+
require(owner() == _msgSender(), 'Ownable: caller is not the owner');
16+
}
17+
_;
18+
}
19+
820
constructor(string memory mockName, string memory mockSymbol, address owner) {
921
name = mockName;
1022
symbol = mockSymbol;
1123

1224
transferOwnership(owner);
25+
_protected = true;
1326
}
1427

15-
function mint(address account, uint256 value) public onlyOwner returns (bool) {
28+
function mint(address account, uint256 value) public onlyOwnerIfProtected returns (bool) {
1629
balanceOf[account] += value;
1730
emit Transfer(address(0), account, value);
1831
return true;
1932
}
33+
34+
function setProtected(bool state) public onlyOwner {
35+
_protected = state;
36+
}
37+
38+
function isProtected() public view returns (bool) {
39+
return _protected;
40+
}
2041
}

contracts/mocks/testnet-helpers/Faucet.sol

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import {IFaucet} from './IFaucet.sol';
1010
* @dev Ownable Faucet Contract
1111
*/
1212
contract Faucet is IFaucet, Ownable {
13-
/// @inheritdoc IFaucet
14-
uint256 public constant MAX_MINT_AMOUNT = 10000;
13+
uint256 internal maximumMintAmount;
1514

1615
// Mapping to control mint of assets (allowed by default)
1716
mapping(address => bool) internal _nonMintable;
@@ -20,10 +19,11 @@ contract Faucet is IFaucet, Ownable {
2019
// If disabled, anyone can call mint at the faucet, for PoC environments
2120
bool internal _permissioned;
2221

23-
constructor(address owner, bool permissioned) {
22+
constructor(address owner, bool permissioned, uint256 maxMinAmount) {
2423
require(owner != address(0));
2524
transferOwnership(owner);
2625
_permissioned = permissioned;
26+
maximumMintAmount = maxMinAmount;
2727
}
2828

2929
/**
@@ -44,7 +44,7 @@ contract Faucet is IFaucet, Ownable {
4444
) external override onlyOwnerIfPermissioned returns (uint256) {
4545
require(!_nonMintable[token], 'Error: not mintable');
4646
require(
47-
amount <= MAX_MINT_AMOUNT * (10 ** TestnetERC20(token).decimals()),
47+
amount <= maximumMintAmount * (10 ** TestnetERC20(token).decimals()),
4848
'Error: Mint limit transaction exceeded'
4949
);
5050

@@ -81,4 +81,25 @@ contract Faucet is IFaucet, Ownable {
8181
Ownable(childContracts[i]).transferOwnership(newOwner);
8282
}
8383
}
84+
85+
/// @inheritdoc IFaucet
86+
function setProtectedOfChild(
87+
address[] calldata childContracts,
88+
bool state
89+
) external override onlyOwner {
90+
for (uint256 i = 0; i < childContracts.length; i++) {
91+
TestnetERC20(childContracts[i]).setProtected(state);
92+
}
93+
}
94+
95+
96+
/// @inheritdoc IFaucet
97+
function setMaximumMintAmount(uint256 newMaxMintAmount) external override onlyOwner {
98+
maximumMintAmount = newMaxMintAmount;
99+
}
100+
101+
/// @inheritdoc IFaucet
102+
function getMaximumMintAmount() external view override returns (uint256) {
103+
return maximumMintAmount;
104+
}
84105
}

contracts/mocks/testnet-helpers/IFaucet.sol

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
pragma solidity ^0.8.0;
33

44
interface IFaucet {
5-
/**
6-
* @notice Returns the maximum amount of tokens per mint allowed
7-
* @return The maximum amount of tokens per mint allowed
8-
*/
9-
function MAX_MINT_AMOUNT() external pure returns (uint256);
10-
115
/**
126
* @notice Function to mint Testnet tokens to the destination address
137
* @param token The address of the token to perform the mint
@@ -49,4 +43,23 @@ interface IFaucet {
4943
* @param newOwner The address of the new owner
5044
*/
5145
function transferOwnershipOfChild(address[] calldata childContracts, address newOwner) external;
46+
47+
/**
48+
* @notice Updates protection of minting feature of child token contracts
49+
* @param childContracts A list of child token contract addresses
50+
* @param state True if tokens are only mintable through Faucet, false otherwise
51+
*/
52+
function setProtectedOfChild(address[] calldata childContracts, bool state) external;
53+
54+
/**
55+
* @notice Updates the maximum amount of tokens per mint allowed
56+
* @param newMaxMintAmount The new value of maximum amount of tokens per mint (whole tokens)
57+
*/
58+
function setMaximumMintAmount(uint256 newMaxMintAmount) external;
59+
60+
/**
61+
* @notice Returns the maximum amount of tokens per mint allowed
62+
* @return The maximum amount of tokens per mint allowed (whole tokens)
63+
*/
64+
function getMaximumMintAmount() external view returns (uint256);
5265
}

contracts/mocks/testnet-helpers/TestnetERC20.sol

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ contract TestnetERC20 is IERC20WithPermit, ERC20, Ownable {
2121

2222
bytes32 public DOMAIN_SEPARATOR;
2323

24+
bool internal _protected;
25+
26+
/**
27+
* @dev Function modifier, if _protected is enabled then msg.sender is required to be the owner
28+
*/
29+
modifier onlyOwnerIfProtected() {
30+
if (_protected == true) {
31+
require(owner() == _msgSender(), 'Ownable: caller is not the owner');
32+
}
33+
_;
34+
}
35+
2436
constructor(
2537
string memory name,
2638
string memory symbol,
@@ -41,6 +53,7 @@ contract TestnetERC20 is IERC20WithPermit, ERC20, Ownable {
4153
_setupDecimals(decimals);
4254
require(owner != address(0));
4355
transferOwnership(owner);
56+
_protected = true;
4457
}
4558

4659
/// @inheritdoc IERC20WithPermit
@@ -74,7 +87,7 @@ contract TestnetERC20 is IERC20WithPermit, ERC20, Ownable {
7487
* @param value The amount of tokens to mint.
7588
* @return A boolean that indicates if the operation was successful.
7689
*/
77-
function mint(uint256 value) public virtual onlyOwner returns (bool) {
90+
function mint(uint256 value) public virtual onlyOwnerIfProtected returns (bool) {
7891
_mint(_msgSender(), value);
7992
return true;
8093
}
@@ -85,12 +98,20 @@ contract TestnetERC20 is IERC20WithPermit, ERC20, Ownable {
8598
* @param value The amount of tokens to mint.
8699
* @return A boolean that indicates if the operation was successful.
87100
*/
88-
function mint(address account, uint256 value) public virtual onlyOwner returns (bool) {
101+
function mint(address account, uint256 value) public virtual onlyOwnerIfProtected returns (bool) {
89102
_mint(account, value);
90103
return true;
91104
}
92105

93106
function nonces(address owner) public view returns (uint256) {
94107
return _nonces[owner];
95108
}
109+
110+
function setProtected(bool state) public onlyOwner {
111+
_protected = state;
112+
}
113+
114+
function isProtected() public view returns (bool) {
115+
return _protected;
116+
}
96117
}

0 commit comments

Comments
 (0)