From 617bf7fe33fa855c2c552a43bde85f2ce788fae6 Mon Sep 17 00:00:00 2001 From: alexcos20 Date: Tue, 13 Oct 2020 09:01:53 -0700 Subject: [PATCH 1/3] remove duplicate totalSupply --- src/balancer/Pool.ts | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/balancer/Pool.ts b/src/balancer/Pool.ts index c09f5955..60ab4cda 100644 --- a/src/balancer/Pool.ts +++ b/src/balancer/Pool.ts @@ -157,24 +157,6 @@ export class Pool extends PoolFactory { return result } - /** - * Get total supply of pool tokens - * @param {String} poolAddress - * @return {String} - */ - async totalSupply(poolAddress: string): Promise { - let result = null - - try { - const pool = new this.web3.eth.Contract(this.poolABI, poolAddress) - const totalSupply = await pool.methods.totalSupply().call() - result = this.web3.utils.fromWei(totalSupply) - } catch (e) { - console.error(e) - } - return result - } - /** * Adds tokens to pool * @param {String} account From a6d79c020a557bb34b4f986942e740d5adf4ce0a Mon Sep 17 00:00:00 2001 From: alexcos20 Date: Tue, 13 Oct 2020 10:10:58 -0700 Subject: [PATCH 2/3] fix balancer test --- test/unit/balancer/Balancer.test.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/unit/balancer/Balancer.test.ts b/test/unit/balancer/Balancer.test.ts index d5208885..c4fe4c9a 100644 --- a/test/unit/balancer/Balancer.test.ts +++ b/test/unit/balancer/Balancer.test.ts @@ -14,6 +14,13 @@ import OceanPoolFactory from '@oceanprotocol/contracts/artifacts/BFactory.json' import OceanSPool from '@oceanprotocol/contracts/artifacts/BPool.json' const web3 = new Web3('http://127.0.0.1:8545') + +function sleep(ms: number) { + return new Promise((resolve) => { + setTimeout(resolve, ms) + }) +} + describe('Balancer flow', () => { let oceanTokenAddress: string let OceanPoolFactoryAddress: string @@ -116,7 +123,7 @@ describe('Balancer flow', () => { it('Alice creates a new OceanPool pool', async () => { /// new pool with total DT = 45 , dt weight=90% with swap fee 2% alicePoolAddress = await Pool.createDTPool(alice, tokenAddress, '45', '9', '0.02') - const s = await Pool.totalSupply(alicePoolAddress) + const s = await Pool.getPoolSharesTotalSupply(alicePoolAddress) assert(String(s) === '100', 'totalSupply does not match: ' + s) const n = await Pool.getNumTokens(alicePoolAddress) assert(String(n) === '2', 'unexpected num tokens: ' + n) @@ -164,7 +171,7 @@ describe('Balancer flow', () => { assert(Number(currentOceanReserve) > 0) }) it('Get total supply of pool tokens', async () => { - const totalSupply = await Pool.totalSupply(alicePoolAddress) + const totalSupply = await Pool.getPoolSharesTotalSupply(alicePoolAddress) assert(Number(totalSupply) > 0) }) it('Get amount of Ocean needed to buy 1 dtToken', async () => { From 9cad5231505b89b75eb066e8131434593ae24eca Mon Sep 17 00:00:00 2001 From: alexcos20 Date: Tue, 13 Oct 2020 10:21:23 -0700 Subject: [PATCH 3/3] fix balancer test --- test/unit/balancer/Balancer.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/unit/balancer/Balancer.test.ts b/test/unit/balancer/Balancer.test.ts index c4fe4c9a..d574ac80 100644 --- a/test/unit/balancer/Balancer.test.ts +++ b/test/unit/balancer/Balancer.test.ts @@ -14,7 +14,6 @@ import OceanPoolFactory from '@oceanprotocol/contracts/artifacts/BFactory.json' import OceanSPool from '@oceanprotocol/contracts/artifacts/BPool.json' const web3 = new Web3('http://127.0.0.1:8545') - function sleep(ms: number) { return new Promise((resolve) => { setTimeout(resolve, ms)