View Source: contracts/CherryPool.sol
β Extends: Initializable β Derived Contracts: CherrySwap
CherryPool
This contract handle Cherry Pool functionalities
Constants & Variables
//public members
address public owner;
uint256 public poolBalance;
uint256 public poolcBalance;
uint256 public longPoolBalance;
uint256 public shortPoolBalance;
uint256 public longPoolReserved;
uint256 public shortPoolReserved;
int256 public poolcTokenProfit;
contract IERC20 public token;
contract ICERC20 public cToken;
contract CherryDai public cherryDai;
//internal members
contract CherryMath internal cherryMath;
Events
event DepositLiquidity(address indexed liquidityProvider, uint256 amount);
event MintCherry(address indexed liquidityProvider, uint256 amountDai, uint256 amountcDai, uint256 amountCherryDai);
event RedeemCherry(address indexed liquidityProvider, uint256 redeemedCherryDaiDaiAmount);
event TransferDai(address indexed to, uint256 value);
event CurrentExchangeRate(uint256 rate);
event PoolShare(uint256 amount);
event FreeLongPool(uint256 amount);
event FreeShortPool(uint256 amount);
event SetCherryDai(address cherryDai);
Modifier to check if long pool is not fully utilized
modifier isLongUtilized() internal
Arguments
Name | Type | Description |
---|
Modifier to check if short pool is not fully utilized
modifier isShortUtilized() internal
Arguments
Name | Type | Description |
---|
modifier canReserveLong(uint256 _amount) internal
Arguments
Name | Type | Description |
---|---|---|
_amount | uint256 |
modifier canReserveShort(uint256 _amount) internal
Arguments
Name | Type | Description |
---|---|---|
_amount | uint256 |
- initialize(address _token, address _cToken, address _cherryMath)
- mint(uint256 _amount)
- calcLongPoolUtil(uint256 _longPoolReserved)
- calcShortPoolUtil(uint256 _shortPoolReserved)
- cherryDaiBalanceOf(address _provider)
- redeem(uint256 _amount)
- getCashPrior()
- payout(address _redeemer, uint256 _redeemedDaiAmount, uint256 _redeemedCherryDaiTokens)
- exchangeRate()
- setToken(address _token)
- _reserveLongPool(uint256 _amount)
- _reserveShortPool(uint256 _amount)
- _freeLongPool(uint256 _amount)
- _freeShortPool(uint256 _amount)
- _addcTokenPoolProfit(int256 _profit)
- getcTokenExchangeRate()
β€Ώ Overridden Implementation(s): CherrySwap.initialize
Initialize contract states
function initialize(address _token, address _cToken, address _cherryMath) public nonpayable initializer
Arguments
Name | Type | Description |
---|---|---|
_token | address | |
_cToken | address | |
_cherryMath | address |
adds liquidity to the cherry pool to offer swaps against
function mint(uint256 _amount) external nonpayable
returns(uint256)
Returns
cherryDaiToMint amount of minted CherryDai
Arguments
Name | Type | Description |
---|---|---|
_amount | uint256 | amount of deposited DAI |
Get long pool utilization
function calcLongPoolUtil(uint256 _longPoolReserved) public view
returns(uint256)
Returns
current long pool utilization as a decimal scaled 10*18
Arguments
Name | Type | Description |
---|---|---|
_longPoolReserved | uint256 | amount of liquidity reserved in the long pool |
Get short pool utilization
function calcShortPoolUtil(uint256 _shortPoolReserved) public view
returns(uint256)
Returns
current short pool utilization as a decimal scaled 10*18
Arguments
Name | Type | Description |
---|---|---|
_shortPoolReserved | uint256 | amount of liquidity reserved in the short pool |
Get Cherrydai balance for liquidity provider
function cherryDaiBalanceOf(address _provider) public view
returns(uint256)
Returns
CherryDai balance
Arguments
Name | Type | Description |
---|---|---|
_provider | address | liquidity provider address |
the amount returned is the number of cherrytokens multiplied by the current exchange rate The sender should approve the _amount to this contract address
function redeem(uint256 _amount) external nonpayable isLongUtilized isShortUtilized
returns(uint256)
Returns
daiRedeemed amount of DAI redeemed
Arguments
Name | Type | Description |
---|---|---|
_amount | uint256 | amount of CherryDai to redeem |
Get available pool balance (total pool balance - total reserved balance)
function getCashPrior() internal nonpayable
returns(uint256)
Returns
available pool balance
Arguments
Name | Type | Description |
---|
Transfer the underlying asset
function payout(address _redeemer, uint256 _redeemedDaiAmount, uint256 _redeemedCherryDaiTokens) internal nonpayable
Arguments
Name | Type | Description |
---|---|---|
_redeemer | address | redeemer address |
_redeemedDaiAmount | uint256 | amount of DAI to transfer |
_redeemedCherryDaiTokens | uint256 | amount of CherryDAI to burn |
Each CherryDai is convertible into the underlying asset + the fees accrued through liquidity provision.
function exchangeRate() public nonpayable
returns(uint256)
Returns
rate Exchange rate
Arguments
Name | Type | Description |
---|
can only be called by the owner
function setToken(address _token) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
_token | address | CherryDai token address |
function _reserveLongPool(uint256 _amount) internal nonpayable canReserveLong
Arguments
Name | Type | Description |
---|---|---|
_amount | uint256 |
function _reserveShortPool(uint256 _amount) internal nonpayable canReserveShort
Arguments
Name | Type | Description |
---|---|---|
_amount | uint256 |
function _freeLongPool(uint256 _amount) internal nonpayable
Arguments
Name | Type | Description |
---|---|---|
_amount | uint256 |
function _freeShortPool(uint256 _amount) internal nonpayable
Arguments
Name | Type | Description |
---|---|---|
_amount | uint256 |
function _addcTokenPoolProfit(int256 _profit) internal nonpayable
Arguments
Name | Type | Description |
---|---|---|
_profit | int256 |
function getcTokenExchangeRate() public view
returns(uint256)
Arguments
Name | Type | Description |
---|