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

Bump aave v3 dependencies #186

Merged
merged 21 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b47c0b2
fix: Remove unneccesary waffle dependency
miguelmtzinf Mar 4, 2024
bfaadea
fix: Bump aave-v3 deploy dep
miguelmtzinf Mar 4, 2024
892dbd2
fix: Bump aave-v3 core dep
miguelmtzinf Mar 4, 2024
c4065a4
fix: Make max mint limit configurable in test Faucet contract
miguelmtzinf Mar 4, 2024
9560def
fix: Bump package version
miguelmtzinf Mar 4, 2024
6401bc6
fix: Make max mint limit configurable in test Faucet contract
miguelmtzinf Mar 4, 2024
ad50c4b
fix: Fix tests
miguelmtzinf Mar 4, 2024
db3a099
Merge branch 'fix/faucet-max-limit' into fix/bump-dependencies
miguelmtzinf Mar 4, 2024
16be295
test: Fix tests with new faucet mintable contracts
miguelmtzinf Mar 4, 2024
414ca0c
chore: Bump package version
miguelmtzinf Mar 5, 2024
2a04537
fix: Add protection feature in TestERC20
miguelmtzinf Mar 5, 2024
2c81ddd
fix: Fix reserved keywork in contact and bump bersion
miguelmtzinf Mar 5, 2024
fef7dc4
chore: Bump version of v3-deploy
miguelmtzinf Mar 5, 2024
959a0c0
fix: revert changes of mock minting
miguelmtzinf Mar 5, 2024
2ab67c6
fix: Add protection feature in WETH9Mock and bump version
miguelmtzinf Mar 5, 2024
6e78cf3
fix: Bump version of v3 deploy
miguelmtzinf Mar 5, 2024
3380e6f
fix: Fix tests
miguelmtzinf Mar 5, 2024
7ca77fd
fix: Bump v3 deploy dependency version
miguelmtzinf Mar 6, 2024
c217d54
fix: Fix natspec docs of testnet contracts
miguelmtzinf Mar 6, 2024
8a87236
fix: Fix files of package
miguelmtzinf Mar 6, 2024
23166e4
fix: Move v3-core to dependecy instead of dev dep
miguelmtzinf Mar 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion contracts/mocks/WETH9Mock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,37 @@ import {WETH9} from '@aave/core-v3/contracts/dependencies/weth/WETH9.sol';
import {Ownable} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/Ownable.sol';

