fix dodomath
This commit is contained in:
@@ -97,7 +97,7 @@ contract DODOIncentive is InitializableOwnable {
|
||||
}
|
||||
|
||||
|
||||
// ============ Incentive function============
|
||||
// ============ Incentive function ============
|
||||
|
||||
function triggerIncentive(address fromToken,address toToken, address assetTo) external {
|
||||
require(msg.sender == _DODO_PROXY_, "DODOIncentive:Access restricted");
|
||||
@@ -128,4 +128,23 @@ contract DODOIncentive is InitializableOwnable {
|
||||
totalReward = uint112(_totalReward);
|
||||
totalDistribution = uint112(_totalDistribution);
|
||||
}
|
||||
|
||||
// ============= Helper function ===============
|
||||
|
||||
function incentiveStatus(address fromToken, address toToken) external view returns (bool isOpen, uint256 reward, uint256 baseRate, uint256 totalRate) {
|
||||
if(startBlock != 0 && block.number >= startBlock) {
|
||||
isOpen = true;
|
||||
baseRate = defaultRate;
|
||||
uint256 fromRate = boosts[fromToken];
|
||||
uint256 toRate = boosts[toToken];
|
||||
totalRate = (fromRate >= toRate ? fromRate : toRate) + defaultRate;
|
||||
uint256 _totalReward = totalReward + (block.number - lastRewardBlock) * dodoPerBlock;
|
||||
reward = (_totalReward - totalDistribution) * totalRate / 1000;
|
||||
}else {
|
||||
isOpen = false;
|
||||
reward = 0;
|
||||
baseRate = 0;
|
||||
totalRate = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -645,17 +645,22 @@ contract DODOV2Proxy01 is IDODOV2Proxy01, ReentrancyGuard, InitializableOwnable
|
||||
IUni(curPair).swapExactTokensForTokens(curAmountIn,0,portionPath,address(this),deadLine);
|
||||
}
|
||||
}
|
||||
|
||||
IERC20(_toToken).universalTransfer(
|
||||
msg.sender,
|
||||
IERC20(_toToken).universalBalanceOf(address(this))
|
||||
);
|
||||
|
||||
{
|
||||
uint256 toBalance;
|
||||
if (_toToken == _ETH_ADDRESS_) {
|
||||
toBalance = IWETH(_WETH_).balanceOf(address(this));
|
||||
IWETH(_WETH_).withdraw(toBalance);
|
||||
} else {
|
||||
toBalance = IERC20(_toToken).tokenBalanceOf(address(this));
|
||||
}
|
||||
IERC20(_toToken).universalTransfer(msg.sender,toBalance);
|
||||
}
|
||||
// {
|
||||
// uint256 toBalance;
|
||||
// if (_toToken == _ETH_ADDRESS_) {
|
||||
// toBalance = IWETH(_WETH_).balanceOf(address(this));
|
||||
// IWETH(_WETH_).withdraw(toBalance);
|
||||
// } else {
|
||||
// toBalance = IERC20(_toToken).tokenBalanceOf(address(this));
|
||||
// }
|
||||
// IERC20(_toToken).universalTransfer(msg.sender,toBalance);
|
||||
// }
|
||||
|
||||
returnAmount = IERC20(_toToken).universalBalanceOf(msg.sender).sub(toTokenOriginBalance);
|
||||
require(returnAmount >= minReturnAmount, "DODOV2Proxy01: Return amount is not enough");
|
||||
|
||||
Reference in New Issue
Block a user