diff --git a/src/interfaces/DispenserInterface.ts b/src/interfaces/DispenserInterface.ts new file mode 100644 index 00000000..e69de29b diff --git a/src/interfaces/Erc20Interface.ts b/src/interfaces/Erc20Interface.ts new file mode 100644 index 00000000..a7a0892d --- /dev/null +++ b/src/interfaces/Erc20Interface.ts @@ -0,0 +1,11 @@ +export interface Erc20CreateParams { + templateIndex: number + minter: string + feeManager: string + mpFeeAddress: string + feeToken: string + feeAmount: string + cap: string + name?: string + symbol?: string +} diff --git a/src/interfaces/FixedRateInterface.ts b/src/interfaces/FixedRateInterface.ts new file mode 100644 index 00000000..7e3c5364 --- /dev/null +++ b/src/interfaces/FixedRateInterface.ts @@ -0,0 +1,18 @@ +export interface FreCreationParams { + fixedRateAddress: string + baseTokenAddress: string + owner: string + marketFeeCollector: string + baseTokenDecimals: number + dataTokenDecimals: number + fixedRate: string + marketFee: number + withMint?: boolean // add FixedPriced contract as minter if withMint == true + allowedConsumer?: string // only account that consume the exhchange +} + +export interface FreOrderParams { + exchangeContract: string + exchangeId: string + maxBaseTokenAmount: string +} diff --git a/src/interfaces/PoolInterface.ts b/src/interfaces/PoolInterface.ts new file mode 100644 index 00000000..22b12fa3 --- /dev/null +++ b/src/interfaces/PoolInterface.ts @@ -0,0 +1,15 @@ +export interface PoolCreationParams { + ssContract: string + basetokenAddress: string + basetokenSender: string + publisherAddress: string + marketFeeCollector: string + poolTemplateAddress: string + rate: string + basetokenDecimals: number + vestingAmount: string + vestedBlocks: number + initialBasetokenLiquidity: string + swapFeeLiquidityProvider: number + swapFeeMarketPlaceRunner: number +} diff --git a/src/interfaces/index.ts b/src/interfaces/index.ts new file mode 100644 index 00000000..74a4e79c --- /dev/null +++ b/src/interfaces/index.ts @@ -0,0 +1,4 @@ +export * from './FixedRateInterface' +export * from './PoolInterface' +export * from './Erc20Interface' +// export * from './DispenserInterface' diff --git a/src/utils/ContractParams.ts b/src/utils/ContractParams.ts new file mode 100644 index 00000000..84688f67 --- /dev/null +++ b/src/utils/ContractParams.ts @@ -0,0 +1,68 @@ +import { Erc20CreateParams, FreCreationParams, PoolCreationParams } from '../interfaces' +import { generateDtName } from '.' +import Web3 from 'web3' + +export function getErcCreationParams(ercParams: Erc20CreateParams, web3: Web3): any { + let name: string, symbol: string + // Generate name & symbol if not present + if (!ercParams.name || !ercParams.symbol) { + ;({ name, symbol } = generateDtName()) + } + + return { + templateIndex: ercParams.templateIndex, + strings: [ercParams.name || name, ercParams.symbol || symbol], + addresses: [ + ercParams.minter, + ercParams.feeManager, + ercParams.mpFeeAddress, + ercParams.feeToken + ], + uints: [web3.utils.toWei(ercParams.cap), web3.utils.toWei(ercParams.feeAmount)], + bytess: [] + } +} + +export function getFreCreationParams(freParams: FreCreationParams, web3: Web3): any { + if (!freParams.allowedConsumer) + freParams.allowedConsumer = '0x0000000000000000000000000000000000000000' + const withMint = freParams.withMint ? 1 : 0 + + return { + fixedPriceAddress: freParams.fixedRateAddress, + addresses: [ + freParams.baseTokenAddress, + freParams.owner, + freParams.marketFeeCollector, + freParams.allowedConsumer + ], + uints: [ + freParams.baseTokenDecimals, + freParams.dataTokenDecimals, + freParams.fixedRate, + freParams.marketFee, + withMint + ] + } +} + +export function getPoolCreationParams(poolParams: PoolCreationParams, web3: Web3): any { + return { + addresses: [ + poolParams.ssContract, + poolParams.basetokenAddress, + poolParams.basetokenSender, + poolParams.publisherAddress, + poolParams.marketFeeCollector, + poolParams.poolTemplateAddress + ], + ssParams: [ + web3.utils.toWei(poolParams.rate), + poolParams.basetokenDecimals, + web3.utils.toWei(poolParams.vestingAmount), + poolParams.vestedBlocks, + web3.utils.toWei(poolParams.initialBasetokenLiquidity) + ], + swapFees: [poolParams.swapFeeLiquidityProvider, poolParams.swapFeeMarketPlaceRunner] + } +}