add reset protection mechanism

This commit is contained in:
owen05
2020-12-18 11:27:45 +08:00
parent 83c8bbaa85
commit 0c77f9c9fe
9 changed files with 72 additions and 78 deletions

View File

@@ -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 ============

View File

@@ -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 ===========

View File

@@ -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;