@@ -5,6 +5,7 @@ import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
5
5
import "./interfaces/IOwnable.sol " ;
6
6
import "./interfaces/ISTFactory.sol " ;
7
7
import "./interfaces/ISecurityTokenRegistry.sol " ;
8
+ import "./interfaces/ISecurityToken.sol " ;
8
9
import "./interfaces/IPolymathRegistry.sol " ;
9
10
import "./interfaces/IOracle.sol " ;
10
11
import "./storage/EternalStorage.sol " ;
@@ -121,6 +122,16 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
121
122
uint256 _usdFee ,
122
123
uint256 _polyFee
123
124
);
125
+ // Emit at when issuer refreshes exisiting token
126
+ event SecurityTokenRefreshed (
127
+ string _ticker ,
128
+ string _name ,
129
+ address indexed _securityTokenAddress ,
130
+ address indexed _owner ,
131
+ uint256 _addedAt ,
132
+ address _registrant ,
133
+ uint256 _protocolVersion
134
+ );
124
135
event ProtocolFactorySet (address indexed _STFactory , uint8 _major , uint8 _minor , uint8 _patch );
125
136
event LatestVersionSet (uint8 _major , uint8 _minor , uint8 _patch );
126
137
event ProtocolFactoryRemoved (address indexed _STFactory , uint8 _major , uint8 _minor , uint8 _patch );
@@ -140,11 +151,13 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
140
151
* @notice Modifier to make a function callable only when the contract is not paused.
141
152
*/
142
153
modifier whenNotPausedOrOwner () {
143
- if (msg .sender == owner ()) _;
144
- else {
154
+ _whenNotPausedOrOwner ();
155
+ _;
156
+ }
157
+
158
+ function _whenNotPausedOrOwner () internal view {
159
+ if (msg .sender != owner ())
145
160
require (! isPaused (), "Paused " );
146
- _;
147
- }
148
161
}
149
162
150
163
/**
@@ -182,7 +195,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
182
195
address _owner ,
183
196
address _getterContract
184
197
)
185
- external
198
+ public
186
199
payable
187
200
{
188
201
require (! getBoolValue (INITIALIZE),"Initialized " );
@@ -266,7 +279,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
266
279
* @param _ticker is unique token ticker
267
280
* @param _tokenName is the name of the token
268
281
*/
269
- function registerTicker (address _owner , string calldata _ticker , string calldata _tokenName ) external whenNotPausedOrOwner {
282
+ function registerTicker (address _owner , string memory _ticker , string memory _tokenName ) public whenNotPausedOrOwner {
270
283
require (_owner != address (0 ), "Bad address " );
271
284
require (bytes (_ticker).length > 0 && bytes (_ticker).length <= 10 , "Bad ticker " );
272
285
// Attempt to charge the reg fee if it is > 0 USD
@@ -315,13 +328,13 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
315
328
*/
316
329
function modifyTicker (
317
330
address _owner ,
318
- string calldata _ticker ,
319
- string calldata _tokenName ,
331
+ string memory _ticker ,
332
+ string memory _tokenName ,
320
333
uint256 _registrationDate ,
321
334
uint256 _expiryDate ,
322
335
bool _status
323
336
)
324
- external
337
+ public
325
338
onlyOwner
326
339
{
327
340
require (bytes (_ticker).length > 0 && bytes (_ticker).length <= 10 , "Bad ticker " );
@@ -367,7 +380,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
367
380
* @notice Removes the ticker details, associated ownership & security token mapping
368
381
* @param _ticker is the token ticker
369
382
*/
370
- function removeTicker (string calldata _ticker ) external onlyOwner {
383
+ function removeTicker (string memory _ticker ) public onlyOwner {
371
384
string memory ticker = Util.upper (_ticker);
372
385
address owner = _tickerOwner (ticker);
373
386
require (owner != address (0 ), "Bad ticker " );
@@ -428,23 +441,23 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
428
441
internal
429
442
{
430
443
bytes32 key = Encoder.getKey ("registeredTickers_owner " , _ticker);
431
- if ( getAddressValue (key) != _owner) set (key, _owner);
444
+ set (key, _owner);
432
445
key = Encoder.getKey ("registeredTickers_registrationDate " , _ticker);
433
- if ( getUintValue (key) != _registrationDate) set (key, _registrationDate);
446
+ set (key, _registrationDate);
434
447
key = Encoder.getKey ("registeredTickers_expiryDate " , _ticker);
435
- if ( getUintValue (key) != _expiryDate) set (key, _expiryDate);
448
+ set (key, _expiryDate);
436
449
key = Encoder.getKey ("registeredTickers_tokenName " , _ticker);
437
- if (Encoder. getKey ( getStringValue (key)) != Encoder. getKey (_tokenName)) set (key, _tokenName);
450
+ set (key, _tokenName);
438
451
key = Encoder.getKey ("registeredTickers_status " , _ticker);
439
- if ( getBoolValue (key) != _status) set (key, _status);
452
+ set (key, _status);
440
453
}
441
454
442
455
/**
443
456
* @notice Transfers the ownership of the ticker
444
457
* @param _newOwner is the address of the new owner of the ticker
445
458
* @param _ticker is the ticker symbol
446
459
*/
447
- function transferTickerOwnership (address _newOwner , string calldata _ticker ) external whenNotPausedOrOwner {
460
+ function transferTickerOwnership (address _newOwner , string memory _ticker ) public whenNotPausedOrOwner {
448
461
string memory ticker = Util.upper (_ticker);
449
462
require (_newOwner != address (0 ), "Bad address " );
450
463
bytes32 ownerKey = Encoder.getKey ("registeredTickers_owner " , ticker);
@@ -479,7 +492,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
479
492
* @notice Changes the expiry time for the token ticker. Only available to Polymath.
480
493
* @param _newExpiry is the new expiry for newly generated tickers
481
494
*/
482
- function changeExpiryLimit (uint256 _newExpiry ) external onlyOwner {
495
+ function changeExpiryLimit (uint256 _newExpiry ) public onlyOwner {
483
496
require (_newExpiry >= 1 days, "Bad dates " );
484
497
emit ChangeExpiryLimit (getUintValue (EXPIRYLIMIT), _newExpiry);
485
498
set (EXPIRYLIMIT, _newExpiry);
@@ -501,14 +514,14 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
501
514
* - if _protocolVersion == 0 then latest version of securityToken will be generated
502
515
*/
503
516
function generateSecurityToken (
504
- string calldata _name ,
505
- string calldata _ticker ,
506
- string calldata _tokenDetails ,
517
+ string memory _name ,
518
+ string memory _ticker ,
519
+ string memory _tokenDetails ,
507
520
bool _divisible ,
508
521
address _treasuryWallet ,
509
522
uint256 _protocolVersion
510
523
)
511
- external
524
+ public
512
525
whenNotPausedOrOwner
513
526
{
514
527
uint256 protocolVersion = _protocolVersion;
@@ -525,7 +538,46 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
525
538
require (_tickerOwner (ticker) == msg .sender , "Not authorised " );
526
539
/*solium-disable-next-line security/no-block-members*/
527
540
require (getUintValue (Encoder.getKey ("registeredTickers_expiryDate " , ticker)) >= now , "Ticker expired " );
528
- _deployToken (_name, ticker, _tokenDetails, msg .sender , _divisible, _treasuryWallet, protocolVersion);
541
+ (uint256 _usdFee , uint256 _polyFee ) = _takeFee (STLAUNCHFEE);
542
+ address newSecurityTokenAddress =
543
+ _deployToken (_name, ticker, _tokenDetails, msg .sender , _divisible, _treasuryWallet, protocolVersion, _usdFee, _polyFee);
544
+ emit NewSecurityToken (
545
+ _ticker, _name, newSecurityTokenAddress, msg .sender , now , msg .sender , false , _usdFee, _polyFee, protocolVersion
546
+ );
547
+ }
548
+
549
+ /**
550
+ * @notice Deploys an instance of a new Security Token and replaces the old one in the registry
551
+ * This can be used to upgrade from version 2.0 of ST to 3.0 or in case something goes wrong with earlier ST
552
+ * @dev This function needs to be in STR 3.0. Defined public to avoid stack overflow
553
+ * @param _name is the name of the token
554
+ * @param _ticker is the ticker symbol of the security token
555
+ * @param _tokenDetails is the off-chain details of the token
556
+ * @param _divisible is whether or not the token is divisible
557
+ */
558
+ function refreshSecurityToken (
559
+ string memory _name ,
560
+ string memory _ticker ,
561
+ string memory _tokenDetails ,
562
+ bool _divisible ,
563
+ address _treasuryWallet
564
+ )
565
+ public whenNotPausedOrOwner returns (address )
566
+ {
567
+ require (bytes (_name).length > 0 && bytes (_ticker).length > 0 , "Bad ticker " );
568
+ require (_treasuryWallet != address (0 ), "0x0 not allowed " );
569
+ string memory ticker = Util.upper (_ticker);
570
+ require (_tickerStatus (ticker), "not deployed " );
571
+ address st = getAddressValue (Encoder.getKey ("tickerToSecurityToken " , ticker));
572
+ address stOwner = IOwnable (st).owner ();
573
+ require (msg .sender == stOwner, "Unauthroized " );
574
+ require (ISecurityToken (st).transfersFrozen (), "Transfers not frozen " );
575
+ uint256 protocolVersion = getUintValue (Encoder.getKey ("latestVersion " ));
576
+ address newSecurityTokenAddress =
577
+ _deployToken (_name, ticker, _tokenDetails, stOwner, _divisible, _treasuryWallet, protocolVersion, 0 , 0 );
578
+ emit SecurityTokenRefreshed (
579
+ _ticker, _name, newSecurityTokenAddress, stOwner, now , stOwner, protocolVersion
580
+ );
529
581
}
530
582
531
583
function _deployToken (
@@ -535,12 +587,14 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
535
587
address _issuer ,
536
588
bool _divisible ,
537
589
address _wallet ,
538
- uint256 _protocolVersion
590
+ uint256 _protocolVersion ,
591
+ uint256 _usdFee ,
592
+ uint256 _polyFee
539
593
)
540
594
internal
595
+ returns (address newSecurityTokenAddress )
541
596
{
542
- (uint256 _usdFee , uint256 _polyFee ) = _takeFee (STLAUNCHFEE);
543
- address newSecurityTokenAddress = ISTFactory (getAddressValue (Encoder.getKey ("protocolVersionST " , _protocolVersion))).deployToken (
597
+ newSecurityTokenAddress = ISTFactory (getAddressValue (Encoder.getKey ("protocolVersionST " , _protocolVersion))).deployToken (
544
598
_name,
545
599
_ticker,
546
600
18 ,
@@ -554,10 +608,6 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
554
608
/*solium-disable-next-line security/no-block-members*/
555
609
_storeSecurityTokenData (newSecurityTokenAddress, _ticker, _tokenDetails, now );
556
610
set (Encoder.getKey ("tickerToSecurityToken " , _ticker), newSecurityTokenAddress);
557
- /*solium-disable-next-line security/no-block-members*/
558
- emit NewSecurityToken (
559
- _ticker, _name, newSecurityTokenAddress, msg .sender , now , msg .sender , false , _usdFee, _polyFee, _protocolVersion
560
- );
561
611
}
562
612
563
613
/**
@@ -570,14 +620,14 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
570
620
* @param _deployedAt is the timestamp at which the security token is deployed
571
621
*/
572
622
function modifySecurityToken (
573
- string calldata _name ,
574
- string calldata _ticker ,
623
+ string memory _name ,
624
+ string memory _ticker ,
575
625
address _owner ,
576
626
address _securityToken ,
577
- string calldata _tokenDetails ,
627
+ string memory _tokenDetails ,
578
628
uint256 _deployedAt
579
629
)
580
- external
630
+ public
581
631
onlyOwner
582
632
{
583
633
require (bytes (_name).length > 0 && bytes (_ticker).length > 0 , "Bad data " );
@@ -631,7 +681,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
631
681
* @dev Allows the current owner to transfer control of the contract to a newOwner.
632
682
* @param _newOwner The address to transfer ownership to.
633
683
*/
634
- function transferOwnership (address _newOwner ) external onlyOwner {
684
+ function transferOwnership (address _newOwner ) public onlyOwner {
635
685
require (_newOwner != address (0 ), "Bad address " );
636
686
emit OwnershipTransferred (getAddressValue (OWNER), _newOwner);
637
687
set (OWNER, _newOwner);
@@ -659,7 +709,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
659
709
* @notice Sets the ticker registration fee in USD tokens. Only Polymath.
660
710
* @param _tickerRegFee is the registration fee in USD tokens (base 18 decimals)
661
711
*/
662
- function changeTickerRegistrationFee (uint256 _tickerRegFee ) external onlyOwner {
712
+ function changeTickerRegistrationFee (uint256 _tickerRegFee ) public onlyOwner {
663
713
uint256 fee = getUintValue (TICKERREGFEE);
664
714
require (fee != _tickerRegFee, "Bad fee " );
665
715
_changeTickerRegistrationFee (fee, _tickerRegFee);
@@ -674,7 +724,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
674
724
* @notice Sets the ticker registration fee in USD tokens. Only Polymath.
675
725
* @param _stLaunchFee is the registration fee in USD tokens (base 18 decimals)
676
726
*/
677
- function changeSecurityLaunchFee (uint256 _stLaunchFee ) external onlyOwner {
727
+ function changeSecurityLaunchFee (uint256 _stLaunchFee ) public onlyOwner {
678
728
uint256 fee = getUintValue (STLAUNCHFEE);
679
729
require (fee != _stLaunchFee, "Bad fee " );
680
730
_changeSecurityLaunchFee (fee, _stLaunchFee);
@@ -691,7 +741,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
691
741
* @param _stLaunchFee is the st generation fee (base 18 decimals)
692
742
* @param _isFeeInPoly defines if the fee is in poly or usd
693
743
*/
694
- function changeFeesAmountAndCurrency (uint256 _tickerRegFee , uint256 _stLaunchFee , bool _isFeeInPoly ) external onlyOwner {
744
+ function changeFeesAmountAndCurrency (uint256 _tickerRegFee , uint256 _stLaunchFee , bool _isFeeInPoly ) public onlyOwner {
695
745
uint256 tickerFee = getUintValue (TICKERREGFEE);
696
746
uint256 stFee = getUintValue (STLAUNCHFEE);
697
747
bool isOldFeesInPoly = getBoolValue (IS_FEE_IN_POLY);
@@ -706,7 +756,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
706
756
* @notice Reclaims all ERC20Basic compatible tokens
707
757
* @param _tokenContract is the address of the token contract
708
758
*/
709
- function reclaimERC20 (address _tokenContract ) external onlyOwner {
759
+ function reclaimERC20 (address _tokenContract ) public onlyOwner {
710
760
require (_tokenContract != address (0 ), "Bad address " );
711
761
IERC20 token = IERC20 (_tokenContract);
712
762
uint256 balance = token.balanceOf (address (this ));
@@ -722,7 +772,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
722
772
* @param _minor Minor version of the proxy.
723
773
* @param _patch Patch version of the proxy
724
774
*/
725
- function setProtocolFactory (address _STFactoryAddress , uint8 _major , uint8 _minor , uint8 _patch ) external onlyOwner {
775
+ function setProtocolFactory (address _STFactoryAddress , uint8 _major , uint8 _minor , uint8 _patch ) public onlyOwner {
726
776
_setProtocolFactory (_STFactoryAddress, _major, _minor, _patch);
727
777
}
728
778
@@ -740,7 +790,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
740
790
* @param _minor Minor version of the proxy.
741
791
* @param _patch Patch version of the proxy
742
792
*/
743
- function removeProtocolFactory (uint8 _major , uint8 _minor , uint8 _patch ) external onlyOwner {
793
+ function removeProtocolFactory (uint8 _major , uint8 _minor , uint8 _patch ) public onlyOwner {
744
794
uint24 _packedVersion = VersionUtils.pack (_major, _minor, _patch);
745
795
require (getUintValue (Encoder.getKey ("latestVersion " )) != _packedVersion, "Cannot remove latestVersion " );
746
796
emit ProtocolFactoryRemoved (getAddressValue (Encoder.getKey ("protocolVersionST " , _packedVersion)), _major, _minor, _patch);
@@ -755,7 +805,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
755
805
* @param _minor Minor version of the proxy.
756
806
* @param _patch Patch version of the proxy
757
807
*/
758
- function setLatestVersion (uint8 _major , uint8 _minor , uint8 _patch ) external onlyOwner {
808
+ function setLatestVersion (uint8 _major , uint8 _minor , uint8 _patch ) public onlyOwner {
759
809
_setLatestVersion (_major, _minor, _patch);
760
810
}
761
811
@@ -770,7 +820,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
770
820
* @notice Changes the PolyToken address. Only Polymath.
771
821
* @param _newAddress is the address of the polytoken.
772
822
*/
773
- function updatePolyTokenAddress (address _newAddress ) external onlyOwner {
823
+ function updatePolyTokenAddress (address _newAddress ) public onlyOwner {
774
824
require (_newAddress != address (0 ), "Bad address " );
775
825
set (POLYTOKEN, _newAddress);
776
826
}
0 commit comments