Skip to content

Commit

Permalink
Merge branch 'dev-3.0.0' into upgradable-tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdossa authored Apr 1, 2019
2 parents 92b96b9 + 9bd9d47 commit d3884cb
Show file tree
Hide file tree
Showing 37 changed files with 367 additions and 151 deletions.
9 changes: 9 additions & 0 deletions contracts/STRGetter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ contract STRGetter is EternalStorage {
bytes32 constant STLAUNCHFEE = 0xd677304bb45536bb7fdfa6b9e47a3c58fe413f9e8f01474b0a4b9c6e0275baf2;
bytes32 constant TICKERREGFEE = 0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2;
bytes32 constant EXPIRYLIMIT = 0x604268e9a73dfd777dcecb8a614493dd65c638bad2f5e7d709d378bd2fb0baee;
bytes32 constant IS_FEE_IN_POLY = 0x7152e5426955da44af11ecd67fec5e2a3ba747be974678842afa9394b9a075b6; //keccak256("IS_FEE_IN_POLY")

/**
* @notice Returns the list of tickers owned by the selected address
Expand Down Expand Up @@ -242,6 +243,14 @@ contract STRGetter is EternalStorage {
return getUintValue(TICKERREGFEE);
}

/**
* @notice Gets the fee currency
* @return true = poly, false = usd
*/
function getIsFeeInPoly() public view returns(bool) {
return getBoolValue(IS_FEE_IN_POLY);
}

/**
* @notice Gets the expiry limit
* @return Expiry limit
Expand Down
50 changes: 42 additions & 8 deletions contracts/SecurityTokenRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
bytes32 constant OWNER = 0x02016836a56b71f0d02689e69e326f4f4c1b9057164ef592671cf0d37c8040c0;
bytes32 constant POLYMATHREGISTRY = 0x90eeab7c36075577c7cc5ff366e389fefa8a18289b949bab3529ab4471139d4d;
bytes32 constant STRGETTER = 0x982f24b3bd80807ec3cb227ba152e15c07d66855fa8ae6ca536e689205c0e2e9;
bytes32 constant IS_FEE_IN_POLY = 0x7152e5426955da44af11ecd67fec5e2a3ba747be974678842afa9394b9a075b6; //keccak256("IS_FEE_IN_POLY")

string constant POLY_ORACLE = "StablePolyUsdOracle";

Expand All @@ -90,6 +91,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
event ChangeSecurityLaunchFee(uint256 _oldFee, uint256 _newFee);
// Emit when changeTickerRegistrationFee is called
event ChangeTickerRegistrationFee(uint256 _oldFee, uint256 _newFee);
// Emit when Fee currency is changed
event ChangeFeeCurrency(bool _isFeeInPoly);
// Emit when ownership gets transferred
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
// Emit when ownership of the ticker gets changed
Expand Down Expand Up @@ -224,12 +227,18 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
* @notice Returns the usd & poly fee for a particular feetype
* @param _feeType Key corresponding to fee type
*/
function getFees(bytes32 _feeType) public returns (uint256, uint256) {
function getFees(bytes32 _feeType) public returns (uint256 usdFee, uint256 polyFee) {
bool isFeesInPoly = getBoolValue(IS_FEE_IN_POLY);
uint256 rawFee = getUintValue(_feeType);
address polymathRegistry = getAddressValue(POLYMATHREGISTRY);
uint256 polyRate = IOracle(IPolymathRegistry(polymathRegistry).getAddress(POLY_ORACLE)).getPrice();
uint256 usdFee = getUintValue(_feeType);
uint256 polyFee = DecimalMath.div(usdFee, polyRate);
return (usdFee, polyFee);
if (!isFeesInPoly) { //Fee is in USD and not poly
usdFee = rawFee;
polyFee = DecimalMath.div(rawFee, polyRate);
} else {
usdFee = DecimalMath.mul(rawFee, polyRate);
polyFee = rawFee;
}
}

/**
Expand Down Expand Up @@ -653,8 +662,12 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
function changeTickerRegistrationFee(uint256 _tickerRegFee) external onlyOwner {
uint256 fee = getUintValue(TICKERREGFEE);
require(fee != _tickerRegFee, "Bad fee");
emit ChangeTickerRegistrationFee(fee, _tickerRegFee);
set(TICKERREGFEE, _tickerRegFee);
_changeTickerRegistrationFee(fee, _tickerRegFee);
}

function _changeTickerRegistrationFee(uint256 _oldFee, uint256 _newFee) internal {
emit ChangeTickerRegistrationFee(_oldFee, _newFee);
set(TICKERREGFEE, _newFee);
}

/**
Expand All @@ -664,8 +677,29 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
function changeSecurityLaunchFee(uint256 _stLaunchFee) external onlyOwner {
uint256 fee = getUintValue(STLAUNCHFEE);
require(fee != _stLaunchFee, "Bad fee");
emit ChangeSecurityLaunchFee(fee, _stLaunchFee);
set(STLAUNCHFEE, _stLaunchFee);
_changeSecurityLaunchFee(fee, _stLaunchFee);
}

function _changeSecurityLaunchFee(uint256 _oldFee, uint256 _newFee) internal {
emit ChangeSecurityLaunchFee(_oldFee, _newFee);
set(STLAUNCHFEE, _newFee);
}

/**
* @notice Sets the ticker registration and ST launch fee amount and currency
* @param _tickerRegFee is the ticker registration fee (base 18 decimals)
* @param _stLaunchFee is the st generation fee (base 18 decimals)
* @param _isFeeInPoly defines if the fee is in poly or usd
*/
function changeFeesAmountAndCurrency(uint256 _tickerRegFee, uint256 _stLaunchFee, bool _isFeeInPoly) external onlyOwner {
uint256 tickerFee = getUintValue(TICKERREGFEE);
uint256 stFee = getUintValue(STLAUNCHFEE);
bool isOldFeesInPoly = getBoolValue(IS_FEE_IN_POLY);
require(isOldFeesInPoly != _isFeeInPoly, "Currency unchanged");
_changeTickerRegistrationFee(tickerFee, _tickerRegFee);
_changeSecurityLaunchFee(stFee, _stLaunchFee);
emit ChangeFeeCurrency(_isFeeInPoly);
set(IS_FEE_IN_POLY, _isFeeInPoly);
}

/**
Expand Down
9 changes: 9 additions & 0 deletions contracts/interfaces/IModuleFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pragma solidity ^0.5.0;
*/
interface IModuleFactory {
event ChangeSetupCost(uint256 _oldSetupCost, uint256 _newSetupCost);
event ChangeCostType(bool _isOldCostInPoly, bool _isNewCostInPoly);
event ChangeUsageCost(uint256 _oldUsageCost, uint256 _newUsageCost);
event GenerateModuleFromFactory(
address _module,
Expand Down Expand Up @@ -71,6 +72,14 @@ interface IModuleFactory {
*/
function changeUsageCost(uint256 _newUsageCost) external;

/**
* @notice Used to change the currency and amount of usage and setup cost
* @param _setupCost new setup cost
* @param _usageCost new usage cost
* @param _isCostInPoly new usage cost currency. USD or POLY
*/
function changeCostsAndType(uint256 _setupCost, uint256 _usageCost, bool _isCostInPoly) external;

/**
* @notice Function use to change the lower and upper bound of the compatible version st
* @param _boundType Type of bound
Expand Down
18 changes: 13 additions & 5 deletions contracts/interfaces/ISecurityTokenRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -175,18 +175,26 @@ interface ISecurityTokenRegistry {
*/
function changeExpiryLimit(uint256 _newExpiry) external;

/**
* @notice Sets the ticker registration fee in POLY tokens
* @param _tickerRegFee Registration fee in POLY tokens (base 18 decimals)
/**
* @notice Sets the ticker registration fee in USD tokens. Only Polymath.
* @param _tickerRegFee is the registration fee in USD tokens (base 18 decimals)
*/
function changeTickerRegistrationFee(uint256 _tickerRegFee) external;

/**
* @notice Sets the ticker registration fee in POLY tokens
* @param _stLaunchFee Registration fee in POLY tokens (base 18 decimals)
* @notice Sets the ticker registration fee in USD tokens. Only Polymath.
* @param _stLaunchFee is the registration fee in USD tokens (base 18 decimals)
*/
function changeSecurityLaunchFee(uint256 _stLaunchFee) external;

/**
* @notice Sets the ticker registration and ST launch fee amount and currency
* @param _tickerRegFee is the ticker registration fee (base 18 decimals)
* @param _stLaunchFee is the st generation fee (base 18 decimals)
* @param _isFeeInPoly defines if the fee is in poly or usd
*/
function changeFeesAmountAndCurrency(uint256 _tickerRegFee, uint256 _stLaunchFee, bool _isFeeInPoly) external;

/**
* @notice Gets the security token launch fee
* @return Fee amount
Expand Down
8 changes: 5 additions & 3 deletions contracts/mocks/Dummy/DummySTOFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ contract DummySTOFactory is UpgradableModuleFactory {
* @param _usageCost Usage cost of the module
* @param _logicContract Contract address that contains the logic related to `description`
* @param _polymathRegistry Address of the Polymath registry
* @param _isCostInPoly true = cost in Poly, false = USD
*/
constructor(
constructor (
uint256 _setupCost,
uint256 _usageCost,
address _logicContract,
address _polymathRegistry
address _polymathRegistry,
bool _isCostInPoly
)
public
UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry)
UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry, _isCostInPoly)
{
name = "DummySTO";
title = "Dummy STO";
Expand Down
5 changes: 3 additions & 2 deletions contracts/mocks/MockBurnFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ contract MockBurnFactory is TrackedRedemptionFactory {
constructor(
uint256 _setupCost,
uint256 _usageCost,
address _polymathRegistry
address _polymathRegistry,
bool _isFeeInPoly
)
public
TrackedRedemptionFactory(_setupCost, _usageCost, _polymathRegistry)
TrackedRedemptionFactory(_setupCost, _usageCost, _polymathRegistry, _isFeeInPoly)
{

}
Expand Down
5 changes: 3 additions & 2 deletions contracts/mocks/MockFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ contract MockFactory is DummySTOFactory {
uint256 _setupCost,
uint256 _usageCost,
address _logicContract,
address _polymathRegistry
address _polymathRegistry,
bool _isFeeInPoly
)
public
DummySTOFactory(_setupCost, _usageCost, _logicContract, _polymathRegistry)
DummySTOFactory(_setupCost, _usageCost, _logicContract, _polymathRegistry, _isFeeInPoly)
{
}

Expand Down
5 changes: 3 additions & 2 deletions contracts/mocks/MockWrongTypeFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ contract MockWrongTypeFactory is MockBurnFactory {
constructor(
uint256 _setupCost,
uint256 _usageCost,
address _polymathRegistry
address _polymathRegistry,
bool _isFeeInPoly
)
public
MockBurnFactory(_setupCost, _usageCost, _polymathRegistry)
MockBurnFactory(_setupCost, _usageCost, _polymathRegistry, _isFeeInPoly)
{

}
Expand Down
5 changes: 3 additions & 2 deletions contracts/mocks/TestSTOFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ contract TestSTOFactory is DummySTOFactory {
uint256 _setupCost,
uint256 _usageCost,
address _logicContract,
address _polymathRegistry
address _polymathRegistry,
bool _isFeeInPoly
)
public
DummySTOFactory(_setupCost, _usageCost, _logicContract, _polymathRegistry)
DummySTOFactory(_setupCost, _usageCost, _logicContract, _polymathRegistry, _isFeeInPoly)
{
name = "TestSTO";
title = "Test STO";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ contract ERC20DividendCheckpointFactory is UpgradableModuleFactory {
* @param _usageCost Usage cost of the module
* @param _logicContract Contract address that contains the logic related to `description`
* @param _polymathRegistry Address of the Polymath registry
* @param _isCostInPoly true = cost in Poly, false = USD
*/
constructor(
constructor (
uint256 _setupCost,
uint256 _usageCost,
address _logicContract,
address _polymathRegistry
address _polymathRegistry,
bool _isCostInPoly
)
public
UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry)
UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry, _isCostInPoly)
{
name = "ERC20DividendCheckpoint";
title = "ERC20 Dividend Checkpoint";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ contract EtherDividendCheckpointFactory is UpgradableModuleFactory {
* @param _usageCost Usage cost of the module
* @param _logicContract Contract address that contains the logic related to `description`
* @param _polymathRegistry Address of the Polymath registry
* @param _isCostInPoly true = cost in Poly, false = USD
*/
constructor(
constructor (
uint256 _setupCost,
uint256 _usageCost,
address _logicContract,
address _polymathRegistry
address _polymathRegistry,
bool _isCostInPoly
)
public
UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry)
UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry, _isCostInPoly)
{
name = "EtherDividendCheckpoint";
title = "Ether Dividend Checkpoint";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ contract TrackedRedemptionFactory is ModuleFactory {
* @param _setupCost Setup cost of module
* @param _usageCost Usage cost of module
* @param _polymathRegistry Address of the Polymath registry
* @param _isCostInPoly true = cost in Poly, false = USD
*/
constructor(
uint256 _setupCost,
uint256 _usageCost,
address _polymathRegistry
address _polymathRegistry,
bool _isCostInPoly
)
public
ModuleFactory(_setupCost, _usageCost, _polymathRegistry)
public ModuleFactory(_setupCost, _usageCost, _polymathRegistry, _isCostInPoly)
{
initialVersion = "3.0.0";
name = "TrackedRedemption";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ contract ScheduledCheckpointFactory is ModuleFactory {
* @param _setupCost Setup cost of the module
* @param _usageCost Usage cost of the module
* @param _polymathRegistry Address of the Polymath registry
* @param _isCostInPoly true = cost in Poly, false = USD
*/
constructor(
uint256 _setupCost,
uint256 _usageCost,
address _polymathRegistry
address _polymathRegistry,
bool _isCostInPoly
)
public
ModuleFactory(_setupCost, _usageCost, _polymathRegistry)
public ModuleFactory(_setupCost, _usageCost, _polymathRegistry, _isCostInPoly)
{
initialVersion = "3.0.0";
name = "ScheduledCheckpoint";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ contract BlacklistTransferManagerFactory is ModuleFactory {
* @param _setupCost Setup cost of the module
* @param _usageCost Usage cost of the module
* @param _polymathRegistry Address of the Polymath registry
* @param _isCostInPoly true = cost in Poly, false = USD
*/
constructor (uint256 _setupCost, uint256 _usageCost, address _polymathRegistry) public
ModuleFactory(_setupCost, _usageCost, _polymathRegistry)
constructor(
uint256 _setupCost,
uint256 _usageCost,
address _polymathRegistry,
bool _isCostInPoly
)
public ModuleFactory(_setupCost, _usageCost, _polymathRegistry, _isCostInPoly)
{
initialVersion = "3.0.0";
name = "BlacklistTransferManager";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ contract KYCTransferManagerFactory is ModuleFactory {
/**
* @notice Constructor
*/
constructor (uint256 _setupCost, uint256 _usageCost, address _polymathRegistry) public
ModuleFactory(_setupCost, _usageCost, _polymathRegistry)
constructor(
uint256 _setupCost,
uint256 _usageCost,
address _polymathRegistry,
bool _isCostInPoly
)
public ModuleFactory(_setupCost, _usageCost, _polymathRegistry, _isCostInPoly)
{
initialVersion = "3.0.0";
name = "KYCTransferManager";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ contract LockUpTransferManagerFactory is UpgradableModuleFactory {
* @param _setupCost Setup cost of the module
* @param _usageCost Usage cost of the module
* @param _polymathRegistry Address of the Polymath registry
* @param _isCostInPoly true = cost in Poly, false = USD
*/
constructor(
uint256 _setupCost,
uint256 _usageCost,
address _logicContract,
address _polymathRegistry
address _polymathRegistry,
bool _isCostInPoly
)
public
UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry)
UpgradableModuleFactory("3.0.0", _setupCost, _usageCost, _logicContract, _polymathRegistry, _isCostInPoly)
{
name = "LockUpTransferManager";
title = "LockUp Transfer Manager";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ contract SignedTransferManagerFactory is ModuleFactory {
/**
* @notice Constructor
*/
constructor (uint256 _setupCost, uint256 _usageCost, address _polymathRegistry) public
ModuleFactory(_setupCost, _usageCost, _polymathRegistry)
constructor(
uint256 _setupCost,
uint256 _usageCost,
address _polymathRegistry,
bool _isCostInPoly
)
public ModuleFactory(_setupCost, _usageCost, _polymathRegistry, _isCostInPoly)
{
initialVersion = "3.0.0";
name = "SignedTransferManager";
Expand Down
Loading

0 comments on commit d3884cb

Please sign in to comment.