Skip to content

Commit

Permalink
Remove unused @uniswap/router-sdk dependency (#10)
Browse files Browse the repository at this point in the history
* Remove unused `@uniswap/router-sdk` dependency

* Remove other packages that had @uniswap/router-sdk as dependency

---------

Co-authored-by: Kunal Jain <jainkunal3004@gmail.com>
Co-authored-by: Kunal <kunal@joinwido.com>
  • Loading branch information
3 people authored Jul 27, 2023
1 parent 974b5ca commit 9a32f63
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 508 deletions.
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,8 @@
"@uniswap/conedison": "^1.2.1",
"@uniswap/permit2-sdk": "^1.2.0",
"@uniswap/redux-multicall": "^1.1.8",
"@uniswap/router-sdk": "^1.3.0",
"@uniswap/sdk-core": "^3.0.1",
"@uniswap/smart-order-router": "^2.10.0",
"@uniswap/token-lists": "^1.0.0-beta.30",
"@uniswap/universal-router-sdk": "^1.3.4",
"@uniswap/v2-sdk": "^3.0.1",
"@uniswap/v3-sdk": "^3.8.2",
"@web3-react/core": "^6.1.9",
Expand Down
168 changes: 0 additions & 168 deletions src/components/Swap/RoutingDiagram/index.tsx

This file was deleted.

38 changes: 0 additions & 38 deletions src/components/Swap/RoutingDiagram/utils.ts

This file was deleted.

13 changes: 3 additions & 10 deletions src/hooks/useSyncFlags.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { UNIVERSAL_ROUTER_ADDRESS } from '@uniswap/universal-router-sdk'
import { useEvmChainId } from 'hooks/useSyncWidgetSettings'
import { Atom, atom } from 'jotai'
import { useAtomValue } from 'jotai/utils'
Expand All @@ -25,13 +24,7 @@ export function useBrandedFooter() {
export function usePermit2() {
const chainId = useEvmChainId()
const permit2 = useAtomValue(flagsAtom).permit2 ?? false
try {
// Detect if the Universal Router is not yet deployed to chainId.
// This is necessary so that we can fallback correctly on chains without a Universal Router deployment.
// It will be removed once Universal Router is deployed on all supported chains.
chainId && UNIVERSAL_ROUTER_ADDRESS(chainId)
return permit2
} catch {
return false
}

// For Wido specific flow, we don't check or require Permit2
return false
}
63 changes: 19 additions & 44 deletions src/state/routing/types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
import { BigNumber } from '@ethersproject/bignumber'
import { Trade } from '@uniswap/router-sdk'
import { Currency, CurrencyAmount, Price, Token, TradeType } from '@uniswap/sdk-core'
import type { ChainId } from '@uniswap/smart-order-router'
import { Currency, CurrencyAmount, Price, TradeType } from '@uniswap/sdk-core'
import { RouterPreference } from 'hooks/routing/types'
import { QuoteRequest, QuoteResult, Step } from 'wido'

export declare enum ChainId {
MAINNET = 1,
ROPSTEN = 3,
RINKEBY = 4,
GÖRLI = 5,
KOVAN = 42,
OPTIMISM = 10,
OPTIMISTIC_KOVAN = 69,
ARBITRUM_ONE = 42161,
ARBITRUM_RINKEBY = 421611,
POLYGON = 137,
POLYGON_MUMBAI = 80001,
CELO = 42220,
CELO_ALFAJORES = 44787,
GNOSIS = 100,
MOONBEAM = 1284
}

export enum TradeState {
LOADING,
INVALID,
Expand All @@ -14,42 +30,6 @@ export enum TradeState {

// from https://github.com/Uniswap/routing-api/blob/main/lib/handlers/schema.ts

export type TokenInRoute = Pick<Token, 'address' | 'chainId' | 'symbol' | 'decimals'>

export type V3PoolInRoute = {
type: 'v3-pool'
tokenIn: TokenInRoute
tokenOut: TokenInRoute
sqrtRatioX96: string
liquidity: string
tickCurrent: string
fee: string
amountIn?: string
amountOut?: string

// not used in the interface
address?: string
}

export type V2Reserve = {
token: TokenInRoute
quotient: string
}

export type V2PoolInRoute = {
type: 'v2-pool'
tokenIn: TokenInRoute
tokenOut: TokenInRoute
reserve0: V2Reserve
reserve1: V2Reserve
amountIn?: string
amountOut?: string

// not used in the interface
// avoid returning it from the client-side smart-order-router
address?: string
}

export interface GetQuoteArgs {
tokenInAddress: string
tokenInChainId: ChainId
Expand All @@ -70,11 +50,6 @@ export const NO_ROUTE = 'No Route'

export type GetQuoteResult = QuoteResult | typeof INITIALIZED | typeof NO_ROUTE

/**
* @deprecated
*/
export class InterfaceTrade extends Trade<Currency, Currency, TradeType> {}

export interface WidoTradeType<TradeInput extends Currency, TradeOutput extends Currency> {
inputAmount: CurrencyAmount<TradeInput>
inputAmountUsdValue?: CurrencyAmount<Currency>
Expand Down
3 changes: 2 additions & 1 deletion src/state/routing/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { ONE } from '@uniswap/router-sdk'
import { Currency, CurrencyAmount, Fraction, Percent } from '@uniswap/sdk-core'
import JSBI from 'jsbi'

export function calcMinimumAmountOut(
slippageTolerance: Percent,
amountOut: CurrencyAmount<Currency>
): CurrencyAmount<Currency> {
const ONE = JSBI.BigInt(1)
const slippageAdjustedAmountOut = new Fraction(ONE).subtract(slippageTolerance).multiply(amountOut.quotient).quotient
return CurrencyAmount.fromRawAmount(amountOut.currency, slippageAdjustedAmountOut)
}
Loading

1 comment on commit 9a32f63

@vercel
Copy link

@vercel vercel bot commented on 9a32f63 Jul 27, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

wido-widget – ./

wido-widget.vercel.app
wido-widget-wido.vercel.app
wido-widget-git-main-wido.vercel.app

Please sign in to comment.