Skip to content
Merged
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
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
48 changes: 4 additions & 44 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 @@ -527,47 +526,9 @@ const SwapWidgetRenderer: FC<SwapWidgetRendererProps> = ({
fromChain?.protocol?.v2?.depository !== undefined &&
toChain?.protocol?.v2?.chainId !== undefined

const quoteProtocol = useMemo(() => {
//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
} else {
return undefined
}
}, [
fromTokenPriceData,
isLoadingFromTokenPrice,
debouncedInputAmountValue,
tradeType,
originChainSupportsProtocolv2,
fromChain?.id
])

const loadingProtocolVersion =
fromChain?.id && originChainSupportsProtocolv2 && isLoadingFromTokenPrice
//Enabled only on certain chains
const quoteProtocol =
fromChain?.id && originChainSupportsProtocolv2 ? 'preferV2' : undefined

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

const {
Expand Down