-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathPoolDeployer.sol
70 lines (56 loc) · 2.6 KB
/
PoolDeployer.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.14;
import { IPoolFactory } from '../interfaces/pool/IPoolFactory.sol';
/**
* @title Pool Deployer base contract
* @notice Base contract for Pool Deployer, contains logic used by both ERC20 and ERC721 Pool Factories.
*/
abstract contract PoolDeployer {
/// @dev Min interest rate value allowed for deploying the pool (1%)
uint256 public constant MIN_RATE = 0.01 * 1e18;
/// @dev Max interest rate value allowed for deploying the pool (10%
uint256 public constant MAX_RATE = 0.1 * 1e18;
/// @dev `Ajna` token address
address public ajna; // Ajna token contract address on a network.
/***********************/
/*** State Variables ***/
/***********************/
/// @dev SubsetHash => CollateralAddress => QuoteAddress => Pool Address mapping
// slither-disable-next-line uninitialized-state
mapping(bytes32 => mapping(address => mapping(address => address))) public deployedPools;
/// @notice List of all deployed pools. Separate list is maintained for each factory.
// slither-disable-next-line uninitialized-state
address[] public deployedPoolsList;
/*****************/
/*** Modifiers ***/
/*****************/
/**
* @notice Ensures that pools are deployed according to specifications.
* @dev Used by both `ERC20` and `ERC721` pool factories.
*/
modifier canDeploy(address collateral_, address quote_, uint256 interestRate_) {
if (collateral_ == quote_) revert IPoolFactory.DeployQuoteCollateralSameToken();
if (collateral_ == address(0) || quote_ == address(0)) revert IPoolFactory.DeployWithZeroAddress();
if (MIN_RATE > interestRate_ || interestRate_ > MAX_RATE) revert IPoolFactory.PoolInterestRateInvalid();
_;
}
/*******************************/
/*** External View Functions ***/
/*******************************/
/**
* @notice Returns the list of all deployed pools.
* @dev This function is used by integrations to access deployed pools.
* @dev Each factory implementation maintains its own list of deployed pools.
* @return List of all deployed pools.
*/
function getDeployedPoolsList() external view returns (address[] memory) {
return deployedPoolsList;
}
/**
* @notice Returns the number of deployed pools that have been deployed by a factory.
* @return Length of `deployedPoolsList` array.
*/
function getNumberOfDeployedPools() external view returns (uint256) {
return deployedPoolsList.length;
}
}