-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(twap): display "Minimum sell size" banner only when there is a bu…
…y amount (#3064)
- Loading branch information
Showing
3 changed files
with
57 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
apps/cowswap-frontend/src/modules/twap/pure/PrimaryActionButton/getTwapFormState.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { CurrencyAmount } from '@uniswap/sdk-core' | ||
|
||
import { COW } from 'legacy/constants/tokens' | ||
import { WETH_GOERLI } from 'legacy/utils/goerli/constants' | ||
|
||
import { getTwapFormState, TwapFormState } from './getTwapFormState' | ||
|
||
import { ExtensibleFallbackVerification } from '../../services/verifyExtensibleFallback' | ||
import { TWAPOrder } from '../../types' | ||
|
||
const COW_GOERLI = COW[5] | ||
|
||
const twapOrder: TWAPOrder = { | ||
sellAmount: CurrencyAmount.fromRawAmount(WETH_GOERLI, 10000000), | ||
buyAmount: CurrencyAmount.fromRawAmount(COW_GOERLI, 10000000), | ||
receiver: '0x00000000000000001', | ||
numOfParts: 1, | ||
startTime: 1000000, | ||
timeInterval: 200, | ||
span: 0, | ||
appData: '0x000000', | ||
} | ||
|
||
describe('getTwapFormState()', () => { | ||
describe('When sell fiat amount is under threshold', () => { | ||
it('And order has buy amount, then should return SELL_AMOUNT_TOO_SMALL', () => { | ||
const result = getTwapFormState({ | ||
isSafeApp: true, | ||
verification: ExtensibleFallbackVerification.HAS_DOMAIN_VERIFIER, | ||
twapOrder: { ...twapOrder }, | ||
sellAmountPartFiat: CurrencyAmount.fromRawAmount(WETH_GOERLI, 10000000), | ||
chainId: 1, | ||
partTime: 1000000, | ||
}) | ||
|
||
expect(result).toEqual(TwapFormState.SELL_AMOUNT_TOO_SMALL) | ||
}) | ||
|
||
it('And order does NOT have buy amount, then should return null', () => { | ||
const result = getTwapFormState({ | ||
isSafeApp: true, | ||
verification: ExtensibleFallbackVerification.HAS_DOMAIN_VERIFIER, | ||
twapOrder: { ...twapOrder, buyAmount: CurrencyAmount.fromRawAmount(COW_GOERLI, 0) }, | ||
sellAmountPartFiat: CurrencyAmount.fromRawAmount(WETH_GOERLI, 10000000), | ||
chainId: 1, | ||
partTime: 1000000, | ||
}) | ||
|
||
expect(result).toEqual(null) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters