MoCHelperLib
View Source: contracts/MoCHelperLib.sol
MoCHelperLib - version: 0.1.12
Structs
MocLibConfig
Contract Members
Constants & Variables
Functions
getMaxInt
Returns max uint256 value constant.
Returns
max uint256 value constant
Arguments
struct MoCHelperLib.MocLibConfig
inrateAvg
Calculates average interest using integral function: T = Rate = a * (x ** b) + c
Returns
average interest rate [using mocPrecision]
Arguments
config
struct MoCHelperLib.MocLibConfig
tMax
uint256
maxInterestRate [using mocPrecision]
power
uint256
factor [using noPrecision]
tMin
uint256
minInterestRate C0 doc amount [using mocPrecision]
abRat1
uint256
initial abundance ratio [using mocPrecision]
abRat2
uint256
final abundance ratio [using mocPrecision]
spotInrate
⚠ 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 spot interest rate that BProx owners should pay to BPro owners: Rate = tMax * (abRatio ** power) + tMin
Arguments
config
struct MoCHelperLib.MocLibConfig
tMax
uint256
max interest rate [using mocPrecision]
power
uint256
power to use in the formula [using NoPrecision]
tMin
uint256
min interest rate [using mocPrecision]
abRatio
uint256
bucket C0 abundance Ratio [using mocPrecision]
potential
Calculates potential interests function with given parameters: Rate = a * (x ** b) + c
Arguments
config
struct MoCHelperLib.MocLibConfig
a
uint256
maxInterestRate [using mocPrecision]
b
uint256
factor [using NoPrecision]
c
uint256
minInterestRate C0 doc amount [using mocPrecision]
value
uint256
global doc amount [using mocPrecision]
avgInt
Calculates average of the integral function: T = ( (c * xf + ((a * (xf ** (b + 1))) / (b + 1))) - (c * xi + ((a * (xi ** (b + 1))) / (b + 1))) ) / (xf - xi)
Returns
average interest rate [using mocPrecision]
Arguments
config
struct MoCHelperLib.MocLibConfig
a
uint256
maxInterestRate [using mocPrecision]
b
uint256
factor [using NoPrecision]
c
uint256
minInterestRate C0 doc amount [using mocPrecision]
value1
uint256
value to put in the function [using mocPrecision]
value2
uint256
value to put in the function [using mocPrecision]
integral
Calculates integral of the exponential function: T = c * (value) + (a * value ** (b + 1)) / (b + 1))
Returns
integration result [using mocPrecision]
Arguments
config
struct MoCHelperLib.MocLibConfig
a
uint256
maxInterestRate [using mocPrecision]
b
uint256
factor [using NoPrecision]
c
uint256
minInterestRate C0 doc amount [using mocPrecision]
value
uint256
value to put in the function [using mocPrecision]
abundanceRatio
Relation between docs in bucket 0 and Doc total supply
Returns
abundance ratio [using mocPrecision]
Arguments
config
struct MoCHelperLib.MocLibConfig
doc0
uint256
doc count in bucket 0 [using mocPrecision]
doct
uint256
total doc supply [using mocPrecision]
bproSpotDiscountRate
Returns the Ratio to apply to BPro Price in discount situations: SpotDiscountRate = TPD * (utpdu - cob) / (uptdu -liq)
Returns
Spot discount rate [using mocPrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
bproLiqDiscountRate
uint256
Discount rate applied at Liquidation level coverage [using mocPrecision]
liq
uint256
Liquidation coverage threshold [using mocPrecision]
utpdu
uint256
Discount coverage threshold [using mocPrecision]
cov
uint256
Actual global Coverage threshold [using mocPrecision]
maxBProWithDiscount
Max amount of BPro to available with discount: MaxBProWithDiscount = (uTPDU * nDOC * PEG - (nBTC * B)) / (TPusd * TPD)
Returns
Total BPro amount [using mocPrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
nB
uint256
Total BTC amount [using reservePrecision]
nDoc
uint256
DOC amount [using mocPrecision]
utpdu
uint256
Discount coverage threshold [using mocPrecision]
peg
uint256
peg value
btcPrice
uint256
BTC price [using mocPrecision]
bproUsdPrice
uint256
bproUsdPrice [using mocPrecision]
spotDiscount
uint256
spot discount [using mocPrecision]
maxBProWithDiscountAux
Max amount of BPro to available with discount: MaxBProWithDiscount = (uTPDU * nDOC * PEG - (nBTC * B)) / (TPusd * TPD)
Returns
Total BPro amount [using mocPrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
nbUsdValue
uint256
Total amount of BTC in USD [using mocPrecision]
nDoc
uint256
DOC amount [using mocPrecision]
utpdu
uint256
Discount coverage threshold [using mocPrecision]
peg
uint256
peg value
bproDiscountPrice
uint256
bproUsdPrice with discount applied [using mocPrecision]
lockedBitcoin
Calculates Locked bitcoin
Returns
Locked bitcoin [using reservePrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
btcPrice
uint256
BTC price [using mocPrecision]
nDoc
uint256
Docs amount [using mocPrecision]
peg
uint256
peg value
liquidationPrice
Calculates price at liquidation event as a relation between the doc total supply and the amount of RBTC available to distribute
Returns
Price at liquidation event [using mocPrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
rbtcAmount
uint256
RBTC to distribute [using reservePrecision]
nDoc
uint256
Docs amount [using mocPrecision]
bproTecPrice
Calculates BPro BTC price: TPbtc = (nB-LB) / nTP
Returns
BPro BTC price [using reservePrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
nB
uint256
Total BTC amount [using reservePrecision]
lb
uint256
Locked bitcoins amount [using reservePrecision]
nTP
uint256
BPro amount [using mocPrecision]
bproxBProPrice
⚠ 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 BPro BTC price: BProxInBPro = bproxTecPrice / bproPrice
Returns
BProx price in BPro [using mocPrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
bproxTecPrice
uint256
BProx BTC price [using reservePrecision]
bproPrice
uint256
Trog BTC price [using reservePrecision]
applyDiscountRate
Returns a new value with the discountRate applied: TPbtc = (price)* (1 - discountRate)
Returns
Price with discount applied [using SomePrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
price
uint256
Price [using SomePrecision]
discountRate
uint256
Discount rate to apply [using mocPrecision]
getInterestCost
Returns the amount of interest to pay: TPbtc = price * interestRate
Returns
Interest cost based on the value and interestRate [using SomePrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
value
uint256
Cost to apply interest [using SomePrecision]
interestRate
uint256
Interest rate to apply [using mocPrecision]
coverage
Calculates Coverage: Coverage = nB / LB
Returns
Coverage [using mocPrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
nB
uint256
Total BTC amount [using reservePrecision]
lB
uint256
Locked bitcoins amount [using reservePrecision]
leverageFromCoverage
Calculates Leverage from Coverage: Leverage = C / (C - 1)
Returns
Leverage [using mocPrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
cov
uint256
Coverage [using mocPrecision]
leverage
Calculates Leverage: Leverage = nB / (nB - lB)
Returns
Leverage [using mocPrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
nB
uint256
Total BTC amount [using reservePrecision]
lB
uint256
Locked bitcoins amount [using reservePrecision]
docsBtcValue
Price in BTC of the amount of Docs
Returns
Total value [using reservePrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
amount
uint256
Total BTC amount [using reservePrecision]
peg
uint256
btcPrice
uint256
BTC price [using mocPrecision]
bproBtcValue
Price in RBTC of the amount of BPros
Returns
Total value [using reservePrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
bproAmount
uint256
amount of BPro [using mocPrecision]
bproBtcPrice
uint256
BPro price in RBTC [using reservePrecision]
maxDoc
Max amount of Docs to issue: MaxDoc = ((nBB)-(CobjB/BconsnDocPEG))/(PEG*(Cobj*B/BCons-1))
Returns
Total Docs amount [using mocPrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
nB
uint256
Total BTC amount [using reservePrecision]
cobj
uint256
Target Coverage [using mocPrecision]
nDoc
uint256
DOC amount [using mocPrecision]
peg
uint256
peg value
btcPrice
uint256
BTC price [using mocPrecision]
bCons
uint256
BTC conservative price [using mocPrecision]
maxDocAux
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
nB
uint256
adjCobj
uint256
nDoc
uint256
peg
uint256
btcPrice
uint256
maxBPro
Max amount of BPro to redeem: MaxBPro = ((nBB)-(CobjnDoc*PEG))/TPusd
Returns
Total BPro amount [using mocPrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
nB
uint256
Total BTC amount [using reservePrecision]
cobj
uint256
Target Coverage [using mocPrecision]
nDoc
uint256
Target Coverage [using mocPrecision]
peg
uint256
peg value
btcPrice
uint256
BTC price [using mocPrecision]
bCons
uint256
BTC conservative price [using mocPrecision]
bproUsdPrice
uint256
bproUsdPrice [using mocPrecision]
totalBProInBtc
Calculates the total BTC price of the amount of BPros
Returns
BPro total value in BTC [using reservePrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
amount
uint256
Amount of BPro [using mocPrecision]
bproPrice
uint256
BPro BTC Price [using reservePrecision]
maxDocsWithBtc
Calculates the equivalent in Docs of the btcAmount
Returns
Equivalent Doc amount [using mocPrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
btcAmount
uint256
BTC amount [using reservePrecision]
btcPrice
uint256
BTC price [using mocPrecision]
maxBProWithBtc
Calculates the equivalent in BPro of the btcAmount
Returns
Equivalent Bpro amount [using mocPrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
btcAmount
uint256
BTC amount [using reservePrecision]
bproPrice
uint256
BPro BTC price [using reservePrecision]
bucketTransferAmount
Calculates the Btc amount to move from C0 bucket to: toMove = btcAmount * (lev - 1) an L bucket when a BProx minting occurs
Returns
btc to move [using reservePrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
btcAmount
uint256
Total BTC amount [using reservePrecision]
lev
uint256
L bucket leverage [using mocPrecision]
maxBProxBtcValue
⚠ 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.
Max amount of BTC allowed to be used to mint bprox: Maxbprox = nDOC/ (PEGB(lev-1))
Returns
Max bprox BTC value [using reservePrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
nDoc
uint256
number of DOC [using mocPrecision]
peg
uint256
peg value
btcPrice
uint256
BTC price [using mocPrecision]
lev
uint256
leverage [using mocPrecision]
maxMoCWithBtc
Calculates the equivalent in MoC of the btcAmount
Returns
Equivalent MoC amount
Arguments
struct MoCHelperLib.MocLibConfig
btcAmount BTC amount
btcAmount
uint256
BTC amount
btcPrice
uint256
BTC price
mocPrice
uint256
MoC price
mocBtcValue
Calculates the equivalent in BTC of the MoC amount
Returns
Equivalent MoC amount
Arguments
struct MoCHelperLib.MocLibConfig
amount BTC amount
amount
uint256
BTC amount
btcPrice
uint256
BTC price
mocPrice
uint256
MoC price
getPayableAddress
Transform an address to payable address
Returns
Payable address for account
Arguments
struct MoCHelperLib.MocLibConfig
account Address to transform to payable
account
address
Address to transform to payable
mulr
Rounding product adapted from DSMath but with custom precision
Returns
Product
Arguments
x
uint256
Multiplicand
y
uint256
Multiplier
precision
uint256
pow
Potentiation by squaring adapted from DSMath but with custom precision
Returns
power
Arguments
x
uint256
Base
n
uint256
Exponent
precision
uint256
Last updated