add gas token && deploy kovan script
This commit is contained in:
@@ -19,14 +19,14 @@ import {IPermissionManager} from "../lib/PermissionManager.sol";
|
|||||||
contract DPPFactory is Ownable {
|
contract DPPFactory is Ownable {
|
||||||
// ============ Templates ============
|
// ============ Templates ============
|
||||||
|
|
||||||
address public _CLONE_FACTORY_;
|
address public immutable _CLONE_FACTORY_;
|
||||||
address public _DPP_TEMPLATE_;
|
address public immutable _DPP_TEMPLATE_;
|
||||||
|
address public immutable _FEE_RATE_MODEL_TEMPLATE_;
|
||||||
|
address public immutable _PERMISSION_MANAGER_TEMPLATE_;
|
||||||
|
address public immutable _DEFAULT_GAS_PRICE_SOURCE_;
|
||||||
|
address public immutable _VALUE_SOURCE_;
|
||||||
|
address public immutable _DODO_SMART_APPROVE_;
|
||||||
address public _DPP_ADMIN_TEMPLATE_;
|
address public _DPP_ADMIN_TEMPLATE_;
|
||||||
address public _FEE_RATE_MODEL_TEMPLATE_;
|
|
||||||
address public _PERMISSION_MANAGER_TEMPLATE_;
|
|
||||||
address public _DEFAULT_GAS_PRICE_SOURCE_;
|
|
||||||
address public _VALUE_SOURCE_;
|
|
||||||
address public _DODO_SMART_APPROVE_;
|
|
||||||
|
|
||||||
// ============ Registry ============
|
// ============ Registry ============
|
||||||
|
|
||||||
|
|||||||
@@ -18,12 +18,12 @@ import {IPermissionManager} from "../lib/PermissionManager.sol";
|
|||||||
contract DVMFactory is Ownable {
|
contract DVMFactory is Ownable {
|
||||||
// ============ Templates ============
|
// ============ Templates ============
|
||||||
|
|
||||||
address public _CLONE_FACTORY_;
|
address public immutable _CLONE_FACTORY_;
|
||||||
address public _DVM_TEMPLATE_;
|
address public immutable _DVM_TEMPLATE_;
|
||||||
|
address public immutable _FEE_RATE_MODEL_TEMPLATE_;
|
||||||
|
address public immutable _PERMISSION_MANAGER_TEMPLATE_;
|
||||||
|
address public immutable _DEFAULT_GAS_PRICE_SOURCE_;
|
||||||
address public _DVM_ADMIN_TEMPLATE_;
|
address public _DVM_ADMIN_TEMPLATE_;
|
||||||
address public _FEE_RATE_MODEL_TEMPLATE_;
|
|
||||||
address public _PERMISSION_MANAGER_TEMPLATE_;
|
|
||||||
address public _DEFAULT_GAS_PRICE_SOURCE_;
|
|
||||||
|
|
||||||
// ============ Registry ============
|
// ============ Registry ============
|
||||||
|
|
||||||
|
|||||||
@@ -13,20 +13,25 @@ import {SafeMath} from "../lib/SafeMath.sol";
|
|||||||
import {IDODOV1} from "./intf/IDODOV1.sol";
|
import {IDODOV1} from "./intf/IDODOV1.sol";
|
||||||
import {IDODOSellHelper} from "./helper/DODOSellHelper.sol";
|
import {IDODOSellHelper} from "./helper/DODOSellHelper.sol";
|
||||||
import {IWETH} from "../intf/IWETH.sol";
|
import {IWETH} from "../intf/IWETH.sol";
|
||||||
|
import {IChi} from "./intf/IChi.sol";
|
||||||
import {IDODOApprove} from "../intf/IDODOApprove.sol";
|
import {IDODOApprove} from "../intf/IDODOApprove.sol";
|
||||||
import {IDODOV1Proxy01} from "./intf/IDODOV1Proxy01.sol";
|
import {IDODOV1Proxy01} from "./intf/IDODOV1Proxy01.sol";
|
||||||
import {ReentrancyGuard} from "../lib/ReentrancyGuard.sol";
|
import {ReentrancyGuard} from "../lib/ReentrancyGuard.sol";
|
||||||
|
import {Ownable} from "../lib/Ownable.sol";
|
||||||
|
|
||||||
contract DODOV1Proxy01 is IDODOV1Proxy01, ReentrancyGuard {
|
contract DODOV1Proxy01 is IDODOV1Proxy01, ReentrancyGuard, Ownable {
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
using UniversalERC20 for IERC20;
|
using UniversalERC20 for IERC20;
|
||||||
|
|
||||||
// ============ Storage ============
|
// ============ Storage ============
|
||||||
|
|
||||||
address constant _ETH_ADDRESS_ = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
|
address constant _ETH_ADDRESS_ = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
|
||||||
address public _DODO_APPROVE_;
|
address public immutable _DODO_APPROVE_;
|
||||||
address public _DODO_SELL_HELPER_;
|
address public immutable _DODO_SELL_HELPER_;
|
||||||
address payable public _WETH_;
|
address public immutable _WETH_;
|
||||||
|
address public immutable _CHI_TOKEN_;
|
||||||
|
uint8 public _GAS_DODO_MAX_RETURN_ = 0;
|
||||||
|
uint8 public _GAS_EXTERNAL_RETURN_ = 0;
|
||||||
|
|
||||||
// ============ Events ============
|
// ============ Events ============
|
||||||
|
|
||||||
@@ -48,17 +53,24 @@ contract DODOV1Proxy01 is IDODOV1Proxy01, ReentrancyGuard {
|
|||||||
constructor(
|
constructor(
|
||||||
address dodoApporve,
|
address dodoApporve,
|
||||||
address dodoSellHelper,
|
address dodoSellHelper,
|
||||||
address payable weth
|
address weth,
|
||||||
|
address chiToken
|
||||||
) public {
|
) public {
|
||||||
_DODO_APPROVE_ = dodoApporve;
|
_DODO_APPROVE_ = dodoApporve;
|
||||||
_DODO_SELL_HELPER_ = dodoSellHelper;
|
_DODO_SELL_HELPER_ = dodoSellHelper;
|
||||||
_WETH_ = weth;
|
_WETH_ = weth;
|
||||||
|
_CHI_TOKEN_ = chiToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
fallback() external payable {}
|
fallback() external payable {}
|
||||||
|
|
||||||
receive() external payable {}
|
receive() external payable {}
|
||||||
|
|
||||||
|
function updateGasReturn(uint8 newDodoGasReturn, uint8 newExternalGasReturn) public onlyOwner {
|
||||||
|
_GAS_DODO_MAX_RETURN_ = newDodoGasReturn;
|
||||||
|
_GAS_EXTERNAL_RETURN_ = newExternalGasReturn;
|
||||||
|
}
|
||||||
|
|
||||||
function dodoSwapV1(
|
function dodoSwapV1(
|
||||||
address fromToken,
|
address fromToken,
|
||||||
address toToken,
|
address toToken,
|
||||||
@@ -67,7 +79,9 @@ contract DODOV1Proxy01 is IDODOV1Proxy01, ReentrancyGuard {
|
|||||||
address[] memory dodoPairs,
|
address[] memory dodoPairs,
|
||||||
uint8[] memory directions,
|
uint8[] memory directions,
|
||||||
uint256 deadLine
|
uint256 deadLine
|
||||||
) external virtual override payable judgeExpired(deadLine) returns (uint256 returnAmount) {
|
) external override payable judgeExpired(deadLine) returns (uint256 returnAmount) {
|
||||||
|
uint256 originGas = gasleft();
|
||||||
|
|
||||||
if (fromToken != _ETH_ADDRESS_) {
|
if (fromToken != _ETH_ADDRESS_) {
|
||||||
IDODOApprove(_DODO_APPROVE_).claimTokens(
|
IDODOApprove(_DODO_APPROVE_).claimTokens(
|
||||||
fromToken,
|
fromToken,
|
||||||
@@ -108,8 +122,16 @@ contract DODOV1Proxy01 is IDODOV1Proxy01, ReentrancyGuard {
|
|||||||
|
|
||||||
require(returnAmount >= minReturnAmount, "DODOV1Proxy01: Return amount is not enough");
|
require(returnAmount >= minReturnAmount, "DODOV1Proxy01: Return amount is not enough");
|
||||||
IERC20(toToken).universalTransfer(msg.sender, returnAmount);
|
IERC20(toToken).universalTransfer(msg.sender, returnAmount);
|
||||||
|
|
||||||
emit OrderHistory(fromToken, toToken, msg.sender, fromTokenAmount, returnAmount);
|
emit OrderHistory(fromToken, toToken, msg.sender, fromTokenAmount, returnAmount);
|
||||||
|
|
||||||
|
uint8 _gasDodoMaxReturn = _GAS_DODO_MAX_RETURN_;
|
||||||
|
if(_gasDodoMaxReturn > 0) {
|
||||||
|
uint256 calcGasTokenBurn = originGas.sub(gasleft()) / 65000;
|
||||||
|
uint256 gasTokenBurn = calcGasTokenBurn > _gasDodoMaxReturn ? _gasDodoMaxReturn : calcGasTokenBurn;
|
||||||
|
if(gasleft() > 27710 + gasTokenBurn * 6080)
|
||||||
|
IChi(_CHI_TOKEN_).freeUpTo(gasTokenBurn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function externalSwap(
|
function externalSwap(
|
||||||
@@ -121,35 +143,44 @@ contract DODOV1Proxy01 is IDODOV1Proxy01, ReentrancyGuard {
|
|||||||
uint256 minReturnAmount,
|
uint256 minReturnAmount,
|
||||||
bytes memory callDataConcat,
|
bytes memory callDataConcat,
|
||||||
uint256 deadLine
|
uint256 deadLine
|
||||||
) external virtual override payable judgeExpired(deadLine) returns (uint256 returnAmount) {
|
) external override payable judgeExpired(deadLine) returns (uint256 returnAmount) {
|
||||||
uint256 toTokenOriginBalance = IERC20(toToken).universalBalanceOf(msg.sender);
|
address _fromToken = fromToken;
|
||||||
|
address _toToken = toToken;
|
||||||
|
|
||||||
|
uint256 toTokenOriginBalance = IERC20(_toToken).universalBalanceOf(msg.sender);
|
||||||
|
|
||||||
if (fromToken != _ETH_ADDRESS_) {
|
if (_fromToken != _ETH_ADDRESS_) {
|
||||||
IDODOApprove(_DODO_APPROVE_).claimTokens(
|
IDODOApprove(_DODO_APPROVE_).claimTokens(
|
||||||
fromToken,
|
_fromToken,
|
||||||
msg.sender,
|
msg.sender,
|
||||||
address(this),
|
address(this),
|
||||||
fromTokenAmount
|
fromTokenAmount
|
||||||
);
|
);
|
||||||
IERC20(fromToken).universalApproveMax(approveTarget, fromTokenAmount);
|
IERC20(_fromToken).universalApproveMax(approveTarget, fromTokenAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
(bool success, ) = to.call{value: fromToken == _ETH_ADDRESS_ ? msg.value : 0}(callDataConcat);
|
(bool success, ) = to.call{value: _fromToken == _ETH_ADDRESS_ ? msg.value : 0}(callDataConcat);
|
||||||
|
|
||||||
require(success, "DODOV1Proxy01: Contract Swap execution Failed");
|
require(success, "DODOV1Proxy01: Contract Swap execution Failed");
|
||||||
|
|
||||||
IERC20(fromToken).universalTransfer(
|
IERC20(_fromToken).universalTransfer(
|
||||||
msg.sender,
|
msg.sender,
|
||||||
IERC20(fromToken).universalBalanceOf(address(this))
|
IERC20(_fromToken).universalBalanceOf(address(this))
|
||||||
);
|
);
|
||||||
|
|
||||||
IERC20(toToken).universalTransfer(
|
IERC20(_toToken).universalTransfer(
|
||||||
msg.sender,
|
msg.sender,
|
||||||
IERC20(toToken).universalBalanceOf(address(this))
|
IERC20(_toToken).universalBalanceOf(address(this))
|
||||||
);
|
);
|
||||||
returnAmount = IERC20(toToken).universalBalanceOf(msg.sender).sub(toTokenOriginBalance);
|
returnAmount = IERC20(_toToken).universalBalanceOf(msg.sender).sub(toTokenOriginBalance);
|
||||||
require(returnAmount >= minReturnAmount, "DODOV1Proxy01: Return amount is not enough");
|
require(returnAmount >= minReturnAmount, "DODOV1Proxy01: Return amount is not enough");
|
||||||
|
|
||||||
emit OrderHistory(fromToken, toToken, msg.sender, fromTokenAmount, returnAmount);
|
emit OrderHistory(_fromToken, _toToken, msg.sender, fromTokenAmount, returnAmount);
|
||||||
|
|
||||||
|
uint8 _gasExternalReturn = _GAS_EXTERNAL_RETURN_;
|
||||||
|
if(_gasExternalReturn > 0) {
|
||||||
|
if(gasleft() > 27710 + _gasExternalReturn * 6080)
|
||||||
|
IChi(_CHI_TOKEN_).freeUpTo(_gasExternalReturn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ contract DODOV2Proxy01 is IDODOV2Proxy01, ReentrancyGuard {
|
|||||||
// ============ Storage ============
|
// ============ Storage ============
|
||||||
|
|
||||||
address constant _ETH_ADDRESS_ = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
|
address constant _ETH_ADDRESS_ = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
|
||||||
address payable public _WETH_;
|
address public immutable _WETH_;
|
||||||
address public _DODO_APPROVE_;
|
address public immutable _DODO_APPROVE_;
|
||||||
address public _DODO_SELL_HELPER_;
|
address public immutable _DODO_SELL_HELPER_;
|
||||||
address public _DVM_FACTORY_;
|
address public immutable _DVM_FACTORY_;
|
||||||
address public _DPP_FACTORY_;
|
address public immutable _DPP_FACTORY_;
|
||||||
|
|
||||||
// ============ Events ============
|
// ============ Events ============
|
||||||
|
|
||||||
@@ -83,7 +83,6 @@ contract DODOV2Proxy01 is IDODOV2Proxy01, ReentrancyGuard {
|
|||||||
uint256 deadLine
|
uint256 deadLine
|
||||||
)
|
)
|
||||||
external
|
external
|
||||||
virtual
|
|
||||||
override
|
override
|
||||||
payable
|
payable
|
||||||
preventReentrant
|
preventReentrant
|
||||||
@@ -137,7 +136,6 @@ contract DODOV2Proxy01 is IDODOV2Proxy01, ReentrancyGuard {
|
|||||||
uint256 deadLine
|
uint256 deadLine
|
||||||
)
|
)
|
||||||
external
|
external
|
||||||
virtual
|
|
||||||
override
|
override
|
||||||
payable
|
payable
|
||||||
preventReentrant
|
preventReentrant
|
||||||
@@ -172,7 +170,7 @@ contract DODOV2Proxy01 is IDODOV2Proxy01, ReentrancyGuard {
|
|||||||
address dvmAddress,
|
address dvmAddress,
|
||||||
uint256 baseInAmount,
|
uint256 baseInAmount,
|
||||||
uint256 quoteInAmount
|
uint256 quoteInAmount
|
||||||
) internal virtual view returns (uint256 baseAdjustedInAmount, uint256 quoteAdjustedInAmount) {
|
) internal view returns (uint256 baseAdjustedInAmount, uint256 quoteAdjustedInAmount) {
|
||||||
(uint256 baseReserve, uint256 quoteReserve) = IDODOV2(dvmAddress).getVaultReserve();
|
(uint256 baseReserve, uint256 quoteReserve) = IDODOV2(dvmAddress).getVaultReserve();
|
||||||
if (quoteReserve == 0 && baseReserve == 0) {
|
if (quoteReserve == 0 && baseReserve == 0) {
|
||||||
baseAdjustedInAmount = baseInAmount;
|
baseAdjustedInAmount = baseInAmount;
|
||||||
@@ -209,7 +207,6 @@ contract DODOV2Proxy01 is IDODOV2Proxy01, ReentrancyGuard {
|
|||||||
uint256 deadLine
|
uint256 deadLine
|
||||||
)
|
)
|
||||||
external
|
external
|
||||||
virtual
|
|
||||||
override
|
override
|
||||||
payable
|
payable
|
||||||
preventReentrant
|
preventReentrant
|
||||||
@@ -256,7 +253,7 @@ contract DODOV2Proxy01 is IDODOV2Proxy01, ReentrancyGuard {
|
|||||||
uint256 quoteOutAmount,
|
uint256 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 deadLine
|
uint256 deadLine
|
||||||
) external virtual override payable preventReentrant judgeExpired(deadLine) {
|
) external override payable preventReentrant judgeExpired(deadLine) {
|
||||||
_deposit(
|
_deposit(
|
||||||
msg.sender,
|
msg.sender,
|
||||||
dppAddress,
|
dppAddress,
|
||||||
@@ -297,7 +294,6 @@ contract DODOV2Proxy01 is IDODOV2Proxy01, ReentrancyGuard {
|
|||||||
uint256 deadLine
|
uint256 deadLine
|
||||||
)
|
)
|
||||||
external
|
external
|
||||||
virtual
|
|
||||||
override
|
override
|
||||||
payable
|
payable
|
||||||
judgeExpired(deadLine)
|
judgeExpired(deadLine)
|
||||||
@@ -345,7 +341,6 @@ contract DODOV2Proxy01 is IDODOV2Proxy01, ReentrancyGuard {
|
|||||||
uint256 deadLine
|
uint256 deadLine
|
||||||
)
|
)
|
||||||
external
|
external
|
||||||
virtual
|
|
||||||
override
|
override
|
||||||
judgeExpired(deadLine)
|
judgeExpired(deadLine)
|
||||||
returns (uint256 returnAmount)
|
returns (uint256 returnAmount)
|
||||||
@@ -391,7 +386,6 @@ contract DODOV2Proxy01 is IDODOV2Proxy01, ReentrancyGuard {
|
|||||||
uint256 deadLine
|
uint256 deadLine
|
||||||
)
|
)
|
||||||
external
|
external
|
||||||
virtual
|
|
||||||
override
|
override
|
||||||
judgeExpired(deadLine)
|
judgeExpired(deadLine)
|
||||||
returns (uint256 returnAmount)
|
returns (uint256 returnAmount)
|
||||||
@@ -436,7 +430,6 @@ contract DODOV2Proxy01 is IDODOV2Proxy01, ReentrancyGuard {
|
|||||||
uint256 deadLine
|
uint256 deadLine
|
||||||
)
|
)
|
||||||
external
|
external
|
||||||
virtual
|
|
||||||
override
|
override
|
||||||
payable
|
payable
|
||||||
judgeExpired(deadLine)
|
judgeExpired(deadLine)
|
||||||
@@ -490,7 +483,6 @@ contract DODOV2Proxy01 is IDODOV2Proxy01, ReentrancyGuard {
|
|||||||
uint256 deadLine
|
uint256 deadLine
|
||||||
)
|
)
|
||||||
external
|
external
|
||||||
virtual
|
|
||||||
override
|
override
|
||||||
payable
|
payable
|
||||||
judgeExpired(deadLine)
|
judgeExpired(deadLine)
|
||||||
@@ -540,7 +532,7 @@ contract DODOV2Proxy01 is IDODOV2Proxy01, ReentrancyGuard {
|
|||||||
uint256 quoteMinShares,
|
uint256 quoteMinShares,
|
||||||
uint8 flag, // 0 erc20 In 1 baseInETH 2 quoteIn ETH
|
uint8 flag, // 0 erc20 In 1 baseInETH 2 quoteIn ETH
|
||||||
uint256 deadLine
|
uint256 deadLine
|
||||||
) external virtual override payable judgeExpired(deadLine) returns(uint256 baseShares, uint256 quoteShares) {
|
) external override payable judgeExpired(deadLine) returns(uint256 baseShares, uint256 quoteShares) {
|
||||||
address _baseToken = IDODOV1(pair)._BASE_TOKEN_();
|
address _baseToken = IDODOV1(pair)._BASE_TOKEN_();
|
||||||
address _quoteToken = IDODOV1(pair)._QUOTE_TOKEN_();
|
address _quoteToken = IDODOV1(pair)._QUOTE_TOKEN_();
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {ReentrancyGuard} from "../../lib/ReentrancyGuard.sol";
|
|||||||
|
|
||||||
contract DODOCalleeHelper is ReentrancyGuard {
|
contract DODOCalleeHelper is ReentrancyGuard {
|
||||||
using SafeERC20 for IERC20;
|
using SafeERC20 for IERC20;
|
||||||
address payable public _WETH_;
|
address public immutable _WETH_;
|
||||||
|
|
||||||
fallback() external payable {
|
fallback() external payable {
|
||||||
require(msg.sender == _WETH_, "WE_SAVED_YOUR_ETH");
|
require(msg.sender == _WETH_, "WE_SAVED_YOUR_ETH");
|
||||||
@@ -25,7 +25,7 @@ contract DODOCalleeHelper is ReentrancyGuard {
|
|||||||
require(msg.sender == _WETH_, "WE_SAVED_YOUR_ETH");
|
require(msg.sender == _WETH_, "WE_SAVED_YOUR_ETH");
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(address payable weth) public {
|
constructor(address weth) public {
|
||||||
_WETH_ = weth;
|
_WETH_ = weth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
13
contracts/SmartRoute/intf/IChi.sol
Normal file
13
contracts/SmartRoute/intf/IChi.sol
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Copyright 2020 DODO ZOO.
|
||||||
|
SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
pragma solidity 0.6.9;
|
||||||
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
|
interface IChi {
|
||||||
|
function freeUpTo(uint256 value) external returns (uint256);
|
||||||
|
}
|
||||||
471
contracts/external/ERC20/ChiToken.sol
vendored
Normal file
471
contracts/external/ERC20/ChiToken.sol
vendored
Normal file
File diff suppressed because one or more lines are too long
3
deploy-detail-v1.5.txt
Normal file
3
deploy-detail-v1.5.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
====================================================
|
||||||
|
network type: kovan
|
||||||
|
Deploy time: 2020/12/7 下午3:15:48
|
||||||
18
deploy-detail-v2.0.txt
Normal file
18
deploy-detail-v2.0.txt
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
====================================================
|
||||||
|
network type: kovan
|
||||||
|
Deploy time: 2020/12/7 下午3:15:53
|
||||||
|
Deploy type: V2
|
||||||
|
CloneFactoryAddress: 0xf7959fe661124C49F96CF30Da33729201aEE1b27
|
||||||
|
FeeRateModelTemplateAddress: 0xEF3137780B387313c5889B999D03BdCf9aeEa892
|
||||||
|
PermissionManagerTemplateAddress: 0x5D2Da09501d97a7bf0A8F192D2eb2F9Aa80d3241
|
||||||
|
ExternalValueTemplateAddress: 0xe0f813951dE2BB012f7Feb981669F9a7b5250A57
|
||||||
|
DefaultGasSourceAddress: 0xE0c0df0e0be7ec4f579503304a6C186cA4365407
|
||||||
|
DvmTemplateAddress: 0x460Ada67279Ff2ce8c87cb88F99070c6520Aa624
|
||||||
|
DvmAdminTemplateAddress: 0xbB9F79f6ac9e577B658E3B2E1340838d8965986B
|
||||||
|
DppTemplateAddress: 0x577c2cE26B8b5C8b3f7c57826Bf351ac7c21a441
|
||||||
|
DppAdminTemplateAddress: 0x402ace5a3e6Aa71FB942d309341F8867afcde302
|
||||||
|
DODOCalleeHelperAddress: 0x507EBbb195CF54E0aF147A2b269C08a38EA36989
|
||||||
|
DvmFactoryAddress: 0xaeF2cce5678e6e29f7a7C2A6f5d2Ce26df600dc1
|
||||||
|
DppFactoryAddress: 0x5935a606383Ba43C61FcE5E632357744a95e9dC3
|
||||||
|
DODOProxyV2 Address: 0xD4b15Ab0e1F06373dA7ccd9f01D5e9776674DB9e
|
||||||
|
DODOApprovce setProxy tx: 0x67c5c5b1883950baec753a99bff5e1c20bfb92f876cdcd03c90ae2aa0053d891
|
||||||
@@ -1,156 +0,0 @@
|
|||||||
const fs = require("fs");
|
|
||||||
const file = fs.createWriteStream("../deploy-detail.txt");
|
|
||||||
let logger = new console.Console(file, file);
|
|
||||||
|
|
||||||
// const SmartApprove = artifacts.require("DODOApprove");
|
|
||||||
// const SmartSwap = artifacts.require("SmartSwap");
|
|
||||||
// const DODOSellHelper = artifacts.require("DODOSellHelper");
|
|
||||||
// const TestERC20 = artifacts.require("TestERC20");
|
|
||||||
// const NaiveOracle = artifacts.require("NaiveOracle");
|
|
||||||
// const DODOZoo = artifacts.require("DODOZoo");
|
|
||||||
|
|
||||||
const DEPLOY_ROUTE = false;
|
|
||||||
const DEPLOY_KOVAN_TOKEN = false;
|
|
||||||
|
|
||||||
module.exports = async (deployer, network, accounts) => {
|
|
||||||
// let DODOSellHelperAddress = "";
|
|
||||||
// let DODOZooAddress = "";
|
|
||||||
// let WETHAddress = "";
|
|
||||||
// let SmartApproveAddress = "";
|
|
||||||
// if (network == "kovan") {
|
|
||||||
// DODOSellHelperAddress = "0xbdEae617F2616b45DCB69B287D52940a76035Fe3";
|
|
||||||
// DODOZooAddress = "0x92230e929a2226b29ed3441ae5524886347c60c8";
|
|
||||||
// WETHAddress = "0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b";
|
|
||||||
// SmartApproveAddress = "0x5627b7DEb3055e1e899003FDca0716b32C382084";
|
|
||||||
// } else if (network == "live") {
|
|
||||||
// DODOSellHelperAddress = "0x533da777aedce766ceae696bf90f8541a4ba80eb";
|
|
||||||
// DODOZooAddress = "0x3a97247df274a17c59a3bd12735ea3fcdfb49950";
|
|
||||||
// WETHAddress = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
|
|
||||||
// SmartApproveAddress = "0xe380Ad3181A69BF92133D2feb609867c4adC61eA";
|
|
||||||
// } else return;
|
|
||||||
|
|
||||||
// logger.log("====================================================");
|
|
||||||
// logger.log("network type: " + network);
|
|
||||||
// logger.log("Deploy time: " + new Date().toLocaleString());
|
|
||||||
|
|
||||||
// if (DEPLOY_ROUTE) {
|
|
||||||
// logger.log("Deploy type: Smart Route");
|
|
||||||
// if (SmartApproveAddress == "") {
|
|
||||||
// await deployer.deploy(SmartApprove);
|
|
||||||
// SmartApproveAddress = SmartApprove.address;
|
|
||||||
// }
|
|
||||||
// if (DODOSellHelperAddress == "") {
|
|
||||||
// await deployer.deploy(DODOSellHelper);
|
|
||||||
// DODOSellHelperAddress = DODOSellHelper.address;
|
|
||||||
// }
|
|
||||||
// logger.log("SmartApprove Address: ", SmartApproveAddress);
|
|
||||||
// logger.log("DODOSellHelper Address: ", DODOSellHelperAddress);
|
|
||||||
// await deployer.deploy(
|
|
||||||
// SmartSwap,
|
|
||||||
// SmartApproveAddress,
|
|
||||||
// DODOSellHelperAddress,
|
|
||||||
// WETHAddress
|
|
||||||
// );
|
|
||||||
// logger.log("SmartSwap Address: ", SmartSwap.address);
|
|
||||||
|
|
||||||
// // const SmartApproveInstance = await SmartApprove.at(SmartApproveAddress);
|
|
||||||
// // var tx = await SmartApproveInstance.setSmartSwap(SmartSwap.address);
|
|
||||||
// // logger.log("SmartApprovce setSmartSwap tx: ", tx.tx);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (DEPLOY_KOVAN_TOKEN) {
|
|
||||||
// logger.log("Deploy type: Create Tokens and Trading Pairs");
|
|
||||||
// await deployer.deploy(TestERC20, "USDC", 6, "USDC");
|
|
||||||
// const USDCAddr = TestERC20.address;
|
|
||||||
// logger.log("USDC Addr: ", USDCAddr);
|
|
||||||
// await deployer.deploy(TestERC20, "USDT", 6, "USDT");
|
|
||||||
// const USDTAddr = TestERC20.address;
|
|
||||||
// logger.log("USDT Addr: ", USDTAddr);
|
|
||||||
// await deployer.deploy(TestERC20, "DODO", 18, "DODO");
|
|
||||||
// const DODOAddr = TestERC20.address;
|
|
||||||
// logger.log("DODO Addr: ", DODOAddr);
|
|
||||||
// await deployer.deploy(TestERC20, "WOO", 18, "WOO");
|
|
||||||
// const WooAddr = TestERC20.address;
|
|
||||||
// logger.log("WOO Addr: ", WooAddr);
|
|
||||||
// const WETHAddr = WETHAddress;
|
|
||||||
// logger.log("WETH Addr: ", WETHAddr);
|
|
||||||
|
|
||||||
// let config = {
|
|
||||||
// lpFeeRate: "2000000000000000",
|
|
||||||
// mtFeeRate: "1000000000000000",
|
|
||||||
// k: "100000000000000000",
|
|
||||||
// gasPriceLimit: "100000000000",
|
|
||||||
// };
|
|
||||||
|
|
||||||
// const DODOZooInstance = await DODOZoo.at(DODOZooAddress);
|
|
||||||
|
|
||||||
// //USDT-USDC
|
|
||||||
// await deployer.deploy(NaiveOracle);
|
|
||||||
// var USDT_USDC_Oracle = NaiveOracle.address;
|
|
||||||
// await DODOZooInstance.breedDODO(
|
|
||||||
// accounts[0],
|
|
||||||
// USDTAddr,
|
|
||||||
// USDCAddr,
|
|
||||||
// USDT_USDC_Oracle,
|
|
||||||
// config.lpFeeRate,
|
|
||||||
// config.mtFeeRate,
|
|
||||||
// config.k,
|
|
||||||
// config.gasPriceLimit
|
|
||||||
// );
|
|
||||||
// const USDT_USDC_Addr = await DODOZooInstance.getDODO(USDTAddr, USDCAddr);
|
|
||||||
// logger.log("USDT_USDC_Addr:", USDT_USDC_Addr);
|
|
||||||
|
|
||||||
// // DODO-USDT
|
|
||||||
// await deployer.deploy(NaiveOracle);
|
|
||||||
// var DODO_USDT_Oracle = NaiveOracle.address;
|
|
||||||
// await DODOZooInstance.breedDODO(
|
|
||||||
// accounts[0],
|
|
||||||
// DODOAddr,
|
|
||||||
// USDTAddr,
|
|
||||||
// DODO_USDT_Oracle,
|
|
||||||
// config.lpFeeRate,
|
|
||||||
// config.mtFeeRate,
|
|
||||||
// config.k,
|
|
||||||
// config.gasPriceLimit
|
|
||||||
// );
|
|
||||||
// const DODO_USDT_Addr = await DODOZooInstance.getDODO(DODOAddr, USDTAddr);
|
|
||||||
// logger.log("DODO_USDT_Addr:", DODO_USDT_Addr);
|
|
||||||
|
|
||||||
// // //WETH-USDC
|
|
||||||
// await deployer.deploy(NaiveOracle);
|
|
||||||
// var WETH_USDC_Oracle = NaiveOracle.address;
|
|
||||||
// await DODOZooInstance.breedDODO(
|
|
||||||
// accounts[0],
|
|
||||||
// WETHAddr,
|
|
||||||
// USDCAddr,
|
|
||||||
// WETH_USDC_Oracle,
|
|
||||||
// config.lpFeeRate,
|
|
||||||
// config.mtFeeRate,
|
|
||||||
// config.k,
|
|
||||||
// config.gasPriceLimit
|
|
||||||
// );
|
|
||||||
// const WETH_USDC_Addr = await DODOZooInstance.getDODO(WETHAddr, USDCAddr);
|
|
||||||
// logger.log("WETH_USDC_Addr:", WETH_USDC_Addr);
|
|
||||||
|
|
||||||
// //WOO-USDT
|
|
||||||
// await deployer.deploy(NaiveOracle);
|
|
||||||
// var WOO_USDT_Oracle = NaiveOracle.address;
|
|
||||||
// await DODOZooInstance.breedDODO(
|
|
||||||
// accounts[0],
|
|
||||||
// WooAddr,
|
|
||||||
// USDTAddr,
|
|
||||||
// WOO_USDT_Oracle,
|
|
||||||
// config.lpFeeRate,
|
|
||||||
// config.mtFeeRate,
|
|
||||||
// config.k,
|
|
||||||
// config.gasPriceLimit
|
|
||||||
// );
|
|
||||||
// const WOO_USDT_Addr = await DODOZooInstance.getDODO(WooAddr, USDTAddr);
|
|
||||||
// logger.log("WOO_USDT_Addr:", WOO_USDT_Addr);
|
|
||||||
|
|
||||||
// //TODO:ing enableBaseDeposit enableQuoteDeposit enableTrading
|
|
||||||
// //TODO:ing apporve pair to token
|
|
||||||
// //TODO:ing mint to lp
|
|
||||||
// //TODO:ing deposit to Base && quote pool
|
|
||||||
// }
|
|
||||||
};
|
|
||||||
63
migrations/2_deploy_v1.5.js
Normal file
63
migrations/2_deploy_v1.5.js
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
const fs = require("fs");
|
||||||
|
const file = fs.createWriteStream("../deploy-detail-v1.5.txt", { 'flags': 'a' });
|
||||||
|
let logger = new console.Console(file, file);
|
||||||
|
|
||||||
|
const DODOApprove = artifacts.require("DODOApprove");
|
||||||
|
const DODOProxyV1 = artifacts.require("DODOV1Proxy01");
|
||||||
|
const DODOSellHelper = artifacts.require("DODOSellHelper");
|
||||||
|
|
||||||
|
const DEPLOY_ROUTE = false;
|
||||||
|
|
||||||
|
module.exports = async (deployer, network, accounts) => {
|
||||||
|
let DODOSellHelperAddress = "";
|
||||||
|
let WETHAddress = "";
|
||||||
|
let DODOApproveAddress = "";
|
||||||
|
let chiAddress = "";
|
||||||
|
if (network == "kovan") {
|
||||||
|
DODOSellHelperAddress = "0xbdEae617F2616b45DCB69B287D52940a76035Fe3";
|
||||||
|
WETHAddress = "0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b";
|
||||||
|
// DODOApproveAddress = "0xbcf0fC05860b14cB3D62D1d4C7f531Ad2F28E0fE";
|
||||||
|
DODOApproveAddress = "0x0C4a80B2e234448E5f6fD86e7eFA733d985004c8";
|
||||||
|
chiAddress = "0x0000000000004946c0e9f43f4dee607b0ef1fa1c";
|
||||||
|
} else if (network == "live") {
|
||||||
|
DODOSellHelperAddress = "0x533da777aedce766ceae696bf90f8541a4ba80eb";
|
||||||
|
WETHAddress = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
|
||||||
|
DODOApproveAddress = "0x4eC851895d85bfa6835241b3157ae10FfFD3BebC";
|
||||||
|
chiAddress = "0x0000000000004946c0e9F43F4Dee607b0eF1fA1c";
|
||||||
|
} else if (network == "bsclive") {
|
||||||
|
DODOSellHelperAddress = "0x0F859706AeE7FcF61D5A8939E8CB9dBB6c1EDA33";
|
||||||
|
WETHAddress = "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c";
|
||||||
|
DODOApproveAddress = "0x19DA73be23Cea6bFA804Ec020041b8F3971BC522";
|
||||||
|
chiAddress = "0x0000000000000000000000000000000000000000";
|
||||||
|
} else return;
|
||||||
|
|
||||||
|
logger.log("====================================================");
|
||||||
|
logger.log("network type: " + network);
|
||||||
|
logger.log("Deploy time: " + new Date().toLocaleString());
|
||||||
|
|
||||||
|
if (DEPLOY_ROUTE) {
|
||||||
|
logger.log("Deploy type: Proxy");
|
||||||
|
if (DODOApproveAddress == "") {
|
||||||
|
await deployer.deploy(DODOApprove);
|
||||||
|
DODOApproveAddress = DODOApprove.address;
|
||||||
|
}
|
||||||
|
if (DODOSellHelperAddress == "") {
|
||||||
|
await deployer.deploy(DODOSellHelper);
|
||||||
|
DODOSellHelperAddress = DODOSellHelper.address;
|
||||||
|
}
|
||||||
|
logger.log("DODOApprove Address: ", DODOApproveAddress);
|
||||||
|
logger.log("DODOSellHelper Address: ", DODOSellHelperAddress);
|
||||||
|
await deployer.deploy(
|
||||||
|
DODOProxyV1,
|
||||||
|
DODOApproveAddress,
|
||||||
|
DODOSellHelperAddress,
|
||||||
|
WETHAddress,
|
||||||
|
chiAddress
|
||||||
|
);
|
||||||
|
logger.log("DODOProxyV1 Address: ", DODOProxyV1.address);
|
||||||
|
|
||||||
|
const DODOApproveInstance = await DODOApprove.at(DODOApproveAddress);
|
||||||
|
var tx = await DODOApproveInstance.setDODOProxy(DODOProxyV1.address);
|
||||||
|
logger.log("DODOApprovce setProxy tx: ", tx.tx);
|
||||||
|
}
|
||||||
|
};
|
||||||
189
migrations/3_deploy_v2.js
Normal file
189
migrations/3_deploy_v2.js
Normal file
@@ -0,0 +1,189 @@
|
|||||||
|
const fs = require("fs");
|
||||||
|
const file = fs.createWriteStream("../deploy-detail-v2.0.txt", { 'flags': 'a' });
|
||||||
|
let logger = new console.Console(file, file);
|
||||||
|
|
||||||
|
const CloneFactory = artifacts.require("CloneFactory");
|
||||||
|
const DvmTemplate = artifacts.require("DVM");
|
||||||
|
const DvmAdminTemplate = artifacts.require("DVMAdmin");
|
||||||
|
const DppTemplate = artifacts.require("DPP");
|
||||||
|
const DppAdminTemplate = artifacts.require("DPPAdmin");
|
||||||
|
const FeeRateModelTemplate = artifacts.require("FeeRateModel");
|
||||||
|
const PermissionManagerTemplate = artifacts.require("PermissionManager");
|
||||||
|
const ExternalValueTemplate = artifacts.require("ExternalValue");
|
||||||
|
|
||||||
|
const DvmFactory = artifacts.require("DVMFactory");
|
||||||
|
const DppFactory = artifacts.require("DPPFactory");
|
||||||
|
|
||||||
|
const DODOApprove = artifacts.require("DODOApprove");
|
||||||
|
const DODOProxyV2 = artifacts.require("DODOV2Proxy01");
|
||||||
|
const DODOSellHelper = artifacts.require("DODOSellHelper");
|
||||||
|
const DODOCalleeHelper = artifacts.require("DODOCalleeHelper");
|
||||||
|
|
||||||
|
const DEPLOY_V2 = true;
|
||||||
|
|
||||||
|
module.exports = async (deployer, network, accounts) => {
|
||||||
|
let DODOSellHelperAddress = "";
|
||||||
|
let DODOCalleeHelperAddress = "";
|
||||||
|
let WETHAddress = "";
|
||||||
|
let DODOApproveAddress = "";
|
||||||
|
let chiAddress = "";
|
||||||
|
let CloneFactoryAddress = "";
|
||||||
|
let FeeRateModelTemplateAddress = "";
|
||||||
|
let PermissionManagerTemplateAddress = "";
|
||||||
|
let ExternalValueTemplateAddress = "";
|
||||||
|
let DefaultGasSourceAddress = "";
|
||||||
|
let DvmTemplateAddress = "";
|
||||||
|
let DvmAdminTemplateAddress = "";
|
||||||
|
let DppTemplateAddress = "";
|
||||||
|
let DppAdminTemplateAddress = "";
|
||||||
|
let DvmFactoryAddress = "";
|
||||||
|
let DppFactoryAddress = "";
|
||||||
|
|
||||||
|
if (network == "kovan") {
|
||||||
|
DODOSellHelperAddress = "0xbdEae617F2616b45DCB69B287D52940a76035Fe3";
|
||||||
|
WETHAddress = "0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b";
|
||||||
|
chiAddress = "0x0000000000004946c0e9f43f4dee607b0ef1fa1c";
|
||||||
|
DODOApproveAddress = "0x0C4a80B2e234448E5f6fD86e7eFA733d985004c8";
|
||||||
|
DODOCalleeHelperAddress = "0x507EBbb195CF54E0aF147A2b269C08a38EA36989";
|
||||||
|
//Template
|
||||||
|
CloneFactoryAddress = "0xf7959fe661124C49F96CF30Da33729201aEE1b27";
|
||||||
|
FeeRateModelTemplateAddress = "0xEF3137780B387313c5889B999D03BdCf9aeEa892";
|
||||||
|
PermissionManagerTemplateAddress = "0x5D2Da09501d97a7bf0A8F192D2eb2F9Aa80d3241";
|
||||||
|
ExternalValueTemplateAddress = "0xe0f813951dE2BB012f7Feb981669F9a7b5250A57";
|
||||||
|
DefaultGasSourceAddress = "0xE0c0df0e0be7ec4f579503304a6C186cA4365407";
|
||||||
|
DvmTemplateAddress = "0x460Ada67279Ff2ce8c87cb88F99070c6520Aa624";
|
||||||
|
DvmAdminTemplateAddress = "0xbB9F79f6ac9e577B658E3B2E1340838d8965986B";
|
||||||
|
DppTemplateAddress = "0x577c2cE26B8b5C8b3f7c57826Bf351ac7c21a441";
|
||||||
|
DppAdminTemplateAddress = "0x402ace5a3e6Aa71FB942d309341F8867afcde302";
|
||||||
|
//Factory
|
||||||
|
DvmFactoryAddress = "0xaeF2cce5678e6e29f7a7C2A6f5d2Ce26df600dc1";
|
||||||
|
DppFactoryAddress = "0x5935a606383Ba43C61FcE5E632357744a95e9dC3";
|
||||||
|
} else if (network == "live") {
|
||||||
|
DODOSellHelperAddress = "0x533da777aedce766ceae696bf90f8541a4ba80eb";
|
||||||
|
WETHAddress = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
|
||||||
|
chiAddress = "0x0000000000004946c0e9F43F4Dee607b0eF1fA1c";
|
||||||
|
DODOApproveAddress = "0x4eC851895d85bfa6835241b3157ae10FfFD3BebC";
|
||||||
|
//Tempalte
|
||||||
|
} else if (network == "bsclive") {
|
||||||
|
DODOSellHelperAddress = "0x0F859706AeE7FcF61D5A8939E8CB9dBB6c1EDA33";
|
||||||
|
WETHAddress = "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c";
|
||||||
|
chiAddress = "0x0000000000000000000000000000000000000000";
|
||||||
|
DODOApproveAddress = "0x19DA73be23Cea6bFA804Ec020041b8F3971BC522";
|
||||||
|
//Template
|
||||||
|
} else return;
|
||||||
|
|
||||||
|
logger.log("====================================================");
|
||||||
|
logger.log("network type: " + network);
|
||||||
|
logger.log("Deploy time: " + new Date().toLocaleString());
|
||||||
|
|
||||||
|
if (DEPLOY_V2) {
|
||||||
|
logger.log("Deploy type: V2");
|
||||||
|
if (CloneFactoryAddress == "") {
|
||||||
|
await deployer.deploy(CloneFactory);
|
||||||
|
CloneFactoryAddress = CloneFactory.address;
|
||||||
|
logger.log("CloneFactoryAddress: ", CloneFactoryAddress);
|
||||||
|
}
|
||||||
|
if (FeeRateModelTemplateAddress == "") {
|
||||||
|
await deployer.deploy(FeeRateModelTemplate);
|
||||||
|
FeeRateModelTemplateAddress = FeeRateModelTemplate.address;
|
||||||
|
logger.log("FeeRateModelTemplateAddress: ", FeeRateModelTemplateAddress);
|
||||||
|
}
|
||||||
|
if (PermissionManagerTemplateAddress == "") {
|
||||||
|
await deployer.deploy(PermissionManagerTemplate);
|
||||||
|
PermissionManagerTemplateAddress = PermissionManagerTemplate.address;
|
||||||
|
logger.log("PermissionManagerTemplateAddress: ", PermissionManagerTemplateAddress);
|
||||||
|
}
|
||||||
|
if (ExternalValueTemplateAddress == "") {
|
||||||
|
await deployer.deploy(ExternalValueTemplate);
|
||||||
|
ExternalValueTemplateAddress = ExternalValueTemplate.address;
|
||||||
|
logger.log("ExternalValueTemplateAddress: ", ExternalValueTemplateAddress);
|
||||||
|
}
|
||||||
|
if (DefaultGasSourceAddress == "") {
|
||||||
|
await deployer.deploy(ExternalValueTemplate);
|
||||||
|
DefaultGasSourceAddress = ExternalValueTemplate.address;
|
||||||
|
logger.log("DefaultGasSourceAddress: ", DefaultGasSourceAddress);
|
||||||
|
const defaultGasSourceInstance = await ExternalValueTemplate.at(DefaultGasSourceAddress);
|
||||||
|
var tx = await defaultGasSourceInstance.init(accounts[0], "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||||
|
logger.log("Set default Gas Tx:", tx.tx);
|
||||||
|
}
|
||||||
|
if (DvmTemplateAddress == "") {
|
||||||
|
await deployer.deploy(DvmTemplate);
|
||||||
|
DvmTemplateAddress = DvmTemplate.address;
|
||||||
|
logger.log("DvmTemplateAddress: ", DvmTemplateAddress);
|
||||||
|
}
|
||||||
|
if (DvmAdminTemplateAddress == "") {
|
||||||
|
await deployer.deploy(DvmAdminTemplate);
|
||||||
|
DvmAdminTemplateAddress = DvmAdminTemplate.address;
|
||||||
|
logger.log("DvmAdminTemplateAddress: ", DvmAdminTemplateAddress);
|
||||||
|
}
|
||||||
|
if (DppTemplateAddress == "") {
|
||||||
|
await deployer.deploy(DppTemplate);
|
||||||
|
DppTemplateAddress = DppTemplate.address;
|
||||||
|
logger.log("DppTemplateAddress: ", DppTemplateAddress);
|
||||||
|
}
|
||||||
|
if (DppAdminTemplateAddress == "") {
|
||||||
|
await deployer.deploy(DppAdminTemplate);
|
||||||
|
DppAdminTemplateAddress = DppAdminTemplate.address;
|
||||||
|
logger.log("DppAdminTemplateAddress: ", DppAdminTemplateAddress);
|
||||||
|
}
|
||||||
|
if (DODOApproveAddress == "") {
|
||||||
|
await deployer.deploy(DODOApprove);
|
||||||
|
DODOApproveAddress = DODOApprove.address;
|
||||||
|
logger.log("DODOApprove Address: ", DODOApproveAddress);
|
||||||
|
}
|
||||||
|
if (DODOSellHelperAddress == "") {
|
||||||
|
await deployer.deploy(DODOSellHelper);
|
||||||
|
DODOSellHelperAddress = DODOSellHelper.address;
|
||||||
|
logger.log("DODOSellHelper Address: ", DODOSellHelperAddress);
|
||||||
|
}
|
||||||
|
if (DODOCalleeHelperAddress == "") {
|
||||||
|
await deployer.deploy(DODOCalleeHelper,WETHAddress);
|
||||||
|
DODOCalleeHelperAddress = DODOCalleeHelper.address;
|
||||||
|
logger.log("DODOCalleeHelperAddress: ", DODOCalleeHelperAddress);
|
||||||
|
}
|
||||||
|
//Factory
|
||||||
|
if (DvmFactoryAddress == "") {
|
||||||
|
await deployer.deploy(
|
||||||
|
DvmFactory,
|
||||||
|
CloneFactoryAddress,
|
||||||
|
DvmTemplateAddress,
|
||||||
|
DvmAdminTemplateAddress,
|
||||||
|
FeeRateModelTemplateAddress,
|
||||||
|
PermissionManagerTemplateAddress,
|
||||||
|
DefaultGasSourceAddress
|
||||||
|
);
|
||||||
|
DvmFactoryAddress = DvmFactory.address;
|
||||||
|
logger.log("DvmFactoryAddress: ", DvmFactoryAddress);
|
||||||
|
}
|
||||||
|
if (DppFactoryAddress == "") {
|
||||||
|
await deployer.deploy(
|
||||||
|
DppFactory,
|
||||||
|
CloneFactoryAddress,
|
||||||
|
DppTemplateAddress,
|
||||||
|
DppAdminTemplateAddress,
|
||||||
|
FeeRateModelTemplateAddress,
|
||||||
|
PermissionManagerTemplateAddress,
|
||||||
|
ExternalValueTemplateAddress,
|
||||||
|
DefaultGasSourceAddress,
|
||||||
|
DODOApproveAddress
|
||||||
|
);
|
||||||
|
DppFactoryAddress = DppFactory.address;
|
||||||
|
logger.log("DppFactoryAddress: ", DppFactoryAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Proxy
|
||||||
|
await deployer.deploy(
|
||||||
|
DODOProxyV2,
|
||||||
|
DvmFactoryAddress,
|
||||||
|
DppFactoryAddress,
|
||||||
|
WETHAddress,
|
||||||
|
DODOApproveAddress,
|
||||||
|
DODOSellHelperAddress
|
||||||
|
);
|
||||||
|
logger.log("DODOProxyV2 Address: ", DODOProxyV2.address);
|
||||||
|
|
||||||
|
const DODOApproveInstance = await DODOApprove.at(DODOApproveAddress);
|
||||||
|
var tx = await DODOApproveInstance.setDODOProxy(DODOProxyV2.address);
|
||||||
|
logger.log("DODOApprovce setProxy tx: ", tx.tx);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -140,13 +140,14 @@ describe("Trader", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await ctx.EVM.reset(snapshotId);
|
// await ctx.EVM.reset(snapshotId);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("route calc test", () => {
|
describe("route calc test", () => {
|
||||||
it("DODO to USDT directly swap", async () => {
|
it.only("DODO to USDT directly swap", async () => {
|
||||||
var b_DODO = await ctx.DODO.methods.balanceOf(trader).call()
|
var b_DODO = await ctx.DODO.methods.balanceOf(trader).call()
|
||||||
var b_USDT = await ctx.USDT.methods.balanceOf(trader).call()
|
var b_USDT = await ctx.USDT.methods.balanceOf(trader).call()
|
||||||
|
var c_b_CHI = await ctx.CHI.methods.balanceOf(ctx.DODOProxyV1.options.address).call()
|
||||||
console.log("Before DODO:" + fromWei(b_DODO, 'ether') + "; USDT:" + fromWei(b_USDT, 'mwei'));
|
console.log("Before DODO:" + fromWei(b_DODO, 'ether') + "; USDT:" + fromWei(b_USDT, 'mwei'));
|
||||||
//approve DODO entry
|
//approve DODO entry
|
||||||
await ctx.DODO.methods.approve(ctx.DODOApprove.options.address, MAX_UINT256).send(ctx.sendParam(trader))
|
await ctx.DODO.methods.approve(ctx.DODOApprove.options.address, MAX_UINT256).send(ctx.sendParam(trader))
|
||||||
@@ -167,15 +168,17 @@ describe("Trader", () => {
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
await logGas(await calcRoute(ctx, decimalStr('10'), 0.1, routes, pairs), ctx.sendParam(trader), "directly swap")
|
await logGas(await calcRoute(ctx, decimalStr('10'), 0.1, routes, pairs), ctx.sendParam(trader), "directly swap")
|
||||||
await logGas(await calcRoute(ctx, decimalStr('10'), 0.1, routes, pairs), ctx.sendParam(trader), "directly swap")
|
var tx = await logGas(await calcRoute(ctx, decimalStr('10'), 0.1, routes, pairs), ctx.sendParam(trader), "directly swap")
|
||||||
// console.log(tx.events['OrderHistory']);
|
console.log(tx.transactionHash);
|
||||||
var a_DODO = await ctx.DODO.methods.balanceOf(trader).call()
|
var a_DODO = await ctx.DODO.methods.balanceOf(trader).call()
|
||||||
var a_USDT = await ctx.USDT.methods.balanceOf(trader).call()
|
var a_USDT = await ctx.USDT.methods.balanceOf(trader).call()
|
||||||
console.log("After DODO:" + fromWei(a_DODO, 'ether') + "; USDT:" + fromWei(a_USDT, 'mwei'));
|
console.log("After DODO:" + fromWei(a_DODO, 'ether') + "; USDT:" + fromWei(a_USDT, 'mwei'));
|
||||||
console.log("===============================================")
|
console.log("===============================================")
|
||||||
var c_DODO = await ctx.DODO.methods.balanceOf(ctx.DODOProxyV1.options.address).call()
|
var c_DODO = await ctx.DODO.methods.balanceOf(ctx.DODOProxyV1.options.address).call()
|
||||||
var c_USDT = await ctx.USDT.methods.balanceOf(ctx.DODOProxyV1.options.address).call()
|
var c_USDT = await ctx.USDT.methods.balanceOf(ctx.DODOProxyV1.options.address).call()
|
||||||
|
var c_a_CHI = await ctx.CHI.methods.balanceOf(ctx.DODOProxyV1.options.address).call()
|
||||||
console.log("Contract DODO:" + fromWei(c_DODO, 'ether') + "; USDT:" + fromWei(c_USDT, 'mwei'));
|
console.log("Contract DODO:" + fromWei(c_DODO, 'ether') + "; USDT:" + fromWei(c_USDT, 'mwei'));
|
||||||
|
console.log("Contract gas Token Before:" + c_b_CHI + " ;After:" + c_a_CHI);
|
||||||
// console.log("USDT:" + a_USDT);
|
// console.log("USDT:" + a_USDT);
|
||||||
assert(a_USDT, "1994000");
|
assert(a_USDT, "1994000");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ const SmartSwap = require(`${jsonPath2}DODOV1Proxy01.json`)
|
|||||||
const SmartApprove = require(`${jsonPath2}DODOApprove.json`)
|
const SmartApprove = require(`${jsonPath2}DODOApprove.json`)
|
||||||
const DODOSellHelper = require(`${jsonPath2}DODOSellHelper.json`)
|
const DODOSellHelper = require(`${jsonPath2}DODOSellHelper.json`)
|
||||||
const WETH = require(`${jsonPath2}WETH9.json`)
|
const WETH = require(`${jsonPath2}WETH9.json`)
|
||||||
|
const CHI = require(`${jsonPath2}ChiToken.json`)
|
||||||
/******/
|
/******/
|
||||||
|
|
||||||
import { getDefaultWeb3 } from './EVM';
|
import { getDefaultWeb3 } from './EVM';
|
||||||
@@ -55,6 +56,7 @@ export const DODO_MINE_READER_NAME = "DODOMineReader"
|
|||||||
export const SMART_SWAP = "DODOV1Proxy01"
|
export const SMART_SWAP = "DODOV1Proxy01"
|
||||||
export const SMART_APPROVE = "DODOApprove"
|
export const SMART_APPROVE = "DODOApprove"
|
||||||
export const DODO_SELL_HELPER = "DODOSellHelper"
|
export const DODO_SELL_HELPER = "DODOSellHelper"
|
||||||
|
export const CHI_TOKEN = "ChiToken"
|
||||||
/******/
|
/******/
|
||||||
|
|
||||||
var contractMap: { [name: string]: any } = {}
|
var contractMap: { [name: string]: any } = {}
|
||||||
@@ -76,6 +78,7 @@ contractMap[DODO_MINE_READER_NAME] = DODOMineReader
|
|||||||
contractMap[SMART_SWAP] = SmartSwap
|
contractMap[SMART_SWAP] = SmartSwap
|
||||||
contractMap[SMART_APPROVE] = SmartApprove
|
contractMap[SMART_APPROVE] = SmartApprove
|
||||||
contractMap[DODO_SELL_HELPER] = DODOSellHelper
|
contractMap[DODO_SELL_HELPER] = DODOSellHelper
|
||||||
|
contractMap[CHI_TOKEN] = CHI
|
||||||
/******/
|
/******/
|
||||||
|
|
||||||
interface ContractJson {
|
interface ContractJson {
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ export class DODOContext {
|
|||||||
USDT: Contract;
|
USDT: Contract;
|
||||||
USDC: Contract;
|
USDC: Contract;
|
||||||
WETH: Contract;
|
WETH: Contract;
|
||||||
|
CHI: Contract;
|
||||||
|
GST2: Contract;
|
||||||
//pair
|
//pair
|
||||||
DODO_USDT: Contract;
|
DODO_USDT: Contract;
|
||||||
USDT_USDC: Contract;
|
USDT_USDC: Contract;
|
||||||
@@ -220,13 +222,23 @@ export class DODOContext {
|
|||||||
contracts.SMART_APPROVE
|
contracts.SMART_APPROVE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//Gas Token
|
||||||
|
this.CHI = await contracts.newContract(
|
||||||
|
contracts.CHI_TOKEN
|
||||||
|
);
|
||||||
|
|
||||||
|
// await this.CHI.methods.mint(140).send(this.sendParam(this.Deployer));
|
||||||
|
|
||||||
this.DODOProxyV1 = await contracts.newContract(
|
this.DODOProxyV1 = await contracts.newContract(
|
||||||
contracts.SMART_SWAP,
|
contracts.SMART_SWAP,
|
||||||
[this.DODOApprove.options.address, this.DODOSellHelper.options.address, this.WETH.options.address]
|
[this.DODOApprove.options.address, this.DODOSellHelper.options.address, this.WETH.options.address, this.CHI.options.address]
|
||||||
|
// [this.DODOApprove.options.address, this.DODOSellHelper.options.address, this.WETH.options.address, "0x0000000000000000000000000000000000000000"]
|
||||||
);
|
);
|
||||||
|
|
||||||
await this.DODOApprove.methods.setDODOProxy(this.DODOProxyV1.options.address).send(this.sendParam(this.Deployer));
|
await this.DODOApprove.methods.setDODOProxy(this.DODOProxyV1.options.address).send(this.sendParam(this.Deployer));
|
||||||
|
|
||||||
|
// await this.CHI.methods.transfer(this.DODOProxyV1.options.address,140).send(this.sendParam(this.Deployer));
|
||||||
|
|
||||||
console.log(log.blueText("[Init dodo context]"));
|
console.log(log.blueText("[Init dodo context]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,10 +68,19 @@ module.exports = {
|
|||||||
return new HDWalletProvider(privKey, "https://mainnet.infura.io/v3/" + infuraId);
|
return new HDWalletProvider(privKey, "https://mainnet.infura.io/v3/" + infuraId);
|
||||||
},
|
},
|
||||||
gas: 3000000,
|
gas: 3000000,
|
||||||
gasPrice: 120000000000,
|
gasPrice: 45000000000,
|
||||||
network_id: 1,
|
network_id: 1,
|
||||||
skipDryRun: true
|
skipDryRun: true
|
||||||
},
|
},
|
||||||
|
bsclive: {
|
||||||
|
provider: function() {
|
||||||
|
return new HDWalletProvider(privKey, "https://bsc-dataseed1.binance.org");
|
||||||
|
},
|
||||||
|
network_id: 56,
|
||||||
|
confirmations: 10,
|
||||||
|
timeoutBlocks: 200,
|
||||||
|
skipDryRun: true
|
||||||
|
},
|
||||||
coverage: {
|
coverage: {
|
||||||
host: "127.0.0.1",
|
host: "127.0.0.1",
|
||||||
port: 6545,
|
port: 6545,
|
||||||
|
|||||||
Reference in New Issue
Block a user