@@ -11,6 +11,8 @@ import "./libraries/Util.sol";
1111import "./libraries/Encoder.sol " ;
1212import "./libraries/VersionUtils.sol " ;
1313import "./proxy/Proxy.sol " ;
14+ import "./interfaces/IOracle.sol " ;
15+ import "./libraries/DecimalMath.sol " ;
1416
1517/**
1618 * @title Registry contract for issuers to register their tickers and security tokens
@@ -74,6 +76,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
7476 bytes32 constant POLYMATHREGISTRY = 0x90eeab7c36075577c7cc5ff366e389fefa8a18289b949bab3529ab4471139d4d ;
7577 bytes32 constant STRGETTER = 0x982f24b3bd80807ec3cb227ba152e15c07d66855fa8ae6ca536e689205c0e2e9 ;
7678
79+ string constant POLY_ORACLE = "PolyUsdOracle " ;
80+
7781 // Emit when network becomes paused
7882 event Pause (uint256 _timestammp );
7983 // Emit when network becomes unpaused
@@ -99,7 +103,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
99103 uint256 _addedAt ,
100104 address _registrant ,
101105 bool _fromAdmin ,
102- uint256 _registrationFee
106+ uint256 _usdFee ,
107+ uint256 _polyFee
103108 );
104109 // Emit after ticker registration
105110 event RegisterTicker (
@@ -109,7 +114,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
109114 uint256 indexed _registrationDate ,
110115 uint256 indexed _expiryDate ,
111116 bool _fromAdmin ,
112- uint256 _registrationFee
117+ uint256 _usdFee ,
118+ uint256 _polyFee
113119 );
114120
115121 /////////////////////////////
@@ -159,8 +165,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
159165 * @notice Initializes instance of STR
160166 * @param _polymathRegistry is the address of the Polymath Registry
161167 * @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
164170 * @param _owner is the owner of the STR,
165171 * @param _getterContract Contract address of the contract which consists getter functions.
166172 */
@@ -205,6 +211,19 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
205211 set (POLYTOKEN, IPolymathRegistry (polymathRegistry).getAddress ("PolyToken " ));
206212 }
207213
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+
208227 /**
209228 * @notice Set the getter contract address
210229 * @param _getterContract Address of the contract
@@ -233,10 +252,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
233252 function registerTicker (address _owner , string calldata _ticker , string calldata _tokenName ) external whenNotPausedOrOwner {
234253 require (_owner != address (0 ), "Owner should not be 0x " );
235254 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);
240257 string memory ticker = Util.upper (_ticker);
241258 require (_tickerAvailable (ticker), "Ticker is reserved " );
242259 // Check whether ticker was previously registered (and expired)
@@ -245,7 +262,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
245262 _deleteTickerOwnership (previousOwner, ticker);
246263 }
247264 /*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 );
249266 }
250267
251268 /**
@@ -259,13 +276,14 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
259276 uint256 _expiryDate ,
260277 bool _status ,
261278 bool _fromAdmin ,
262- uint256 _fee
279+ uint256 _usdFee ,
280+ uint256 _polyFee
263281 )
264282 internal
265283 {
266284 _setTickerOwnership (_owner, _ticker);
267285 _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 );
269287 }
270288
271289 /**
@@ -321,7 +339,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
321339 if (_status) {
322340 require (getAddressValue (Encoder.getKey ("tickerToSecurityToken " , _ticker)) != address (0 ), "Token not registered " );
323341 }
324- _addTicker (_owner, _ticker, _tokenName, _registrationDate, _expiryDate, _status, true , uint256 (0 ));
342+ _addTicker (_owner, _ticker, _tokenName, _registrationDate, _expiryDate, _status, true , uint256 (0 ), uint256 ( 0 ) );
325343 }
326344
327345 function _tickerOwner (string memory _ticker ) internal view returns (address ) {
@@ -478,10 +496,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
478496 require (_tickerOwner (ticker) == msg .sender , "Not authorised " );
479497 /*solium-disable-next-line security/no-block-members*/
480498 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);
485500
486501 address newSecurityTokenAddress = ISTFactory (getAddressValue (Encoder.getKey ("protocolVersionST " , getUintValue (Encoder.getKey ("latestVersion " ))))).deployToken (
487502 _name,
@@ -497,7 +512,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
497512 _storeSecurityTokenData (newSecurityTokenAddress, ticker, _tokenDetails, now );
498513 set (Encoder.getKey ("tickerToSecurityToken " , ticker), newSecurityTokenAddress);
499514 /*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 );
501516 }
502517
503518 /**
@@ -535,7 +550,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
535550 set (Encoder.getKey ("tickerToSecurityToken " , ticker), _securityToken);
536551 _modifyTicker (_owner, ticker, _name, registrationTime, expiryTime, true );
537552 _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 ));
539554 }
540555
541556 /**
@@ -594,8 +609,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
594609 }
595610
596611 /**
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)
599614 */
600615 function changeTickerRegistrationFee (uint256 _tickerRegFee ) external onlyOwner {
601616 uint256 fee = getUintValue (TICKERREGFEE);
@@ -605,8 +620,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
605620 }
606621
607622 /**
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)
610625 */
611626 function changeSecurityLaunchFee (uint256 _stLaunchFee ) external onlyOwner {
612627 uint256 fee = getUintValue (STLAUNCHFEE);
0 commit comments