contract WETH9Mock is WETH9, Ownable {
bool internal _protected;

/**
* @dev Function modifier, if _protected is enabled then msg.sender is required to be the owner
*/
modifier onlyOwnerIfProtected() {
if (_protected == true) {
require(owner() == _msgSender(), 'Ownable: caller is not the owner');
}
_;
}

constructor(string memory mockName, string memory mockSymbol, address owner) {
name = mockName;
symbol = mockSymbol;

transferOwnership(owner);
_protected = true;
}

function mint(address account, uint256 value) public onlyOwner returns (bool) {
function mint(address account, uint256 value) public onlyOwnerIfProtected returns (bool) {
balanceOf[account] += value;
emit Transfer(address(0), account, value);
return true;
}

function setProtected(bool state) public onlyOwner {
_protected = state;
}

function isProtected() public view returns (bool) {
return _protected;
}
}
29 changes: 25 additions & 4 deletions contracts/mocks/testnet-helpers/Faucet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import {IFaucet} from './IFaucet.sol';
* @dev Ownable Faucet Contract
*/
contract Faucet is IFaucet, Ownable {
/// @inheritdoc IFaucet
uint256 public constant MAX_MINT_AMOUNT = 10000;
uint256 internal maximumMintAmount;

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

constructor(address owner, bool permissioned) {
constructor(address owner, bool permissioned, uint256 maxMinAmount) {
require(owner != address(0));
transferOwnership(owner);
_permissioned = permissioned;
maximumMintAmount = maxMinAmount;
}

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

Expand Down Expand Up @@ -81,4 +81,25 @@ contract Faucet is IFaucet, Ownable {
Ownable(childContracts[i]).transferOwnership(newOwner);
}
}

/// @inheritdoc IFaucet
function setProtectedOfChild(
address[] calldata childContracts,
bool state
) external override onlyOwner {
for (uint256 i = 0; i < childContracts.length; i++) {
TestnetERC20(childContracts[i]).setProtected(state);
}
}


/// @inheritdoc IFaucet
function setMaximumMintAmount(uint256 newMaxMintAmount) external override onlyOwner {
maximumMintAmount = newMaxMintAmount;
}

/// @inheritdoc IFaucet
function getMaximumMintAmount() external view override returns (uint256) {
return maximumMintAmount;
}
}
25 changes: 19 additions & 6 deletions contracts/mocks/testnet-helpers/IFaucet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
pragma solidity ^0.8.0;

interface IFaucet {
/**
* @notice Returns the maximum amount of tokens per mint allowed
* @return The maximum amount of tokens per mint allowed
*/
function MAX_MINT_AMOUNT() external pure returns (uint256);

/**
* @notice Function to mint Testnet tokens to the destination address
* @param token The address of the token to perform the mint
Expand Down Expand Up @@ -49,4 +43,23 @@ interface IFaucet {
* @param newOwner The address of the new owner
*/
function transferOwnershipOfChild(address[] calldata childContracts, address newOwner) external;

/**
* @notice Updates protection of minting feature of child token contracts
* @param childContracts A list of child token contract addresses
* @param state True if tokens are only mintable through Faucet, false otherwise
*/
function setProtectedOfChild(address[] calldata childContracts, bool state) external;

/**
* @notice Updates the maximum amount of tokens per mint allowed
* @param newMaxMintAmount The new value of maximum amount of tokens per mint (whole tokens)
*/
function setMaximumMintAmount(uint256 newMaxMintAmount) external;

/**
* @notice Returns the maximum amount of tokens per mint allowed
* @return The maximum amount of tokens per mint allowed (whole tokens)
*/
function getMaximumMintAmount() external view returns (uint256);
}
25 changes: 23 additions & 2 deletions contracts/mocks/testnet-helpers/TestnetERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ contract TestnetERC20 is IERC20WithPermit, ERC20, Ownable {

bytes32 public DOMAIN_SEPARATOR;

bool internal _protected;

/**
* @dev Function modifier, if _protected is enabled then msg.sender is required to be the owner
*/
modifier onlyOwnerIfProtected() {
if (_protected == true) {
require(owner() == _msgSender(), 'Ownable: caller is not the owner');
}
_;
}

constructor(
string memory name,
string memory symbol,
Expand All @@ -41,6 +53,7 @@ contract TestnetERC20 is IERC20WithPermit, ERC20, Ownable {
_setupDecimals(decimals);
require(owner != address(0));
transferOwnership(owner);
_protected = true;
}

/// @inheritdoc IERC20WithPermit
Expand Down Expand Up @@ -74,7 +87,7 @@ contract TestnetERC20 is IERC20WithPermit, ERC20, Ownable {
* @param value The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(uint256 value) public virtual onlyOwner returns (bool) {
function mint(uint256 value) public virtual onlyOwnerIfProtected returns (bool) {
_mint(_msgSender(), value);
return true;
}
Expand All @@ -85,12 +98,20 @@ contract TestnetERC20 is IERC20WithPermit, ERC20, Ownable {
* @param value The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address account, uint256 value) public virtual onlyOwner returns (bool) {
function mint(address account, uint256 value) public virtual onlyOwnerIfProtected returns (bool) {
_mint(account, value);
return true;
}

function nonces(address owner) public view returns (uint256) {
return _nonces[owner];
}

function setProtected(bool state) public onlyOwner {
_protected = state;
}

function isProtected() public view returns (bool) {
return _protected;
}
}
Loading
Loading