diff --git a/packages/whale-api-client/__tests__/api/poolpairs.test.ts b/packages/whale-api-client/__tests__/api/poolpairs.test.ts index 2c6c6799c..5f8d387fd 100644 --- a/packages/whale-api-client/__tests__/api/poolpairs.test.ts +++ b/packages/whale-api-client/__tests__/api/poolpairs.test.ts @@ -449,12 +449,14 @@ describe('poolswap', () => { from: { address: expect.any(String), symbol: 'A', - amount: '123.00000000' + amount: '123.00000000', + displaySymbol: 'dA' }, to: { address: expect.any(String), amount: '10.42667420', - symbol: 'C' + symbol: 'C', + displaySymbol: 'dC' } }, { @@ -474,12 +476,14 @@ describe('poolswap', () => { from: { address: expect.any(String), symbol: 'A', - amount: '50.00000000' + amount: '50.00000000', + displaySymbol: 'dA' }, to: { address: expect.any(String), amount: '45.71428571', - symbol: 'DFI' + symbol: 'DFI', + displaySymbol: 'DFI' } }, { @@ -499,12 +503,14 @@ describe('poolswap', () => { from: { address: expect.any(String), symbol: 'A', - amount: '25.00000000' + amount: '25.00000000', + displaySymbol: 'dA' }, to: { address: expect.any(String), amount: '39.99999999', - symbol: 'DFI' + symbol: 'DFI', + displaySymbol: 'DFI' } } ]) diff --git a/packages/whale-api-client/src/api/poolpairs.ts b/packages/whale-api-client/src/api/poolpairs.ts index e62371915..e96c50a9c 100644 --- a/packages/whale-api-client/src/api/poolpairs.ts +++ b/packages/whale-api-client/src/api/poolpairs.ts @@ -156,6 +156,7 @@ export interface PoolSwapFromToData { address: string amount: string symbol: string + displaySymbol: string } export interface PoolSwapAggregatedData { diff --git a/src/module.api/poolpair.service.ts b/src/module.api/poolpair.service.ts index 19c76ac0e..fc7644b15 100644 --- a/src/module.api/poolpair.service.ts +++ b/src/module.api/poolpair.service.ts @@ -23,6 +23,7 @@ import { fromScript } from '@defichain/jellyfish-address' import { NetworkName } from '@defichain/jellyfish-network' import { AccountHistory } from '@defichain/jellyfish-api-core/dist/category/account' import { DeFiDCache } from '@src/module.api/cache/defid.cache' +import { parseDisplaySymbol } from '@src/module.api/token.controller' import { UndirectedGraph } from 'graphology' import { PoolPairToken, PoolPairTokenMapper } from '@src/module.model/pool.pair.token' import { Interval } from '@nestjs/schedule' @@ -234,7 +235,9 @@ export class PoolPairService { const fromToken = await this.deFiDCache.getTokenInfo(dftx.fromTokenId.toString()) const toAddress = fromScript(dftx.toScript, this.network)?.address - if (fromAddress === undefined || toAddress === undefined || fromToken === undefined) { + const toToken = await this.deFiDCache.getTokenInfo(dftx.toTokenId.toString()) + + if (fromAddress === undefined || toAddress === undefined || fromToken === undefined || toToken === undefined) { return undefined } @@ -244,9 +247,10 @@ export class PoolPairService { from: { address: fromAddress, symbol: fromToken.symbol, - amount: dftx.fromAmount.toFixed(8) + amount: dftx.fromAmount.toFixed(8), + displaySymbol: parseDisplaySymbol(fromToken) }, - to: findPoolSwapFromTo(history, false) + to: findPoolSwapFromTo(history, false, parseDisplaySymbol(toToken)) } } @@ -402,7 +406,7 @@ function findPoolSwapDfTx (vouts: TransactionVout[]): PoolSwapDfTx | undefined { } } -function findPoolSwapFromTo (history: AccountHistory | undefined, from: boolean): PoolSwapFromToData | undefined { +function findPoolSwapFromTo (history: AccountHistory | undefined, from: boolean, displaySymbol: string): PoolSwapFromToData | undefined { if (history?.amounts === undefined) { return undefined } @@ -415,7 +419,8 @@ function findPoolSwapFromTo (history: AccountHistory | undefined, from: boolean) return { address: history.owner, amount: new BigNumber(value).absoluteValue().toFixed(8), - symbol: symbol + symbol: symbol, + displaySymbol: displaySymbol } } @@ -423,7 +428,8 @@ function findPoolSwapFromTo (history: AccountHistory | undefined, from: boolean) return { address: history.owner, amount: new BigNumber(value).absoluteValue().toFixed(8), - symbol: symbol + symbol: symbol, + displaySymbol: displaySymbol } } }