diff --git a/src/pools/balancer/Pool.ts b/src/pools/balancer/Pool.ts index 692148c0..051509fc 100644 --- a/src/pools/balancer/Pool.ts +++ b/src/pools/balancer/Pool.ts @@ -2,7 +2,7 @@ import Web3 from 'web3' import { AbiItem } from 'web3-utils/types' import { TransactionReceipt } from 'web3-core' import { Contract } from 'web3-eth-contract' -import { Logger, getFairGasPrice } from '../../utils' +import { Logger, getFairGasPrice, LoggerInstance } from '../../utils' import BigNumber from 'bignumber.js' import PoolTemplate from '@oceanprotocol/contracts/artifacts/contracts/pools/balancer/BPool.sol/BPool.json' import defaultPool from '@oceanprotocol/contracts/artifacts/contracts/pools/FactoryRouter.sol/FactoryRouter.json' @@ -58,7 +58,7 @@ export class Pool { .estimateGas({ from: account }, (err, estGas) => (err ? gasLimitDefault : estGas)) } catch (e) { estGas = gasLimitDefault - console.log(e) + LoggerInstance.error('estimage gas failed for approve!', e) } return estGas } @@ -751,44 +751,38 @@ export class Pool { } async amountToUnits(token: string, amount: string): Promise { - let decimals = 18 - const tokenContract = new this.web3.eth.Contract( - defaultERC20ABI.abi as AbiItem[], - token - ) - try { - decimals = await tokenContract.methods.decimals().call() - if (decimals === 0) { + const tokenContract = new this.web3.eth.Contract( + defaultERC20ABI.abi as AbiItem[], + token + ) + let decimals = await tokenContract.methods.decimals().call() + if (decimals == 0) { decimals = 18 } + const amountFormatted = new BigNumber(parseInt(amount) * 10 ** decimals) + return amountFormatted.toString() } catch (e) { this.logger.error('ERROR: FAILED TO CALL DECIMALS(), USING 18') } - - const amountFormatted = new BigNumber(parseInt(amount) * 10 ** decimals) - - return amountFormatted.toString() } async unitsToAmount(token: string, amount: string): Promise { - let decimals = 18 - const tokenContract = new this.web3.eth.Contract( - defaultERC20ABI.abi as AbiItem[], - token - ) try { - decimals = await tokenContract.methods.decimals().call() - if (decimals === 0) { + const tokenContract = new this.web3.eth.Contract( + defaultERC20ABI.abi as AbiItem[], + token + ) + let decimals = await tokenContract.methods.decimals().call() + if (decimals == 0) { decimals = 18 } + const amountFormatted = new BigNumber(parseInt(amount) / 10 ** decimals) + + return amountFormatted.toString() } catch (e) { this.logger.error('ERROR: FAILED TO CALL DECIMALS(), USING 18') } - - const amountFormatted = new BigNumber(parseInt(amount) / 10 ** decimals) - - return amountFormatted.toString() } /** @@ -1534,6 +1528,7 @@ export class Pool { tokenAmountIn: string ): Promise { const pool = new this.web3.eth.Contract(this.poolABI, poolAddress) + console.log('pool ', pool.methods) let amount = null try { const result = await pool.methods @@ -1553,7 +1548,6 @@ export class Pool { ): Promise { const pool = new this.web3.eth.Contract(this.poolABI, poolAddress) let amount = null - const amountFormatted = await this.amountToUnits(poolAddress, poolAmountOut) try { @@ -1561,7 +1555,6 @@ export class Pool { .calcSingleInPoolOut(tokenIn, amountFormatted) .call() - amount = await this.unitsToAmount(tokenIn, result) } catch (e) { this.logger.error(`ERROR: Failed to calculate SingleInGivenPoolOut : ${e.message}`) diff --git a/src/pools/fixedRate/FixedRateExchange.ts b/src/pools/fixedRate/FixedRateExchange.ts index c718c97f..b451f182 100644 --- a/src/pools/fixedRate/FixedRateExchange.ts +++ b/src/pools/fixedRate/FixedRateExchange.ts @@ -5,7 +5,7 @@ import { TransactionReceipt } from 'web3-core' import { Contract, EventData } from 'web3-eth-contract' import { AbiItem } from 'web3-utils/types' import Web3 from 'web3' -import { Logger, getFairGasPrice } from '../../utils' +import { LoggerInstance, getFairGasPrice } from '../../utils' const MAX_AWAIT_PROMISES = 10 @@ -55,7 +55,6 @@ export class FixedRateExchange { public fixedRateContract: Contract public web3: Web3 public contract: Contract = null - private logger: Logger public startBlock: number public ssABI: AbiItem | AbiItem[] @@ -67,7 +66,6 @@ export class FixedRateExchange { */ constructor( web3: Web3, - logger: Logger, fixedRateAddress: string, fixedRateExchangeABI: AbiItem | AbiItem[] = null, oceanAddress: string = null, @@ -85,8 +83,6 @@ export class FixedRateExchange { this.fixedRateExchangeABI, this.fixedRateAddress ) - - this.logger = logger } async amountToUnits(token: string, amount: string): Promise { @@ -99,7 +95,7 @@ export class FixedRateExchange { try { decimals = await tokenContract.methods.decimals().call() } catch (e) { - this.logger.error('ERROR: FAILED TO CALL DECIMALS(), USING 18') + LoggerInstance.error('ERROR: FAILED TO CALL DECIMALS(), USING 18') } const amountFormatted = new BigNumber(parseInt(amount) * 10 ** decimals) @@ -116,7 +112,7 @@ export class FixedRateExchange { try { decimals = await tokenContract.methods.decimals().call() } catch (e) { - this.logger.error('ERROR: FAILED TO CALL DECIMALS(), USING 18') + LoggerInstance.error('ERROR: FAILED TO CALL DECIMALS(), USING 18') } const amountFormatted = new BigNumber(parseInt(amount) / 10 ** decimals) @@ -212,7 +208,7 @@ export class FixedRateExchange { }) return trxReceipt } catch (e) { - this.logger.error(`ERROR: Failed to buy datatokens: ${e.message}`) + LoggerInstance.error(`ERROR: Failed to buy datatokens: ${e.message}`) return null } } @@ -287,7 +283,7 @@ export class FixedRateExchange { }) return trxReceipt } catch (e) { - this.logger.error(`ERROR: Failed to sell datatokens: ${e.message}`) + LoggerInstance.error(`ERROR: Failed to sell datatokens: ${e.message}`) return null } } @@ -981,7 +977,7 @@ export class FixedRateExchange { try { result = await this.contract.methods.opfCollector().call() } catch (e) { - this.logger.error(`ERROR: Failed to get OPF Collector address: ${e.message}`) + LoggerInstance.error(`ERROR: Failed to get OPF Collector address: ${e.message}`) } return result } @@ -995,7 +991,7 @@ export class FixedRateExchange { try { result = await this.contract.methods.router().call() } catch (e) { - this.logger.error(`ERROR: Failed to get Router address: ${e.message}`) + LoggerInstance.error(`ERROR: Failed to get Router address: ${e.message}`) } return result } @@ -1010,7 +1006,7 @@ export class FixedRateExchange { try { result = await (await this.getExchange(exchangeId)).exchangeOwner } catch (e) { - this.logger.error(`ERROR: Failed to get OPF Collector address: ${e.message}`) + LoggerInstance.error(`ERROR: Failed to get OPF Collector address: ${e.message}`) } return result } diff --git a/src/pools/ssContracts/SideStaking.ts b/src/pools/ssContracts/SideStaking.ts index b1f5bdff..7b9db81d 100644 --- a/src/pools/ssContracts/SideStaking.ts +++ b/src/pools/ssContracts/SideStaking.ts @@ -2,12 +2,11 @@ import Web3 from 'web3' import { AbiItem } from 'web3-utils/types' import { TransactionReceipt } from 'web3-core' import { Contract } from 'web3-eth-contract' -import { Logger, getFairGasPrice } from '../../utils' +import { LoggerInstance, getFairGasPrice } from '../../utils' import BigNumber from 'bignumber.js' import SideStakingTemplate from '@oceanprotocol/contracts/artifacts/contracts/pools/ssContracts/SideStaking.sol/SideStaking.json' import defaultPool from '@oceanprotocol/contracts/artifacts/contracts/pools/FactoryRouter.sol/FactoryRouter.json' import defaultERC20ABI from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json' -import Decimal from 'decimal.js' const MaxUint256 = '115792089237316195423570985008687907853269984665640564039457584007913129639934' @@ -19,13 +18,11 @@ export class SideStaking { public ssABI: AbiItem | AbiItem[] public web3: Web3 public GASLIMIT_DEFAULT = 1000000 - private logger: Logger - constructor(web3: Web3, logger: Logger, ssABI: AbiItem | AbiItem[] = null) { + constructor(web3: Web3, ssABI: AbiItem | AbiItem[] = null) { if (ssABI) this.ssABI = ssABI else this.ssABI = SideStakingTemplate.abi as AbiItem[] this.web3 = web3 - this.logger = logger } async amountToUnits(token: string, amount: string): Promise { @@ -37,7 +34,7 @@ export class SideStaking { try { decimals = await tokenContract.methods.decimals().call() } catch (e) { - this.logger.error('ERROR: FAILED TO CALL DECIMALS(), USING 18') + LoggerInstance.error('ERROR: FAILED TO CALL DECIMALS(), USING 18') } const amountFormatted = new BigNumber(parseInt(amount) * 10 ** decimals) @@ -54,7 +51,7 @@ export class SideStaking { try { decimals = await tokenContract.methods.decimals().call() } catch (e) { - this.logger.error('ERROR: FAILED TO CALL DECIMALS(), USING 18') + LoggerInstance.error('ERROR: FAILED TO CALL DECIMALS(), USING 18') } const amountFormatted = new BigNumber(parseInt(amount) / 10 ** decimals) @@ -79,7 +76,7 @@ export class SideStaking { .getDataTokenCirculatingSupply(datatokenAddress) .call() } catch (e) { - this.logger.error(`ERROR: Failed to get: ${e.message}`) + LoggerInstance.error(`ERROR: Failed to get: ${e.message}`) } return result.toString() } @@ -102,7 +99,7 @@ export class SideStaking { .getDataTokenCurrentCirculatingSupply(datatokenAddress) .call() } catch (e) { - this.logger.error(`ERROR: Failed to get: ${e.message}`) + LoggerInstance.error(`ERROR: Failed to get: ${e.message}`) } return result.toString() } @@ -122,7 +119,7 @@ export class SideStaking { try { result = await sideStaking.methods.getPublisherAddress(datatokenAddress).call() } catch (e) { - this.logger.error(`ERROR: Failed to get: ${e.message}`) + LoggerInstance.error(`ERROR: Failed to get: ${e.message}`) } return result } @@ -139,7 +136,7 @@ export class SideStaking { try { result = await sideStaking.methods.getBaseTokenAddress(datatokenAddress).call() } catch (e) { - this.logger.error(`ERROR: Failed to get: ${e.message}`) + LoggerInstance.error(`ERROR: Failed to get: ${e.message}`) } return result } @@ -156,7 +153,7 @@ export class SideStaking { try { result = await sideStaking.methods.getPoolAddress(datatokenAddress).call() } catch (e) { - this.logger.error(`ERROR: Failed to get: ${e.message}`) + LoggerInstance.error(`ERROR: Failed to get: ${e.message}`) } return result } @@ -176,7 +173,7 @@ export class SideStaking { try { result = await sideStaking.methods.getBaseTokenBalance(datatokenAddress).call() } catch (e) { - this.logger.error(`ERROR: Failed to get: ${e.message}`) + LoggerInstance.error(`ERROR: Failed to get: ${e.message}`) } return result } @@ -196,7 +193,7 @@ export class SideStaking { try { result = await sideStaking.methods.getDataTokenBalance(datatokenAddress).call() } catch (e) { - this.logger.error(`ERROR: Failed to get: ${e.message}`) + LoggerInstance.error(`ERROR: Failed to get: ${e.message}`) } result = await this.unitsToAmount(datatokenAddress, result) return result @@ -214,7 +211,7 @@ export class SideStaking { try { result = await sideStaking.methods.getvestingEndBlock(datatokenAddress).call() } catch (e) { - this.logger.error(`ERROR: Failed to get: ${e.message}`) + LoggerInstance.error(`ERROR: Failed to get: ${e.message}`) } return result } @@ -231,7 +228,7 @@ export class SideStaking { try { result = await sideStaking.methods.getvestingAmount(datatokenAddress).call() } catch (e) { - this.logger.error(`ERROR: Failed to get: ${e.message}`) + LoggerInstance.error(`ERROR: Failed to get: ${e.message}`) } result = await this.unitsToAmount(datatokenAddress, result) return result @@ -252,7 +249,7 @@ export class SideStaking { try { result = await sideStaking.methods.getvestingLastBlock(datatokenAddress).call() } catch (e) { - this.logger.error(`ERROR: Failed to get: ${e.message}`) + LoggerInstance.error(`ERROR: Failed to get: ${e.message}`) } return result } @@ -272,7 +269,7 @@ export class SideStaking { try { result = await sideStaking.methods.getvestingAmountSoFar(datatokenAddress).call() } catch (e) { - this.logger.error(`ERROR: Failed to get: ${e.message}`) + LoggerInstance.error(`ERROR: Failed to get: ${e.message}`) } result = await this.unitsToAmount(datatokenAddress, result) return result @@ -335,7 +332,7 @@ export class SideStaking { gasPrice: await getFairGasPrice(this.web3) }) } catch (e) { - this.logger.error('ERROR: Failed to join swap pool amount out') + LoggerInstance.error('ERROR: Failed to join swap pool amount out') } return result } @@ -351,7 +348,7 @@ export class SideStaking { try { result = await sideStaking.methods.router().call() } catch (e) { - this.logger.error(`ERROR: Failed to get Router address: ${e.message}`) + LoggerInstance.error(`ERROR: Failed to get Router address: ${e.message}`) } return result } diff --git a/test/unit/pools/fixedRate/FixedRateExchange.test.ts b/test/unit/pools/fixedRate/FixedRateExchange.test.ts index e1a9955e..83c061c4 100644 --- a/test/unit/pools/fixedRate/FixedRateExchange.test.ts +++ b/test/unit/pools/fixedRate/FixedRateExchange.test.ts @@ -16,10 +16,11 @@ import MockERC20 from '@oceanprotocol/contracts/artifacts/contracts/utils/mock/M import PoolTemplate from '@oceanprotocol/contracts/artifacts/contracts/pools/balancer/BPool.sol/BPool.json' import OPFCollector from '@oceanprotocol/contracts/artifacts/contracts/communityFee/OPFCommunityFeeCollector.sol/OPFCommunityFeeCollector.json' import { LoggerInstance } from '../../../../src/utils' -import { NFTFactory } from '../../../../src/factories/NFTFactory' +import { NFTFactory, NFTCreateData } from '../../../../src/factories/NFTFactory' import { Pool } from '../../../../src/pools/balancer/Pool' import { FixedRateExchange } from '../../../../src/pools/fixedRate/FixedRateExchange' import { BADFAMILY } from 'dns' +import { FreCreationParams, Erc20CreateParams } from '../../../../src/interfaces' const { keccak256 } = require('@ethersproject/keccak256') const web3 = new Web3('http://127.0.0.1:8545') const communityCollector = '0xeE9300b7961e0a01d9f0adb863C7A227A07AaD75' @@ -103,34 +104,46 @@ describe('Fixed Rate unit test', () => { it('#create an exchange', async () => { // CREATE AN Exchange // we prepare transaction parameters objects - const nftData = { + + const nftFactory = new NFTFactory(contracts.factory721Address, web3) + + const nftData: NFTCreateData = { name: '72120Bundle', symbol: '72Bundle', templateIndex: 1, baseURI: 'https://oceanprotocol.com/nft/' } - const ercData = { + + const ercParams: Erc20CreateParams = { templateIndex: 1, - strings: ['ERC20B1', 'ERC20DT1Symbol'], - addresses: [contracts.accounts[0], user3, contracts.accounts[0], ADDRESS_ZERO], - uints: [web3.utils.toWei('1000000'), 0], - bytess: [] + minter: contracts.accounts[0], + feeManager: user3, + mpFeeAddress: contracts.accounts[0], + feeToken: ADDRESS_ZERO, + cap: '1000000', + feeAmount: '0', + name: 'ERC20B1', + symbol: 'ERC20DT1Symbol' } - // [baseToken,owner,marketFeeCollector,allowedSwapper] - const fixedRateData = { - fixedPriceAddress: contracts.fixedRateAddress, - addresses: [contracts.daiAddress, exchangeOwner, user3, ADDRESS_ZERO], - uints: [18, 18, web3.utils.toWei('1'), 1e15, 0] + const freParams: FreCreationParams = { + fixedRateAddress: contracts.fixedRateAddress, + baseTokenAddress: contracts.daiAddress, + owner: exchangeOwner, + marketFeeCollector: user3, + baseTokenDecimals: 18, + dataTokenDecimals: 18, + fixedRate: '1', + marketFee: 1e15, + allowedConsumer: ADDRESS_ZERO, + withMint: false } - const nftFactory = new NFTFactory(contracts.factory721Address, web3, LoggerInstance) - const txReceipt = await nftFactory.createNftErcWithFixedRate( exchangeOwner, nftData, - ercData, - fixedRateData + ercParams, + freParams ) initialBlock = await web3.eth.getBlockNumber() @@ -144,7 +157,6 @@ describe('Fixed Rate unit test', () => { fixedRateAddress = contracts.fixedRateAddress fixedRate = new FixedRateExchange( web3, - LoggerInstance, fixedRateAddress, FixedRate.abi as AbiItem[], contracts.oceanAddress @@ -420,34 +432,46 @@ describe('Fixed Rate unit test', () => { it('#create an exchange', async () => { // CREATE AN Exchange // we prepare transaction parameters objects - const nftData = { + + const nftFactory = new NFTFactory(contracts.factory721Address, web3) + + const nftData: NFTCreateData = { name: '72120Bundle', symbol: '72Bundle', templateIndex: 1, baseURI: 'https://oceanprotocol.com/nft/' } - const ercData = { + + const ercParams: Erc20CreateParams = { templateIndex: 1, - strings: ['ERC20B1', 'ERC20DT1Symbol'], - addresses: [contracts.accounts[0], user3, contracts.accounts[0], ADDRESS_ZERO], - uints: [web3.utils.toWei('1000000'), 0], - bytess: [] + minter: contracts.accounts[0], + feeManager: user3, + mpFeeAddress: contracts.accounts[0], + feeToken: ADDRESS_ZERO, + cap: '1000000', + feeAmount: '0', + name: 'ERC20B1', + symbol: 'ERC20DT1Symbol' } - // [baseToken,owner,marketFeeCollector,allowedSwapper] - const fixedRateData = { - fixedPriceAddress: contracts.fixedRateAddress, - addresses: [contracts.usdcAddress, exchangeOwner, user3, ADDRESS_ZERO], - uints: [6, 18, web3.utils.toWei('1'), 1e15, 0] + const freParams: FreCreationParams = { + fixedRateAddress: contracts.fixedRateAddress, + baseTokenAddress: contracts.usdcAddress, + owner: exchangeOwner, + marketFeeCollector: user3, + baseTokenDecimals: 6, + dataTokenDecimals: 18, + fixedRate: '1', + marketFee: 1e15, + allowedConsumer: ADDRESS_ZERO, + withMint: false } - const nftFactory = new NFTFactory(contracts.factory721Address, web3, LoggerInstance) - const txReceipt = await nftFactory.createNftErcWithFixedRate( exchangeOwner, nftData, - ercData, - fixedRateData + ercParams, + freParams ) initialBlock = await web3.eth.getBlockNumber() @@ -461,7 +485,6 @@ describe('Fixed Rate unit test', () => { fixedRateAddress = contracts.fixedRateAddress fixedRate = new FixedRateExchange( web3, - LoggerInstance, fixedRateAddress, FixedRate.abi as AbiItem[], contracts.oceanAddress diff --git a/test/unit/pools/ssContracts/SideStaking.test.ts b/test/unit/pools/ssContracts/SideStaking.test.ts index 09a46407..46c6803f 100644 --- a/test/unit/pools/ssContracts/SideStaking.test.ts +++ b/test/unit/pools/ssContracts/SideStaking.test.ts @@ -16,9 +16,10 @@ import MockERC20 from '@oceanprotocol/contracts/artifacts/contracts/utils/mock/M import PoolTemplate from '@oceanprotocol/contracts/artifacts/contracts/pools/balancer/BPool.sol/BPool.json' import OPFCollector from '@oceanprotocol/contracts/artifacts/contracts/communityFee/OPFCommunityFeeCollector.sol/OPFCommunityFeeCollector.json' import { LoggerInstance } from '../../../../src/utils' -import { NFTFactory } from '../../../../src/factories/NFTFactory' +import { NFTFactory, NFTCreateData } from '../../../../src/factories/NFTFactory' import { Pool } from '../../../../src/pools/balancer/Pool' import { SideStaking } from '../../../../src/pools/ssContracts/SideStaking' +import { Erc20CreateParams, PoolCreationParams } from '../../../../src/interfaces' const { keccak256 } = require('@ethersproject/keccak256') const web3 = new Web3('http://127.0.0.1:8545') const communityCollector = '0xeE9300b7961e0a01d9f0adb863C7A227A07AaD75' @@ -79,7 +80,7 @@ describe('SideStaking unit test', () => { pool = new Pool(web3, LoggerInstance, PoolTemplate.abi as AbiItem[]) assert(pool != null) // - sideStaking = new SideStaking(web3, LoggerInstance, SSContract.abi as AbiItem[]) + sideStaking = new SideStaking(web3, SSContract.abi as AbiItem[]) assert(sideStaking != null) daiContract = new web3.eth.Contract( @@ -134,57 +135,50 @@ describe('SideStaking unit test', () => { it('#create a pool', async () => { // CREATE A POOL // we prepare transaction parameters objects - const nftData = { + const nftFactory = new NFTFactory(contracts.factory721Address, web3) + + const nftData: NFTCreateData = { name: '72120Bundle', symbol: '72Bundle', templateIndex: 1, baseURI: 'https://oceanprotocol.com/nft/' } - const ercData = { + + const ercParams: Erc20CreateParams = { templateIndex: 1, - strings: ['ERC20B1', 'ERC20DT1Symbol'], - addresses: [ - contracts.accounts[0], - user3, - contracts.accounts[0], - '0x0000000000000000000000000000000000000000' - ], - uints: [web3.utils.toWei('1000000'), 0], - bytess: [] + minter: contracts.accounts[0], + feeManager: user3, + mpFeeAddress: contracts.accounts[0], + feeToken: '0x0000000000000000000000000000000000000000', + cap: '1000000', + feeAmount: '0', + name: 'ERC20B1', + symbol: 'ERC20DT1Symbol' } - const basetokenInitialLiq = await pool.amountToUnits(contracts.daiAddress, '2000') - - const poolData = { - addresses: [ - contracts.sideStakingAddress, - contracts.daiAddress, - contracts.factory721Address, - contracts.accounts[0], - contracts.accounts[0], - contracts.poolTemplateAddress - ], - ssParams: [ - web3.utils.toWei('1'), // rate - 18, // basetokenDecimals - web3.utils.toWei('10000'), - vestedBlocks, // vested blocks - web3.utils.toWei('2000') // baseToken initial pool liquidity - ], - swapFees: [ - 1e15, // - 1e15 - ] + const poolParams: PoolCreationParams = { + ssContract: contracts.sideStakingAddress, + basetokenAddress: contracts.daiAddress, + basetokenSender: contracts.factory721Address, + publisherAddress: contracts.accounts[0], + marketFeeCollector: contracts.accounts[0], + poolTemplateAddress: contracts.poolTemplateAddress, + rate: '1', + basetokenDecimals: 18, + vestingAmount: '10000', + vestedBlocks: vestedBlocks, + initialBasetokenLiquidity: '2000', + swapFeeLiquidityProvider: 1e15, + swapFeeMarketPlaceRunner: 1e15 } - const nftFactory = new NFTFactory(contracts.factory721Address, web3, LoggerInstance) - const txReceipt = await nftFactory.createNftErcWithPool( contracts.accounts[0], nftData, - ercData, - poolData + ercParams, + poolParams ) + initialBlock = await web3.eth.getBlockNumber() erc20Token = txReceipt.events.TokenCreated.returnValues.newTokenAddress poolAddress = txReceipt.events.NewPool.returnValues.poolAddress @@ -420,58 +414,52 @@ describe('SideStaking unit test', () => { it('#create a pool', async () => { // CREATE A POOL // we prepare transaction parameters objects - const nftData = { + const nftFactory = new NFTFactory(contracts.factory721Address, web3) + + const nftData: NFTCreateData = { name: '72120Bundle', symbol: '72Bundle', templateIndex: 1, baseURI: 'https://oceanprotocol.com/nft/' } - const ercData = { + + const ercParams: Erc20CreateParams = { templateIndex: 1, - strings: ['ERC20B1', 'ERC20DT1Symbol'], - addresses: [ - contracts.accounts[0], - user3, - contracts.accounts[0], - '0x0000000000000000000000000000000000000000' - ], - uints: [web3.utils.toWei('1000000'), 0], - bytess: [] - } - const basetokenInitialLiq = Number( - await pool.amountToUnits(contracts.usdcAddress, '2000') - ) - - const poolData = { - addresses: [ - contracts.sideStakingAddress, - contracts.usdcAddress, - contracts.factory721Address, - contracts.accounts[0], - contracts.accounts[0], - contracts.poolTemplateAddress - ], - ssParams: [ - web3.utils.toWei('1'), // rate - await usdcContract.methods.decimals().call(), // basetokenDecimals - web3.utils.toWei('10000'), - 2500000, // vested blocks - basetokenInitialLiq // baseToken initial pool liquidity - ], - swapFees: [ - 1e15, // - 1e15 - ] + minter: contracts.accounts[0], + feeManager: user3, + mpFeeAddress: contracts.accounts[0], + feeToken: '0x0000000000000000000000000000000000000000', + cap: '1000000', + feeAmount: '0', + name: 'ERC20B1', + symbol: 'ERC20DT1Symbol' } - const nftFactory = new NFTFactory(contracts.factory721Address, web3, LoggerInstance) + const poolParams: PoolCreationParams = { + ssContract: contracts.sideStakingAddress, + basetokenAddress: contracts.usdcAddress, + basetokenSender: contracts.factory721Address, + publisherAddress: contracts.accounts[0], + marketFeeCollector: contracts.accounts[0], + poolTemplateAddress: contracts.poolTemplateAddress, + rate: '1', + basetokenDecimals: await usdcContract.methods.decimals().call(), + vestingAmount: '10000', + vestedBlocks: 2500000, + initialBasetokenLiquidity: web3.utils.fromWei( + await pool.amountToUnits(contracts.usdcAddress, '2000') + ), + swapFeeLiquidityProvider: 1e15, + swapFeeMarketPlaceRunner: 1e15 + } const txReceipt = await nftFactory.createNftErcWithPool( contracts.accounts[0], nftData, - ercData, - poolData + ercParams, + poolParams ) + initialBlock = await web3.eth.getBlockNumber() erc20Token = txReceipt.events.TokenCreated.returnValues.newTokenAddress poolAddress = txReceipt.events.NewPool.returnValues.poolAddress