Main Contract
Search…
MoC
    Referenced by: MoCSettlement
    References/uses: SafeMath, MoCLibConnection, DocToken, BProToken, PriceProvider, MoCBProxManager, MoCState, MoCConverter, MoCSettlement, MoCExchange, base/MoCBase
    Inherits from: MoCEvents, MoCLibConnection, MoCBase, Stoppable
    MoC is the main contract of the MoC ecosystem, it's the entry point of almost every public interaction with it and it articulates the main logic and relations between the rest of the contracts. It is also the only one that receives RBTC and holds the actual value of the system. The only methods marked as payable belongs to this contract and corresponds with the actual two ways of adding "value" to the system minting BitPro and DoC: - function mintBProVendors() public payable transitionState() { ... } - function mintDocVendors() public payable transitionState() atLeastState(MoCState.States.AboveCobj) { ... } You'll also notice that many of it's methods just "redirects" to a more specif contract, abstracting it from the msg.sender and msg.value; for example:
1
/**
2
* @dev Creates or updates the amount of a Doc redeem Request from the msg.sender
3
* @param docAmount Amount of Docs to redeem on settlement [using dollarPrecision]
4
*/
5
function redeemDocRequest(uint256 docAmount) public {
6
settlement.addRedeemRequest(docAmount, msg.sender);
7
}
Copied!
MoC also handles the System states by a series of modifiers:
    atState: requires certain state to allow execution
1
modifier atState(MoCState.States _state) {
2
require(mocState.state() == _state, "Function cannot be called at this state.");
3
_;
4
}
Copied!
    atLeastState: as states have a progressive order, we can require certain state or higher (where higher indicates a healthier system state)
1
modifier atLeastState(MoCState.States _state) {
2
require(mocState.state() >= _state, "Function cannot be called at this state.");
3
_;
4
}
Copied!
    notInProtectionMode: system can enter in protection mode when coverage is below protected threshold, thus preventing the execution of operations which make use of this modifier
1
modifier notInProtectionMode() {
2
require(mocState.globalCoverage() > mocState.getProtected(), "Function cannot be called at protection mode.");
3
_;
4
}
Copied!
    bucketStateTransition: Any method that can potentially modify a bucket values is require to first verify if current conditions doesn't demand that bucket liquidation. This is currently used while minting/redeeming Leveraged instruments (BProX).
1
modifier bucketStateTransition(string bucket) {
2
evalBucketLiquidation(bucket);
3
_;
4
}
Copied!
    transitionState: As liquidation (as a way to maintain the USD PEG) is a fundamental commitment of the system, we want to ensure that no operation could ever be done without triggering it if the conditions are met. This is why every method that may change the system inner state, is annotated with this modifier.
1
modifier transitionState()
2
{
3
mocState.nextState();
4
if (mocState.state() == MoCState.States.Liquidated)
5
liquidation();
6
else
7
_;
8
}
Copied!
Last modified 3mo ago
Copy link