MoCHelperLib
Last updated
Last updated
View Source:
MoCHelperLib - version: 0.1.10
Constants & Variables
Returns max uint256 value constant.
Returns
max uint256 value constant
Arguments
struct MoCHelperLib.MocLibConfig
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 stableToken amount [using mocPrecision]
abRat1
uint256
initial abundance ratio [using mocPrecision]
abRat2
uint256
final abundance ratio [using mocPrecision]
Calculates spot interest rate that RiskProx owners should pay to RiskPro 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]
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 stableToken amount [using mocPrecision]
value
uint256
global stableToken amount [using mocPrecision]
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 stableToken amount [using mocPrecision]
value1
uint256
value to put in the function [using mocPrecision]
value2
uint256
value to put in the function [using mocPrecision]
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 stableToken amount [using mocPrecision]
value
uint256
value to put in the function [using mocPrecision]
Relation between stableTokens in bucket 0 and StableToken total supply
Returns
abundance ratio [using mocPrecision]
Arguments
config
struct MoCHelperLib.MocLibConfig
stableToken0
uint256
stableToken count in bucket 0 [using mocPrecision]
stableTokent
uint256
total stableToken supply [using mocPrecision]
Returns the Ratio to apply to RiskPro Price in discount situations: SpotDiscountRate = TPD * (utpdu - cob) / (uptdu -liq)
Returns
Spot discount rate [using mocPrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
riskProLiqDiscountRate
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]
Max amount of RiskPro to available with discount: MaxRiskProWithDiscount = (uTPDU * nStableToken * PEG - (nReserve * B)) / (TPusd * TPD)
Returns
Total RiskPro amount [using mocPrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
nReserve
uint256
Total ReserveTokens amount [using reservePrecision]
nStableToken
uint256
StableToken amount [using mocPrecision]
utpdu
uint256
Discount coverage threshold [using mocPrecision]
peg
uint256
peg value
reservePrice
uint256
ReserveTokens price [using mocPrecision]
riskProUsdPrice
uint256
riskProUsdPrice [using mocPrecision]
spotDiscount
uint256
spot discount [using mocPrecision]
Max amount of RiskPro to available with discount: MaxRiskProWithDiscount = (uTPDU * nStableToken * PEG - (nReserve * B)) / (TPusd * TPD)
Returns
Total RiskPro amount [using reservePrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
nbUsdValue
uint256
Total amount of ReserveTokens in USD [using mocPrecision]
nStableToken
uint256
StableToken amount [using mocPrecision]
utpdu
uint256
Discount coverage threshold [using mocPrecision]
peg
uint256
peg value
riskProDiscountPrice
uint256
riskProUsdPrice with discount applied [using mocPrecision]
Calculates Locked ReserveTokens
Returns
Locked ReserveTokens [using reservePrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
reservePrice
uint256
ReserveTokens price [using mocPrecision]
nStableToken
uint256
StableTokens amount [using mocPrecision]
peg
uint256
peg value
Calculates price at liquidation event as a relation between the stableToken total supply and the amount of ReserveTokens available to distribute
Returns
Price at liquidation event [using mocPrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
resTokenAmount
uint256
ReserveTokens to distribute [using reservePrecision]
nStableToken
uint256
StableTokens amount [using mocPrecision]
Calculates RiskPro ReserveTokens: (nReserve-LB) / nTP
Returns
RiskPro ReserveTokens price [using reservePrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
nReserve
uint256
Total ReserveTokens amount [using reservePrecision]
lb
uint256
Locked ReserveTokens amount [using reservePrecision]
nTP
uint256
RiskPro amount [using mocPrecision]
Calculates RiskPro ReserveToken price: RiskProxInRiskPro = riskProxTecPrice / riskProPrice
Returns
RiskProx price in RiskPro [using mocPrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
riskProxTecPrice
uint256
RiskProx ReserveTokens price [using reservePrecision]
riskProPrice
uint256
Trog ReserveTokens price [using reservePrecision]
Returns a new value with the discountRate applied: (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]
Returns the amount of interest to pay: = 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]
Calculates Coverage: nReserve / LB
Returns
Coverage [using mocPrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
nReserve
uint256
Total ReserveTokens amount [using reservePrecision]
lB
uint256
Locked ReserveTokens amount [using reservePrecision]
Calculates Leverage from Coverage: Leverage = C / (C - 1)
Returns
Leverage [using mocPrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
cov
uint256
Coverage [using mocPrecision]
Calculates Leverage: Leverage = nReserve / (nReserve - lB)
Returns
Leverage [using mocPrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
nReserve
uint256
Total ReserveTokens amount [using reservePrecision]
lB
uint256
Locked ReserveTokens amount [using reservePrecision]
Price in ReserveTokens of the amount of StableTokens
Returns
Total value [using reservePrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
amount
uint256
Total ReserveTokens amount [using reservePrecision]
peg
uint256
reservePrice
uint256
ReserveTokens price [using mocPrecision]
Price in ReserveTokens of the amount of RiskPros
Returns
Total value [using reservePrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
riskProAmount
uint256
amount of RiskPro [using mocPrecision]
riskProResTokenPrice
uint256
RiskPro price in ReserveTokens [using reservePrecision]
Max amount of Docs to issue: MaxStableToken = ((nReserveB)-(CobjB/BconsnStableTokenPEG))/(PEG*(Cobj*B/BCons-1))
Returns
Total StableTokens amount [using mocPrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
nReserve
uint256
Total ReserveTokens amount [using reservePrecision]
cobj
uint256
Target Coverage [using mocPrecision]
nStableToken
uint256
StableToken amount [using mocPrecision]
peg
uint256
peg value
reservePrice
uint256
ReserveTokens price [using mocPrecision]
bCons
uint256
ReserveTokens conservative price [using mocPrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
nReserve
uint256
adjCobj
uint256
nStableToken
uint256
peg
uint256
reservePrice
uint256
Max amount of RiskPro to redeem: MaxRiskPro = ((nReserveB)-(CobjnStableToken*PEG))/TPusd
Returns
Total RiskPro amount [using mocPrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
nReserve
uint256
Total ReserveTokens amount [using reservePrecision]
cobj
uint256
Target Coverage [using mocPrecision]
nStableToken
uint256
Target Coverage [using mocPrecision]
peg
uint256
peg value
reservePrice
uint256
ReserveTokens price [using mocPrecision]
bCons
uint256
ReserveTokens conservative price [using mocPrecision]
riskProUsdPrice
uint256
riskProUsdPrice [using mocPrecision]
Calculates the total ReserveTokens price of the amount of RiskPros
Returns
RiskPro total value in ReserveTokens [using reservePrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
amount
uint256
Amount of RiskPro [using mocPrecision]
riskProPrice
uint256
RiskPro ReserveTokens Price [using reservePrecision]
Calculates the equivalent in StableTokens of the resTokensAmount
Returns
Equivalent StableToken amount [using mocPrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
resTokensAmount
uint256
ReserveTokens amount [using reservePrecision]
reservePrice
uint256
ReserveTokens price [using mocPrecision]
Calculates the equivalent in RiskPro of the resTokensAmount
Returns
Equivalent RiskPro amount [using mocPrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
resTokensAmount
uint256
ReserveTokens amount [using reservePrecision]
riskProPrice
uint256
RiskPro ReserveTokens price [using reservePrecision]
Calculates the ResToken amount to move from C0 bucket to an L bucket when a RiskProx minting occurs: toMove = resTokensAmount * (lev - 1)
Returns
resTokens to move [using reservePrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
resTokensAmount
uint256
Total ReserveTokens amount [using reservePrecision]
lev
uint256
L bucket leverage [using mocPrecision]
Max amount of ReserveTokens allowed to be used to mint riskProx: MaxriskProx = nStableToken/ (PEGB(lev-1))
Returns
Max riskProx ReserveTokens value [using reservePrecision]
Arguments
libConfig
struct MoCHelperLib.MocLibConfig
nStableToken
uint256
number of StableToken [using mocPrecision]
peg
uint256
peg value
reservePrice
uint256
ReserveTokens price [using mocPrecision]
lev
uint256
leverage [using mocPrecision]
Calculates the equivalent in MoC of the reserve token
Returns
Equivalent MoC amount
Arguments
struct MoCHelperLib.MocLibConfig
resTokensAmount Total ReserveTokens amount
resTokensAmount
uint256
Total ReserveTokens amount
reservePrice
uint256
ReserveTokens price
mocPrice
uint256
MoC price
Calculates the equivalent in reserve token of the MoC amount
Returns
Equivalent ReserveToken amount
Arguments
struct MoCHelperLib.MocLibConfig
amount MoC amount
amount
uint256
MoC amount
reservePrice
uint256
ReserveTokens price
mocPrice
uint256
MoC price
Rounding product adapted from DSMath but with custom precision
Returns
Product
Arguments
x
uint256
Multiplicand
y
uint256
Multiplier
precision
uint256
Potentiation by squaring adapted from DSMath but with custom precision
Returns
power
Arguments
x
uint256
Base
n
uint256
Exponent
precision
uint256
⚠ This has been deprecated since the from the protocol was approved, however it is necessary to maintain the contracts and their documentation for legacy support.
⚠ This has been deprecated since the from the protocol was approved, however it is necessary to maintain the contracts and their documentation for legacy support.