MoCSettlement
↗ Extends: MoCSettlementEvents, MoCBase, PartialExecution, Governed, IMoCSettlement ↘ Derived Contracts: MoCSettlementMock
MoCSettlement - version: 0.1.12
struct RedeemRequest {
address payable who,
uint256 amount
}
struct UserRedeemRequest {
uint256 index,
bool activeRedeemer
}
struct SettlementInfo {
uint256 btcPrice,
uint256 btcxPrice,
uint256 docRedeemCount,
uint256 deleveragingCount,
uint256 bproxAmount,
uint256 partialCommissionAmount,
uint256 finalCommissionAmount,
uint256 leverage,
uint256 startBlockNumber,
bool isProtectedMode
}
Constants & Variables
bytes32 public constant DOC_REDEMPTION_TASK;
bytes32 public constant DELEVERAGING_TASK;
bytes32 public constant SETTLEMENT_TASK;
contract IMoCState internal mocState;
contract IMoCExchange internal mocExchange;
contract DocToken internal docToken;
contract MoCBProxManager internal bproxManager;
uint256 internal lastProcessedBlock;
uint256 internal blockSpan;
struct MoCSettlement.SettlementInfo internal settlementInfo;
struct MoCSettlement.RedeemRequest[] private redeemQueue;
uint256 private redeemQueueLength;
mapping(address => struct MoCSettlement.UserRedeemRequest) private redeemMapping;
uint256[50] private upgradeGap;
Parameters
Name | Type | Description |
---|---|---|
redeemer | address | |
isAddition | bool | |
delta | uint256 | |
Parameters
Name | Type | Description |
---|---|---|
redeemer | address | |
commission | uint256 | |
amount | uint256 | |
Parameters
Name | Type | Description |
---|---|---|
queueSize | uint256 | |
accumCommissions | uint256 | |
reservePrice | uint256 | |
Parameters
Name | Type | Description |
---|---|---|
leverage | uint256 | |
riskProxPrice | uint256 | |
reservePrice | uint256 | |
startBlockNumber | uint256 | |
Parameters
Name | Type | Description |
---|---|---|
stableTokenRedeemCount | uint256 | |
deleveragingCount | uint256 | |
riskProxPrice | uint256 | |
reservePrice | uint256 | |
Parameters
Name | Type | Description |
---|---|---|
commissionsPayed | uint256 | |
Verify that the index is smaller than the length of the redeem request queue
modifier withinBoundaries(uint256 _index) internal
Arguments
Name | Type | Description |
---|---|---|
_index | uint256 | queue position to get |
modifier isTime() internal
Arguments
Initializes the contract
function initialize(address connectorAddress, address _governor, uint256 _blockSpan) public nonpayable initializer
Arguments
Name | Type | Description |
---|---|---|
connectorAddress | address | MoCConnector contract address |
_governor | address | Governor contract address |
_blockSpan | uint256 | Blockspan configuration blockspan of settlement |
Set the blockspan configuration blockspan of settlement
function setBlockSpan(uint256 bSpan) public nonpayable onlyAuthorizedChanger
Arguments
Name | Type | Description |
---|---|---|
bSpan | uint256 | |
Set Settlement to be kept in finnished state after all execution is completed.
function setSettlementToStall() public nonpayable onlyAuthorizedChanger
Arguments
Set Settlement state to Ready
function restartSettlementState() public nonpayable onlyAuthorizedChanger
Arguments
⤾ overrides IMoCSettlement.getRedeemRequestAt
Gets the RedeemRequest at the queue index position
function getRedeemRequestAt(uint256 _index) public view withinBoundaries
returns(address payable, uint256)
Returns
redeemer's address and amount he submitted
Arguments
Name | Type | Description |
---|---|---|
_index | uint256 | queue position to get |
Gets the number of blocks the settlemnet will be allowed to run
function getBlockSpan() public view
returns(uint256)
Arguments
⤾ overrides IMoCSettlement.redeemQueueSize
Returns the current redeem request queue's length
function redeemQueueSize() public view
returns(uint256)
Arguments
⤾ overrides IMoCSettlement.isSettlementEnabled
Returns true if blockSpan number of blocks has pass since last execution
function isSettlementEnabled() public view
returns(bool)
Arguments
Returns true if the settlment is running
function isSettlementRunning() public view
returns(bool)
Arguments
⤾ overrides IMoCSettlement.isSettlementReady
Returns true if the settlment is ready
function isSettlementReady() public view
returns(bool)
Arguments
⤾ overrides IMoCSettlement.nextSettlementBlock
Returns the next block from which settlement is possible
function nextSettlementBlock() public view
returns(uint256)
Arguments
⤾ overrides IMoCSettlement.docAmountToRedeem
returns the total amount of Docs in the redeem queue for _who
function docAmountToRedeem(address _who) public view
returns(uint256)
Returns
total amount of Docs in the redeem queue for _who [using mocPrecision]
Arguments
Name | Type | Description |
---|---|---|
_who | address | address for which ^ is computed |
⤾ overrides IMoCSettlement.addRedeemRequest
push a new redeem request to the queue for the sender or updates the amount if the user has a redeem request
function addRedeemRequest(uint256 amount, address payable redeemer) public nonpayable onlyWhitelisted
Arguments
Name | Type | Description |
---|---|---|
amount | uint256 | amount he is willing to redeem [using mocPrecision] |
redeemer | address payable | redeemer address |
empty the queue
function clear() public nonpayable onlyWhitelisted
Arguments
⤾ overrides IMoCSettlement.alterRedeemRequestAmount
Alters the redeem amount position for the redeemer
function alterRedeemRequestAmount(bool isAddition, uint256 delta, address redeemer) public nonpayable onlyWhitelisted
Returns
the filled amount [using mocPrecision]
Arguments
Name | Type | Description |
---|---|---|
isAddition | bool | true if adding amount to redeem, false to substract. |
delta | uint256 | the amount to add/substract to current position [using mocPrecision] |
redeemer | address | address to alter amount for |
⤾ overrides IMoCSettlement.runSettlement
Runs settlement process in steps
function runSettlement(uint256 steps) public nonpayable onlyWhitelisted isTime
returns(uint256)
Returns
The commissions collected in the executed steps
Arguments
Name | Type | Description |
---|---|---|
steps | uint256 | Amount of steps to run |
Create Task structures for Settlement execution
function fixTasksPointer() public nonpayable
Arguments
function initializeContracts() internal nonpayable
Arguments
function initializeValues(address _governor, uint256 _blockSpan) internal nonpayable
Arguments
Name | Type | Description |
---|---|---|
_governor | address | |
_blockSpan | uint256 | |
Returns the amount of steps for the Deleveraging task which is the amount of active BProx addresses
function deleveragingStepCount() internal view
returns(uint256)
Arguments
Returns the amount of steps for the Doc Redemption task which is the amount of redeem requests in the queue
function docRedemptionStepCount() internal view
returns(uint256)
Arguments
Freezes state for Settlement execution
function initializeSettlement() internal nonpayable
Arguments
Execute final step of Settlement task group
function finishSettlement() internal nonpayable
Arguments
Execute final step of Deleveraging task
function finishDeleveraging() internal nonpayable
Arguments
Execute final step of DocRedemption task
function finishDocRedemption() internal nonpayable
Arguments
Individual Deleveraging step to be executed in partial execution uint256 parameter needed for PartialExecution
function deleveragingStep(uint256 ) internal nonpayable
Arguments
Name | Type | Description |
---|---|---|
| uint256 | |
Individual DocRedemption step to be executed in partial execution
function docRedemptionStep(uint256 index) internal nonpayable
Arguments
Name | Type | Description |
---|---|---|
index | uint256 | Step number currently in execution |
Create Task structures for Settlement execution
function initializeTasks() internal nonpayable
Arguments
Last modified 1yr ago