From 9b0e61ec8b67ba2f6051266623b534e63f5610be Mon Sep 17 00:00:00 2001 From: owen05 Date: Mon, 20 Dec 2021 17:43:23 +0800 Subject: [PATCH] add comments --- contracts/DODOStarter/impl/FairFunding.sol | 15 +++++++----- contracts/DODOStarter/impl/InstantFunding.sol | 23 +++++-------------- contracts/DODOStarter/impl/Storage.sol | 1 + contracts/DODOStarter/impl/Vesting.sol | 2 ++ 4 files changed, 18 insertions(+), 23 deletions(-) diff --git a/contracts/DODOStarter/impl/FairFunding.sol b/contracts/DODOStarter/impl/FairFunding.sol index adbb001..3f7c1c1 100644 --- a/contracts/DODOStarter/impl/FairFunding.sol +++ b/contracts/DODOStarter/impl/FairFunding.sol @@ -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_); diff --git a/contracts/DODOStarter/impl/InstantFunding.sol b/contracts/DODOStarter/impl/InstantFunding.sol index 6bea048..6bdf00e 100644 --- a/contracts/DODOStarter/impl/InstantFunding.sol +++ b/contracts/DODOStarter/impl/InstantFunding.sol @@ -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_); } diff --git a/contracts/DODOStarter/impl/Storage.sol b/contracts/DODOStarter/impl/Storage.sol index 4e7c192..65806a5 100644 --- a/contracts/DODOStarter/impl/Storage.sol +++ b/contracts/DODOStarter/impl/Storage.sol @@ -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; diff --git a/contracts/DODOStarter/impl/Vesting.sol b/contracts/DODOStarter/impl/Vesting.sol index 0394fd6..8bc61d3 100644 --- a/contracts/DODOStarter/impl/Vesting.sol +++ b/contracts/DODOStarter/impl/Vesting.sol @@ -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),