Skip to content

Commit eff3390

Browse files
authored
Merge branch 'dev-3.0.0' into migrate-gtm-data
2 parents 28f0652 + 25e8f0e commit eff3390

File tree

60 files changed

+454
-487
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+454
-487
lines changed

contracts/PolymathRegistry.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ contract PolymathRegistry is ReclaimTokens {
1717
*/
1818
function getAddress(string calldata _nameKey) external view returns(address) {
1919
bytes32 key = keccak256(bytes(_nameKey));
20-
require(storedAddresses[key] != address(0), "Invalid address key");
20+
require(storedAddresses[key] != address(0), "Invalid key");
2121
return storedAddresses[key];
2222
}
2323

contracts/SecurityTokenRegistry.sol

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import "./libraries/Util.sol";
1111
import "./libraries/Encoder.sol";
1212
import "./libraries/VersionUtils.sol";
1313
import "./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);

contracts/interfaces/IModuleFactory.sol

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ pragma solidity ^0.5.0;
44
* @title Interface that every module factory contract should implement
55
*/
66
interface IModuleFactory {
7-
event ChangeFactorySetupFee(uint256 _oldSetupCost, uint256 _newSetupCost, address _moduleFactory);
8-
event ChangeFactoryUsageFee(uint256 _oldUsageCost, uint256 _newUsageCost, address _moduleFactory);
9-
event ChangeFactorySubscriptionFee(uint256 _oldSubscriptionCost, uint256 _newMonthlySubscriptionCost, address _moduleFactory);
7+
event ChangeSetupCost(uint256 _oldSetupCost, uint256 _newSetupCost);
8+
event ChangeUsageCost(uint256 _oldUsageCost, uint256 _newUsageCost);
109
event GenerateModuleFromFactory(
1110
address _module,
1211
bytes32 indexed _moduleName,
1312
address indexed _moduleFactory,
1413
address _creator,
1514
uint256 _setupCost,
15+
uint256 _setupCostInPoly,
1616
uint256 _timestamp
1717
);
1818
event ChangeSTVersionBound(string _boundType, uint8 _major, uint8 _minor, uint8 _patch);
@@ -44,19 +44,13 @@ interface IModuleFactory {
4444
* @notice Used to change the setup fee
4545
* @param _newSetupCost New setup fee
4646
*/
47-
function changeFactorySetupFee(uint256 _newSetupCost) external;
47+
function changeSetupCost(uint256 _newSetupCost) external;
4848

4949
/**
5050
* @notice Used to change the usage fee
5151
* @param _newUsageCost New usage fee
5252
*/
53-
function changeFactoryUsageFee(uint256 _newUsageCost) external;
54-
55-
/**
56-
* @notice Used to change the subscription fee
57-
* @param _newSubscriptionCost New subscription fee
58-
*/
59-
function changeFactorySubscriptionFee(uint256 _newSubscriptionCost) external;
53+
function changeUsageCost(uint256 _newUsageCost) external;
6054

6155
/**
6256
* @notice Function use to change the lower and upper bound of the compatible version st
@@ -66,10 +60,15 @@ interface IModuleFactory {
6660
function changeSTVersionBounds(string calldata _boundType, uint8[] calldata _newVersion) external;
6761

6862
/**
69-
* @notice Get the setup cost of the module
63+
* @notice Get the setup cost of the module in USD
7064
*/
7165
function getSetupCost() external view returns(uint256);
7266

67+
/**
68+
* @notice Get the setup cost of the module
69+
*/
70+
function getSetupCostInPoly() external view returns (uint256);
71+
7372
/**
7473
* @notice Used to get the lower bound
7574
* @return Lower bound

contracts/mocks/MockBurnFactory.sol

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@ import "../modules/Experimental/Burn/TrackedRedemptionFactory.sol";
88
*/
99

1010
contract MockBurnFactory is TrackedRedemptionFactory {
11+
1112
/**
1213
* @notice Constructor
1314
* @param _setupCost Setup cost of the module
1415
* @param _usageCost Usage cost of the module
15-
* @param _subscriptionCost Subscription cost of the module
16+
* @param _polymathRegistry Address of the Polymath Registry
1617
*/
1718
constructor(
1819
uint256 _setupCost,
1920
uint256 _usageCost,
20-
uint256 _subscriptionCost
21-
)
22-
public
23-
TrackedRedemptionFactory(_setupCost, _usageCost, _subscriptionCost)
21+
address _polymathRegistry
22+
)
23+
public
24+
TrackedRedemptionFactory(_setupCost, _usageCost, _polymathRegistry)
2425
{
2526

2627
}
@@ -31,15 +32,15 @@ contract MockBurnFactory is TrackedRedemptionFactory {
3132
*/
3233
function deploy(
3334
bytes calldata /*_data*/
34-
)
35-
external
36-
returns(address)
35+
)
36+
external
37+
returns(address)
3738
{
3839
address polyToken = _takeFee();
3940
//Check valid bytes - can only call module init function
4041
MockRedemptionManager mockRedemptionManager = new MockRedemptionManager(msg.sender, polyToken);
4142
/*solium-disable-next-line security/no-block-members*/
42-
emit GenerateModuleFromFactory(address(mockRedemptionManager), getName(), address(this), msg.sender, setupCost, now);
43+
emit GenerateModuleFromFactory(address(mockRedemptionManager), getName(), address(this), msg.sender, getSetupCost(), getSetupCostInPoly(), now);
4344
return address(mockRedemptionManager);
4445
}
4546

contracts/mocks/MockFactory.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ contract MockFactory is DummySTOFactory {
1313
* @notice Constructor
1414
* @param _setupCost Setup cost of the module
1515
* @param _usageCost Usage cost of the module
16-
* @param _subscriptionCost Subscription cost of the module
1716
* @param _logicContract Contract address that contains the logic related to `description`
17+
* @param _polymathRegistry Address of the Polymath Registry
1818
*/
1919
constructor(
2020
uint256 _setupCost,
2121
uint256 _usageCost,
22-
uint256 _subscriptionCost,
23-
address _logicContract
24-
)
25-
public
26-
DummySTOFactory(_setupCost, _usageCost, _subscriptionCost, _logicContract)
22+
address _logicContract,
23+
address _polymathRegistry
24+
)
25+
public
26+
DummySTOFactory(_setupCost, _usageCost, _logicContract, _polymathRegistry)
2727
{
2828
}
2929

contracts/mocks/MockWrongTypeFactory.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ contract MockWrongTypeFactory is MockBurnFactory {
1313
* @notice Constructor
1414
* @param _setupCost Setup cost of the module
1515
* @param _usageCost Usage cost of the module
16-
* @param _subscriptionCost Subscription cost of the module
16+
* @param _polymathRegistry Address of the Polymath Registry
1717
*/
1818
constructor(
1919
uint256 _setupCost,
2020
uint256 _usageCost,
21-
uint256 _subscriptionCost
22-
)
23-
public
24-
MockBurnFactory(_setupCost, _usageCost, _subscriptionCost)
21+
address _polymathRegistry
22+
)
23+
public
24+
MockBurnFactory(_setupCost, _usageCost, _polymathRegistry)
2525
{
2626

2727
}

contracts/mocks/TestSTOFactory.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ contract TestSTOFactory is DummySTOFactory {
77
* @notice Constructor
88
* @param _setupCost Setup cost of the module
99
* @param _usageCost Usage cost of the module
10-
* @param _subscriptionCost Subscription cost of the module
1110
* @param _logicContract Contract address that contains the logic related to `description`
11+
* @param _polymathRegistry Address of the Polymath Registry
1212
*/
1313
constructor(
1414
uint256 _setupCost,
1515
uint256 _usageCost,
16-
uint256 _subscriptionCost,
17-
address _logicContract
18-
)
19-
public
20-
DummySTOFactory(_setupCost, _usageCost, _subscriptionCost, _logicContract)
16+
address _logicContract,
17+
address _polymathRegistry
18+
)
19+
public
20+
DummySTOFactory(_setupCost, _usageCost, _logicContract, _polymathRegistry)
2121
{
2222
version = "1.0.0";
2323
name = "TestSTO";

contracts/modules/Checkpoint/ERC20DividendCheckpointFactory.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ contract ERC20DividendCheckpointFactory is ModuleFactory {
1515
* @notice Constructor
1616
* @param _setupCost Setup cost of the module
1717
* @param _usageCost Usage cost of the module
18-
* @param _subscriptionCost Subscription cost of the module
1918
* @param _logicContract Contract address that contains the logic related to `description`
19+
* @param _polymathRegistry Address of the Polymath registry
2020
*/
2121
constructor(
2222
uint256 _setupCost,
2323
uint256 _usageCost,
24-
uint256 _subscriptionCost,
25-
address _logicContract
24+
address _logicContract,
25+
address _polymathRegistry
2626
)
2727
public
28-
ModuleFactory(_setupCost, _usageCost, _subscriptionCost)
28+
ModuleFactory(_setupCost, _usageCost, _polymathRegistry)
2929
{
3030
require(_logicContract != address(0), "Invalid logic contract");
3131
version = "2.1.0";
@@ -51,7 +51,7 @@ contract ERC20DividendCheckpointFactory is ModuleFactory {
5151
(success, ) = erc20DividendCheckpoint.call(_data);
5252
require(success, "Unsuccessful call");
5353
/*solium-disable-next-line security/no-block-members*/
54-
emit GenerateModuleFromFactory(erc20DividendCheckpoint, getName(), address(this), msg.sender, setupCost, now);
54+
emit GenerateModuleFromFactory(erc20DividendCheckpoint, getName(), address(this), msg.sender, getSetupCost(), getSetupCostInPoly(), now);
5555
return erc20DividendCheckpoint;
5656
}
5757

0 commit comments

Comments
 (0)