From ba73b8fea3698fff50b7872b2dc494eb52613a43 Mon Sep 17 00:00:00 2001 From: Alexander Khramov Date: Tue, 23 Jul 2024 12:54:53 +0300 Subject: [PATCH] feat: rm jumper aggregator related code --- assets/icons/jumper.svg | 5 -- consts/matomo-click-events.ts | 6 --- .../request/withdrawal-rates/icons.tsx | 8 --- .../request/withdrawal-rates/integrations.ts | 36 +------------- .../request/withdrawal-rates/types.ts | 7 +-- utils/get-jumper-rate.ts | 49 ------------------- 6 files changed, 2 insertions(+), 109 deletions(-) delete mode 100644 assets/icons/jumper.svg delete mode 100644 utils/get-jumper-rate.ts diff --git a/assets/icons/jumper.svg b/assets/icons/jumper.svg deleted file mode 100644 index d0dd04c21..000000000 --- a/assets/icons/jumper.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/consts/matomo-click-events.ts b/consts/matomo-click-events.ts index a80211ab5..3d2ff1044 100644 --- a/consts/matomo-click-events.ts +++ b/consts/matomo-click-events.ts @@ -56,7 +56,6 @@ export const enum MATOMO_CLICK_EVENTS_TYPES { withdrawalGoToCowSwap = 'withdrawalGoToCowSwap', withdrawalGoToParaswap = 'withdrawalGoToParaswap', withdrawalGoToOpenOcean = 'withdrawalGoToOpenOcean', - withdrawalGoToJumper = 'withdrawalGoToJumper', withdrawalEtherscanSuccessTemplate = 'withdrawalEtherscanSuccessTemplate', withdrawalGuideSuccessTemplate = 'withdrawalGuideSuccessTemplate', @@ -319,11 +318,6 @@ export const MATOMO_CLICK_EVENTS: Record< 'Click on «Go to OpenOcean in aggregators list on Request tab', 'eth_withdrawals_request_go_to_OpenOcean', ], - [MATOMO_CLICK_EVENTS_TYPES.withdrawalGoToJumper]: [ - 'Ethereum_Withdrawals_Widget', - 'Click on «Go to Jumper in aggregators list on Request tab', - 'eth_withdrawals_request_go_to_Jumper', - ], [MATOMO_CLICK_EVENTS_TYPES.withdrawalEtherscanSuccessTemplate]: [ 'Ethereum_Withdrawals_Widget', 'Click on "Etherscan" on success template after withdrawal request', diff --git a/features/withdrawals/request/withdrawal-rates/icons.tsx b/features/withdrawals/request/withdrawal-rates/icons.tsx index a2c89f5ac..a598f670d 100644 --- a/features/withdrawals/request/withdrawal-rates/icons.tsx +++ b/features/withdrawals/request/withdrawal-rates/icons.tsx @@ -3,7 +3,6 @@ import OpenOcean from 'assets/icons/open-ocean.svg'; import Paraswap from 'assets/icons/paraswap-circle.svg'; import Oneinch from 'assets/icons/oneinch-circle.svg'; import Bebop from 'assets/icons/bebop.svg'; -import Jumper from 'assets/icons/jumper.svg'; export const OpenOceanIcon = styled.img.attrs({ src: OpenOcean, @@ -32,10 +31,3 @@ export const BebopIcon = styled.img.attrs({ })` display: block; `; - -export const JumperIcon = styled.img.attrs({ - src: Jumper, - alt: 'Jumper', -})` - display: block; -`; diff --git a/features/withdrawals/request/withdrawal-rates/integrations.ts b/features/withdrawals/request/withdrawal-rates/integrations.ts index 45e9ba962..24d1a7477 100644 --- a/features/withdrawals/request/withdrawal-rates/integrations.ts +++ b/features/withdrawals/request/withdrawal-rates/integrations.ts @@ -12,13 +12,7 @@ import { getBebopRate } from 'utils/get-bebop-rate'; import { getOpenOceanRate } from 'utils/get-open-ocean-rate'; import { standardFetcher } from 'utils/standardFetcher'; -import { - BebopIcon, - OneInchIcon, - OpenOceanIcon, - ParaSwapIcon, - JumperIcon, -} from './icons'; +import { BebopIcon, OneInchIcon, OpenOceanIcon, ParaSwapIcon } from './icons'; import type { DexWithdrawalApi, @@ -26,7 +20,6 @@ import type { GetRateType, RateCalculationResult, } from './types'; -import { getJumperRate } from 'utils/get-jumper-rate'; const RATE_PRECISION = 100000; const RATE_PRECISION_BN = BigNumber.from(RATE_PRECISION); @@ -151,23 +144,6 @@ const getBebopWithdrawalRate: GetRateType = async ({ amount, token }) => { }; }; -const getJumperWithdrawalRate: GetRateType = async ({ amount, token }) => { - try { - if (amount.gt(Zero)) { - return await getJumperRate(amount, token, 'ETH'); - } - } catch (e) { - console.warn( - '[getOneInchWithdrawalRate] Failed to receive withdraw rate', - e, - ); - } - return { - rate: null, - toReceive: null, - }; -}; - const dexWithdrawalMap: DexWithdrawalIntegrationMap = { 'open-ocean': { title: 'OpenOcean', @@ -212,16 +188,6 @@ const dexWithdrawalMap: DexWithdrawalIntegrationMap = { getTokenAddress(CHAINS.Mainnet, token), )}&sellAmounts=${formatEther(amount)}&source=lido`, }, - jumper: { - title: 'Jumper', - icon: JumperIcon, - fetcher: getJumperWithdrawalRate, - matomoEvent: MATOMO_CLICK_EVENTS_TYPES.withdrawalGoToJumper, - link: (amount, token) => - `https://jumper.exchange/?fromAmount=${formatEther(amount)}&fromChain=1&fromToken=${getAddress( - getTokenAddress(CHAINS.Mainnet, token), - )}&source=lido&toChain=1&toToken=0x0000000000000000000000000000000000000000`, - }, } as const; export const getDexConfig = (dexKey: DexWithdrawalApi) => diff --git a/features/withdrawals/request/withdrawal-rates/types.ts b/features/withdrawals/request/withdrawal-rates/types.ts index 388526f5f..d3d57136c 100644 --- a/features/withdrawals/request/withdrawal-rates/types.ts +++ b/features/withdrawals/request/withdrawal-rates/types.ts @@ -19,12 +19,7 @@ export type SingleWithdrawalRateResult = { toReceive: BigNumber | null; }; -export type DexWithdrawalApi = - | 'paraswap' - | 'open-ocean' - | 'one-inch' - | 'bebop' - | 'jumper'; +export type DexWithdrawalApi = 'paraswap' | 'open-ocean' | 'one-inch' | 'bebop'; export type DexWithdrawalIntegration = { title: string; diff --git a/utils/get-jumper-rate.ts b/utils/get-jumper-rate.ts deleted file mode 100644 index 06e562f3c..000000000 --- a/utils/get-jumper-rate.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { BigNumber } from 'ethers'; -import { TOKENS } from '@lido-sdk/constants'; -import { standardFetcher } from './standardFetcher'; - -type JumperGetQuotePartial = { - estimate: { - toAmount: string; - }; -}; - -type RateToken = TOKENS.STETH | TOKENS.WSTETH | 'ETH'; - -type RateCalculationResult = { rate: number; toReceive: BigNumber }; - -const RATE_PRECISION = 1000000; - -export const getJumperRate = async ( - amount: BigNumber, - fromToken: RateToken, - toToken: RateToken, -): Promise => { - const basePath = 'https://li.quest/v1/quote'; - - const params = new URLSearchParams({ - fromChain: 'ETH', - toChain: 'ETH', - fromToken, - toToken, - fromAddress: '0x11D00000000000000000000000000000000011D0', - fromAmount: amount.toString(), - source: 'lido', - }); - - const data = await standardFetcher( - `${basePath}?${params.toString()}`, - ); - - if (data && data.estimate && data.estimate.toAmount) { - const toAmount = BigNumber.from(data.estimate.toAmount); - const rate = - toAmount.mul(BigNumber.from(RATE_PRECISION)).div(amount).toNumber() / - RATE_PRECISION; - return { - rate, - toReceive: toAmount, - }; - } - throw new Error('[getJumperRate] Could not get quote, invalid response body'); -};