-
Notifications
You must be signed in to change notification settings - Fork 158
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: v2
Swap API
#878
feat: v2
Swap API
#878
Conversation
src/swap/types.ts
Outdated
@@ -57,6 +58,7 @@ export type GetSwapAPIParams = GetQuoteAPIParams & { | |||
export type GetSwapQuoteParams = { | |||
from: Token; // The source token for the swap | |||
to: Token; // The destination token for the swap | |||
aggregator: boolean; // Whether to use a DEX aggregator |
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.
alphabetical
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.
fixed
@@ -45,6 +45,7 @@ export type GetQuoteAPIParams = { | |||
to: AddressOrETH | ''; // The destination address or 'ETH' for Ethereum | |||
amount: string; // The amount to be swapped | |||
amountReference?: string; // The reference amount for the swap | |||
v2Enabled?: boolean; // Whether to use V2 of the API (default: false) |
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.
why not just enable it as default? After all it should not have a real change for the experience, right?
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.
see Slack
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.
use experimental
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.
v2Enabled
this is such a bad way to name a property for an API.
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.
do we really need this year?
|
||
if (!params.aggregator) { | ||
apiParams = { | ||
v2Enabled: true, |
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.
oh I see you want to test this on his own for a bit?
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.
yeah, we'll do a switchover once the V2 service is more production ready
src/swap/components/SwapProvider.tsx
Outdated
@@ -36,9 +36,11 @@ export function useSwapContext() { | |||
export function SwapProvider({ | |||
address, | |||
children, | |||
useAggregator, |
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.
the provider too should have experimental
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.
we don't want to leak bad experience across too many components, and we want to keep experimental
nice and neat.
isAmountInDecimals?: boolean; // Whether the amount is in decimals | ||
to: Token; // The destination token for the swap | ||
useAggregator: boolean; // Whether to use a DEX aggregator |
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.
use experimental
}) { | ||
// Feature flags |
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.
Love the comment
What changed? Why?
aggregators
prop to<Swap/>
to controlV1
orV2
APIv2Enabled
parameter in the request body, our API will route these to a beta implementation for serving quotes/trades directly from Uniswap V3V1
API does not index pools with under <= $10,000 of liquidity,V2
API will make a direct call to theUniswapRouter
contractNotes to reviewers
slippage
for theV2
API is hardcoded to 1000 bps (10%) - Tina is aligned for the initial launch and we'll fast-follow to add configurability to the UIusage
How has it been tested?
See Slack for demo