Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add lifi swap quote provider #65

Merged
merged 14 commits into from
Jun 27, 2024

Conversation

janndriessen
Copy link
Collaborator

@janndriessen janndriessen commented Jun 19, 2024

  • Adds LiFiSwapQuoteProvider - an adapter for swap quotes as an alternative to 0x

What's different from 0x?

  • LiFi needs a fromAddress, so the address was added to the SwapQuoteRequest

TODOs

  • add constructing swap data
  • more tests e.g. w/ Arbitrum
  • update docs w/ swap quote provider section?
  • run integration tests using LiFiSwapQuoteProvider for ultimate test

@janndriessen janndriessen force-pushed the feat/add-lifi-swap-quote-provider branch from dea0de3 to bf2afbc Compare June 20, 2024 14:15
@janndriessen janndriessen force-pushed the feat/add-lifi-swap-quote-provider branch from 1ac6b5b to 6dac9e3 Compare June 25, 2024 09:58
@janndriessen janndriessen requested a review from 0xonramp June 26, 2024 14:17
@janndriessen janndriessen marked this pull request as ready for review June 26, 2024 14:17
@@ -44,7 +44,8 @@ jobs:
- run: npm run test:rwa
- run: npm run test:btc2x
- run: npm run test:cdeti
- run: npm run test:dseth
# skipping as currently no liquidity for sfrETH
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

please note this also for other skipped tests for dsETH in this PR


async getSwapQuote(request: SwapQuoteRequest): Promise<SwapQuote | null> {
// This is not ideal but right now the only way to get only uniV2 and sushi quotes
const allowExchanges = ['uniswap', 'sushiswap']
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This would likely be an issue in production as LiFi only supports UniV2

Copy link
Collaborator

Choose a reason for hiding this comment

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

e.g. this won't work since sushiswap is provided?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since the contracts require UniV3 quotes

const isUniswap = lifiResult.toolDetails.name
.toLowerCase()
.includes('uniswap')
const exchange = isUniswap ? Exchange.UniV3 : Exchange.Sushiswap
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this would likely be an issue in production

lifiResult.action.toToken.address,
],
fees: [fees],
pool: AddressZero,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since we can't get the pool from LiFi quotes, sushi quotes probably wouldn't work

@@ -20,6 +20,7 @@ export interface SwapQuoteRequest {
inputAmount?: string
outputAmount?: string
// Optional
address?: string
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If we'd try to use LiFi with new contracts at some point, we'd need to add address (user's account) to all requests.

Copy link
Collaborator

Choose a reason for hiding this comment

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

any reason why that would be a problem? (i'm wondering if we should just make it required starting now)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

because it changes several interfaces throughout the project which we might not need for any other swap quote provider

@janndriessen janndriessen merged commit 47a0bd5 into main Jun 27, 2024
1 check passed
@janndriessen janndriessen deleted the feat/add-lifi-swap-quote-provider branch June 27, 2024 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants