This commit is contained in:
owen05
2021-10-11 15:47:30 +08:00
parent bbfe01231f
commit 484cadbe95
7 changed files with 282 additions and 130 deletions

View File

@@ -0,0 +1,68 @@
module.exports = {
BOBA_TEST_CONFIG: {
//TOKEN
WETH: "",
CHI: "0x0000000000000000000000000000000000000000",
DODO: "",
//Helper
//MultiCall: "",
//DODOSwapCalcHelper: "",
//DODOZoo: "",
//DODO: "",
//ERC20Helper: "",
DODOSellHelper: "",
DODOCalleeHelper: "",
DODOV1PmmHelper: "",
DODOV2RouteHelper: "",
CurveSample: "",
//Template
CloneFactory: "",
FeeRateModel: "",
//FeeRateDIP3: "",
PermissionManager: "",
DVM: "",
DPP: "",
DSP: "",
DPPAdmin: "",
CP: "",
//ERC20MineV2: "",
ERC20MineV3: "",
ERC20: "",
CustomERC20: "",
//Factory
DVMFactory: "",
DPPFactory: "",
DSPFactory: "",
UpCpFactory: "",
CrowdPoolingFactory: "",
ERC20V2Factory: "",
//DODOMineV2Factory: "",
DODOMineV3Registry: "",
//Approve
DODOApprove: "",
DODOApproveProxy: "",
//Adapter
DODOV1Adapter: "",
DODOV2Adapter: "",
UniAdapter: "",
CurveAdapter: "",
//Proxy
DODOV2Proxy: "",
DSPProxy: "",
CpProxy: "",
RouteProxy: "",
DODOMineV3Proxy: "",
//Account
multiSigAddress: "0x7e83d9d94837eE82F0cc18a691da6f42F03F1d86",
defaultMaintainer: "0x7e83d9d94837eE82F0cc18a691da6f42F03F1d86",
}
}

View File

@@ -8,6 +8,7 @@ const { RINKEBY_CONFIG } = require("./config/rinkeby-config");
const { OK_CONFIG } = require("./config/ok-config");
const { NEON_TEST_CONFIG } = require("./config/neon-test-config");
const { MOONRIVER_CONFIG } = require("./config/moonriver-config");
const { BOBA_TEST_CONFIG } = require("./config/boba-test-config");
exports.GetConfig = function (network, accounts) {
var CONFIG = {}
@@ -49,6 +50,11 @@ exports.GetConfig = function (network, accounts) {
CONFIG.multiSigAddress = accounts[0]
CONFIG.defaultMaintainer = accounts[0]
break;
case "boba_test":
CONFIG = BOBA_TEST_CONFIG
CONFIG.multiSigAddress = accounts[0]
CONFIG.defaultMaintainer = accounts[0]
break;
}
return CONFIG
}

View File

