Merge pull request #8 from DODOEX/feature/V2

Feature/v2
This commit is contained in:
owen05
2021-02-13 21:45:18 +08:00
committed by GitHub
16 changed files with 800 additions and 540 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

@@ -0,0 +1,40 @@
/*
Copyright 2020 DODO ZOO.
SPDX-License-Identifier: Apache-2.0
*/
pragma solidity ^0.6.9;
import {SafeERC20} from "../lib/SafeERC20.sol";
import {IERC20} from "../intf/IERC20.sol";
import {InitializableOwnable} from "../lib/InitializableOwnable.sol";
import {IDODOApproveProxy} from "../SmartRoute/DODOApproveProxy.sol";
contract DODORecharge is InitializableOwnable {
using SafeERC20 for IERC20;
address immutable _DODO_TOKEN_;
address immutable _DODO_APPROVE_PROXY_;
event DeductDODO(address user,uint256 _amount);
constructor(address dodoAddress, address dodoApproveProxy) public {
_DODO_TOKEN_ = dodoAddress;
_DODO_APPROVE_PROXY_ = dodoApproveProxy;
}
function deductionDODO(uint256 amount) external {
IDODOApproveProxy(_DODO_APPROVE_PROXY_).claimTokens(_DODO_TOKEN_, msg.sender, address(this), amount);
emit DeductDODO(msg.sender, amount);
}
// ============ Owner Functions ============
function claimToken(address token) public onlyOwner {
uint256 balance = IERC20(token).balanceOf(address(this));
require(balance>0,"no enough token can claim");
IERC20(token).safeTransfer(_OWNER_, balance);
}
}

View File

