support k = 0 case
This commit is contained in:
@@ -29,6 +29,8 @@ library DODOMath {
|
|||||||
|
|
||||||
i is the price of res-V trading pair
|
i is the price of res-V trading pair
|
||||||
|
|
||||||
|
support k=1 & k=0 case
|
||||||
|
|
||||||
[round down]
|
[round down]
|
||||||
*/
|
*/
|
||||||
function _GeneralIntegrate(
|
function _GeneralIntegrate(
|
||||||
@@ -53,6 +55,8 @@ library DODOMath {
|
|||||||
i is the price of delta-V trading pair
|
i is the price of delta-V trading pair
|
||||||
give out target of V
|
give out target of V
|
||||||
|
|
||||||
|
support k=1 & k=0 case
|
||||||
|
|
||||||
[round down]
|
[round down]
|
||||||
*/
|
*/
|
||||||
function _SolveQuadraticFunctionForTarget(
|
function _SolveQuadraticFunctionForTarget(
|
||||||
@@ -60,7 +64,10 @@ library DODOMath {
|
|||||||
uint256 delta,
|
uint256 delta,
|
||||||
uint256 i,
|
uint256 i,
|
||||||
uint256 k
|
uint256 k
|
||||||
) internal pure returns (uint256 V0) {
|
) internal pure returns (uint256) {
|
||||||
|
if (k == 0) {
|
||||||
|
return V1.add(DecimalMath.mulFloor(i, delta));
|
||||||
|
}
|
||||||
// V0 = V1*(1+(sqrt-1)/2k)
|
// V0 = V1*(1+(sqrt-1)/2k)
|
||||||
// sqrt = √(1+4kidelta/V1)
|
// sqrt = √(1+4kidelta/V1)
|
||||||
// premium = 1+(sqrt-1)/2k
|
// premium = 1+(sqrt-1)/2k
|
||||||
@@ -93,6 +100,8 @@ library DODOMath {
|
|||||||
|
|
||||||
i is the price of delta-V trading pair
|
i is the price of delta-V trading pair
|
||||||
|
|
||||||
|
support k=1 & k=0 case
|
||||||
|
|
||||||
[round down]
|
[round down]
|
||||||
*/
|
*/
|
||||||
function _SolveQuadraticFunctionForTrade(
|
function _SolveQuadraticFunctionForTrade(
|
||||||
@@ -107,6 +116,10 @@ library DODOMath {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (k == 0) {
|
||||||
|
return DecimalMath.mulFloor(i, delta);
|
||||||
|
}
|
||||||
|
|
||||||
if (k == DecimalMath.ONE) {
|
if (k == DecimalMath.ONE) {
|
||||||
// if k==1
|
// if k==1
|
||||||
// Q2=Q1/(1+ideltaBQ1/Q0/Q0)
|
// Q2=Q1/(1+ideltaBQ1/Q0/Q0)
|
||||||
|
|||||||
Reference in New Issue
Block a user