add event

This commit is contained in:
owen05
2022-02-08 22:23:52 +08:00
parent 38241e81e1
commit 7ac5b8a403
4 changed files with 75 additions and 13 deletions

View File

@@ -20,6 +20,9 @@ contract Vesting is Storage {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// ============ Events ============
event ClaimLpToken(address indexed to, uint256 lpAmount);
function claimLp(address to) external preventReentrant onlyOwner {
require(_INITIAL_POOL_ != address(0), "LIQUIDITY_NOT_ESTABLISHED");
uint256 remainingLp = DecimalMath.mulFloor(
@@ -30,6 +33,8 @@ contract Vesting is Storage {
_CLAIMED_LP_ = _CLAIMED_LP_.add(claimableLp);
IERC20(_INITIAL_POOL_).safeTransfer(to, claimableLp);
emit ClaimLpToken(to, claimableLp);
}
//tokenType 0: BaseToken, 1: Fund, 2: LpToken
@@ -65,24 +70,24 @@ contract Vesting is Storage {
// ============ Internal Function ============
function _claimToken(address to, uint256 totalAllocation) internal {
function _claimToken(address to, uint256 totalAllocation) internal returns(uint256 claimableTokenAmount) {
uint256 remainingToken = DecimalMath.mulFloor(
getRemainingRatio(block.timestamp,0),
totalAllocation
);
uint256 claimableTokenAmount = totalAllocation.sub(remainingToken).sub(_CLAIMED_TOKEN_[msg.sender]);
claimableTokenAmount = totalAllocation.sub(remainingToken).sub(_CLAIMED_TOKEN_[msg.sender]);
_CLAIMED_TOKEN_[msg.sender] = _CLAIMED_TOKEN_[msg.sender].add(claimableTokenAmount);
IERC20(_TOKEN_ADDRESS_).safeTransfer(to,claimableTokenAmount);
}
function _claimFunds(address to, uint256 totalUsedRaiseFunds) internal {
function _claimFunds(address to, uint256 totalUsedRaiseFunds) internal returns(uint256 claimableFund) {
require(totalUsedRaiseFunds > _INITIAL_FUND_LIQUIDITY_, "FUND_NOT_ENOUGH");
uint256 vestingFunds = totalUsedRaiseFunds.sub(_INITIAL_FUND_LIQUIDITY_);
uint256 remainingFund = DecimalMath.mulFloor(
getRemainingRatio(block.timestamp,1),
vestingFunds
);
uint256 claimableFund = vestingFunds.sub(remainingFund).sub(_CLAIMED_FUNDS_);
claimableFund = vestingFunds.sub(remainingFund).sub(_CLAIMED_FUNDS_);
_CLAIMED_FUNDS_ = _CLAIMED_FUNDS_.add(claimableFund);
IERC20(_FUNDS_ADDRESS_).safeTransfer(to, claimableFund);
}