Skip to content

Commit

Permalink
fix: documentation issues from review
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Wiebe committed Jan 8, 2020
1 parent 275ebf5 commit 46748e0
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 47 deletions.
18 changes: 11 additions & 7 deletions src/entities/SimpleSto.ts
Expand Up @@ -15,7 +15,7 @@ import { Investment } from './Investment';
const { weiToValue } = conversionUtils;

/**
* Represents a simple sto
* Properties that uniquely identify a simple sto
*/
export interface Params extends StoParams {
/**
Expand All @@ -28,9 +28,6 @@ export interface Params extends StoParams {
rate: BigNumber;
}

/**
* Represents a unique sto
*/
export { UniqueIdentifiers };

/**
Expand All @@ -45,16 +42,23 @@ export class SimpleSto extends Sto<Params> {
});
}

/**
* Unique generated Tiered STO id
*/
public uid: string;

/**
* Cap of total tokens that can be sold in sto
*/
public cap: BigNumber;

/**
* Rate at which the tokens will be sold in sto
*/
public rate: BigNumber;

/**
* Create a new simple sto instance
* @param params parameters for an sto and unique identifiers
* @param context the sdk is being used in
*/
constructor(params: Params & UniqueIdentifiers, context: Context) {
const { cap, rate, ...rest } = params;
Expand Down Expand Up @@ -139,7 +143,7 @@ export class SimpleSto extends Sto<Params> {
}

/**
* Hydrating the entity
* Hydrate the entity
*/
public _refresh(params: Partial<Params>) {
const { cap, rate, ...rest } = params;
Expand Down
54 changes: 46 additions & 8 deletions src/entities/Sto.ts
Expand Up @@ -13,7 +13,7 @@ import {
} from '../procedures';

/**
* Represents a unique sto
* Properties that uniquely identify an STO
*/
export interface UniqueIdentifiers {
securityTokenId: string;
Expand All @@ -23,8 +23,6 @@ export interface UniqueIdentifiers {

/**
* Check if the provided value is of type [[UniqueIdentifiers]]
*
* @param identifiers - internal security token representation
*/
function isUniqueIdentifiers(identifiers: any): identifiers is UniqueIdentifiers {
const { securityTokenId, stoType, address } = identifiers;
Expand All @@ -33,7 +31,7 @@ function isUniqueIdentifiers(identifiers: any): identifiers is UniqueIdentifiers
}

/**
* Represents an sto
* STO constructor parameters
*/
export interface Params {
/**
Expand Down Expand Up @@ -61,7 +59,7 @@ export interface Params {
*/
unsoldTokensWallet: string;
/**
* amount of tokens to be raised
* funds that have been raised to this date
*/
raisedAmount: BigNumber;
/**
Expand Down Expand Up @@ -98,40 +96,82 @@ export interface Params {
* Abstract class used as a base to manage sto functionalities
*/
export abstract class Sto<P> extends Entity<P> {
/**
* Uniquely generated id for the STO
*/
public abstract uid: string;

/**
* Ethereum address for the STO
*/
public address: string;

public securityTokenSymbol: string;

public securityTokenId: string;

/**
* Type of STO setup
*/
public stoType: StoType;

public startDate: Date;

public endDate: Date;

/**
* Wallet where funds raised will be forwarded to
*/
public raisedFundsWallet: string;

/**
* Wallet where unsold tokens will be returned to
*/
public unsoldTokensWallet: string;

/**
* Amount of funds that have been raised so far
*/
public raisedAmount: BigNumber;

/**
* Total number of tokens that have been sold so far
*/
public soldTokensAmount: BigNumber;

/**
* Number of investors that have purchased tokens in the STO
*/
public investorCount: number;

/**
* Valid currencies that funds can be raised in
*/
public fundraiseCurrencies: Currency[];

/**
* Whether the STO is currently paused or not
*/
public isPaused: boolean;

/**
* Whether the STO cap has been reached or not
*/
public capReached: boolean;

/**
* Whether the STO has been finalized or not
*/
public isFinalized: boolean;

/**
* Whether the preissuing of tokens is allowed or not
*/
public preIssueAllowed: boolean;

/**
* Whether investments can be made on behalf of a beneficiary or not
*/
public beneficialInvestmentsAllowed: boolean;

protected context: Context;
Expand All @@ -156,8 +196,6 @@ export abstract class Sto<P> extends Entity<P> {

/**
* Create a new sto instance
* @param params parameters for an sto and unique identifiers
* @param context the sdk is being used in
*/
constructor(params: Params & UniqueIdentifiers, context: Context) {
super();
Expand Down Expand Up @@ -395,7 +433,7 @@ export abstract class Sto<P> extends Entity<P> {
}

/**
* Hydrating the entity
* Hydrate the entity
*/
public _refresh(params: Partial<Params>) {
const {
Expand Down
47 changes: 22 additions & 25 deletions src/entities/TieredSto.ts
Expand Up @@ -18,13 +18,10 @@ import { Investment } from './Investment';

const { weiToValue } = conversionUtils;

/**
* Represents a unique sto
*/
export { UniqueIdentifiers };

/**
* Represents a tier in the tiered sto
* Unique properties of a tier in the tiered sto
*/
export interface Tier {
/**
Expand All @@ -40,25 +37,25 @@ export interface Tier {
*/
price: BigNumber;
/**
* total number of tokens that are available to be sold with a discount within the tier
* total number of tokens that are available to be sold at a discount when paid in POLY
*/
tokensWithDiscount: BigNumber;
/**
* total number of tokens that have been sold with a discount within the tier
* total number of tokens that have been sold at a discount
*/
tokensSoldAtDiscount: BigNumber;
/**
* discounted price at which tokens will be sold within the tier
* discounted price at which tokens will be sold
*/
discountedPrice: BigNumber;
}

/**
* Represents a tiered sto
* Represents a Tiered STO
*/
export interface Params extends StoParams {
/**
* numerical identifier for the current tier
* numerical identifier for the current tier index
*/
currentTier: number;
/**
Expand All @@ -68,9 +65,9 @@ export interface Params extends StoParams {
}

/**
* Represents a tiered sto's base parameters
* @hidden
*/
interface BaseParams {
interface BaseInvestParams {
/**
* minimum amount of tokens that will be sold in the sto
*/
Expand All @@ -90,9 +87,9 @@ interface BaseParams {
}

/**
* Represents a tiered sto raising in stable coin with a stable coin address
* @hidden
*/
interface InvestInStableCoinParams extends BaseParams {
interface InvestInStableCoinParams extends BaseInvestParams {
/**
* currency to raise in stable coin
*/
Expand All @@ -104,9 +101,9 @@ interface InvestInStableCoinParams extends BaseParams {
}

/**
* Represents a tiered sto where funds are raised in other fund raise types
* @hidden
*/
interface InvestInOtherParams extends BaseParams {
interface InvestInOtherParams extends BaseInvestParams {
currency: Currency.ETH | Currency.POLY;
stableCoinAddress?: undefined;
}
Expand All @@ -123,16 +120,23 @@ export class TieredSto extends Sto<Params> {
});
}

/**
* Unique generated Tiered STO id
*/
public uid: string;

/**
* Index of the current active tier
*/
public currentTier: number;

/**
* Array of tier information
*/
public tiers: Tier[];

/**
* Create a new tiered sto instance
* @param params parameters for an sto and unique identifiers
* @param context the sdk is being used in
*/
constructor(params: Params & UniqueIdentifiers, context: Context) {
const { currentTier, tiers, ...rest } = params;
Expand Down Expand Up @@ -237,20 +241,13 @@ export class TieredSto extends Sto<Params> {
* @param args.startDate - date when the STO should start
* @param args.endDate - date when the STO should end
* @param args.tiers - tier information
* @param args.tiers[].tokensOnSale - amount of tokens to be sold on that tier
* @param args.tiers[].price - price of each token on that tier
* @param args.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 args.tiers[].discountedPrice - price of discounted tokens on that tier (defaults to 0)
* @param args.nonAccreditedInvestmentLimit - maximum investment for non-accredited investors
* @param args.minimumInvestment - minimum investment amount
* @param args.fundraiseCurrencies - array of currencies in which the funds will be raised (ETH, POLY, StableCoin)
* @param args.raisedFundsWallet - wallet address that will receive the funds that are being raised
* @param args.unsoldTokensWallet - wallet address that will receive unsold tokens when the end date is reached
* @param args.stableCoinAddresses - addresses of supported stablecoins
* @param args.customCurrency - custom currency data. Allows the STO to raise funds pegged to a different currency. Optional, defaults to USD
* @param args.customCurrency.currencySymbol - symbol of the custom currency (USD, CAD, EUR, etc. Default is USD)
* @param args.customCurrency.ethOracleAddress - address of the oracle that states the price of ETH in the custom currency. Only required if raising funds in ETH
* @param args.customCurrency.polyOracleAddress - address of the oracle that states the price of POLY in the custom currency. Only required if raising funds in POLY
*/
public async modifyData(args: {
startDate?: Date;
Expand Down Expand Up @@ -322,7 +319,7 @@ export class TieredSto extends Sto<Params> {
}

/**
* Hydrating the entity
* Hydrate the entity
*/
public _refresh(params: Partial<Params>) {
const { currentTier, tiers, ...rest } = params;
Expand Down
4 changes: 1 addition & 3 deletions src/entities/factories/SimpleStoFactory.ts
Expand Up @@ -79,9 +79,7 @@ export class SimpleStoFactory extends Factory<SimpleSto, Params, UniqueIdentifie
};

/**
* Creates an instance of the simple sto factory
*
* @param context the context in which sdk will be used
* Create an instance of the simple sto factory
*/
constructor(context: Context) {
super(SimpleSto, context);
Expand Down
4 changes: 1 addition & 3 deletions src/entities/factories/TieredStoFactory.ts
Expand Up @@ -140,9 +140,7 @@ export class TieredStoFactory extends Factory<TieredSto, Params, UniqueIdentifie
};

/**
* Creates an instance of the tiered sto factory
*
* @param context the context in which sdk will be used
* Create an instance of the tiered sto factory
*/
constructor(context: Context) {
super(TieredSto, context);
Expand Down
14 changes: 13 additions & 1 deletion src/types/index.ts
Expand Up @@ -376,9 +376,21 @@ export interface StoTier {
discountedPrice?: BigNumber;
}

/**
* Unique properties of a custom currency
*/
export interface CustomCurrency {
/**
* symbol of the custom currency (USD, CAD, EUR, etc. Default is USD)
*/
currencySymbol: string;
/**
* address of the oracle that states the price of ETH in the custom currency. Only required if raising funds in ETH
*/
ethOracleAddress: string;
/**
* address of the oracle that states the price of POLY in the custom currency. Only required if raising funds in POLY
*/
polyOracleAddress: string;
}

Expand Down Expand Up @@ -612,7 +624,7 @@ export interface ProcedureArguments {
[ProcedureType.PullDividendPayment]: PullDividendPaymentProcedureArgs;
[ProcedureType.SetDividendsWallet]: SetDividendsWalletProcedureArgs;
// prettier-ignore
[ProcedureType.ModifyDividendsDefaultExclusionList]:
[ProcedureType.ModifyDividendsDefaultExclusionList]:
ModifyDividendsDefaultExclusionListProcedureArgs;
[ProcedureType.LaunchSimpleSto]: LaunchSimpleStoProcedureArgs;
[ProcedureType.LaunchTieredSto]: LaunchTieredStoProcedureArgs;
Expand Down

0 comments on commit 46748e0

Please sign in to comment.