@@ -210,90 +210,90 @@ contract DODOV2Proxy02 is IDODOV2Proxy01, ReentrancyGuard, InitializableOwnable
// ============ DPP Functions (create & reset) ============
function createDODOPrivatePool(
address baseToken,
address quoteToken,
uint256 baseInAmount,
uint256 quoteInAmount,
uint256 lpFeeRate,
uint256 i,
uint256 k,
bool isOpenTwap,
uint256 deadLine
)
external
override
payable
preventReentrant
judgeExpired(deadLine)
returns (address newPrivatePool)
{
newPrivatePool = IDODOV2(_DPP_FACTORY_).createDODOPrivatePool();
// function createDODOPrivatePool(
// address baseToken,
// address quoteToken,
// uint256 baseInAmount,
// uint256 quoteInAmount,
// uint256 lpFeeRate,
// uint256 i,
// uint256 k,
// bool isOpenTwap,
// uint256 deadLine
// )
// external
// override
// payable
// preventReentrant
// judgeExpired(deadLine)
// returns (address newPrivatePool)
// {
// newPrivatePool = IDODOV2(_DPP_FACTORY_).createDODOPrivatePool();
address _baseToken = baseToken;
address _quoteToken = quoteToken;
_deposit(msg.sender, newPrivatePool, _baseToken, baseInAmount, _baseToken == _ETH_ADDRESS_);
_deposit(
msg.sender,
newPrivatePool,
_quoteToken,
quoteInAmount,
_quoteToken == _ETH_ADDRESS_
);
// address _baseToken = baseToken;
// address _quoteToken = quoteToken;
// _deposit(msg.sender, newPrivatePool, _baseToken, baseInAmount, _baseToken == _ETH_ADDRESS_);
// _deposit(
// msg.sender,
// newPrivatePool,
// _quoteToken,
// quoteInAmount,
// _quoteToken == _ETH_ADDRESS_
// );
if (_baseToken == _ETH_ADDRESS_) _baseToken = _WETH_;
if (_quoteToken == _ETH_ADDRESS_) _quoteToken = _WETH_;
// if (_baseToken == _ETH_ADDRESS_) _baseToken = _WETH_;
// if (_quoteToken == _ETH_ADDRESS_) _quoteToken = _WETH_;
IDODOV2(_DPP_FACTORY_).initDODOPrivatePool(
newPrivatePool,
msg.sender,
_baseToken,
_quoteToken,
lpFeeRate,
k,
i,
isOpenTwap
);
}
// IDODOV2(_DPP_FACTORY_).initDODOPrivatePool(
// newPrivatePool,
// msg.sender,
// _baseToken,
// _quoteToken,
// lpFeeRate,
// k,
// i,
// isOpenTwap
// );
// }
function resetDODOPrivatePool(
address dppAddress,
uint256[] memory paramList, //0 - newLpFeeRate, 1 - newI, 2 - 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_(),
amountList[0],
flag == 1
);
_deposit(
msg.sender,
dppAddress,
IDODOV2(dppAddress)._QUOTE_TOKEN_(),
amountList[1],
flag == 2
);
// function resetDODOPrivatePool(
// address dppAddress,
// uint256[] memory paramList, //0 - newLpFeeRate, 1 - newI, 2 - 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_(),
// amountList[0],
// flag == 1
// );
// _deposit(
// msg.sender,
// dppAddress,
// IDODOV2(dppAddress)._QUOTE_TOKEN_(),
// amountList[1],
// flag == 2
// );
require(IDODOV2(IDODOV2(dppAddress)._OWNER_()).reset(
msg.sender,
paramList[0],
paramList[1],
paramList[2],
amountList[2],
amountList[3],
minBaseReserve,
minQuoteReserve
), "Reset Failed");
// require(IDODOV2(IDODOV2(dppAddress)._OWNER_()).reset(
// msg.sender,
// paramList[0],
// paramList[1],
// paramList[2],
// amountList[2],
// amountList[3],
// minBaseReserve,
// minQuoteReserve
// ), "Reset Failed");
_withdraw(msg.sender, IDODOV2(dppAddress)._BASE_TOKEN_(), amountList[2], flag == 3);
_withdraw(msg.sender, IDODOV2(dppAddress)._QUOTE_TOKEN_(), amountList[3], 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

@@ -69,27 +69,27 @@ interface IDODOV2Proxy01 {
uint256 quoteAdjustedInAmount
);
function createDODOPrivatePool(
address baseToken,
address quoteToken,
uint256 baseInAmount,
uint256 quoteInAmount,
uint256 lpFeeRate,
uint256 i,
uint256 k,
bool isOpenTwap,
uint256 deadLine
) external payable returns (address newPrivatePool);
// function createDODOPrivatePool(
// address baseToken,
// address quoteToken,
// uint256 baseInAmount,
// uint256 quoteInAmount,
// uint256 lpFeeRate,
// uint256 i,
// uint256 k,
// bool isOpenTwap,
// uint256 deadLine
// ) external payable returns (address newPrivatePool);
function resetDODOPrivatePool(
address dppAddress,
uint256[] memory paramList, //0 - newLpFeeRate, 1 - newI, 2 - 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;
// function resetDODOPrivatePool(
// address dppAddress,
// uint256[] memory paramList, //0 - newLpFeeRate, 1 - newI, 2 - 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;
function bid(

View File

@@ -14,17 +14,17 @@ import {SafeMath} from "../../lib/SafeMath.sol";
import {SafeERC20} from "../../lib/SafeERC20.sol";
import {ReentrancyGuard} from "../../lib/ReentrancyGuard.sol";
interface IDPPOracle {
function reset(
address assetTo,
uint256 newLpFeeRate,
uint256 newK,
uint256 baseOutAmount,
uint256 quoteOutAmount,
uint256 minBaseReserve,
uint256 minQuoteReserve
) external returns (bool);
}
// interface IDPPOracle {
// function reset(
// address assetTo,
// uint256 newLpFeeRate,
// uint256 newK,
// uint256 baseOutAmount,
// uint256 quoteOutAmount,
// uint256 minBaseReserve,
// uint256 minQuoteReserve
// ) external returns (bool);
// }
/**
@@ -42,6 +42,7 @@ contract DODODppProxy is ReentrancyGuard {
address constant _ETH_ADDRESS_ = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
address public immutable _WETH_;
address public immutable _DODO_APPROVE_PROXY_;
address public immutable _DPP_FACTORY_;
// ============ Modifiers ============
@@ -56,18 +57,65 @@ contract DODODppProxy is ReentrancyGuard {
constructor(
address payable weth,
address dodoApproveProxy
address dodoApproveProxy,
address dppFactory
) public {
_WETH_ = weth;
_DODO_APPROVE_PROXY_ = dodoApproveProxy;
_DPP_FACTORY_ = dppFactory;
}
function createDODOPrivatePool(
address baseToken,
address quoteToken,
uint256 baseInAmount,
uint256 quoteInAmount,
uint256 lpFeeRate,
uint256 i,
uint256 k,
bool isOpenTwap,
uint256 deadLine
)
external
payable
preventReentrant
judgeExpired(deadLine)
returns (address newPrivatePool)
{
newPrivatePool = IDODOV2(_DPP_FACTORY_).createDODOPrivatePool();
address _baseToken = baseToken;
address _quoteToken = quoteToken;
_deposit(msg.sender, newPrivatePool, _baseToken, baseInAmount, _baseToken == _ETH_ADDRESS_);
_deposit(
msg.sender,
newPrivatePool,
_quoteToken,
quoteInAmount,
_quoteToken == _ETH_ADDRESS_
);
if (_baseToken == _ETH_ADDRESS_) _baseToken = _WETH_;
if (_quoteToken == _ETH_ADDRESS_) _quoteToken = _WETH_;
IDODOV2(_DPP_FACTORY_).initDODOPrivatePool(
newPrivatePool,
msg.sender,
_baseToken,
_quoteToken,
lpFeeRate,
k,
i,
isOpenTwap
);
}
// DPPOracle
function resetDODOPrivatePool(
address dppAddress,
uint256[] memory paramList, //0 - newLpFeeRate, 1 - newK
uint256[] memory paramList, //0 - newLpFeeRate, 1 - newI, 2 - newK
uint256[] memory amountList, //0 - baseInAmount, 1 - quoteInAmount, 2 - baseOutAmount, 3- quoteOutAmount
uint8 flag, //0 - ERC20, 1 - baseInETH, 2 - quoteInETH, 3 - baseOutETH, 4 - quoteOutETH
uint8 flag, // 0 - ERC20, 1 - baseInETH, 2 - quoteInETH, 3 - baseOutETH, 4 - quoteOutETH
uint256 minBaseReserve,
uint256 minQuoteReserve,
uint256 deadLine
@@ -87,10 +135,11 @@ contract DODODppProxy is ReentrancyGuard {
flag == 2
);
require(IDPPOracle(IDODOV2(dppAddress)._OWNER_()).reset(
require(IDODOV2(IDODOV2(dppAddress)._OWNER_()).reset(
msg.sender,
paramList[0],
paramList[1],
paramList[2],
amountList[2],
amountList[3],
minBaseReserve,
@@ -101,6 +150,46 @@ contract DODODppProxy is ReentrancyGuard {
_withdraw(msg.sender, IDODOV2(dppAddress)._QUOTE_TOKEN_(), amountList[3], flag == 4);
}
// DPPOracle
// function resetDODOPrivatePool(
// address dppAddress,
// uint256[] memory paramList, //0 - newLpFeeRate, 1 - 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 preventReentrant judgeExpired(deadLine) {
// _deposit(
// msg.sender,
// dppAddress,
// IDODOV2(dppAddress)._BASE_TOKEN_(),
// amountList[0],
// flag == 1
// );
// _deposit(
// msg.sender,
// dppAddress,
// IDODOV2(dppAddress)._QUOTE_TOKEN_(),
// amountList[1],
// flag == 2
// );
// require(IDPPOracle(IDODOV2(dppAddress)._OWNER_()).reset(
// msg.sender,
// paramList[0],
// paramList[1],
// amountList[2],
// amountList[3],
// minBaseReserve,
// minQuoteReserve
// ), "Reset Failed");
// _withdraw(msg.sender, IDODOV2(dppAddress)._BASE_TOKEN_(), amountList[2], flag == 3);
// _withdraw(msg.sender, IDODOV2(dppAddress)._QUOTE_TOKEN_(), amountList[3], flag == 4);
// }
//====================== internal =======================

View File

@@ -461,7 +461,7 @@ module.exports = async (deployer, network, accounts) => {
}
if (network == 'kovan' || network == 'rinkeby') {
if (network == 'kovan' || network == 'rinkeby' ||network == "boba_test") {
var tx;
//ApproveProxy init以及添加ProxyList
const DODOApproveProxyInstance = await DODOApproveProxy.at(DODOApproveProxyAddress);

View File

@@ -40,7 +40,7 @@ module.exports = {
*/
deploySwitch: {
DEPLOY_V1: false,
DEPLOY_V2: false,
DEPLOY_V2: true,
MOCK_TOKEN: false,
MOCK_V2_POOL: false,
vDODOToken: false,
@@ -166,12 +166,12 @@ module.exports = {
skipDryRun: true
},
omgTest: {
boba_test: {
networkCheckTimeout: 100000,
provider: () => {
return new HDWalletProvider(privKey, 'https://rinkeby.omgx.network')
return new HDWalletProvider(privKey, 'https://rinkeby-v2.boba.network')
},
network_id: 28,
network_id: 420,
gasPrice: 0,
},
@@ -184,17 +184,6 @@ module.exports = {
gasPrice: 0,
},
arbtest: {
provider: function () {
return wrapProvider(
new HDWalletProvider(privKey, "https://kovan4.arbitrum.io/rpc")
)
},
network_id: '212984383488152',
gas: 1000000000,
gasPrice: 0,
},
arb: {
networkCheckTimeout: 100000,
// provider: function () {