Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(apps/whale-api): update poolpairs to ignore token symbols with BURN #2085

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions apps/whale-api/src/module.api/poolpair.controller.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,18 @@ async function setup (): Promise<void> {
shareAddress: await getNewAddress(container)
})

// BURN2 should not be listed as Swappable
await createToken(container, 'BURN2')
await createPoolPair(container, 'BURN2', 'DFI', { status: false })
await mintTokens(container, 'BURN2', { mintAmount: 1 })
await addPoolLiquidity(container, {
tokenA: 'BURN2',
amountA: 1,
tokenB: 'DFI',
amountB: 1,
shareAddress: await getNewAddress(container)
})

await container.call('setgov', [{ LP_SPLITS: { 16: 1.0 } }])
await container.generate(1)

Expand Down Expand Up @@ -266,6 +278,15 @@ describe('list', () => {
})
})

it('list should not include any poolpairs with BURN', async () => {
const response = await controller.list({
size: 30
})
const burnTokens = ['BURN', 'BURN2']

expect(response.data.some(poolpair => burnTokens.includes(poolpair.symbol))).toBe(false)
})

it('should list with pagination', async () => {
const first = await controller.list({
size: 2
Expand All @@ -276,7 +297,7 @@ describe('list', () => {
expect(first.data[1].symbol).toStrictEqual('B-DFI')

const next = await controller.list({
size: 14,
size: 15,
next: first.page?.next
})

Expand Down Expand Up @@ -972,8 +993,9 @@ describe('get list swappable tokens', () => {

it('should not show status:false tokens', async () => {
const result = await controller.listSwappableTokens('1') // A
expect(result.swappableTokens.map(token => token.symbol))
.not.toContain('BURN')
const unswappableTokens = ['BURN', 'BURN2']

expect(result.swappableTokens.some(token => unswappableTokens.includes(token.symbol))).toBe(false)
})

it('should list no tokens for token that is not swappable with any', async () => {
Expand Down Expand Up @@ -1206,6 +1228,14 @@ describe('latest dex prices', () => {
await expect(controller.listDexPrices('BURN'))
.rejects
.toThrowError('Token \'BURN\' is invalid as it is not tradeable')

// BURN2 not included in any denominated dex prices
expect(result.dexPrices.BURN2).toBeUndefined()

// BURN2 is not a valid 'denomination' token
await expect(controller.listDexPrices('BURN2'))
.rejects
.toThrowError('Token \'BURN2\' is invalid as it is not tradeable')
})

describe('param validation - denomination', () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/whale-api/src/module.api/poolpair.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class PoolPairController {
return item.id
})
response.data = response.data.filter(value => {
return !value.symbol.startsWith('BURN-')
return !value.symbol.includes('BURN')
kyleleow marked this conversation as resolved.
Show resolved Hide resolved
})
return response
}
Expand Down
2 changes: 1 addition & 1 deletion apps/whale-api/src/module.api/poolpair.prices.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class PoolPairPricesService {
}

private isUntradeableToken (token: TokenInfoWithId): boolean {
return token.isLPS || !token.isDAT || token.symbol === 'BURN' || !token.tradeable
return token.isLPS || !token.isDAT || token.symbol.includes('BURN') || !token.tradeable
}
}

Expand Down