Skip to content
This repository has been archived by the owner on Jun 3, 2022. It is now read-only.

Commit

Permalink
due to hard fork upgrades on PoolPairHistory Data this is not represe…
Browse files Browse the repository at this point in the history
…ntative of actual DfTx (#798)
  • Loading branch information
fuxingloh authored Feb 21, 2022
1 parent 6418fc9 commit d8e3caf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/module.indexer/model/dftx/composite.swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<CompositeSwap> {
OP_CODE: number = CCompositeSwap.OP_CODE
Expand All @@ -29,12 +27,12 @@ export class CompositeSwapIndexer extends DfTxIndexer<CompositeSwap> {
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)
}
}

Expand All @@ -43,12 +41,12 @@ export class CompositeSwapIndexer extends DfTxIndexer<CompositeSwap> {
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)
}
}

Expand Down
1 change: 1 addition & 0 deletions src/module.indexer/model/dftx/create.pool.pair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class CreatePoolPairIndexer extends DfTxIndexer<PoolCreatePair> {

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),
Expand Down

0 comments on commit d8e3caf

Please sign in to comment.