add comments

This commit is contained in:
owen05
2021-12-20 17:43:23 +08:00
parent 28bae5945c
commit 9b0e61ec8b
4 changed files with 18 additions and 23 deletions

View File

@@ -213,6 +213,15 @@ contract FairFunding is Vesting {
}
}
function claimToken(address to) external {
require(isSettled(), "NOT_SETTLED");
uint256 totalAllocation = getUserTokenAllocation(msg.sender);
_claimToken(to, totalAllocation);
}
// ============ Ownable Functions ============
function withdrawUnallocatedToken(address to) external preventReentrant onlyOwner {
require(isSettled(), "NOT_SETTLED");
require(_FINAL_PRICE_ == _LOWER_LIMIT_PRICE_, "NO_TOKEN_LEFT");
@@ -227,12 +236,6 @@ contract FairFunding is Vesting {
_initializeLiquidity(initialTokenAmount, totalUsedRaiseFunds, lpFeeRate, isOpenTWAP);
}
function claimToken(address to) external {
require(isSettled(), "NOT_SETTLED");
uint256 totalAllocation = getUserTokenAllocation(msg.sender);
_claimToken(to, totalAllocation);
}
function claimFund(address to) external preventReentrant onlyOwner {
require(isSettled(), "NOT_SETTLED");
uint256 totalUsedRaiseFunds = DecimalMath.mulFloor(_TOTAL_RAISED_FUNDS_, _USED_FUND_RATIO_);

View File

@@ -25,7 +25,6 @@ contract InstantFunding is Vesting {
uint256 public _END_PRICE_;
mapping(address => uint256) _FUNDS_USED_;
// mapping(address => uint256) _FUNDS_UNUSED_;
mapping(address => uint256) _TOKEN_ALLOCATION_;
uint256 public _TOTAL_ALLOCATED_TOKEN_;
@@ -134,10 +133,6 @@ contract InstantFunding is Vesting {
return _TOKEN_ALLOCATION_[user];
}
// function getUserFundsUnused(address user) public view returns (uint256) {
// return _FUNDS_UNUSED_[user];
// }
function getUserFundsUsed(address user) public view returns (uint256) {
return _FUNDS_USED_[user];
}
@@ -173,7 +168,6 @@ contract InstantFunding is Vesting {
_FUNDS_RESERVE_ = _FUNDS_RESERVE_.add(fundUsed);
IERC20(_FUNDS_ADDRESS_).safeTransfer(to, inputFund.sub(fundUsed));
// _FUNDS_UNUSED_[to] = _FUNDS_UNUSED_[to].add(inputFund.sub(fundUsed));
} else {
_FUNDS_USED_[to] = _FUNDS_USED_[to].add(inputFund);
_TOTAL_RAISED_FUNDS_ = _TOTAL_RAISED_FUNDS_.add(inputFund);
@@ -184,12 +178,12 @@ contract InstantFunding is Vesting {
_TOTAL_ALLOCATED_TOKEN_ = _TOTAL_ALLOCATED_TOKEN_.add(newTokenAllocation);
}
// function withdrawFunds(address to, uint256 amount) external preventReentrant {
// require(_FUNDS_UNUSED_[msg.sender] >= amount, "UNUSED_FUND_NOT_ENOUGH");
// _FUNDS_UNUSED_[msg.sender] = _FUNDS_UNUSED_[msg.sender].sub(amount);
// _FUNDS_RESERVE_ = _FUNDS_RESERVE_.sub(amount);
// IERC20(_FUNDS_ADDRESS_).safeTransfer(to, amount);
// }
function claimToken(address to) external {
uint256 totalAllocation = getUserTokenAllocation(msg.sender);
_claimToken(to, totalAllocation);
}
// ============ Ownable Functions ============
function withdrawUnallocatedToken(address to) external preventReentrant onlyOwner {
require(isFundingEnd(), "CAN_NOT_WITHDRAW");
@@ -202,11 +196,6 @@ contract InstantFunding is Vesting {
_initializeLiquidity(initialTokenAmount, _TOTAL_RAISED_FUNDS_, lpFeeRate, isOpenTWAP);
}
function claimToken(address to) external {
uint256 totalAllocation = getUserTokenAllocation(msg.sender);
_claimToken(to, totalAllocation);
}
function claimFund(address to) external preventReentrant onlyOwner {
_claimFunds(to,_TOTAL_RAISED_FUNDS_);
}

View File

@@ -63,6 +63,7 @@ contract Storage is InitializableOwnable, ReentrancyGuard {
_;
}
// ============ Ownable Control ============
function forceStop() external onlyOwner {
require(block.timestamp < _START_TIME_, "FUNDING_ALREADY_STARTED");
_FORCE_STOP_ = true;

View File

@@ -61,6 +61,8 @@ contract Vesting is Storage {
}
}
// ============ Internal Function ============
function _claimToken(address to, uint256 totalAllocation) internal {
uint256 remainingToken = DecimalMath.mulFloor(
getRemainingRatio(block.timestamp,0),