@@ -11,6 +11,8 @@ import "./libraries/Util.sol";
11
11
import "./libraries/Encoder.sol " ;
12
12
import "./libraries/VersionUtils.sol " ;
13
13
import "./proxy/Proxy.sol " ;
14
+ import "./interfaces/IOracle.sol " ;
15
+ import "./libraries/DecimalMath.sol " ;
14
16
15
17
/**
16
18
* @title Registry contract for issuers to register their tickers and security tokens
@@ -74,6 +76,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
74
76
bytes32 constant POLYMATHREGISTRY = 0x90eeab7c36075577c7cc5ff366e389fefa8a18289b949bab3529ab4471139d4d ;
75
77
bytes32 constant STRGETTER = 0x982f24b3bd80807ec3cb227ba152e15c07d66855fa8ae6ca536e689205c0e2e9 ;
76
78
79
+ string constant POLY_ORACLE = "PolyUsdOracle " ;
80
+
77
81
// Emit when network becomes paused
78
82
event Pause (uint256 _timestammp );
79
83
// Emit when network becomes unpaused
@@ -99,7 +103,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
99
103
uint256 _addedAt ,
100
104
address _registrant ,
101
105
bool _fromAdmin ,
102
- uint256 _registrationFee
106
+ uint256 _usdFee ,
107
+ uint256 _polyFee
103
108
);
104
109
// Emit after ticker registration
105
110
event RegisterTicker (
@@ -109,7 +114,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
109
114
uint256 indexed _registrationDate ,
110
115
uint256 indexed _expiryDate ,
111
116
bool _fromAdmin ,
112
- uint256 _registrationFee
117
+ uint256 _usdFee ,
118
+ uint256 _polyFee
113
119
);
114
120
115
121
/////////////////////////////
@@ -159,8 +165,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
159
165
* @notice Initializes instance of STR
160
166
* @param _polymathRegistry is the address of the Polymath Registry
161
167
* @param _STFactory is the address of the Proxy contract for Security Tokens
162
- * @param _stLaunchFee is the fee in POLY required to launch a token
163
- * @param _tickerRegFee is the fee in POLY required to register a ticker
168
+ * @param _stLaunchFee is the fee in USD required to launch a token
169
+ * @param _tickerRegFee is the fee in USD required to register a ticker
164
170
* @param _owner is the owner of the STR,
165
171
* @param _getterContract Contract address of the contract which consists getter functions.
166
172
*/
@@ -205,6 +211,19 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
205
211
set (POLYTOKEN, IPolymathRegistry (polymathRegistry).getAddress ("PolyToken " ));
206
212
}
207
213
214
+ /**
215
+ * @notice Converts USD fees into POLY amounts
216
+ */
217
+ function _takeFee (bytes32 _feeType ) internal returns (uint256 , uint256 ){
218
+ address polymathRegistry = getAddressValue (POLYMATHREGISTRY);
219
+ uint256 polyRate = IOracle (IPolymathRegistry (polymathRegistry).getAddress (POLY_ORACLE)).getPrice ();
220
+ uint256 usdFee = getUintValue (_feeType);
221
+ uint256 polyFee = DecimalMath.div (usdFee, polyRate);
222
+ if (polyFee > 0 )
223
+ require (IERC20 (getAddressValue (POLYTOKEN)).transferFrom (msg .sender , address (this ), polyFee), "Insufficent allowance " );
224
+ return (usdFee, polyFee);
225
+ }
226
+
208
227
/**
209
228
* @notice Set the getter contract address
210
229
* @param _getterContract Address of the contract
@@ -233,10 +252,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
233
252
function registerTicker (address _owner , string calldata _ticker , string calldata _tokenName ) external whenNotPausedOrOwner {
234
253
require (_owner != address (0 ), "Owner should not be 0x " );
235
254
require (bytes (_ticker).length > 0 && bytes (_ticker).length <= 10 , "Ticker length range (0,10] " );
236
- // Attempt to charge the reg fee if it is > 0 POLY
237
- uint256 tickerFee = getUintValue (TICKERREGFEE);
238
- if (tickerFee > 0 )
239
- require (IERC20 (getAddressValue (POLYTOKEN)).transferFrom (msg .sender , address (this ), tickerFee), "Insufficent allowance " );
255
+ // Attempt to charge the reg fee if it is > 0 USD
256
+ (uint256 _usdFee , uint256 _polyFee ) = _takeFee (TICKERREGFEE);
240
257
string memory ticker = Util.upper (_ticker);
241
258
require (_tickerAvailable (ticker), "Ticker is reserved " );
242
259
// Check whether ticker was previously registered (and expired)
@@ -245,7 +262,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
245
262
_deleteTickerOwnership (previousOwner, ticker);
246
263
}
247
264
/*solium-disable-next-line security/no-block-members*/
248
- _addTicker (_owner, ticker, _tokenName, now , now .add (getUintValue (EXPIRYLIMIT)), false , false , tickerFee );
265
+ _addTicker (_owner, ticker, _tokenName, now , now .add (getUintValue (EXPIRYLIMIT)), false , false , _usdFee, _polyFee );
249
266
}
250
267
251
268
/**
@@ -259,13 +276,14 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
259
276
uint256 _expiryDate ,
260
277
bool _status ,
261
278
bool _fromAdmin ,
262
- uint256 _fee
279
+ uint256 _usdFee ,
280
+ uint256 _polyFee
263
281
)
264
282
internal
265
283
{
266
284
_setTickerOwnership (_owner, _ticker);
267
285
_storeTickerDetails (_ticker, _owner, _registrationDate, _expiryDate, _tokenName, _status);
268
- emit RegisterTicker (_owner, _ticker, _tokenName, _registrationDate, _expiryDate, _fromAdmin, _fee );
286
+ emit RegisterTicker (_owner, _ticker, _tokenName, _registrationDate, _expiryDate, _fromAdmin, _usdFee, _polyFee );
269
287
}
270
288
271
289
/**
@@ -321,7 +339,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
321
339
if (_status) {
322
340
require (getAddressValue (Encoder.getKey ("tickerToSecurityToken " , _ticker)) != address (0 ), "Token not registered " );
323
341
}
324
- _addTicker (_owner, _ticker, _tokenName, _registrationDate, _expiryDate, _status, true , uint256 (0 ));
342
+ _addTicker (_owner, _ticker, _tokenName, _registrationDate, _expiryDate, _status, true , uint256 (0 ), uint256 ( 0 ) );
325
343
}
326
344
327
345
function _tickerOwner (string memory _ticker ) internal view returns (address ) {
@@ -478,10 +496,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
478
496
require (_tickerOwner (ticker) == msg .sender , "Not authorised " );
479
497
/*solium-disable-next-line security/no-block-members*/
480
498
require (getUintValue (Encoder.getKey ("registeredTickers_expiryDate " , ticker)) >= now , "Ticker gets expired " );
481
-
482
- uint256 launchFee = getUintValue (STLAUNCHFEE);
483
- if (launchFee > 0 )
484
- require (IERC20 (getAddressValue (POLYTOKEN)).transferFrom (msg .sender , address (this ), launchFee), "Insufficient allowance " );
499
+ (uint256 _usdFee , uint256 _polyFee ) = _takeFee (STLAUNCHFEE);
485
500
486
501
address newSecurityTokenAddress = ISTFactory (getAddressValue (Encoder.getKey ("protocolVersionST " , getUintValue (Encoder.getKey ("latestVersion " ))))).deployToken (
487
502
_name,
@@ -497,7 +512,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
497
512
_storeSecurityTokenData (newSecurityTokenAddress, ticker, _tokenDetails, now );
498
513
set (Encoder.getKey ("tickerToSecurityToken " , ticker), newSecurityTokenAddress);
499
514
/*solium-disable-next-line security/no-block-members*/
500
- emit NewSecurityToken (ticker, _name, newSecurityTokenAddress, msg .sender , now , msg .sender , false , launchFee );
515
+ emit NewSecurityToken (ticker, _name, newSecurityTokenAddress, msg .sender , now , msg .sender , false , _usdFee, _polyFee );
501
516
}
502
517
503
518
/**
@@ -535,7 +550,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
535
550
set (Encoder.getKey ("tickerToSecurityToken " , ticker), _securityToken);
536
551
_modifyTicker (_owner, ticker, _name, registrationTime, expiryTime, true );
537
552
_storeSecurityTokenData (_securityToken, ticker, _tokenDetails, _deployedAt);
538
- emit NewSecurityToken (ticker, _name, _securityToken, _owner, _deployedAt, msg .sender , true , getUintValue (STLAUNCHFEE ));
553
+ emit NewSecurityToken (ticker, _name, _securityToken, _owner, _deployedAt, msg .sender , true , uint256 ( 0 ), uint256 ( 0 ));
539
554
}
540
555
541
556
/**
@@ -594,8 +609,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
594
609
}
595
610
596
611
/**
597
- * @notice Sets the ticker registration fee in POLY tokens. Only Polymath.
598
- * @param _tickerRegFee is the registration fee in POLY tokens (base 18 decimals)
612
+ * @notice Sets the ticker registration fee in USD tokens. Only Polymath.
613
+ * @param _tickerRegFee is the registration fee in USD tokens (base 18 decimals)
599
614
*/
600
615
function changeTickerRegistrationFee (uint256 _tickerRegFee ) external onlyOwner {
601
616
uint256 fee = getUintValue (TICKERREGFEE);
@@ -605,8 +620,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
605
620
}
606
621
607
622
/**
608
- * @notice Sets the ticker registration fee in POLY tokens. Only Polymath.
609
- * @param _stLaunchFee is the registration fee in POLY tokens (base 18 decimals)
623
+ * @notice Sets the ticker registration fee in USD tokens. Only Polymath.
624
+ * @param _stLaunchFee is the registration fee in USD tokens (base 18 decimals)
610
625
*/
611
626
function changeSecurityLaunchFee (uint256 _stLaunchFee ) external onlyOwner {
612
627
uint256 fee = getUintValue (STLAUNCHFEE);
0 commit comments