-
Notifications
You must be signed in to change notification settings - Fork 5
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 uniswap swap quote provider #73
Conversation
|
||
import { getSwapData } from './swap-data' | ||
|
||
export class CurveSwapQuoteProvider implements SwapQuoteProvider { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adapter we need for a few products that specifically use quotes of a Curve pool for ETH/stETH.
exchange: Exchange.Curve, | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
path: [WETH.address!, stETH.address!], | ||
fees: [], // not needed for curve |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be correct with what I saw in tests but please confirm @ckoopmann
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, should be correct.
I'm not 100% sure now at one point the condition fees.length = path.length - 1
is checked. It should only be checked for uniswap swaps, but if you do end up getting "path / fee length mismatch" errors, then just set fees: [0]
.
Just in case, shouldn't be necessary though.
return [inputToken, outputToken] | ||
} | ||
return [inputToken, weth, outputToken] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might not need this and will delete later.
outputToken, | ||
inputAmount: inputAmount ?? quotedAmount, | ||
outputAmount: outputAmount ?? quotedAmount, | ||
callData: '0x', // TOOD: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ckoopmann I would assume this is the call data for the 0x contract right? Or would it work to send a Uniswap encoded tx call data here?
This should be only relevant for the FlashMintZeroEx contract, correct? https://github.com/IndexCoop/flash-mint-sdk/blob/main/src/quote/flashmint/zeroEx/provider.ts#L91
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we only need fully encoded calldata for 0x interactions.
All other flashmint contracts encode the calldata themselves based on the SwapData object provided.
src/quote/swap/adapters/adapter.ts
Outdated
return await curveSwapQuoteProvider.getSwapQuote(request) | ||
} | ||
const uniswapSwapQuoteProvider = new UniswapSwapQuoteProvider(this.rpcUrl) | ||
return await uniswapSwapQuoteProvider.getSwapQuote(request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a simple check to take Curve for ETH/stETH. Otherwise, use Uniswap V3 (or V2).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
isSameAddress(inputToken, EthAddress) || | ||
isSameAddress(outputToken, EthAddress) | ||
) { | ||
// FIXME: remove for production, just for runnint tests and catching any of these cases |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flagging for pre-release
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll keep this until we have part 2 because it now actually shouldn't happen anymore but might catch some "bugs".
🎉 This PR is included in version 3.5.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Resources
Tests
The Number is the
indexTokenAmount
e.g. 1 BTC2x/ETH means minting 1 BTC2x with ETH.These test do not check for deep liquidity.
TODOs