From 3eb174ff602de0b8340c3cf87f02b4017f90c220 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Tue, 5 Oct 2021 13:10:47 +0200 Subject: [PATCH 1/5] feat: avalanche market --- src/config.tsx | 8 ++++ src/libs/apollo-config/client-config.ts | 47 ++++++++----------- .../providers/static-pool-data-provider.tsx | 5 +- src/libs/web3-data-provider/web3-helpers.ts | 7 +++ src/ui-config/markets/index.ts | 26 ++++++++++ src/ui-config/networks.ts | 43 ++++++++++++++++- 6 files changed, 107 insertions(+), 29 deletions(-) diff --git a/src/config.tsx b/src/config.tsx index de0d4f535..67edd1a76 100644 --- a/src/config.tsx +++ b/src/config.tsx @@ -30,6 +30,9 @@ export function getSupportedNetworks(): Network[] { if (localStorage.getItem('polygon_fork_enabled') === 'true') { supportedNetworks.push(Network.polygon_fork); } + if (localStorage.getItem('avalanche_fork_enabled') === 'true') { + supportedNetworks.push(Network.avalanche_fork); + } return supportedNetworks; } @@ -75,3 +78,8 @@ export const POLYGON_FORK_RPC_URL = localStorage.getItem('polygonForkRPCUrl') || 'http://127.0.0.1:8545'; export const POLYGON_FORK_WS_RPC_URL = localStorage.getItem('polygonForkWsRPCUrl') || 'ws://127.0.0.1:8545'; +// Avalanche Fork +export const AVALANCHE_FORK_RPC_URL = + localStorage.getItem('avalancheForkRPCUrl') || 'http://127.0.0.1:8545'; +export const AVALANCHE_FORK_WS_RPC_URL = + localStorage.getItem('avalancheForkWsRPCUrl') || 'ws://127.0.0.1:8545'; diff --git a/src/libs/apollo-config/client-config.ts b/src/libs/apollo-config/client-config.ts index 069d6ca75..42f4113ee 100644 --- a/src/libs/apollo-config/client-config.ts +++ b/src/libs/apollo-config/client-config.ts @@ -194,34 +194,27 @@ export function getApolloClient({ protocolDataUrl, }: NetworkConfig): { client: ApolloClient; wsClients: any[] } { const poolTheGraphLink = new HttpLink({ uri: protocolDataUrl }); - const governanceDataLink = governanceConfig - ? split( - ({ query }) => { - const definition = getMainDefinition(query); - return ( - definition.kind === 'OperationDefinition' && definition.operation === 'subscription' - ); - }, - createWsLink(governanceConfig.wsGovernanceDataUrl), - new HttpLink({ uri: governanceConfig.queryGovernanceDataUrl }) - ) - : undefined; + const governanceDataLink = split( + ({ query }) => { + const definition = getMainDefinition(query); + return definition.kind === 'OperationDefinition' && definition.operation === 'subscription'; + }, + createWsLink(governanceConfig!.wsGovernanceDataUrl), + new HttpLink({ uri: governanceConfig!.queryGovernanceDataUrl }) + ); - const thegraphDataLink = - governanceDataLink === undefined - ? poolTheGraphLink - : split( - ({ query }) => { - const definition = getMainDefinition(query); - return ( - definition.kind === 'OperationDefinition' && - definition.operation === 'query' && - definition.name?.value === 'UserHistory' - ); - }, - poolTheGraphLink, - governanceDataLink - ); + const thegraphDataLink = split( + ({ query }) => { + const definition = getMainDefinition(query); + return ( + definition.kind === 'OperationDefinition' && + definition.operation === 'query' && + definition.name?.value === 'UserHistory' + ); + }, + poolTheGraphLink, + governanceDataLink + ); const cachedServerDataLink = getCachedServerLink(cachingServerUrl, cachingWSServerUrl); const generalLink = diff --git a/src/libs/pool-data-provider/providers/static-pool-data-provider.tsx b/src/libs/pool-data-provider/providers/static-pool-data-provider.tsx index d5485c003..3bc271382 100644 --- a/src/libs/pool-data-provider/providers/static-pool-data-provider.tsx +++ b/src/libs/pool-data-provider/providers/static-pool-data-provider.tsx @@ -165,7 +165,10 @@ export function StaticPoolDataProvider({ networkConfig, refresh: isRPCActive ? refresh : async () => {}, WrappedBaseNetworkAssetAddress, - isTestnet: network !== Network.mainnet && network !== Network.polygon, + isTestnet: + network !== Network.mainnet && + network !== Network.polygon && + network !== Network.avalanche, rawReserves: reservesWithFixedUnderlying, rawUserReserves: userReservesWithFixedUnderlying, isUserHasDeposits, diff --git a/src/libs/web3-data-provider/web3-helpers.ts b/src/libs/web3-data-provider/web3-helpers.ts index 10ae92c8a..8faebeb9f 100644 --- a/src/libs/web3-data-provider/web3-helpers.ts +++ b/src/libs/web3-data-provider/web3-helpers.ts @@ -9,6 +9,9 @@ const FORK_NETWORK_ID = Number(localStorage.getItem('forkNetworkId') || ChainId. const POLYGON_FORK_NETWORK_ID = Number( localStorage.getItem('polygonForkNetworkId') || ChainId.polygon_fork ); +const AVALANCHE_FORK_NETWORK_ID = Number( + localStorage.getItem('avalancheForkNetworkId') || ChainId.avalanche_fork +); export function mapChainIdToName(id: number): ExtendedSupportedNetworks { switch (id) { @@ -30,6 +33,8 @@ export function mapChainIdToName(id: number): ExtendedSupportedNetworks { return Network.arbitrum_one; case ChainId.avalanche: return Network.avalanche; + case AVALANCHE_FORK_NETWORK_ID: + return Network.avalanche_fork; case FORK_NETWORK_ID: return Network.fork; case POLYGON_FORK_NETWORK_ID: @@ -63,6 +68,8 @@ export function mapNameToChainID(chain?: ExtendedSupportedNetworks): number { return ChainId.arbitrum_one; case Network.avalanche: return ChainId.avalanche; + case Network.avalanche_fork: + return AVALANCHE_FORK_NETWORK_ID; default: return 0; } diff --git a/src/ui-config/markets/index.ts b/src/ui-config/markets/index.ts index 12d01ccd9..91e71cd76 100644 --- a/src/ui-config/markets/index.ts +++ b/src/ui-config/markets/index.ts @@ -6,6 +6,8 @@ import * as logos from './images'; export enum CustomMarket { proto_kovan = 'proto_kovan', proto_mainnet = 'proto_mainnet', + proto_avalanche = 'proto_avalanche', + avalanche_fork = 'avalanche_fork', proto_matic = 'proto_matic', proto_mumbai = 'proto_mumbai', proto_fork = 'proto_fork', @@ -192,4 +194,28 @@ export const marketsData: { [key in keyof typeof CustomMarket]: MarketDataType } FAUCET: '0x90E5BAc5A98fff59617080848959f44eACB4Cd7B', }, }, + [CustomMarket.proto_avalanche]: { + network: Network.avalanche, + logo: logos.aaveLogo, + activeLogo: logos.aaveActiveLogo, + subLogo: logos.avalanche, + aTokenPrefix: 'AV', + addresses: { + LENDING_POOL_ADDRESS_PROVIDER: '0xb6A86025F0FE1862B372cb0ca18CE3EDe02A318f'.toLowerCase(), + LENDING_POOL: '0x4F01AeD16D97E3aB5ab2B501154DC9bb0F1A5A2C', + WETH_GATEWAY: '0x8a47F74d1eE0e2edEB4F3A7e64EF3bD8e11D27C8', + }, + }, + [CustomMarket.avalanche_fork]: { + network: Network.avalanche_fork, + logo: logos.aaveLogo, + activeLogo: logos.aaveActiveLogo, + subLogo: logos.avalanche, + aTokenPrefix: 'AV', + addresses: { + LENDING_POOL_ADDRESS_PROVIDER: '0xb6A86025F0FE1862B372cb0ca18CE3EDe02A318f'.toLowerCase(), + LENDING_POOL: '0x4F01AeD16D97E3aB5ab2B501154DC9bb0F1A5A2C', + WETH_GATEWAY: '0x8a47F74d1eE0e2edEB4F3A7e64EF3bD8e11D27C8', + }, + }, } as const; diff --git a/src/ui-config/networks.ts b/src/ui-config/networks.ts index e5bb3f9d6..20202d744 100644 --- a/src/ui-config/networks.ts +++ b/src/ui-config/networks.ts @@ -5,6 +5,8 @@ import { FORK_WS_RPC_URL, POLYGON_FORK_RPC_URL, POLYGON_FORK_WS_RPC_URL, + AVALANCHE_FORK_RPC_URL, + AVALANCHE_FORK_WS_RPC_URL, } from '../config'; import { BaseNetworkConfig } from '../helpers/markets/markets-data'; import polygonBridgeLogo from './branding/images/polygonLogo.svg'; @@ -61,6 +63,36 @@ const polygon_config: BaseNetworkConfig = { }, } as const; +const avalanche_config: BaseNetworkConfig = { + publicJsonRPCUrl: 'https://api.avax.network/ext/bc/C/rpc', + publicJsonRPCWSUrl: 'wss://api.avax.network/ext/bc/C/rpc', + walletBalanceProvider: '0x73e4898a1Bfa9f710B6A6AB516403A6299e01fc6', + uiPoolDataProvider: '0x2dB63Ca358aB41264A5359BF77175D488a22a7Aa', + protocolDataUrl: 'https://api.thegraph.com/subgraphs/name/aave/protocol-v2-avalanche', + cachingServerUrl: 'https://cache-api-avalanche.aave.com/graphql', + cachingWSServerUrl: 'wss://cache-api-avalanche.aave.com/graphql', + baseUniswapAdapter: '0x0', + baseAsset: 'AVAX', + // incentives hardcoded information + rewardTokenSymbol: 'WAVAX', + rewardTokenAddress: API_ETH_MOCK_ADDRESS, + rewardTokenDecimals: 18, + incentivePrecision: 18, + explorerLink: 'https://cchain.explorer.avax.network', + rpcOnly: !ENABLE_CACHING_BACKEND, + usdMarket: true, + addresses: { + INCENTIVES_CONTROLLER: '0x01d83fe6a10d2f2b7af17034343746188272cac9', + INCENTIVES_CONTROLLER_REWARD_TOKEN: '0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7', + }, + bridge: { + brandColor: '232, 65, 66', + name: 'Avalanche Bridge', + url: 'https://bridge.avax.network/', + logo: avalancheBridgeLogo, + }, +}; + export const networkConfigs: { [key: string]: BaseNetworkConfig } = { [Network.kovan]: { publicJsonRPCUrl: 'https://kovan.poa.network ', @@ -119,7 +151,7 @@ export const networkConfigs: { [key: string]: BaseNetworkConfig } = { rpcOnly: true, usdMarket: true, addresses: { - INCENTIVES_CONTROLLER: '0xa1EF206fb9a8D8186157FC817fCddcC47727ED55', + INCENTIVES_CONTROLLER: '0xd4eCF34187a52E755D44fca4d37aBe0b50724De2', INCENTIVES_CONTROLLER_REWARD_TOKEN: '0xd00ae08403b9bbb9124bb305c09058e32c39a48c', }, bridge: { @@ -141,4 +173,13 @@ export const networkConfigs: { [key: string]: BaseNetworkConfig } = { privateJsonRPCWSUrl: POLYGON_FORK_WS_RPC_URL, rpcOnly: true, }, + [Network.avalanche]: { + ...avalanche_config, + }, + [Network.avalanche_fork]: { + ...avalanche_config, + privateJsonRPCUrl: AVALANCHE_FORK_RPC_URL, + privateJsonRPCWSUrl: AVALANCHE_FORK_WS_RPC_URL, + rpcOnly: true, + }, } as const; From e71000ab7eb6648991a014d260fd569145468ce1 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Tue, 5 Oct 2021 13:18:10 +0200 Subject: [PATCH 2/5] fix: add avalanche to networks --- docker-compose.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 582d2acc1..84e9c5005 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: "3.8" +version: '3.8' services: frontend: @@ -8,11 +8,11 @@ services: volumes: - ./:/app environment: - REACT_APP_SUPPORTED_ETHEREUM_NETWORKS: "polygon,mainnet" + REACT_APP_SUPPORTED_ETHEREUM_NETWORKS: 'polygon,mainnet,avalanche' #REACT_APP_SUPPORTED_ETHEREUM_NETWORKS: "polygon,mumbai,mainnet,kovan,fuji,arbitrum_rinkeby" - REACT_APP_DEFAULT_ETHEREUM_NETWORK: "mainnet" - REACT_APP_ENABLE_CACHING_BACKEND: "true" - REACT_APP_RATES_HISTORY_ENDPOINT: "https://aave-api-v2.aave.com/data/rates-history" + REACT_APP_DEFAULT_ETHEREUM_NETWORK: 'mainnet' + REACT_APP_ENABLE_CACHING_BACKEND: 'true' + REACT_APP_RATES_HISTORY_ENDPOINT: 'https://aave-api-v2.aave.com/data/rates-history' REACT_APP_ENABLE_NASH: ${ENABLE_NASH} REACT_APP_FORTMATIC_KEY_MAINNET: ${FORTMATIC_KEY_MAINNET} REACT_APP_FORTMATIC_KEY_TESTNET: ${FORTMATIC_KEY_TESTNET} @@ -25,4 +25,4 @@ services: CF_ZONE_ID: ${CF_ZONE_ID} CF_API_TOKEN: ${CF_API_TOKEN} ports: - - "19006:3000" + - '19006:3000' From c33a112296fb5ec94e2198f9ad88d24a56d45294 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Tue, 5 Oct 2021 13:23:30 +0200 Subject: [PATCH 3/5] fix: bump uikit --- package.json | 2 +- src/ui-config/networks.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3b610e667..0449795fd 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "license": "BSD-3-Clause", "dependencies": { "@0x/subproviders": "^6.5.4", - "@aave/aave-ui-kit": "^0.1.11", + "@aave/aave-ui-kit": "^0.1.12", "@aave/protocol-js": "^4.1.0", "@apollo/client": "^3.4.8", "@apollo/react-common": "^3.1.4", diff --git a/src/ui-config/networks.ts b/src/ui-config/networks.ts index 20202d744..5ad0372df 100644 --- a/src/ui-config/networks.ts +++ b/src/ui-config/networks.ts @@ -67,7 +67,7 @@ const avalanche_config: BaseNetworkConfig = { publicJsonRPCUrl: 'https://api.avax.network/ext/bc/C/rpc', publicJsonRPCWSUrl: 'wss://api.avax.network/ext/bc/C/rpc', walletBalanceProvider: '0x73e4898a1Bfa9f710B6A6AB516403A6299e01fc6', - uiPoolDataProvider: '0x2dB63Ca358aB41264A5359BF77175D488a22a7Aa', + uiPoolDataProvider: '0x7d9d970CaE574912221d25107A6728f0d17Cb901', protocolDataUrl: 'https://api.thegraph.com/subgraphs/name/aave/protocol-v2-avalanche', cachingServerUrl: 'https://cache-api-avalanche.aave.com/graphql', cachingWSServerUrl: 'wss://cache-api-avalanche.aave.com/graphql', From 582b1521dad971fd26aeefccaecab4430b80c6ad Mon Sep 17 00:00:00 2001 From: sakulstra Date: Tue, 5 Oct 2021 13:24:56 +0200 Subject: [PATCH 4/5] fix: also patch lockfile --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index a59380dcf..f19b1576c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -393,9 +393,9 @@ } }, "@aave/aave-ui-kit": { - "version": "0.1.11", - "resolved": "https://registry.npmjs.org/@aave/aave-ui-kit/-/aave-ui-kit-0.1.11.tgz", - "integrity": "sha512-wImUTD5BxUD/UXS8t82iL3BkHy/8JlBDf50iOfKjtYyuA7CLapDrWlFkEoihdyKzjEmtm/gX/hQUB6RW4fKBEw==", + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/@aave/aave-ui-kit/-/aave-ui-kit-0.1.12.tgz", + "integrity": "sha512-iFWc7gtMJl1XyYlTFqa+WFfzl/CVIA4OmCEeTCEGJjV4gt3quHhor2Pl85m1vva7wRIb9EvAdr4maeJEIuMfvA==", "requires": { "@react-hook/window-size": "^3.0.7", "@types/react-modal": "^3.10.6", From 685cc3f6f88ae54cde9431f278f0843c343566b1 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Wed, 6 Oct 2021 16:32:54 +0200 Subject: [PATCH 5/5] fix: apply patch fix: remove patch files --- .../RouteParamsValidationWrapper/index.tsx | 11 +++++-- .../CurrencyOverview/index.tsx | 2 +- .../components/Card/index.tsx | 5 +-- src/helpers/loan-action-link-composer.ts | 6 ++-- src/helpers/router-types.ts | 4 +-- src/helpers/toggle-borrow-rate-mode.ts | 6 ++-- src/helpers/toggle-use-as-collateral.ts | 6 ++-- .../BorrowAssetTable/BorrowItem.tsx | 3 +- .../BorrowAssetTable/BorrowMobileCard.tsx | 3 +- .../components/BorrowAssetTable/types.ts | 1 + .../borrow/screens/BorrowAmount/index.tsx | 2 +- .../borrow/screens/BorrowMain/index.tsx | 3 +- .../components/DashboardNoData/style.ts | 2 +- .../dashboard/screens/Dashboard/index.tsx | 31 +++++++++++-------- .../DepositAssetsTable/DepositItem.tsx | 3 +- .../DepositAssetsTable/DepositMobileCard.tsx | 3 +- .../DepositDashboardTable/DepositItem.tsx | 4 +-- .../DepositMobileCard.tsx | 4 +-- .../deposit/screens/DepositMain/index.tsx | 3 +- .../FaucetAssetTable/FaucetItem.tsx | 10 ++++-- .../components/FaucetAssetTable/types.ts | 1 + .../components/MarketMobileCard/index.tsx | 3 +- .../components/MarketTableItem/index.tsx | 3 +- .../components/MarketTableItem/style.ts | 1 + .../components/RepayScreenWrapper/index.tsx | 4 ++- .../BorrowTable/BorrowTableItem/index.tsx | 12 +++---- .../components/UserInformation/index.tsx | 10 +++--- 27 files changed, 88 insertions(+), 58 deletions(-) diff --git a/src/components/RouteParamsValidationWrapper/index.tsx b/src/components/RouteParamsValidationWrapper/index.tsx index f969b275c..5e40ed7a5 100644 --- a/src/components/RouteParamsValidationWrapper/index.tsx +++ b/src/components/RouteParamsValidationWrapper/index.tsx @@ -46,23 +46,27 @@ export default function routeParamValidationHOC({ return (ChildComponent: React.ComponentType) => ({ match, location, history }: RouteComponentProps) => { const intl = useIntl(); - const currencySymbol = match.params.currencySymbol.toUpperCase(); + const underlyingAsset = match.params.underlyingAsset.toUpperCase(); const reserveId = match.params.id; const { usdPriceEth } = useStaticPoolDataContext(); const { reserves, user } = useDynamicPoolDataContext(); const poolReserve = reserves.find((res) => - reserveId ? res.id === reserveId : res.symbol === currencySymbol + reserveId + ? res.id === reserveId + : res.underlyingAsset.toLowerCase() === underlyingAsset.toLowerCase() ); const userReserve = user ? user.reservesData.find((userReserve) => reserveId ? userReserve.reserve.id === reserveId - : userReserve.reserve.symbol === currencySymbol + : userReserve.reserve.underlyingAsset.toLowerCase() === underlyingAsset.toLowerCase() ) : undefined; + const currencySymbol = poolReserve?.symbol || ''; + const { walletData } = useWalletBalanceProviderContext({ skip: !withWalletBalance || !poolReserve || (withUserReserve && !userReserve), }); @@ -120,6 +124,7 @@ export default function routeParamValidationHOC({ walletBalanceUSD, isWalletBalanceEnough, currencySymbol, + underlyingAsset, history, location, }; diff --git a/src/components/wrappers/CurrencyScreenWrapper/CurrencyOverview/index.tsx b/src/components/wrappers/CurrencyScreenWrapper/CurrencyOverview/index.tsx index 9a4fa1254..94abcc97b 100644 --- a/src/components/wrappers/CurrencyScreenWrapper/CurrencyOverview/index.tsx +++ b/src/components/wrappers/CurrencyScreenWrapper/CurrencyOverview/index.tsx @@ -366,7 +366,7 @@ export default function CurrencyOverview({
{title &&

{title}

} diff --git a/src/components/wrappers/DepositBorrowMainWrapper/components/Card/index.tsx b/src/components/wrappers/DepositBorrowMainWrapper/components/Card/index.tsx index 0e4dba62b..abb9861d6 100644 --- a/src/components/wrappers/DepositBorrowMainWrapper/components/Card/index.tsx +++ b/src/components/wrappers/DepositBorrowMainWrapper/components/Card/index.tsx @@ -13,9 +13,10 @@ interface CardProps { symbol: string; id: string; value: string; + underlyingAsset: string; } -export default function Card({ link, symbol, id, value }: CardProps) { +export default function Card({ link, symbol, id, value, underlyingAsset }: CardProps) { const { currentTheme, xl, sm } = useThemeContext(); const asset = getAssetInfo(symbol); @@ -34,7 +35,7 @@ export default function Card({ link, symbol, id, value }: CardProps) { diff --git a/src/helpers/loan-action-link-composer.ts b/src/helpers/loan-action-link-composer.ts index 009324902..2681a9810 100644 --- a/src/helpers/loan-action-link-composer.ts +++ b/src/helpers/loan-action-link-composer.ts @@ -2,9 +2,9 @@ import { InterestRate } from '@aave/protocol-js'; export function loanActionLinkComposer( action: 'borrow' | 'repay', - symbol: string, reserveId: string, - debtType: InterestRate + debtType: InterestRate, + underlyingAsset: string ): string { - return `/${action}/${symbol}-${reserveId}?debtType=${debtType}`; + return `/${action}/${underlyingAsset}-${reserveId}?debtType=${debtType}`; } diff --git a/src/helpers/router-types.ts b/src/helpers/router-types.ts index 220c9cf65..607c1e2c7 100644 --- a/src/helpers/router-types.ts +++ b/src/helpers/router-types.ts @@ -1,5 +1,5 @@ export interface CurrencyRouteParamsInterface { - currencySymbol: string; + underlyingAsset: string; id?: string; } -export const CURRENCY_ROUTE_PARAMS = ':currencySymbol([A-Z]+)(-?):id?'; +export const CURRENCY_ROUTE_PARAMS = ':underlyingAsset([A-Z0-9x]+)(-?):id?'; diff --git a/src/helpers/toggle-borrow-rate-mode.ts b/src/helpers/toggle-borrow-rate-mode.ts index 01974e82f..4cbcf9f80 100644 --- a/src/helpers/toggle-borrow-rate-mode.ts +++ b/src/helpers/toggle-borrow-rate-mode.ts @@ -3,11 +3,11 @@ import { InterestRate } from '@aave/protocol-js'; export const toggleBorrowRateMode = ( history: History, - symbol: string, reserveID: string, - borrowRateMode: InterestRate + borrowRateMode: InterestRate, + underlyingAsset: string ) => { history.push( - `/interest-swap/${symbol}-${reserveID}/confirmation?borrowRateMode=${borrowRateMode}` + `/interest-swap/${underlyingAsset}-${reserveID}/confirmation?borrowRateMode=${borrowRateMode}` ); }; diff --git a/src/helpers/toggle-use-as-collateral.ts b/src/helpers/toggle-use-as-collateral.ts index 9f39cf394..4fcd9701c 100644 --- a/src/helpers/toggle-use-as-collateral.ts +++ b/src/helpers/toggle-use-as-collateral.ts @@ -3,10 +3,10 @@ import { History } from 'history'; export const toggleUseAsCollateral = ( history: History, - symbol: string | undefined, reserveId: string | undefined, - asCollateral: boolean | undefined + asCollateral: boolean | undefined, + underlyingAsset: string | undefined ) => { const query = queryString.stringify({ asCollateral }); - history.push(`/usage-as-collateral/${symbol}-${reserveId}/confirmation?${query}`); + history.push(`/usage-as-collateral/${underlyingAsset}-${reserveId}/confirmation?${query}`); }; diff --git a/src/modules/borrow/components/BorrowAssetTable/BorrowItem.tsx b/src/modules/borrow/components/BorrowAssetTable/BorrowItem.tsx index 62d6bada7..0e13292ef 100644 --- a/src/modules/borrow/components/BorrowAssetTable/BorrowItem.tsx +++ b/src/modules/borrow/components/BorrowAssetTable/BorrowItem.tsx @@ -12,6 +12,7 @@ import { BorrowTableItem } from './types'; export default function BorrowItem({ id, symbol, + underlyingAsset, availableBorrows, availableBorrowsInUSD, stableBorrowRate, @@ -23,7 +24,7 @@ export default function BorrowItem({ vIncentivesAPY, sIncentivesAPY, }: BorrowTableItem) { - const url = `/borrow/${symbol}-${id}`; + const url = `/borrow/${underlyingAsset}-${id}`; return ( )} diff --git a/src/modules/borrow/screens/BorrowMain/index.tsx b/src/modules/borrow/screens/BorrowMain/index.tsx index 5ece0044f..27e9d7eb1 100644 --- a/src/modules/borrow/screens/BorrowMain/index.tsx +++ b/src/modules/borrow/screens/BorrowMain/index.tsx @@ -122,10 +122,11 @@ export default function BorrowMain() { {item.currentBorrows.toString() > '0' && ( )} diff --git a/src/modules/dashboard/components/DashboardNoData/style.ts b/src/modules/dashboard/components/DashboardNoData/style.ts index a3d22f7ae..bb3f620e9 100644 --- a/src/modules/dashboard/components/DashboardNoData/style.ts +++ b/src/modules/dashboard/components/DashboardNoData/style.ts @@ -79,7 +79,7 @@ const staticStyles = css.global` } &__logo-inner { img { - width: 85px; + width: 84px; max-height: 16px; @include respond-to(sm) { width: 105px; diff --git a/src/modules/dashboard/screens/Dashboard/index.tsx b/src/modules/dashboard/screens/Dashboard/index.tsx index f2e7d168d..06b262e99 100644 --- a/src/modules/dashboard/screens/Dashboard/index.tsx +++ b/src/modules/dashboard/screens/Dashboard/index.tsx @@ -94,9 +94,9 @@ export default function Dashboard() { onToggleSwitch: () => toggleUseAsCollateral( history, - poolReserve.symbol, poolReserve.id, - !userReserve.usageAsCollateralEnabledOnUser + !userReserve.usageAsCollateralEnabledOnUser, + poolReserve.underlyingAsset ), }); } @@ -114,22 +114,22 @@ export default function Dashboard() { avg30DaysVariableRate: poolReserve.avg30DaysVariableBorrowRate, repayLink: loanActionLinkComposer( 'repay', - poolReserve.symbol, poolReserve.id, - InterestRate.Variable + InterestRate.Variable, + poolReserve.underlyingAsset ), borrowLink: loanActionLinkComposer( 'borrow', - poolReserve.symbol, poolReserve.id, - InterestRate.Variable + InterestRate.Variable, + poolReserve.underlyingAsset ), onSwitchToggle: () => toggleBorrowRateMode( history, - poolReserve.symbol, poolReserve.id, - InterestRate.Variable + InterestRate.Variable, + poolReserve.underlyingAsset ), }); } @@ -145,18 +145,23 @@ export default function Dashboard() { sIncentivesAPY: poolReserve.sIncentivesAPY, repayLink: loanActionLinkComposer( 'repay', - poolReserve.symbol, poolReserve.id, - InterestRate.Stable + InterestRate.Stable, + poolReserve.underlyingAsset ), borrowLink: loanActionLinkComposer( 'borrow', - poolReserve.symbol, poolReserve.id, - InterestRate.Stable + InterestRate.Stable, + poolReserve.underlyingAsset ), onSwitchToggle: () => - toggleBorrowRateMode(history, poolReserve.symbol, poolReserve.id, InterestRate.Stable), + toggleBorrowRateMode( + history, + poolReserve.id, + InterestRate.Stable, + poolReserve.underlyingAsset + ), }); } } diff --git a/src/modules/deposit/components/DepositAssetsTable/DepositItem.tsx b/src/modules/deposit/components/DepositAssetsTable/DepositItem.tsx index 57eaa8acd..d1571237c 100644 --- a/src/modules/deposit/components/DepositAssetsTable/DepositItem.tsx +++ b/src/modules/deposit/components/DepositAssetsTable/DepositItem.tsx @@ -12,6 +12,7 @@ import { DepositTableItem } from './types'; export default function DepositItem({ id, symbol, + underlyingAsset, walletBalance, walletBalanceInUSD, liquidityRate, @@ -21,7 +22,7 @@ export default function DepositItem({ isFreezed, aIncentivesAPY, }: DepositTableItem) { - const url = `/deposit/${symbol}-${id}`; + const url = `/deposit/${underlyingAsset}-${id}`; return ( diff --git a/src/modules/deposit/components/DepositAssetsTable/DepositMobileCard.tsx b/src/modules/deposit/components/DepositAssetsTable/DepositMobileCard.tsx index 6bb8771d2..e3107a227 100644 --- a/src/modules/deposit/components/DepositAssetsTable/DepositMobileCard.tsx +++ b/src/modules/deposit/components/DepositAssetsTable/DepositMobileCard.tsx @@ -16,6 +16,7 @@ import { DepositTableItem } from './types'; export default function DepositMobileCard({ id, symbol, + underlyingAsset, walletBalance, walletBalanceInUSD, liquidityRate, @@ -28,7 +29,7 @@ export default function DepositMobileCard({ const intl = useIntl(); const history = useHistory(); - const url = `/deposit/${symbol}-${id}`; + const url = `/deposit/${underlyingAsset}-${id}`; return ( )} diff --git a/src/modules/deposit/components/DepositDashboardTable/DepositMobileCard.tsx b/src/modules/deposit/components/DepositDashboardTable/DepositMobileCard.tsx index c921edf4a..90e6789fc 100644 --- a/src/modules/deposit/components/DepositDashboardTable/DepositMobileCard.tsx +++ b/src/modules/deposit/components/DepositDashboardTable/DepositMobileCard.tsx @@ -97,7 +97,7 @@ export default function DepositMobileCard({ className="Row__center" > @@ -116,7 +116,7 @@ export default function DepositMobileCard({ className="Row__center" > diff --git a/src/modules/deposit/screens/DepositMain/index.tsx b/src/modules/deposit/screens/DepositMain/index.tsx index 1f9338962..57213189b 100644 --- a/src/modules/deposit/screens/DepositMain/index.tsx +++ b/src/modules/deposit/screens/DepositMain/index.tsx @@ -135,10 +135,11 @@ export default function DepositsMain() { {item.underlyingBalance.toString() > '0' && ( )} diff --git a/src/modules/faucet/components/FaucetAssetTable/FaucetItem.tsx b/src/modules/faucet/components/FaucetAssetTable/FaucetItem.tsx index 417c0c72c..ef2b339c7 100644 --- a/src/modules/faucet/components/FaucetAssetTable/FaucetItem.tsx +++ b/src/modules/faucet/components/FaucetAssetTable/FaucetItem.tsx @@ -6,8 +6,14 @@ import Value from '../../../../components/basic/Value'; import { FaucetTableItem } from './types'; -export default function FaucetItem({ symbol, id, userId, walletBalance }: FaucetTableItem) { - const url = `/faucet/${symbol}-${id}`; +export default function FaucetItem({ + symbol, + id, + userId, + walletBalance, + underlyingAsset, +}: FaucetTableItem) { + const url = `/faucet/${underlyingAsset}-${id}`; return ( diff --git a/src/modules/faucet/components/FaucetAssetTable/types.ts b/src/modules/faucet/components/FaucetAssetTable/types.ts index cccc7bb3d..bfa5a3d80 100644 --- a/src/modules/faucet/components/FaucetAssetTable/types.ts +++ b/src/modules/faucet/components/FaucetAssetTable/types.ts @@ -5,4 +5,5 @@ export type FaucetTableItem = { symbol: string; walletBalance: BigNumber; userId?: string; + underlyingAsset: string; }; diff --git a/src/modules/markets/components/MarketMobileCard/index.tsx b/src/modules/markets/components/MarketMobileCard/index.tsx index 309a01516..042a9ea72 100644 --- a/src/modules/markets/components/MarketMobileCard/index.tsx +++ b/src/modules/markets/components/MarketMobileCard/index.tsx @@ -18,6 +18,7 @@ import { MarketTableItemProps } from '../MarketTableItem'; export default function MarketMobileCard({ id, currencySymbol, + underlyingAsset, totalLiquidityInUSD, totalBorrowsInUSD, depositAPY, @@ -65,7 +66,7 @@ export default function MarketMobileCard({ ]; const handleClick = () => { - history.push(`/reserve-overview/${currencySymbol}-${id}`); + history.push(`/reserve-overview/${underlyingAsset}-${id}`); }; return ( diff --git a/src/modules/markets/components/MarketTableItem/index.tsx b/src/modules/markets/components/MarketTableItem/index.tsx index dbc4a1c98..51ba9c793 100644 --- a/src/modules/markets/components/MarketTableItem/index.tsx +++ b/src/modules/markets/components/MarketTableItem/index.tsx @@ -35,6 +35,7 @@ export interface MarketTableItemProps { export default function MarketTableItem({ id, + underlyingAsset, currencySymbol, totalLiquidity, totalLiquidityInUSD, @@ -58,7 +59,7 @@ export default function MarketTableItem({ const asset = getAssetInfo(currencySymbol); const handleClick = () => { - history.push(`/reserve-overview/${currencySymbol}-${id}`); + history.push(`/reserve-overview/${underlyingAsset}-${id}`); }; return ( diff --git a/src/modules/markets/components/MarketTableItem/style.ts b/src/modules/markets/components/MarketTableItem/style.ts index c7dfd0647..90995ef97 100644 --- a/src/modules/markets/components/MarketTableItem/style.ts +++ b/src/modules/markets/components/MarketTableItem/style.ts @@ -65,6 +65,7 @@ const staticStyles = css.global` &__isFreezed-inner { position: relative; flex: 3; + text-align: center; } .TokenIcon__dollar { diff --git a/src/modules/repay/components/RepayScreenWrapper/index.tsx b/src/modules/repay/components/RepayScreenWrapper/index.tsx index aaf85ada7..53e536cdd 100644 --- a/src/modules/repay/components/RepayScreenWrapper/index.tsx +++ b/src/modules/repay/components/RepayScreenWrapper/index.tsx @@ -13,6 +13,7 @@ import { isAssetStable } from '../../../../helpers/markets/assets'; import messages from './messages'; import staticStyles from './style'; +import { useProtocolDataContext } from '../../../../libs/protocol-data-provider'; interface RepayScreenWrapperProps { title: string; @@ -42,6 +43,7 @@ export default function RepayScreenWrapper({ children, }: RepayScreenWrapperProps) { const intl = useIntl(); + const { networkConfig } = useProtocolDataContext(); return ( <> @@ -80,7 +82,7 @@ export default function RepayScreenWrapper({ toggleBorrowRateMode( history, - poolReserve.symbol, poolReserve.id, - type === 'stable' ? InterestRate.Stable : InterestRate.Variable + type === 'stable' ? InterestRate.Stable : InterestRate.Variable, + poolReserve.underlyingAsset ) } // @ts-ignore diff --git a/src/modules/reserve-overview/components/UserInformation/index.tsx b/src/modules/reserve-overview/components/UserInformation/index.tsx index 5469e09c2..d993cf348 100644 --- a/src/modules/reserve-overview/components/UserInformation/index.tsx +++ b/src/modules/reserve-overview/components/UserInformation/index.tsx @@ -94,7 +94,7 @@ export default function UserInformation({ {intl.formatMessage(messages.deposits)}{' '}
@@ -109,7 +109,7 @@ export default function UserInformation({ className={classNames({ UserInformation__buttonNoBorderDisabled: !underlyingBalance, })} - to={`/withdraw/${symbol}-${poolReserve.id}`} + to={`/withdraw/${poolReserve.underlyingAsset}-${poolReserve.id}`} disabled={!underlyingBalance} > @@ -168,9 +168,9 @@ export default function UserInformation({ onSwitch={() => toggleUseAsCollateral( history, - poolReserve.symbol, poolReserve.id, - !userReserve?.usageAsCollateralEnabledOnUser + !userReserve?.usageAsCollateralEnabledOnUser, + poolReserve.underlyingAsset ) } disabled={!poolReserve.usageAsCollateralEnabled} @@ -189,7 +189,7 @@ export default function UserInformation({ {!totalBorrows && (