add todo && smartSwap event update

This commit is contained in:
owen05
2020-11-20 11:05:41 +08:00
parent 93c2270076
commit 857e4fc01a
9 changed files with 30 additions and 10 deletions

View File

@@ -50,7 +50,9 @@ contract DPPVault is DPPStorage {
_checkStatus(); _checkStatus();
} }
//TODO: Route queryfunc 以及 withdraw and reset
// todo 这里需要考虑怎么一个tx同时更新k i 和 fee并reset // todo 这里需要考虑怎么一个tx同时更新k i 和 fee并reset
//TODO: 修改feerate等
function reset() public onlyOwner { function reset() public onlyOwner {
_BASE_TARGET_ = _BASE_TOKEN_.balanceOf(address(this)); _BASE_TARGET_ = _BASE_TOKEN_.balanceOf(address(this));
_QUOTE_TARGET_ = _QUOTE_TOKEN_.balanceOf(address(this)); _QUOTE_TARGET_ = _QUOTE_TOKEN_.balanceOf(address(this));
@@ -67,6 +69,7 @@ contract DPPVault is DPPStorage {
// ============ Assets Transfer ============ // ============ Assets Transfer ============
//TODO确定Amount后内部调用
function withdraw( function withdraw(
address to, address to,
uint256 baseAmount, uint256 baseAmount,

View File

@@ -31,6 +31,7 @@ contract DVMFunding is DVMVault {
} }
// case 3. normal case // case 3. normal case
if (baseReserve > 0 && quoteReserve > 0) { if (baseReserve > 0 && quoteReserve > 0) {
//TODO: (Route合约配合实现)
uint256 baseInputRatio = DecimalMath.divFloor(baseInput, baseReserve); uint256 baseInputRatio = DecimalMath.divFloor(baseInput, baseReserve);
uint256 quoteInputRatio = DecimalMath.divFloor(quoteInput, quoteReserve); uint256 quoteInputRatio = DecimalMath.divFloor(quoteInput, quoteReserve);
uint256 mintRatio = baseInputRatio > quoteInputRatio ? quoteInputRatio : baseInputRatio; uint256 mintRatio = baseInputRatio > quoteInputRatio ? quoteInputRatio : baseInputRatio;

View File

@@ -61,6 +61,7 @@ contract DVMStorage is InitializableOwnable, ReentrancyGuard {
// ============ Setting Functions ============ // ============ Setting Functions ============
//TODO: owner权限问题论证
function setLpFeeRateModel(address newLpFeeRateModel) external onlyOwner { function setLpFeeRateModel(address newLpFeeRateModel) external onlyOwner {
_LP_FEE_RATE_MODEL_ = IFeeRateModel(newLpFeeRateModel); _LP_FEE_RATE_MODEL_ = IFeeRateModel(newLpFeeRateModel);
} }

View File

@@ -49,6 +49,7 @@ contract DVMTrader is DVMVault {
{ {
uint256 baseInput = getBaseInput(); uint256 baseInput = getBaseInput();
uint256 mtFee; uint256 mtFee;
//TODO:tx.origin 的潜在风险,直接写to
(receiveQuoteAmount, mtFee) = querySellBase(tx.origin, baseInput); (receiveQuoteAmount, mtFee) = querySellBase(tx.origin, baseInput);
_transferQuoteOut(to, receiveQuoteAmount); _transferQuoteOut(to, receiveQuoteAmount);
_transferQuoteOut(_MAINTAINER_, mtFee); _transferQuoteOut(_MAINTAINER_, mtFee);

View File

@@ -39,6 +39,7 @@ contract DVMFactory is Ownable {
_DEFAULT_GAS_PRICE_SOURCE_ = defaultGasPriceSource; _DEFAULT_GAS_PRICE_SOURCE_ = defaultGasPriceSource;
} }
function createStandardDODOVendingMachine( function createStandardDODOVendingMachine(
address baseToken, address baseToken,
address quoteToken, address quoteToken,
@@ -62,6 +63,9 @@ contract DVMFactory is Ownable {
k k
); );
//TODO: Create2
//TODO: DVM作为Mapping的字段维护自身属性
//TODO: 创建者索引便于my pool查询
_REGISTRY_[baseToken][quoteToken].push(newVendorMachine); _REGISTRY_[baseToken][quoteToken].push(newVendorMachine);
return newVendorMachine; return newVendorMachine;
} }

View File

@@ -36,7 +36,8 @@ contract SmartSwap is Ownable {
IERC20 indexed toToken, IERC20 indexed toToken,
address indexed sender, address indexed sender,
uint256 fromAmount, uint256 fromAmount,
uint256 returnAmount uint256 returnAmount,
uint256 timeStamp
); );
event ExternalRecord(address indexed to, address indexed sender); event ExternalRecord(address indexed to, address indexed sender);
@@ -104,7 +105,7 @@ contract SmartSwap is Ownable {
require(returnAmount >= minReturnAmount, "DODO SmartSwap: Return amount is not enough"); require(returnAmount >= minReturnAmount, "DODO SmartSwap: Return amount is not enough");
toToken.universalTransfer(msg.sender, returnAmount); toToken.universalTransfer(msg.sender, returnAmount);
emit OrderHistory(fromToken, toToken, msg.sender, fromTokenAmount, returnAmount); emit OrderHistory(fromToken, toToken, msg.sender, fromTokenAmount, returnAmount, block.timestamp);
} }
function externalSwap( function externalSwap(
@@ -137,7 +138,7 @@ contract SmartSwap is Ownable {
require(returnAmount >= minReturnAmount, "DODO SmartSwap: Return amount is not enough"); require(returnAmount >= minReturnAmount, "DODO SmartSwap: Return amount is not enough");
toToken.universalTransfer(msg.sender, returnAmount); toToken.universalTransfer(msg.sender, returnAmount);
emit OrderHistory(fromToken, toToken, msg.sender, fromTokenAmount, returnAmount); emit OrderHistory(fromToken, toToken, msg.sender, fromTokenAmount, returnAmount, block.timestamp);
emit ExternalRecord(to, msg.sender); emit ExternalRecord(to, msg.sender);
} }
} }

View File

@@ -0,0 +1,8 @@
====================================================
network type: kovan
Deploy time: 2020/11/20 上午10:58:49
Deploy type: Smart Route
SmartApprove Address: 0x0E5cf0e4658E371f93a6bDB7E72d6789Aff08666
DODOSellHelper Address: 0xbdEae617F2616b45DCB69B287D52940a76035Fe3
SmartSwap Address: 0x767A6FB2f5e908c4E573CaA2bc7f53D468ffd78E
SmartApprovce setSmartSwap tx: 0xc9efe8b60cba3a2d288d487a7e512a3cfcdd017a25a923477323067546fbbec2

View File

@@ -21,7 +21,7 @@ module.exports = async (deployer, network, accounts) => {
DODOSellHelperAddress = "0xbdEae617F2616b45DCB69B287D52940a76035Fe3"; DODOSellHelperAddress = "0xbdEae617F2616b45DCB69B287D52940a76035Fe3";
DODOZooAddress = "0x92230e929a2226b29ed3441ae5524886347c60c8"; DODOZooAddress = "0x92230e929a2226b29ed3441ae5524886347c60c8";
WETHAddress = "0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b"; WETHAddress = "0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b";
SmartApproveAddress = "0x5627b7DEb3055e1e899003FDca0716b32C382084"; SmartApproveAddress = "";
} else if (network == "live") { } else if (network == "live") {
DODOSellHelperAddress = "0x533da777aedce766ceae696bf90f8541a4ba80eb"; DODOSellHelperAddress = "0x533da777aedce766ceae696bf90f8541a4ba80eb";
DODOZooAddress = "0x3a97247df274a17c59a3bd12735ea3fcdfb49950"; DODOZooAddress = "0x3a97247df274a17c59a3bd12735ea3fcdfb49950";
@@ -35,7 +35,7 @@ module.exports = async (deployer, network, accounts) => {
if (DEPLOY_ROUTE) { if (DEPLOY_ROUTE) {
logger.log("Deploy type: Smart Route"); logger.log("Deploy type: Smart Route");
if (SmartApprove == "") { if (SmartApproveAddress == "") {
await deployer.deploy(SmartApprove); await deployer.deploy(SmartApprove);
SmartApproveAddress = SmartApprove.address; SmartApproveAddress = SmartApprove.address;
} }
@@ -45,7 +45,6 @@ module.exports = async (deployer, network, accounts) => {
} }
logger.log("SmartApprove Address: ", SmartApproveAddress); logger.log("SmartApprove Address: ", SmartApproveAddress);
logger.log("DODOSellHelper Address: ", DODOSellHelperAddress); logger.log("DODOSellHelper Address: ", DODOSellHelperAddress);
await deployer.deploy( await deployer.deploy(
SmartSwap, SmartSwap,
SmartApproveAddress, SmartApproveAddress,

View File

@@ -18,8 +18,9 @@
* *
*/ */
// const HDWalletProvider = require('@truffle/hdwallet-provider'); var HDWalletProvider = require("truffle-hdwallet-provider");
// const infuraKey = "fj4jll3k....."; var privKey = process.env.privKey;
var infuraId = process.env.infuraId;
// //
// const fs = require('fs'); // const fs = require('fs');
// const mnemonic = fs.readFileSync(".secret").toString().trim(); // const mnemonic = fs.readFileSync(".secret").toString().trim();
@@ -52,6 +53,7 @@ module.exports = {
gasPrice: 1, gasPrice: 1,
}, },
kovan: { kovan: {
networkCheckTimeout: 100000,
provider: function() { provider: function() {
return new HDWalletProvider(privKey, "https://kovan.infura.io/v3/" + infuraId); return new HDWalletProvider(privKey, "https://kovan.infura.io/v3/" + infuraId);
}, },
@@ -65,8 +67,8 @@ module.exports = {
provider: function() { provider: function() {
return new HDWalletProvider(privKey, "https://mainnet.infura.io/v3/" + infuraId); return new HDWalletProvider(privKey, "https://mainnet.infura.io/v3/" + infuraId);
}, },
gas: 4000000, gas: 3000000,
gasPrice: 22000000000, gasPrice: 60000000000,
network_id: 1, network_id: 1,
skipDryRun: true skipDryRun: true
}, },