From a70b3f5eb3bdc9f8eec0928dc03a5c4dce2d4a23 Mon Sep 17 00:00:00 2001 From: Norbert Date: Fri, 25 Feb 2022 11:55:06 +0200 Subject: [PATCH 01/21] replaced toWei inside FRE --- src/pools/fixedRate/FixedRateExchange.ts | 50 ++++++++++++------------ 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/src/pools/fixedRate/FixedRateExchange.ts b/src/pools/fixedRate/FixedRateExchange.ts index 3c6f87acd..ab903cb49 100644 --- a/src/pools/fixedRate/FixedRateExchange.ts +++ b/src/pools/fixedRate/FixedRateExchange.ts @@ -171,17 +171,17 @@ export class FixedRateExchange { consumeMarketAddress: string = '0x0000000000000000000000000000000000000000', consumeMarketFee: string = '0' ): Promise { - const consumeMarketFeeFormatted = await this.web3.utils.toWei(consumeMarketFee) + const exchange = await this.getExchange(exchangeId) + const consumeMarketFeeFormatted = await this.amountToUnits( + exchange.baseToken, + consumeMarketFee + ) const dtAmountFormatted = await this.amountToUnits( - ( - await this.getExchange(exchangeId) - ).datatoken, + exchange.datatoken, datatokenAmount ) const maxBtFormatted = await this.amountToUnits( - ( - await this.getExchange(exchangeId) - ).baseToken, + exchange.baseToken, maxBaseTokenAmount ) @@ -270,17 +270,17 @@ export class FixedRateExchange { consumeMarketAddress: string = '0x0000000000000000000000000000000000000000', consumeMarketFee: string = '0' ): Promise { - const consumeMarketFeeFormatted = await this.web3.utils.toWei(consumeMarketFee) + const exchange = await this.getExchange(exchangeId) + const consumeMarketFeeFormatted = await this.amountToUnits( + exchange.baseToken, + consumeMarketFee + ) const dtAmountFormatted = await this.amountToUnits( - ( - await this.getExchange(exchangeId) - ).datatoken, + exchange.datatoken, datatokenAmount ) const minBtFormatted = await this.amountToUnits( - ( - await this.getExchange(exchangeId) - ).baseToken, + exchange.baseToken, minBaseTokenAmount ) const estGas = await this.estBuyDT( @@ -362,13 +362,14 @@ export class FixedRateExchange { exchangeId: string, newRate: string ): Promise { + const exchange = await this.getExchange(exchangeId) const estGas = await this.estSetRate( address, exchangeId, - this.web3.utils.toWei(String(newRate)) + await this.unitsToAmount(exchange.baseToken, String(newRate)) ) const trxReceipt = await this.contract.methods - .setRate(exchangeId, this.web3.utils.toWei(newRate)) + .setRate(exchangeId, this.unitsToAmount(exchange.baseToken, newRate)) .send({ from: address, gas: estGas + 1, @@ -592,7 +593,7 @@ export class FixedRateExchange { .calcBaseInGivenOutDT( exchangeId, await this.amountToUnits(fixedRateExchange.datatoken, datatokenAmount), - this.web3.utils.toWei(consumeMarketFee) + await this.amountToUnits(fixedRateExchange.baseToken, consumeMarketFee) ) .call() @@ -629,16 +630,12 @@ export class FixedRateExchange { datatokenAmount: string, consumeMarketFee: string = '0' ): Promise { + const exchange = await this.getExchange(exchangeId) const result = await this.contract.methods .calcBaseOutGivenInDT( exchangeId, - await this.amountToUnits( - ( - await this.getExchange(exchangeId) - ).datatoken, - datatokenAmount - ), - this.web3.utils.toWei(consumeMarketFee) + await this.amountToUnits(exchange.datatoken, datatokenAmount), + this.unitsToAmount(exchange.baseToken, consumeMarketFee) ) .call() @@ -1089,13 +1086,14 @@ export class FixedRateExchange { exchangeId: string, newMarketFee: string ): Promise { + const exchange = await this.getExchange(exchangeId) const estGas = await this.estSetRate( address, exchangeId, - this.web3.utils.toWei(newMarketFee) + await this.unitsToAmount(exchange.baseToken, newMarketFee) ) const trxReceipt = await this.contract.methods - .updateMarketFee(exchangeId, this.web3.utils.toWei(newMarketFee)) + .updateMarketFee(exchangeId, this.unitsToAmount(exchange.baseToken, newMarketFee)) .send({ from: address, gas: estGas + 1, From 7f3f04dda40c3167b019897df6ee50275a582f0f Mon Sep 17 00:00:00 2001 From: Norbert Date: Mon, 28 Feb 2022 15:56:22 +0200 Subject: [PATCH 02/21] added amountToUnits for maxPrice inside pool --- src/pools/balancer/Pool.ts | 76 +++++++++++++++++++++++++++++--------- 1 file changed, 58 insertions(+), 18 deletions(-) diff --git a/src/pools/balancer/Pool.ts b/src/pools/balancer/Pool.ts index b8161d543..88f6bffa7 100644 --- a/src/pools/balancer/Pool.ts +++ b/src/pools/balancer/Pool.ts @@ -802,8 +802,24 @@ export class Pool { this.config ) + amountsInOutMaxFee.tokenAmountIn = await amountToUnits( + this.web3, + tokenInOutMarket.tokenIn, + amountsInOutMaxFee.tokenAmountIn + ) + + amountsInOutMaxFee.minAmountOut = await amountToUnits( + this.web3, + tokenInOutMarket.tokenOut, + amountsInOutMaxFee.minAmountOut + ) + const maxPrice = amountsInOutMaxFee.maxPrice - ? this.web3.utils.toWei(amountsInOutMaxFee.maxPrice) + ? amountToUnits( + this.web3, + await this.getBaseToken(poolAddress), + amountsInOutMaxFee.maxPrice + ) : MaxUint256 const gasLimitDefault = this.GASLIMIT_DEFAULT @@ -859,6 +875,13 @@ export class Pool { throw new Error(`tokenAmountIn is greater than ${maxSwap.toString()}`) } + const estGas = await this.estSwapExactAmountIn( + address, + poolAddress, + tokenInOutMarket, + amountsInOutMaxFee + ) + amountsInOutMaxFee.tokenAmountIn = await amountToUnits( this.web3, tokenInOutMarket.tokenIn, @@ -873,15 +896,12 @@ export class Pool { let result = null - const estGas = await this.estSwapExactAmountIn( - address, - poolAddress, - tokenInOutMarket, - amountsInOutMaxFee - ) - const maxPrice = amountsInOutMaxFee.maxPrice - ? this.web3.utils.toWei(amountsInOutMaxFee.maxPrice) + ? amountToUnits( + this.web3, + await this.getBaseToken(poolAddress), + amountsInOutMaxFee.maxPrice + ) : MaxUint256 try { @@ -936,8 +956,24 @@ export class Pool { const gasLimitDefault = this.GASLIMIT_DEFAULT + amountsInOutMaxFee.maxAmountIn = await amountToUnits( + this.web3, + tokenInOutMarket.tokenIn, + amountsInOutMaxFee.maxAmountIn + ) + + amountsInOutMaxFee.tokenAmountOut = await amountToUnits( + this.web3, + tokenInOutMarket.tokenOut, + amountsInOutMaxFee.tokenAmountOut + ) + const maxPrice = amountsInOutMaxFee.maxPrice - ? this.web3.utils.toWei(amountsInOutMaxFee.maxPrice) + ? amountToUnits( + this.web3, + await this.getBaseToken(poolAddress), + amountsInOutMaxFee.maxPrice + ) : MaxUint256 let estGas @@ -988,6 +1024,13 @@ export class Pool { throw new Error(`tokenAmountOut is greater than ${maxSwap.toString()}`) } + const estGas = await this.estSwapExactAmountOut( + account, + poolAddress, + tokenInOutMarket, + amountsInOutMaxFee + ) + amountsInOutMaxFee.maxAmountIn = await amountToUnits( this.web3, tokenInOutMarket.tokenIn, @@ -1000,15 +1043,12 @@ export class Pool { amountsInOutMaxFee.tokenAmountOut ) - const estGas = await this.estSwapExactAmountOut( - account, - poolAddress, - tokenInOutMarket, - amountsInOutMaxFee - ) - const maxPrice = amountsInOutMaxFee.maxPrice - ? this.web3.utils.toWei(amountsInOutMaxFee.maxPrice) + ? amountToUnits( + this.web3, + await this.getBaseToken(poolAddress), + amountsInOutMaxFee.maxPrice + ) : MaxUint256 try { From 21beab9203008293287a1c55dea7e5dd625f1f44 Mon Sep 17 00:00:00 2001 From: Norbert Date: Tue, 1 Mar 2022 11:11:27 +0200 Subject: [PATCH 03/21] replaced fromWei --- src/factories/NFTFactory.ts | 4 ++-- src/utils/ContractUtils.ts | 10 ++++++++-- test/unit/pools/balancer/Pool.test.ts | 12 ++++++++++-- test/unit/pools/ssContracts/SideStaking.test.ts | 12 ++++++++++-- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/factories/NFTFactory.ts b/src/factories/NFTFactory.ts index 1458b1d77..871c38e55 100644 --- a/src/factories/NFTFactory.ts +++ b/src/factories/NFTFactory.ts @@ -705,7 +705,7 @@ export class NftFactory { let estGas try { const ercCreateData = getErcCreationParams(ercParams) - const poolData = getPoolCreationParams(poolParams) + const poolData = await getPoolCreationParams(poolParams) estGas = await this.factory721.methods .createNftWithErc20WithPool(nftCreateData, ercCreateData, poolData) .estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas)) @@ -738,7 +738,7 @@ export class NftFactory { poolParams ) const ercCreateData = getErcCreationParams(ercParams) - const poolData = getPoolCreationParams(poolParams) + const poolData = await getPoolCreationParams(poolParams) // Invoke createToken function of the contract const trxReceipt = await this.factory721.methods diff --git a/src/utils/ContractUtils.ts b/src/utils/ContractUtils.ts index cd00106ea..3cebe171a 100644 --- a/src/utils/ContractUtils.ts +++ b/src/utils/ContractUtils.ts @@ -87,7 +87,9 @@ export function getFreCreationParams(freParams: FreCreationParams): any { } } -export function getPoolCreationParams(poolParams: PoolCreationParams): any { +export async function getPoolCreationParams( + poolParams: PoolCreationParams +): Promise { return { addresses: [ poolParams.ssContract, @@ -102,7 +104,11 @@ export function getPoolCreationParams(poolParams: PoolCreationParams): any { poolParams.baseTokenDecimals, Web3.utils.toWei(poolParams.vestingAmount), poolParams.vestedBlocks, - Web3.utils.toWei(poolParams.initialBaseTokenLiquidity) + await amountToUnits( + this.web3, + poolParams.baseTokenAddress, + poolParams.initialBaseTokenLiquidity + ) ], swapFees: [ Web3.utils.toWei(poolParams.swapFeeLiquidityProvider), diff --git a/test/unit/pools/balancer/Pool.test.ts b/test/unit/pools/balancer/Pool.test.ts index e77f433c5..0ba97edc8 100644 --- a/test/unit/pools/balancer/Pool.test.ts +++ b/test/unit/pools/balancer/Pool.test.ts @@ -12,7 +12,13 @@ import Dispenser from '@oceanprotocol/contracts/artifacts/contracts/pools/dispen import FixedRate from '@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json' 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 { allowance, amountToUnits, approve, LoggerInstance } from '../../../../src/utils' +import { + allowance, + amountToUnits, + approve, + LoggerInstance, + unitsToAmount +} from '../../../../src/utils' import { NftFactory, NftCreateData } from '../../../../src/factories/NFTFactory' import { Pool } from '../../../../src/pools/balancer/Pool' import { @@ -606,7 +612,9 @@ describe('Pool unit test', () => { baseTokenDecimals: await usdcContract.methods.decimals().call(), vestingAmount: '10000', vestedBlocks: 2500000, - initialBaseTokenLiquidity: web3.utils.fromWei( + initialBaseTokenLiquidity: await unitsToAmount( + web3, + contracts.usdcAddress, await amountToUnits(web3, contracts.usdcAddress, '2000') ), swapFeeLiquidityProvider: '0.001', diff --git a/test/unit/pools/ssContracts/SideStaking.test.ts b/test/unit/pools/ssContracts/SideStaking.test.ts index be1d62a5d..6f39ff76f 100644 --- a/test/unit/pools/ssContracts/SideStaking.test.ts +++ b/test/unit/pools/ssContracts/SideStaking.test.ts @@ -12,7 +12,13 @@ import Dispenser from '@oceanprotocol/contracts/artifacts/contracts/pools/dispen import FixedRate from '@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json' 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 { allowance, amountToUnits, approve, LoggerInstance } from '../../../../src/utils' +import { + allowance, + amountToUnits, + approve, + LoggerInstance, + unitsToAmount +} from '../../../../src/utils' import { NftFactory, NftCreateData } from '../../../../src/factories/NFTFactory' import { Pool } from '../../../../src/pools/balancer/Pool' import { SideStaking } from '../../../../src/pools/ssContracts/SideStaking' @@ -410,7 +416,9 @@ describe('SideStaking unit test', () => { baseTokenDecimals: await usdcContract.methods.decimals().call(), vestingAmount: '10000', vestedBlocks: 2500000, - initialBaseTokenLiquidity: web3.utils.fromWei( + initialBaseTokenLiquidity: await unitsToAmount( + web3, + contracts.usdcAddress, await amountToUnits(web3, contracts.usdcAddress, '2000') ), swapFeeLiquidityProvider: '0.001', From ea5999a39205d232fc60401b4541d779350c9a8d Mon Sep 17 00:00:00 2001 From: Norbert Date: Wed, 2 Mar 2022 13:55:22 +0200 Subject: [PATCH 04/21] add web3 param to getPoolCreationParams --- src/factories/NFTFactory.ts | 4 ++-- src/utils/ContractUtils.ts | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/factories/NFTFactory.ts b/src/factories/NFTFactory.ts index 871c38e55..96b03808f 100644 --- a/src/factories/NFTFactory.ts +++ b/src/factories/NFTFactory.ts @@ -705,7 +705,7 @@ export class NftFactory { let estGas try { const ercCreateData = getErcCreationParams(ercParams) - const poolData = await getPoolCreationParams(poolParams) + const poolData = await getPoolCreationParams(this.web3, poolParams) estGas = await this.factory721.methods .createNftWithErc20WithPool(nftCreateData, ercCreateData, poolData) .estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas)) @@ -738,7 +738,7 @@ export class NftFactory { poolParams ) const ercCreateData = getErcCreationParams(ercParams) - const poolData = await getPoolCreationParams(poolParams) + const poolData = await getPoolCreationParams(this.web3, poolParams) // Invoke createToken function of the contract const trxReceipt = await this.factory721.methods diff --git a/src/utils/ContractUtils.ts b/src/utils/ContractUtils.ts index 3cebe171a..20bbca70e 100644 --- a/src/utils/ContractUtils.ts +++ b/src/utils/ContractUtils.ts @@ -88,6 +88,7 @@ export function getFreCreationParams(freParams: FreCreationParams): any { } export async function getPoolCreationParams( + web3: Web3, poolParams: PoolCreationParams ): Promise { return { @@ -105,7 +106,7 @@ export async function getPoolCreationParams( Web3.utils.toWei(poolParams.vestingAmount), poolParams.vestedBlocks, await amountToUnits( - this.web3, + web3, poolParams.baseTokenAddress, poolParams.initialBaseTokenLiquidity ) From 5ec5c061d8e96a837095498ff5b98860f25621e2 Mon Sep 17 00:00:00 2001 From: Norbert Date: Wed, 2 Mar 2022 14:15:24 +0200 Subject: [PATCH 05/21] added await before amountToUnits inside swapExactAmount --- src/pools/balancer/Pool.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pools/balancer/Pool.ts b/src/pools/balancer/Pool.ts index 88f6bffa7..c44f6c630 100644 --- a/src/pools/balancer/Pool.ts +++ b/src/pools/balancer/Pool.ts @@ -897,7 +897,7 @@ export class Pool { let result = null const maxPrice = amountsInOutMaxFee.maxPrice - ? amountToUnits( + ? await amountToUnits( this.web3, await this.getBaseToken(poolAddress), amountsInOutMaxFee.maxPrice @@ -969,7 +969,7 @@ export class Pool { ) const maxPrice = amountsInOutMaxFee.maxPrice - ? amountToUnits( + ? await amountToUnits( this.web3, await this.getBaseToken(poolAddress), amountsInOutMaxFee.maxPrice From 2ece3c7a310f0dfc79d691e2e139930fec1bbfd0 Mon Sep 17 00:00:00 2001 From: Norbert Date: Wed, 2 Mar 2022 15:04:22 +0200 Subject: [PATCH 06/21] swapExactAmount update --- src/pools/balancer/Pool.ts | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/pools/balancer/Pool.ts b/src/pools/balancer/Pool.ts index c44f6c630..3a9369565 100644 --- a/src/pools/balancer/Pool.ts +++ b/src/pools/balancer/Pool.ts @@ -802,13 +802,13 @@ export class Pool { this.config ) - amountsInOutMaxFee.tokenAmountIn = await amountToUnits( + const tokenAmountIn = await amountToUnits( this.web3, tokenInOutMarket.tokenIn, amountsInOutMaxFee.tokenAmountIn ) - amountsInOutMaxFee.minAmountOut = await amountToUnits( + const minAmountOut = await amountToUnits( this.web3, tokenInOutMarket.tokenOut, amountsInOutMaxFee.minAmountOut @@ -833,8 +833,8 @@ export class Pool { tokenInOutMarket.marketFeeAddress ], [ - amountsInOutMaxFee.tokenAmountIn, - amountsInOutMaxFee.minAmountOut, + tokenAmountIn, + minAmountOut, maxPrice, this.web3.utils.toWei(amountsInOutMaxFee.swapMarketFee) ] @@ -882,13 +882,13 @@ export class Pool { amountsInOutMaxFee ) - amountsInOutMaxFee.tokenAmountIn = await amountToUnits( + const tokenAmountIn = await amountToUnits( this.web3, tokenInOutMarket.tokenIn, amountsInOutMaxFee.tokenAmountIn ) - amountsInOutMaxFee.minAmountOut = await amountToUnits( + const minAmountOut = await amountToUnits( this.web3, tokenInOutMarket.tokenOut, amountsInOutMaxFee.minAmountOut @@ -913,8 +913,8 @@ export class Pool { tokenInOutMarket.marketFeeAddress ], [ - amountsInOutMaxFee.tokenAmountIn, - amountsInOutMaxFee.minAmountOut, + tokenAmountIn, + minAmountOut, maxPrice, this.web3.utils.toWei(amountsInOutMaxFee.swapMarketFee) ] @@ -956,13 +956,13 @@ export class Pool { const gasLimitDefault = this.GASLIMIT_DEFAULT - amountsInOutMaxFee.maxAmountIn = await amountToUnits( + const maxAmountIn = await amountToUnits( this.web3, tokenInOutMarket.tokenIn, amountsInOutMaxFee.maxAmountIn ) - amountsInOutMaxFee.tokenAmountOut = await amountToUnits( + const tokenAmountOut = await amountToUnits( this.web3, tokenInOutMarket.tokenOut, amountsInOutMaxFee.tokenAmountOut @@ -986,8 +986,8 @@ export class Pool { tokenInOutMarket.marketFeeAddress ], [ - amountsInOutMaxFee.maxAmountIn, - amountsInOutMaxFee.tokenAmountOut, + maxAmountIn, + tokenAmountOut, maxPrice, this.web3.utils.toWei(amountsInOutMaxFee.swapMarketFee) ] @@ -1031,13 +1031,13 @@ export class Pool { amountsInOutMaxFee ) - amountsInOutMaxFee.maxAmountIn = await amountToUnits( + const maxAmountIn = await amountToUnits( this.web3, tokenInOutMarket.tokenIn, amountsInOutMaxFee.maxAmountIn ) - amountsInOutMaxFee.tokenAmountOut = await amountToUnits( + const tokenAmountOut = await amountToUnits( this.web3, tokenInOutMarket.tokenOut, amountsInOutMaxFee.tokenAmountOut @@ -1060,8 +1060,8 @@ export class Pool { tokenInOutMarket.marketFeeAddress ], [ - amountsInOutMaxFee.maxAmountIn, - amountsInOutMaxFee.tokenAmountOut, + maxAmountIn, + tokenAmountOut, maxPrice, this.web3.utils.toWei(amountsInOutMaxFee.swapMarketFee) ] From f6bcd73450b68f9c4826073d10a911ef3197d362 Mon Sep 17 00:00:00 2001 From: Norbert Date: Wed, 2 Mar 2022 15:20:06 +0200 Subject: [PATCH 07/21] add await to unitsToAmount inside setRate --- src/pools/fixedRate/FixedRateExchange.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pools/fixedRate/FixedRateExchange.ts b/src/pools/fixedRate/FixedRateExchange.ts index ab903cb49..df0850f52 100644 --- a/src/pools/fixedRate/FixedRateExchange.ts +++ b/src/pools/fixedRate/FixedRateExchange.ts @@ -369,7 +369,7 @@ export class FixedRateExchange { await this.unitsToAmount(exchange.baseToken, String(newRate)) ) const trxReceipt = await this.contract.methods - .setRate(exchangeId, this.unitsToAmount(exchange.baseToken, newRate)) + .setRate(exchangeId, await this.unitsToAmount(exchange.baseToken, newRate)) .send({ from: address, gas: estGas + 1, From 3322aca0860f395da3a2a626eb5794f7157e0a36 Mon Sep 17 00:00:00 2001 From: Norbert Date: Wed, 2 Mar 2022 15:29:52 +0200 Subject: [PATCH 08/21] convert newRate to string --- src/pools/fixedRate/FixedRateExchange.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pools/fixedRate/FixedRateExchange.ts b/src/pools/fixedRate/FixedRateExchange.ts index df0850f52..2121ccd07 100644 --- a/src/pools/fixedRate/FixedRateExchange.ts +++ b/src/pools/fixedRate/FixedRateExchange.ts @@ -369,7 +369,7 @@ export class FixedRateExchange { await this.unitsToAmount(exchange.baseToken, String(newRate)) ) const trxReceipt = await this.contract.methods - .setRate(exchangeId, await this.unitsToAmount(exchange.baseToken, newRate)) + .setRate(exchangeId, await this.unitsToAmount(exchange.baseToken, String(newRate))) .send({ from: address, gas: estGas + 1, From 5da72426b0964a7987eda7f5aee11de0a3ed3648 Mon Sep 17 00:00:00 2001 From: Norbert Date: Thu, 3 Mar 2022 14:57:04 +0200 Subject: [PATCH 09/21] replaced unitToAmounts with amountToUnits inside setRate --- src/pools/fixedRate/FixedRateExchange.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pools/fixedRate/FixedRateExchange.ts b/src/pools/fixedRate/FixedRateExchange.ts index 2121ccd07..379c6cbe7 100644 --- a/src/pools/fixedRate/FixedRateExchange.ts +++ b/src/pools/fixedRate/FixedRateExchange.ts @@ -366,10 +366,10 @@ export class FixedRateExchange { const estGas = await this.estSetRate( address, exchangeId, - await this.unitsToAmount(exchange.baseToken, String(newRate)) + await this.amountToUnits(exchange.baseToken, String(newRate)) ) const trxReceipt = await this.contract.methods - .setRate(exchangeId, await this.unitsToAmount(exchange.baseToken, String(newRate))) + .setRate(exchangeId, await this.amountToUnits(exchange.baseToken, String(newRate))) .send({ from: address, gas: estGas + 1, From ca6193b929978cc6f0f44dbd6b8ac2f520150000 Mon Sep 17 00:00:00 2001 From: Norbert Date: Thu, 3 Mar 2022 15:17:37 +0200 Subject: [PATCH 10/21] replace unitToAmounts with amountToUnits --- src/pools/fixedRate/FixedRateExchange.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pools/fixedRate/FixedRateExchange.ts b/src/pools/fixedRate/FixedRateExchange.ts index 379c6cbe7..6b1d6c0e1 100644 --- a/src/pools/fixedRate/FixedRateExchange.ts +++ b/src/pools/fixedRate/FixedRateExchange.ts @@ -635,7 +635,7 @@ export class FixedRateExchange { .calcBaseOutGivenInDT( exchangeId, await this.amountToUnits(exchange.datatoken, datatokenAmount), - this.unitsToAmount(exchange.baseToken, consumeMarketFee) + this.amountToUnits(exchange.baseToken, consumeMarketFee) ) .call() @@ -1090,10 +1090,10 @@ export class FixedRateExchange { const estGas = await this.estSetRate( address, exchangeId, - await this.unitsToAmount(exchange.baseToken, newMarketFee) + await this.amountToUnits(exchange.baseToken, newMarketFee) ) const trxReceipt = await this.contract.methods - .updateMarketFee(exchangeId, this.unitsToAmount(exchange.baseToken, newMarketFee)) + .updateMarketFee(exchangeId, this.amountToUnits(exchange.baseToken, newMarketFee)) .send({ from: address, gas: estGas + 1, From b40d9f2b9327351efd99ae59ab499e7fdf59f569 Mon Sep 17 00:00:00 2001 From: Norbert Date: Thu, 3 Mar 2022 15:28:24 +0200 Subject: [PATCH 11/21] added await --- src/pools/fixedRate/FixedRateExchange.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pools/fixedRate/FixedRateExchange.ts b/src/pools/fixedRate/FixedRateExchange.ts index 6b1d6c0e1..959c3ba77 100644 --- a/src/pools/fixedRate/FixedRateExchange.ts +++ b/src/pools/fixedRate/FixedRateExchange.ts @@ -635,7 +635,7 @@ export class FixedRateExchange { .calcBaseOutGivenInDT( exchangeId, await this.amountToUnits(exchange.datatoken, datatokenAmount), - this.amountToUnits(exchange.baseToken, consumeMarketFee) + await this.amountToUnits(exchange.baseToken, consumeMarketFee) ) .call() @@ -1093,7 +1093,10 @@ export class FixedRateExchange { await this.amountToUnits(exchange.baseToken, newMarketFee) ) const trxReceipt = await this.contract.methods - .updateMarketFee(exchangeId, this.amountToUnits(exchange.baseToken, newMarketFee)) + .updateMarketFee( + exchangeId, + await this.amountToUnits(exchange.baseToken, newMarketFee) + ) .send({ from: address, gas: estGas + 1, From 81a3d3b531b79bd62328f81e4b9ed64b13d971aa Mon Sep 17 00:00:00 2001 From: Norbert Date: Fri, 4 Mar 2022 09:06:30 +0200 Subject: [PATCH 12/21] replaced String() with toSting() --- src/pools/fixedRate/FixedRateExchange.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/pools/fixedRate/FixedRateExchange.ts b/src/pools/fixedRate/FixedRateExchange.ts index 959c3ba77..72e8cd132 100644 --- a/src/pools/fixedRate/FixedRateExchange.ts +++ b/src/pools/fixedRate/FixedRateExchange.ts @@ -366,10 +366,13 @@ export class FixedRateExchange { const estGas = await this.estSetRate( address, exchangeId, - await this.amountToUnits(exchange.baseToken, String(newRate)) + await this.amountToUnits(exchange.baseToken, newRate.toString()) ) const trxReceipt = await this.contract.methods - .setRate(exchangeId, await this.amountToUnits(exchange.baseToken, String(newRate))) + .setRate( + exchangeId, + await this.amountToUnits(exchange.baseToken, newRate.toString()) + ) .send({ from: address, gas: estGas + 1, @@ -534,7 +537,14 @@ export class FixedRateExchange { */ public async getRate(exchangeId: string): Promise { const weiRate = await this.contract.methods.getRate(exchangeId).call() - return this.web3.utils.fromWei(weiRate) + const rate = await unitsToAmount( + this.web3, + ( + await this.getExchange(exchangeId) + ).baseToken, + weiRate + ) + return rate } /** From 31ee3f9de9e4e8917ae521f9d8284f3907678e3e Mon Sep 17 00:00:00 2001 From: Norbert Date: Fri, 4 Mar 2022 09:10:40 +0200 Subject: [PATCH 13/21] replaced String() in Provider --- src/provider/Provider.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/provider/Provider.ts b/src/provider/Provider.ts index 283647e1d..de2517fd9 100644 --- a/src/provider/Provider.ts +++ b/src/provider/Provider.ts @@ -100,7 +100,7 @@ export class Provider { }, signal: signal }) - return String((await response.json()).nonce) + return (await response.json()).nonce.toString() } catch (e) { LoggerInstance.error(e) throw new Error('HTTP request failed') @@ -623,7 +623,7 @@ export class Provider { let signatureMessage = accountId signatureMessage += jobId - signatureMessage += String(index) + signatureMessage += index.toString() signatureMessage += nonce const signature = await this.createHashSignature(web3, accountId, signatureMessage) From 81dd759d346d1ee1b398b515ff7c6c85c1544d3e Mon Sep 17 00:00:00 2001 From: Norbert Date: Fri, 4 Mar 2022 10:29:54 +0200 Subject: [PATCH 14/21] transform newRate into wei inside estimateSetRate --- src/pools/fixedRate/FixedRateExchange.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/pools/fixedRate/FixedRateExchange.ts b/src/pools/fixedRate/FixedRateExchange.ts index 72e8cd132..17ea9f161 100644 --- a/src/pools/fixedRate/FixedRateExchange.ts +++ b/src/pools/fixedRate/FixedRateExchange.ts @@ -337,12 +337,16 @@ export class FixedRateExchange { newRate: string, contractInstance?: Contract ): Promise { + const exchange = await this.getExchange(exchangeId) const fixedRate = contractInstance || this.fixedRateContract const gasLimitDefault = this.GASLIMIT_DEFAULT let estGas try { estGas = await fixedRate.methods - .setRate(exchangeId, newRate) + .setRate( + exchangeId, + await this.amountToUnits(exchange.baseToken, newRate.toString()) + ) .estimateGas({ from: account }, (err, estGas) => (err ? gasLimitDefault : estGas)) } catch (e) { estGas = gasLimitDefault @@ -363,11 +367,7 @@ export class FixedRateExchange { newRate: string ): Promise { const exchange = await this.getExchange(exchangeId) - const estGas = await this.estSetRate( - address, - exchangeId, - await this.amountToUnits(exchange.baseToken, newRate.toString()) - ) + const estGas = await this.estSetRate(address, exchangeId, newRate) const trxReceipt = await this.contract.methods .setRate( exchangeId, @@ -537,6 +537,8 @@ export class FixedRateExchange { */ public async getRate(exchangeId: string): Promise { const weiRate = await this.contract.methods.getRate(exchangeId).call() + console.log(weiRate) + console.log((await this.getExchange(exchangeId)).baseToken) const rate = await unitsToAmount( this.web3, ( @@ -544,6 +546,7 @@ export class FixedRateExchange { ).baseToken, weiRate ) + console.log(rate) return rate } From 433577a4ec6b9694e153adb0bf5d449ebe172363 Mon Sep 17 00:00:00 2001 From: Norbert Date: Fri, 4 Mar 2022 10:57:18 +0200 Subject: [PATCH 15/21] replace toWei inside getFreCreationParams --- src/factories/NFTFactory.ts | 4 ++-- src/utils/ContractUtils.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/factories/NFTFactory.ts b/src/factories/NFTFactory.ts index 96b03808f..5fd83f822 100644 --- a/src/factories/NFTFactory.ts +++ b/src/factories/NFTFactory.ts @@ -770,7 +770,7 @@ export class NftFactory { const ercCreateData = getErcCreationParams(ercParams) - const fixedData = getFreCreationParams(freParams) + const fixedData = await getFreCreationParams(freParams) try { estGas = await this.factory721.methods @@ -799,7 +799,7 @@ export class NftFactory { freParams: FreCreationParams ): Promise { const ercCreateData = getErcCreationParams(ercParams) - const fixedData = getFreCreationParams(freParams) + const fixedData = await getFreCreationParams(freParams) const estGas = await this.estGasCreateNftErc20WithFixedRate( address, diff --git a/src/utils/ContractUtils.ts b/src/utils/ContractUtils.ts index 20bbca70e..eb4a3c74e 100644 --- a/src/utils/ContractUtils.ts +++ b/src/utils/ContractUtils.ts @@ -64,7 +64,7 @@ export function getFreOrderParams(freParams: FreOrderParams): any { } } -export function getFreCreationParams(freParams: FreCreationParams): any { +export async function getFreCreationParams(freParams: FreCreationParams): Promise { if (!freParams.allowedConsumer) freParams.allowedConsumer = '0x0000000000000000000000000000000000000000' const withMint = freParams.withMint ? 1 : 0 @@ -80,7 +80,7 @@ export function getFreCreationParams(freParams: FreCreationParams): any { uints: [ freParams.baseTokenDecimals, freParams.datatokenDecimals, - Web3.utils.toWei(freParams.fixedRate), + await amountToUnits(this.web, freParams.baseTokenAddress, freParams.fixedRate), Web3.utils.toWei(freParams.marketFee), withMint ] From cbba765ece25d84d3309841eb634938c370d7f2d Mon Sep 17 00:00:00 2001 From: Norbert Date: Fri, 4 Mar 2022 11:04:28 +0200 Subject: [PATCH 16/21] added web3 param to getFreCreationParams --- src/factories/NFTFactory.ts | 4 ++-- src/utils/ContractUtils.ts | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/factories/NFTFactory.ts b/src/factories/NFTFactory.ts index 5fd83f822..7ffe551e1 100644 --- a/src/factories/NFTFactory.ts +++ b/src/factories/NFTFactory.ts @@ -770,7 +770,7 @@ export class NftFactory { const ercCreateData = getErcCreationParams(ercParams) - const fixedData = await getFreCreationParams(freParams) + const fixedData = await getFreCreationParams(freParams, this.web3) try { estGas = await this.factory721.methods @@ -799,7 +799,7 @@ export class NftFactory { freParams: FreCreationParams ): Promise { const ercCreateData = getErcCreationParams(ercParams) - const fixedData = await getFreCreationParams(freParams) + const fixedData = await getFreCreationParams(freParams, this.web3) const estGas = await this.estGasCreateNftErc20WithFixedRate( address, diff --git a/src/utils/ContractUtils.ts b/src/utils/ContractUtils.ts index eb4a3c74e..18213f5fb 100644 --- a/src/utils/ContractUtils.ts +++ b/src/utils/ContractUtils.ts @@ -64,7 +64,10 @@ export function getFreOrderParams(freParams: FreOrderParams): any { } } -export async function getFreCreationParams(freParams: FreCreationParams): Promise { +export async function getFreCreationParams( + freParams: FreCreationParams, + web3: Web3 +): Promise { if (!freParams.allowedConsumer) freParams.allowedConsumer = '0x0000000000000000000000000000000000000000' const withMint = freParams.withMint ? 1 : 0 @@ -80,7 +83,7 @@ export async function getFreCreationParams(freParams: FreCreationParams): Promis uints: [ freParams.baseTokenDecimals, freParams.datatokenDecimals, - await amountToUnits(this.web, freParams.baseTokenAddress, freParams.fixedRate), + await amountToUnits(web3, freParams.baseTokenAddress, freParams.fixedRate), Web3.utils.toWei(freParams.marketFee), withMint ] From bdc60a5f029b2c478088fb3569531ca81582fc2d Mon Sep 17 00:00:00 2001 From: Norbert Date: Fri, 4 Mar 2022 14:33:19 +0200 Subject: [PATCH 17/21] add amountToUnits inside getFreOrderParams --- src/factories/NFTFactory.ts | 2 +- src/pools/fixedRate/FixedRateExchange.ts | 9 +++------ src/tokens/Datatoken.ts | 2 +- src/utils/ContractUtils.ts | 11 +++++++++-- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/factories/NFTFactory.ts b/src/factories/NFTFactory.ts index 7ffe551e1..403631da3 100644 --- a/src/factories/NFTFactory.ts +++ b/src/factories/NFTFactory.ts @@ -798,7 +798,7 @@ export class NftFactory { ercParams: Erc20CreateParams, freParams: FreCreationParams ): Promise { - const ercCreateData = getErcCreationParams(ercParams) + const ercCreateData = await getErcCreationParams(ercParams) const fixedData = await getFreCreationParams(freParams, this.web3) const estGas = await this.estGasCreateNftErc20WithFixedRate( diff --git a/src/pools/fixedRate/FixedRateExchange.ts b/src/pools/fixedRate/FixedRateExchange.ts index 17ea9f161..893fd386a 100644 --- a/src/pools/fixedRate/FixedRateExchange.ts +++ b/src/pools/fixedRate/FixedRateExchange.ts @@ -327,7 +327,7 @@ export class FixedRateExchange { * Estimate gas cost for setRate * @param {String} account * @param {String} exchangeId ExchangeId - * @param {Number} newRate New rate + * @param {String} newRate New rate * @param {Contract} contractInstance optional contract instance * @return {Promise} */ @@ -357,7 +357,7 @@ export class FixedRateExchange { /** * Set new rate * @param {String} exchangeId ExchangeId - * @param {Number} newRate New rate + * @param {String} newRate New rate * @param {String} address User account * @return {Promise} transaction receipt */ @@ -369,10 +369,7 @@ export class FixedRateExchange { const exchange = await this.getExchange(exchangeId) const estGas = await this.estSetRate(address, exchangeId, newRate) const trxReceipt = await this.contract.methods - .setRate( - exchangeId, - await this.amountToUnits(exchange.baseToken, newRate.toString()) - ) + .setRate(exchangeId, await this.amountToUnits(exchange.baseToken, newRate)) .send({ from: address, gas: estGas + 1, diff --git a/src/tokens/Datatoken.ts b/src/tokens/Datatoken.ts index b63e911cc..d6d033a01 100644 --- a/src/tokens/Datatoken.ts +++ b/src/tokens/Datatoken.ts @@ -1052,7 +1052,7 @@ export class Datatoken { ): Promise { const dtContract = new this.web3.eth.Contract(this.datatokensEnterpriseAbi, dtAddress) try { - const freContractParams = getFreOrderParams(freParams) + const freContractParams = await getFreOrderParams(freParams, this.web3) const estGas = await this.estGasBuyFromFreAndOrder( dtAddress, diff --git a/src/utils/ContractUtils.ts b/src/utils/ContractUtils.ts index 18213f5fb..eea1d2d24 100644 --- a/src/utils/ContractUtils.ts +++ b/src/utils/ContractUtils.ts @@ -54,11 +54,18 @@ export function getErcCreationParams(ercParams: Erc20CreateParams): any { } } -export function getFreOrderParams(freParams: FreOrderParams): any { +export async function getFreOrderParams( + freParams: FreOrderParams, + web3: Web3 +): Promise { return { exchangeContract: freParams.exchangeContract, exchangeId: freParams.exchangeId, - maxBaseTokenAmount: Web3.utils.toWei(freParams.maxBaseTokenAmount), + maxBaseTokenAmount: await amountToUnits( + web3, + await this.getBaseToken(freParams.exchangeId), + freParams.maxBaseTokenAmount + ), swapMarketFee: Web3.utils.toWei(freParams.swapMarketFee), marketFeeAddress: freParams.marketFeeAddress } From 62cc124a95e952ff65952bf7f7727ee6fe1e6082 Mon Sep 17 00:00:00 2001 From: Norbert Date: Mon, 7 Mar 2022 12:13:49 +0200 Subject: [PATCH 18/21] added logs --- src/factories/NFTFactory.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/factories/NFTFactory.ts b/src/factories/NFTFactory.ts index 403631da3..daeb27702 100644 --- a/src/factories/NFTFactory.ts +++ b/src/factories/NFTFactory.ts @@ -770,8 +770,12 @@ export class NftFactory { const ercCreateData = getErcCreationParams(ercParams) + console.log(freParams) + const fixedData = await getFreCreationParams(freParams, this.web3) + console.log(fixedData) + try { estGas = await this.factory721.methods .createNftWithErc20WithFixedRate(nftCreateData, ercCreateData, fixedData) @@ -798,9 +802,12 @@ export class NftFactory { ercParams: Erc20CreateParams, freParams: FreCreationParams ): Promise { + console.log(freParams) const ercCreateData = await getErcCreationParams(ercParams) const fixedData = await getFreCreationParams(freParams, this.web3) + console.log(fixedData) + const estGas = await this.estGasCreateNftErc20WithFixedRate( address, nftCreateData, From 8dd8f34d677597e0104eb86d1144cbfa12049f70 Mon Sep 17 00:00:00 2001 From: Norbert Date: Tue, 8 Mar 2022 13:55:21 +0200 Subject: [PATCH 19/21] removed unitsToAmount from fixed rate --- src/factories/NFTFactory.ts | 7 +++---- src/pools/fixedRate/FixedRateExchange.ts | 17 +++-------------- src/tokens/Datatoken.ts | 2 +- src/utils/ContractUtils.ts | 18 ++++-------------- 4 files changed, 11 insertions(+), 33 deletions(-) diff --git a/src/factories/NFTFactory.ts b/src/factories/NFTFactory.ts index daeb27702..61359e124 100644 --- a/src/factories/NFTFactory.ts +++ b/src/factories/NFTFactory.ts @@ -772,7 +772,7 @@ export class NftFactory { console.log(freParams) - const fixedData = await getFreCreationParams(freParams, this.web3) + const fixedData = await getFreCreationParams(freParams) console.log(fixedData) @@ -802,9 +802,8 @@ export class NftFactory { ercParams: Erc20CreateParams, freParams: FreCreationParams ): Promise { - console.log(freParams) - const ercCreateData = await getErcCreationParams(ercParams) - const fixedData = await getFreCreationParams(freParams, this.web3) + const ercCreateData = getErcCreationParams(ercParams) + const fixedData = getFreCreationParams(freParams) console.log(fixedData) diff --git a/src/pools/fixedRate/FixedRateExchange.ts b/src/pools/fixedRate/FixedRateExchange.ts index 893fd386a..f79ea3471 100644 --- a/src/pools/fixedRate/FixedRateExchange.ts +++ b/src/pools/fixedRate/FixedRateExchange.ts @@ -337,16 +337,12 @@ export class FixedRateExchange { newRate: string, contractInstance?: Contract ): Promise { - const exchange = await this.getExchange(exchangeId) const fixedRate = contractInstance || this.fixedRateContract const gasLimitDefault = this.GASLIMIT_DEFAULT let estGas try { estGas = await fixedRate.methods - .setRate( - exchangeId, - await this.amountToUnits(exchange.baseToken, newRate.toString()) - ) + .setRate(exchangeId, await this.web3.utils.toWei(newRate)) .estimateGas({ from: account }, (err, estGas) => (err ? gasLimitDefault : estGas)) } catch (e) { estGas = gasLimitDefault @@ -366,10 +362,9 @@ export class FixedRateExchange { exchangeId: string, newRate: string ): Promise { - const exchange = await this.getExchange(exchangeId) const estGas = await this.estSetRate(address, exchangeId, newRate) const trxReceipt = await this.contract.methods - .setRate(exchangeId, await this.amountToUnits(exchange.baseToken, newRate)) + .setRate(exchangeId, this.web3.utils.toWei(newRate)) .send({ from: address, gas: estGas + 1, @@ -536,13 +531,7 @@ export class FixedRateExchange { const weiRate = await this.contract.methods.getRate(exchangeId).call() console.log(weiRate) console.log((await this.getExchange(exchangeId)).baseToken) - const rate = await unitsToAmount( - this.web3, - ( - await this.getExchange(exchangeId) - ).baseToken, - weiRate - ) + const rate = await this.web3.utils.fromWei(weiRate) console.log(rate) return rate } diff --git a/src/tokens/Datatoken.ts b/src/tokens/Datatoken.ts index d6d033a01..b63e911cc 100644 --- a/src/tokens/Datatoken.ts +++ b/src/tokens/Datatoken.ts @@ -1052,7 +1052,7 @@ export class Datatoken { ): Promise { const dtContract = new this.web3.eth.Contract(this.datatokensEnterpriseAbi, dtAddress) try { - const freContractParams = await getFreOrderParams(freParams, this.web3) + const freContractParams = getFreOrderParams(freParams) const estGas = await this.estGasBuyFromFreAndOrder( dtAddress, diff --git a/src/utils/ContractUtils.ts b/src/utils/ContractUtils.ts index eea1d2d24..20bbca70e 100644 --- a/src/utils/ContractUtils.ts +++ b/src/utils/ContractUtils.ts @@ -54,27 +54,17 @@ export function getErcCreationParams(ercParams: Erc20CreateParams): any { } } -export async function getFreOrderParams( - freParams: FreOrderParams, - web3: Web3 -): Promise { +export function getFreOrderParams(freParams: FreOrderParams): any { return { exchangeContract: freParams.exchangeContract, exchangeId: freParams.exchangeId, - maxBaseTokenAmount: await amountToUnits( - web3, - await this.getBaseToken(freParams.exchangeId), - freParams.maxBaseTokenAmount - ), + maxBaseTokenAmount: Web3.utils.toWei(freParams.maxBaseTokenAmount), swapMarketFee: Web3.utils.toWei(freParams.swapMarketFee), marketFeeAddress: freParams.marketFeeAddress } } -export async function getFreCreationParams( - freParams: FreCreationParams, - web3: Web3 -): Promise { +export function getFreCreationParams(freParams: FreCreationParams): any { if (!freParams.allowedConsumer) freParams.allowedConsumer = '0x0000000000000000000000000000000000000000' const withMint = freParams.withMint ? 1 : 0 @@ -90,7 +80,7 @@ export async function getFreCreationParams( uints: [ freParams.baseTokenDecimals, freParams.datatokenDecimals, - await amountToUnits(web3, freParams.baseTokenAddress, freParams.fixedRate), + Web3.utils.toWei(freParams.fixedRate), Web3.utils.toWei(freParams.marketFee), withMint ] From a62666df6f41b23757eda47bb46681ed226b26cd Mon Sep 17 00:00:00 2001 From: Norbert Date: Tue, 8 Mar 2022 14:03:32 +0200 Subject: [PATCH 20/21] removed amountToUnits inside marketFee --- src/pools/fixedRate/FixedRateExchange.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/pools/fixedRate/FixedRateExchange.ts b/src/pools/fixedRate/FixedRateExchange.ts index f79ea3471..3619d357b 100644 --- a/src/pools/fixedRate/FixedRateExchange.ts +++ b/src/pools/fixedRate/FixedRateExchange.ts @@ -1085,17 +1085,13 @@ export class FixedRateExchange { exchangeId: string, newMarketFee: string ): Promise { - const exchange = await this.getExchange(exchangeId) const estGas = await this.estSetRate( address, exchangeId, - await this.amountToUnits(exchange.baseToken, newMarketFee) + this.web3.utils.toWei(newMarketFee) ) const trxReceipt = await this.contract.methods - .updateMarketFee( - exchangeId, - await this.amountToUnits(exchange.baseToken, newMarketFee) - ) + .updateMarketFee(exchangeId, this.web3.utils.toWei(newMarketFee)) .send({ from: address, gas: estGas + 1, From cee1bc21639abd9af137143a5fc5b4add52555b0 Mon Sep 17 00:00:00 2001 From: Norbert Date: Tue, 8 Mar 2022 14:11:05 +0200 Subject: [PATCH 21/21] removed logs --- src/factories/NFTFactory.ts | 7 ------- src/pools/fixedRate/FixedRateExchange.ts | 3 --- 2 files changed, 10 deletions(-) diff --git a/src/factories/NFTFactory.ts b/src/factories/NFTFactory.ts index 61359e124..1e9a92ad2 100644 --- a/src/factories/NFTFactory.ts +++ b/src/factories/NFTFactory.ts @@ -769,13 +769,8 @@ export class NftFactory { let estGas const ercCreateData = getErcCreationParams(ercParams) - - console.log(freParams) - const fixedData = await getFreCreationParams(freParams) - console.log(fixedData) - try { estGas = await this.factory721.methods .createNftWithErc20WithFixedRate(nftCreateData, ercCreateData, fixedData) @@ -805,8 +800,6 @@ export class NftFactory { const ercCreateData = getErcCreationParams(ercParams) const fixedData = getFreCreationParams(freParams) - console.log(fixedData) - const estGas = await this.estGasCreateNftErc20WithFixedRate( address, nftCreateData, diff --git a/src/pools/fixedRate/FixedRateExchange.ts b/src/pools/fixedRate/FixedRateExchange.ts index 3619d357b..3883ec969 100644 --- a/src/pools/fixedRate/FixedRateExchange.ts +++ b/src/pools/fixedRate/FixedRateExchange.ts @@ -529,10 +529,7 @@ export class FixedRateExchange { */ public async getRate(exchangeId: string): Promise { const weiRate = await this.contract.methods.getRate(exchangeId).call() - console.log(weiRate) - console.log((await this.getExchange(exchangeId)).baseToken) const rate = await this.web3.utils.fromWei(weiRate) - console.log(rate) return rate }