From d8e3caf6784f00f9395b5052b4b77a4c519ea379 Mon Sep 17 00:00:00 2001 From: Fuxing Loh <4266087+fuxingloh@users.noreply.github.com> Date: Tue, 22 Feb 2022 02:12:13 +0800 Subject: [PATCH] due to hard fork upgrades on PoolPairHistory Data this is not representative of actual DfTx (#798) --- src/module.indexer/model/dftx/composite.swap.ts | 10 ++++------ src/module.indexer/model/dftx/create.pool.pair.ts | 1 + 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/module.indexer/model/dftx/composite.swap.ts b/src/module.indexer/model/dftx/composite.swap.ts index a96328224..f4cf815be 100644 --- a/src/module.indexer/model/dftx/composite.swap.ts +++ b/src/module.indexer/model/dftx/composite.swap.ts @@ -9,8 +9,6 @@ import { NetworkName } from '@defichain/jellyfish-network' import { IndexerError } from '@src/module.indexer/error' import BigNumber from 'bignumber.js' -const ONE = new BigNumber(1.0) - @Injectable() export class CompositeSwapIndexer extends DfTxIndexer { OP_CODE: number = CCompositeSwap.OP_CODE @@ -29,12 +27,12 @@ export class CompositeSwapIndexer extends DfTxIndexer { const poolSwap = data.poolSwap const poolIds = await this.getPoolIdsForTokens(data) - let fromAmount: BigNumber = poolSwap.fromAmount + const fromAmount: BigNumber = poolSwap.fromAmount for (const pool of poolIds) { const poolPair = await this.getPoolPair(pool.id) await this.poolSwapIndexer.indexSwap(block, transaction, poolPair.poolPairId, poolSwap.fromTokenId, fromAmount) - fromAmount = ONE.minus(poolPair.commission).times(fromAmount) + // fromAmount = ONE.minus(poolPair.commission).times(fromAmount) } } @@ -43,12 +41,12 @@ export class CompositeSwapIndexer extends DfTxIndexer { const poolSwap = data.poolSwap const poolIds = await this.getPoolIdsForTokens(data) - let fromAmount: BigNumber = poolSwap.fromAmount + const fromAmount: BigNumber = poolSwap.fromAmount for (const pool of poolIds) { const poolPair = await this.getPoolPair(pool.id) await this.poolSwapIndexer.invalidateSwap(transaction, poolPair.poolPairId, poolSwap.fromTokenId, fromAmount) - fromAmount = ONE.minus(poolPair.commission).times(fromAmount) + // fromAmount = ONE.minus(poolPair.commission).times(fromAmount) } } diff --git a/src/module.indexer/model/dftx/create.pool.pair.ts b/src/module.indexer/model/dftx/create.pool.pair.ts index 9bf77d40c..cdb69d74d 100644 --- a/src/module.indexer/model/dftx/create.pool.pair.ts +++ b/src/module.indexer/model/dftx/create.pool.pair.ts @@ -51,6 +51,7 @@ export class CreatePoolPairIndexer extends DfTxIndexer { const pairSymbol = this.getPairSymbol(tokenA, tokenB, block, transaction) + // due to hard fork upgrades on PoolPair Data this is not representative of actual DfTx await this.poolPairHistoryMapper.put({ id: txid, sort: HexEncoder.encodeHeight(block.height) + HexEncoder.encodeHeight(transaction.txnNo),