finish vdodo test && update

This commit is contained in:
owen05
2021-02-09 18:56:35 +08:00
parent ec55357330
commit 3b3248851c
14 changed files with 512 additions and 390 deletions

View File

@@ -59,30 +59,25 @@ contract DODOCirculationHelper is InitializableOwnable {
uint256 dodoCirculationAmout = getCirculation();
uint256 x =
DecimalMath.divCeil(
dodoCirculationAmout,
IERC20(_VDODO_TOKEN_).totalSupply()
IERC20(_VDODO_TOKEN_).totalSupply() * 100,
dodoCirculationAmout
);
ratio = geRatioValue(x);
}
function geRatioValue(uint256 input) public view returns (uint256 ratio) {
function geRatioValue(uint256 input) public view returns (uint256) {
// (x - 1)^2 / 81 + (y - 15)^2 / 100 = 1
// y = 5% (x ≤ 1)
// y = 15% (x ≥ 10)
// y = 15% - 10% * sqrt(1-[(x-1)/9]^2)
// y = 15% (x < 0.1)
// y = 5% (x > 0.5)
// y = 0.175 - 0.25 * x
if (input <= 10**18) {
return _MIN_PENALTY_RATIO_;
} else if (input >= 10**19) {
if (input < 10**17) {
return _MAX_PENALTY_RATIO_;
} else if (input > 5 * 10**17) {
return _MIN_PENALTY_RATIO_;
} else {
uint256 xTemp = input.sub(DecimalMath.ONE).div(9);
uint256 premium = DecimalMath.ONE2.sub(xTemp.mul(xTemp)).sqrt();
ratio =
_MAX_PENALTY_RATIO_ -
DecimalMath.mulFloor(_MAX_PENALTY_RATIO_ - _MIN_PENALTY_RATIO_, premium);
return 175 * 10**15 - DecimalMath.mulFloor(input, 25 * 10**16);
}
}
}

View File

@@ -21,9 +21,9 @@ contract DODOMigrationBSC is InitializableOwnable {
// ============ Storage ============
address immutable _ETH_DODO_TOKEN_;
address immutable _DODO_APPROVE_PROXY_;
mapping(address => uint256) internal balances;
address public immutable _ETH_DODO_TOKEN_;
address public immutable _DODO_APPROVE_PROXY_;
mapping(address => uint256) public balances;
constructor(address ethDodoToken, address dodoApproveProxy) public {
_ETH_DODO_TOKEN_ = ethDodoToken;

View File

@@ -37,9 +37,9 @@ contract vDODOToken is InitializableOwnable {
// ============ Storage ============
address immutable _DODO_TOKEN_;
address immutable _DODO_APPROVE_PROXY_;
address immutable _DODO_TEAM_;
address public immutable _DODO_TOKEN_;
address public immutable _DODO_APPROVE_PROXY_;
address public immutable _DODO_TEAM_;
address public _DOOD_GOV_;
address public _DODO_CIRCULATION_HELPER_;
@@ -52,8 +52,11 @@ contract vDODOToken is InitializableOwnable {
uint256 public _DODO_FEE_BURN_RATIO_;
// accounting
uint128 public alpha = 10**18; // 1
uint128 public lastRewardBlock;
uint112 public alpha = 10**18; // 1
uint112 public _TOTAL_BLOCK_DISTRIBUTION_;
uint32 public _LAST_REWARD_BLOCK_;
uint256 public _TOTAL_BLOCK_REWARD_;
uint256 public _TOTAL_STAKING_POWER_;
mapping(address => UserInfo) public userInfo;
@@ -99,7 +102,6 @@ contract vDODOToken is InitializableOwnable {
_DOOD_GOV_ = dodoGov;
_DODO_TOKEN_ = dodoToken;
_DODO_APPROVE_PROXY_ = dodoApproveProxy;
lastRewardBlock = uint128(block.number);
_DODO_TEAM_ = dodoTeam;
}
@@ -210,17 +212,30 @@ contract vDODOToken is InitializableOwnable {
address(this),
dodoAmount
);
alpha = uint128(
alpha = uint112(
uint256(alpha).add(DecimalMath.divFloor(dodoAmount, _TOTAL_STAKING_POWER_))
);
}
function preDepositedBlockReward(uint256 dodoAmount) public {
IDODOApproveProxy(_DODO_APPROVE_PROXY_).claimTokens(
_DODO_TOKEN_,
msg.sender,
address(this),
dodoAmount
);
_TOTAL_BLOCK_REWARD_ = _TOTAL_BLOCK_REWARD_.add(dodoAmount);
}
// ============ ERC20 Functions ============
function totalSupply() public view returns (uint256 vDODOSupply) {
vDODOSupply = IERC20(_DODO_TOKEN_).balanceOf(address(this)) / _DODO_RATIO_;
uint256 totalDODO = IERC20(_DODO_TOKEN_).balanceOf(address(this));
(,uint256 curDistribution) = getLatestAlpha();
uint256 actualDODO = totalDODO.sub(_TOTAL_BLOCK_REWARD_.sub(curDistribution.add(_TOTAL_BLOCK_DISTRIBUTION_)));
vDODOSupply = actualDODO / _DODO_RATIO_;
}
function balanceOf(address account) public view returns (uint256 vDODOAmount) {
vDODOAmount = dodoBalanceOf(account) / _DODO_RATIO_;
}
@@ -231,7 +246,7 @@ contract vDODOToken is InitializableOwnable {
return true;
}
function approve(address spender, uint256 vDODOAmount) public returns (bool) {
function approve(address spender, uint256 vDODOAmount) canTransfer public returns (bool) {
_ALLOWED_[msg.sender][spender] = vDODOAmount;
emit Approval(msg.sender, spender, vDODOAmount);
return true;
@@ -255,29 +270,33 @@ contract vDODOToken is InitializableOwnable {
// ============ Helper Functions ============
function getLatestAlpha() public view returns (uint256) {
uint256 accuDODO = _DODO_PER_BLOCK_ * (block.number - lastRewardBlock);
function getLatestAlpha() public view returns (uint256 newAlpha, uint256 curDistribution) {
curDistribution = _DODO_PER_BLOCK_ * (block.number - _LAST_REWARD_BLOCK_);
if (_TOTAL_STAKING_POWER_ > 0) {
return uint256(alpha).add(DecimalMath.divFloor(accuDODO, _TOTAL_STAKING_POWER_));
newAlpha = uint256(alpha).add(DecimalMath.divFloor(curDistribution, _TOTAL_STAKING_POWER_));
} else {
return alpha;
newAlpha = alpha;
}
}
function availableBalanceOf(address account) public view returns (uint256 balance) {
function availableBalanceOf(address account) public view returns (uint256 vDODOAmount) {
if (_DOOD_GOV_ == address(0)) {
balance = balanceOf(account);
vDODOAmount = balanceOf(account);
} else {
uint256 lockedBalance = IGovernance(_DOOD_GOV_).getLockedvDODO(account);
balance = balanceOf(account).sub(lockedBalance);
uint256 lockedvDODOAmount = IGovernance(_DOOD_GOV_).getLockedvDODO(account);
vDODOAmount = balanceOf(account).sub(lockedvDODOAmount);
}
}
function dodoBalanceOf(address account) public view returns (uint256 dodoAmount) {
UserInfo memory user = userInfo[account];
dodoAmount = DecimalMath.mulFloor(uint256(user.stakingPower), getLatestAlpha()).sub(
user.credit
);
(uint256 newAlpha,) = getLatestAlpha();
uint256 nominalDodo = DecimalMath.mulFloor(uint256(user.stakingPower), newAlpha);
if(nominalDodo > user.credit) {
dodoAmount = nominalDodo - user.credit;
}else {
dodoAmount = 0;
}
}
function getWithdrawResult(uint256 dodoAmount)
@@ -310,10 +329,12 @@ contract vDODOToken is InitializableOwnable {
// ============ Internal Functions ============
function _updateAlpha() internal {
uint256 newAlpha = getLatestAlpha();
require(newAlpha <= uint128(-1), "OVERFLOW");
alpha = uint128(newAlpha);
lastRewardBlock = uint128(block.number);
(uint256 newAlpha, uint256 curDistribution) = getLatestAlpha();
uint256 newTotalDistribution = curDistribution.add(_TOTAL_BLOCK_DISTRIBUTION_);
require(newAlpha <= uint112(-1) && newTotalDistribution <= uint112(-1), "OVERFLOW");
alpha = uint112(newAlpha);
_TOTAL_BLOCK_DISTRIBUTION_ = uint112(newTotalDistribution);
_LAST_REWARD_BLOCK_ = uint32(block.number);
}
function _mint(UserInfo storage to, uint256 stakingPower) internal {

View File

@@ -14,3 +14,19 @@ DODOCirculationHelperAddress: 0x0bfb5Beb854e3104f47C1Cb057DEEB90CB7B9464
Init DODOCirculationHelperAddress Tx: 0x8b2d1b9d3455db665f7ac06b465f1bfc2e0ccddb0aa5cd4bca72bc9c7b69b2d9
vDODOToken changeReward tx: 0x8ed4b35edff17b8ef9480b9c40b7673cf7a50088afb9fb7c7fe50d439930c4cf
vDODOToken setDODOCirculationHelper tx: 0x402a9d1abd299ac8df019cff5d6f79e49b82cae34b356a0f1e0afdb47d7bd811
====================================================
network type: live
Deploy time: 2021/2/8 下午3:06:45
Deploy type: DODOMigrationBSC
====================================================
network type: live
Deploy time: 2021/2/8 下午3:08:35
Deploy type: DODOMigrationBSC
DODOMigrationBSCAddress: 0xb159260989012fA98af560A3Fa6D9cd11a64cf6E
Init DODOMigrationBSCAddress Tx: 0x5e825f52f1eae7f251acd5f36281dcbcd8a7520c3d271aad4907fbbf586da392
====================================================
network type: live
Deploy time: 2021/2/8 下午3:27:50
Deploy type: DODOMigrationBSC
DODOMigrationBSCAddress: 0x958f79e2998DFe417208b9A07D799265B0298e58
Init DODOMigrationBSCAddress Tx: 0x9b9ed65c536b5b53d83b811a754383d48cae00e4e5c80bee74f755c30a9c0748

View File

@@ -599,3 +599,57 @@ DODOIncentiveAddress: 0x4EE6398898F7FC3e648b3f6bA458310ac29cD352
DODOIncentive Init tx: 0xf654d6b6be449f56933ff5b21952efc89eeca4ce71fa21940294d4f5519aadda
DODOV2Proxy02 Address: 0xD56281EF996B6B29874C77D2e1464216E8043127
Init DODOProxyV2 Tx: 0xe1b3c17b93959592b6ec6242651b4a1abde27c927b1ebe5da5cc970c60f7e69f
====================================================
network type: kovan
Deploy time: 2021/2/9 上午8:48:33
Deploy type: V2
DefaultMtFeeRateAddress: 0x57e5b46e400c0C31cA174C8E199fB5fE650DB18a
Init DefaultMtFeeRateAddress Tx: 0x71fdca3d54f1d0b5eea530cb52cdb87945833246c78488ad68bfd4c75fbd7078
DefaultPermissionAddress: 0x82C87c5EB912762676E7a87Aad67D916317c7D0e
Init DefaultPermissionAddress Tx: 0x5d0dd494ed7f6d541b29349b8aeacd5cb80dcdc9f8385903a50bf10c975e8d4d
DvmTemplateAddress: 0x268EA583bc954678DeD93D4832F147604142aDaD
DppAdminTemplateAddress: 0xf63e41A459D9AEcaE4bAE1278ef0ae84F7F2DE56
CpTemplateAddress: 0x973bEbaE41E79c2B4d9EaEE14c2aB85f43673dc3
DODOApprove Address: 0x4A354b8d0DDb7083f066bDaC1f50d23DE221B01C
DODOApproveProxy Address: 0xe778affD2a337b57a9cDAF6f2ba0bebe3e16316E
DODOIncentiveAddress: 0x5cFCc14f7C8be8B138D9fDF7438391b0BFe0589F
DODOIncentive Init tx: 0xd7f67d2bdfa4fe199fd8c54fc5cd0dddaeb4923a374dec69f532032dbf7a5272
DvmFactoryAddress: 0x322F8014C125Da09314d3a68d4d9F427823F17FD
Init DvmFactory Tx: 0x21f1af2c2c991f7f6cea353b68f60f4dfd597a50e6615a4c4fd389aa8ae0baaa
DppFactoryAddress: 0x9fA487762d4329eBDD83a00a82C8a02719Fdf512
Init DppFactory Tx: 0x9aa6052e2c34b015fd298ea7079f3bccd3da86b6fd1f7f644a0e1fa55c6d1497
CpFactoryAddress: 0x9e6E8985D52E91eDf1671f28Ca73bc4F3E219b72
Init CpFactory Tx: 0x332eb5c4d3242fc2cb005e48327c08557cb3eeaeed29335c038f8685042581b8
DODOV2RouteHelper Address: 0x4605149BB2Efab69D4fA37Bc9669f3b6f7bD3F92
DODOV2Proxy02 Address: 0x5b3faEAa344F8134a7E0A269a9dFb3C7898b090D
Init DODOProxyV2 Tx: 0x2341d998ff725cfce55b2494c9ebc61e24a1ed07e65784cf064a282aa6512dbb
DODOApproveProxy Init tx: 0x5438ae07169d56c95349f2028c6516d7b999b9689a1daa7b1f4f3c3d4e4ce36e
DODOApprove Init tx: 0x49813a01135d05674e2086511c57f27fb55b8b5ec5ca5373812d6634db110a38
DODOIncentive ChangeProxy tx: 0xde4919c4a69b5eb58dfa2132c2d41ff163fe95a49fe972f76fb296cd491f7df6
====================================================
network type: kovan
Deploy time: 2021/2/9 上午9:22:06
====================================================
network type: kovan
Deploy time: 2021/2/9 上午9:37:18
====================================================
network type: kovan
Deploy time: 2021/2/9 上午9:45:32
====================================================
network type: kovan
Deploy time: 2021/2/9 上午9:49:16
====================================================
network type: kovan
Deploy time: 2021/2/9 上午9:55:50
====================================================
network type: kovan
Deploy time: 2021/2/9 上午10:00:29
====================================================
network type: kovan
Deploy time: 2021/2/9 上午10:07:02
====================================================
network type: kovan
Deploy time: 2021/2/9 上午10:38:43
====================================================
network type: kovan
Deploy time: 2021/2/9 上午10:39:52

View File

@@ -451,3 +451,66 @@ Deploy time: 2021/2/4 下午5:54:17
====================================================
network type: kovan
Deploy time: 2021/2/4 下午6:12:03
====================================================
network type: kovan
Deploy time: 2021/2/9 上午8:55:06
====================================================
network type: kovan
Deploy time: 2021/2/9 上午9:22:10
Mock POOL Tx: V2
Approve:0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE Tx: 0xeef360809a8a76596ad1df35b0446b5b95bac7dffc9197446461ea3feffe37d7
Approve:0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA Tx: 0x762bfee15a4d64075fec8f1ec316ff88e26c7afd3680e165383597f54569556a
Approve:0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b Tx: 0x90aa6261ceda2f5ca85f47fa837e8c6a922fa360b6608052c268751bc0603561
Approve:0x156595bAF85D5C29E91d959889B022d952190A64 Tx: 0x9da3ab71c06b430fa3701a0893cd03dd505939d93b9437c42bfd3007a58e1eaa
====================================================
network type: kovan
Deploy time: 2021/2/9 上午9:37:23
Mock POOL Tx: V2
Approve:0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE Tx: 0x126e9df26d72d0dd31a34c12b52af93a344e4e75cf21ab421a6ed40576d75da9
Approve:0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA Tx: 0x9f515352cfe82c58da2bbdb569ae174dbc129e2b3ae5152d35815554f5e23205
Approve:0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b Tx: 0x2f1bbbe75d0d702d5a2aadfcfb5f1ea6b5de31592e0c59bd587b0ae15eb6945b
Approve:0x156595bAF85D5C29E91d959889B022d952190A64 Tx: 0x4d2644d6b52fe82c142921a310ef5a9326828fae9335877a3495810b192b7445
Create DVM: 0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE-0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b Pool:0x1A277d421b46AE6574AE726287548c8F1A9fE696 Tx: 0x430ce391328636d6434be3b6b6a06c7904d8451e29c1a63b665187601a189f7f
Create DVM: 0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE-0x156595bAF85D5C29E91d959889B022d952190A64 Pool:0xaA5e59551361aef38fbe56dEB75bEf19934b784c Tx: 0x0f4a8831dd6623784a5f9b90e04e43be7859cee6bd6486f8998cecbcdf01b497
Create DVM: 0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA-0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b Pool:0x9b198c973dbabb7DeF97465d54595E609c6158c3 Tx: 0xa715e83efcc2f884ccf1174d539b4cf3ff387902b8e01ea6e3f6d09b4216118a
Create DVM: 0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA-0x156595bAF85D5C29E91d959889B022d952190A64 Pool:0xf6B54C865c484E889B30F23Ae298538599CB0708 Tx: 0x45cc1fc7e0a3bf1d750a4f9f1baf1c6d5a8a697ed21124f2f265e02ee8be2fdd
Create DPP: 0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE-0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b Pool:0x4DB1Bd2be60A5334C9FE81495Ad14FBe60Ca93E0 Tx: 0xb8db13dd215ec0644abf51d013d8f1b086ab80057d28e244844f3bf9d1c1d168
Create DPP: 0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE-0x156595bAF85D5C29E91d959889B022d952190A64 Pool:0x420083a9CB8B00A7CeBCFEb5Cf87CF387f710f99 Tx: 0xb39f27d3e4caf5785d9ce2b908c7d0efed3755a8989920639c0e56fa5b5867b2
Create DPP: 0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA-0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b Pool:0x431C5Eb805eEe2b61721F2282F6C8ca943088854 Tx: 0x253d4ed17dccfdb546652db3cc7433594401d3f66ec8dbfacf38f1c6a2173211
Create DPP: 0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA-0x156595bAF85D5C29E91d959889B022d952190A64 Pool:0x9bC80A052b273A3E450A011dC6Cf7D626fbB339B Tx: 0xde39181b6563dedc9dfa6f9693d029a3e483e5e49398002b990c2dccb424053f
====================================================
network type: kovan
Deploy time: 2021/2/9 上午9:45:37
Mock POOL Tx: V2
Create DVM: 0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE-0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b Pool:0x09F24c92Dc04a94aB9038A7571f9704D90d8F0f1 Tx: 0xfc09fc20af6a68626e6267eb708bbd957536af578da9c5fd735854dced832e92
Create DVM: 0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA-0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b Pool:0x2AA7d9830Ce612F6bFBf8066f81DD007c47DCD2A Tx: 0xa12d2d0921da80e443fd8d40b061612bc1cc61de5f68901b542bc985aa5a3e45
====================================================
network type: kovan
Deploy time: 2021/2/9 上午9:49:20
Mock POOL Tx: V2
Create DVM: 0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE-0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b Pool:0x09F24c92Dc04a94aB9038A7571f9704D90d8F0f1 Tx: 0x6ee2d127b8ffbc6ec102fa32dcab7e4f81a583650ea565edd660ffb430566042
Create DVM: 0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA-0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b Pool:0x2AA7d9830Ce612F6bFBf8066f81DD007c47DCD2A Tx: 0x55670454f9288bb833390e102062836e3eb3a55568a46869fad83c0b048a81d4
====================================================
network type: kovan
Deploy time: 2021/2/9 上午9:55:55
Mock POOL Tx: V2
====================================================
network type: kovan
Deploy time: 2021/2/9 上午10:00:33
Mock POOL Tx: V2
====================================================
network type: kovan
Deploy time: 2021/2/9 上午10:07:07
Mock POOL Tx: V2
====================================================
network type: kovan
Deploy time: 2021/2/9 上午10:38:48
Mock POOL Tx: V2
Approve:0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA Tx: 0xaf0228c0a967d69750e54f18150b8ee0c7cb3801cb0643fdcb5b6dddcbbadb67
====================================================
network type: kovan
Deploy time: 2021/2/9 上午10:39:56
Mock POOL Tx: V2
Approve:0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA Tx: 0x29017dc8173e6e65768ef17baeffdb006e88d36088be0cc97a53c365ac929e60
Create DPP: 0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE-0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b Pool:0x210912095691C9b0e318c22e49d94170ACAaCd0a Tx: 0x5bf334d720433b4fbfb71a4f75f5755ccd39f0977e59b74e78df083b03d9d9f5
Create DPP: 0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA-0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b Pool:0x25F03Cc8d661D04513D17497dDE752BDF96A8459 Tx: 0xb15244e5e51f2e593adee05c337c00b265636869c59af6589ca49b82f56a86a7

View File

@@ -77,26 +77,26 @@ module.exports = async (deployer, network, accounts) => {
chiAddress = "0x0000000000004946c0e9f43f4dee607b0ef1fa1c";
DODOCalleeHelperAddress = "0x36ce1831941d35c3588759B2D084E240a094ad4A";
DODOV1PmmHelperAddress = "0xC972069473a686b1c11Bd9347D719c87e6745d39";
DODORouteV2HelperAddress = "0xD5171044E369Ef316125da5A0Af8E75ea6Cd3A90";
DODORouteV2HelperAddress = "0x4605149BB2Efab69D4fA37Bc9669f3b6f7bD3F92";
//Template
CloneFactoryAddress = "0xf7959fe661124C49F96CF30Da33729201aEE1b27";
DefaultMtFeeRateAddress = "0x2F7e3B1c22C1baE2224Cef9F8BFe6B13789Fd0F7";
DefaultPermissionAddress = "0xACc7E23368261e1E02103c4e5ae672E7D01f5797";
DefaultMtFeeRateAddress = "0x57e5b46e400c0C31cA174C8E199fB5fE650DB18a";
DefaultPermissionAddress = "0x82C87c5EB912762676E7a87Aad67D916317c7D0e";
DvmTemplateAddress = "0xA6384D1501842e9907D43148E2ca0d50E4ad56E2";
DppTemplateAddress = "0x6b9Db3908ddFD853AD2A42Ab75b5de3f22f137a5";
DppAdminTemplateAddress = "0x2d69731283ac620760309d8b561De11C6166a5F5";
CpTemplateAddress = "0x81c802080c3CE0dE98fcb625670A14Eb8440184a";
DvmTemplateAddress = "0x268EA583bc954678DeD93D4832F147604142aDaD";
DppTemplateAddress = "0xEAdc4943329Cb8139Ee3c8575f6a9B3659cd0591";
DppAdminTemplateAddress = "0xf63e41A459D9AEcaE4bAE1278ef0ae84F7F2DE56";
CpTemplateAddress = "0x973bEbaE41E79c2B4d9EaEE14c2aB85f43673dc3";
//Factory
DvmFactoryAddress = "0xE842d8c9A54B23C4D0cf208daCA3882c0c311353";
DppFactoryAddress = "0x80c03749C22Acbe5EaFEb1d550a32C707a67fc34";
CpFactoryAddress = "0xD25e0A9A464f50191d9C879bE818FbA44680E980";
DvmFactoryAddress = "0x322F8014C125Da09314d3a68d4d9F427823F17FD";
DppFactoryAddress = "0x9fA487762d4329eBDD83a00a82C8a02719Fdf512";
CpFactoryAddress = "0x9e6E8985D52E91eDf1671f28Ca73bc4F3E219b72";
//Approve
DODOApproveAddress = "0x9e159C2932ceFCD0FdC21458fBAd99a535BC1ccB";
DODOApproveProxyAddress = "0x5ee5B85ddf0b842e0d65f0d295F6954eceFBEeD4";
DODOIncentiveAddress = "0x1f69E3CEAbDc464Ab11bceB15726530CD8AC535E";
DODOTokenAddress = "0xfF2985D13953Cb92ecc585aA2B6A4AF8cB46068f";
DODOApproveAddress = "0x4A354b8d0DDb7083f066bDaC1f50d23DE221B01C";
DODOApproveProxyAddress = "0xe778affD2a337b57a9cDAF6f2ba0bebe3e16316E";
DODOIncentiveAddress = "0x5cFCc14f7C8be8B138D9fDF7438391b0BFe0589F";
DODOTokenAddress = "0x854b0f89BAa9101e49Bfb357A38071C9db5d0DFa";
//Account
multiSigAddress = accounts[0];
defaultMaintainer = accounts[0];

View File

@@ -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: "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
// 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: "100000000000000000" //0.1
// },
// {
// 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" //0.7
// },
// {
// baseAddr: "0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA", //ABC1
// quoteAddr: "0x156595bAF85D5C29E91d959889B022d952190A64", //USDT
// lpFeeRate: "3000000000000000", //0.003
// i: "8000000", //8
// k: "600000000000000000" //0.6
// },
{
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 = "0x6DAb26dFE83E484DCC5126F812E3e6AA8e7eEf4D";
let DVMFactoryAddress = "0xE842d8c9A54B23C4D0cf208daCA3882c0c311353";
let DODOApproveAddress = "0x8acF28D9d8124B20b645893b6102950B488dfd29";
let DODOProxyV2Address = "0x3457A15B9ab57FC754789EE83E4BD2BD8f4F50C8";
let DPPFactoryAddress = "0x9fA487762d4329eBDD83a00a82C8a02719Fdf512";
let DVMFactoryAddress = "0x322F8014C125Da09314d3a68d4d9F427823F17FD";
let DODOApproveAddress = "0x4A354b8d0DDb7083f066bDaC1f50d23DE221B01C";
let DODOProxyV2Address = "0x5b3faEAa344F8134a7E0A269a9dFb3C7898b090D";
@@ -152,6 +152,7 @@ module.exports = async (deployer, network, accounts) => {
{//Approve when change DODOApprove Address
const token0Addr = "0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE";
const token1Addr = "0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA";
const wethAddr = "0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b";
// const token2Addr = "0xFE1133ea03d701C5006b7f065bBf987955E7A67C";
// const token3Addr = "0x123ee47BaE3F64d422F2FB18ac444B47c1880F4C";
// const token4Addr = "0x0ab8EF8B19655F32959c83e5fC5cD6536065D28f";
@@ -160,6 +161,7 @@ module.exports = async (deployer, network, accounts) => {
const quote1Addr = "0x156595bAF85D5C29E91d959889B022d952190A64";
const token0 = await ERC20Template.at(token0Addr);
const token1 = await ERC20Template.at(token1Addr);
const weth = await ERC20Template.at(wethAddr);
// const token2 = await ERC20Template.at(token2Addr);
// const token3 = await ERC20Template.at(token3Addr);
// const token4 = await ERC20Template.at(token4Addr);
@@ -167,9 +169,11 @@ module.exports = async (deployer, network, accounts) => {
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");
// 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 weth.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
logger.log("Approve:" + token1Addr + " Tx:", tx.tx);
// tx = await token2.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
// logger.log("Approve:" + token2Addr + " Tx:", tx.tx);
@@ -179,18 +183,18 @@ module.exports = async (deployer, network, accounts) => {
// 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 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 baseInAmount = web3.utils.toWei("100000", 'ether');
const quoteInAmount = web3.utils.toWei("10000", 'mwei');
// const quoteInAmount = web3.utils.toWei("0.5", '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++) {

View File

@@ -27,7 +27,7 @@ module.exports = async (deployer, network, accounts) => {
multiSigAddress = accounts[0];
} else if (network == "live") {
DODOTokenAddress = "0x43dfc4159d86f3a37a5a4b3d4580b888ad7d4ddd";
DODOApproveProxyAddress = " 0x335aC99bb3E51BDbF22025f092Ebc1Cf2c5cC619";
DODOApproveProxyAddress = "0x335aC99bb3E51BDbF22025f092Ebc1Cf2c5cC619";
DODOCirculationHelperAddress = "";
vDODOTokenAddress = "";
GovernanceAddress = "0x0000000000000000000000000000000000000000";

View File

@@ -107,17 +107,19 @@ export class VDODOContext {
this.Deployer
).send(this.sendParam(this.Deployer))
await this.VDODO.methods.changePerReward(decimalStr("1")).send(this.sendParam(this.Deployer));
await this.VDODO.methods.updateDODOCirculationHelper(this.DODOCirculationHelper.options.address).send(this.sendParam(this.Deployer));
await this.mintTestToken(this.VDODO.options.address, decimalStr("100000"));
await this.mintTestToken(allAccounts[8], decimalStr("10000"));
await this.approveProxy(allAccounts[8]);
this.alpha = await this.VDODO.methods.alpha().call();
this.lastRewardBlock = await this.VDODO.methods.lastRewardBlock().call();
await this.VDODO.methods.preDepositedBlockReward(decimalStr("10000")).send(this.sendParam(allAccounts[8]));
var lastRewardBlock = await this.VDODO.methods._LAST_REWARD_BLOCK_().call();
var curBlock = await this.Web3.eth.getBlockNumber();
console.log("init-block:" + lastRewardBlock + " blockNumber:" + curBlock)
await this.VDODO.methods.changePerReward(decimalStr("1")).send(this.sendParam(this.Deployer));
console.log(log.blueText("[Init VDODO context]"));
console.log("init alpha = " + this.alpha);
console.log("init lastRewardBlock = " + this.lastRewardBlock);
}
sendParam(sender, value = "0") {

View File

@@ -16,10 +16,12 @@ let account0: string;
let account1: string;
let account2: string;
let account3: string;
let dodoTeam: string;
let defaultSuperAddress: string;
let owner: string;
async function init(ctx: VDODOContext): Promise<void> {
dodoTeam = ctx.Deployer;
account0 = ctx.SpareAccounts[0];
account1 = ctx.SpareAccounts[1];
account2 = ctx.SpareAccounts[2];
@@ -28,7 +30,9 @@ async function init(ctx: VDODOContext): Promise<void> {
owner = ctx.Deployer
await ctx.mintTestToken(account0, decimalStr("1000"));
await ctx.mintTestToken(account1, decimalStr("1000"));
await ctx.mintTestToken(account2, decimalStr("1000"));
await ctx.mintTestToken(account3, decimalStr("1000"));
await ctx.approveProxy(account0);
await ctx.approveProxy(account1);
@@ -39,39 +43,39 @@ async function init(ctx: VDODOContext): Promise<void> {
}
async function getGlobalState(ctx: VDODOContext, logInfo?: string) {
var alpha = await ctx.VDODO.methods.getLatestAlpha().call();
var lastRewardBlock = await ctx.VDODO.methods.lastRewardBlock().call();
let [alpha,] = await ctx.VDODO.methods.getLatestAlpha().call();
var lastRewardBlock = await ctx.VDODO.methods._LAST_REWARD_BLOCK_().call();
var totalSuppy = await ctx.VDODO.methods.totalSupply().call();
// console.log(logInfo + " alpha:" + fromWei(alpha, 'ether') + " lastRewardBlock:" + lastRewardBlock + " totalSuppy:" + fromWei(totalSuppy, 'ether'));
return [alpha, lastRewardBlock,totalSuppy]
}
async function dodoBalance(ctx: VDODOContext, user: string, logInfo?: string) {
return [alpha, lastRewardBlock, totalSuppy]
}
async function dodoBalance(ctx: VDODOContext, user: string, logInfo?: string) {
var dodo_contract = await ctx.DODO.methods.balanceOf(ctx.VDODO.options.address).call();
var dodo_account = await ctx.DODO.methods.balanceOf(user).call();
// console.log(logInfo + " DODO:" + fromWei(dodo_contract, 'ether') + " account:" + fromWei(dodo_account, 'ether'));
return [dodo_contract, dodo_account]
}
async function getUserInfo(ctx: VDODOContext, user: string, logInfo?: string) {
}
async function getUserInfo(ctx: VDODOContext, user: string, logInfo?: string) {
var info = await ctx.VDODO.methods.userInfo(user).call();
var res = {
"VDODOAmount": info.VDODOAmount,
"superiorVDODO": info.superiorVDODO,
"superior": info.superior,
"credit": info.credit
"stakingPower": info.stakingPower,
"superiorSP": info.superiorSP,
"superior": info.superior,
"credit": info.credit
}
// console.log(logInfo + " VDODOAmount:" + fromWei(info.VDODOAmount, 'ether') + " superiorVDODO:" + fromWei(info.superiorVDODO, 'ether') + " superior:" + info.superior + " credit:" + fromWei(info.credit, 'ether'));
// console.log(logInfo + " stakingPower:" + fromWei(info.stakingPower, 'ether') + " superiorSP:" + fromWei(info.superiorSP, 'ether') + " superior:" + info.superior + " credit:" + fromWei(info.credit, 'ether'));
return res
}
async function mint(ctx: VDODOContext, user: string, mintAmount: string, superior: string) {
}
async function mint(ctx: VDODOContext, user: string, mintAmount: string, superior: string) {
await ctx.VDODO.methods.mint(
mintAmount,
superior
mintAmount,
superior
).send(ctx.sendParam(user));
}
}
describe("vDODO-erc20", () => {
let snapshotId: string;
@@ -93,214 +97,171 @@ describe("vDODO-erc20", () => {
describe("vdodo-erc20", () => {
it("totalSupply", async () => {
var lastRewardBlock = await ctx.VDODO.methods._LAST_REWARD_BLOCK_().call();
var curBlock = await ctx.Web3.eth.getBlockNumber();
console.log("init-block:" + lastRewardBlock + " blockNumber:" + curBlock)
var totalSuppy = await ctx.VDODO.methods.totalSupply().call();
assert(totalSuppy, decimalStr("0.09"))
await ctx.VDODO.methods.mint(decimalStr("10"), dodoTeam).send(ctx.sendParam(account0))
var totalSuppy = await ctx.VDODO.methods.totalSupply().call();
assert(totalSuppy, decimalStr("0.2"))
await ctx.VDODO.methods.mint(decimalStr("10"), dodoTeam).send(ctx.sendParam(account0))
var totalSuppy = await ctx.VDODO.methods.totalSupply().call();
assert(totalSuppy, decimalStr("0.31"))
})
it("transfer-vdodo", async () => {
//检查四个人 【包括from, to 以及各自的上级】info变化
//alpha lastRewardBlock
//各自dodo余额变化
let [,lastRewardBlockStart,] = await getGlobalState(ctx, "before");
await ctx.VDODO.methods.mint(decimalStr("10"),account1).send(ctx.sendParam(account0))
await ctx.VDODO.methods.mint(decimalStr("10"),account3).send(ctx.sendParam(account2))
let [, lastRewardBlockStart,] = await getGlobalState(ctx, "before");
await ctx.VDODO.methods.mint(decimalStr("10"), dodoTeam).send(ctx.sendParam(account0))
await ctx.VDODO.methods.mint(decimalStr("10"), account0).send(ctx.sendParam(account1))
await ctx.VDODO.methods.mint(decimalStr("10"), account1).send(ctx.sendParam(account2))
await ctx.VDODO.methods.mint(decimalStr("10"), account2).send(ctx.sendParam(account3))
//增加一个区块
await ctx.mintTestToken(account0, decimalStr("0"));
let [alpha,lastRewardBlock,] = await getGlobalState(ctx, "after");
assert.equal(lastRewardBlock,Number(lastRewardBlockStart)+11);
let [alpha, lastRewardBlock,] = await getGlobalState(ctx, "after");
assert.equal(alpha, "113833992094861660108");
assert.equal(alpha, "1195775916960005765");
var totalSuppy = await ctx.VDODO.methods.totalSupply().call();
assert.equal(
totalSuppy
, decimalStr("0.210833333333333332"));
assert.equal(totalSuppy, "540000000000000000");
let userInfo0 = await getUserInfo(ctx, account0, "User0 ");
assert.equal(userInfo0.VDODOAmount, decimalStr("0.1"));
assert.equal(userInfo0.superiorVDODO, decimalStr("0.01"));
assert.equal(userInfo0.credit, "0");
let userInfo1 = await getUserInfo(ctx, account1, "User0 Superior ")
assert.equal(userInfo1.VDODOAmount, decimalStr("0.01"));
assert.equal(userInfo1.superiorVDODO, decimalStr("0"));
assert.equal(userInfo1.credit, decimalStr("1"));
assert.equal(userInfo0.stakingPower, "10916666666666666666");
assert.equal(userInfo0.superiorSP, decimalStr("1"));
assert.equal(userInfo0.credit, "999999999999999999");
let userInfo1 = await getUserInfo(ctx, account1, "User1 ")
assert.equal(userInfo1.stakingPower, "10045138888888888889");
assert.equal(userInfo1.superiorSP, "916666666666666666");
assert.equal(userInfo1.credit, "999999999999999999");
let userInfo2 = await getUserInfo(ctx, account2, "User2 ");
assert.equal(userInfo2.VDODOAmount, decimalStr("0.091666666666666666"));
assert.equal(userInfo2.superiorVDODO, decimalStr("0.009166666666666666"));
assert.equal(userInfo2.credit, decimalStr("0"));
let userInfo3 = await getUserInfo(ctx, account3, "User2 Superior");
assert.equal(userInfo3.VDODOAmount, decimalStr("0.009166666666666666"));
assert.equal(userInfo3.superiorVDODO, decimalStr("0"));
assert.equal(userInfo3.credit, decimalStr("0.999999999999999928"));
assert.equal(userInfo2.stakingPower, "9638792438271604945");
assert.equal(userInfo2.superiorSP, "878472222222222222");
assert.equal(userInfo2.credit, "999999999999999999");
let userInfo3 = await getUserInfo(ctx, account3, "User3 ");
assert.equal(userInfo3.stakingPower, "8540702160493827171");
assert.equal(userInfo3.superiorSP, "854070216049382717");
assert.equal(userInfo3.credit, decimalStr("0"));
let [, dodo_u0] = await dodoBalance(ctx, account0, "start")
assert.equal(dodo_u0, "990000000000000000000");
let [, dodo_u1] = await dodoBalance(ctx, account1, "start")
assert.equal(dodo_u1, "0");
assert.equal(dodo_u1, "990000000000000000000");
let [, dodo_u2] = await dodoBalance(ctx, account2, "start")
assert.equal(dodo_u2, "990000000000000000000");
let [, dodo_u3] = await dodoBalance(ctx, account3, "start")
assert.equal(dodo_u3, "0");
assert.equal(dodo_u3, "990000000000000000000");
let account1Balance = await ctx.VDODO.methods.balanceOf(account1).call()
await logGas(await ctx.VDODO.methods.transfer(
account2,
decimalStr("0.1")
), ctx.sendParam(account0), "transfer");
// await ctx.VDODO.methods.transfer(account2,decimalStr("0.1")).send(ctx.sendParam(account0))
account3,
account1Balance
), ctx.sendParam(account1), "transfer");
let userInfo0_after = await getUserInfo(ctx, account0, "userInfo0_after");
let userInfo1_after = await getUserInfo(ctx, account1, "userInfo1_after");
let userInfo2_after = await getUserInfo(ctx, account2, "userInfo2_after");
let userInfo3_after = await getUserInfo(ctx, account3, "userInfo3_after");
assert.equal(userInfo0_after.VDODOAmount, "0");
assert.equal(userInfo0_after.superiorVDODO, "0");
assert.equal(userInfo0_after.stakingPower, "10097456459435626102");
assert.equal(userInfo0_after.superiorSP, decimalStr("1"));
assert.equal(userInfo0_after.credit, "0");
assert.equal(userInfo1_after.VDODOAmount, decimalStr("0.001566666666666667"));
assert.equal(userInfo1_after.superiorVDODO, decimalStr("0"));
assert.equal(userInfo1_after.credit, "0");
assert.equal(userInfo1_after.stakingPower, "1024213041698160810");
assert.equal(userInfo1_after.superiorSP, "14574081947593859");
assert.equal(userInfo1_after.credit, "999999999999999999");
assert.equal(userInfo2_after.VDODOAmount, decimalStr("0.191666666666666666"));
assert.equal(userInfo2_after.superiorVDODO, decimalStr("0.019166666666666666"));
assert.equal(userInfo2_after.credit, "0");
assert.equal(userInfo2_after.stakingPower, "10540885022990677752");
assert.equal(userInfo2_after.superiorSP, "878472222222222222");
assert.equal(userInfo2_after.credit, "2101173516585172447");
assert.equal(userInfo3_after.VDODOAmount, decimalStr("0.019166666666666666"));
assert.equal(userInfo3_after.superiorVDODO, decimalStr("0"));
assert.equal(userInfo3_after.credit, decimalStr("2.185770750988142222"));
assert.equal(userInfo3_after.stakingPower, "17561628007684555250");
assert.equal(userInfo3_after.superiorSP, "1756162800768455524");
assert.equal(userInfo3_after.credit, "0");
let [alphaEnd,lastRewardBlockEnd,totalSuppyEnd] = await getGlobalState(ctx, "end");
assert.equal(alphaEnd, decimalStr("118.577075098814229308"));
assert.equal(totalSuppyEnd, decimalStr("0.212399999999999999"));
assert.equal(lastRewardBlockEnd,Number(lastRewardBlock)+2);
let [, dodo_u0_end] = await dodoBalance(ctx, account0, "end")
assert.equal(dodo_u0_end, "990000000000000000000");
let [, dodo_u1_end] = await dodoBalance(ctx, account1, "end")
assert.equal(dodo_u1_end, "0");
let [, dodo_u2_end] = await dodoBalance(ctx, account2, "end")
assert.equal(dodo_u2_end, "990000000000000000000");
let [, dodo_u3_end] = await dodoBalance(ctx, account3, "end")
assert.equal(dodo_u3_end, "0");
let [alphaEnd, lastRewardBlockEnd, totalSuppyEnd] = await getGlobalState(ctx, "end");
assert.equal(alphaEnd, "1220687915230005885");
assert.equal(totalSuppyEnd, "550000000000000000");
assert.equal(lastRewardBlockEnd, Number(lastRewardBlock) + 2);
});
it("transferFrom-vdodo", async () => {
//检查四个人 【包括from, to 以及各自的上级】info变化
//alpha lastRewardBlock
//各自dodo余额变化
//approve 状态变化
let [,lastRewardBlockStart,] = await getGlobalState(ctx, "before");
await ctx.VDODO.methods.mint(decimalStr("10"),account1).send(ctx.sendParam(account0))
await ctx.VDODO.methods.mint(decimalStr("10"),account3).send(ctx.sendParam(account2))
await ctx.VDODO.methods.mint(decimalStr("10"), dodoTeam).send(ctx.sendParam(account0))
await ctx.VDODO.methods.mint(decimalStr("10"), dodoTeam).send(ctx.sendParam(account1))
//增加一个区块
await ctx.mintTestToken(account0, decimalStr("0"));
let [alpha,lastRewardBlock,] = await getGlobalState(ctx, "after");
assert.equal(lastRewardBlock,Number(lastRewardBlockStart)+11);
let [alpha, lastRewardBlock,] = await getGlobalState(ctx, "after");
assert.equal(alpha, "113833992094861660108");
assert.equal(alpha, "1138339920948616600");
var totalSuppy = await ctx.VDODO.methods.totalSupply().call();
assert.equal(
totalSuppy
, decimalStr("0.210833333333333332"));
assert.equal(totalSuppy, "320000000000000000");
let userInfo0 = await getUserInfo(ctx, account0, "User0 ");
assert.equal(userInfo0.VDODOAmount, decimalStr("0.1"));
assert.equal(userInfo0.superiorVDODO, decimalStr("0.01"));
assert.equal(userInfo0.stakingPower, decimalStr("10"));
assert.equal(userInfo0.superiorSP, decimalStr("1"));
assert.equal(userInfo0.credit, "0");
let userInfo1 = await getUserInfo(ctx, account1, "User0 Superior ")
assert.equal(userInfo1.VDODOAmount, decimalStr("0.01"));
assert.equal(userInfo1.superiorVDODO, decimalStr("0"));
assert.equal(userInfo1.credit, decimalStr("1"));
let userInfo2 = await getUserInfo(ctx, account2, "User2 ");
assert.equal(userInfo2.VDODOAmount, decimalStr("0.091666666666666666"));
assert.equal(userInfo2.superiorVDODO, decimalStr("0.009166666666666666"));
assert.equal(userInfo2.credit, decimalStr("0"));
let userInfo3 = await getUserInfo(ctx, account3, "User2 Superior");
assert.equal(userInfo3.VDODOAmount, decimalStr("0.009166666666666666"));
assert.equal(userInfo3.superiorVDODO, decimalStr("0"));
assert.equal(userInfo3.credit, decimalStr("0.999999999999999928"));
let userInfo1 = await getUserInfo(ctx, account1, "User1 ")
assert.equal(userInfo1.stakingPower, "9166666666666666667");
assert.equal(userInfo1.superiorSP, "916666666666666666");
assert.equal(userInfo1.credit, decimalStr("0"));
let [, dodo_u0] = await dodoBalance(ctx, account0, "start")
assert.equal(dodo_u0, "990000000000000000000");
let [, dodo_u1] = await dodoBalance(ctx, account1, "start")
assert.equal(dodo_u1, "0");
let [, dodo_u2] = await dodoBalance(ctx, account2, "start")
assert.equal(dodo_u2, "990000000000000000000");
let [, dodo_u3] = await dodoBalance(ctx, account3, "start")
assert.equal(dodo_u3, "0");
assert.equal(dodo_u1, "990000000000000000000");
let account0Balance = await ctx.VDODO.methods.balanceOf(account0).call()
await logGas(await ctx.VDODO.methods.approve(
account3,
decimalStr("0.1")
account2,
account0Balance
), ctx.sendParam(account0), "approve");
await logGas(await ctx.VDODO.methods.transferFrom(
account0,
account2,
decimalStr("0.1")
), ctx.sendParam(account3), "transferFrom");
account1,
account0Balance
), ctx.sendParam(account2), "transferFrom");
let userInfo0_after = await getUserInfo(ctx, account0, "userInfo0_after");
let userInfo1_after = await getUserInfo(ctx, account1, "userInfo1_after");
let userInfo2_after = await getUserInfo(ctx, account2, "userInfo2_after");
let userInfo3_after = await getUserInfo(ctx, account3, "userInfo3_after");
assert.equal(userInfo0_after.VDODOAmount, "0");
assert.equal(userInfo0_after.superiorVDODO, "0");
assert.equal(userInfo0_after.stakingPower, "769230769230769236");
assert.equal(userInfo0_after.superiorSP, "76923076923076924");
assert.equal(userInfo0_after.credit, "0");
assert.equal(userInfo1_after.VDODOAmount, decimalStr("0.001891025641025642"));
assert.equal(userInfo1_after.superiorVDODO, decimalStr("0"));
assert.equal(userInfo1_after.stakingPower, "18397435897435897431");
assert.equal(userInfo1_after.superiorSP, "1839743589743589742");
assert.equal(userInfo1_after.credit, "0");
assert.equal(userInfo2_after.VDODOAmount, decimalStr("0.191666666666666666"));
assert.equal(userInfo2_after.superiorVDODO, decimalStr("0.019166666666666666"));
assert.equal(userInfo2_after.stakingPower, "0");
assert.equal(userInfo2_after.superiorSP, "0");
assert.equal(userInfo2_after.credit, "0");
assert.equal(userInfo3_after.VDODOAmount, decimalStr("0.019166666666666666"));
assert.equal(userInfo3_after.superiorVDODO, decimalStr("0"));
assert.equal(userInfo3_after.credit, decimalStr("2.233201581027667914"));
let [alphaEnd,lastRewardBlockEnd,totalSuppyEnd] = await getGlobalState(ctx, "end");
assert.equal(alphaEnd, decimalStr("123.320158102766798508"));
assert.equal(totalSuppyEnd, decimalStr("0.212724358974358974"));
assert.equal(lastRewardBlockEnd,Number(lastRewardBlock)+3);
let [, dodo_u0_end] = await dodoBalance(ctx, account0, "end")
assert.equal(dodo_u0_end, "990000000000000000000");
let [, dodo_u1_end] = await dodoBalance(ctx, account1, "end")
assert.equal(dodo_u1_end, "0");
let [, dodo_u2_end] = await dodoBalance(ctx, account2, "end")
assert.equal(dodo_u2_end, "990000000000000000000");
let [, dodo_u3_end] = await dodoBalance(ctx, account3, "end")
assert.equal(dodo_u3_end, "0");
let [alphaEnd, lastRewardBlockEnd, totalSuppyEnd] = await getGlobalState(ctx, "end");
assert.equal(alphaEnd, "1233201581027667984");
assert.equal(totalSuppyEnd, "340000000000000000");
assert.equal(lastRewardBlockEnd, Number(lastRewardBlock) + 3);
//再次transferFrom 预期revert
//预期revert
await truffleAssert.reverts(
ctx.VDODO.methods.transferFrom(account0,account2,decimalStr("0.1")).send(ctx.sendParam(account3)),
ctx.VDODO.methods.transferFrom(account0, account1, 1).send(ctx.sendParam(account2)),
"ALLOWANCE_NOT_ENOUGH"
)
});
@@ -308,39 +269,41 @@ describe("vDODO-erc20", () => {
it("transfer - close", async () => {
await ctx.VDODO.methods.setCantransfer(false).send(ctx.sendParam(owner))
await ctx.VDODO.methods.mint(decimalStr("10"),defaultSuperAddress).send(ctx.sendParam(account0))
await ctx.VDODO.methods.mint(decimalStr("10"), dodoTeam).send(ctx.sendParam(account0))
assert.equal(
await ctx.DODO.methods.balanceOf(account0).call(),
decimalStr("990")
);
assert.equal(
await ctx.DODO.methods.balanceOf(ctx.VDODO.options.address).call(),
decimalStr("100010")
decimalStr("10010")
);
assert.equal(
await ctx.VDODO.methods.balanceOf(account0).call(),
decimalStr("0.1")
);
assert.equal(
await ctx.VDODO.methods.balanceOf(account1).call(),
decimalStr("0")
);
//预期revert
await truffleAssert.reverts(
ctx.VDODO.methods.transfer(account1,decimalStr("0.1")).send(ctx.sendParam(account0)),
"vDODOToken: not allowed transfer"
)
assert.equal(
await ctx.VDODO.methods.balanceOf(account0).call(),
decimalStr("0.1")
);
assert.equal(
await ctx.VDODO.methods.balanceOf(account1).call(),
await ctx.VDODO.methods.balanceOf(dodoTeam).call(),
decimalStr("0")
);
//预期revert
await truffleAssert.reverts(
ctx.VDODO.methods.transfer(account1, 1).send(ctx.sendParam(account0)),
"vDODOToken: not allowed transfer"
)
//revert 触发产生区块造成vdodo增加
assert.equal(
await ctx.VDODO.methods.balanceOf(account0).call(),
"109090909090909090"
);
assert.equal(
await ctx.VDODO.methods.balanceOf(account1).call(),
decimalStr("0")
);
});
})
});

View File

@@ -13,8 +13,10 @@ import BigNumber from 'bignumber.js';
let account0: string;
let account1: string;
let dodoTeam: string;
async function init(ctx: VDODOContext): Promise<void> {
dodoTeam = ctx.Deployer;
account0 = ctx.SpareAccounts[0];
account1 = ctx.SpareAccounts[1];
@@ -26,13 +28,14 @@ async function init(ctx: VDODOContext): Promise<void> {
}
async function getGlobalState(ctx: VDODOContext, logInfo?: string) {
var alpha = await ctx.VDODO.methods.getLatestAlpha().call();
var lastRewardBlock = await ctx.VDODO.methods.lastRewardBlock().call();
let [alpha,] = await ctx.VDODO.methods.getLatestAlpha().call();
var lastRewardBlock = await ctx.VDODO.methods._LAST_REWARD_BLOCK_().call();
var totalSuppy = await ctx.VDODO.methods.totalSupply().call();
var dodoPerBlock = await ctx.VDODO.methods.dodoPerBlock().call();
// console.log(logInfo + "==> alpha:" + fromWei(alpha, 'ether') + " lastRewardBlock:" + lastRewardBlock + " totalSuppy:" + fromWei(totalSuppy, 'ether')+ " dodoPerBlock:" + fromWei(dodoPerBlock, 'ether'));
return [alpha, lastRewardBlock,dodoPerBlock]
}
var dodoPerBlock = await ctx.VDODO.methods._DODO_PER_BLOCK_().call();
console.log(logInfo + "==> alpha:" + fromWei(alpha, 'ether') + " lastRewardBlock:" + lastRewardBlock + " totalSuppy:" + fromWei(totalSuppy, 'ether') + " dodoPerBlock:" + fromWei(dodoPerBlock, 'ether'));
return [alpha, lastRewardBlock, dodoPerBlock]
}
describe("vDODO-owner", () => {
let snapshotId: string;
let ctx: VDODOContext;
@@ -54,79 +57,84 @@ describe("vDODO-owner", () => {
it("change-reward", async () => {
//改变前alpha lastRewardBlock 状态
let [alpha,lastRewardBlock,dodoPerBlock] = await getGlobalState(ctx, "before");
let [alpha, lastRewardBlock, dodoPerBlock] = await getGlobalState(ctx, "before");
//change-reward
await ctx.VDODO.methods.changePerReward(decimalStr("2")).send(ctx.sendParam(ctx.Deployer))
//改变后状态
let [alphaAfter,lastRewardBlockAfter,dodoPerBlockAfter] = await getGlobalState(ctx, "after");
let [alphaAfter, lastRewardBlockAfter, dodoPerBlockAfter] = await getGlobalState(ctx, "after");
assert.equal(
await lastRewardBlock,
Number(lastRewardBlockAfter)-7
);
assert.equal(//totalSupply==0
await alpha,
alphaAfter
alpha,
"1000000000000000000"
);
assert.notEqual(
await dodoPerBlock,
dodoPerBlockAfter
"2000000000000000000"
);
});
it("donate", async () => {
//改变前alpha lastRewardBlock 状态
let [before,lastRewardBlock,] = await getGlobalState(ctx, "before");
await logGas(await ctx.VDODO.methods.mint(
decimalStr("100"),
account1
), ctx.sendParam(account0), "mint-fisrt");
dodoTeam
), ctx.sendParam(account0), "mint-fisrt");
let [alphaBefore, lastRewardBlock,] = await getGlobalState(ctx, "before");
await logGas(await ctx.VDODO.methods.donate(
decimalStr("100")
), ctx.sendParam(account0), "donate");
let [alphaAfter,lastRewardBlockAfter,] = await getGlobalState(ctx, "after");
assert.notEqual(
before,
alphaAfter
let [alphaAfter, lastRewardBlockAfter,] = await getGlobalState(ctx, "after");
assert.equal(
alphaBefore,
"1000000000000000000"
);
assert.equal(
alphaAfter,
"191818181818181818180"//newAlpha +amount/totalSupply
alphaAfter,
"1918181818181818180"//newAlpha +amount/totalSupply
);
assert.equal(
lastRewardBlock,
Number(lastRewardBlockAfter)-7
lastRewardBlockAfter
);
});
it("read-helper", async () => {
//不同amount对应的feeRatio 5 5-15 15
let ratio0 = await ctx.DODOCirculationHelper.methods.geRatioValue(decimalStr("0.2")).call()//<=1 ->5
let ratio0 = await ctx.DODOCirculationHelper.methods.geRatioValue(decimalStr("0.51")).call()
assert.equal(
ratio0,
decimalStr("0.05")
);
let ratio1 = await ctx.DODOCirculationHelper.methods.geRatioValue(decimalStr("11")).call()//>=10 ->15
let ratio1 = await ctx.DODOCirculationHelper.methods.geRatioValue(decimalStr("0.5")).call()
assert.equal(
ratio1,
decimalStr("0.05")
);
let ratio2 = await ctx.DODOCirculationHelper.methods.geRatioValue(decimalStr("0.09")).call()
assert.equal(
ratio2,
decimalStr("0.15")
);
let ratio2 = await ctx.DODOCirculationHelper.methods.geRatioValue(decimalStr("6")).call()//-->5-15
let ratio3 = await ctx.DODOCirculationHelper.methods.geRatioValue(decimalStr("0.1")).call()
assert.equal(
ratio2,
decimalStr("0.066852058071690192")
ratio3,
decimalStr("0.15")
);
let ratio4 = await ctx.DODOCirculationHelper.methods.geRatioValue(decimalStr("0.3")).call()
assert.equal(
ratio4,
decimalStr("0.1")
);
// console.log("ratio2 = "+ fromWei(ratio2, 'ether'));
assert.isAbove(Number(ratio2),Number(ratio0))
assert.isBelow(Number(ratio2),Number(ratio1))
});
})
});

View File

@@ -39,8 +39,8 @@ async function init(ctx: VDODOContext): Promise<void> {
}
async function getGlobalState(ctx: VDODOContext, logInfo?: string) {
var alpha = await ctx.VDODO.methods.getLatestAlpha().call();
var lastRewardBlock = await ctx.VDODO.methods.lastRewardBlock().call();
let [alpha,] = await ctx.VDODO.methods.getLatestAlpha().call();
var lastRewardBlock = await ctx.VDODO.methods._LAST_REWARD_BLOCK_().call();
var totalSuppy = await ctx.VDODO.methods.totalSupply().call();
console.log(logInfo + " alpha:" + fromWei(alpha, 'ether') + " lastRewardBlock:" + lastRewardBlock + " totalSuppy:" + fromWei(totalSuppy, 'ether'));
return [alpha, lastRewardBlock]
@@ -57,12 +57,12 @@ async function dodoBalance(ctx: VDODOContext, user: string, logInfo?: string) {
async function getUserInfo(ctx: VDODOContext, user: string, logInfo?: string) {
var info = await ctx.VDODO.methods.userInfo(user).call();
var res = {
"VDODOAmount": info.VDODOAmount,
"superiorVDODO": info.superiorVDODO,
"stakingPower": info.stakingPower,
"superiorSP": info.superiorSP,
"superior": info.superior,
"credit": info.credit
}
console.log(logInfo + " VDODOAmount:" + fromWei(info.VDODOAmount, 'ether') + " superiorVDODO:" + fromWei(info.superiorVDODO, 'ether') + " superior:" + info.superior + " credit:" + fromWei(info.credit, 'ether'));
console.log(logInfo + " stakingPower:" + fromWei(info.stakingPower, 'ether') + " superiorSP:" + fromWei(info.superiorSP, 'ether') + " superior:" + info.superior + " credit:" + fromWei(info.credit, 'ether'));
return res
}
@@ -112,14 +112,14 @@ describe("VDODO", () => {
let superiorInfo = await getUserInfo(ctx, dodoTeam, "Superior after")
let [, dodo_u] = await dodoBalance(ctx, account0, "after")
assert.equal(alpha, "101818181818181818181");
assert.equal(userInfo.VDODOAmount, "1000000000000000000");
assert.equal(userInfo.superiorVDODO, "100000000000000000");
assert.equal(alpha, "1018181818181818181");
assert.equal(userInfo.stakingPower, "100000000000000000000");
assert.equal(userInfo.superiorSP, "10000000000000000000");
assert.equal(userInfo.credit, "0");
assert.equal(userInfo.superior, dodoTeam);
assert.equal(superiorInfo.VDODOAmount, "100000000000000000");
assert.equal(superiorInfo.superiorVDODO, "0");
assert.equal(superiorInfo.stakingPower, "10000000000000000000");
assert.equal(superiorInfo.superiorSP, "0");
assert.equal(superiorInfo.credit, "10000000000000000000");
assert.equal(superiorInfo.superior, "0x0000000000000000000000000000000000000000");
@@ -147,15 +147,15 @@ describe("VDODO", () => {
let superiorInfo = await getUserInfo(ctx, dodoTeam, "Superior after")
let [, dodo_u] = await dodoBalance(ctx, account0, "after")
assert.equal(alpha, "101365693130399012751");
assert.equal(userInfo.VDODOAmount, "1990990990990990990");
assert.equal(userInfo.superiorVDODO, "199099099099099099");
assert.equal(alpha, "1013656931303990126");
assert.equal(userInfo.stakingPower, "199099099099099099188");
assert.equal(userInfo.superiorSP, "19909909909909909918");
assert.equal(userInfo.credit, "0");
assert.equal(userInfo.superior, dodoTeam);
assert.equal(superiorInfo.VDODOAmount, "199099099099099099");
assert.equal(superiorInfo.superiorVDODO, "0");
assert.equal(superiorInfo.credit, "19999999999999999990");
assert.equal(superiorInfo.stakingPower, "19909909909909909918");
assert.equal(superiorInfo.superiorSP, "0");
assert.equal(superiorInfo.credit, "19999999999999999999");
assert.equal(superiorInfo.superior, "0x0000000000000000000000000000000000000000");
assert.equal(dodo_u, "99800000000000000000000")
@@ -185,15 +185,15 @@ describe("VDODO", () => {
let superiorInfo = await getUserInfo(ctx, dodoTeam, "Superior after")
let [, dodo_u] = await dodoBalance(ctx, account0, "after")
assert.equal(alpha, "101671011483201419416");
assert.equal(userInfo.VDODOAmount, "1986527067608148689");
assert.equal(userInfo.superiorVDODO, "198652706760814868");
assert.equal(alpha, "1016710114832014192");
assert.equal(userInfo.stakingPower, "198652706760814869070");
assert.equal(userInfo.superiorSP, "19865270676081486907");
assert.equal(userInfo.credit, "0");
assert.equal(userInfo.superior, dodoTeam);
assert.equal(superiorInfo.VDODOAmount, "297751805859913967");
assert.equal(superiorInfo.superiorVDODO, "0");
assert.equal(superiorInfo.credit, "29999999999999999897");
assert.equal(superiorInfo.stakingPower, "29775180585991396825");
assert.equal(superiorInfo.superiorSP, "0");
assert.equal(superiorInfo.credit, "29999999999999999998");
assert.equal(superiorInfo.superior, "0x0000000000000000000000000000000000000000")
@@ -201,8 +201,8 @@ describe("VDODO", () => {
let otherInfo = await getUserInfo(ctx, account1, "Superior after")
assert.equal(otherInfo.VDODOAmount, "990990990990990990");
assert.equal(otherInfo.superiorVDODO, "99099099099099099");
assert.equal(otherInfo.stakingPower, "99099099099099099188");
assert.equal(otherInfo.superiorSP, "9909909909909909918");
assert.equal(otherInfo.credit, "0");
assert.equal(otherInfo.superior, dodoTeam)
@@ -213,11 +213,11 @@ describe("VDODO", () => {
it("redeem-amount-read", async () => {
await mint(ctx, account0, decimalStr("100"), dodoTeam)
let [dodoReceive, burnDodoAmount, withdrawFeeDodoAmount] = await ctx.VDODO.methods.getWithdrawAmount(decimalStr("1")).call();
let [dodoReceive, burnDodoAmount, withdrawFeeDodoAmount] = await ctx.VDODO.methods.getWithdrawResult(decimalStr("1")).call();
assert.equal(dodoReceive, decimalStr("85"));
assert.equal(dodoReceive, decimalStr("0.85"));
assert.equal(burnDodoAmount, decimalStr("0"));
assert.equal(withdrawFeeDodoAmount, decimalStr("15"));
assert.equal(withdrawFeeDodoAmount, decimalStr("0.15"));
});
@@ -229,25 +229,25 @@ describe("VDODO", () => {
await getUserInfo(ctx, dodoTeam, "Superior before")
await dodoBalance(ctx, account0, "before")
await logGas(await ctx.VDODO.methods.redeem(decimalStr("10")), ctx.sendParam(account0), "redeem-partial-haveMint");
await logGas(await ctx.VDODO.methods.redeem(decimalStr("10"), false), ctx.sendParam(account0), "redeem-partial-haveMint");
let [alpha,] = await getGlobalState(ctx, "after");
let userInfo = await getUserInfo(ctx, account0, "User after");
let superiorInfo = await getUserInfo(ctx, dodoTeam, "Superior after")
let [, dodo_u] = await dodoBalance(ctx, account0, "after")
assert.equal(alpha, "101524380165289256197");
assert.equal(userInfo.VDODOAmount, "90000000000000000000");
assert.equal(userInfo.superiorVDODO, "9000000000000000000");
assert.equal(alpha, "1015242271212274241");
assert.equal(userInfo.stakingPower, "9000090900827197526589");
assert.equal(userInfo.superiorSP, "900009090082719752659");
assert.equal(userInfo.credit, "0");
assert.equal(userInfo.superior, dodoTeam);
assert.equal(superiorInfo.VDODOAmount, "9000000000000000000");
assert.equal(superiorInfo.superiorVDODO, "0");
assert.equal(superiorInfo.credit, "899990909090909090910");
assert.equal(superiorInfo.stakingPower, "900009090082719752659");
assert.equal(superiorInfo.superiorSP, "0");
assert.equal(superiorInfo.credit, "900000000000000000001");
assert.equal(superiorInfo.superior, "0x0000000000000000000000000000000000000000");
assert.equal(dodo_u, "90850077272727272727265")
assert.equal(dodo_u, "90850000000000000000000")
});
@@ -266,25 +266,25 @@ describe("VDODO", () => {
let dodoTeamVdodoAmount = await ctx.VDODO.methods.balanceOf(dodoTeam).call()
await logGas(await ctx.VDODO.methods.redeem((dodoTeamVdodoAmount - 3000) + ""), ctx.sendParam(dodoTeam), "redeem-partial-NotMint");
await logGas(await ctx.VDODO.methods.redeem((dodoTeamVdodoAmount - 3000) + "", false), ctx.sendParam(dodoTeam), "redeem-partial-NotMint");
let [alpha,] = await getGlobalState(ctx, "after");
let userInfo = await getUserInfo(ctx, dodoTeam, "User after");
let superiorInfo = await getUserInfo(ctx, account3, "One of referer after")
let [, dodo_u] = await dodoBalance(ctx, dodoTeam, "after")
assert.equal(alpha, "101909933011338172201");
assert.equal(userInfo.VDODOAmount, "393425809544634067");
assert.equal(userInfo.superiorVDODO, "0");
assert.equal(userInfo.credit, "39999999999999999876");
assert.equal(alpha, "1019099117914144640");
assert.equal(userInfo.stakingPower, "39343185109576338546");
assert.equal(userInfo.superiorSP, "0");
assert.equal(userInfo.credit, "39999999999999999997");
assert.equal(userInfo.superior, "0x0000000000000000000000000000000000000000");
assert.equal(superiorInfo.VDODOAmount, "986527067608148689");
assert.equal(superiorInfo.superiorVDODO, "98652706760814868");
assert.equal(superiorInfo.stakingPower, "98652706760814869070");
assert.equal(superiorInfo.superiorSP, "9865270676081486907");
assert.equal(superiorInfo.credit, "0");
assert.equal(superiorInfo.superior, dodoTeam);
assert.equal(dodo_u, "232341473424735076")
assert.equal(dodo_u, "231818181817926710")
});
@@ -298,27 +298,25 @@ describe("VDODO", () => {
await getUserInfo(ctx, dodoTeam, "Superior before")
await dodoBalance(ctx, account1, "before")
let account1VdodoAmount = await ctx.VDODO.methods.balanceOf(account1).call()
await logGas(await ctx.VDODO.methods.redeem(account1VdodoAmount), ctx.sendParam(account1), "redeem-all-haveMint");
await logGas(await ctx.VDODO.methods.redeem(0, true), ctx.sendParam(account1), "redeem-all-haveMint");
let [alpha,] = await getGlobalState(ctx, "after");
let userInfo = await getUserInfo(ctx, account1, "User after");
let superiorInfo = await getUserInfo(ctx, dodoTeam, "Superior after")
let [, dodo_u] = await dodoBalance(ctx, account1, "after")
assert.equal(alpha, "100154467726495446770");
assert.equal(userInfo.VDODOAmount, "0");
assert.equal(userInfo.superiorVDODO, "0");
assert.equal(alpha, "1001544677264954465");
assert.equal(userInfo.stakingPower, "0");
assert.equal(userInfo.superiorSP, "0");
assert.equal(userInfo.credit, "0");
assert.equal(userInfo.superior, dodoTeam);
assert.equal(superiorInfo.VDODOAmount, "10000000000000000000");
assert.equal(superiorInfo.superiorVDODO, "0");
assert.equal(superiorInfo.credit, "999999099990999910000");
assert.equal(superiorInfo.stakingPower, "1000000000000000000000");
assert.equal(superiorInfo.superiorSP, "0");
assert.equal(superiorInfo.credit, "999999099990999910008");
assert.equal(superiorInfo.superior, "0x0000000000000000000000000000000000000000");
assert.equal(dodo_u, "985007650076500764963")
assert.equal(dodo_u, "985007650076500764931")
});
@@ -335,27 +333,25 @@ describe("VDODO", () => {
await getUserInfo(ctx, account3, "One of referer before");
await dodoBalance(ctx, dodoTeam, "before")
let dodoTeamVdodoAmount = await ctx.VDODO.methods.balanceOf(dodoTeam).call()
await logGas(await ctx.VDODO.methods.redeem(dodoTeamVdodoAmount), ctx.sendParam(dodoTeam), "redeem-all-NotMint");
await logGas(await ctx.VDODO.methods.redeem(0, true), ctx.sendParam(dodoTeam), "redeem-all-NotMint");
let [alpha,] = await getGlobalState(ctx, "after");
let userInfo = await getUserInfo(ctx, dodoTeam, "User after");
let superiorInfo = await getUserInfo(ctx, account3, "One of referer after")
let [, dodo_u] = await dodoBalance(ctx, dodoTeam, "after")
assert.equal(alpha, "101909933011338182738");
assert.equal(userInfo.VDODOAmount, "393425809544631067");
assert.equal(userInfo.superiorVDODO, "0");
assert.equal(userInfo.credit, "39999999999999999876");
assert.equal(alpha, "1019130459045726342");
assert.equal(userInfo.stakingPower, "39253971537899000903");
assert.equal(userInfo.superiorSP, "0");
assert.equal(userInfo.credit, "39999999999999999997");
assert.equal(userInfo.superior, "0x0000000000000000000000000000000000000000");
assert.equal(superiorInfo.VDODOAmount, "986527067608148689");
assert.equal(superiorInfo.superiorVDODO, "98652706760814868");
assert.equal(superiorInfo.stakingPower, "98652706760814869070");
assert.equal(superiorInfo.superiorSP, "9865270676081486907");
assert.equal(superiorInfo.credit, "0");
assert.equal(superiorInfo.superior, dodoTeam);
assert.equal(dodo_u, "232341473424994923")
assert.equal(dodo_u, "309090909090909029")
});
})
});

View File

@@ -42,7 +42,7 @@ module.exports = {
DEPLOY_V2: false,
ADAPTER: false,
MOCK_TOKEN: false,
MOCK_V2_POOL: false,
MOCK_V2_POOL: true,
MOCK_V2_SWAP: false,
MANUAL_ADD_POOL: false,
MOCK_TARGET_POOL: false,
@@ -82,7 +82,7 @@ module.exports = {
return new HDWalletProvider(privKey, "https://mainnet.infura.io/v3/" + infuraId);
},
gas: 6000000,
gasPrice: 80000000000,
gasPrice: 100000000000,
network_id: 1,
skipDryRun: true
},