add cpProxy
This commit is contained in:
@@ -47,6 +47,7 @@ module.exports = {
|
||||
DODOV2Proxy: "",
|
||||
DSPProxy: "0x4599ed18F34cFE06820E3684bF0aACB8D75c644d",
|
||||
UpCpProxy: "0x26D898A37782B04d6c460E11aEeCD8f3d99e91B8",
|
||||
CpProxy: "0x471e1A083D76C4FC9e088FD259F64Eff0A37DAbD",
|
||||
|
||||
//vDODO
|
||||
DODOCirculationHelper: "0x357c5e9cfa8b834edcef7c7aabd8f9db09119d11",
|
||||
|
||||
@@ -47,6 +47,7 @@ module.exports = {
|
||||
DODOV2Proxy: "0x85CAA68ae47f047aa01C48BCaA711CA70a950fFb",
|
||||
DSPProxy: "0xC5fF477667E29df8887D258CaE593e04A1961A69",
|
||||
UpCpProxy: "0x6F9C270A13fB267216216C53e48de9e3B840aBB6",
|
||||
CpProxy: "0x648586084AC06cFC8D2A91a55EAc0ca49473eF27",
|
||||
|
||||
//vDODO
|
||||
DODOCirculationHelper: "",
|
||||
|
||||
111
contracts/SmartRoute/proxies/DODOCpProxy.sol
Normal file
111
contracts/SmartRoute/proxies/DODOCpProxy.sol
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
Copyright 2021 DODO ZOO.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
pragma solidity 0.6.9;
|
||||
|
||||
import {IDODOApproveProxy} from "../DODOApproveProxy.sol";
|
||||
import {IDODOV2} from "./../intf/IDODOV2.sol";
|
||||
import {IERC20} from "../../intf/IERC20.sol";
|
||||
import {SafeERC20} from "../../lib/SafeERC20.sol";
|
||||
import {IWETH} from "../../intf/IWETH.sol";
|
||||
import {SafeMath} from "../../lib/SafeMath.sol";
|
||||
import {SafeERC20} from "../../lib/SafeERC20.sol";
|
||||
import {ReentrancyGuard} from "../../lib/ReentrancyGuard.sol";
|
||||
|
||||
/**
|
||||
* @title DODOCpProxy
|
||||
* @author DODO Breeder
|
||||
*
|
||||
* @notice CrowdPooling Proxy
|
||||
*/
|
||||
contract DODOCpProxy is ReentrancyGuard {
|
||||
using SafeMath for uint256;
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
// ============ Storage ============
|
||||
|
||||
address constant _ETH_ADDRESS_ = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
|
||||
address public immutable _WETH_;
|
||||
address public immutable _DODO_APPROVE_PROXY_;
|
||||
address public immutable _CP_FACTORY_;
|
||||
|
||||
// ============ Modifiers ============
|
||||
|
||||
modifier judgeExpired(uint256 deadLine) {
|
||||
require(deadLine >= block.timestamp, "DODOCpProxy: EXPIRED");
|
||||
_;
|
||||
}
|
||||
|
||||
fallback() external payable {}
|
||||
|
||||
receive() external payable {}
|
||||
|
||||
constructor(
|
||||
address payable weth,
|
||||
address cpFactory,
|
||||
address dodoApproveProxy
|
||||
) public {
|
||||
_WETH_ = weth;
|
||||
_CP_FACTORY_ = cpFactory;
|
||||
_DODO_APPROVE_PROXY_ = dodoApproveProxy;
|
||||
}
|
||||
|
||||
//============ CrowdPooling Functions (create) ============
|
||||
|
||||
function createCrowdPooling(
|
||||
address baseToken,
|
||||
address quoteToken,
|
||||
uint256 baseInAmount,
|
||||
uint256[] memory timeLine,
|
||||
uint256[] memory valueList,
|
||||
bool isOpenTWAP,
|
||||
uint256 deadLine
|
||||
) external payable preventReentrant judgeExpired(deadLine) returns (address payable newCrowdPooling) {
|
||||
address _baseToken = baseToken;
|
||||
address _quoteToken = quoteToken == _ETH_ADDRESS_ ? _WETH_ : quoteToken;
|
||||
|
||||
newCrowdPooling = IDODOV2(_CP_FACTORY_).createCrowdPooling();
|
||||
|
||||
_deposit(
|
||||
msg.sender,
|
||||
newCrowdPooling,
|
||||
_baseToken,
|
||||
baseInAmount,
|
||||
false
|
||||
);
|
||||
|
||||
(bool success, ) = newCrowdPooling.call{value: msg.value}("");
|
||||
require(success, "DODOCpProxy: Transfer failed");
|
||||
|
||||
IDODOV2(_CP_FACTORY_).initCrowdPooling(
|
||||
newCrowdPooling,
|
||||
msg.sender,
|
||||
_baseToken,
|
||||
_quoteToken,
|
||||
timeLine,
|
||||
valueList,
|
||||
isOpenTWAP
|
||||
);
|
||||
}
|
||||
|
||||
//====================== internal =======================
|
||||
|
||||
function _deposit(
|
||||
address from,
|
||||
address to,
|
||||
address token,
|
||||
uint256 amount,
|
||||
bool isETH
|
||||
) internal {
|
||||
if (isETH) {
|
||||
if (amount > 0) {
|
||||
IWETH(_WETH_).deposit{value: amount}();
|
||||
if (to != address(this)) SafeERC20.safeTransfer(IERC20(_WETH_), to, amount);
|
||||
}
|
||||
} else {
|
||||
IDODOApproveProxy(_DODO_APPROVE_PROXY_).claimTokens(token, from, to, amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -435,3 +435,13 @@ Deploy time: 2021/4/27 下午2:16:05
|
||||
Deploy type: WETH9
|
||||
WETH9Address: 0x18AA6Bb215CDBd179E7beAE10F66C21B26971306
|
||||
MultiCallAddress: 0x3a60A76aCAe8feeC74D6B5b665d4DBaab2abC406
|
||||
====================================================
|
||||
network type: kovan
|
||||
Deploy time: 2021/4/29 上午12:41:17
|
||||
Deploy type: DODOCpProxy
|
||||
CpProxy address: 0x648586084AC06cFC8D2A91a55EAc0ca49473eF27
|
||||
====================================================
|
||||
network type: live
|
||||
Deploy time: 2021/4/29 上午12:47:09
|
||||
Deploy type: DODOCpProxy
|
||||
CpProxy address: 0x471e1A083D76C4FC9e088FD259F64Eff0A37DAbD
|
||||
|
||||
@@ -19,6 +19,7 @@ const MultiCall = artifacts.require("Multicall");
|
||||
const LockedTokenVault = artifacts.require("LockedTokenVault");
|
||||
const DODORouteProxy = artifacts.require("DODORouteProxy");
|
||||
const DODOUpCpProxy = artifacts.require("DODOUpCpProxy");
|
||||
const DODOCpProxy = artifacts.require("DODOCpProxy");
|
||||
|
||||
const DspTemplate = artifacts.require("DSP");
|
||||
const DspFactory = artifacts.require("DSPFactory");
|
||||
@@ -41,6 +42,7 @@ module.exports = async (deployer, network, accounts) => {
|
||||
let DvmFactoryAddress = CONFIG.DVMFactory;
|
||||
let DppFactoryAddress = CONFIG.DPPFactory;
|
||||
let UpCpFactoryAddress = CONFIG.UpCpFactory;
|
||||
let CpFactoryAddress = CONFIG.CrowdPoolingFactory;
|
||||
|
||||
|
||||
let DODOCirculationHelperAddress = CONFIG.DODOCirculationHelper;
|
||||
@@ -168,6 +170,20 @@ module.exports = async (deployer, network, accounts) => {
|
||||
logger.log("UpCpProxy address: ", DODOUpCpProxy.address);
|
||||
}
|
||||
|
||||
if (deploySwitch.CpProxy) {
|
||||
logger.log("====================================================");
|
||||
logger.log("network type: " + network);
|
||||
logger.log("Deploy time: " + new Date().toLocaleString());
|
||||
logger.log("Deploy type: DODOCpProxy");
|
||||
await deployer.deploy(
|
||||
DODOCpProxy,
|
||||
WETHAddress,
|
||||
CpFactoryAddress,
|
||||
DODOApproveProxyAddress
|
||||
);
|
||||
logger.log("CpProxy address: ", DODOCpProxy.address);
|
||||
}
|
||||
|
||||
|
||||
if (deploySwitch.UpCP) {
|
||||
logger.log("====================================================");
|
||||
|
||||
@@ -58,7 +58,8 @@ module.exports = {
|
||||
DSP: false,
|
||||
LockedVault: false,
|
||||
MULTIHOP: false,
|
||||
UpCpProxy: false
|
||||
UpCpProxy: false,
|
||||
CpProxy: true
|
||||
},
|
||||
|
||||
networks: {
|
||||
|
||||
Reference in New Issue
Block a user