Skip to content

Commit

Permalink
Add DFNDR FOT test case for fee exclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
jsy1218 committed Jul 18, 2024
1 parent d379409 commit e7d8d47
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/mocha/e2e/quote.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,24 @@ const BULLET_WHT_TAX = new Token(
BigNumber.from(500),
BigNumber.from(500)
)
export const DFNDR = new Token(
ChainId.MAINNET,
'0x3f57c35633cb29834bb7577ba8052eab90f52a02',
18,
'DFNDR',
'Defender Bot',
false
)
export const DFNDR_WITH_TAX = new Token(
ChainId.MAINNET,
'0x3f57c35633cb29834bb7577ba8052eab90f52a02',
18,
'DFNDR',
'Defender Bot',
false,
BigNumber.from(500),
BigNumber.from(500)
)

const V2_SUPPORTED_PAIRS = [
[WETH9[ChainId.ARBITRUM_ONE], USDC_NATIVE_ARBITRUM],
Expand Down Expand Up @@ -1114,6 +1132,7 @@ describe('quote', function () {
const tokenInAndTokenOut = [
[BULLET, WETH9[ChainId.MAINNET]!],
[WETH9[ChainId.MAINNET]!, BULLET],
[WETH9[ChainId.MAINNET]!, DFNDR],
]

tokenInAndTokenOut.forEach(([tokenIn, tokenOut]) => {
Expand Down Expand Up @@ -1156,9 +1175,12 @@ describe('quote', function () {
enableUniversalRouter: true,
// if fee-on-transfer flag is not enabled, most likely the simulation will fail due to quote not subtracting the tax
simulateFromAddress: enableFeeOnTransferFeeFetching ? simulateFromAddress : undefined,
portionBips: FLAT_PORTION.bips,
portionRecipient: FLAT_PORTION.recipient
}

const queryParams = qs.stringify(quoteReq)
console.log(`${API}?${queryParams}`)

const response: AxiosResponse<QuoteResponse> = await axios.get<QuoteResponse>(
`${API}?${queryParams}`
Expand Down Expand Up @@ -1193,6 +1215,13 @@ describe('quote', function () {
new Fraction(BigNumber.from(BULLET_WHT_TAX.buyFeeBps ?? 0).toString(), 10_000).toFixed(3)
)
}

// in case of FOT token that should not take a portion/fee, we assert that all portion fields are undefined
if (tokenOut?.equals(DFNDR)) {
expect(r.data.portionAmount).to.be.undefined
expect(r.data.portionBips).to.be.undefined
expect(r.data.portionRecipient).to.be.undefined
}
}
})

Expand Down

0 comments on commit e7d8d47

Please sign in to comment.