MoCInrate
View Source: contracts/MoCInrate.sol
↗ Extends: MoCInrateEvents, MoCInrateStructs, MoCBase, MoCLibConnection, Governed, IMoCInrate
MoCInrate - version: 0.1.10
Structs
InrateParams
struct InrateParams {
uint256 tMax,
uint256 tMin,
uint256 power
}
Contract Members
Constants & Variables
struct MoCInrateStructs.InrateParams internal riskProxParams;
contract IMoCState internal mocState;
address internal DEPRECATED_mocConverter;
contract MoCRiskProxManager internal riskProxManager;
uint256 public lastDailyPayBlock;
uint256 public riskProRate;
address payable public riskProInterestAddress;
uint256 public lastRiskProInterestBlock;
uint256 public riskProInterestBlockSpan;
address payable public commissionsAddress;
uint256 public DEPRECATED_commissionRate;
uint256 public stableTmin;
uint256 public stablePower;
uint256 public stableTmax;
uint8 public constant MINT_RISKPRO_FEES_RESERVE;
uint8 public constant REDEEM_RISKPRO_FEES_RESERVE;
uint8 public constant MINT_STABLETOKEN_FEES_RESERVE;
uint8 public constant REDEEM_STABLETOKEN_FEES_RESERVE;
uint8 public constant MINT_RISKPROX_FEES_RESERVE;
uint8 public constant REDEEM_RISKPROX_FEES_RESERVE;
uint8 public constant MINT_RISKPRO_FEES_MOC;
uint8 public constant REDEEM_RISKPRO_FEES_MOC;
uint8 public constant MINT_STABLETOKEN_FEES_MOC;
uint8 public constant REDEEM_STABLETOKEN_FEES_MOC;
uint8 public constant MINT_RISKPROX_FEES_MOC;
uint8 public constant REDEEM_RISKPROX_FEES_MOC;
mapping(uint8 => uint256) public commissionRatesByTxType;
uint256[50] private upgradeGap;
InrateDailyPay
Parameters
amount
uint256
daysToSettlement
uint256
nReserveBucketC0
uint256
RiskProHoldersInterestPay
Parameters
amount
uint256
nReserveBucketC0BeforePay
uint256
Modifiers
onlyOnceADay
modifier onlyOnceADay() internal
Arguments
onlyWhenRiskProInterestsIsEnabled
modifier onlyWhenRiskProInterestsIsEnabled() internal
Arguments
Functions
setStableTmin
function setStableTmin(uint256 _stableTmin) public nonpayable onlyAuthorizedChanger
Arguments
_stableTmin
uint256
setStableTmax
function setStableTmax(uint256 _stableTmax) public nonpayable onlyAuthorizedChanger
Arguments
_stableTmax
uint256
setStablePower
function setStablePower(uint256 _stablePower) public nonpayable onlyAuthorizedChanger
Arguments
_stablePower
uint256
getStableTmin
function getStableTmin() public view
returns(uint256)
Arguments
getStableTmax
function getStableTmax() public view
returns(uint256)
Arguments
getStablePower
function getStablePower() public view
returns(uint256)
Arguments
stableTokenInrateAvg
Calculates an average interest rate between after and before free stableToken Redemption
function stableTokenInrateAvg(uint256 stableTokenRedeem) public view
returns(uint256)
Returns
Interest rate value [using mocPrecision]
Arguments
stableTokenRedeem
uint256
StableTokens to redeem [using mocPrecision]
initialize
Initializes the contract
function initialize(address connectorAddress, address _governor, uint256 riskProxTmin, uint256 riskProxPower, uint256 riskProxTmax, uint256 _riskProRate, uint256 blockSpanRiskPro, address payable riskProInterestTargetAddress, address payable commissionsAddressTarget, uint256 _stableTmin, uint256 _stablePower, uint256 _stableTmax) public nonpayable initializer
Arguments
connectorAddress
address
MoCConnector contract address
_governor
address
Governor contract address
riskProxTmin
uint256
Minimum interest rate [using mocPrecision]
riskProxPower
uint256
Power is a parameter for interest rate calculation [using noPrecision]
riskProxTmax
uint256
Maximun interest rate [using mocPrecision]
_riskProRate
uint256
BitPro holder interest rate [using mocPrecision]
blockSpanRiskPro
uint256
BitPro blockspan to configure payments periods[using mocPrecision]
riskProInterestTargetAddress
address payable
Target address to transfer the weekly BitPro holders interest
commissionsAddressTarget
address payable
Target addres to transfer commissions of mint/redeem
_stableTmin
uint256
Upgrade to support red stable inrate parameter
_stablePower
uint256
Upgrade to support red stable inrate parameter
_stableTmax
uint256
Upgrade to support red stable inrate parameter
getRiskProxTmin
âš 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.
gets tMin param of RiskProx tokens
function getRiskProxTmin() public view
returns(uint256)
Returns
returns tMin of RiskProx
Arguments
getRiskProxTmax
âš 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.
gets tMax param of RiskProx tokens
function getRiskProxTmax() public view
returns(uint256)
Returns
returns tMax of RiskProx
Arguments
getRiskProxPower
âš 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.
gets power param of RiskProx tokens
function getRiskProxPower() public view
returns(uint256)
Returns
returns power of RiskProx
Arguments
getRiskProInterestBlockSpan
⤾ overrides IMoCInrate.getRiskProInterestBlockSpan
Gets the blockspan of RiskPro that represents the frecuency of RiskPro holders intereset payment
function getRiskProInterestBlockSpan() public view
returns(uint256)
Returns
returns power of riskProInterestBlockSpan
Arguments
setRiskProxTmin
âš 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.
sets tMin param of RiskProx tokens
function setRiskProxTmin(uint256 _btxcTmin) public nonpayable onlyAuthorizedChanger
Arguments
_btxcTmin
uint256
tMin of RiskProx
setRiskProxTmax
âš 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.
sets tMax param of RiskProx tokens
function setRiskProxTmax(uint256 _btxcTax) public nonpayable onlyAuthorizedChanger
Arguments
_btxcTax
uint256
tMax of RiskProx
setRiskProxPower
âš 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.
sets power param of RiskProx tokens
function setRiskProxPower(uint256 _btxcPower) public nonpayable onlyAuthorizedChanger
Arguments
_btxcPower
uint256
power of RiskProx
getRiskProRate
⤾ overrides IMoCInrate.getRiskProRate
Gets the rate for RiskPro Holders
function getRiskProRate() public view
returns(uint256)
Returns
RiskPro Rate
Arguments
setRiskProRate
Sets RiskPro Holders rate
function setRiskProRate(uint256 newRiskProRate) public nonpayable onlyAuthorizedChanger
Arguments
newRiskProRate
uint256
New RiskPro rate
setRiskProInterestBlockSpan
⤾ overrides IMoCInrate.setRiskProInterestBlockSpan
Sets the blockspan RiskPro Intereset rate payment is enable to be executed
function setRiskProInterestBlockSpan(uint256 newRiskProBlockSpan) public nonpayable onlyAuthorizedChanger
Arguments
newRiskProBlockSpan
uint256
New RiskPro Block span
getRiskProInterestAddress
⤾ overrides IMoCInrate.getRiskProInterestAddress
Gets the target address to transfer RiskPro Holders rate
function getRiskProInterestAddress() public view
returns(address payable)
Returns
Target address to transfer RiskPro Holders interest
Arguments
setRiskProInterestAddress
Sets the target address to transfer RiskPro Holders rate
function setRiskProInterestAddress(address payable newRiskProInterestAddress) public nonpayable onlyAuthorizedChanger
Arguments
newRiskProInterestAddress
address payable
New RiskPro rate
setCommissionsAddress
Sets the target address to transfer commissions of Mint/Redeem transactions
function setCommissionsAddress(address payable newCommissionsAddress) public nonpayable onlyAuthorizedChanger
Arguments
newCommissionsAddress
address payable
New commisions address
spotInrate
Calculates interest rate for RiskProx Minting, redeem and Free StableToken Redeem
function spotInrate() public view
returns(uint256)
Returns
Interest rate value [using RatePrecsion]
Arguments
riskProxInrateAvg
âš 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.
Calculates an average interest rate between after and before mint/redeem
function riskProxInrateAvg(bytes32 bucket, uint256 resTokensAmount, bool onMinting) public view
returns(uint256)
Returns
Interest rate value [using mocPrecision]
Arguments
bucket
bytes32
Name of the bucket involved in the operation
resTokensAmount
uint256
Value of the operation from which calculates the inrate [using reservePrecision]
onMinting
bool
Value that represents if the calculation is based on mint or on redeem
dailyInrate
returns the amount of ReserveTokens to pay in concept of interest to bucket C0
function dailyInrate() public view
returns(uint256)
Arguments
calcMintInterestValues
⤾ overrides IMoCInrate.calcMintInterestValues
Extract the inrate from the passed ReserveTokens value for RiskProx minting operation
function calcMintInterestValues(bytes32 bucket, uint256 reserveTokenAmount) public view
returns(uint256)
Returns
ReserveTokens to pay in concept of interests [using reservePrecision]
Arguments
bucket
bytes32
Bucket to use to calculate interés
reserveTokenAmount
uint256
Total value from which extract the interest rate [using reservePrecision]
calcStableTokenRedInterestValues
⤾ overrides IMoCInrate.calcStableTokenRedInterestValues
Extract the inrate from the passed ReserveTokens value for the StableToken Redeem operation
function calcStableTokenRedInterestValues(uint256 stableTokenAmount, uint256 reserveTokenAmount) public view
returns(uint256)
Returns
finalInterest
Arguments
stableTokenAmount
uint256
StableToken amount of the redemption [using mocPrecision]
reserveTokenAmount
uint256
Total value from which extract the interest rate [using reservePrecision]
calcFinalRedeemInterestValue
⤾ overrides IMoCInrate.calcFinalRedeemInterestValue
This function calculates the interest to return to the user in a RiskProx redemption. It uses a mechanism to counteract the effect of free stableTokens redemption. It will be replaced with FreeStableToken redemption interests in the future
function calcFinalRedeemInterestValue(bytes32 bucket, uint256 reserveTokenToRedeem) public view
returns(uint256)
Returns
Reserves to recover in concept of interests [using reservePrecision]
Arguments
bucket
bytes32
Bucket to use to calculate interest
reserveTokenToRedeem
uint256
Total value from which calculate interest [using reservePrecision]
calcCommissionValue
DEPRECATED calculates the Commission rate from the passed RBTC amount for mint/redeem operations
function calcCommissionValue(uint256 reserveTokenAmount) external view
returns(uint256)
Returns
finalCommissionAmount [using reservePrecision]
Arguments
reserveTokenAmount
uint256
Total value from which apply the Commission rate [using reservePrecision]
calcCommissionValue
⤾ overrides IMoCInrate.calcCommissionValue
calculates the Commission rate from the passed ReserveTokens amount for mint/redeem operations
function calcCommissionValue(uint256 reserveTokenAmount, uint8 txType) public view
returns(uint256)
Returns
finalCommissionAmount [using reservePrecision]
Arguments
reserveTokenAmount
uint256
Total value from which apply the Commission rate [using reservePrecision]
txType
uint8
Transaction type according to constant values defined in this contract
calculateVendorMarkup
⤾ overrides IMoCInrate.calculateVendorMarkup
calculates the vendor markup rate from the passed vendor account and amount
function calculateVendorMarkup(address vendorAccount, uint256 amount) public view
returns(markup uint256)
Returns
finalCommissionAmount [using reservePrecision]
Arguments
vendorAccount
address
Vendor address
amount
uint256
Total value from which apply the vendor markup rate [using reservePrecision]
calcRedeemInterestValue
Calculates ReserveTokens value to return to the user in concept of interests
function calcRedeemInterestValue(bytes32 bucket, uint256 reserveTokenToRedeem) public view
returns(uint256)
Returns
Reserves to recover in concept of interests [using reservePrecision]
Arguments
bucket
bytes32
Bucket to use to calculate interest
reserveTokenToRedeem
uint256
Total value from which calculate interest [using reservePrecision]
dailyInratePayment
⤾ overrides IMoCInrate.dailyInratePayment
Moves the daily amount of interest rate to C0 bucket
function dailyInratePayment() public nonpayable onlyWhitelisted onlyOnceADay
returns(uint256)
Arguments
isDailyEnabled
⤾ overrides IMoCInrate.isDailyEnabled
function isDailyEnabled() public view
returns(bool)
Arguments
isRiskProInterestEnabled
⤾ overrides IMoCInrate.isRiskProInterestEnabled
function isRiskProInterestEnabled() public view
returns(bool)
Arguments
calculateRiskProHoldersInterest
⤾ overrides IMoCInrate.calculateRiskProHoldersInterest
Calculates RiskPro Holders interest rates
function calculateRiskProHoldersInterest() public view
returns(uint256, uint256)
Returns
toPay interest in ReserveTokens [using reservePrecsion]
Arguments
payRiskProHoldersInterestPayment
⤾ overrides IMoCInrate.payRiskProHoldersInterestPayment
Pays the RiskPro Holders interest rates
function payRiskProHoldersInterestPayment() public nonpayable onlyWhitelisted onlyWhenRiskProInterestsIsEnabled
returns(uint256)
Returns
interest payed in ReserveTokens [using reservePrecsion]
Arguments
setCommissionRateByTxType
Sets the commission rate to a particular transaction type
function setCommissionRateByTxType(uint8 txType, uint256 value) public nonpayable onlyAuthorizedChanger
Arguments
txType
uint8
Transaction type according to constant values defined in this contract
value
uint256
Commission rate
inrateToSettlement
Calculates the interest rate to pay until the settlement day
function inrateToSettlement(uint256 inrate, bool countAllDays) internal view
returns(uint256)
Returns
Interest rate value [using mocPrecision]
Arguments
inrate
uint256
Spot interest rate
countAllDays
bool
Value that represents if the calculation will use all days or one day less
calcProportionalInterestValue
This function calculates the interest to return to a user redeeming RiskProx as a proportion of the amount in the interestBag.
function calcProportionalInterestValue(bytes32 bucket, uint256 redeemInterest) internal view
returns(uint256)
Returns
InterestsInBag * (RedeemInterests / FullRedeemInterest) [using reservePrecision]
Arguments
bucket
bytes32
Bucket to use to calculate interest
redeemInterest
uint256
Total value from which calculate interest [using reservePrecision]
calcFullRedeemInterestValue
This function calculates the interest to return if a user redeem all RiskProx in existance
function calcFullRedeemInterestValue(bytes32 bucket) internal view
returns(uint256)
Returns
Interests [using reservePrecision]
Arguments
bucket
bytes32
Bucket to use to calculate interest
simulateStableTokenMovement
Calculates the final amount of Bucket 0 StableTokens on RiskProx mint/redeem
function simulateStableTokenMovement(bytes32 bucket, uint256 resTokensAmount, bool onMinting) internal view
returns(uint256)
Returns
Final bucket 0 StableToken amount
Arguments
bucket
bytes32
Name of the bucket involved in the operation
resTokensAmount
uint256
Value of the operation from which calculates the inrate [using reservePrecision]
onMinting
bool
inrateDayCount
Returns the days to use for interests calculation
function inrateDayCount(bool countAllDays) internal view
returns(uint256)
Returns
days [using dayPrecision]
Arguments
countAllDays
bool
Value that represents if the calculation is based on mint or on redeem
initializeContracts
Initialize the contracts with which it interacts
function initializeContracts() internal nonpayable
Arguments
initializeValues
Initialize the parameters of the contract
function initializeValues(address _governor, uint256 riskProxMin, uint256 riskProxPower, uint256 riskProxMax, uint256 _riskProRate, address payable commissionsAddressTarget, uint256 blockSpanRiskPro, address payable riskProInterestsTarget, uint256 _stableTmin, uint256 _stablePower, uint256 _stableTmax) internal nonpayable
Arguments
_governor
address
the address of the IGovernor contract
riskProxMin
uint256
Minimum interest rate [using mocPrecision]
riskProxPower
uint256
Power is a parameter for interest rate calculation [using noPrecision]
riskProxMax
uint256
Maximun interest rate [using mocPrecision]
_riskProRate
uint256
RiskPro holder interest rate [using mocPrecision]
commissionsAddressTarget
address payable
blockSpanRiskPro
uint256
RiskPro blockspan to configure payments periods[using mocPrecision]
riskProInterestsTarget
address payable
Target address to transfer the weekly RiskPro holders interest
_stableTmin
uint256
Upgrade to support red stable inrate parameter
_stablePower
uint256
Upgrade to support red stable inrate parameter
_stableTmax
uint256
Upgrade to support red stable inrate parameter
Last updated