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

test: auto router #122

Draft
wants to merge 49 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
7fa3ea2
wip: feat: add autorouter param
kristiehuang Jul 5, 2022
714f7dd
feat: add routerAPIBaseURL prop [wip]
kristiehuang Jul 7, 2022
3c5b6e1
remove V3 quoters for useBestTrade
kristiehuang Jul 7, 2022
954e147
feat: [wip] add rtk-query createAPI logic
kristiehuang Jul 7, 2022
cbe9b78
style(lint): lint action with ESLint
Jul 7, 2022
cce2796
feat: rename useBestTrade to useRouterTrade
kristiehuang Jul 7, 2022
d2799d7
Merge branch 'feat/auto-router-params' of https://github.com/Uniswap/…
kristiehuang Jul 7, 2022
2dee4f1
Add routingApi slice reducer to store
kristiehuang Jul 7, 2022
cf18b98
use baseURL in API fetch
kristiehuang Jul 7, 2022
5472667
use string type instead of URL type
kristiehuang Jul 7, 2022
a0146ee
fix: use isFetching for trade state
kristiehuang Jul 7, 2022
a2124a0
nit: remove comments
kristiehuang Jul 7, 2022
98aad98
Disable eslint for SOR import
kristiehuang Jul 7, 2022
b173535
nit: add comments for router provider
kristiehuang Jul 7, 2022
51e406b
use activeWeb3React for router provider
kristiehuang Jul 8, 2022
d100bd3
style(lint): lint action with ESLint
Jul 8, 2022
8d9710b
nit
kristiehuang Jul 8, 2022
25fe842
Merge branch 'feat/auto-router-params' of https://github.com/Uniswap/…
kristiehuang Jul 8, 2022
4c8864d
nit: fix lint about React hooks
kristiehuang Jul 8, 2022
f689a6d
nit: import comments
kristiehuang Jul 8, 2022
eaae27f
remove jank logic
kristiehuang Jul 8, 2022
ee937b3
fix: undefined chainId
kristiehuang Jul 8, 2022
14d5843
fix: use provider connection URLs for router provider
kristiehuang Jul 8, 2022
abd1e23
nit: comments
kristiehuang Jul 8, 2022
1016cbb
feat: combine useRouterTrade & useRoutingAPITrade
kristiehuang Jul 8, 2022
54f0a5c
nit: comments
kristiehuang Jul 8, 2022
bf26c8e
fix: rename params & address PR comments
kristiehuang Jul 11, 2022
1e02294
lint: type import SOR
kristiehuang Jul 11, 2022
2288aba
remove comments + address PR
kristiehuang Jul 11, 2022
402746a
Remove 'useClientSideRouter' param
kristiehuang Jul 12, 2022
8bb32f4
fix: clientside router should use existing JsonRpcProvider obj (#57)
kristiehuang Jul 12, 2022
db49a07
remove comment
kristiehuang Jul 12, 2022
fc6b0c9
update fxn docs
kristiehuang Jul 12, 2022
44c9487
nit: fix serializeQueryArgs type
kristiehuang Jul 12, 2022
3b7061a
pr review
kristiehuang Jul 13, 2022
cbb97fb
nit: remove comment
kristiehuang Jul 13, 2022
f5ed85d
Add comments
kristiehuang Jul 13, 2022
eb081a9
fix: check currency chainid only if token inputted
kristiehuang Jul 13, 2022
72fc2b2
[wip] tests: auto router API params
kristiehuang Jul 13, 2022
3ad4a02
Merge branch 'main' into auto-router/tests
kristiehuang Jul 26, 2022
d39f274
wip tests
kristiehuang Jul 26, 2022
d4c18ac
confusion
kristiehuang Aug 1, 2022
15ceaa3
nit
kristiehuang Aug 1, 2022
bb84d9c
add real route data result
kristiehuang Aug 1, 2022
a5709e1
Merge branch 'main' into auto-router/tests
kristiehuang Aug 2, 2022
0b9d785
style(lint): lint action with ESLint
Aug 2, 2022
6d58a01
very wip
kristiehuang Aug 2, 2022
cb2f183
Merge branch 'auto-router/tests' of https://github.com/Uniswap/widget…
kristiehuang Aug 2, 2022
0826544
delete undeeded file
kristiehuang Aug 12, 2022
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
"@semantic-release/git": "^10.0.1",
"@svgr/rollup": "^6.2.1",
"@testing-library/react": "^12",
"@testing-library/react-hooks": "^8.0.1",
"@testing-library/user-event": "^14.2.0",
"@typechain/ethers-v5": "^7.0.0",
"@types/jest": "^25.2.1",
Expand Down Expand Up @@ -185,7 +186,7 @@
"react-cosmos": "^5.6.6",
"react-dom": "^17.0.1",
"react-redux": "^7.2.2",
"react-test-renderer": "^18.0.0",
"react-test-renderer": "^17.0.1",
"redux": "^4.1.2",
"rollup": "^2.63.0",
"rollup-plugin-dts": "^4.2.1",
Expand Down
20 changes: 5 additions & 15 deletions src/hooks/routing/clientSideSmartOrderRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { BigintIsh, CurrencyAmount, Token, TradeType } from '@uniswap/sdk-core'
// eslint-disable-next-line no-restricted-imports
import { AlphaRouter, AlphaRouterConfig, AlphaRouterParams, ChainId } from '@uniswap/smart-order-router'
import JSBI from 'jsbi'
import { QuoteArguments } from 'state/routing/slice'
import { GetQuoteResult } from 'state/routing/types'

import { transformSwapRouteToGetQuoteResult } from './transformSwapRouteToGetQuoteResult'
Expand Down Expand Up @@ -53,20 +54,9 @@ async function getQuote(
if (!swapRoute)
throw new Error(`Failed to generate client side quote from ${currencyIn.symbol} to ${currencyOut.symbol}`)

return { data: transformSwapRouteToGetQuoteResult(type, amount, swapRoute) }
}

interface QuoteArguments {
tokenInAddress: string
tokenInChainId: ChainId
tokenInDecimals: number
tokenInSymbol?: string
tokenOutAddress: string
tokenOutChainId: ChainId
tokenOutDecimals: number
tokenOutSymbol?: string
amount: string
type: 'exactIn' | 'exactOut'
const data = transformSwapRouteToGetQuoteResult(type, amount, swapRoute)
data.isApiResult = false
return { data }
}

export async function getClientSideQuote(
Expand All @@ -80,9 +70,9 @@ export async function getClientSideQuote(
tokenOutDecimals,
tokenOutSymbol,
amount,
provider,
type,
}: QuoteArguments,
provider: JsonRpcProvider,
routerConfig: Partial<AlphaRouterConfig>
) {
return getQuote(
Expand Down
Loading