Skip to main content

OriginationPool

Git Source

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

NameTypeDescription
namePrefixstringThe prefix for the name of the pool
symbolPrefixstringThe prefix for the symbol of the pool
epochuint256The epoch of the pool
consol_addressThe address of the consol contract
usdx_addressThe address of the USDX token
deployPhaseTimestamp_uint256The timestamp of the deploy phase
redemptionPhaseTimestamp_uint256The timestamp of the redemption phase
poolLimit_uint256The pool limit
poolMultiplierBps_uint16The 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

NameTypeDescription
phaseOriginationPoolPhaseThe 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

NameTypeDescription
pauseboolThe new paused state

currentPhase

Fetches the current phase of the Origination Pool

function currentPhase() public view override returns (OriginationPoolPhase);

Returns

NameTypeDescription
<none>OriginationPoolPhaseThe 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

NameTypeDescription
amountuint256The amount of USDX to calculate the return amount for

Returns

NameTypeDescription
returnAmountuint256The return amount of Consol

deposit

Deposit USDX into the pool

function deposit(uint256 amount)
external
override
whenNotPaused
onlyPhase(OriginationPoolPhase.DEPOSIT)
returns (uint256);

Parameters

NameTypeDescription
amountuint256The amount of USDX to deposit

Returns

NameTypeDescription
<none>uint256mintAmount 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

NameTypeDescription
amountuint256The amount of USDX to deploy
databytesThe 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

NameTypeDescription
amountuint256The amount of receipt tokens to burn in exchange for USDX + Consol