MoCExchange

View Source: contracts/MoCExchange.sol

↗ Extends: MoCExchangeEvents, MoCBase, MoCLibConnection, IMoCExchange

MoCExchange - version: 0.1.12

Structs

RiskProxRedeemStruct

struct RiskProxRedeemStruct {
 uint256 totalBtcRedeemed,
 uint256 btcTotalWithoutCommission,
 uint256 rbtcInterests,
 uint256 bucketLev,
 uint256 bproxToRedeem,
 uint256 rbtcToRedeem,
 uint256 bproxPrice,
 struct MoCExchange.CommissionReturnStruct commission
}

RiskProxMintStruct

struct RiskProxMintStruct {
 uint256 bproxToMint,
 uint256 finalBtcToMint,
 uint256 btcInterestAmount,
 uint256 lev,
 struct MoCExchange.CommissionReturnStruct commission
}

RiskProRedeemStruct

struct RiskProRedeemStruct {
 uint256 bproFinalAmount,
 uint256 btcTotalWithoutCommission,
 struct MoCExchange.CommissionReturnStruct commission
}

FreeStableTokenRedeemStruct

struct FreeStableTokenRedeemStruct {
 uint256 finalDocAmount,
 uint256 finalBtcAmount,
 uint256 btcInterestAmount,
 struct MoCExchange.CommissionReturnStruct commission
}

RiskProMintStruct

struct RiskProMintStruct {
 uint256 bproRegularPrice,
 uint256 btcValue,
 uint256 discountPrice,
 uint256 bproDiscountAmount,
 uint256 regularBProAmount,
 uint256 availableBPro,
 uint256 finalBProAmount,
 struct MoCExchange.CommissionReturnStruct commission
}

StableTokenMintStruct

struct StableTokenMintStruct {
 uint256 docs,
 uint256 docAmount,
 uint256 totalCost,
 struct MoCExchange.CommissionReturnStruct commission
}

CommissionParamsStruct

struct CommissionParamsStruct {
 address account,
 uint256 amount,
 uint8 txTypeFeesMOC,
 uint8 txTypeFeesRBTC,
 address vendorAccount
}

CommissionReturnStruct

struct CommissionReturnStruct {
 uint256 btcCommission,
 uint256 mocCommission,
 uint256 btcPrice,
 uint256 mocPrice,
 uint256 btcMarkup,
 uint256 mocMarkup
}

StableTokenRedeemStruct

struct StableTokenRedeemStruct {
 uint256 reserveTotal,
 uint256 btcToRedeem,
 uint256 totalBtc,
 struct MoCExchange.CommissionReturnStruct commission
}

Contract Members

Constants & Variables

contract IMoCState internal mocState;

address internal DEPRECATED_mocConverter;

contract MoCBProxManager internal bproxManager;

contract BProToken internal bproToken;

contract DocToken internal docToken;

contract IMoCInrate internal mocInrate;

contract IMoC internal moc;

uint256[50] private upgradeGap;

RiskProMint

Parameters

RiskProWithDiscountMint

Parameters

RiskProRedeem

Parameters

StableTokenMint

Parameters

StableTokenRedeem

Parameters

FreeStableTokenRedeem

Parameters

RiskProxMint

Parameters

RiskProxRedeem

Parameters

Functions

initialize

Initializes the contract

function initialize(address connectorAddress) public nonpayable initializer 

Arguments

getMoCTokenBalance

⤾ overrides IMoCExchange.getMoCTokenBalance

Converts MoC commission from RBTC to MoC price

function getMoCTokenBalance(address owner, address spender) public view
returns(mocBalance uint256, mocAllowance uint256)

Returns

MoC balance of owner and MoC allowance of spender

Arguments

calculateCommissionsWithPrices

Calculates commissions in MoC and BTC

function calculateCommissionsWithPrices(struct MoCExchange.CommissionParamsStruct params) public view
returns(ret struct MoCExchange.CommissionReturnStruct)

Returns

Commissions calculated in MoC price and bitcoin price; and Bitcoin and MoC prices

Arguments

bproDiscToBtc

BTC equivalent for the amount of bpro given applying the spotDiscountRate

function bproDiscToBtc(uint256 bproAmount, uint256 bproTecPrice, uint256 bproDiscountRate) internal view
returns(uint256)

Returns

BTC amount

Arguments

mintBPro

⤾ overrides IMoCExchange.mintBPro

Mint BPros and give it to the msg.sender

function mintBPro(address account, uint256 btcAmount, address vendorAccount) external nonpayable onlyWhitelisted 
returns(uint256, uint256, uint256, uint256, uint256)

Arguments

redeemBPro

⤾ overrides IMoCExchange.redeemBPro

Sender burns his BProS and redeems the equivalent BTCs

function redeemBPro(address account, uint256 bproAmount, address vendorAccount) public nonpayable onlyWhitelisted 
returns(uint256, uint256, uint256, uint256, uint256)

Returns

bitcoins to transfer to the redeemer and commission spent (in BTC and MoC), using [using reservePrecision]

Arguments

redeemFreeDoc

⤾ overrides IMoCExchange.redeemFreeDoc

Redeems the requested amount for the account, or the max amount of free docs possible.

function redeemFreeDoc(address account, uint256 docAmount, address vendorAccount) public nonpayable onlyWhitelisted 
returns(uint256, uint256, uint256, uint256, uint256)

Returns

bitcoins to transfer to the redeemer and commission spent (in BTC and MoC), using [using reservePrecision]

Arguments

mintDoc

