OriginationPool
Inherits: IOriginationPool, ERC165, AccessControl, ERC20, ReentrancyGuard
Title: The OriginationPool contract
Author: SocksNFlops
The OriginationPool allows lending USDX to be used for origination of mortgage positions, earning yield in the form of Consol.
In order to minimize smart contract risk, we are hedging towards immutability.
State Variables
consol
The Consol token address
address public immutable consol
usdx
The USDX token address
address public immutable usdx
depositPhaseTimestamp
The deposit phase timestamp
uint256 public immutable depositPhaseTimestamp
deployPhaseTimestamp
The deploy phase timestamp
uint256 public immutable deployPhaseTimestamp
redemptionPhaseTimestamp
The redemption phase timestamp
uint256 public immutable redemptionPhaseTimestamp
poolLimit
Fetches the pool deposit limit
uint256 public immutable poolLimit
poolMultiplierBps
Fetches the pool multiplier in basis points
uint16 public immutable poolMultiplierBps
amountDeployed
Fetches the amount of USD tokens deployed from the pool
uint256 public amountDeployed
paused
Get the paused state of the contract
bool public paused
Functions
constructor
Constructor
constructor(
string memory namePrefix,
string memory symbolPrefix,
uint256 epoch,
address consol_,
address usdx_,
uint256 deployPhaseTimestamp_,
uint256 redemptionPhaseTimestamp_,
uint256 poolLimit_,
uint16 poolMultiplierBps_
) ERC20(string.concat(namePrefix, " - ", epoch.toString()), string.concat(symbolPrefix, "-", epoch.toString()));
Parameters
| Name | Type | Description |
|---|---|---|
namePrefix | string | The prefix for the name of the pool |
symbolPrefix | string | The prefix for the symbol of the pool |
epoch | uint256 | The epoch of the pool |
consol_ | address | The address of the consol contract |
usdx_ | address | The address of the USDX token |
deployPhaseTimestamp_ | uint256 | The timestamp of the deploy phase |
redemptionPhaseTimestamp_ | uint256 | The timestamp of the redemption phase |
poolLimit_ | uint256 | The pool limit |
poolMultiplierBps_ | uint16 | The pool multiplier in basis points |
whenNotPaused
Modifier to check if the contract is paused
modifier whenNotPaused() ;
onlyPhase
Modifier to check if the current phase is the given phase
modifier onlyPhase(OriginationPoolPhase phase) ;
Parameters
| Name | Type | Description |
|---|---|---|
phase | OriginationPoolPhase | The phase to check |
supportsInterface
function supportsInterface(bytes4 interfaceId) public view override(AccessControl, ERC165) returns (bool);
setPaused
Pause or unpause the contract
function setPaused(bool pause) external override onlyRole(Roles.PAUSE_ROLE);
Parameters
| Name | Type | Description |
|---|---|---|
pause | bool | The new paused state |
currentPhase
Fetches the current phase of the Origination Pool
function currentPhase() public view override returns (OriginationPoolPhase);
Returns
| Name | Type | Description |
|---|---|---|
<none> | OriginationPoolPhase | The current phase |
calculateReturnAmount
Calculates the return amount of Consol for a given amount of USDX by applying the pool multiplier
function calculateReturnAmount(uint256 amount) public view override returns (uint256 returnAmount);
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of USDX to calculate the return amount for |
Returns
| Name | Type | Description |
|---|---|---|
returnAmount | uint256 | The return amount of Consol |
deposit
Deposit USDX into the pool
function deposit(uint256 amount)
external
override
whenNotPaused
onlyPhase(OriginationPoolPhase.DEPOSIT)
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of USDX to deposit |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | mintAmount The amount of receipt tokens minted to the user |
deploy
Deploy USDX in the pool and convert it to Consol. Only callable by contracts implementing IOriginationPoolDeployCallback
function deploy(uint256 amount, bytes calldata data)
external
override
whenNotPaused
onlyPhase(OriginationPoolPhase.DEPLOY)
onlyRole(Roles.DEPLOY_ROLE)
nonReentrant;
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of USDX to deploy |
data | bytes | The calldata to pass into the callback |
redeem
Redeem USDX + Consol from the pool from receipt tokens
function redeem(uint256 amount) external override onlyPhase(OriginationPoolPhase.REDEMPTION);
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of receipt tokens to burn in exchange for USDX + Consol |