Skip to content

Commit 25e6d81

Browse files
authored
Revert "using family api for token prices in swaps when possible (#2500)"
This reverts commit 2d0ee5e.
1 parent 15e258d commit 25e6d81

File tree

9 files changed

+5
-302
lines changed

9 files changed

+5
-302
lines changed

.env.development

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,3 @@ NEXT_PUBLIC_ENABLE_STAKING=true
99
NEXT_PUBLIC_ENABLE_GOVERNANCE=true
1010
NEXT_PUBLIC_API_BASEURL=https://aave-api-v2.aave.com
1111
NEXT_PUBLIC_SUBGRAPH_API_KEY=
12-
FAMILY_API_KEY=
13-
FAMILY_API_URL=

.env.example

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,3 @@ ZKSYNC_RPC_API_KEY=
3838
LINEA_RPC_API_KEY=
3939
SONIC_RPC_API_KEY=
4040
CELO_RPC_API_KEY=
41-
FAMILY_API_KEY=
42-
FAMILY_API_URL=

pages/api/prices-proxy.md

Lines changed: 0 additions & 80 deletions
This file was deleted.

pages/api/prices-proxy.ts

Lines changed: 0 additions & 79 deletions
This file was deleted.

src/components/transactions/Switch/BaseSwitchModalContent.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,6 @@ export const BaseSwitchModalContent = ({
348348
destDecimals: selectedOutputToken.decimals,
349349
inputSymbol: selectedInputToken.symbol,
350350
outputSymbol: selectedOutputToken.symbol,
351-
isInputTokenCustom: !!selectedInputToken.extensions?.isUserCustom,
352-
isOutputTokenCustom: !!selectedOutputToken.extensions?.isUserCustom,
353351
user,
354352
options: {
355353
partner: 'aave-widget',

src/components/transactions/Switch/switch.types.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ export type SwitchParams = {
1919
inputSymbol?: string;
2020
outputSymbol?: string;
2121

22-
isInputTokenCustom?: boolean;
23-
isOutputTokenCustom?: boolean;
24-
2522
setError?: (error: TxErrorType) => void;
2623
};
2724

src/hooks/switch/cowprotocol.rates.ts

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { ChainId } from '@aave/contract-helpers';
21
import {
32
OrderKind,
43
QuoteAndPost,
@@ -15,10 +14,8 @@ import { isChainIdSupportedByCoWProtocol } from 'src/components/transactions/Swi
1514
import { SwitchParams, SwitchRatesType } from 'src/components/transactions/Switch/switch.types';
1615
import { getEthersProvider } from 'src/libs/web3-data-provider/adapters/EthersAdapter';
1716
import { CoWProtocolPricesService } from 'src/services/CoWProtocolPricesService';
18-
import { FamilyPricesService } from 'src/services/FamilyPricesService';
1917
import { getErrorTextFromError, TxAction } from 'src/ui-config/errorMapping';
2018
import { wagmiConfig } from 'src/ui-config/wagmiConfig';
21-
import { getNetworkConfig } from 'src/utils/marketsAndNetworksConfig';
2219

2320
export async function getCowProtocolSellRates({
2421
chainId,
@@ -31,11 +28,8 @@ export async function getCowProtocolSellRates({
3128
inputSymbol,
3229
outputSymbol,
3330
setError,
34-
isInputTokenCustom,
35-
isOutputTokenCustom,
3631
}: SwitchParams): Promise<SwitchRatesType> {
3732
const cowProtocolPricesService = new CoWProtocolPricesService();
38-
const familyPricesService = new FamilyPricesService();
3933
const tradingSdk = new TradingSdk({ chainId });
4034

4135
let orderBookQuote: QuoteAndPost | undefined;
@@ -59,9 +53,6 @@ export async function getCowProtocolSellRates({
5953

6054
const provider = await getEthersProvider(wagmiConfig, { chainId });
6155
const signer = provider?.getSigner();
62-
const isMainnet =
63-
!getNetworkConfig(chainId as unknown as ChainId).isTestnet &&
64-
!getNetworkConfig(chainId as unknown as ChainId).isFork;
6556

6657
if (!inputSymbol || !outputSymbol) {
6758
throw new Error('No input or output symbol provided');
@@ -85,19 +76,14 @@ export async function getCowProtocolSellRates({
8576
console.error(cowError);
8677
throw new Error(cowError?.body?.errorType);
8778
}),
88-
(isInputTokenCustom || !isMainnet
89-
? cowProtocolPricesService.getTokenUsdPrice(chainId, srcTokenWrapped)
90-
: familyPricesService.getTokenUsdPrice(chainId, srcTokenWrapped)
91-
).catch((cowError) => {
79+
// CoW Quote doesn't return values in USD, so we need to fetch the price from the API separately
80+
cowProtocolPricesService.getTokenUsdPrice(chainId, srcTokenWrapped).catch((cowError) => {
9281
console.error(cowError);
93-
throw new Error('No price found for token, please try another token');
82+
throw new Error(cowError?.body?.errorType);
9483
}),
95-
(isOutputTokenCustom || !isMainnet
96-
? cowProtocolPricesService.getTokenUsdPrice(chainId, destTokenWrapped)
97-
: familyPricesService.getTokenUsdPrice(chainId, destTokenWrapped)
98-
).catch((cowError) => {
84+
cowProtocolPricesService.getTokenUsdPrice(chainId, destTokenWrapped).catch((cowError) => {
9985
console.error(cowError);
100-
throw new Error('No price found for token, please try another token');
86+
throw new Error(cowError?.body?.errorType);
10187
}),
10288
]);
10389

src/hooks/switch/useMultiProviderSwitchRates.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ export const useMultiProviderSwitchRates = ({
1313
destToken,
1414
user,
1515
inputSymbol,
16-
isInputTokenCustom,
17-
isOutputTokenCustom,
1816
outputSymbol,
1917
srcDecimals,
2018
destDecimals,
@@ -43,8 +41,6 @@ export const useMultiProviderSwitchRates = ({
4341
destDecimals,
4442
inputSymbol,
4543
outputSymbol,
46-
isInputTokenCustom,
47-
isOutputTokenCustom,
4844
});
4945
case 'paraswap':
5046
return await getParaswapSellRates({

src/services/FamilyPricesService.ts

Lines changed: 0 additions & 111 deletions
This file was deleted.

0 commit comments

Comments
 (0)