From 60f95d8d724d2791f506f25c42da411999affb48 Mon Sep 17 00:00:00 2001 From: mingda Date: Sun, 7 Feb 2021 15:32:31 +0800 Subject: [PATCH] add dodoBalanceOf and fix balanceOf --- contracts/DODOToken/vDODOToken.sol | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/contracts/DODOToken/vDODOToken.sol b/contracts/DODOToken/vDODOToken.sol index d60ef6f..b61f030 100644 --- a/contracts/DODOToken/vDODOToken.sol +++ b/contracts/DODOToken/vDODOToken.sol @@ -221,12 +221,8 @@ contract vDODOToken is InitializableOwnable { vDODOSupply = IERC20(_DODO_TOKEN_).balanceOf(address(this)) / _DODO_RATIO_; } - function balanceOf(address account) public view returns (uint256 dodoAmount) { - UserInfo memory user = userInfo[account]; - dodoAmount = DecimalMath - .mulFloor(uint256(user.stakingPower), getLatestAlpha()) - .mul(_DODO_RATIO_) - .sub(user.credit); + function balanceOf(address account) public view returns (uint256 vDODOAmount) { + vDODOAmount = dodoBalanceOf(account) / _DODO_RATIO_; } function availableBalanceOf(address account) public view returns (uint256 balance) { @@ -238,6 +234,13 @@ contract vDODOToken is InitializableOwnable { } } + function dodoBalanceOf(address account) public view returns (uint256 dodoAmount) { + UserInfo memory user = userInfo[account]; + dodoAmount = DecimalMath.mulFloor(uint256(user.stakingPower), getLatestAlpha()).sub( + user.credit + ); + } + function transfer(address to, uint256 vDODOAmount) public returns (bool) { _updateAlpha(); _transfer(msg.sender, to, vDODOAmount);