Skip to content

Commit 86508fb

Browse files
Merge pull request #437 from PolymathNetwork/multiple-stable-coins
Multiple stable coins support in USD Tiered STO
2 parents 2336d85 + 15d9dcf commit 86508fb

24 files changed

+677
-311
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ All notable changes to this project will be documented in this file.
55

66
[__2.1.0__](https://www.npmjs.com/package/polymath-core?activeTab=readme) __13-09-18__
77

8-
## CappedSTO 2.0.1
8+
9+
## CappedSTO 2.1.0
910
* `rate` is now accepted as multiplied by 10^18 to allow settting higher price than 1ETH/POLY per token.
1011
* Indivisble tokens are now supported. When trying to buy partial tokens, allowed full units of tokens will be purchased and remaining funds will be returned.
1112

1213
## USDTieredSTO 2.1.0
14+
* Added `stableCoinsRaised` function that returns amount of individual stable coin raised when address of that stable coin is passed.
15+
* Added support for multiple stable coins in USDTSTO.
1316
* Added `buyTokensView` and `getTokensMintedByTier` to USDTSTO.
1417
* Added `getSTODetails` to USDTSTO.
1518
* Added an Array of Tiers that will hold data about every tier in USDTSTO.

CLI/commands/ST20Generator.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ async function executeApp(_ticker, _transferOwnership, _name, _details, _divisib
3232
await step_transfer_ticker_ownership(_transferOwnership);
3333
await step_token_deploy(_name, _details, _divisible);
3434
}
35-
await tokenManager.executeApp(tokenSymbol);
35+
if (typeof _divisible === 'undefined') {
36+
await tokenManager.executeApp(tokenSymbol);
37+
}
3638
} catch (err) {
3739
console.log(err);
3840
return;

CLI/commands/TickerRollForward.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ let securityTokenRegistry;
2020
let securityTokenRegistryAddress;
2121

2222
function Ticker(_owner, _symbol, _name) {
23-
this.owner = _owner;
24-
this.symbol = _symbol;
25-
this.name = _name;
23+
this.owner = _owner;
24+
this.symbol = _symbol;
25+
this.name = _name;
2626
}
2727

2828
function FailedRegistration(_ticker, _error) {
@@ -58,11 +58,11 @@ async function startScript() {
5858
}
5959

6060
async function readFile() {
61-
var stream = fs.createReadStream("./CLI/data/ticker_data.csv");
61+
var stream = fs.createReadStream(`${__dirname}/../data/ticker_data.csv`);
6262

6363
var csvStream = csv()
6464
.on("data", function (data) {
65-
ticker_data.push(new Ticker(data[0],data[1],data[2],data[3]));
65+
ticker_data.push(new Ticker(data[0], data[1], data[2], data[3]));
6666
})
6767
.on("end", async function () {
6868
await registerTickers();
@@ -73,12 +73,12 @@ async function readFile() {
7373
async function registerTickers() {
7474
// Poly approval for registration fees
7575
let polyBalance = BigNumber(await polyToken.methods.balanceOf(Issuer.address).call());
76-
let fee = web3.utils.fromWei(await securityTokenRegistry.methods.getTickerRegistrationFee().call());
76+
let fee = web3.utils.fromWei(await securityTokenRegistry.methods.getTickerRegistrationFee().call());
7777
let totalFee = BigNumber(ticker_data.length).mul(fee);
7878

7979
if (totalFee.gt(polyBalance)) {
8080
console.log(chalk.red(`\n*******************************************************************************`));
81-
console.log(chalk.red(`Not enough POLY to pay registration fee. Require ${totalFee.div(10**18).toNumber()} POLY but have ${polyBalance.div(10**18).toNumber()} POLY.`));
81+
console.log(chalk.red(`Not enough POLY to pay registration fee. Require ${totalFee.div(10 ** 18).toNumber()} POLY but have ${polyBalance.div(10 ** 18).toNumber()} POLY.`));
8282
console.log(chalk.red(`*******************************************************************************\n`));
8383
process.exit(0);
8484
} else {
@@ -100,7 +100,7 @@ async function registerTickers() {
100100
}
101101

102102
// validate ticker
103-
await securityTokenRegistry.methods.getTickerDetails(ticker_data[i].symbol).call({}, function(error, result){
103+
await securityTokenRegistry.methods.getTickerDetails(ticker_data[i].symbol).call({}, function (error, result) {
104104
if (result[1] != 0) {
105105
failed_tickers.push(` ${i} is already registered`);
106106
valid = false;
@@ -131,7 +131,7 @@ async function logResults() {
131131
Successful registrations: ${registered_tickers.length}
132132
Failed registrations: ${failed_tickers.length}
133133
Total gas consumed: ${totalGas}
134-
Total gas cost: ${defaultGasPrice.mul(totalGas).div(10**18)} ETH
134+
Total gas cost: ${defaultGasPrice.mul(totalGas).div(10 ** 18)} ETH
135135
136136
List of failed registrations:
137137
${failed_tickers}

CLI/commands/common/common_functions.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const Tx = require('ethereumjs-tx');
33
const permissionsList = require('./permissions_list');
44
const abis = require('../helpers/contract_abis');
55

6-
async function connect(abi, address) {
6+
function connect(abi, address) {
77
contractRegistry = new web3.eth.Contract(abi, address);
88
contractRegistry.setProvider(web3.currentProvider);
99
return contractRegistry
@@ -15,7 +15,7 @@ async function checkPermission(contractName, functionName, contractRegistry) {
1515
return true
1616
} else {
1717
let stAddress = await contractRegistry.methods.securityToken().call();
18-
let securityToken = await connect(abis.securityToken(), stAddress);
18+
let securityToken = connect(abis.securityToken(), stAddress);
1919
let stOwner = await securityToken.methods.owner().call();
2020
if (stOwner == Issuer.address) {
2121
return true
@@ -48,11 +48,11 @@ async function getGasLimit(options, action) {
4848
}
4949

5050
async function checkPermissions(action) {
51-
let contractRegistry = await connect(action._parent.options.jsonInterface, action._parent._address);
51+
let contractRegistry = connect(action._parent.options.jsonInterface, action._parent._address);
5252
//NOTE this is a condition to verify if the transaction comes from a module or not.
5353
if (contractRegistry.methods.hasOwnProperty('factory')) {
5454
let moduleAddress = await contractRegistry.methods.factory().call();
55-
let moduleRegistry = await connect(abis.moduleFactory(), moduleAddress);
55+
let moduleRegistry = connect(abis.moduleFactory(), moduleAddress);
5656
let parentModule = await moduleRegistry.methods.getName().call();
5757
let result = await checkPermission(web3.utils.hexToUtf8(parentModule), action._method.name, contractRegistry);
5858
if (!result) {
@@ -153,6 +153,9 @@ module.exports = {
153153
let filteredLogs = logs.filter(l => l.topics.includes(eventJsonInterface.signature));
154154
return filteredLogs.map(l => web3.eth.abi.decodeLog(eventJsonInterface.inputs, l.data, l.topics.slice(1)));
155155
},
156+
connect: function (abi, address) {
157+
return connect(abi, address)
158+
},
156159
splitIntoBatches: function (data, batchSize) {
157160
let allBatches = [];
158161
for (let index = 0; index < data.length; index += batchSize) {

CLI/commands/common/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = Object.freeze({
2929
FUND_RAISE_TYPES: {
3030
ETH: 0,
3131
POLY: 1,
32-
DAI: 2
32+
STABLE: 2
3333
},
3434
DEFAULT_BATCH_SIZE: 75,
3535
ADDRESS_ZERO: '0x0000000000000000000000000000000000000000'

CLI/commands/common/global.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ module.exports = {
4444
console.log("Invalid remote node")
4545
process.exit(0)
4646
}
47-
await httpProvider(remoteNetwork, './privKey');
47+
await httpProvider(remoteNetwork, `${__dirname}/../../../privKey`);
4848
} else {
49-
await httpProvider("http://localhost:8545", './privKeyLocal');
49+
await httpProvider("http://localhost:8545", `${__dirname}/../../../privKeyLocal`);
5050
}
5151
defaultGasPrice = getGasPrice(await web3.eth.net.getId());
5252
}

0 commit comments

Comments
 (0)