In both PoolFactory.sol
and LoanFactory.sol
we found the following properties.
contract PoolFactory is Pausable {
...
uint256 public poolsCreated; // Incrementor for number of Pools created
mapping(uint256 => address) public pools; // Map to keep `Pool` contract corresponds to its index.
mapping(address => bool) public isPool; // Used to check if a `Pool` was instantiated from this factory.
...
contract LoanFactory is Pausable {
...
uint256 public loansCreated; // Incrementor for number of loan vaults created.
mapping(uint256 => address) public loans; // Loans address mapping
mapping(address => bool) public isLoan; // Used to check if a Loan was instantiated from this contract
I feel both contracts could remove the mapping(uint256 => address)
field without impacting the contracts.
The only explanation I can find to having this mapping mapping(uint256 => address)
is because they want to be able to iterate over mapping to check the loans.
But in this case we could use an array instead of a mapping and we could remove the incrementor.
contract LoanFactory is Pausable {
...
Loan[] public loans;
mapping(address => bool) public isLoan; // Used to check if a Loan was instantiated from this contract
function loansCreated() public view returns (uint256) {
return loans.length;
}