MoCState
View Source: contracts/MoCState.sol
↗ Extends: MoCLibConnection, MoCBase, MoCEMACalculator, IMoCState ↘ Derived Contracts: MoCStateMock
MoCState - version: 0.1.10
Structs
InitializeParams
struct InitializeParams {
address connectorAddress,
address governor,
address priceProvider,
uint256 liq,
uint256 utpdu,
uint256 maxDiscRate,
uint256 dayBlockSpan,
uint256 ema,
uint256 smoothFactor,
uint256 emaBlockSpan,
uint256 maxMintRiskPro,
address mocPriceProvider,
address mocTokenAddress,
address mocVendorsAddress,
bool liquidationEnabled,
uint256 protected
}
Contract Members
Constants & Variables
enum IMoCState.States public state;
uint256 public dayBlockSpan;
uint256 public peg;
uint256 public riskProMaxDiscountRate;
uint256 public liq;
uint256 public utpdu;
uint256 public reserves;
uint256 public liquidationPrice;
uint256 public maxMintRiskPro;
bool public liquidationEnabled;
uint256 public protected;
contract PriceProvider internal priceProvider;
contract IMoCSettlement internal mocSettlement;
address internal DEPRECATED_mocConverter;
contract IERC20 internal stableToken;
contract RiskProToken internal riskProToken;
contract MoCRiskProxManager internal riskProxManager;
contract PriceProvider internal mocPriceProvider;
contract MoCToken internal mocToken;
address internal mocVendors;
uint256[50] private upgradeGap;
StateTransition
Parameters
newState
enum IMoCState.States
PriceProviderUpdated
Parameters
oldAddress
address
newAddress
address
MoCPriceProviderUpdated
Parameters
oldAddress
address
newAddress
address
MoCTokenChanged
Parameters
mocTokenAddress
address
MoCVendorsChanged
Parameters
mocVendorsAddress
address
Functions
initialize
⤿ Overridden Implementation(s): MoCStateMock.initialize
Initializes the contract
function initialize(struct MoCState.InitializeParams params) public nonpayable initializer
Arguments
params
struct MoCState.InitializeParams
Params defined in InitializeParams struct
setMaxDiscountRate
Sets the max discount rate.
function setMaxDiscountRate(uint256 rate) public nonpayable onlyAuthorizedChanger
Arguments
rate
uint256
Discount rate at liquidation level [using mocPrecision]
getMaxDiscountRate
return the value of the RiskPro max discount rate configuration param
function getMaxDiscountRate() public view
returns(uint256)
Returns
riskProMaxDiscountRate RiskPro max discount rate
Arguments
setDayBlockSpan
Defines how many blocks there are in a day
function setDayBlockSpan(uint256 blockSpan) public nonpayable onlyAuthorizedChanger
Arguments
blockSpan
uint256
blocks there are in a day
setPriceProvider
Sets a new PriceProvider contract
function setPriceProvider(address priceProviderAddress) public nonpayable onlyAuthorizedChanger
Arguments
priceProviderAddress
address
address of the price provider contract
getPriceProvider
Gets the PriceProviderAddress
function getPriceProvider() public view
returns(address)
Returns
address of the price provider contract
Arguments
getDayBlockSpan
Gets how many blocks there are in a day
function getDayBlockSpan() public view
returns(uint256)
Returns
blocks there are in a day
Arguments
substractFromReserves
⤾ overrides IMoCState.substractFromReserves
Subtract the reserve amount passed by parameter to the reserves total
function substractFromReserves(uint256 amount) public nonpayable onlyWhitelisted
Arguments
amount
uint256
Amount that will be subtract to reserves
addToReserves
⤾ overrides IMoCState.addToReserves
Add the reserve amount passed by parameter to the reserves total
function addToReserves(uint256 amount) public nonpayable onlyWhitelisted
Arguments
amount
uint256
Amount that will be added to reserves
riskProTotalSupply
All RiskPros in circulation
function riskProTotalSupply() public view
returns(uint256)
Arguments
stableTokenTotalSupply
All stableTokens in circulation
function stableTokenTotalSupply() public view
returns(uint256)
Arguments
cobj
Target coverage for complete system
function cobj() public view
returns(uint256)
Arguments
collateralReserves
Amount of ReserveTokens in the system excluding RiskProx values and interests holdings
function collateralReserves() public view
returns(uint256)
Arguments
globalCoverage
⤾ overrides IMoCState.globalCoverage
GLOBAL Coverage
function globalCoverage() public view
returns(uint256)
Returns
coverage [using mocPrecision].
Arguments
lockedReserveTokens
BUCKET lockedReserveTokens
function lockedReserveTokens(bytes32 bucket) public view
returns(uint256)
Returns
lockedReserveTokens amount [using reservePrecision].
Arguments
bucket
bytes32
Name of the bucket used
getResTokensInRiskPro
Gets ReserveTokens in RiskPro within specified bucket
function getResTokensInRiskPro(bytes32 bucket) public view
returns(uint256)
Returns
ReserveToken amount of RiskPro in Bucket [using reservePrecision].
Arguments
bucket
bytes32
Name of the bucket used
getReservesRemainder
⤾ overrides IMoCState.getReservesRemainder
Gets the ReserveTokens in the contract that not corresponds to StableToken collateral
function getReservesRemainder() public view
returns(uint256)
Returns
ReserveTokens remainder [using reservePrecision].
Arguments
coverage
⤾ overrides IMoCState.coverage
BUCKET Coverage
function coverage(bytes32 bucket) public view
returns(uint256)
Returns
coverage [using mocPrecision]
Arguments
bucket
bytes32
Name of the bucket used
abundanceRatio
⤾ overrides IMoCState.abundanceRatio
Abundance ratio, receives tha amount of stableToken to use the value of stableToken0 and StableToken total supply
function abundanceRatio(uint256 stableToken0) public view
returns(uint256)
Returns
abundance ratio [using mocPrecision]
Arguments
stableToken0
uint256
currentAbundanceRatio
⤾ overrides IMoCState.currentAbundanceRatio
Relation between stableTokens in bucket 0 and StableToken total supply
function currentAbundanceRatio() public view
returns(uint256)
Returns
abundance ratio [using mocPrecision]
Arguments
leverage
⤾ overrides IMoCState.leverage
BUCKET Leverage
function leverage(bytes32 bucket) public view
returns(uint256)
Returns
leverage [using mocPrecision]
Arguments
bucket
bytes32
Name of the bucket used
globalMaxStableToken
GLOBAL maxStableToken
function globalMaxStableToken() public view
returns(uint256)
Returns
maxStableToken to issue [using mocPrecision]
Arguments
freeStableToken
⤾ overrides IMoCState.freeStableToken
Returns the amount of stableTokens in bucket 0, that can be redeemed outside of settlement
function freeStableToken() public view
returns(uint256)
Returns
amount of stableTokens in bucket 0, that can be redeemed outside of settlement [using mocPrecision]
Arguments
maxStableToken
BUCKET maxStableToken
function maxStableToken(bytes32 bucket) public view
returns(uint256)
Returns
maxStableToken to issue [using mocPrecision]
Arguments
bucket
bytes32
globalMaxRiskPro
GLOBAL maxRiskPro
function globalMaxRiskPro() public view
returns(uint256)
Returns
maxRiskPro for redeem [using mocPrecision].
Arguments
absoluteMaxStableToken
⤾ overrides IMoCState.absoluteMaxStableToken
ABSOLUTE maxStableToken
function absoluteMaxStableToken() public view
returns(uint256)
Returns
maxStableToken to issue [using mocPrecision]
Arguments
maxRiskPro
BUCKET maxRiskPro to redeem / mint
function maxRiskPro(bytes32 bucket) public view
returns(uint256)
Returns
maxRiskPro for redeem [using mocPrecision].
Arguments
bucket
bytes32
Name of the bucket used
maxRiskProx
âš This has been deprecated since the Proposal to remove leveraged positions from the protocol was approved, however it is necessary to maintain the contracts and their documentation for legacy support.
GLOBAL max riskProx to mint
function maxRiskProx(bytes32 bucket) public view
returns(uint256)
Returns
maxRiskProx [using mocPrecision]
Arguments
bucket
bytes32
Name of the bucket used
maxRiskProxResTokenValue
âš This has been deprecated since the Proposal to remove leveraged positions from the protocol was approved, however it is necessary to maintain the contracts and their documentation for legacy support.
⤾ overrides IMoCState.maxRiskProxResTokenValue
GLOBAL max riskProx to mint
function maxRiskProxResTokenValue(bytes32 bucket) public view
returns(uint256)
Returns
maxRiskProx ReserveTokens value to mint [using reservePrecision]
Arguments
bucket
bytes32
Name of the bucket used
absoluteMaxRiskPro
⤾ overrides IMoCState.absoluteMaxRiskPro
ABSOLUTE maxRiskPro
function absoluteMaxRiskPro() public view
returns(uint256)
Returns
maxStableToken to issue [using mocPrecision].
Arguments
maxRiskProWithDiscount
⤾ overrides IMoCState.maxRiskProWithDiscount
DISCOUNT maxRiskPro
function maxRiskProWithDiscount() public view
returns(uint256)
Returns
maxRiskPro for mint with discount [using mocPrecision]
Arguments
globalLockedReserveTokens
GLOBAL lockedReserveTokens
function globalLockedReserveTokens() public view
returns(uint256)
Returns
lockedReserveTokens amount [using reservePrecision].
Arguments
riskProTecPrice
⤾ overrides IMoCState.riskProTecPrice
ReserveTokens price of RiskPro
function riskProTecPrice() public view
returns(uint256)
Returns
the RiskPro Tec Price [using reservePrecision].
Arguments
bucketRiskProTecPrice
⤾ overrides IMoCState.bucketRiskProTecPrice
BUCKET ReserveTokens price of RiskPro
function bucketRiskProTecPrice(bytes32 bucket) public view
returns(uint256)
Returns
the RiskPro Tec Price [using reservePrecision]
Arguments
bucket
bytes32
Name of the bucket used
bucketRiskProTecPriceHelper
⤾ overrides IMoCState.bucketRiskProTecPriceHelper
BUCKET ReserveTokens price of RiskPro (helper)
function bucketRiskProTecPriceHelper(bytes32 bucket) public view
returns(uint256)
Returns
the RiskPro Tec Price [using reservePrecision]
Arguments
bucket
bytes32
Name of the bucket used
riskProDiscountPrice
⤾ overrides IMoCState.riskProDiscountPrice
ReserveTokens price of RiskPro with spot discount applied
function riskProDiscountPrice() public view
returns(uint256)
Returns
the RiskPro Tec Price [using reservePrecision].
Arguments
riskProUsdPrice
RiskPro USD PRICE
function riskProUsdPrice() public view
returns(uint256)
Returns
the RiskPro USD Price [using mocPrecision]
Arguments
maxRiskProxRiskProValue
âš This has been deprecated since the Proposal to remove leveraged positions from the protocol was approved, however it is necessary to maintain the contracts and their documentation for legacy support.
GLOBAL max riskProx to mint
function maxRiskProxRiskProValue(bytes32 bucket) public view
returns(uint256)
Returns
max RiskPro allowed to be spent to mint RiskProx [using reservePrecision]
Arguments
bucket
bytes32
Name of the bucket used
riskProxRiskProPrice
âš This has been deprecated since the Proposal to remove leveraged positions from the protocol was approved, however it is necessary to maintain the contracts and their documentation for legacy support.
BUCKET RiskProx price in RiskPro
function riskProxRiskProPrice(bytes32 bucket) public view
returns(uint256)
Returns
RiskPro RiskPro Price [[using mocPrecision]Precision].
Arguments
bucket
bytes32
Name of the bucket used
riskProSpotDiscountRate
⤾ overrides IMoCState.riskProSpotDiscountRate
GLOBAL ReserveTokens Discount rate to apply to RiskProPrice.
function riskProSpotDiscountRate() public view
returns(uint256)
Returns
RiskPro discount rate [using DISCOUNT_PRECISION].
Arguments
daysToSettlement
⤾ overrides IMoCState.daysToSettlement
⤿ Overridden Implementation(s): MoCStateMock.daysToSettlement
Calculates the number of days to next settlement based dayBlockSpan
function daysToSettlement() public view
returns(uint256)
Returns
days to next settlement
Arguments
blocksToSettlement
Number of blocks to settlement
function blocksToSettlement() public view
returns(uint256)
Returns
Number of blocks to settlement
Arguments
isLiquidationReached
Verifies if forced liquidation is reached checking if globalCoverage <= liquidation (currently 1.04) and if liquidation is enabled
function isLiquidationReached() public view
returns(bool)
Returns
true if liquidation state is reached, false otherwise
Arguments
getLiquidationPrice
⤾ overrides IMoCState.getLiquidationPrice
Returns the price to use for stableToken redeem in a liquidation event
function getLiquidationPrice() public view
returns(uint256)
Returns
price to use for stableToken redeem in a liquidation event
Arguments
getBucketNReserve
⤾ overrides IMoCState.getBucketNReserve
function getBucketNReserve(bytes32 bucket) public view
returns(uint256)
Arguments
bucket
bytes32
getBucketNRiskPro
function getBucketNRiskPro(bytes32 bucket) public view
returns(uint256)
Arguments
bucket
bytes32
getBucketNStableToken
function getBucketNStableToken(bytes32 bucket) public view
returns(uint256)
Arguments
bucket
bytes32
getBucketCobj
function getBucketCobj(bytes32 bucket) public view
returns(uint256)
Arguments
bucket
bytes32
getInrateBag
function getInrateBag(bytes32 bucket) public view
returns(uint256)
Arguments
bucket
bytes32
getBcons
function getBcons() public view
returns(uint256)
Arguments
getReserveTokenPrice
⤾ overrides IMoCState.getReserveTokenPrice
function getReserveTokenPrice() public view
returns(uint256)
Arguments
calculateReserveTokenMovingAverage
function calculateReserveTokenMovingAverage() public nonpayable
Arguments
getLiq
return the value of the liq threshold configuration param
function getLiq() public view
returns(uint256)
Returns
liq threshold, currently 1.04
Arguments
setLiq
sets the value of the liq threshold configuration param
function setLiq(uint256 _liq) public nonpayable onlyAuthorizedChanger
Arguments
_liq
uint256
liquidation threshold
getUtpdu
return the value of the utpdu threshold configuration param
function getUtpdu() public view
returns(uint256)
Returns
utpdu Universal TPro discount sales coverage threshold
Arguments
setUtpdu
sets the value of the utpdu threshold configuration param
function setUtpdu(uint256 _utpdu) public nonpayable onlyAuthorizedChanger
Arguments
_utpdu
uint256
Universal TPro discount sales coverage threshold
getPeg
returns the relation between StableToken and dollar. By default it is 1.
function getPeg() public view
returns(uint256)
Returns
peg relation between StableToken and dollar
Arguments
setPeg
sets the relation between StableToken and dollar. By default it is 1.
function setPeg(uint256 _peg) public nonpayable onlyAuthorizedChanger
Arguments
_peg
uint256
relation between StableToken and dollar
getProtected
⤾ overrides IMoCState.getProtected
return the value of the protected threshold configuration param
function getProtected() public view
returns(uint256)
Returns
protected threshold, currently 1.5
Arguments
setProtected
sets the value of the protected threshold configuration param
function setProtected(uint256 _protected) public nonpayable onlyAuthorizedChanger
Arguments
_protected
uint256
protected threshold
getLiquidationEnabled
returns if is liquidation enabled.
function getLiquidationEnabled() public view
returns(bool)
Returns
liquidationEnabled is liquidation enabled
Arguments
setLiquidationEnabled
returns if is liquidation enabled.
function setLiquidationEnabled(bool _liquidationEnabled) public nonpayable onlyAuthorizedChanger
Arguments
_liquidationEnabled
bool
is liquidation enabled
nextState
⤾ overrides IMoCState.nextState
Transitions to next state.
function nextState() public nonpayable
Arguments
setMaxMintRiskPro
Sets max mint RiskPro value
function setMaxMintRiskPro(uint256 _maxMintRiskPro) public nonpayable onlyAuthorizedChanger
Arguments
_maxMintRiskPro
uint256
[using mocPrecision]
getMaxMintRiskPro
return Max value posible to mint of RiskPro
function getMaxMintRiskPro() public view
returns(uint256)
Returns
maxMintRiskPro
Arguments
setMoCPriceProvider
Sets a new MoCProvider contract
function setMoCPriceProvider(address mocProviderAddress) public nonpayable onlyAuthorizedChanger
Arguments
mocProviderAddress
address
MoC price provider address
getMoCPriceProvider
Gets the MoCPriceProviderAddress
function getMoCPriceProvider() public view
returns(address)
Returns
MoC price provider address
Arguments
getMoCPrice
⤾ overrides IMoCState.getMoCPrice
Gets the MoCPrice
function getMoCPrice() public view
returns(uint256)
Returns
MoC price
Arguments
setMoCToken
Sets the MoC token contract address
function setMoCToken(address mocTokenAddress) public nonpayable onlyAuthorizedChanger
Arguments
mocTokenAddress
address
MoC token contract address
getMoCToken
⤾ overrides IMoCState.getMoCToken
Gets the MoC token contract address
function getMoCToken() public view
returns(address)
Returns
MoC token contract address
Arguments
setMoCVendors
Sets the MoCVendors contract address
function setMoCVendors(address mocVendorsAddress) public nonpayable onlyAuthorizedChanger
Arguments
mocVendorsAddress
address
MoCVendors contract address
getMoCVendors
⤾ overrides IMoCState.getMoCVendors
Gets the MoCVendors contract addfress
function getMoCVendors() public view
returns(address)
Returns
MoCVendors contract address
Arguments
stableTokensToResToken
⤾ overrides IMoCState.stableTokensToResToken
function stableTokensToResToken(uint256 stableTokenAmount) public view
returns(uint256)
Arguments
stableTokenAmount
uint256
resTokenToStableToken
⤾ overrides IMoCState.resTokenToStableToken
function resTokenToStableToken(uint256 resTokensAmount) public view
returns(uint256)
Arguments
resTokensAmount
uint256
riskProxToResToken
âš This has been deprecated since the Proposal to remove leveraged positions from the protocol was approved, however it is necessary to maintain the contracts and their documentation for legacy support.
⤾ overrides IMoCState.riskProxToResToken
function riskProxToResToken(uint256 riskProxAmount, bytes32 bucket) public view
returns(uint256)
Arguments
riskProxAmount
uint256
bucket
bytes32
riskProxToResTokenHelper
âš This has been deprecated since the Proposal to remove leveraged positions from the protocol was approved, however it is necessary to maintain the contracts and their documentation for legacy support.
function riskProxToResTokenHelper(uint256 riskProxAmount, bytes32 bucket) public view
returns(uint256)
Arguments
riskProxAmount
uint256
bucket
bytes32
resTokenToRiskProx
âš This has been deprecated since the Proposal to remove leveraged positions from the protocol was approved, however it is necessary to maintain the contracts and their documentation for legacy support.
⤾ overrides IMoCState.resTokenToRiskProx
function resTokenToRiskProx(uint256 resTokensAmount, bytes32 bucket) public view
returns(uint256)
Arguments
resTokensAmount
uint256
bucket
bytes32
setMoCTokenInternal
Sets the MoC token contract address (internal function)
function setMoCTokenInternal(address mocTokenAddress) internal nonpayable
Arguments
mocTokenAddress
address
MoC token contract address
setMoCVendorsInternal
Sets the MoCVendors contract address (internal function)
function setMoCVendorsInternal(address mocVendorsAddress) internal nonpayable
Arguments
mocVendorsAddress
address
MoCVendors contract address
setLiquidationPrice
Calculates price at liquidation event as the relation between the stableToken total supply and the amount of ReserveTokens available to distribute
function setLiquidationPrice() internal nonpayable
Arguments
initializeValues
function initializeValues(address _governor, address _priceProvider, uint256 _liq, uint256 _utpdu, uint256 _maxDiscRate, uint256 _dayBlockSpan, uint256 _maxMintRiskPro, address _mocPriceProvider, bool _liquidationEnabled, uint256 _protected) internal nonpayable
Arguments
_governor
address
_priceProvider
address
_liq
uint256
_utpdu
uint256
_maxDiscRate
uint256
_dayBlockSpan
uint256
_maxMintRiskPro
uint256
_mocPriceProvider
address
_liquidationEnabled
bool
_protected
uint256
initializeContracts
function initializeContracts(address _mocTokenAddress, address _mocVendorsAddress) internal nonpayable
Arguments
_mocTokenAddress
address
_mocVendorsAddress
address
Last updated