refactor mixSwap && add trade adapter
This commit is contained in:
BIN
audit/PeckShield-Audit-DODOV2-v1.0.pdf
Executable file
BIN
audit/PeckShield-Audit-DODOV2-v1.0.pdf
Executable file
Binary file not shown.
@@ -23,6 +23,7 @@ import {DecimalMath} from "../lib/DecimalMath.sol";
|
||||
import {ReentrancyGuard} from "../lib/ReentrancyGuard.sol";
|
||||
import {InitializableOwnable} from "../lib/InitializableOwnable.sol";
|
||||
import {IDODOIncentive} from "./DODOIncentive.sol";
|
||||
import {IDODOAdapter} from "./intf/IDODOAdapter.sol";
|
||||
|
||||
/**
|
||||
* @title DODOV2Proxy01
|
||||
@@ -602,76 +603,70 @@ contract DODOV2Proxy01 is IDODOV2Proxy01, ReentrancyGuard, InitializableOwnable
|
||||
emit OrderHistory(_fromToken, _toToken, msg.sender, fromTokenAmount, returnAmount);
|
||||
}
|
||||
|
||||
function mixSwapV1(
|
||||
|
||||
function mixSwap(
|
||||
address fromToken,
|
||||
address toToken,
|
||||
uint256 fromTokenAmount,
|
||||
uint256 minReturnAmount,
|
||||
address[] memory mixAdapters,
|
||||
address[] memory mixPairs,
|
||||
uint256[] memory directions,
|
||||
address[] memory portionPath,
|
||||
uint256 directions,
|
||||
bool isIncentive,
|
||||
uint256 deadLine
|
||||
) external override payable judgeExpired(deadLine) returns (uint256 returnAmount) {
|
||||
require(mixPairs.length == directions.length, "DODOV2Proxy01: PARAMS_LENGTH_NOT_MATCH");
|
||||
require(mixPairs.length > 0, "DODOV2Proxy01: PAIRS_EMPTY");
|
||||
require(mixPairs.length == mixAdapters.length, "DODOV2Proxy01: ADAPTER_PAIR_NOT_MATCH");
|
||||
require(minReturnAmount > 0, "DODOV2Proxy01: RETURN_AMOUNT_ZERO");
|
||||
|
||||
uint256 toTokenOriginBalance = IERC20(toToken).universalBalanceOf(msg.sender);
|
||||
|
||||
|
||||
{
|
||||
address _fromToken = fromToken;
|
||||
address _toToken = toToken;
|
||||
_deposit(msg.sender, address(this), _fromToken, fromTokenAmount, _fromToken == _ETH_ADDRESS_);
|
||||
_deposit(msg.sender, mixPairs[0], _fromToken, fromTokenAmount, _fromToken == _ETH_ADDRESS_);
|
||||
}
|
||||
|
||||
for (uint8 i = 0; i < mixPairs.length; i++) {
|
||||
address curPair = mixPairs[i];
|
||||
if (directions[i] == 0) {
|
||||
address curDodoBase = IDODOV1(curPair)._BASE_TOKEN_();
|
||||
uint256 curAmountIn = IERC20(curDodoBase).balanceOf(address(this));
|
||||
IERC20(curDodoBase).universalApproveMax(curPair, curAmountIn);
|
||||
IDODOV1(curPair).sellBaseToken(curAmountIn, 0, "");
|
||||
} else if(directions[i] == 1){
|
||||
address curDodoQuote = IDODOV1(curPair)._QUOTE_TOKEN_();
|
||||
uint256 curAmountIn = IERC20(curDodoQuote).balanceOf(address(this));
|
||||
IERC20(curDodoQuote).universalApproveMax(curPair, curAmountIn);
|
||||
uint256 canBuyBaseAmount = IDODOSellHelper(_DODO_SELL_HELPER_).querySellQuoteToken(
|
||||
curPair,
|
||||
curAmountIn
|
||||
);
|
||||
IDODOV1(curPair).buyBaseToken(canBuyBaseAmount, curAmountIn, "");
|
||||
address assetTo = toToken == _ETH_ADDRESS_ ? address(this): msg.sender;
|
||||
for (uint256 i = 0; i < mixPairs.length; i++) {
|
||||
if (i == mixPairs.length - 1) {
|
||||
if (directions & 1 == 0) {
|
||||
IDODOAdapter(mixAdapters[i]).sellBase(assetTo,mixPairs[i]);
|
||||
} else {
|
||||
IDODOAdapter(mixAdapters[i]).sellQuote(assetTo,mixPairs[i]);
|
||||
}
|
||||
} else {
|
||||
uint256 curAmountIn = IERC20(portionPath[0]).balanceOf(address(this));
|
||||
IERC20(portionPath[0]).universalApproveMax(curPair, curAmountIn);
|
||||
IUni(curPair).swapExactTokensForTokens(curAmountIn,0,portionPath,address(this),deadLine);
|
||||
if (directions& 1 == 0) {
|
||||
IDODOAdapter(mixAdapters[i]).sellBase(mixPairs[i + 1],mixPairs[i]);
|
||||
} else {
|
||||
IDODOAdapter(mixAdapters[i]).sellQuote(mixPairs[i + 1],mixPairs[i]);
|
||||
}
|
||||
}
|
||||
directions = directions >> 1;
|
||||
}
|
||||
|
||||
IERC20(_toToken).universalTransfer(
|
||||
msg.sender,
|
||||
IERC20(_toToken).universalBalanceOf(address(this))
|
||||
);
|
||||
|
||||
// {
|
||||
// uint256 toBalance;
|
||||
// if (_toToken == _ETH_ADDRESS_) {
|
||||
// toBalance = IWETH(_WETH_).balanceOf(address(this));
|
||||
// IWETH(_WETH_).withdraw(toBalance);
|
||||
// } else {
|
||||
// toBalance = IERC20(_toToken).tokenBalanceOf(address(this));
|
||||
// }
|
||||
// IERC20(_toToken).universalTransfer(msg.sender,toBalance);
|
||||
// }
|
||||
if(toToken == _ETH_ADDRESS_) {
|
||||
returnAmount = IWETH(_WETH_).balanceOf(address(this));
|
||||
IWETH(_WETH_).withdraw(returnAmount);
|
||||
msg.sender.transfer(returnAmount);
|
||||
}else {
|
||||
returnAmount = IERC20(toToken).tokenBalanceOf(msg.sender).sub(toTokenOriginBalance);
|
||||
}
|
||||
|
||||
returnAmount = IERC20(_toToken).universalBalanceOf(msg.sender).sub(toTokenOriginBalance);
|
||||
require(returnAmount >= minReturnAmount, "DODOV2Proxy01: Return amount is not enough");
|
||||
|
||||
|
||||
_externalGasReturn();
|
||||
|
||||
|
||||
if(isIncentive) {
|
||||
IDODOIncentive(_DODO_INCENTIVE_).triggerIncentive(_fromToken,_toToken,msg.sender);
|
||||
IDODOIncentive(_DODO_INCENTIVE_).triggerIncentive(fromToken,toToken,msg.sender);
|
||||
}
|
||||
|
||||
emit OrderHistory(_fromToken, _toToken, msg.sender, fromTokenAmount, returnAmount);
|
||||
|
||||
emit OrderHistory(
|
||||
fromToken,
|
||||
toToken,
|
||||
msg.sender,
|
||||
fromTokenAmount,
|
||||
returnAmount
|
||||
);
|
||||
}
|
||||
|
||||
//============ CrowdPooling Functions (create & bid) ============
|
||||
|
||||
52
contracts/SmartRoute/adapter/DODOV1Adapter.sol
Normal file
52
contracts/SmartRoute/adapter/DODOV1Adapter.sol
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
|
||||
Copyright 2020 DODO ZOO.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity 0.6.9;
|
||||
|
||||
import {IERC20} from "../../intf/IERC20.sol";
|
||||
import {IDODOV1} from "../intf/IDODOV1.sol";
|
||||
import {IDODOSellHelper} from "../helper/DODOSellHelper.sol";
|
||||
import {UniversalERC20} from "../lib/UniversalERC20.sol";
|
||||
import {SafeMath} from "../../lib/SafeMath.sol";
|
||||
import {IDODOAdapter} from "../intf/IDODOAdapter.sol";
|
||||
|
||||
contract DODOV1Adapter is IDODOAdapter {
|
||||
using SafeMath for uint256;
|
||||
using UniversalERC20 for IERC20;
|
||||
|
||||
address public immutable _DODO_SELL_HELPER_;
|
||||
|
||||
constructor(address dodoSellHelper) public {
|
||||
_DODO_SELL_HELPER_ = dodoSellHelper;
|
||||
}
|
||||
|
||||
function sellBase(address to, address pool) external override {
|
||||
address curBase = IDODOV1(pool)._BASE_TOKEN_();
|
||||
uint256 curAmountIn = IERC20(curBase).balanceOf(address(this));
|
||||
IERC20(curBase).universalApproveMax(pool, curAmountIn);
|
||||
IDODOV1(pool).sellBaseToken(curAmountIn, 0, "");
|
||||
if(to == msg.sender) {
|
||||
address curQuote = IDODOV1(pool)._QUOTE_TOKEN_();
|
||||
IERC20(curQuote).transfer(to,IERC20(curQuote).balanceOf(address(this)));
|
||||
}
|
||||
}
|
||||
|
||||
function sellQuote(address to, address pool) external override {
|
||||
address curQuote = IDODOV1(pool)._QUOTE_TOKEN_();
|
||||
uint256 curAmountIn = IERC20(curQuote).balanceOf(address(this));
|
||||
IERC20(curQuote).universalApproveMax(pool, curAmountIn);
|
||||
uint256 canBuyBaseAmount = IDODOSellHelper(_DODO_SELL_HELPER_).querySellQuoteToken(
|
||||
pool,
|
||||
curAmountIn
|
||||
);
|
||||
IDODOV1(pool).buyBaseToken(canBuyBaseAmount, curAmountIn, "");
|
||||
if(to == msg.sender) {
|
||||
address curBase = IDODOV1(pool)._BASE_TOKEN_();
|
||||
IERC20(curBase).transfer(to,IERC20(curBase).balanceOf(address(this)));
|
||||
}
|
||||
}
|
||||
}
|
||||
21
contracts/SmartRoute/adapter/DODOV2Adapter.sol
Normal file
21
contracts/SmartRoute/adapter/DODOV2Adapter.sol
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
|
||||
Copyright 2020 DODO ZOO.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity 0.6.9;
|
||||
|
||||
import {IDODOV2} from "../intf/IDODOV2.sol";
|
||||
import {IDODOAdapter} from "../intf/IDODOAdapter.sol";
|
||||
|
||||
contract DODOV2Adapter is IDODOAdapter {
|
||||
function sellBase(address to, address pool) external override {
|
||||
IDODOV2(pool).sellBase(to);
|
||||
}
|
||||
|
||||
function sellQuote(address to, address pool) external override {
|
||||
IDODOV2(pool).sellQuote(to);
|
||||
}
|
||||
}
|
||||
49
contracts/SmartRoute/adapter/UniAdapter.sol
Normal file
49
contracts/SmartRoute/adapter/UniAdapter.sol
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
|
||||
Copyright 2020 DODO ZOO.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity 0.6.9;
|
||||
|
||||
import {IDODOAdapter} from "../intf/IDODOAdapter.sol";
|
||||
import {IUni} from "../intf/IUni.sol";
|
||||
import {IERC20} from "../../intf/IERC20.sol";
|
||||
import {SafeMath} from "../../lib/SafeMath.sol";
|
||||
|
||||
contract UniAdapter is IDODOAdapter {
|
||||
using SafeMath for uint;
|
||||
|
||||
//fromToken == token0
|
||||
function sellBase(address to, address pool) external override {
|
||||
address baseToken = IUni(pool).token0();
|
||||
(uint reserveIn, uint reserveOut,) = IUni(pool).getReserves();
|
||||
require(reserveIn > 0 && reserveOut > 0, 'UniAdapter: INSUFFICIENT_LIQUIDITY');
|
||||
|
||||
uint balance0 = IERC20(baseToken).balanceOf(pool);
|
||||
uint sellBaseAmount = balance0 - reserveIn;
|
||||
|
||||
uint sellBaseAmountWithFee = sellBaseAmount.mul(997);
|
||||
uint numerator = sellBaseAmountWithFee.mul(reserveOut);
|
||||
uint denominator = reserveIn.mul(1000).add(sellBaseAmountWithFee);
|
||||
uint receiveQuoteAmount = numerator / denominator;
|
||||
IUni(pool).swap(0, receiveQuoteAmount, to, new bytes(0));
|
||||
}
|
||||
|
||||
//fromToken == token1
|
||||
function sellQuote(address to, address pool) external override {
|
||||
address quoteToken = IUni(pool).token1();
|
||||
(uint reserveOut, uint reserveIn,) = IUni(pool).getReserves();
|
||||
require(reserveIn > 0 && reserveOut > 0, 'UniAdapter: INSUFFICIENT_LIQUIDITY');
|
||||
|
||||
uint balance1 = IERC20(quoteToken).balanceOf(pool);
|
||||
uint sellQuoteAmount = balance1 - reserveIn;
|
||||
|
||||
uint sellQuoteAmountWithFee = sellQuoteAmount.mul(997);
|
||||
uint numerator = sellQuoteAmountWithFee.mul(reserveOut);
|
||||
uint denominator = reserveIn.mul(1000).add(sellQuoteAmountWithFee);
|
||||
uint receiveBaseAmount = numerator / denominator;
|
||||
IUni(pool).swap(receiveBaseAmount, 0, to, new bytes(0));
|
||||
}
|
||||
}
|
||||
16
contracts/SmartRoute/intf/IDODOAdapter.sol
Normal file
16
contracts/SmartRoute/intf/IDODOAdapter.sol
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
|
||||
Copyright 2020 DODO ZOO.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity 0.6.9;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
interface IDODOAdapter {
|
||||
|
||||
function sellBase(address to, address pool) external;
|
||||
|
||||
function sellQuote(address to, address pool) external;
|
||||
}
|
||||
@@ -138,14 +138,14 @@ interface IDODOV2Proxy01 {
|
||||
uint256 deadLine
|
||||
) external payable returns (uint256 returnAmount);
|
||||
|
||||
function mixSwapV1(
|
||||
function mixSwap(
|
||||
address fromToken,
|
||||
address toToken,
|
||||
uint256 fromTokenAmount,
|
||||
uint256 minReturnAmount,
|
||||
address[] memory mixAdapters,
|
||||
address[] memory mixPairs,
|
||||
uint256[] memory directions,
|
||||
address[] memory portionPath,
|
||||
uint256 directions,
|
||||
bool isIncentive,
|
||||
uint256 deadLine
|
||||
) external payable returns (uint256 returnAmount);
|
||||
|
||||
@@ -9,4 +9,12 @@ interface IUni {
|
||||
address to,
|
||||
uint deadline
|
||||
) external returns (uint[] memory amounts);
|
||||
|
||||
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
|
||||
|
||||
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
|
||||
|
||||
function token0() external view returns (address);
|
||||
|
||||
function token1() external view returns (address);
|
||||
}
|
||||
@@ -16,9 +16,6 @@ contract FeeRateModelLogic is ReentrancyGuard,InitializableOwnable {
|
||||
uint256 public _FEE_RATE_;
|
||||
mapping(address => uint256) feeMapping;
|
||||
|
||||
|
||||
event Log(string str, bool result);
|
||||
|
||||
function setSpecificFeeRate(address trader, uint256 feeRate) external onlyOwner {
|
||||
require(trader != address(0), "INVALID ADDRESS!");
|
||||
feeMapping[trader] = feeRate;
|
||||
|
||||
@@ -17,9 +17,6 @@ contract FeeRateModelLogicUpdate is ReentrancyGuard ,InitializableOwnable{
|
||||
uint256 public _FEE_RATE_;
|
||||
mapping(address => uint256) feeMapping;
|
||||
|
||||
|
||||
event Log(string str, bool result);
|
||||
|
||||
function setSpecificFeeRate(address trader, uint256 feeRate) external onlyOwner {
|
||||
require(trader != address(0), "INVALID ADDRESS!");
|
||||
feeMapping[trader] = 0;
|
||||
|
||||
@@ -294,3 +294,25 @@ Create DPP: 0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA-0x156595bAF85D5C29E91d959
|
||||
====================================================
|
||||
network type: kovan
|
||||
Deploy time: 2021/1/13 下午8:37:27
|
||||
====================================================
|
||||
network type: kovan
|
||||
Deploy time: 2021/1/13 下午8:45:21
|
||||
Mock POOL Tx: V2
|
||||
Approve:0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE Tx: 0x713758a969dd87b682fff12535aec26b068cabfac7e623759105e02925108796
|
||||
Approve:0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA Tx: 0xa69a799bc1bad6873a972aee79ac77f53960df61caa69330c712c098e933b079
|
||||
Approve:0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b Tx: 0x58a13285f365d9b0955f10523984758412f9a8776b261e89c5d7e09c7dc9bbee
|
||||
Approve:0x156595bAF85D5C29E91d959889B022d952190A64 Tx: 0xb7db2b7a86e675a9ed8ae9e573f9e33337b79c3dea037c9a9df91ffb2f8cf456
|
||||
Create DVM: 0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE-0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b Pool:0x06FC88aA4598d176e3D936823ea8C62EBb4e9096 Tx: 0xea949b9890895450666a37b7ecaa39a530cbf14d6a64dd7ecec9d02af7ff43a2
|
||||
Create DVM: 0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE-0x156595bAF85D5C29E91d959889B022d952190A64 Pool:0x44Fe35FD06878b4FD1FC85C66C8a8991E96363A8 Tx: 0x1a75e771132f0d77d8eb6ae961d25218508953cbe1f9b47720ee77d4dbb52566
|
||||
Create DVM: 0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA-0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b Pool:0x40e98099713F3b26796d2460df2fd5D0f41d22E6 Tx: 0xeeed9aa66c6ec98fe3ac7d4bff8050fae6afaac98d416006454b645899614dcc
|
||||
Create DVM: 0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA-0x156595bAF85D5C29E91d959889B022d952190A64 Pool:0x0fa0Fb4230d890f2098A09C125ef8dE4C54ed65A Tx: 0xa36501c62683d11fcc37fe14bb4d5c0b35514c1801cb30ae2439eead9b3f0dfe
|
||||
Create DPP: 0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE-0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b Pool:0x7E70B7d95847c4688fc111aB2A670855bB1F8425 Tx: 0x1b3f3fea46d3d8329c82b6390355e8170a6cbf8492834d7d9f923f915867ad34
|
||||
Create DPP: 0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE-0x156595bAF85D5C29E91d959889B022d952190A64 Pool:0x312593a0045646aF845bA80Ca3995b68B6C37d8F Tx: 0x8959fc0b0ef347734e64668e4150fd1586329aa7e102286588174cc800e5417f
|
||||
Create DPP: 0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA-0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b Pool:0xF3560C11F6683D5A80cDD2A2dDEcb15863f9cE9D Tx: 0x6f4c01c6c99340e966aee06d88a9889512550aafc733259d280edd1a1a816411
|
||||
Create DPP: 0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA-0x156595bAF85D5C29E91d959889B022d952190A64 Pool:0x9a5905c9027ED43bB08088cee5EEa71342152280 Tx: 0x533f85a0489a1441a2cdd6f82d1b0b0a7110ed833391cf2448ad9f9526ae6fc7
|
||||
====================================================
|
||||
network type: kovan
|
||||
Deploy time: 2021/1/13 下午9:51:04
|
||||
Mock POOL Tx: V2
|
||||
Create DVM: 0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE-0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b Pool:0xec6675ba2B9f978EF5bFBEa391b1c42bA74E340A Tx: 0xd417e65c4e437a1e2ea2432c149393869d6d6b8d5de68cd361455395a2441e7b
|
||||
Create DVM: 0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA-0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b Pool:0xF4833EDaEfdBf28e246ade2d82EA7087Bc106C8F Tx: 0xad1ce8f0fbd5b937055f62a0c4e6024ef32cdf40bcbb8033cbeccdbf314ce9c3
|
||||
|
||||
@@ -69,7 +69,7 @@ module.exports = async (deployer, network, accounts) => {
|
||||
WETHAddress = "0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b";
|
||||
chiAddress = "0x0000000000004946c0e9f43f4dee607b0ef1fa1c";
|
||||
DODOCalleeHelperAddress = "0x507EBbb195CF54E0aF147A2b269C08a38EA36989";
|
||||
DODORouteV2HelperAddress = "";
|
||||
DODORouteV2HelperAddress = "0xcA79C9431aB16857f78f9F7EE56Ff698bD518533";
|
||||
//Template
|
||||
CloneFactoryAddress = "0xf7959fe661124C49F96CF30Da33729201aEE1b27";
|
||||
// FeeRateModelTemplateAddress = "0xEF3137780B387313c5889B999D03BdCf9aeEa892";
|
||||
@@ -81,14 +81,14 @@ module.exports = async (deployer, network, accounts) => {
|
||||
DefaultMtFeeRateAddress = "0xEfdE4225AC747136289979e29f1236527b2E4DB1";
|
||||
DefaultPermissionAddress = "0xACc7E23368261e1E02103c4e5ae672E7D01f5797";
|
||||
|
||||
DvmTemplateAddress = "";
|
||||
DppTemplateAddress = "";
|
||||
DppAdminTemplateAddress = "";
|
||||
CpTemplateAddress = "";
|
||||
DvmTemplateAddress = "0xC61dD1a8C0242785E290CA41bA84AB319c94FF55";
|
||||
DppTemplateAddress = "0xF89DBd5e716748A5C0d8a081bED1BF554B50dc59";
|
||||
DppAdminTemplateAddress = "0xe39E02c4f269c4E235Ca8979a125608644c8924a";
|
||||
CpTemplateAddress = "0x55f940C2244Bb16735baCF7D090134fe636d47ea";
|
||||
//Factory
|
||||
DvmFactoryAddress = "";
|
||||
DppFactoryAddress = "";
|
||||
CpFactoryAddress = "";
|
||||
DvmFactoryAddress = "0xdd3dDDaae565E7745b2cAcD980B8a98546bAb978";
|
||||
DppFactoryAddress = "0x36ab096ADBfd1491FE90F56a9C782dE7b1019f7c";
|
||||
CpFactoryAddress = "0xDaB9B619A78Fca5FC2f562C5b41Bf44f74c1c239";
|
||||
//Approve
|
||||
DODOApproveAddress = "";
|
||||
DODOIncentiveAddress = "";
|
||||
|
||||
@@ -13,48 +13,48 @@ const DVMFactory = artifacts.require("DVMFactory");
|
||||
const DPPFactory = artifacts.require("DPPFactory");
|
||||
|
||||
const POOL_PARAM = [
|
||||
{
|
||||
baseAddr: "0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE", //ABC0
|
||||
quoteAddr: "0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b", //USDC
|
||||
lpFeeRate: "0", //0
|
||||
i: "10000000", //10
|
||||
k: "500000000000000000" //0.5
|
||||
},
|
||||
{
|
||||
baseAddr: "0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE", //ABC0
|
||||
quoteAddr: "0x156595bAF85D5C29E91d959889B022d952190A64", //USDT
|
||||
lpFeeRate: "3000000000000000", //0.003
|
||||
i: "10000000", //10
|
||||
k: "0" //0
|
||||
},
|
||||
{
|
||||
baseAddr: "0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA", //ABC1
|
||||
quoteAddr: "0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b", //USDC
|
||||
lpFeeRate: "0", //0
|
||||
i: "5000000", //5
|
||||
k: "1000000000000000000" //1
|
||||
},
|
||||
{
|
||||
baseAddr: "0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA", //ABC1
|
||||
quoteAddr: "0x156595bAF85D5C29E91d959889B022d952190A64", //USDT
|
||||
lpFeeRate: "3000000000000000", //0.003
|
||||
i: "8000000", //8
|
||||
k: "900000000000000000" //0.9
|
||||
},
|
||||
// {
|
||||
// baseAddr: "0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE", //ABC0
|
||||
// quoteAddr: "0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b", //WETH
|
||||
// quoteAddr: "0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b", //USDC
|
||||
// lpFeeRate: "0", //0
|
||||
// i: "10000000", //10
|
||||
// k: "500000000000000000" //0.5
|
||||
// },
|
||||
// {
|
||||
// baseAddr: "0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE", //ABC0
|
||||
// quoteAddr: "0x156595bAF85D5C29E91d959889B022d952190A64", //USDT
|
||||
// lpFeeRate: "3000000000000000", //0.003
|
||||
// i: "45000000000000000000", //45
|
||||
// k: "800000000000000000" //0.8
|
||||
// i: "10000000", //10
|
||||
// k: "0" //0
|
||||
// },
|
||||
// {
|
||||
// baseAddr: "0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA", //ABC1
|
||||
// quoteAddr: "0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b", //WETH
|
||||
// lpFeeRate: "0", //0.003
|
||||
// i: "30000000000000000000", //30
|
||||
// k: "300000000000000000" //0.3
|
||||
// quoteAddr: "0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b", //USDC
|
||||
// lpFeeRate: "0", //0
|
||||
// i: "5000000", //5
|
||||
// k: "700000000000000000" //1
|
||||
// },
|
||||
// {
|
||||
// baseAddr: "0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA", //ABC1
|
||||
// quoteAddr: "0x156595bAF85D5C29E91d959889B022d952190A64", //USDT
|
||||
// lpFeeRate: "3000000000000000", //0.003
|
||||
// i: "8000000", //8
|
||||
// k: "900000000000000000" //0.9
|
||||
// },
|
||||
{
|
||||
baseAddr: "0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE", //ABC0
|
||||
quoteAddr: "0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b", //WETH
|
||||
lpFeeRate: "3000000000000000", //0.003
|
||||
i: "45000000000000000000", //45
|
||||
k: "800000000000000000" //0.8
|
||||
},
|
||||
{
|
||||
baseAddr: "0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA", //ABC1
|
||||
quoteAddr: "0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b", //WETH
|
||||
lpFeeRate: "0", //0.003
|
||||
i: "30000000000000000000", //30
|
||||
k: "300000000000000000" //0.3
|
||||
},
|
||||
];
|
||||
|
||||
module.exports = async (deployer, network, accounts) => {
|
||||
@@ -64,10 +64,10 @@ module.exports = async (deployer, network, accounts) => {
|
||||
let MintableERC20TemplateAddress = "0xA45a64DAba80757432fA4d654Df12f65f020C13C";
|
||||
let ERC20FactoryAddress = "0xCb1A2f64EfB02803276BFB5a8D511C4D950282a0";
|
||||
|
||||
let DPPFactoryAddress = "0x6D4a70354cd03ae3A8461eDE9A4dAd445a169a6B";
|
||||
let DVMFactoryAddress = "0x0ac46584e4566d5841E7D708Ab4D92Ef191fFe37";
|
||||
let DODOApproveAddress = "0xe51d8085aB43AC8BC98e965b2F7B79b998c23814";
|
||||
let DODOProxyV2Address = "0xB035847e685925647AaA8b9d74e3bFF36f81EBcB";
|
||||
let DPPFactoryAddress = "0x36ab096ADBfd1491FE90F56a9C782dE7b1019f7c";
|
||||
let DVMFactoryAddress = "0xdd3dDDaae565E7745b2cAcD980B8a98546bAb978";
|
||||
let DODOApproveAddress = "0xFa3C805fDE678E93C3d0954F20471799f892F81d";
|
||||
let DODOProxyV2Address = "0x06B5D7590297F7b0DcEcC5E382938EB562D91e1a";
|
||||
|
||||
const provider = new Web3.providers.HttpProvider("https://kovan.infura.io/v3/22d4a3b2df0e47b78d458f43fe50a199");
|
||||
|
||||
@@ -112,49 +112,49 @@ module.exports = async (deployer, network, accounts) => {
|
||||
if (deploySwitch.MOCK_V2_POOL) {
|
||||
logger.log("Mock POOL Tx: V2");
|
||||
var tx;
|
||||
{//Approve when change DODOApprove Address
|
||||
const token0Addr = "0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE";
|
||||
const token1Addr = "0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA";
|
||||
const token2Addr = "0xFE1133ea03d701C5006b7f065bBf987955E7A67C";
|
||||
const token3Addr = "0x123ee47BaE3F64d422F2FB18ac444B47c1880F4C";
|
||||
const token4Addr = "0x0ab8EF8B19655F32959c83e5fC5cD6536065D28f";
|
||||
const token5Addr = "0x6462794c19e6b4543BEC56200212c7c746bbB9eB";
|
||||
const quote0Addr = "0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b";
|
||||
const quote1Addr = "0x156595bAF85D5C29E91d959889B022d952190A64";
|
||||
const token0 = await ERC20Template.at(token0Addr);
|
||||
const token1 = await ERC20Template.at(token1Addr);
|
||||
const token2 = await ERC20Template.at(token2Addr);
|
||||
const token3 = await ERC20Template.at(token3Addr);
|
||||
const token4 = await ERC20Template.at(token4Addr);
|
||||
const token5 = await ERC20Template.at(token5Addr);
|
||||
const quote0 = await ERC20Template.at(quote0Addr);
|
||||
const quote1 = await ERC20Template.at(quote1Addr);
|
||||
// {//Approve when change DODOApprove Address
|
||||
// const token0Addr = "0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE";
|
||||
// const token1Addr = "0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA";
|
||||
// // const token2Addr = "0xFE1133ea03d701C5006b7f065bBf987955E7A67C";
|
||||
// // const token3Addr = "0x123ee47BaE3F64d422F2FB18ac444B47c1880F4C";
|
||||
// // const token4Addr = "0x0ab8EF8B19655F32959c83e5fC5cD6536065D28f";
|
||||
// // const token5Addr = "0x6462794c19e6b4543BEC56200212c7c746bbB9eB";
|
||||
// const quote0Addr = "0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b";
|
||||
// const quote1Addr = "0x156595bAF85D5C29E91d959889B022d952190A64";
|
||||
// const token0 = await ERC20Template.at(token0Addr);
|
||||
// const token1 = await ERC20Template.at(token1Addr);
|
||||
// // const token2 = await ERC20Template.at(token2Addr);
|
||||
// // const token3 = await ERC20Template.at(token3Addr);
|
||||
// // const token4 = await ERC20Template.at(token4Addr);
|
||||
// // const token5 = await ERC20Template.at(token5Addr);
|
||||
// const quote0 = await ERC20Template.at(quote0Addr);
|
||||
// const quote1 = await ERC20Template.at(quote1Addr);
|
||||
|
||||
tx = await token0.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
logger.log("Approve:" + token0Addr + " Tx:", tx.tx);
|
||||
tx = await token1.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
logger.log("Approve:" + token1Addr + " Tx:", tx.tx);
|
||||
tx = await token2.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
logger.log("Approve:" + token2Addr + " Tx:", tx.tx);
|
||||
tx = await token3.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
logger.log("Approve:" + token3Addr + " Tx:", tx.tx);
|
||||
tx = await token4.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
logger.log("Approve:" + token4Addr + " Tx:", tx.tx);
|
||||
tx = await token5.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
logger.log("Approve:" + token5Addr + " Tx:", tx.tx);
|
||||
tx = await quote0.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
logger.log("Approve:" + quote0Addr + " Tx:", tx.tx);
|
||||
tx = await quote1.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
logger.log("Approve:" + quote1Addr + " Tx:", tx.tx);
|
||||
}
|
||||
// tx = await token0.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
// logger.log("Approve:" + token0Addr + " Tx:", tx.tx);
|
||||
// tx = await token1.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
// logger.log("Approve:" + token1Addr + " Tx:", tx.tx);
|
||||
// // tx = await token2.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
// // logger.log("Approve:" + token2Addr + " Tx:", tx.tx);
|
||||
// // tx = await token3.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
// // logger.log("Approve:" + token3Addr + " Tx:", tx.tx);
|
||||
// // tx = await token4.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
// // logger.log("Approve:" + token4Addr + " Tx:", tx.tx);
|
||||
// // tx = await token5.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
// // logger.log("Approve:" + token5Addr + " Tx:", tx.tx);
|
||||
// tx = await quote0.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
// logger.log("Approve:" + quote0Addr + " Tx:", tx.tx);
|
||||
// tx = await quote1.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
// logger.log("Approve:" + quote1Addr + " Tx:", tx.tx);
|
||||
// }
|
||||
const DODOProxyV2Instance = await DODOProxyV2.at(DODOProxyV2Address);
|
||||
const DVMFactoryInstance = await DVMFactory.at(DVMFactoryAddress);
|
||||
const DPPFactoryInstance = await DPPFactory.at(DPPFactoryAddress);
|
||||
|
||||
const assetTo = accounts[0];
|
||||
const baseInAmount = web3.utils.toWei("100000", 'ether');
|
||||
const quoteInAmount = web3.utils.toWei("10000", 'mwei');
|
||||
// const quoteInAmount = web3.utils.toWei("0", 'ether');
|
||||
// const quoteInAmount = web3.utils.toWei("10000", 'mwei');
|
||||
const quoteInAmount = web3.utils.toWei("0.5", 'ether');
|
||||
const deadline = Math.floor(new Date().getTime() / 1000 + 60 * 10);
|
||||
//DVM Pool
|
||||
for (var i = 0; i < POOL_PARAM.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user