⤾ overrides IMoCExchange.mintDoc

Mint Max amount of Docs and give it to the msg.sender

function mintDoc(address account, uint256 btcToMint, address vendorAccount) public nonpayable onlyWhitelisted 
returns(uint256, uint256, uint256, uint256, uint256)

Returns

the actual amount of btc used and the btc commission (in BTC and MoC) for them [using rbtPresicion]

Arguments

redeemDocWithPrice

⤾ overrides IMoCExchange.redeemDocWithPrice

User DoCs get burned and he receives the equivalent BTCs in return

function redeemDocWithPrice(address payable userAddress, uint256 amount, uint256 btcPrice) public nonpayable onlyWhitelisted 
returns(bool, uint256)

Returns

true and commission spent (in BTC and MoC) if btc send was completed, false if fails.

Arguments

redeemAllDoc

⤾ overrides IMoCExchange.redeemAllDoc

Allow redeem on liquidation state, user DoCs get burned and he receives the equivalent RBTCs according to liquidationPrice

function redeemAllDoc(address origin, address payable destination) public nonpayable onlyWhitelisted 
returns(uint256)

Returns

The amount of RBTC in sent for the redemption or 0 if send does not succed

Arguments

mintBProx

⚠ 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.

⚠ See the approved technical proposal to understand how the behavior of this function has changed.

⤾ overrides IMoCExchange.mintBProx

BUCKET Bprox minting. Mints Bprox for the specified bucket

function mintBProx(address payable account, bytes32 bucket, uint256 btcToMint, address vendorAccount) public nonpayable onlyWhitelisted 
returns(uint256, uint256, uint256, uint256, uint256)

Returns

total RBTC Spent (btcToMint more interest) and commission spent (in BTC and MoC) [using reservePrecision]

Arguments

redeemBProx

⚠ 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 IMoCExchange.redeemBProx

Sender burns his BProx, redeems the equivalent amount of BPros, return the "borrowed" DOCs and recover pending interests

function redeemBProx(address payable account, bytes32 bucket, uint256 bproxAmount, address vendorAccount) public nonpayable onlyWhitelisted 
returns(uint256, uint256, uint256, uint256, uint256)

Returns

the actual amount of btc to redeem and the btc commission (in BTC and MoC) for them [using reservePrecision]

Arguments

forceRedeemBProx

⚠ 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 IMoCExchange.forceRedeemBProx

Burns user BProx and sends the equivalent amount of RBTC to the account without caring if transaction succeeds

function forceRedeemBProx(bytes32 bucket, address payable account, uint256 bproxAmount, uint256 bproxPrice) public nonpayable onlyWhitelisted 
returns(bool)

Returns

result of the RBTC sending transaction [using reservePrecision]

Arguments

burnBProxFor

⚠ 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.

Burns user BProx

function burnBProxFor(bytes32 bucket, address payable account, uint256 bproxAmount, uint256 bproxPrice) public nonpayable onlyWhitelisted 
returns(uint256)

Returns

Bitcoin total value of the redemption [using reservePrecision]

Arguments

redeemBProxInternal

⚠ 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.

Internal function to avoid stack too deep errors

function redeemBProxInternal(address account, bytes32 bucket, uint256 bproxAmount, struct MoCExchange.RiskProxRedeemStruct details, address vendorAccount) internal nonpayable

Arguments

mintBProInternal

Internal function to avoid stack too deep errors

function mintBProInternal(address account, uint256 btcAmount, struct MoCExchange.RiskProMintStruct details, address vendorAccount) internal nonpayable

Arguments

mintBProxInternal

⚠ 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.

⚠ See the approved technical proposal to understand how the behavior of this function has changed.

Internal function to avoid stack too deep errors

function mintBProxInternal(address account, bytes32 bucket, struct MoCExchange.RiskProxMintStruct details, address vendorAccount) internal nonpayable

Arguments

mintDocInternal

Internal function to avoid stack too deep errors

function mintDocInternal(address account, struct MoCExchange.StableTokenMintStruct details, address vendorAccount) internal nonpayable

Arguments

redeemFreeDocInternal

Internal function to avoid stack too deep errors

function redeemFreeDocInternal(address account, struct MoCExchange.FreeStableTokenRedeemStruct details, address vendorAccount) internal nonpayable

Arguments

redeemBProInternal

Internal function to avoid stack too deep errors

function redeemBProInternal(address account, struct MoCExchange.RiskProRedeemStruct details, address vendorAccount) internal nonpayable

Arguments

redeemDocWithPriceInternal

Internal function to avoid stack too deep errors

function redeemDocWithPriceInternal(address account, uint256 amount, struct MoCExchange.StableTokenRedeemStruct details, address vendorAccount) internal nonpayable

Arguments

moveExtraFundsToBucket

Calculates the amount of RBTC that one bucket should move to another in BProx minting/redemption. This extra makes BProx more leveraging than BPro.

function moveExtraFundsToBucket(bytes32 bucketFrom, bytes32 bucketTo, uint256 totalBtc, uint256 lev) internal nonpayable

Arguments

recoverInterests

Returns RBTCs for user in concept of interests refund

function recoverInterests(bytes32 bucket, uint256 rbtcToRedeem) internal nonpayable
returns(uint256)

Returns

Interests [using reservePrecision]

Arguments

doDocRedeem

function doDocRedeem(address userAddress, uint256 docAmount, uint256 totalBtc) internal nonpayable

Arguments

initializeContracts

function initializeContracts() internal nonpayable

Arguments

Last updated