Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 5 additions & 0 deletions .changeset/tame-buckets-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@relayprotocol/relay-kit-ui': patch
---

Remove protocol v2 threshold
41 changes: 3 additions & 38 deletions packages/ui/src/components/widgets/SwapWidgetRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import type { ChainVM, Execute } from '@relayprotocol/relay-sdk'
import {
calculatePriceTimeEstimate,
calculateRelayerFeeProportionUsd,
calculateUsdValue,
extractQuoteId,
getCurrentStep,
getSwapEventData,
Expand Down Expand Up @@ -530,44 +529,11 @@ const SwapWidgetRenderer: FC<SwapWidgetRendererProps> = ({
const quoteProtocol = useMemo(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can just change this from a memo to a simple variable since it's no longer doing anything complex

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch! fixed!

//Enabled only on certain chains
if (fromChain?.id && originChainSupportsProtocolv2) {
if (!fromToken && !fromTokenPriceData) {
return undefined
}

const relevantPrice =
fromTokenPriceData?.price && !isLoadingFromTokenPrice
? fromTokenPriceData.price
: undefined
const amount =
tradeType === 'EXACT_INPUT'
? debouncedInputAmountValue
: debouncedOutputAmountValue

if (!amount) {
return undefined
}

const usdAmount = relevantPrice
? calculateUsdValue(relevantPrice, amount)
: undefined

return usdAmount !== undefined && usdAmount <= 10000
? 'preferV2'
: undefined
return 'preferV2'
} else {
return undefined
}
}, [
fromTokenPriceData,
isLoadingFromTokenPrice,
debouncedInputAmountValue,
tradeType,
originChainSupportsProtocolv2,
fromChain?.id
])

const loadingProtocolVersion =
fromChain?.id && originChainSupportsProtocolv2 && isLoadingFromTokenPrice
}, [originChainSupportsProtocolv2, fromChain?.id])

// Get native balance only when not swapping from native token
const isFromNative = fromToken?.address === fromChain?.currency?.address
Expand Down Expand Up @@ -725,8 +691,7 @@ const SwapWidgetRenderer: FC<SwapWidgetRendererProps> = ({
fromToken !== undefined &&
toToken !== undefined &&
!transactionModalOpen &&
!depositAddressModalOpen &&
!loadingProtocolVersion
!depositAddressModalOpen
)

const {
Expand Down