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

View File

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

View File

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

View File

@@ -14,17 +14,17 @@ import {SafeMath} from "../../lib/SafeMath.sol";
import {SafeERC20} from "../../lib/SafeERC20.sol"; import {SafeERC20} from "../../lib/SafeERC20.sol";
import {ReentrancyGuard} from "../../lib/ReentrancyGuard.sol"; import {ReentrancyGuard} from "../../lib/ReentrancyGuard.sol";
interface IDPPOracle { // interface IDPPOracle {
function reset( // function reset(
address assetTo, // address assetTo,
uint256 newLpFeeRate, // uint256 newLpFeeRate,
uint256 newK, // uint256 newK,
uint256 baseOutAmount, // uint256 baseOutAmount,
uint256 quoteOutAmount, // uint256 quoteOutAmount,
uint256 minBaseReserve, // uint256 minBaseReserve,
uint256 minQuoteReserve // uint256 minQuoteReserve
) external returns (bool); // ) external returns (bool);
} // }
/** /**
@@ -42,6 +42,7 @@ contract DODODppProxy is ReentrancyGuard {
address constant _ETH_ADDRESS_ = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; address constant _ETH_ADDRESS_ = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
address public immutable _WETH_; address public immutable _WETH_;
address public immutable _DODO_APPROVE_PROXY_; address public immutable _DODO_APPROVE_PROXY_;
address public immutable _DPP_FACTORY_;
// ============ Modifiers ============ // ============ Modifiers ============
@@ -56,18 +57,65 @@ contract DODODppProxy is ReentrancyGuard {
constructor( constructor(
address payable weth, address payable weth,
address dodoApproveProxy address dodoApproveProxy,
address dppFactory
) public { ) public {
_WETH_ = weth; _WETH_ = weth;
_DODO_APPROVE_PROXY_ = dodoApproveProxy; _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( function resetDODOPrivatePool(
address dppAddress, 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 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 minBaseReserve,
uint256 minQuoteReserve, uint256 minQuoteReserve,
uint256 deadLine uint256 deadLine
@@ -87,10 +135,11 @@ contract DODODppProxy is ReentrancyGuard {
flag == 2 flag == 2
); );
require(IDPPOracle(IDODOV2(dppAddress)._OWNER_()).reset( require(IDODOV2(IDODOV2(dppAddress)._OWNER_()).reset(
msg.sender, msg.sender,
paramList[0], paramList[0],
paramList[1], paramList[1],
paramList[2],
amountList[2], amountList[2],
amountList[3], amountList[3],
minBaseReserve, minBaseReserve,
@@ -101,6 +150,46 @@ contract DODODppProxy is ReentrancyGuard {
_withdraw(msg.sender, IDODOV2(dppAddress)._QUOTE_TOKEN_(), amountList[3], flag == 4); _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 ======================= //====================== 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; var tx;
//ApproveProxy init以及添加ProxyList //ApproveProxy init以及添加ProxyList
const DODOApproveProxyInstance = await DODOApproveProxy.at(DODOApproveProxyAddress); const DODOApproveProxyInstance = await DODOApproveProxy.at(DODOApproveProxyAddress);

View File

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