Skip to content

Commit

Permalink
Merge pull request #303 from reservoirprotocol/feature/tweak-price-im…
Browse files Browse the repository at this point in the history
…pact

Tweak Price impact and improve no instant liquidity ux
  • Loading branch information
pedromcunha authored Oct 14, 2024
2 parents 6e35308 + af05332 commit d83ae10
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/giant-cars-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@reservoir0x/relay-kit-ui': patch
---

Improve price impact, handle no instant liquidity ux
5 changes: 3 additions & 2 deletions packages/ui/src/components/widgets/SwapWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -829,9 +829,10 @@ const SwapWidget: FC<SwapWidgetProps> = ({
mb: '6px'
}}
/>
{isCapacityExceededError && supportsExternalLiquidity ? (
{error && supportsExternalLiquidity ? (
<Flex css={{ mt: '6px', gap: '3' }}>
{maxCapacityFormatted != '0' ? (
{isCapacityExceededError &&
maxCapacityFormatted != '0' ? (
<Button
color="white"
css={{ flexGrow: '1', justifyContent: 'center' }}
Expand Down
21 changes: 21 additions & 0 deletions packages/ui/src/components/widgets/WidgetErrorWell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,27 @@ export const WidgetErrorWell: FC<Props> = ({
</Text>
</Flex>
)
} else if (supportsExternalLiquidity && currency) {
return (
<Flex
align="center"
css={{
gap: '2',
p: '3',
backgroundColor: 'red2',
borderRadius: 12,
mb: '3',
...containerCss
}}
>
<Box css={{ color: 'red10' }}>
<FontAwesomeIcon icon={faExclamationCircle} width={16} />
</Box>
<Text style="subtitle3" css={{ color: 'red12' }}>
{fetchQuoteErrorMessage} Please switch to the native route.
</Text>
</Flex>
)
} else {
return (
<Flex
Expand Down
8 changes: 6 additions & 2 deletions packages/ui/src/utils/quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,12 @@ export const isHighRelayerServiceFeeUsd = (quote?: QuoteResponse) => {
return false
}

const fivePercentOfUsdIn = (usdIn * 5) / 100
return relayerServiceFeeUsd >= fivePercentOfUsdIn
const feeThresholdPercentage = (usdIn * 2.5) / 100
const feeThresholdUsd = 25
return (
relayerServiceFeeUsd > feeThresholdPercentage &&
relayerServiceFeeUsd > feeThresholdUsd
)
}

export const extractQuoteId = (steps?: Execute['steps']) => {
Expand Down

0 comments on commit d83ae10

Please sign in to comment.