add reset protection mechanism
This commit is contained in:
@@ -95,22 +95,26 @@ contract DPPAdmin is InitializableOwnable {
|
||||
uint256 newI,
|
||||
uint256 newK,
|
||||
uint256 baseOutAmount,
|
||||
uint256 quoteOutAmount
|
||||
) external notFreezed {
|
||||
uint256 quoteOutAmount,
|
||||
uint256 minBaseReserve,
|
||||
uint256 minQuoteReserve
|
||||
) external notFreezed returns (bool) {
|
||||
require(
|
||||
msg.sender == _OWNER_ ||
|
||||
(msg.sender == IDODOApprove(_DODO_APPROVE_).getDODOProxy() &&
|
||||
operator == _OPERATOR_),
|
||||
"RESET FORBIDDEN!"
|
||||
);
|
||||
IDPP(_DPP_).reset(
|
||||
return IDPP(_DPP_).reset(
|
||||
msg.sender,
|
||||
newLpFeeRate,
|
||||
newMtFeeRate,
|
||||
newI,
|
||||
newK,
|
||||
baseOutAmount,
|
||||
quoteOutAmount
|
||||
quoteOutAmount,
|
||||
minBaseReserve,
|
||||
minQuoteReserve
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,8 +78,11 @@ contract DPPVault is DPPStorage {
|
||||
uint256 newI,
|
||||
uint256 newK,
|
||||
uint256 baseOutAmount,
|
||||
uint256 quoteOutAmount
|
||||
) public preventReentrant onlyOwner {
|
||||
uint256 quoteOutAmount,
|
||||
uint256 minBaseReserve,
|
||||
uint256 minQuoteReserve
|
||||
) public preventReentrant onlyOwner returns (bool) {
|
||||
require(_BASE_RESERVE_ >= minBaseReserve && _QUOTE_RESERVE_ >= minQuoteReserve, "Reserve amount is not enough");
|
||||
_LP_FEE_RATE_MODEL_.setFeeRate(newLpFeeRate);
|
||||
_MT_FEE_RATE_MODEL_.setFeeRate(newMtFeeRate);
|
||||
_I_.set(newI);
|
||||
@@ -89,6 +92,7 @@ contract DPPVault is DPPStorage {
|
||||
_resetTargetAndReserve();
|
||||
_checkIK();
|
||||
emit Reset(newLpFeeRate, newMtFeeRate);
|
||||
return true;
|
||||
}
|
||||
|
||||
function _setRState() internal {
|
||||
|
||||
@@ -60,6 +60,8 @@ interface IDPP {
|
||||
uint256 newI,
|
||||
uint256 newK,
|
||||
uint256 baseOutAmount,
|
||||
uint256 quoteOutAmount
|
||||
) external;
|
||||
uint256 quoteOutAmount,
|
||||
uint256 minBaseReserve,
|
||||
uint256 minQuoteReserve
|
||||
) external returns (bool);
|
||||
}
|
||||
|
||||
@@ -258,44 +258,42 @@ contract DODOV2Proxy01 is IDODOV2Proxy01, ReentrancyGuard, InitializableOwnable
|
||||
|
||||
function resetDODOPrivatePool(
|
||||
address dppAddress,
|
||||
uint256 newLpFeeRate,
|
||||
uint256 newMtFeeRate,
|
||||
uint256 newI,
|
||||
uint256 newK,
|
||||
uint256 baseInAmount,
|
||||
uint256 quoteInAmount,
|
||||
uint256 baseOutAmount,
|
||||
uint256 quoteOutAmount,
|
||||
uint256[] memory paramList, //0 - newLpFeeRate, 1 - newMtFeeRate, 2 - newI, 3 - newK
|
||||
uint256[] memory amountList, //0 - baseInAmount, 1 - quoteInAmount, 2 - baseOutAmount, 3- quoteOutAmount
|
||||
uint8 flag, // 0 - ERC20, 1 - baseInETH, 2 - quoteInETH, 3 - baseOutETH, 4 - quoteOutETH
|
||||
uint256 minBaseReserve,
|
||||
uint256 minQuoteReserve,
|
||||
uint256 deadLine
|
||||
) external override payable preventReentrant judgeExpired(deadLine) {
|
||||
_deposit(
|
||||
msg.sender,
|
||||
dppAddress,
|
||||
IDODOV2(dppAddress)._BASE_TOKEN_(),
|
||||
baseInAmount,
|
||||
amountList[0],
|
||||
flag == 1
|
||||
);
|
||||
_deposit(
|
||||
msg.sender,
|
||||
dppAddress,
|
||||
IDODOV2(dppAddress)._QUOTE_TOKEN_(),
|
||||
quoteInAmount,
|
||||
amountList[1],
|
||||
flag == 2
|
||||
);
|
||||
|
||||
IDODOV2(IDODOV2(dppAddress)._OWNER_()).reset(
|
||||
require(IDODOV2(IDODOV2(dppAddress)._OWNER_()).reset(
|
||||
msg.sender,
|
||||
newLpFeeRate,
|
||||
newMtFeeRate,
|
||||
newI,
|
||||
newK,
|
||||
baseOutAmount,
|
||||
quoteOutAmount
|
||||
);
|
||||
paramList[0],
|
||||
paramList[1],
|
||||
paramList[2],
|
||||
paramList[3],
|
||||
amountList[2],
|
||||
amountList[3],
|
||||
minBaseReserve,
|
||||
minQuoteReserve
|
||||
), "Reset Failed");
|
||||
|
||||
_withdraw(msg.sender, IDODOV2(dppAddress)._BASE_TOKEN_(), baseOutAmount, flag == 3);
|
||||
_withdraw(msg.sender, IDODOV2(dppAddress)._QUOTE_TOKEN_(), quoteOutAmount, flag == 4);
|
||||
_withdraw(msg.sender, IDODOV2(dppAddress)._BASE_TOKEN_(), amountList[2], flag == 3);
|
||||
_withdraw(msg.sender, IDODOV2(dppAddress)._QUOTE_TOKEN_(), amountList[3], flag == 4);
|
||||
}
|
||||
|
||||
// ============ Swap ============
|
||||
|
||||
@@ -61,8 +61,10 @@ interface IDODOV2 {
|
||||
uint256 newI,
|
||||
uint256 newK,
|
||||
uint256 baseOutAmount,
|
||||
uint256 quoteOutAmount
|
||||
) external;
|
||||
uint256 quoteOutAmount,
|
||||
uint256 minBaseReserve,
|
||||
uint256 minQuoteReserve
|
||||
) external returns (bool);
|
||||
|
||||
//========== CrowdPooling ===========
|
||||
|
||||
|
||||
@@ -86,15 +86,11 @@ interface IDODOV2Proxy01 is IDODOV1Proxy01 {
|
||||
|
||||
function resetDODOPrivatePool(
|
||||
address dppAddress,
|
||||
uint256 newLpFeeRate,
|
||||
uint256 newMtFeeRate,
|
||||
uint256 newI,
|
||||
uint256 newK,
|
||||
uint256 baseInAmount,
|
||||
uint256 quoteInAmount,
|
||||
uint256 baseOutAmount,
|
||||
uint256 quoteOutAmount,
|
||||
uint256[] memory paramList, //0 - newLpFeeRate, 1 - newMtFeeRate, 2 - newI, 3 - newK
|
||||
uint256[] memory amountList, //0 - baseInAmount, 1 - quoteInAmount, 2 - baseOutAmount, 3 - quoteOutAmount
|
||||
uint8 flag, // 0 - ERC20, 1 - baseInETH, 2 - quoteInETH, 3 - baseOutETH, 4 - quoteOutETH
|
||||
uint256 minBaseReserve,
|
||||
uint256 minQuoteReserve,
|
||||
uint256 deadLine
|
||||
) external payable;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user