diff --git a/contracts/CrowdPooling/impl/CPStorage.sol b/contracts/CrowdPooling/impl/CPStorage.sol index a788e84..7412c53 100644 --- a/contracts/CrowdPooling/impl/CPStorage.sol +++ b/contracts/CrowdPooling/impl/CPStorage.sol @@ -50,7 +50,7 @@ contract CPStorage is InitializableOwnable, ReentrancyGuard { uint256 public _TOTAL_SHARES_; mapping(address => uint256) internal _SHARES_; - mapping(address => bool) internal _CLAIMED_; + mapping(address => bool) public _CLAIMED_; address public _POOL_FACTORY_; address public _POOL_; diff --git a/contracts/SmartRoute/DODOIncentive.sol b/contracts/SmartRoute/DODOIncentive.sol index 3669aaf..70a0fce 100644 --- a/contracts/SmartRoute/DODOIncentive.sol +++ b/contracts/SmartRoute/DODOIncentive.sol @@ -97,7 +97,7 @@ contract DODOIncentive is InitializableOwnable { } - // ============ Incentive function============ + // ============ Incentive function ============ function triggerIncentive(address fromToken,address toToken, address assetTo) external { require(msg.sender == _DODO_PROXY_, "DODOIncentive:Access restricted"); @@ -128,4 +128,23 @@ contract DODOIncentive is InitializableOwnable { totalReward = uint112(_totalReward); totalDistribution = uint112(_totalDistribution); } + + // ============= Helper function =============== + + function incentiveStatus(address fromToken, address toToken) external view returns (bool isOpen, uint256 reward, uint256 baseRate, uint256 totalRate) { + if(startBlock != 0 && block.number >= startBlock) { + isOpen = true; + baseRate = defaultRate; + uint256 fromRate = boosts[fromToken]; + uint256 toRate = boosts[toToken]; + totalRate = (fromRate >= toRate ? fromRate : toRate) + defaultRate; + uint256 _totalReward = totalReward + (block.number - lastRewardBlock) * dodoPerBlock; + reward = (_totalReward - totalDistribution) * totalRate / 1000; + }else { + isOpen = false; + reward = 0; + baseRate = 0; + totalRate = 0; + } + } } \ No newline at end of file diff --git a/contracts/SmartRoute/DODOV2Proxy01.sol b/contracts/SmartRoute/DODOV2Proxy01.sol index 9bb31ee..3c7e85a 100644 --- a/contracts/SmartRoute/DODOV2Proxy01.sol +++ b/contracts/SmartRoute/DODOV2Proxy01.sol @@ -645,17 +645,22 @@ contract DODOV2Proxy01 is IDODOV2Proxy01, ReentrancyGuard, InitializableOwnable IUni(curPair).swapExactTokensForTokens(curAmountIn,0,portionPath,address(this),deadLine); } } + + 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); - } + // { + // 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); + // } returnAmount = IERC20(_toToken).universalBalanceOf(msg.sender).sub(toTokenOriginBalance); require(returnAmount >= minReturnAmount, "DODOV2Proxy01: Return amount is not enough"); diff --git a/contracts/lib/DODOMath.sol b/contracts/lib/DODOMath.sol index fbd5c25..a847f60 100644 --- a/contracts/lib/DODOMath.sol +++ b/contracts/lib/DODOMath.sol @@ -68,6 +68,9 @@ library DODOMath { uint256 i, uint256 k ) internal pure returns (uint256) { + if (V1 == 0) { + return 0; + } if (k == 0) { return V1.add(DecimalMath.mulFloor(i, delta)); } diff --git a/deploy-detail-v2.0.txt b/deploy-detail-v2.0.txt index 306cc6f..87ccebb 100644 --- a/deploy-detail-v2.0.txt +++ b/deploy-detail-v2.0.txt @@ -206,3 +206,54 @@ Init DODOProxyV2 Tx: 0xc3d8815852219d5a33b8377389f2f9862010c741f9041b3bfb1f97295 DODOApprove Init tx: 0x0fd68e3a962d04ae71815fecff10ae65b09a74fe995ecf064022ae299a6525a1 DODOIncentive ChangeProxy tx: 0xe9e4dc61df5a36b11459530a29f7213b05f1611f043d56d733bf9c725f001782 DODOV2RouteHelper Address: 0x9007007b1923C264088Fa23920109F5297bAd8c7 +==================================================== +network type: kovan +Deploy time: 2021/1/13 下午1:37:29 +Deploy type: V2 +CpTemplateAddress: 0x777e548caf1689cbbF45bc8d6108B5D6102E8d6b +CpFactoryAddress: 0x230399caC89E371A05bC133a671c9882ABEFD828 +==================================================== +network type: kovan +Deploy time: 2021/1/13 下午1:50:37 +Deploy type: V2 +DODOApprove Address: 0x8d11670EFE43E37d05111d63337C51e7bCA212e5 +DODOProxyV2 Address: 0x9543Ab4fd525cb95A736888078cCdE042521103C +Init DODOProxyV2 Tx: 0xefe6930e0eda7f845f2ef66a52692bbe22135a8daff722a64eb3ec5cb0214c5d +DODOApprove Init tx: 0xc6235b0625200e920643a63baed27d1ccee109be9deeb00638e054a3af1fa66c +DODOIncentive ChangeProxy tx: 0x30873957ac46d7bd1056c07b4beaf86813b6aeca92bcf38c47d92943d2a09310 +==================================================== +network type: kovan +Deploy time: 2021/1/13 下午2:43:41 +Deploy type: V2 +DODOApprove Address: 0x2F3512cEf28E2f0ae13832D811d7228E3c27aeBf +DODOIncentiveAddress: 0x51Ff5E4f890d1fdc7407e95FA9F2AD06A32d13Ad +DODOIncentive Init tx: 0xe7232abd0f9cb722cd485dd1c63c853f671bd68a6f28d9b3fe5a1794ef007fa3 +DODOProxyV2 Address: 0x63815694141f87E5D45760E98477f248478818Bd +Init DODOProxyV2 Tx: 0x230685707582e8b282d7c028b9689752b134e28f9c5580208cbd834cfa64c168 +DODOApprove Init tx: 0x2ec35578244751fc06e8037659669b9d1b1b0632dd383c9f0775d6cea426429f +DODOIncentive ChangeProxy tx: 0x9c960a96734e4e21b7e4f8df42b8cc3924bced7dc8f292c0888b831361f1aecc +==================================================== +network type: kovan +Deploy time: 2021/1/13 下午8:21:28 +Deploy type: V2 +==================================================== +network type: kovan +Deploy time: 2021/1/13 下午8:25:38 +Deploy type: V2 +DvmTemplateAddress: 0xC61dD1a8C0242785E290CA41bA84AB319c94FF55 +DppTemplateAddress: 0xF89DBd5e716748A5C0d8a081bED1BF554B50dc59 +DppAdminTemplateAddress: 0xe39E02c4f269c4E235Ca8979a125608644c8924a +CpTemplateAddress: 0x55f940C2244Bb16735baCF7D090134fe636d47ea +DODOApprove Address: 0xFa3C805fDE678E93C3d0954F20471799f892F81d +DODOIncentiveAddress: 0x0b8fa3Bb6E352d74803018e934f742198f6bf68B +DODOIncentive Init tx: 0x7376534859db56c94632d6c75861637b23c4f649e298ad52b5dbdb1273ba3947 +DvmFactoryAddress: 0xdd3dDDaae565E7745b2cAcD980B8a98546bAb978 +Init DvmFactory Tx: 0x67c6573ce7de14878924a916777d325ee0231a878d54a04482b0aecb4d1d1304 +DppFactoryAddress: 0x36ab096ADBfd1491FE90F56a9C782dE7b1019f7c +Init DppFactory Tx: 0x57b1a2794e36b3da85b21aa668c66c390e5cbaa7ab85436df8b4dbe1e4d0ed66 +CpFactoryAddress: 0xDaB9B619A78Fca5FC2f562C5b41Bf44f74c1c239 +DODOV2RouteHelper Address: 0xcA79C9431aB16857f78f9F7EE56Ff698bD518533 +DODOProxyV2 Address: 0x06B5D7590297F7b0DcEcC5E382938EB562D91e1a +Init DODOProxyV2 Tx: 0x1951bece5f30c090c6e6cdd121ddb5cfa17a5ca610e30173ec2e12e8698a6c21 +DODOApprove Init tx: 0xf3a9ff215e335405086c44d11e377cddeef39cb8b028f011cb6ffc1362c03f6e +DODOIncentive ChangeProxy tx: 0xc722cf182f24e03b6ccbc19f261452f1a6019f77b32c4350be8df26c069290f0 diff --git a/kovan-mock-v2.0.txt b/kovan-mock-v2.0.txt index d3fac1d..7099104 100644 --- a/kovan-mock-v2.0.txt +++ b/kovan-mock-v2.0.txt @@ -291,3 +291,6 @@ Create DPP: 0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE-0x43688f367eb83697c3ca5d0 Create DPP: 0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE-0x156595bAF85D5C29E91d959889B022d952190A64 Pool:0x94648109F3DE33B2a04FbAE8Baf73F4Ea83ec259 Tx: 0xec487be5e60ad4614fa804c6798fe32ee5b87b6eb6b47f3d00435d220b8a9b84 Create DPP: 0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA-0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b Pool:0x7e3261fEbD42a045429A7BfDF02307064034E157 Tx: 0x7412f7fbc70e236ffcd8a95193bfacc2926fc0dcfcc98cf0f507acb8489ece66 Create DPP: 0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA-0x156595bAF85D5C29E91d959889B022d952190A64 Pool:0x875bCf57CC98e7c6cfC1F7c80ca0fb2709Bc4F01 Tx: 0x1fe29cf3ff586e914c81f31291912be69a7d73a50396f986ddf143495d8ba3ac +==================================================== +network type: kovan +Deploy time: 2021/1/13 下午8:37:27 diff --git a/migrations/3_deploy_v2.js b/migrations/3_deploy_v2.js index 7b48b0b..7200103 100644 --- a/migrations/3_deploy_v2.js +++ b/migrations/3_deploy_v2.js @@ -81,17 +81,17 @@ module.exports = async (deployer, network, accounts) => { DefaultMtFeeRateAddress = "0xEfdE4225AC747136289979e29f1236527b2E4DB1"; DefaultPermissionAddress = "0xACc7E23368261e1E02103c4e5ae672E7D01f5797"; - DvmTemplateAddress = "0xB13662Fcb9140dD573e74D76BACF2085A853C779"; - DppTemplateAddress = "0x5121e563d6f091945244d02cfE68b1b617206d76"; - DppAdminTemplateAddress = "0x59Fd9F2065b9aA717a51111c31B3cA89291BB866"; - CpTemplateAddress = "0x7b10eE056D1FBeABd0174477418f90032807b06E"; + DvmTemplateAddress = ""; + DppTemplateAddress = ""; + DppAdminTemplateAddress = ""; + CpTemplateAddress = ""; //Factory DvmFactoryAddress = ""; - DppFactoryAddress = "0x6D4a70354cd03ae3A8461eDE9A4dAd445a169a6B"; - CpFactoryAddress = "0x3a4Cdaf1796b985826CF1Ee451CACA991c2f79E1"; + DppFactoryAddress = ""; + CpFactoryAddress = ""; //Approve DODOApproveAddress = ""; - DODOIncentiveAddress = "0xe7F4bd2a486DE815824335353973B2f4B94BaCeA"; + DODOIncentiveAddress = ""; DODOTokenAddress = "0xfF2985D13953Cb92ecc585aA2B6A4AF8cB46068f"; //Account multiSigAddress = accounts[0]; diff --git a/migrations/5_deploy_feerate.js b/migrations/5_deploy_feerate.js index 6a155be..ff01863 100644 --- a/migrations/5_deploy_feerate.js +++ b/migrations/5_deploy_feerate.js @@ -10,13 +10,13 @@ const FeeRateModelLogicUpdate = artifacts.require("FeeRateModelLogicUpdate"); module.exports = async (deployer, network, accounts) => { - let FeeRateModelLogicAddress; - let FeeRateModelLogicUpdateAddress; - await deployer.deploy(FeeRateModelLogic); - FeeRateModelLogicAddress = FeeRateModelLogic.address; + // let FeeRateModelLogicAddress; + // let FeeRateModelLogicUpdateAddress; + // await deployer.deploy(FeeRateModelLogic); + // FeeRateModelLogicAddress = FeeRateModelLogic.address; // logger.log("FeeRateModelLogicAddress: ", FeeRateModelLogicAddress); - await deployer.deploy(FeeRateModelLogicUpdate); - FeeRateModelLogicUpdateAddress = FeeRateModelLogicUpdate.address; + // await deployer.deploy(FeeRateModelLogicUpdate); + // FeeRateModelLogicUpdateAddress = FeeRateModelLogicUpdate.address; // logger.log("FeeRateModelLogicUpdateAddress: ", FeeRateModelLogicUpdateAddress); }; diff --git a/truffle-config.js b/truffle-config.js index 01bb1a1..9173f8a 100644 --- a/truffle-config.js +++ b/truffle-config.js @@ -39,7 +39,7 @@ module.exports = { */ deploySwitch: { DEPLOY_V1: false, - DEPLOY_V2: false, + DEPLOY_V2: true, MOCK_TOKEN: false, MOCK_V2_POOL: false, MOCK_V2_SWAP: false, @@ -66,7 +66,7 @@ module.exports = { provider: function () { return new HDWalletProvider(privKey, "https://kovan.infura.io/v3/" + infuraId); }, - gas: 8000000, + gas: 12000000, gasPrice: 1000000000, network_id: 42, skipDryRun: true