1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

added new files

This commit is contained in:
Bogdan Fazakas 2021-11-09 10:58:28 +02:00
parent 9a8be41549
commit fc6074e8af
6 changed files with 116 additions and 0 deletions

View File

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

4
src/interfaces/index.ts Normal file
View File

@ -0,0 +1,4 @@
export * from './FixedRateInterface'
export * from './PoolInterface'
export * from './Erc20Interface'
// export * from './DispenserInterface'

View File

@ -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]
}
}