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

feat: avalanche market #26

Merged
merged 5 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
12 changes: 6 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "3.8"
version: '3.8'

services:
frontend:
Expand All @@ -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}
Expand All @@ -25,4 +25,4 @@ services:
CF_ZONE_ID: ${CF_ZONE_ID}
CF_API_TOKEN: ${CF_API_TOKEN}
ports:
- "19006:3000"
- '19006:3000'
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions src/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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';
47 changes: 20 additions & 27 deletions src/libs/apollo-config/client-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,34 +194,27 @@ export function getApolloClient({
protocolDataUrl,
}: NetworkConfig): { client: ApolloClient<NormalizedCacheObject>; 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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions src/libs/web3-data-provider/web3-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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:
Expand Down Expand Up @@ -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;
}
Expand Down
26 changes: 26 additions & 0 deletions src/ui-config/markets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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;
43 changes: 42 additions & 1 deletion src/ui-config/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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: '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',
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 ',
Expand Down Expand Up @@ -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: {
Expand All @@ -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;