Compatible with rebase token

This commit is contained in:
owen05
2020-12-18 21:33:40 +08:00
parent c24e4b8176
commit 67067f73c7
4 changed files with 26 additions and 0 deletions

View File

@@ -36,6 +36,12 @@ contract DPPAdmin is InitializableOwnable {
_DODO_APPROVE_ = dodoApprove;
}
//For Rebase Token
function sync() external notFreezed onlyOwner {
IDPP(_DPP_).sync();
}
function setFreezeTimestamp(uint256 timestamp) external notFreezed onlyOwner {
_FREEZE_TIMESTAMP_ = timestamp;
}

View File

@@ -57,6 +57,19 @@ contract DPPVault is DPPStorage {
// ============ Set States ============
function sync() external preventReentrant onlyOwner {
uint256 baseBalance = _BASE_TOKEN_.balanceOf(address(this));
uint256 quoteBalance = _QUOTE_TOKEN_.balanceOf(address(this));
if (baseBalance != _BASE_RESERVE_) {
_BASE_TARGET_ = _BASE_TARGET_.mul(baseBalance).div(_BASE_RESERVE_);
_BASE_RESERVE_ = baseBalance;
}
if (quoteBalance != _QUOTE_RESERVE_) {
_QUOTE_TARGET_ = _QUOTE_TARGET_.mul(quoteBalance).div(_QUOTE_RESERVE_);
_QUOTE_RESERVE_ = quoteBalance;
}
}
function setTarget(uint256 baseTarget, uint256 quoteTarget) public preventReentrant onlyOwner {
_BASE_TARGET_ = baseTarget;
_QUOTE_TARGET_ = quoteTarget;

View File

@@ -45,6 +45,8 @@ interface IDPP {
function setSell(bool open) external;
function sync() external;
//==============================
function retrieve(

View File

@@ -68,6 +68,11 @@ contract DVMVault is DVMStorage {
}
}
function sync() external preventReentrant {
_sync();
}
// ============ Asset Out ============
function _transferBaseOut(address to, uint256 amount) internal {