@@ -6,17 +6,16 @@ import "../../interfaces/IOracle.sol";
6
6
import "../../RegistryUpdater.sol " ;
7
7
import "../../libraries/DecimalMath.sol " ;
8
8
import "openzeppelin-solidity/contracts/math/SafeMath.sol " ;
9
- import "openzeppelin-solidity/contracts/utils/ReentrancyGuard.sol " ;
10
9
import "../../storage/USDTieredSTOStorage.sol " ;
11
10
12
11
/**
13
12
* @title STO module for standard capped crowdsale
14
13
*/
15
- contract USDTieredSTO is USDTieredSTOStorage , STO , ReentrancyGuard {
14
+ contract USDTieredSTO is USDTieredSTOStorage , STO {
16
15
using SafeMath for uint256 ;
17
16
18
- string public constant POLY_ORACLE = "PolyUsdOracle " ;
19
- string public constant ETH_ORACLE = "EthUsdOracle " ;
17
+ string internal constant POLY_ORACLE = "PolyUsdOracle " ;
18
+ string internal constant ETH_ORACLE = "EthUsdOracle " ;
20
19
21
20
////////////
22
21
// Events //
@@ -200,10 +199,12 @@ contract USDTieredSTO is USDTieredSTOStorage, STO, ReentrancyGuard {
200
199
)
201
200
internal
202
201
{
203
- require (_tokensPerTierTotal.length > 0 , "No tiers provided " );
204
202
require (
205
- _ratePerTier.length == _tokensPerTierTotal.length && _ratePerTierDiscountPoly.length == _tokensPerTierTotal.length && _tokensPerTierDiscountPoly.length == _tokensPerTierTotal.length ,
206
- "Tier data length mismatch "
203
+ _tokensPerTierTotal.length > 0 &&
204
+ _ratePerTier.length == _tokensPerTierTotal.length &&
205
+ _ratePerTierDiscountPoly.length == _tokensPerTierTotal.length &&
206
+ _tokensPerTierDiscountPoly.length == _tokensPerTierTotal.length ,
207
+ "Invalid Input "
207
208
);
208
209
delete tiers;
209
210
for (uint256 i = 0 ; i < _ratePerTier.length ; i++ ) {
@@ -253,7 +254,7 @@ contract USDTieredSTO is USDTieredSTOStorage, STO, ReentrancyGuard {
253
254
* @notice Reserve address must be whitelisted to successfully finalize
254
255
*/
255
256
function finalize () public onlyOwner {
256
- require (! isFinalized, "STO is already finalized " );
257
+ require (! isFinalized, "STO already finalized " );
257
258
isFinalized = true ;
258
259
uint256 tempReturned;
259
260
uint256 tempSold;
@@ -266,7 +267,7 @@ contract USDTieredSTO is USDTieredSTOStorage, STO, ReentrancyGuard {
266
267
tiers[i].mintedTotal = tiers[i].tokenTotal;
267
268
}
268
269
}
269
- require (ISecurityToken (securityToken).mint (reserveWallet, tempReturned), "Error in minting " );
270
+ require (ISecurityToken (securityToken).mint (reserveWallet, tempReturned), "Minting Failed " );
270
271
emit ReserveTokenMint (msg .sender , reserveWallet, tempReturned, currentTier);
271
272
finalAmountReturned = tempReturned;
272
273
totalTokensSold = tempSold;
@@ -437,7 +438,6 @@ contract USDTieredSTO is USDTieredSTOStorage, STO, ReentrancyGuard {
437
438
FundRaiseType _fundRaiseType
438
439
)
439
440
internal
440
- nonReentrant
441
441
whenNotPaused
442
442
returns (uint256 spentUSD , uint256 spentValue )
443
443
{
@@ -485,10 +485,10 @@ contract USDTieredSTO is USDTieredSTOStorage, STO, ReentrancyGuard {
485
485
returns (uint256 netInvestedUSD )
486
486
{
487
487
require (isOpen (), "STO not open " );
488
- require (_investmentValue > 0 , "No funds were sent " );
488
+ require (_investmentValue > 0 , "No funds sent " );
489
489
490
490
// Check for minimum investment
491
- require (investedUSD.add (investorInvestedUSD[_beneficiary]) >= minimumInvestmentUSD, "Total investment < minimumInvestmentUSD " );
491
+ require (investedUSD.add (investorInvestedUSD[_beneficiary]) >= minimumInvestmentUSD, "Investment < min " );
492
492
netInvestedUSD = investedUSD;
493
493
// Check for non-accredited cap
494
494
if (investors[_beneficiary].accredited == uint8 (0 )) {
@@ -565,7 +565,7 @@ contract USDTieredSTO is USDTieredSTOStorage, STO, ReentrancyGuard {
565
565
purchasedTokens = maximumTokens;
566
566
}
567
567
if (purchasedTokens > 0 ) {
568
- require (ISecurityToken (securityToken).mint (_beneficiary, purchasedTokens), "Error in minting " );
568
+ require (ISecurityToken (securityToken).mint (_beneficiary, purchasedTokens), "Mint failed " );
569
569
emit TokenPurchase (msg .sender , _beneficiary, purchasedTokens, spentUSD, _tierPrice, _tier);
570
570
}
571
571
}
@@ -579,15 +579,8 @@ contract USDTieredSTO is USDTieredSTOStorage, STO, ReentrancyGuard {
579
579
* @return bool Whether the STO is accepting investments
580
580
*/
581
581
function isOpen () public view returns (bool ) {
582
- if (isFinalized)
583
- return false ;
584
- /*solium-disable-next-line security/no-block-members*/
585
- if (now < startTime)
586
- return false ;
587
- /*solium-disable-next-line security/no-block-members*/
588
- if (now >= endTime)
589
- return false ;
590
- if (capReached ())
582
+ /*solium-disable-next-line security/no-block-members*/
583
+ if (isFinalized || now < startTime || now >= endTime || capReached ())
591
584
return false ;
592
585
return true ;
593
586
}
@@ -613,9 +606,7 @@ contract USDTieredSTO is USDTieredSTOStorage, STO, ReentrancyGuard {
613
606
} else if (_fundRaiseType == FundRaiseType.POLY) {
614
607
return IOracle (_getOracle (bytes32 ("POLY " ), bytes32 ("USD " ))).getPrice ();
615
608
} else if (_fundRaiseType == FundRaiseType.SC) {
616
- return 1 * 10 ** 18 ;
617
- } else {
618
- revert ("Incorrect funding " );
609
+ return 10 ** 18 ;
619
610
}
620
611
}
621
612
@@ -626,8 +617,7 @@ contract USDTieredSTO is USDTieredSTOStorage, STO, ReentrancyGuard {
626
617
* @return uint256 Value in USD
627
618
*/
628
619
function convertToUSD (FundRaiseType _fundRaiseType , uint256 _amount ) public view returns (uint256 ) {
629
- uint256 rate = getRate (_fundRaiseType);
630
- return DecimalMath.mul (_amount, rate);
620
+ return DecimalMath.mul (_amount, getRate (_fundRaiseType));
631
621
}
632
622
633
623
/**
@@ -637,8 +627,7 @@ contract USDTieredSTO is USDTieredSTOStorage, STO, ReentrancyGuard {
637
627
* @return uint256 Value in ETH or POLY
638
628
*/
639
629
function convertFromUSD (FundRaiseType _fundRaiseType , uint256 _amount ) public view returns (uint256 ) {
640
- uint256 rate = getRate (_fundRaiseType);
641
- return DecimalMath.div (_amount, rate);
630
+ return DecimalMath.div (_amount, getRate (_fundRaiseType));
642
631
}
643
632
644
633
/**
@@ -648,42 +637,36 @@ contract USDTieredSTO is USDTieredSTOStorage, STO, ReentrancyGuard {
648
637
function getTokensSold () public view returns (uint256 ) {
649
638
if (isFinalized)
650
639
return totalTokensSold;
651
- else
652
- return getTokensMinted ();
640
+ return getTokensMinted ();
653
641
}
654
642
655
643
/**
656
644
* @notice Return the total no. of tokens minted
657
645
* @return uint256 Total number of tokens minted
658
646
*/
659
- function getTokensMinted () public view returns (uint256 ) {
660
- uint256 tokensMinted;
647
+ function getTokensMinted () public view returns (uint256 tokensMinted ) {
661
648
for (uint256 i = 0 ; i < tiers.length ; i++ ) {
662
649
tokensMinted = tokensMinted.add (tiers[i].mintedTotal);
663
650
}
664
- return tokensMinted;
665
651
}
666
652
667
653
/**
668
654
* @notice Return the total no. of tokens sold for the given fund raise type
669
655
* param _fundRaiseType The fund raising currency (e.g. ETH, POLY, SC) to calculate sold tokens for
670
656
* @return uint256 Total number of tokens sold for ETH
671
657
*/
672
- function getTokensSoldFor (FundRaiseType _fundRaiseType ) public view returns (uint256 ) {
673
- uint256 tokensSold;
658
+ function getTokensSoldFor (FundRaiseType _fundRaiseType ) external view returns (uint256 tokensSold ) {
674
659
for (uint256 i = 0 ; i < tiers.length ; i++ ) {
675
660
tokensSold = tokensSold.add (tiers[i].minted[uint8 (_fundRaiseType)]);
676
661
}
677
- return tokensSold;
678
662
}
679
663
680
664
/**
681
665
* @notice Return array of minted tokens in each fund raise type for given tier
682
666
* param _tier The tier to return minted tokens for
683
667
* @return uint256[] array of minted tokens in each fund raise type
684
668
*/
685
- function getTokensMintedByTier (uint256 _tier ) public view returns (uint256 [] memory ) {
686
- require (_tier < tiers.length , "Invalid tier " );
669
+ function getTokensMintedByTier (uint256 _tier ) external view returns (uint256 [] memory ) {
687
670
uint256 [] memory tokensMinted = new uint256 [](3 );
688
671
tokensMinted[0 ] = tiers[_tier].minted[uint8 (FundRaiseType.ETH)];
689
672
tokensMinted[1 ] = tiers[_tier].minted[uint8 (FundRaiseType.POLY)];
@@ -696,8 +679,7 @@ contract USDTieredSTO is USDTieredSTOStorage, STO, ReentrancyGuard {
696
679
* param _tier The tier to calculate sold tokens for
697
680
* @return uint256 Total number of tokens sold in the tier
698
681
*/
699
- function getTokensSoldByTier (uint256 _tier ) public view returns (uint256 ) {
700
- require (_tier < tiers.length , "Incorrect tier " );
682
+ function getTokensSoldByTier (uint256 _tier ) external view returns (uint256 ) {
701
683
uint256 tokensSold;
702
684
tokensSold = tokensSold.add (tiers[_tier].minted[uint8 (FundRaiseType.ETH)]);
703
685
tokensSold = tokensSold.add (tiers[_tier].minted[uint8 (FundRaiseType.POLY)]);
@@ -709,23 +691,22 @@ contract USDTieredSTO is USDTieredSTOStorage, STO, ReentrancyGuard {
709
691
* @notice Return the total no. of tiers
710
692
* @return uint256 Total number of tiers
711
693
*/
712
- function getNumberOfTiers () public view returns (uint256 ) {
694
+ function getNumberOfTiers () external view returns (uint256 ) {
713
695
return tiers.length ;
714
696
}
715
697
716
698
/**
717
699
* @notice Return the usd tokens accepted by the STO
718
700
* @return address[] usd tokens
719
701
*/
720
- function getUsdTokens () public view returns (address [] memory ) {
702
+ function getUsdTokens () external view returns (address [] memory ) {
721
703
return usdTokens;
722
704
}
723
705
724
706
/**
725
707
* @notice Return the permissions flag that are associated with STO
726
708
*/
727
- function getPermissions () public view returns (bytes32 [] memory ) {
728
- bytes32 [] memory allPermissions = new bytes32 [](0 );
709
+ function getPermissions () public view returns (bytes32 [] memory allPermissions ) {
729
710
return allPermissions;
730
711
}
731
712
@@ -741,7 +722,7 @@ contract USDTieredSTO is USDTieredSTOStorage, STO, ReentrancyGuard {
741
722
* @return Amount of tokens sold.
742
723
* @return Array of bools to show if funding is allowed in ETH, POLY, SC respectively
743
724
*/
744
- function getSTODetails () public view returns (uint256 , uint256 , uint256 , uint256 [] memory , uint256 [] memory , uint256 , uint256 , uint256 , bool [] memory ) {
725
+ function getSTODetails () external view returns (uint256 , uint256 , uint256 , uint256 [] memory , uint256 [] memory , uint256 , uint256 , uint256 , bool [] memory ) {
745
726
uint256 [] memory cap = new uint256 [](tiers.length );
746
727
uint256 [] memory rate = new uint256 [](tiers.length );
747
728
for (uint256 i = 0 ; i < tiers.length ; i++ ) {
0 commit comments