diff --git a/contracts/DODOPrivatePool/impl/DPPTrader.sol b/contracts/DODOPrivatePool/impl/DPPTrader.sol index 4456001..8b8eee0 100644 --- a/contracts/DODOPrivatePool/impl/DPPTrader.sol +++ b/contracts/DODOPrivatePool/impl/DPPTrader.sol @@ -257,7 +257,13 @@ contract DPPTrader is DPPVault { } function _sync() internal { - _BASE_RESERVE_ = _BASE_TOKEN_.balanceOf(address(this)); - _QUOTE_RESERVE_ = _QUOTE_TOKEN_.balanceOf(address(this)); + uint256 baseBalance = _BASE_TOKEN_.balanceOf(address(this)); + uint256 quoteBalance = _QUOTE_TOKEN_.balanceOf(address(this)); + if(baseBalance != _BASE_RESERVE_) { + _BASE_RESERVE_ = baseBalance; + } + if(quoteBalance != _QUOTE_RESERVE_) { + _QUOTE_RESERVE_ = quoteBalance; + } } } diff --git a/contracts/DODOPrivatePool/impl/DPPVault.sol b/contracts/DODOPrivatePool/impl/DPPVault.sol index 303e4b1..330548f 100644 --- a/contracts/DODOPrivatePool/impl/DPPVault.sol +++ b/contracts/DODOPrivatePool/impl/DPPVault.sol @@ -81,9 +81,9 @@ contract DPPVault is DPPStorage { function _setRState() internal { if (_BASE_RESERVE_ == _BASE_TARGET_ && _QUOTE_RESERVE_ == _QUOTE_TARGET_) { _RState_ = PMMPricing.RState.ONE; - } else if (_BASE_RESERVE_ > _BASE_TARGET_) { + } else if (_BASE_RESERVE_ > _BASE_TARGET_ && _QUOTE_RESERVE_ < _QUOTE_TARGET_) { _RState_ = PMMPricing.RState.BELOW_ONE; - } else if (_QUOTE_RESERVE_ > _QUOTE_TARGET_) { + } else if (_BASE_RESERVE_ < _BASE_TARGET_ && _QUOTE_RESERVE_ > _QUOTE_TARGET_) { _RState_ = PMMPricing.RState.ABOVE_ONE; } else { require(false, "R_STATE_WRONG"); diff --git a/contracts/DODOVendingMachine/impl/DVMFunding.sol b/contracts/DODOVendingMachine/impl/DVMFunding.sol index 3212430..7e992f4 100644 --- a/contracts/DODOVendingMachine/impl/DVMFunding.sol +++ b/contracts/DODOVendingMachine/impl/DVMFunding.sol @@ -92,6 +92,8 @@ contract DVMFunding is DVMVault { _burn(msg.sender, shareAmount); _transferBaseOut(to, baseAmount); _transferQuoteOut(to, quoteAmount); + _sync(); + if (data.length > 0) { IDODOCallee(to).DVMSellShareCall( msg.sender, @@ -101,7 +103,7 @@ contract DVMFunding is DVMVault { data ); } - _sync(); + emit SellShares(msg.sender, to, shareAmount, _SHARES_[msg.sender]); } } diff --git a/contracts/Factory/ERC20Factory.sol b/contracts/Factory/ERC20Factory.sol index 53f166f..c905919 100644 --- a/contracts/Factory/ERC20Factory.sol +++ b/contracts/Factory/ERC20Factory.sol @@ -20,9 +20,9 @@ import {InitializableMintableERC20} from "../external/ERC20/InitializableMintabl contract ERC20Factory is Ownable { // ============ Templates ============ - address public _CLONE_FACTORY_; - address public _ERC20_TEMPLATE_; - address public _MINTABLE_ERC20_TEMPLATE_; + address public immutable _CLONE_FACTORY_; + address public immutable _ERC20_TEMPLATE_; + address public immutable _MINTABLE_ERC20_TEMPLATE_; // ============ Events ============