Factory
Author: Aloe Labs, Inc.
"Test everything; hold fast what is good." - 1 Thessalonians 5:21
State Variables
GOVERNOR
The only address that can propose new MarketConfig
s and rewards programs
address public immutable GOVERNOR;
ORACLE
The oracle to use for prices and implied volatility
VolatilityOracle public immutable ORACLE;
LENDER_IMPLEMENTATION
The implementation to which all Lender
clones will point
address public immutable LENDER_IMPLEMENTATION;
_BORROWER_DEPLOYER
A simple contract that deploys Borrower
s to keep Factory
bytecode size down
BorrowerDeployer private immutable _BORROWER_DEPLOYER;
DEFAULT_RATE_MODEL
The rate model that Lender
s will use when first created
IRateModel public immutable DEFAULT_RATE_MODEL;
getMarket
Returns the Market
addresses associated with a Uniswap V3 pool
mapping(IUniswapV3Pool => Market) public getMarket;
getParameters
Returns the borrowing Parameters
associated with a Uniswap V3 pool
mapping(IUniswapV3Pool => Parameters) public getParameters;
peer
Returns the other Lender
in the Market
iff input is itself a Lender
, otherwise 0
mapping(address => address) public peer;
isBorrower
Returns whether the given address is a Borrower
deployed by this Factory
mapping(address => bool) public isBorrower;
rewardsToken
The token in which rewards are paid out
ERC20 public rewardsToken;
couriers
Returns the Courier
for any given ID
mapping(uint32 => Courier) public couriers;
Functions
constructor
constructor(
address governor,
address reserve,
VolatilityOracle oracle,
BorrowerDeployer borrowerDeployer,
IRateModel defaultRateModel
);
pause
function pause(IUniswapV3Pool pool, uint40 oracleSeed) external;
createMarket
function createMarket(IUniswapV3Pool pool) external;
createBorrower
function createBorrower(IUniswapV3Pool pool, address owner, bytes12 salt) external returns (Borrower borrower);
claimRewards
function claimRewards(Lender[] calldata lenders, address beneficiary) external returns (uint256 earned);
enrollCourier
Enrolls msg.sender
in the referral program. This allows frontends/wallets/apps to
credit themselves for a given user's deposit, and receive a portion of their interest. Note
that after enrolling, msg.sender
will not be eligible for REWARDS_TOKEN
rewards.
See Lender.creditCourier
function enrollCourier(uint32 id, uint16 cut) external;
Parameters
Name | Type | Description |
---|---|---|
id | uint32 | A unique identifier for the courier |
cut | uint16 | The portion of interest the courier will receive. Should be in the range [0, 10000), with 10000 being 100%. |
governRewardsToken
function governRewardsToken(ERC20 rewardsToken_) external;
governRewardsRate
function governRewardsRate(Lender lender, uint64 rate) external;
governMarketConfig
function governMarketConfig(IUniswapV3Pool pool, MarketConfig memory config) external;
_setMarketConfig
function _setMarketConfig(IUniswapV3Pool pool, MarketConfig memory config, uint32 pausedUntilTime) private;
_newBorrower
function _newBorrower(IUniswapV3Pool pool, Lender lender0, Lender lender1) private returns (Borrower);
Events
CreateMarket
event CreateMarket(IUniswapV3Pool indexed pool, Lender lender0, Lender lender1);
CreateBorrower
event CreateBorrower(IUniswapV3Pool indexed pool, address indexed owner, Borrower account);
EnrollCourier
event EnrollCourier(uint32 indexed id, address indexed wallet, uint16 cut);
SetMarketConfig
event SetMarketConfig(IUniswapV3Pool indexed pool, MarketConfig config);
Structs
Market
struct Market {
Lender lender0;
Lender lender1;
Borrower borrowerImplementation;
}
Parameters
struct Parameters {
uint208 ante;
uint8 nSigma;
uint8 manipulationThresholdDivisor;
uint32 pausedUntilTime;
}
MarketConfig
struct MarketConfig {
uint208 ante;
uint8 nSigma;
uint8 manipulationThresholdDivisor;
uint8 reserveFactor0;
uint8 reserveFactor1;
IRateModel rateModel0;
IRateModel rateModel1;
}
Courier
struct Courier {
address wallet;
uint16 cut;
}