MoCSettlement

View Source: contracts/MoCSettlement.sol

↗ Extends: MoCSettlementEvents, MoCBase, PartialExecution, Governed, IMoCSettlement ↘ Derived Contracts: MoCSettlementMock

MoCSettlement - version: 0.1.12

Structs

RedeemRequest

struct RedeemRequest {
 address payable who,
 uint256 amount
}

UserRedeemRequest

struct UserRedeemRequest {
 uint256 index,
 bool activeRedeemer
}

SettlementInfo

struct SettlementInfo {
 uint256 btcPrice,
 uint256 btcxPrice,
 uint256 docRedeemCount,
 uint256 deleveragingCount,
 uint256 bproxAmount,
 uint256 partialCommissionAmount,
 uint256 finalCommissionAmount,
 uint256 leverage,
 uint256 startBlockNumber,
 bool isProtectedMode
}

Contract Members

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;

RedeemRequestAlter

Parameters

Name
Type
Description

redeemer

address

isAddition

bool

delta

uint256

RedeemRequestProcessed

Parameters

Name
Type
Description

redeemer

address

commission

uint256

amount

uint256

SettlementRedeemStableToken

Parameters

Name
Type
Description

queueSize

uint256

accumCommissions

uint256

reservePrice

uint256

SettlementDeleveraging

Parameters

Name
Type
Description

leverage

uint256

riskProxPrice

uint256

reservePrice

uint256

startBlockNumber

uint256

SettlementStarted

Parameters

Name
Type
Description

stableTokenRedeemCount

uint256

deleveragingCount

uint256

riskProxPrice

uint256

reservePrice

uint256

SettlementCompleted

Parameters

Name
Type
Description

commissionsPayed

uint256

Modifiers

withinBoundaries

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

isTime

modifier isTime() internal

Arguments

Functions

initialize

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

setBlockSpan

⤿ Overridden Implementation(s): MoCSettlementMock.setBlockSpan

Set the blockspan configuration blockspan of settlement

function setBlockSpan(uint256 bSpan) public nonpayable onlyAuthorizedChanger 

Arguments

Name
Type
Description

bSpan

uint256

setSettlementToStall

Set Settlement to be kept in finnished state after all execution is completed.

function setSettlementToStall() public nonpayable onlyAuthorizedChanger 

Arguments

restartSettlementState

Set Settlement state to Ready

function restartSettlementState() public nonpayable onlyAuthorizedChanger 

Arguments

getRedeemRequestAt

⤾ 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

getBlockSpan

Gets the number of blocks the settlemnet will be allowed to run

function getBlockSpan() public view
returns(uint256)

Arguments

redeemQueueSize

⤾ overrides IMoCSettlement.redeemQueueSize

Returns the current redeem request queue's length

function redeemQueueSize() public view
returns(uint256)

Arguments

isSettlementEnabled

⤾ overrides IMoCSettlement.isSettlementEnabled

Returns true if blockSpan number of blocks has pass since last execution

function isSettlementEnabled() public view
returns(bool)

Arguments

isSettlementRunning

Returns true if the settlment is running

function isSettlementRunning() public view
returns(bool)

Arguments

isSettlementReady

⤾ overrides IMoCSettlement.isSettlementReady

Returns true if the settlment is ready

function isSettlementReady() public view
returns(bool)

Arguments

nextSettlementBlock

⤾ overrides IMoCSettlement.nextSettlementBlock

Returns the next block from which settlement is possible

function nextSettlementBlock() public view
returns(uint256)

Arguments

docAmountToRedeem

⤾ 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

addRedeemRequest

⤾ 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

clear

empty the queue

function clear() public nonpayable onlyWhitelisted 

Arguments

alterRedeemRequestAmount

⤾ 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

runSettlement

⤾ 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

fixTasksPointer

Create Task structures for Settlement execution

function fixTasksPointer() public nonpayable

Arguments

initializeContracts

function initializeContracts() internal nonpayable

Arguments

initializeValues

function initializeValues(address _governor, uint256 _blockSpan) internal nonpayable

Arguments

Name
Type
Description

_governor

address

_blockSpan

uint256

deleveragingStepCount

Returns the amount of steps for the Deleveraging task which is the amount of active BProx addresses

function deleveragingStepCount() internal view
returns(uint256)

Arguments

docRedemptionStepCount

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

initializeSettlement

Freezes state for Settlement execution

function initializeSettlement() internal nonpayable

Arguments

finishSettlement

Execute final step of Settlement task group

function finishSettlement() internal nonpayable

Arguments

finishDeleveraging

Execute final step of Deleveraging task

function finishDeleveraging() internal nonpayable

Arguments

finishDocRedemption

Execute final step of DocRedemption task

function finishDocRedemption() internal nonpayable

Arguments

deleveragingStep

Individual Deleveraging step to be executed in partial execution uint256 parameter needed for PartialExecution

function deleveragingStep(uint256 ) internal nonpayable

Arguments

Name
Type
Description

uint256

docRedemptionStep

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

initializeTasks

Create Task structures for Settlement execution

function initializeTasks() internal nonpayable

Arguments

Last updated