require vDODO transfer from!=to
This commit is contained in:
@@ -333,29 +333,20 @@ contract vDODOToken is InitializableOwnable {
|
|||||||
function _transfer(
|
function _transfer(
|
||||||
address from,
|
address from,
|
||||||
address to,
|
address to,
|
||||||
uint256 _dodoAmount
|
uint256 vDODOAmount
|
||||||
) internal balanceEnough(from, _dodoAmount) canTransfer {
|
) internal canTransfer balanceEnough(from, vDODOAmount) {
|
||||||
require(from != address(0), "transfer from the zero address");
|
require(from != address(0), "transfer from the zero address");
|
||||||
require(to != address(0), "transfer to the zero address");
|
require(to != address(0), "transfer to the zero address");
|
||||||
|
require(from != to, "transfer from same with to");
|
||||||
uint256 _amount = DecimalMath.divFloor(_dodoAmount,_DODO_RATIO_);
|
|
||||||
|
uint256 stakingPower = DecimalMath.divFloor(vDODOAmount * _DODO_RATIO_, alpha);
|
||||||
|
|
||||||
UserInfo storage fromUser = userInfo[from];
|
UserInfo storage fromUser = userInfo[from];
|
||||||
fromUser.VDODOAmount = uint128(uint256(fromUser.VDODOAmount).sub(_amount));
|
|
||||||
|
|
||||||
UserInfo storage toUser = userInfo[to];
|
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)) {
|
emit Transfer(from, to, vDODOAmount);
|
||||||
_redeemFromSuperior(fromUser, superiorRedeemVDODO);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (toUser.superior != address(0)) {
|
|
||||||
_mintToSuperior(toUser, superiorRedeemVDODO);
|
|
||||||
}
|
|
||||||
|
|
||||||
emit Transfer(from, to, _dodoAmount);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user