fix CP Zero bid case
This commit is contained in:
@@ -69,12 +69,22 @@ contract CPFunding is CPStorage {
|
||||
// if quote = m*base i = 1
|
||||
// if quote > m*base reverse
|
||||
{
|
||||
uint256 avgPrice = DecimalMath.divCeil(poolQuote, _UNUSED_BASE_);
|
||||
uint256 baseDepth = DecimalMath.mulFloor(avgPrice, poolBase);
|
||||
address _poolBaseToken;
|
||||
address _poolQuoteToken;
|
||||
uint256 _poolI;
|
||||
if (poolQuote.mul(_UNUSED_BASE_) == poolQuote.mul(poolBase)) {
|
||||
|
||||
uint256 avgPrice = _UNUSED_BASE_ == 0
|
||||
? _I_
|
||||
: DecimalMath.divCeil(poolQuote, _UNUSED_BASE_);
|
||||
uint256 baseDepth = DecimalMath.mulFloor(avgPrice, poolBase);
|
||||
|
||||
if (poolQuote == 0) {
|
||||
// ask side only DVM
|
||||
_poolBaseToken = address(_BASE_TOKEN_);
|
||||
_poolQuoteToken = address(_QUOTE_TOKEN_);
|
||||
_poolI = _I_;
|
||||
} else if (poolQuote.mul(_UNUSED_BASE_) == poolQuote.mul(poolBase)) {
|
||||
// standard bonding curve
|
||||
_poolBaseToken = address(_BASE_TOKEN_);
|
||||
_poolQuoteToken = address(_QUOTE_TOKEN_);
|
||||
_poolI = 1;
|
||||
|
||||
@@ -43,7 +43,7 @@ library DODOMath {
|
||||
require(V0 > 0, "TARGET_IS_ZERO");
|
||||
uint256 fairAmount = i.mul(V1.sub(V2)); // i*delta
|
||||
if (k == 0) {
|
||||
return fairAmount;
|
||||
return fairAmount.div(DecimalMath.ONE);
|
||||
}
|
||||
uint256 V0V0V1V2 = DecimalMath.divFloor(V0.mul(V0).div(V1), V2);
|
||||
uint256 penalty = DecimalMath.mulFloor(k, V0V0V1V2); // k(V0^2/V1/V2)
|
||||
|
||||
Reference in New Issue
Block a user