Skip to content

Commit

Permalink
refactor: rename UsdTieredSto to TieredSto
Browse files Browse the repository at this point in the history
This is in line with changes to the smart contracts which will allow Tiered STOs to raise funds in
any denomination

BREAKING CHANGE: entity `UsdTieredSto` rernamed to `TieredSto`, enum `StoType.UsdTiered` changed to
`StoType.Tiered`
  • Loading branch information
monitz87 committed Oct 30, 2019
1 parent 750ace1 commit 06e719f
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 63 deletions.
6 changes: 3 additions & 3 deletions src/Context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Erc20TokenBalanceFactory,
InvestmentFactory,
CappedStoFactory,
UsdTieredStoFactory,
TieredStoFactory,
DividendDistributionFactory,
CheckpointFactory,
Erc20DividendsManagerFactory,
Expand All @@ -25,7 +25,7 @@ interface Factories {
erc20TokenBalanceFactory: Erc20TokenBalanceFactory;
investmentFactory: InvestmentFactory;
cappedStoFactory: CappedStoFactory;
usdTieredStoFactory: UsdTieredStoFactory;
tieredStoFactory: TieredStoFactory;
dividendDistributionFactory: DividendDistributionFactory;
checkpointFactory: CheckpointFactory;
erc20DividendsManagerFactory: Erc20DividendsManagerFactory;
Expand Down Expand Up @@ -61,7 +61,7 @@ export class Context {
erc20TokenBalanceFactory: new Erc20TokenBalanceFactory(this),
investmentFactory: new InvestmentFactory(this),
cappedStoFactory: new CappedStoFactory(this),
usdTieredStoFactory: new UsdTieredStoFactory(this),
tieredStoFactory: new TieredStoFactory(this),
dividendDistributionFactory: new DividendDistributionFactory(this),
checkpointFactory: new CheckpointFactory(this),
erc20DividendsManagerFactory: new Erc20DividendsManagerFactory(this),
Expand Down
38 changes: 19 additions & 19 deletions src/entities/SecurityToken/Offerings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { BigNumber, ModuleName } from '@polymathnetwork/contract-wrappers';
import { includes } from 'lodash';
import { SubModule } from './SubModule';
import { CappedStoCurrency, StoTier, Currency, StoType, ErrorCode } from '../../types';
import { LaunchCappedSto, LaunchUsdTieredSto } from '../../procedures';
import { CappedSto, UsdTieredSto, Sto } from '..';
import { LaunchCappedSto, LaunchTieredSto } from '../../procedures';
import { CappedSto, TieredSto, Sto } from '..';
import { PolymathError } from '../../PolymathError';

interface GetSto {
(args: { stoType: StoType.Capped; address: string }): Promise<CappedSto>;
(args: { stoType: StoType.UsdTiered; address: string }): Promise<UsdTieredSto>;
(args: string): Promise<CappedSto | UsdTieredSto>;
(args: { stoType: StoType.Tiered; address: string }): Promise<TieredSto>;
(args: string): Promise<CappedSto | TieredSto>;
}

export class Offerings extends SubModule {
Expand Down Expand Up @@ -47,24 +47,24 @@ export class Offerings extends SubModule {
};

/**
* Launch a USD Tiered STO
* Launch a Tiered STO
*
* @param startDate date when the STO should start
* @param endDate date when the STO should end
* @param tiers tier information
* @param tiers[].tokensOnSale amount of tokens to be sold on that tier
* @param tiers[].price price of each token on that tier in USD
* @param tiers[].price price of each token on that tier
* @param tiers[].tokensWithDiscount amount of tokens to be sold on that tier at a discount if paid in POLY (must be less than tokensOnSale, defaults to 0)
* @param tiers[].discountedPrice price of discounted tokens on that tier (defaults to 0)
* @param nonAccreditedInvestmentLimit maximum investment for non-accredited investors
* @param minimumInvestment minimum investment amount
* @param currencies array of currencies in which the funds will be raised (ETH, POLY, StableCoin)
* @param storageWallet wallet address that will receive the funds that are being raised
* @param treasuryWallet wallet address that will receive unsold tokens when the end date is reached
* @param usdTokenAddresses array of USD stable coins that the offering supports
* @param stableCoinAddresses array of stable coins that the offering supports
*
*/
public launchUsdTieredSto = async (args: {
public launchTieredSto = async (args: {
startDate: Date;
endDate: Date;
tiers: StoTier[];
Expand All @@ -73,11 +73,11 @@ export class Offerings extends SubModule {
currencies: Currency[];
storageWallet: string;
treasuryWallet: string;
usdTokenAddresses: string[];
stableCoinAddresses: string[];
}) => {
const { context, securityToken } = this;
const { symbol } = securityToken;
const procedure = new LaunchUsdTieredSto(
const procedure = new LaunchTieredSto(
{
symbol,
...args,
Expand All @@ -90,7 +90,7 @@ export class Offerings extends SubModule {
/**
* Retrieve an STO by type and address or UUID
*
* @param stoType type of the STO (Capped or USDTiered)
* @param stoType type of the STO (Capped or Tiered)
* @param address address of the STO contract
*/
public getSto: GetSto = async (
Expand Down Expand Up @@ -120,9 +120,9 @@ export class Offerings extends SubModule {
return factories.cappedStoFactory.fetch(
CappedSto.generateId({ securityTokenId: uid, stoType, address })
);
} else if (stoType === StoType.UsdTiered) {
return factories.usdTieredStoFactory.fetch(
UsdTieredSto.generateId({ securityTokenId: uid, stoType, address })
} else if (stoType === StoType.Tiered) {
return factories.tieredStoFactory.fetch(
TieredSto.generateId({ securityTokenId: uid, stoType, address })
);
} else {
throw new PolymathError({
Expand All @@ -141,7 +141,7 @@ export class Offerings extends SubModule {
opts: {
stoTypes: StoType[];
} = {
stoTypes: [StoType.Capped, StoType.UsdTiered],
stoTypes: [StoType.Capped, StoType.Tiered],
}
) => {
const { contractWrappers, factories } = this.context;
Expand All @@ -150,7 +150,7 @@ export class Offerings extends SubModule {

const { stoTypes } = opts;

let stos: Promise<CappedSto | UsdTieredSto>[] = [];
let stos: Promise<CappedSto | TieredSto>[] = [];

if (includes(stoTypes, StoType.Capped)) {
const fetchedModules = await contractWrappers.getAttachedModules(
Expand All @@ -169,7 +169,7 @@ export class Offerings extends SubModule {
);
}

if (includes(stoTypes, StoType.UsdTiered)) {
if (includes(stoTypes, StoType.Tiered)) {
const fetchedModules = await contractWrappers.getAttachedModules(
{ symbol: securityTokenSymbol, moduleName: ModuleName.UsdTieredSTO },
{ unarchived: true }
Expand All @@ -179,8 +179,8 @@ export class Offerings extends SubModule {

stos = stos.concat(
addresses.map(address =>
factories.usdTieredStoFactory.fetch(
UsdTieredSto.generateId({ address, stoType: StoType.Capped, securityTokenId: uid })
factories.tieredStoFactory.fetch(
TieredSto.generateId({ address, stoType: StoType.Capped, securityTokenId: uid })
)
)
);
Expand Down
6 changes: 3 additions & 3 deletions src/entities/UsdTieredSto.ts → src/entities/TieredSto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export interface Params extends StoParams {
tiers: Tier[];
}

export class UsdTieredSto extends Sto<Params> {
export class TieredSto extends Sto<Params> {
public static generateId({ securityTokenId, stoType, address }: UniqueIdentifiers) {
return serialize('usdTieredSto', {
return serialize('tieredSto', {
securityTokenId,
stoType,
address,
Expand All @@ -39,7 +39,7 @@ export class UsdTieredSto extends Sto<Params> {

this.currentTier = currentTier;
this.tiers = tiers;
this.uid = UsdTieredSto.generateId({ address, stoType, securityTokenId });
this.uid = TieredSto.generateId({ address, stoType, securityTokenId });
}

public toPojo() {
Expand Down
2 changes: 1 addition & 1 deletion src/entities/factories/InvestmentFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class InvestmentFactory extends Factory<Investment, Params, UniqueIdentif
investedFunds: weiToValue(value, FULL_DECIMALS),
securityTokenSymbol: symbol,
};
} else if (stoType === StoType.UsdTiered) {
} else if (stoType === StoType.Tiered) {
const module = await this.context.contractWrappers.moduleFactory.getModuleInstance({
name: ModuleName.UsdTieredSTO,
address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import { Context } from '../../Context';
import { Currency } from '../../types';
import { SecurityToken } from '../SecurityToken';
import { Investment } from '../Investment';
import { UsdTieredSto, Params, UniqueIdentifiers } from '../UsdTieredSto';
import { TieredSto, Params, UniqueIdentifiers } from '../TieredSto';

const { weiToValue } = conversionUtils;

export class UsdTieredStoFactory extends Factory<UsdTieredSto, Params, UniqueIdentifiers> {
export class TieredStoFactory extends Factory<TieredSto, Params, UniqueIdentifiers> {
protected generateProperties = async (uid: string) => {
const { securityTokenId, stoType, address } = UsdTieredSto.unserialize(uid);
const { securityTokenId, stoType, address } = TieredSto.unserialize(uid);

const { symbol } = SecurityToken.unserialize(securityTokenId);

Expand Down Expand Up @@ -59,7 +59,7 @@ export class UsdTieredStoFactory extends Factory<UsdTieredSto, Params, UniqueIde
},
] = await Promise.all([module.paused(), module.capReached(), module.getSTODetails()]);

const stoId = UsdTieredSto.generateId({
const stoId = TieredSto.generateId({
securityTokenId,
stoType,
address,
Expand Down Expand Up @@ -106,6 +106,6 @@ export class UsdTieredStoFactory extends Factory<UsdTieredSto, Params, UniqueIde
};

constructor(context: Context) {
super(UsdTieredSto, context);
super(TieredSto, context);
}
}
2 changes: 1 addition & 1 deletion src/entities/factories/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export { SecurityTokenReservationFactory } from './SecurityTokenReservationFacto
export { Erc20TokenBalanceFactory } from './Erc20TokenBalanceFactory';
export { InvestmentFactory } from './InvestmentFactory';
export { CappedStoFactory } from './CappedStoFactory';
export { UsdTieredStoFactory } from './UsdTieredStoFactory';
export { TieredStoFactory } from './TieredStoFactory';
export { DividendDistributionFactory } from './DividendDistributionFactory';
export { CheckpointFactory } from './CheckpointFactory';
export { Erc20DividendsManagerFactory } from './Erc20DividendsManagerFactory';
Expand Down
2 changes: 1 addition & 1 deletion src/entities/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export { PolyTransaction } from './PolyTransaction';
export { TransactionQueue } from './TransactionQueue';
export { Erc20TokenBalance } from './Erc20TokenBalance';
export { CappedSto } from './CappedSto';
export { UsdTieredSto } from './UsdTieredSto';
export { TieredSto } from './TieredSto';
export { Investment } from './Investment';
export { Sto } from './Sto';
export { Shareholder } from './Shareholder';
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import {
ProcedureType,
PolyTransactionTag,
ErrorCode,
LaunchUsdTieredStoProcedureArgs,
LaunchTieredStoProcedureArgs,
StoType,
} from '../types';
import { PolymathError } from '../PolymathError';
import { TransferErc20 } from './TransferErc20';
import { findEvents } from '../utils';
import { SecurityToken, UsdTieredSto } from '../entities';
import { SecurityToken, TieredSto } from '../entities';

interface AddUSDTieredSTOParams {
moduleName: ModuleName.UsdTieredSTO;
Expand All @@ -38,8 +38,8 @@ interface AddUSDTieredSTOParams {
label?: string;
}

export class LaunchUsdTieredSto extends Procedure<LaunchUsdTieredStoProcedureArgs, UsdTieredSto> {
public type = ProcedureType.LaunchUsdTieredSto;
export class LaunchTieredSto extends Procedure<LaunchTieredStoProcedureArgs, TieredSto> {
public type = ProcedureType.LaunchTieredSto;

public async prepareTransactions() {
const { args, context } = this;
Expand All @@ -53,11 +53,11 @@ export class LaunchUsdTieredSto extends Procedure<LaunchUsdTieredStoProcedureArg
currencies,
storageWallet,
treasuryWallet,
usdTokenAddresses,
stableCoinAddresses,
} = args;
const {
contractWrappers,
factories: { usdTieredStoFactory },
factories: { tieredStoFactory },
} = context;

let securityToken;
Expand Down Expand Up @@ -117,10 +117,10 @@ export class LaunchUsdTieredSto extends Procedure<LaunchUsdTieredStoProcedureArg
}
);

const newSto = await this.addTransaction<AddUSDTieredSTOParams, UsdTieredSto>(
const newSto = await this.addTransaction<AddUSDTieredSTOParams, TieredSto>(
securityToken.addModuleWithLabel,
{
tag: PolyTransactionTag.EnableUsdTieredSto,
tag: PolyTransactionTag.EnableTieredSto,
fees: {
usd: usdCost,
poly: polyCost,
Expand All @@ -138,18 +138,18 @@ export class LaunchUsdTieredSto extends Procedure<LaunchUsdTieredStoProcedureArg

const { _module } = eventArgs;

return usdTieredStoFactory.fetch(
UsdTieredSto.generateId({
return tieredStoFactory.fetch(
TieredSto.generateId({
securityTokenId: SecurityToken.generateId({ symbol }),
stoType: StoType.UsdTiered,
stoType: StoType.Tiered,
address: _module,
})
);
}
throw new PolymathError({
code: ErrorCode.UnexpectedEventLogs,
message:
"The USD Tiered STO was successfully launched but the corresponding event wasn't fired. Please report this issue to the Polymath team.",
"The Tiered STO was successfully launched but the corresponding event wasn't fired. Please report this issue to the Polymath team.",
});
},
}
Expand All @@ -168,7 +168,7 @@ export class LaunchUsdTieredSto extends Procedure<LaunchUsdTieredStoProcedureArg
fundRaiseTypes: currencies,
wallet: storageWallet,
treasuryWallet,
usdTokens: usdTokenAddresses,
usdTokens: stableCoinAddresses,
},
archived: false,
});
Expand Down
12 changes: 6 additions & 6 deletions src/procedures/PauseSto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '../types';
import { PolymathError } from '../PolymathError';
import { isValidAddress } from '../utils';
import { SecurityToken, CappedSto, UsdTieredSto } from '../entities';
import { SecurityToken, CappedSto, TieredSto } from '../entities';

export class PauseSto extends Procedure<PauseStoProcedureArgs> {
public type = ProcedureType.PauseSto;
Expand Down Expand Up @@ -39,7 +39,7 @@ export class PauseSto extends Procedure<PauseStoProcedureArgs> {
});
break;
}
case StoType.UsdTiered: {
case StoType.Tiered: {
stoModule = await contractWrappers.moduleFactory.getModuleInstance({
name: ModuleName.UsdTieredSTO,
address: stoAddress,
Expand Down Expand Up @@ -80,11 +80,11 @@ export class PauseSto extends Procedure<PauseStoProcedureArgs> {
})
);
}
case StoType.UsdTiered: {
return factories.usdTieredStoFactory.refresh(
UsdTieredSto.generateId({
case StoType.Tiered: {
return factories.tieredStoFactory.refresh(
TieredSto.generateId({
securityTokenId,
stoType: StoType.UsdTiered,
stoType: StoType.Tiered,
address: stoAddress,
})
);
Expand Down
2 changes: 1 addition & 1 deletion src/procedures/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export { ControllerTransfer } from './ControllerTransfer';
export { PauseSto } from './PauseSto';
export { SetController } from './SetController';
export { LaunchCappedSto } from './LaunchCappedSto';
export { LaunchUsdTieredSto } from './LaunchUsdTieredSto';
export { LaunchTieredSto } from './LaunchTieredSto';
export { ModifyShareholderData } from './ModifyShareholderData';
export { RevokeKyc } from './RevokeKyc';
export { MintTokens } from './MintTokens';
Loading

0 comments on commit 06e719f

Please sign in to comment.