@@ -12,7 +12,7 @@ import {InitializableOwnable} from "../lib/InitializableOwnable.sol";
//todo
contract Governance is InitializableOwnable {
function getLockedDODO(address account) external pure returns (uint256 lockedDODO) {
lockedDODO = 0;//todo for test
function getLockedvDODO(address account) external pure returns (uint256 lockedvDODO) {
lockedvDODO = 0;//todo for test
}
}

View File

@@ -15,7 +15,7 @@ import {SafeERC20} from "../lib/SafeERC20.sol";
import {IDODOApproveProxy} from "../SmartRoute/DODOApproveProxy.sol";
interface IGovernance {
function getLockedDODO(address account) external view returns (uint256);
function getLockedvDODO(address account) external view returns (uint256);
}
interface IDODOCirculationHelper {
@@ -33,45 +33,50 @@ contract vDODOToken is InitializableOwnable {
string public name = "vDODO Token";
string public symbol = "vDODO";
uint8 public decimals = 18;
uint256 public totalSupply;
mapping(address => mapping(address => uint256)) internal _ALLOWED_;
// ============ 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_;
bool public _CAN_TRANSFER_;
// staking reward parameters
uint256 public dodoPerBlock;
uint256 public _DODO_PER_BLOCK_;
uint256 public constant _SUPERIOR_RATIO_ = 10**17; // 0.1
uint256 public constant _DODO_RATIO_ = 100 * 10**18; // 100
uint256 public dodoFeeBurnRation;
uint256 public constant _DODO_RATIO_ = 100; // 100
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;
struct UserInfo {
uint128 VDODOAmount;
uint128 superiorVDODO;
uint128 stakingPower;
uint128 superiorSP;
address superior;
uint256 credit;
}
// ============ Events ============
event MintVDODO(address user, address superior, uint256 amount);
event RedeemVDODO(address user, uint256 amount);
event MintVDODO(address user, address superior, uint256 mintDODO);
event RedeemVDODO(address user, uint256 receiveDODO, uint256 burnDODO, uint256 feeDODO);
event DonateDODO(address user, uint256 donateDODO);
event SetCantransfer(bool allowed);
event PreDeposit(uint256 dodoAmount);
event ChangePerReward(uint256 dodoPerBlock);
event UpdatedodoFeeBurnRation(uint256 dodoFeeBurnRation);
event UpdateDODOFeeBurnRatio(uint256 dodoFeeBurnRatio);
event Transfer(address indexed from, address indexed to, uint256 amount);
event Approval(address indexed owner, address indexed spender, uint256 amount);
@@ -99,7 +104,6 @@ contract vDODOToken is InitializableOwnable {
_DOOD_GOV_ = dodoGov;
_DODO_TOKEN_ = dodoToken;
_DODO_APPROVE_PROXY_ = dodoApproveProxy;
lastRewardBlock = uint128(block.number);
_DODO_TEAM_ = dodoTeam;
}
@@ -110,15 +114,15 @@ contract vDODOToken is InitializableOwnable {
emit SetCantransfer(allowed);
}
function changePerReward(uint256 _dodoPerBlock) public onlyOwner {
function changePerReward(uint256 dodoPerBlock) public onlyOwner {
_updateAlpha();
dodoPerBlock = _dodoPerBlock;
emit ChangePerReward(_dodoPerBlock);
_DODO_PER_BLOCK_ = dodoPerBlock;
emit ChangePerReward(dodoPerBlock);
}
function updatedodoFeeBurnRation(uint256 _dodoFeeBurnRation) public onlyOwner {
dodoFeeBurnRation = _dodoFeeBurnRation;
emit UpdatedodoFeeBurnRation(_dodoFeeBurnRation);
function updateDODOFeeBurnRatio(uint256 dodoFeeBurnRatio) public onlyOwner {
_DODO_FEE_BURN_RATIO_ = dodoFeeBurnRatio;
emit UpdateDODOFeeBurnRatio(_DODO_FEE_BURN_RATIO_);
}
function updateDODOCirculationHelper(address helper) public onlyOwner {
@@ -128,20 +132,33 @@ contract vDODOToken is InitializableOwnable {
function updateGovernance(address governance) public onlyOwner {
_DOOD_GOV_ = governance;
}
function emergencyWithdraw() public onlyOwner {
uint256 dodoBalance = IERC20(_DODO_TOKEN_).balanceOf(address(this));
IERC20(_DODO_TOKEN_).transfer(_OWNER_, dodoBalance);
}
// ============ Functions ============
// ============ Mint & Redeem & Donate ============
function mint(uint256 dodoAmount, address superiorAddress) public {
require(superiorAddress != address(0) && superiorAddress != msg.sender, "vDODOToken: Superior INVALID");
require(
superiorAddress != address(0) && superiorAddress != msg.sender,
"vDODOToken: Superior INVALID"
);
require(dodoAmount > 0, "vDODOToken: must mint greater than 0");
UserInfo storage user = userInfo[msg.sender];
if (user.superior == address(0)) {
require(
superiorAddress == _DODO_TEAM_ || userInfo[superiorAddress].superior != address(0),
"vDODOToken: INVALID_SUPERIOR_ADDRESS"
);
user.superior = superiorAddress;
}
_updateAlpha();
IDODOApproveProxy(_DODO_APPROVE_PROXY_).claimTokens(
_DODO_TOKEN_,
msg.sender,
@@ -149,54 +166,49 @@ contract vDODOToken is InitializableOwnable {
dodoAmount
);
uint256 newVdodoAmount = DecimalMath.divFloor(dodoAmount,_DODO_RATIO_);
uint256 newStakingPower = DecimalMath.divFloor(dodoAmount, alpha);
UserInfo storage user = userInfo[msg.sender];
_mint(user, newVdodoAmount);
_mint(user, newStakingPower);
uint256 increSuperiorVDODO = DecimalMath.mulFloor(newVdodoAmount, _SUPERIOR_RATIO_);
if (user.superior == address(0)) {
require(superiorAddress == _DODO_TEAM_ || userInfo[superiorAddress].superior != address(0), "vDODOToken: INVALID_SUPERIOR_ADDRESS");
user.superior = superiorAddress;
}
_mintToSuperior(user, increSuperiorVDODO);
emit MintVDODO(msg.sender, superiorAddress, dodoAmount);
}
function redeem(uint256 dodoAmount)
public
balanceEnough(msg.sender, dodoAmount)
{
function redeem(uint256 vdodoAmount, bool all) public balanceEnough(msg.sender, vdodoAmount) {
_updateAlpha();
UserInfo storage user = userInfo[msg.sender];
uint256 vDodoAmount = DecimalMath.divFloor(dodoAmount,_DODO_RATIO_);
_redeem(user, vDodoAmount);
if (user.superior != address(0)) {
uint256 superiorRedeemVDODO = DecimalMath.mulFloor(vDodoAmount, _SUPERIOR_RATIO_);
_redeemFromSuperior(user, superiorRedeemVDODO);
uint256 dodoAmount;
uint256 stakingPower;
if (all) {
stakingPower = uint256(user.stakingPower).sub(DecimalMath.divFloor(user.credit, alpha));
dodoAmount = DecimalMath.mulFloor(stakingPower, alpha);
} else {
dodoAmount = vdodoAmount.mul(_DODO_RATIO_);
stakingPower = DecimalMath.divFloor(dodoAmount, alpha);
}
(uint256 dodoReceive, uint256 burnDodoAmount, uint256 withdrawFeeDodoAmount) = getWithdrawAmount(dodoAmount);
_redeem(user, stakingPower);
(uint256 dodoReceive, uint256 burnDodoAmount, uint256 withdrawFeeDodoAmount) = getWithdrawResult(dodoAmount);
IERC20(_DODO_TOKEN_).transfer(msg.sender, dodoReceive);
if(burnDodoAmount > 0){
if (burnDodoAmount > 0) {
IERC20(_DODO_TOKEN_).transfer(address(0), burnDodoAmount);
}
if(withdrawFeeDodoAmount > 0) {
alpha = uint128(uint256(alpha).add(DecimalMath.divFloor(withdrawFeeDodoAmount, totalSupply)));
}
if (withdrawFeeDodoAmount > 0) {
alpha = uint112(
uint256(alpha).add(
DecimalMath.divFloor(withdrawFeeDodoAmount, _TOTAL_STAKING_POWER_)
)
);
}
emit RedeemVDODO(msg.sender, dodoAmount);
emit RedeemVDODO(msg.sender, dodoReceive, burnDodoAmount, withdrawFeeDodoAmount);
}
function donate(uint256 dodoAmount) public {
IDODOApproveProxy(_DODO_APPROVE_PROXY_).claimTokens(
_DODO_TOKEN_,
@@ -204,46 +216,57 @@ contract vDODOToken is InitializableOwnable {
address(this),
dodoAmount
);
alpha = uint128(uint256(alpha).add(DecimalMath.divFloor(dodoAmount, totalSupply)));
alpha = uint112(
uint256(alpha).add(DecimalMath.divFloor(dodoAmount, _TOTAL_STAKING_POWER_))
);
emit DonateDODO(msg.sender, dodoAmount);
}
// ============ Functions(ERC20) ============
function balanceOf(address account) public view returns (uint256 dodoAmount) {
UserInfo memory user = userInfo[account];
dodoAmount = DecimalMath.mulFloor(uint256(user.VDODOAmount),_DODO_RATIO_.add(getLatestAlpha())).sub(user.credit);
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);
emit PreDeposit(dodoAmount);
}
function availableBalanceOf(address account) public view returns (uint256 balance) {
if(_DOOD_GOV_ == address(0)){
balance = balanceOf(account);
}else {
uint256 lockedBalance = IGovernance(_DOOD_GOV_).getLockedDODO(account);
balance = balanceOf(account).sub(lockedBalance);
}
// ============ ERC20 Functions ============
function totalSupply() public view returns (uint256 vDODOSupply) {
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_;
}
function transfer(address to, uint256 dodoAmount) public returns (bool) {
function transfer(address to, uint256 vDODOAmount) public returns (bool) {
_updateAlpha();
_transfer(msg.sender, to, dodoAmount);
_transfer(msg.sender, to, vDODOAmount);
return true;
}
function approve(address spender, uint256 dodoAmount) public returns (bool) {
_ALLOWED_[msg.sender][spender] = dodoAmount;
emit Approval(msg.sender, spender, dodoAmount);
function approve(address spender, uint256 vDODOAmount) canTransfer public returns (bool) {
_ALLOWED_[msg.sender][spender] = vDODOAmount;
emit Approval(msg.sender, spender, vDODOAmount);
return true;
}
function transferFrom(
address from,
address to,
uint256 dodoAmount
uint256 vDODOAmount
) public returns (bool) {
require(dodoAmount <= _ALLOWED_[from][msg.sender], "ALLOWANCE_NOT_ENOUGH");
require(vDODOAmount <= _ALLOWED_[from][msg.sender], "ALLOWANCE_NOT_ENOUGH");
_updateAlpha();
_transfer(from, to, dodoAmount);
_ALLOWED_[from][msg.sender] = _ALLOWED_[from][msg.sender].sub(dodoAmount);
_transfer(from, to, vDODOAmount);
_ALLOWED_[from][msg.sender] = _ALLOWED_[from][msg.sender].sub(vDODOAmount);
return true;
}
@@ -251,111 +274,135 @@ contract vDODOToken is InitializableOwnable {
return _ALLOWED_[owner][spender];
}
// ============ View Functions ============
// ============ Helper Functions ============
function getLatestAlpha() public view returns(uint256) {
uint256 accuDODO = dodoPerBlock * (block.number - lastRewardBlock);
if (totalSupply > 0) {
return uint256(alpha).add(DecimalMath.divFloor(accuDODO, totalSupply));
function getLatestAlpha() public view returns (uint256 newAlpha, uint256 curDistribution) {
if (_LAST_REWARD_BLOCK_ == 0) {
curDistribution = 0;
} else {
return alpha;
curDistribution = _DODO_PER_BLOCK_ * (block.number - _LAST_REWARD_BLOCK_);
}
if (_TOTAL_STAKING_POWER_ > 0) {
newAlpha = uint256(alpha).add(DecimalMath.divFloor(curDistribution, _TOTAL_STAKING_POWER_));
} else {
newAlpha = alpha;
}
}
function getWithdrawAmount(uint256 dodoAmount) public view returns(uint256 dodoReceive, uint256 burnDodoAmount, uint256 withdrawFeeDodoAmount) {
uint256 vDodoAmount = DecimalMath.divFloor(dodoAmount,_DODO_RATIO_);
uint256 feeRatio = IDODOCirculationHelper(_DODO_CIRCULATION_HELPER_).getDodoWithdrawFeeRatio();
uint256 newAlpha = getLatestAlpha();
uint256 withdrawDodoAmount = DecimalMath.mulFloor(vDodoAmount, _DODO_RATIO_.add(newAlpha));
withdrawFeeDodoAmount = DecimalMath.mulCeil(withdrawDodoAmount, feeRatio);
dodoReceive = withdrawDodoAmount.sub(withdrawFeeDodoAmount);
if(dodoFeeBurnRation > 0){
burnDodoAmount = DecimalMath.mulFloor(withdrawFeeDodoAmount,dodoFeeBurnRation);
withdrawFeeDodoAmount = withdrawFeeDodoAmount.sub(burnDodoAmount);
}else {
burnDodoAmount = 0;
function availableBalanceOf(address account) public view returns (uint256 vDODOAmount) {
if (_DOOD_GOV_ == address(0)) {
vDODOAmount = balanceOf(account);
} else {
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];
(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)
public
view
returns (
uint256 dodoReceive,
uint256 burnDodoAmount,
uint256 withdrawFeeDodoAmount
)
{
uint256 feeRatio =
IDODOCirculationHelper(_DODO_CIRCULATION_HELPER_).getDodoWithdrawFeeRatio();
withdrawFeeDodoAmount = DecimalMath.mulFloor(dodoAmount, feeRatio);
dodoReceive = dodoAmount.sub(withdrawFeeDodoAmount);
burnDodoAmount = DecimalMath.mulFloor(withdrawFeeDodoAmount, _DODO_FEE_BURN_RATIO_);
withdrawFeeDodoAmount = withdrawFeeDodoAmount.sub(burnDodoAmount);
}
function getDODOWithdrawFeeRatio() public view returns (uint256 feeRatio) {
feeRatio = IDODOCirculationHelper(_DODO_CIRCULATION_HELPER_).getDodoWithdrawFeeRatio();
}
function getSuperior(address account) public view returns (address superior) {
return userInfo[account].superior;
}
// ============ 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 vdodoAmount) internal {
require(vdodoAmount <= uint128(-1), "OVERFLOW");
to.VDODOAmount = uint128(uint256(to.VDODOAmount).add(vdodoAmount));
totalSupply = totalSupply.add(vdodoAmount);
function _mint(UserInfo storage to, uint256 stakingPower) internal {
require(stakingPower <= uint128(-1), "OVERFLOW");
UserInfo storage superior = userInfo[to.superior];
uint256 superiorIncreSP = DecimalMath.mulFloor(stakingPower, _SUPERIOR_RATIO_);
uint256 superiorIncreCredit = DecimalMath.mulFloor(superiorIncreSP, alpha);
to.stakingPower = uint128(uint256(to.stakingPower).add(stakingPower));
to.superiorSP = uint128(uint256(to.superiorSP).add(superiorIncreSP));
superior.stakingPower = uint128(uint256(superior.stakingPower).add(superiorIncreSP));
superior.credit = uint128(uint256(superior.credit).add(superiorIncreCredit));
_TOTAL_STAKING_POWER_ = _TOTAL_STAKING_POWER_.add(stakingPower).add(superiorIncreSP);
}
function _mintToSuperior(UserInfo storage user, uint256 vdodoAmount) internal {
if (vdodoAmount > 0) {
user.superiorVDODO = uint128(uint256(user.superiorVDODO).add(vdodoAmount));
UserInfo storage superiorUser = userInfo[user.superior];
_mint(superiorUser, vdodoAmount);
uint256 dodoAmount = DecimalMath.mulCeil(vdodoAmount, _DODO_RATIO_.add(alpha));
superiorUser.credit = superiorUser.credit.add(dodoAmount);
function _redeem(UserInfo storage from, uint256 stakingPower) internal {
from.stakingPower = uint128(uint256(from.stakingPower).sub(stakingPower));
// superior decrease sp = min(stakingPower*0.1, from.superiorSP)
uint256 superiorDecreSP = DecimalMath.mulFloor(stakingPower, _SUPERIOR_RATIO_);
superiorDecreSP = from.superiorSP <= superiorDecreSP ? from.superiorSP : superiorDecreSP;
from.superiorSP = uint128(uint256(from.superiorSP).sub(superiorDecreSP));
UserInfo storage superior = userInfo[from.superior];
uint256 creditSP = DecimalMath.divFloor(superior.credit, alpha);
if (superiorDecreSP >= creditSP) {
superior.credit = 0;
superior.stakingPower = uint128(uint256(superior.stakingPower).sub(creditSP));
} else {
superior.credit = uint128(
uint256(superior.credit).sub(DecimalMath.mulFloor(superiorDecreSP, alpha))
);
superior.stakingPower = uint128(uint256(superior.stakingPower).sub(superiorDecreSP));
}
}
function _redeem(UserInfo storage from, uint256 vdodoAmount) internal {
from.VDODOAmount = uint128(uint256(from.VDODOAmount).sub(vdodoAmount));
totalSupply = totalSupply.sub(vdodoAmount);
}
function _redeemFromSuperior(UserInfo storage user, uint256 vdodoAmount) internal {
if (vdodoAmount > 0) {
vdodoAmount = user.superiorVDODO <= vdodoAmount ? user.superiorVDODO : vdodoAmount;
user.superiorVDODO = uint128(uint256(user.superiorVDODO).sub(vdodoAmount));
UserInfo storage superiorUser = userInfo[user.superior];
uint256 creditVDODO = DecimalMath.divFloor(superiorUser.credit, _DODO_RATIO_.add(alpha));
if (vdodoAmount >= creditVDODO) {
superiorUser.credit = 0;
_redeem(superiorUser, creditVDODO);
} else {
superiorUser.credit = superiorUser.credit.sub(
DecimalMath.mulFloor(vdodoAmount, _DODO_RATIO_.add(alpha))
);
_redeem(superiorUser, vdodoAmount);
}
}
_TOTAL_STAKING_POWER_ = _TOTAL_STAKING_POWER_.sub(stakingPower).sub(superiorDecreSP);
}
function _transfer(
address from,
address to,
uint256 _dodoAmount
) internal balanceEnough(from, _dodoAmount) canTransfer {
uint256 vDODOAmount
) internal canTransfer balanceEnough(from, vDODOAmount) {
require(from != address(0), "transfer from the zero address");
require(to != address(0), "transfer to the zero address");
uint256 _amount = DecimalMath.divFloor(_dodoAmount,_DODO_RATIO_);
require(from != to, "transfer from same with to");
uint256 stakingPower = DecimalMath.divFloor(vDODOAmount * _DODO_RATIO_, alpha);
UserInfo storage fromUser = userInfo[from];
fromUser.VDODOAmount = uint128(uint256(fromUser.VDODOAmount).sub(_amount));
UserInfo storage toUser = userInfo[to];
toUser.VDODOAmount = uint128(uint256(toUser.VDODOAmount).add(_amount));
uint256 superiorRedeemVDODO = DecimalMath.mulFloor(_amount, _SUPERIOR_RATIO_);
_redeem(fromUser, stakingPower);
_mint(toUser, stakingPower);
if (fromUser.superior != address(0)) {
_redeemFromSuperior(fromUser, superiorRedeemVDODO);
}
if (toUser.superior != address(0)) {
_mintToSuperior(toUser, superiorRedeemVDODO);
}
emit Transfer(from, to, _dodoAmount);
emit Transfer(from, to, vDODOAmount);
}
}

View File

@@ -14,3 +14,56 @@ 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
====================================================
network type: kovan
Deploy time: 2021/2/9 下午10:43:23
Deploy type: vDODOToken
vDODOTokenAddress: 0x8e565B96C3B6BB36363183f5D43D667927164e91
Init vDODOTokenAddress Tx: 0x14ed266c46601e4ac34918dd09219551825cf53b87746f39b2b5967a86f35291
DODOCirculationHelperAddress: 0xC4d70FdD0310BcAcA8a6eC85e66e95576CB096E4
Init DODOCirculationHelperAddress Tx: 0xfe3a2e2373f5c3e4a1edf9c508fe6e7065718a93c3d2dc088605ef005eeffa10
vDODOToken setDODOCirculationHelper tx: 0xb8081353a0ce44b7158419992ab8f1c0e2ce9ed74f37299682ca98a29c8d38d1
====================================================
network type: kovan
Deploy time: 2021/2/9 下午10:51:22
Deploy type: vDODOToken
DODOApproveProxy Unlock tx: 0x898ee9683fd23561eacc2c7997a1fbc8784ce71e98d726a99653498f3b8ca978
DODOApproveProxy add tx: 0xc9b63fc733fef275c5d4ded72d63c6b5c16d529f3be9d8d053446b8f850bbc9a
vDODOToken first mint tx: 0x8bf4e65fb02588e8f806f33c813424b10d16c2c5756f05faba92de3d94a4b5fc
vDODOToken injected dodo tx: 0x146f5a4446ff3427e87f3e64b7953f139b5effcf92036bdb880be280bf03fa2d
vDODOToken changeReward tx: 0x913602870c7d25fedc7f21eb9314b7329db032c5141dc3ed432f1d9661a19804
====================================================
network type: live
Deploy time: 2021/2/9 下午11:22:45
Deploy type: DODOMigrationBSC
DODOMigrationBSCAddress: 0x02fCB21dc1cf221939C1d4277fB54016b5d32bC7
====================================================
network type: kovan
Deploy time: 2021/2/13 下午12:25:51
Deploy type: vDODOToken
vDODOTokenAddress: 0x188A86C23c596C8b907b227C1DB34EfE769e5c0b
Init vDODOTokenAddress Tx: 0x203c468d95005fe957e0ee22717b1a098a893be916dc18926de98f8d752832e3
DODOCirculationHelperAddress: 0xbF5B98D74B249B86a2f1099D34CF568e2b5EB5b6
Init DODOCirculationHelperAddress Tx: 0xfc46968cf93ff5324b70ca838e66ab5a4b95a2477a352f30e5e92f02d2cbce4a
vDODOToken setDODOCirculationHelper tx: 0x47216bde498446ee2ed3e4e534c8814ad1e919e4c86f95d5ac619cbf1c1529aa
DODOApproveProxy Unlock tx: 0xac285c252c052144c80722ca67b9e765280f2c45b8e4ff73282fabe26158aba6
DODOApproveProxy add tx: 0x0a9174ac009af95a3273ad3a3a961e997aef48d5c3d2537e0389dd48619f1d06
vDODOToken first mint tx: 0x600c5714df725a86725b36a01c3bf5cfc60853f02b7f7214ca9d80c98eb9e72d
vDODOToken injected dodo tx: 0xf2415de9bafeef0d80afe990b5e36a0ebcd339d6cd604d6388fd72e4f01e0de7
vDODOToken changeReward tx: 0x80c01b5e630acdccc2a96f97d884e207488ee64a18cdfcb4566820473ffe3a1f

View File

@@ -591,3 +591,55 @@ Init DODOProxyV2 Tx: 0x42b4de22ef3a32db868174cc2f99bc3acdc17a77cafa9435e4be998e3
DODOApproveProxy Init tx: 0x34d085f14d73db5df4564d40c74151404ce66f7b14edb7308986bbfc05072f57
DODOApprove Init tx: 0x51d7a94362e44515c6e67b9f9535889863977ea0a3a6f58cc2e8524bdf03f4c3
DODOIncentive ChangeProxy tx: 0xb03cda4c06262131e28c36bed506be52d0621029e4a8dd57fa96d3aecdb81691
====================================================
network type: bsclive
Deploy time: 2021/2/7 下午10:51:39
Deploy type: V2
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 下午10:15:02
Deploy type: V2
DODOApprove Address: 0xa375b128e139ae54EF7F189BC8fEb4624f1c2Afa
DODOApproveProxy Address: 0xE2bf3e72E126f0AD4Aec07AdfA6cc345EEF43bDe
DppFactoryAddress: 0xC65F8087288aa0a118aa6F3228Ef9ecc8187F4b6
Init DppFactory Tx: 0x7c031a17e29c7585704b1669b4fe1ea66e1180aa1990b973fc133f8fd950114a
DODOV2RouteHelper Address: 0xcB3b6cdBe2e57D3e37feba0C55584992Cc1B973F
DODOV2Proxy02 Address: 0x85CAA68ae47f047aa01C48BCaA711CA70a950fFb
Init DODOProxyV2 Tx: 0x72afdcd3795ee00b67b87c88af14227584b1ca7588dd10cdcda11c42331117e6
DODOApproveProxy Init tx: 0x34e33c12750fff4abd34dd368157ad1b2101597f44a3f9783725d8a245860b73
DODOApprove Init tx: 0x1f8ac1bbf54e3b42dc3657485fd837efba382a73342e2ced29b6e9fbdb4edeb4
DODOIncentive ChangeProxy tx: 0xd0427f9a814efb822a36ebf17bbf637d066887adacf636c32455a165d30b768
====================================================
network type: kovan
Deploy time: 2021/2/13 下午12:25:44

View File

@@ -451,3 +451,81 @@ 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
====================================================
network type: kovan
Deploy time: 2021/2/9 下午10:19:34
====================================================
network type: kovan
Deploy time: 2021/2/9 下午10:43:19
====================================================
network type: kovan
Deploy time: 2021/2/9 下午10:48:41
====================================================
network type: kovan
Deploy time: 2021/2/9 下午10:51:19
====================================================
network type: kovan
Deploy time: 2021/2/13 下午12:25:48

View File

@@ -77,26 +77,26 @@ module.exports = async (deployer, network, accounts) => {
chiAddress = "0x0000000000004946c0e9f43f4dee607b0ef1fa1c";
DODOCalleeHelperAddress = "0x36ce1831941d35c3588759B2D084E240a094ad4A";
DODOV1PmmHelperAddress = "0xC972069473a686b1c11Bd9347D719c87e6745d39";
DODORouteV2HelperAddress = "0xD5171044E369Ef316125da5A0Af8E75ea6Cd3A90";
DODORouteV2HelperAddress = "0xcB3b6cdBe2e57D3e37feba0C55584992Cc1B973F";
//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 = "0xC65F8087288aa0a118aa6F3228Ef9ecc8187F4b6";
CpFactoryAddress = "0x9e6E8985D52E91eDf1671f28Ca73bc4F3E219b72";
//Approve
DODOApproveAddress = "0x9e159C2932ceFCD0FdC21458fBAd99a535BC1ccB";
DODOApproveProxyAddress = "0x5ee5B85ddf0b842e0d65f0d295F6954eceFBEeD4";
DODOIncentiveAddress = "0x1f69E3CEAbDc464Ab11bceB15726530CD8AC535E";
DODOTokenAddress = "0xfF2985D13953Cb92ecc585aA2B6A4AF8cB46068f";
DODOApproveAddress = "0xa375b128e139ae54EF7F189BC8fEb4624f1c2Afa";
DODOApproveProxyAddress = "0xE2bf3e72E126f0AD4Aec07AdfA6cc345EEF43bDe";
DODOIncentiveAddress = "0x5cFCc14f7C8be8B138D9fDF7438391b0BFe0589F";
DODOTokenAddress = "0x854b0f89BAa9101e49Bfb357A38071C9db5d0DFa";
//Account
multiSigAddress = accounts[0];
defaultMaintainer = accounts[0];
@@ -134,8 +134,8 @@ module.exports = async (deployer, network, accounts) => {
DODOSellHelperAddress = "0x0F859706AeE7FcF61D5A8939E8CB9dBB6c1EDA33";
WETHAddress = "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c";
chiAddress = "0x0000000000000000000000000000000000000000";
DODOCalleeHelperAddress = "0xDfaf9584F5d229A9DBE5978523317820A8897C5A";
DODORouteV2HelperAddress = "";
DODOCalleeHelperAddress = "0xaaffAd1017D6a13E026A00121BF258C616B25f7C";
DODORouteV2HelperAddress = "0x335aC99bb3E51BDbF22025f092Ebc1Cf2c5cC619";
DODOV1PmmHelperAddress = "0x2BBD66fC4898242BDBD2583BBe1d76E8b8f71445";
//Template
CloneFactoryAddress = "0x03E2427859119E497EB856a166F616a2Ce5f8c88";
@@ -144,17 +144,17 @@ module.exports = async (deployer, network, accounts) => {
DvmTemplateAddress = "0xC3BeD579CaB3EC29B22D9AB99F4E586af42496b9";
DppTemplateAddress = "0x85351262f7474Ebe23FfAcD633cf20A491F1325D";
DppAdminTemplateAddress = "";
DppAdminTemplateAddress = "0x44D5dF24d5Ef52A791D6436Fa45A8D426f6de34e";
CpTemplateAddress = "0x041ABa00c57Dd47abC37A2931dF569a2A2cc57Be";
//Factory
DvmFactoryAddress = "0xf50BDc9E90B7a1c138cb7935071b85c417C4cb8e";
DppFactoryAddress = "";
DppFactoryAddress = "0x9B64c81ba54eA51e1f6B7fefb3cfF8AA6F1e2A09";
CpFactoryAddress = "0x9aE501385Bc7996A2A4a1FBb00c8d3820611BCB5";
//Proxy
DODOApproveAddress = "0xa128Ba44B2738A558A1fdC06d6303d52D3Cef8c1";
DODOApproveProxyAddress = "";
DODOIncentiveAddress = "0x80930Cb1849F7D42531506fF45E66724338A821b";
DODOTokenAddress = "0x497A44c951fCCF92ADfdeD0a5b0162256F147647";
DODOApproveProxyAddress = "0xB76de21f04F677f07D9881174a1D8E624276314C";
DODOIncentiveAddress = "";
DODOTokenAddress = "0x67ee3Cb086F8a16f34beE3ca72FAD36F7Db929e2";
//Account
multiSigAddress = "0x4073f2b9bB95774531b9e23d206a308c614A943a";
defaultMaintainer = "0x4073f2b9bB95774531b9e23d206a308c614A943a";

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

@@ -7,6 +7,7 @@ const DODOBscToken = artifacts.require("DODOBscToken");
const DODOMigrationBSC = artifacts.require("DODOMigrationBSC");
const vDODOToken = artifacts.require("vDODOToken");
const DODOCirculationHelper = artifacts.require("DODOCirculationHelper");
const DODOApproveProxy = artifacts.require("DODOApproveProxy");
module.exports = async (deployer, network, accounts) => {
@@ -16,23 +17,26 @@ module.exports = async (deployer, network, accounts) => {
let DODOCirculationHelperAddress = "";
let GovernanceAddress = "";
let vDODOTokenAddress = "";
let dodoTeam = "";
if (network == "kovan") {
DODOTokenAddress = "0xfF2985D13953Cb92ecc585aA2B6A4AF8cB46068f";
DODOApproveProxyAddress = "0x5ee5B85ddf0b842e0d65f0d295F6954eceFBEeD4";
DODOTokenAddress = "0x854b0f89BAa9101e49Bfb357A38071C9db5d0DFa";
DODOApproveProxyAddress = "0xE2bf3e72E126f0AD4Aec07AdfA6cc345EEF43bDe";
DODOCirculationHelperAddress = "";
vDODOTokenAddress = "";
GovernanceAddress = "0x0000000000000000000000000000000000000000";
//Account
multiSigAddress = accounts[0];
dodoTeam = "0xaac153c1344cA14497A5dd22b1F70C28793625aa";
} else if (network == "live") {
DODOTokenAddress = "0x43dfc4159d86f3a37a5a4b3d4580b888ad7d4ddd";
DODOApproveProxyAddress = " 0x335aC99bb3E51BDbF22025f092Ebc1Cf2c5cC619";
DODOApproveProxyAddress = "0x335aC99bb3E51BDbF22025f092Ebc1Cf2c5cC619";
DODOCirculationHelperAddress = "";
vDODOTokenAddress = "";
GovernanceAddress = "0x0000000000000000000000000000000000000000";
//Account
multiSigAddress = "0x95C4F5b83aA70810D4f142d58e5F7242Bd891CB0";
dodoTeam = "";
} else if (network == "bsclive") {
//Account
multiSigAddress = "0x4073f2b9bB95774531b9e23d206a308c614A943a";
@@ -71,7 +75,8 @@ module.exports = async (deployer, network, accounts) => {
vDODOToken,
GovernanceAddress,
DODOTokenAddress,
DODOApproveProxyAddress
DODOApproveProxyAddress,
dodoTeam
);
vDODOTokenAddress = vDODOToken.address;
logger.log("vDODOTokenAddress: ", vDODOTokenAddress);
@@ -81,7 +86,7 @@ module.exports = async (deployer, network, accounts) => {
}
if (DODOCirculationHelperAddress == "") {
await deployer.deploy(DODOCirculationHelper, vDODOTokenAddress, DODOTokenAddress );
await deployer.deploy(DODOCirculationHelper, vDODOTokenAddress, DODOTokenAddress);
DODOCirculationHelperAddress = DODOCirculationHelper.address;
logger.log("DODOCirculationHelperAddress: ", DODOCirculationHelperAddress);
const DODOCirculationHelperInstance = await DODOCirculationHelper.at(DODOCirculationHelperAddress);
@@ -91,12 +96,29 @@ module.exports = async (deployer, network, accounts) => {
if(network == 'kovan') {
const vDODOTokenInstance = await vDODOToken.at(vDODOTokenAddress);
//changePerReward
var tx = await vDODOTokenInstance.changePerReward("10000000000000000000");
logger.log("vDODOToken changeReward tx: ", tx.tx);
//updateDODOCirculationHelper
tx = await vDODOTokenInstance.updateDODOCirculationHelper(DODOCirculationHelperAddress);
var tx = await vDODOTokenInstance.updateDODOCirculationHelper(DODOCirculationHelperAddress);
logger.log("vDODOToken setDODOCirculationHelper tx: ", tx.tx);
//ApproveProxy add
const DODOApproveProxyInstance = await DODOApproveProxy.at(DODOApproveProxyAddress);
tx = await DODOApproveProxyInstance.unlockAddProxy(vDODOTokenAddress);
logger.log("DODOApproveProxy Unlock tx: ", tx.tx);
tx = await DODOApproveProxyInstance.addDODOProxy();
logger.log("DODOApproveProxy add tx: ", tx.tx);
//Mint DODO first
tx = await vDODOTokenInstance.mint("100000000000000000000000",dodoTeam);
logger.log("vDODOToken first mint tx: ", tx.tx);
//preDepositedBlockReward
tx = await vDODOTokenInstance.preDepositedBlockReward("1000000000000000000000");
logger.log("vDODOToken injected dodo tx: ", tx.tx);
//changePerReward
tx = await vDODOTokenInstance.changePerReward("100000000000000000");
logger.log("vDODOToken changeReward tx: ", tx.tx);
}
}

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

@@ -48,7 +48,7 @@ module.exports = {
MOCK_TARGET_POOL: false,
BSCMigration: false,
DODOBscToken: false,
vDODOToken: false,
vDODOToken: true,
CALLEE: false,
},
@@ -82,7 +82,7 @@ module.exports = {
return new HDWalletProvider(privKey, "https://mainnet.infura.io/v3/" + infuraId);
},
gas: 6000000,
gasPrice: 80000000000,
gasPrice: 120000000000,
network_id: 1,
skipDryRun: true
},