diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dcd8ffe2c..cbf1492ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -109,13 +109,13 @@ jobs: - name: Run Barge working-directory: ${{ github.workspace }}/barge run: | - bash -x start_ocean.sh --with-provider2 --no-dashboard 2>&1 > start_ocean.log & + bash -x start_ocean.sh --with-provider2 --no-dashboard --with-c2d 2>&1 > start_ocean.log & cd .. && ./scripts/waitforcontracts.sh - name: integration run: npm run test:integration:cover - name: docker logs - run: docker logs ocean_aquarius_1 + run: docker logs ocean_aquarius_1 && docker logs ocean_provider_1 && docker logs ocean_provider2_1 if: ${{ failure() }} - name: Upload coverage uses: actions/upload-artifact@v2 diff --git a/package-lock.json b/package-lock.json index 664176a92..7981a277d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0-next.11", "license": "Apache-2.0", "dependencies": { - "@oceanprotocol/contracts": "^1.0.0-alpha.17", + "@oceanprotocol/contracts": "^1.0.0-alpha.18", "bignumber.js": "^9.0.2", "cross-fetch": "^3.1.4", "crypto-js": "^4.0.0", @@ -3016,9 +3016,9 @@ } }, "node_modules/@oceanprotocol/contracts": { - "version": "1.0.0-alpha.17", - "resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.17.tgz", - "integrity": "sha512-qbJPFHMJtzmp65emj/eJC0W4iTLICTxeKr+Ud5pXUjdWOtiiBE4Cp0qKDpcjuNDlddh+WWPWfJYQWBMnkJGoEQ==", + "version": "1.0.0-alpha.18", + "resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.18.tgz", + "integrity": "sha512-0MFX5n71dke095drRKXoCvF25FrAuraAcNyuUqps0WsVyM7N+jIdiJsF4u26/TrfYzNV/Y/0zRmi6bR4mTA7KA==", "dependencies": { "@openzeppelin/contracts": "^4.3.3", "@openzeppelin/test-helpers": "^0.5.15", @@ -27489,9 +27489,9 @@ } }, "@oceanprotocol/contracts": { - "version": "1.0.0-alpha.17", - "resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.17.tgz", - "integrity": "sha512-qbJPFHMJtzmp65emj/eJC0W4iTLICTxeKr+Ud5pXUjdWOtiiBE4Cp0qKDpcjuNDlddh+WWPWfJYQWBMnkJGoEQ==", + "version": "1.0.0-alpha.18", + "resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.0.0-alpha.18.tgz", + "integrity": "sha512-0MFX5n71dke095drRKXoCvF25FrAuraAcNyuUqps0WsVyM7N+jIdiJsF4u26/TrfYzNV/Y/0zRmi6bR4mTA7KA==", "requires": { "@openzeppelin/contracts": "^4.3.3", "@openzeppelin/test-helpers": "^0.5.15", diff --git a/package.json b/package.json index 405c49e56..d3859f2eb 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "web3": ">=1.3.5" }, "dependencies": { - "@oceanprotocol/contracts": "^1.0.0-alpha.17", + "@oceanprotocol/contracts": "^1.0.0-alpha.18", "bignumber.js": "^9.0.2", "cross-fetch": "^3.1.4", "crypto-js": "^4.0.0", diff --git a/scripts/waitforcontracts.sh b/scripts/waitforcontracts.sh index 2a01fd6aa..537307feb 100755 --- a/scripts/waitforcontracts.sh +++ b/scripts/waitforcontracts.sh @@ -1,8 +1,8 @@ -while [ ! -f "${HOME}/.ocean/ocean-contracts/artifacts/ready" ]; do +#!/bin/bash +while [ ! -f "$HOME/.ocean/ocean-contracts/artifacts/ready" ] || [ ! -f "$HOME/.ocean/ocean-c2d/ready" ]; do sleep 2 done - -cat "barge/start_ocean.log" +#cat "barge/start_ocean.log" ls -lh "${HOME}/.ocean/ocean-contracts/" ls -lh "${HOME}/.ocean/ocean-contracts/artifacts/" cat "${HOME}/.ocean/ocean-contracts/artifacts/address.json" diff --git a/src/factories/NFTFactory.ts b/src/factories/NFTFactory.ts index d0796efa6..5e743d9ad 100644 --- a/src/factories/NFTFactory.ts +++ b/src/factories/NFTFactory.ts @@ -628,14 +628,14 @@ export class NftFactory { } /** - * Estimate gas cost for createNftWithErc method + * Estimate gas cost for createNftWithErc20 method * @param address Caller address * @param _NftCreateData input data for nft creation * @param _ErcCreateData input data for erc20 creation * @return {Promise} transaction receipt */ - public async estGasCreateNftWithErc( + public async estGasCreateNftWithErc20( address: string, nftCreateData: NftCreateData, ercParams: Erc20CreateParams @@ -646,7 +646,7 @@ export class NftFactory { try { const ercCreateData = getErcCreationParams(ercParams) estGas = await this.factory721.methods - .createNftWithErc(nftCreateData, ercCreateData) + .createNftWithErc20(nftCreateData, ercCreateData) .estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas)) } catch (e) { estGas = gasLimitDefault @@ -655,7 +655,7 @@ export class NftFactory { } /** - * @dev createNftWithErc + * @dev createNftWithErc20 * Creates a new NFT, then a ERC20,all in one call * @param address Caller address * @param _NftCreateData input data for nft creation @@ -663,17 +663,17 @@ export class NftFactory { * @return {Promise} transaction receipt */ - public async createNftWithErc( + public async createNftWithErc20( address: string, nftCreateData: NftCreateData, ercParams: Erc20CreateParams ): Promise { const ercCreateData = getErcCreationParams(ercParams) - const estGas = await this.estGasCreateNftWithErc(address, nftCreateData, ercParams) + const estGas = await this.estGasCreateNftWithErc20(address, nftCreateData, ercParams) // Invoke createToken function of the contract const trxReceipt = await this.factory721.methods - .createNftWithErc(nftCreateData, ercCreateData) + .createNftWithErc20(nftCreateData, ercCreateData) .send({ from: address, gas: estGas + 1, @@ -684,14 +684,14 @@ export class NftFactory { } /** - * Estimate gas cost for createNftErcWithPool method + * Estimate gas cost for createNftErc20WithPool method * @param address Caller address * @param nftCreateData input data for NFT Creation * @param ercParams input data for ERC20 Creation * @param poolParams input data for Pool Creation * @return {Promise} transaction receipt */ - public async estGasCreateNftErcWithPool( + public async estGasCreateNftErc20WithPool( address: string, nftCreateData: NftCreateData, ercParams: Erc20CreateParams, @@ -703,7 +703,7 @@ export class NftFactory { const ercCreateData = getErcCreationParams(ercParams) const poolData = getPoolCreationParams(poolParams) estGas = await this.factory721.methods - .createNftErcWithPool(nftCreateData, ercCreateData, poolData) + .createNftWithErc20WithPool(nftCreateData, ercCreateData, poolData) .estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas)) } catch (e) { estGas = gasLimitDefault @@ -712,7 +712,7 @@ export class NftFactory { } /** - * @dev createNftErcWithPool + * @dev createNftErc20WithPool * Creates a new NFT, then a ERC20, then a Pool, all in one call * Use this carefully, because if Pool creation fails, you are still going to pay a lot of gas * @param address Caller address @@ -721,13 +721,13 @@ export class NftFactory { * @param poolParams input data for Pool Creation * @return {Promise} transaction receipt */ - public async createNftErcWithPool( + public async createNftErc20WithPool( address: string, nftCreateData: NftCreateData, ercParams: Erc20CreateParams, poolParams: PoolCreationParams ): Promise { - const estGas = await this.estGasCreateNftErcWithPool( + const estGas = await this.estGasCreateNftErc20WithPool( address, nftCreateData, ercParams, @@ -738,7 +738,7 @@ export class NftFactory { // Invoke createToken function of the contract const trxReceipt = await this.factory721.methods - .createNftErcWithPool(nftCreateData, ercCreateData, poolData) + .createNftWithErc20WithPool(nftCreateData, ercCreateData, poolData) .send({ from: address, gas: estGas + 1, @@ -748,14 +748,14 @@ export class NftFactory { return trxReceipt } - /** Estimate gas cost for createNftErcWithFixedRate method + /** Estimate gas cost for createNftErc20WithFixedRate method * @param address Caller address * @param nftCreateData input data for NFT Creation * @param ercParams input data for ERC20 Creation * @param freParams input data for FixedRate Creation * @return {Promise} transaction receipt */ - public async estGasCreateNftErcWithFixedRate( + public async estGasCreateNftErc20WithFixedRate( address: string, nftCreateData: NftCreateData, ercParams: Erc20CreateParams, @@ -770,7 +770,7 @@ export class NftFactory { try { estGas = await this.factory721.methods - .createNftErcWithFixedRate(nftCreateData, ercCreateData, fixedData) + .createNftWithErc20WithFixedRate(nftCreateData, ercCreateData, fixedData) .estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas)) } catch (e) { estGas = gasLimitDefault @@ -779,7 +779,7 @@ export class NftFactory { } /** - * @dev createNftErcWithFixedRate + * @dev createNftErc20WithFixedRate * Creates a new NFT, then a ERC20, then a FixedRateExchange, all in one call * Use this carefully, because if Fixed Rate creation fails, you are still going to pay a lot of gas * @param address Caller address @@ -788,7 +788,7 @@ export class NftFactory { * @param freParams input data for FixedRate Creation * @return {Promise} transaction receipt */ - public async createNftErcWithFixedRate( + public async createNftErc20WithFixedRate( address: string, nftCreateData: NftCreateData, ercParams: Erc20CreateParams, @@ -797,7 +797,7 @@ export class NftFactory { const ercCreateData = getErcCreationParams(ercParams) const fixedData = getFreCreationParams(freParams) - const estGas = await this.estGasCreateNftErcWithFixedRate( + const estGas = await this.estGasCreateNftErc20WithFixedRate( address, nftCreateData, ercParams, @@ -806,7 +806,7 @@ export class NftFactory { // Invoke createToken function of the contract const trxReceipt = await this.factory721.methods - .createNftErcWithFixedRate(nftCreateData, ercCreateData, fixedData) + .createNftWithErc20WithFixedRate(nftCreateData, ercCreateData, fixedData) .send({ from: address, gas: estGas + 1, @@ -816,14 +816,14 @@ export class NftFactory { return trxReceipt } - /** Estimate gas cost for createNftErcWithFixedRate method + /** Estimate gas cost for createNftErc20WithFixedRate method * @param address Caller address * @param nftCreateData input data for NFT Creation * @param ercParams input data for ERC20 Creation * @param dispenserParams input data for Dispenser Creation * @return {Promise} transaction receipt */ - public async estGasCreateNftErcWithDispenser( + public async estGasCreateNftErc20WithDispenser( address: string, nftCreateData: NftCreateData, ercParams: Erc20CreateParams, @@ -836,17 +836,17 @@ export class NftFactory { try { estGas = await this.factory721.methods - .createNftErcWithDispenser(nftCreateData, ercCreateData, dispenserParams) + .createNftWithErc20WithDispenser(nftCreateData, ercCreateData, dispenserParams) .estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas)) } catch (e) { estGas = gasLimitDefault - LoggerInstance.error('Failed to estimate gas for createNftErcWithDispenser', e) + LoggerInstance.error('Failed to estimate gas for createNftErc20WithDispenser', e) } return estGas } /** - * @dev createNftErcWithDispenser + * @dev createNftErc20WithDispenser * Creates a new NFT, then a ERC20, then a Dispenser, all in one call * Use this carefully, because if Dispenser creation fails, you are still going to pay a lot of gas * @param address Caller address @@ -855,7 +855,7 @@ export class NftFactory { * @param dispenserParams input data for Dispenser Creation * @return {Promise} transaction receipt */ - public async createNftErcWithDispenser( + public async createNftErc20WithDispenser( address: string, nftCreateData: NftCreateData, ercParams: Erc20CreateParams, @@ -863,7 +863,7 @@ export class NftFactory { ): Promise { const ercCreateData = getErcCreationParams(ercParams) - const estGas = await this.estGasCreateNftErcWithDispenser( + const estGas = await this.estGasCreateNftErc20WithDispenser( address, nftCreateData, ercParams, @@ -872,7 +872,7 @@ export class NftFactory { // Invoke createToken function of the contract const trxReceipt = await this.factory721.methods - .createNftErcWithDispenser(nftCreateData, ercCreateData, dispenserParams) + .createNftWithErc20WithDispenser(nftCreateData, ercCreateData, dispenserParams) .send({ from: address, gas: estGas + 1, diff --git a/src/pools/balancer/Pool.ts b/src/pools/balancer/Pool.ts index 0ab958458..c55ca511e 100644 --- a/src/pools/balancer/Pool.ts +++ b/src/pools/balancer/Pool.ts @@ -1160,7 +1160,6 @@ export class Pool { public async estJoinswapExternAmountIn( address: string, poolAddress: string, - tokenIn: string, tokenAmountIn: string, minPoolAmountOut: string, contractInstance?: Contract @@ -1176,7 +1175,7 @@ export class Pool { let estGas try { estGas = await poolContract.methods - .joinswapExternAmountIn(tokenIn, tokenAmountIn, minPoolAmountOut) + .joinswapExternAmountIn(tokenAmountIn, minPoolAmountOut) .estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas)) } catch (e) { estGas = gasLimitDefault @@ -1185,7 +1184,7 @@ export class Pool { } /** - * Pay tokenAmountIn of token tokenIn to join the pool, getting poolAmountOut of the pool shares. + * Pay tokenAmountIn of baseToken to join the pool, getting poolAmountOut of the pool shares. * @param {String} account * @param {String} poolAddress * @param {String} tokenIn @@ -1196,7 +1195,6 @@ export class Pool { async joinswapExternAmountIn( account: string, poolAddress: string, - tokenIn: string, tokenAmountIn: string, minPoolAmountOut: string ): Promise { @@ -1206,11 +1204,14 @@ export class Pool { ) let result = null - const amountInFormatted = await amountToUnits(this.web3, tokenIn, tokenAmountIn) + const amountInFormatted = await amountToUnits( + this.web3, + await this.getBaseToken(poolAddress), + tokenAmountIn + ) const estGas = await this.estJoinswapExternAmountIn( account, poolAddress, - tokenIn, amountInFormatted, this.web3.utils.toWei(minPoolAmountOut) ) @@ -1218,7 +1219,6 @@ export class Pool { try { result = await pool.methods .joinswapExternAmountIn( - tokenIn, amountInFormatted, this.web3.utils.toWei(minPoolAmountOut) ) @@ -1234,97 +1234,10 @@ export class Pool { return result } - /** - * Estimate gas cost for joinswapPoolAmountOut - * @param {String} address - * @param {String} poolAddress - * @param {String} tokenIn - * @param {String} poolAmountOut will be converted to wei - * @param {String} maxAmountIn will be converted to wei - * @param {Contract} contractInstance optional contract instance - * @return {Promise} - */ - public async estJoinswapPoolAmountOut( - address: string, - poolAddress: string, - tokenIn: string, - poolAmountOut: string, - maxAmountIn: string, - contractInstance?: Contract - ): Promise { - const poolContract = - contractInstance || - setContractDefaults( - new this.web3.eth.Contract(this.poolAbi as AbiItem[], poolAddress), - this.config - ) - - const gasLimitDefault = this.GASLIMIT_DEFAULT - let estGas - try { - estGas = await poolContract.methods - .joinswapPoolAmountOut(tokenIn, poolAmountOut, maxAmountIn) - .estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas)) - } catch (e) { - estGas = gasLimitDefault - } - return estGas - } - - /** - * Specify poolAmountOut pool shares that you want to get, and a token tokenIn to pay with. This costs tokenAmountIn tokens (these went into the pool). - * @param {String} account - * @param {String} poolAddress - * @param {String} tokenIn - * @param {String} poolAmountOut will be converted to wei - * @param {String} maxAmountIn will be converted to wei - * @return {TransactionReceipt} - */ - async joinswapPoolAmountOut( - account: string, - poolAddress: string, - tokenIn: string, - poolAmountOut: string, - maxAmountIn: string - ): Promise { - const pool = setContractDefaults( - new this.web3.eth.Contract(this.poolAbi, poolAddress), - this.config - ) - let result = null - - const maxAmountInFormatted = await amountToUnits(this.web3, tokenIn, maxAmountIn) - const estGas = await this.estJoinswapPoolAmountOut( - account, - poolAddress, - tokenIn, - this.web3.utils.toWei(poolAmountOut), - maxAmountInFormatted - ) - - try { - result = await pool.methods - .joinswapPoolAmountOut( - tokenIn, - this.web3.utils.toWei(poolAmountOut), - maxAmountInFormatted - ) - .send({ - from: account, - gas: estGas + 1, - gasPrice: await getFairGasPrice(this.web3, this.config) - }) - } catch (e) { - LoggerInstance.error(`ERROR: Failed to join swap pool amount out ${e.message}`) - } - return result - } - /** * Estimate gas cost for joinswapExternAmountIn * @param {String} address @param {String} poolAddress - * @param {String} tokenOut * @param {String} poolAmountIn will be converted to wei * @param {String} minTokenAmountOut will be converted to wei * @param {Contract} contractInstance optional contract instance @@ -1333,7 +1246,6 @@ export class Pool { public async estExitswapPoolAmountIn( address: string, poolAddress: string, - tokenOut: string, poolAmountIn: string, minTokenAmountOut: string, contractInstance?: Contract @@ -1349,7 +1261,7 @@ export class Pool { let estGas try { estGas = await poolContract.methods - .exitswapPoolAmountIn(tokenOut, poolAmountIn, minTokenAmountOut) + .exitswapPoolAmountIn(poolAmountIn, minTokenAmountOut) .estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas)) } catch (e) { estGas = gasLimitDefault @@ -1358,7 +1270,7 @@ export class Pool { } /** - * Pay poolAmountIn pool shares into the pool, getting minTokenAmountOut of the given token tokenOut out of the pool. + * Pay poolAmountIn pool shares into the pool, getting minTokenAmountOut of the baseToken * @param {String} account * @param {String} poolAddress * @param {String} tokenOut @@ -1369,7 +1281,6 @@ export class Pool { async exitswapPoolAmountIn( account: string, poolAddress: string, - tokenOut: string, poolAmountIn: string, minTokenAmountOut: string ): Promise { @@ -1381,24 +1292,19 @@ export class Pool { const minTokenOutFormatted = await amountToUnits( this.web3, - tokenOut, + await this.getBaseToken(poolAddress), minTokenAmountOut ) const estGas = await this.estExitswapPoolAmountIn( account, poolAddress, - tokenOut, this.web3.utils.toWei(poolAmountIn), minTokenOutFormatted ) try { result = await pool.methods - .exitswapPoolAmountIn( - tokenOut, - this.web3.utils.toWei(poolAmountIn), - minTokenOutFormatted - ) + .exitswapPoolAmountIn(this.web3.utils.toWei(poolAmountIn), minTokenOutFormatted) .send({ from: account, gas: estGas + 1, @@ -1410,91 +1316,6 @@ export class Pool { return result } - /** - * Estimate gas cost for joinswapExternAmountIn - * @param {String} address - * @param {String} poolAddress - * @param {String} tokenOut - * @param {String} tokenAmountOut will be converted to wei - * @param {String} maxPoolAmountIn will be converted to wei - * @param {Contract} contractInstance optional contract instance - * @return {Promise} - */ - public async estExitswapExternAmountOut( - address: string, - poolAddress: string, - tokenOut: string, - tokenAmountOut: string, - maxPoolAmountIn: string, - contractInstance?: Contract - ): Promise { - const poolContract = - contractInstance || - setContractDefaults( - new this.web3.eth.Contract(this.poolAbi as AbiItem[], poolAddress), - this.config - ) - - const gasLimitDefault = this.GASLIMIT_DEFAULT - let estGas - try { - estGas = await poolContract.methods - .exitswapExternAmountOut(tokenOut, tokenAmountOut, maxPoolAmountIn) - .estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas)) - } catch (e) { - estGas = gasLimitDefault - } - return estGas - } - - /** - * Specify tokenAmountOut of token tokenOut that you want to get out of the pool. This costs poolAmountIn pool shares (these went into the pool). - * @param {String} account - * @param {String} poolAddress - * @param {String} tokenOut - * @param {String} tokenAmountOut will be converted to wei - * @param {String} maxPoolAmountIn will be converted to wei - * @return {TransactionReceipt} - */ - async exitswapExternAmountOut( - account: string, - poolAddress: string, - tokenOut: string, - tokenAmountOut: string, - maxPoolAmountIn: string - ): Promise { - const pool = setContractDefaults( - new this.web3.eth.Contract(this.poolAbi, poolAddress), - this.config - ) - let result = null - - const estGas = await this.estExitswapExternAmountOut( - account, - poolAddress, - tokenOut, - this.web3.utils.toWei(tokenAmountOut), - this.web3.utils.toWei(maxPoolAmountIn) - ) - - try { - result = await pool.methods - .exitswapExternAmountOut( - tokenOut, - this.web3.utils.toWei(tokenAmountOut), - this.web3.utils.toWei(maxPoolAmountIn) - ) - .send({ - from: account, - gas: estGas + 1, - gasPrice: await getFairGasPrice(this.web3, this.config) - }) - } catch (e) { - LoggerInstance.error(`ERROR: Failed to exitswapExternAmountOut ${e.message}`) - } - return result - } - /** * Get Spot Price of swaping tokenIn to tokenOut * @param {String} poolAddress diff --git a/test/integration/ComputeFlow.test.ts b/test/integration/ComputeFlow.test.ts index 064a69815..44d808e5c 100644 --- a/test/integration/ComputeFlow.test.ts +++ b/test/integration/ComputeFlow.test.ts @@ -134,7 +134,7 @@ describe('Simple compute tests', async () => { name: 'testNFT', symbol: 'TST', templateIndex: 1, - tokenURI: '' + tokenURI: 'aaa' } const erc20ParamsAsset: Erc20CreateParams = { templateIndex: 1, @@ -145,11 +145,13 @@ describe('Simple compute tests', async () => { minter: publisherAccount, mpFeeAddress: '0x0000000000000000000000000000000000000000' } - const result = await Factory.createNftWithErc( + + const result = await Factory.createNftWithErc20( publisherAccount, nftParamsAsset, erc20ParamsAsset ) + const erc721AddressAsset = result.events.NFTCreated.returnValues[0] const datatokenAddressAsset = result.events.TokenCreated.returnValues[0] // create the files encrypted string @@ -192,7 +194,7 @@ describe('Simple compute tests', async () => { minter: publisherAccount, mpFeeAddress: '0x0000000000000000000000000000000000000000' } - const resultAlgo = await Factory.createNftWithErc( + const resultAlgo = await Factory.createNftWithErc20( publisherAccount, nftParamsAlgo, erc20ParamsAlgo diff --git a/test/integration/PublishFlows.test.ts b/test/integration/PublishFlows.test.ts index d03b6435d..a98c3c404 100644 --- a/test/integration/PublishFlows.test.ts +++ b/test/integration/PublishFlows.test.ts @@ -119,7 +119,7 @@ describe('Publish tests', async () => { swapFeeLiquidityProvider: 1e15, swapFeeMarketRunner: 1e15 } - const bundleNFT = await factory.createNftErcWithPool( + const bundleNFT = await factory.createNftErc20WithPool( accounts[0], nftParams, erc20Params, @@ -197,7 +197,7 @@ describe('Publish tests', async () => { withMint: false } - const bundleNFT = await factory.createNftErcWithFixedRate( + const bundleNFT = await factory.createNftErc20WithFixedRate( accounts[0], nftParams, erc20Params, @@ -268,7 +268,7 @@ describe('Publish tests', async () => { allowedSwapper: ZERO_ADDRESS } - const bundleNFT = await factory.createNftErcWithDispenser( + const bundleNFT = await factory.createNftErc20WithDispenser( accounts[0], nftParams, erc20Params, diff --git a/test/integration/SimplePublishConsumeFlow.test.ts b/test/integration/SimplePublishConsumeFlow.test.ts index b935a4bdc..02614a59d 100644 --- a/test/integration/SimplePublishConsumeFlow.test.ts +++ b/test/integration/SimplePublishConsumeFlow.test.ts @@ -85,7 +85,7 @@ describe('Simple Publish & consume test', async () => { minter: publisherAccount, mpFeeAddress: '0x0000000000000000000000000000000000000000' } - const result = await Factory.createNftWithErc( + const result = await Factory.createNftWithErc20( publisherAccount, nftParams, erc20Params diff --git a/test/unit/NftFactory.test.ts b/test/unit/NftFactory.test.ts index ef286752e..29aa3fa3e 100644 --- a/test/unit/NftFactory.test.ts +++ b/test/unit/NftFactory.test.ts @@ -181,7 +181,7 @@ describe('Nft Factory test', () => { symbol: 'ERC20DT1Symbol' } - const txReceipt = await nftFactory.createNftWithErc( + const txReceipt = await nftFactory.createNftWithErc20( contracts.accounts[0], nftData, ercParams @@ -233,7 +233,7 @@ describe('Nft Factory test', () => { swapFeeMarketRunner: 1e15 } - const txReceipt = await nftFactory.createNftErcWithPool( + const txReceipt = await nftFactory.createNftErc20WithPool( contracts.accounts[0], nftData, ercParams, @@ -280,7 +280,7 @@ describe('Nft Factory test', () => { withMint: false } - const txReceipt = await nftFactory.createNftErcWithFixedRate( + const txReceipt = await nftFactory.createNftErc20WithFixedRate( contracts.accounts[0], nftData, ercParams, @@ -325,7 +325,7 @@ describe('Nft Factory test', () => { allowedSwapper: ZERO_ADDRESS } - const txReceipt = await nftFactory.createNftErcWithDispenser( + const txReceipt = await nftFactory.createNftErc20WithDispenser( contracts.accounts[0], nftData, ercParams, diff --git a/test/unit/pools/Router.test.ts b/test/unit/pools/Router.test.ts index c1f7d8709..128d1cf81 100644 --- a/test/unit/pools/Router.test.ts +++ b/test/unit/pools/Router.test.ts @@ -218,7 +218,7 @@ describe('Router unit test', () => { ERC721Factory.abi as AbiItem[] ) - const txReceipt = await nftFactory.createNftErcWithPool( + const txReceipt = await nftFactory.createNftErc20WithPool( contracts.accounts[0], nftData, ercParams, @@ -265,7 +265,7 @@ describe('Router unit test', () => { swapFeeMarketRunner: 1e15 } - const txReceipt2 = await nftFactory.createNftErcWithPool( + const txReceipt2 = await nftFactory.createNftErc20WithPool( contracts.accounts[0], nftData2, ercParams2, diff --git a/test/unit/pools/balancer/Pool.test.ts b/test/unit/pools/balancer/Pool.test.ts index 42ad445d0..6f16f0a90 100644 --- a/test/unit/pools/balancer/Pool.test.ts +++ b/test/unit/pools/balancer/Pool.test.ts @@ -170,7 +170,7 @@ describe('Pool unit test', () => { ERC721Factory.abi as AbiItem[] ) - const txReceipt = await nftFactory.createNftErcWithPool( + const txReceipt = await nftFactory.createNftErc20WithPool( contracts.accounts[0], nftData, ercParams, @@ -346,7 +346,6 @@ describe('Pool unit test', () => { const tx = await pool.joinswapExternAmountIn( user2, poolAddress, - contracts.daiAddress, daiAmountIn, minBPTOut ) @@ -361,30 +360,6 @@ describe('Pool unit test', () => { ) }) - it('#joinswapPoolAmountOut- user2 should add liquidity, receiving LP tokens', async () => { - const BPTAmountOut = '0.1' - const maxDAIIn = '100' - - await approve(web3, user2, contracts.daiAddress, poolAddress, '100') - - const tx = await pool.joinswapPoolAmountOut( - user2, - poolAddress, - contracts.daiAddress, - BPTAmountOut, - maxDAIIn - ) - - assert(tx != null) - - expect(tx.events.LOG_JOIN[0].event === 'LOG_JOIN') - expect(tx.events.LOG_BPT.event === 'LOG_BPT') - // 2 JOIN EVENTS BECAUSE SIDE STAKING ALSO STAKED DTs, TODO: we should add to whom has been sent in the LOG_BPT event - expect(tx.events.LOG_JOIN[0].returnValues.bptAmount).to.equal( - tx.events.LOG_JOIN[1].returnValues.bptAmount - ) - }) - it('#exitPool- user2 exit the pool receiving both tokens, burning LP', async () => { const BPTAmountIn = '0.5' const minAmountOut = [ @@ -407,7 +382,6 @@ describe('Pool unit test', () => { const tx = await pool.exitswapPoolAmountIn( user2, poolAddress, - contracts.daiAddress, BPTAmountIn, minDAIOut ) @@ -427,7 +401,6 @@ describe('Pool unit test', () => { const tx = await pool.exitswapPoolAmountIn( user2, poolAddress, - contracts.daiAddress, maxBTPIn, exactDAIOut ) @@ -643,7 +616,7 @@ describe('Pool unit test', () => { ERC721Factory.abi as AbiItem[] ) - const txReceipt = await nftFactory.createNftErcWithPool( + const txReceipt = await nftFactory.createNftErc20WithPool( contracts.accounts[0], nftData, ercParams, @@ -894,7 +867,6 @@ describe('Pool unit test', () => { const tx = await pool.joinswapExternAmountIn( user2, poolAddress, - contracts.usdcAddress, usdcAmountIn, minBPTOut ) @@ -909,30 +881,6 @@ describe('Pool unit test', () => { ) }) - it('#joinswapPoolAmountOut- user2 should add liquidity, receiving LP tokens', async () => { - const BPTAmountOut = '0.1' - const maxUSDCIn = '100' - - await approve(web3, user2, contracts.usdcAddress, poolAddress, '100') - - const tx = await pool.joinswapPoolAmountOut( - user2, - poolAddress, - contracts.usdcAddress, - BPTAmountOut, - maxUSDCIn - ) - - assert(tx != null) - - expect(tx.events.LOG_JOIN[0].event === 'LOG_JOIN') - expect(tx.events.LOG_BPT.event === 'LOG_BPT') - // 2 JOIN EVENTS BECAUSE SIDE STAKING ALSO STAKED DTs, TODO: we should add to whom has been sent in the LOG_BPT event - expect(tx.events.LOG_JOIN[0].returnValues.bptAmount).to.equal( - tx.events.LOG_JOIN[1].returnValues.bptAmount - ) - }) - it('#exitPool- user2 exit the pool receiving both tokens, burning LP', async () => { const BPTAmountIn = '0.5' const minAmountOut = [ @@ -955,7 +903,6 @@ describe('Pool unit test', () => { const tx = await pool.exitswapPoolAmountIn( user2, poolAddress, - contracts.usdcAddress, BPTAmountIn, minUSDCOut ) @@ -968,26 +915,6 @@ describe('Pool unit test', () => { expect(tx.events.LOG_EXIT[1].returnValues.tokenOut).to.equal(erc20Token) }) - it('#exitswapExternAmountOut- user2 exit the pool receiving only USDC', async () => { - const maxBTPIn = '0.5' - const exactUSDCOut = '1' - - const tx = await pool.exitswapPoolAmountIn( - user2, - poolAddress, - contracts.usdcAddress, - maxBTPIn, - exactUSDCOut - ) - - assert(tx != null) - - expect(tx.events.LOG_EXIT[0].returnValues.tokenOut).to.equal(contracts.usdcAddress) - - // DTs were also unstaked in the same transaction (went to the staking contract) - expect(tx.events.LOG_EXIT[1].returnValues.tokenOut).to.equal(erc20Token) - }) - it('#getAmountInExactOut- should get the amount in for exact out', async () => { const maxBTPIn = '0.5' const exactUSDCOut = '1' diff --git a/test/unit/pools/dispenser/Dispenser.test.ts b/test/unit/pools/dispenser/Dispenser.test.ts index ccc393a6f..6f4334fdc 100644 --- a/test/unit/pools/dispenser/Dispenser.test.ts +++ b/test/unit/pools/dispenser/Dispenser.test.ts @@ -96,7 +96,7 @@ describe('Dispenser flow', () => { symbol: 'ERC20DT1Symbol' } - const txReceipt = await nftFactory.createNftWithErc( + const txReceipt = await nftFactory.createNftWithErc20( contracts.accounts[0], nftData, ercParams diff --git a/test/unit/pools/fixedRate/FixedRateExchange.test.ts b/test/unit/pools/fixedRate/FixedRateExchange.test.ts index 949184fec..17edbe880 100644 --- a/test/unit/pools/fixedRate/FixedRateExchange.test.ts +++ b/test/unit/pools/fixedRate/FixedRateExchange.test.ts @@ -127,7 +127,7 @@ describe('Fixed Rate unit test', () => { withMint: false } - const txReceipt = await nftFactory.createNftErcWithFixedRate( + const txReceipt = await nftFactory.createNftErc20WithFixedRate( exchangeOwner, nftData, ercParams, @@ -455,7 +455,7 @@ describe('Fixed Rate unit test', () => { withMint: false } - const txReceipt = await nftFactory.createNftErcWithFixedRate( + const txReceipt = await nftFactory.createNftErc20WithFixedRate( exchangeOwner, nftData, ercParams, diff --git a/test/unit/pools/ssContracts/SideStaking.test.ts b/test/unit/pools/ssContracts/SideStaking.test.ts index 78c36044c..9218ee2f7 100644 --- a/test/unit/pools/ssContracts/SideStaking.test.ts +++ b/test/unit/pools/ssContracts/SideStaking.test.ts @@ -177,7 +177,7 @@ describe('SideStaking unit test', () => { swapFeeMarketRunner: 1e15 } - const txReceipt = await nftFactory.createNftErcWithPool( + const txReceipt = await nftFactory.createNftErc20WithPool( contracts.accounts[0], nftData, ercParams, @@ -352,7 +352,6 @@ describe('SideStaking unit test', () => { const tx = await pool.joinswapExternAmountIn( user2, poolAddress, - contracts.daiAddress, daiAmountIn, minBPTOut ) @@ -367,30 +366,6 @@ describe('SideStaking unit test', () => { ) }) - it('#joinswapPoolAmountOut- user2 should add liquidity, receiving LP tokens', async () => { - const BPTAmountOut = '0.1' - const maxDAIIn = '100' - - await approve(web3, user2, contracts.daiAddress, poolAddress, '100') - - const tx = await pool.joinswapPoolAmountOut( - user2, - poolAddress, - contracts.daiAddress, - BPTAmountOut, - maxDAIIn - ) - - assert(tx != null) - - expect(tx.events.LOG_JOIN[0].event === 'LOG_JOIN') - expect(tx.events.LOG_BPT.event === 'LOG_BPT') - // 2 JOIN EVENTS BECAUSE SIDE STAKING ALSO STAKED DTs, TODO: we should add to whom has been sent in the LOG_BPT event - expect(tx.events.LOG_JOIN[0].returnValues.bptAmount).to.equal( - tx.events.LOG_JOIN[1].returnValues.bptAmount - ) - }) - it('#exitswapPoolAmountIn- user2 exit the pool receiving only DAI', async () => { const BPTAmountIn = '0.5' const minDAIOut = '0.5' @@ -398,7 +373,6 @@ describe('SideStaking unit test', () => { const tx = await pool.exitswapPoolAmountIn( user2, poolAddress, - contracts.daiAddress, BPTAmountIn, minDAIOut ) @@ -410,26 +384,6 @@ describe('SideStaking unit test', () => { // DTs were also unstaked in the same transaction (went to the staking contract) expect(tx.events.LOG_EXIT[1].returnValues.tokenOut).to.equal(erc20Token) }) - - it('#exitswapExternAmountOut- user2 exit the pool receiving only DAI', async () => { - const maxBTPIn = '0.5' - const exactDAIOut = '1' - - const tx = await pool.exitswapPoolAmountIn( - user2, - poolAddress, - contracts.daiAddress, - maxBTPIn, - exactDAIOut - ) - - assert(tx != null) - - expect(tx.events.LOG_EXIT[0].returnValues.tokenOut).to.equal(contracts.daiAddress) - - // DTs were also unstaked in the same transaction (went to the staking contract) - expect(tx.events.LOG_EXIT[1].returnValues.tokenOut).to.equal(erc20Token) - }) }) describe('Test a pool with USDC (6 Decimals)', () => { @@ -475,7 +429,7 @@ describe('SideStaking unit test', () => { swapFeeMarketRunner: 1e15 } - const txReceipt = await nftFactory.createNftErcWithPool( + const txReceipt = await nftFactory.createNftErc20WithPool( contracts.accounts[0], nftData, ercParams, @@ -612,7 +566,6 @@ describe('SideStaking unit test', () => { const tx = await pool.joinswapExternAmountIn( user2, poolAddress, - contracts.usdcAddress, usdcAmountIn, minBPTOut ) @@ -627,30 +580,6 @@ describe('SideStaking unit test', () => { ) }) - it('#joinswapPoolAmountOut- user2 should add liquidity, receiving LP tokens', async () => { - const BPTAmountOut = '0.1' - const maxUSDCIn = '100' - - await approve(web3, user2, contracts.usdcAddress, poolAddress, '100') - - const tx = await pool.joinswapPoolAmountOut( - user2, - poolAddress, - contracts.usdcAddress, - BPTAmountOut, - maxUSDCIn - ) - - assert(tx != null) - - expect(tx.events.LOG_JOIN[0].event === 'LOG_JOIN') - expect(tx.events.LOG_BPT.event === 'LOG_BPT') - // 2 JOIN EVENTS BECAUSE SIDE STAKING ALSO STAKED DTs, TODO: we should add to whom has been sent in the LOG_BPT event - expect(tx.events.LOG_JOIN[0].returnValues.bptAmount).to.equal( - tx.events.LOG_JOIN[1].returnValues.bptAmount - ) - }) - it('#exitswapPoolAmountIn- user2 exit the pool receiving only USDC', async () => { const BPTAmountIn = '0.5' const minUSDCOut = '0.5' @@ -658,7 +587,6 @@ describe('SideStaking unit test', () => { const tx = await pool.exitswapPoolAmountIn( user2, poolAddress, - contracts.usdcAddress, BPTAmountIn, minUSDCOut ) @@ -670,25 +598,5 @@ describe('SideStaking unit test', () => { // DTs were also unstaked in the same transaction (went to the staking contract) expect(tx.events.LOG_EXIT[1].returnValues.tokenOut).to.equal(erc20Token) }) - - it('#exitswapExternAmountOut- user2 exit the pool receiving only USDC', async () => { - const maxBTPIn = '0.5' - const exactUSDCOut = '1' - - const tx = await pool.exitswapPoolAmountIn( - user2, - poolAddress, - contracts.usdcAddress, - maxBTPIn, - exactUSDCOut - ) - - assert(tx != null) - - expect(tx.events.LOG_EXIT[0].returnValues.tokenOut).to.equal(contracts.usdcAddress) - - // DTs were also unstaked in the same transaction (went to the staking contract) - expect(tx.events.LOG_EXIT[1].returnValues.tokenOut).to.equal(erc20Token) - }) }) })