Skip to content

Commit

Permalink
Feat: Avalanche Support (#3487)
Browse files Browse the repository at this point in the history
* Feat: Avalanche Support

* Add Initial contract addresses and settings for Avalanche

* Add subgraphs and token addresses

* Use a different public RPC. Add multicall address

* Fix websocket URL, wallet enum and allowlist pools I created

* Add trust wallet network for gauges and icons

* Add avalanche network icon

* Use new BAL token

* Hide Avalanche in UI

* whitelist initial boosted pools

* Add pool factories. Remove pool with old BAL token from allowlist

* Load ComposableStable and FX pool types

* Add gyro to included pool types

* Fix pools protocol features after refactor

---------

Co-authored-by: ZeKraken <[email protected]>
Co-authored-by: Alberto Gualis <[email protected]>
  • Loading branch information
3 people committed Jul 24, 2023
1 parent 3064559 commit 720b673
Show file tree
Hide file tree
Showing 11 changed files with 321 additions and 1 deletion.
46 changes: 46 additions & 0 deletions src/assets/data/contracts/avalanche.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"AaveLinearPoolFactory": "0x6caf662b573F577DE01165d2d38D1910bba41F8A",
"Authorizer": "0xA331D84eC860Bf466b4CdCcFb4aC09a1B43F3aE6",
"AuthorizerAdaptor": "0xdAE7e32ADc5d490a43cCba1f0c736033F2b4eFca",
"AuthorizerAdaptorEntrypoint": "0x4E7bBd911cf1EFa442BC1b2e9Ea01ffE785412EC",
"AuthorizerWithAdaptorValidation": "0x8df317a729fcaA260306d7de28888932cb579b88",
"BalancerHelpers": "0x8E9aa87E45e92bad84D5F8DD1bff34Fb92637dE9",
"BalancerQueries": "0xC128468b7Ce63eA702C1f104D55A2566b13D3ABD",
"BalancerRelayer": "0x03F1ab8b19bcE21EB06C364aEc9e40322572a1e9",
"BatchRelayerLibrary": "0x45fFd460cC6642B8D8Fb12373DFd77Ceb0f4932B",
"ChildChainGauge": "0x4b7b369989e613ff2C65768B7Cf930cC927F901E",
"ChildChainGaugeFactory": "0x161f4014C27773840ccb4EC1957113e6DD028846",
"ChildChainGaugeRewardHelper": "0x2E96068b3D5B5BAE3D7515da4A1D2E52d08A2647",
"ChildChainGaugeTokenAdder": "0xf302f9F50958c5593770FDf4d4812309fF77414f",
"ChildChainLiquidityGaugeFactory": "0xb08E16cFc07C684dAA2f93C70323BAdb2A6CBFd2",
"ChildChainStreamer": "0xD7FAD3bd59D6477cbe1BE7f646F7f1BA25b230f8",
"CircuitBreakerLib": "0x9129E834e15eA19b6069e8f08a8EcFc13686B8dC",
"ComposableStablePoolFactory": "0x3B1eb8EB7b43882b385aB30533D9A2BeF9052a98",
"DistributionScheduler": "0xC128a9954e6c874eA3d62ce62B468bA073093F25",
"ERC4626LinearPoolFactory": "0x4507d91Cd2C0D51D9B4F30Bf0B93AFC938A70BA5",
"ExternalWeightedMath": "0xDF9B5B00Ef9bca66e9902Bd813dB14e4343Be025",
"L2BalancerPseudoMinter": "0xEa924b45a3fcDAAdf4E5cFB1665823B8F8F2039B",
"L2LayerZeroBridgeForwarder": "0x4638ab64022927C9bD5947607459D13f57f1551C",
"ManagedPoolAddRemoveTokenLib": "0xAcf05BE5134d64d150d153818F8C67EE36996650",
"ManagedPoolAmmLib": "0xA69E0Ccf150a29369D8Bbc0B3f510849dB7E8EEE",
"ManagedPoolFactory": "0x03F3Fb107e74F2EAC9358862E91ad3c692712054",
"MockAaveLendingPool": "0x57EA28A99394978D060E483477C0Fd9fb9aFa96c",
"MockAaveLinearPool": "0xA826a114B0c7dB4d1FF4a4BE845a78998c64564C",
"MockComposableStablePool": "0xEa4643102dFC03d5e382e7827Bf767f6587E9965",
"MockERC4626LinearPool": "0xEd3E2F496cbCd8e212192fb8D1499842f04A0D19",
"MockERC4626Token": "0x2EbE41E1aa44D61c206A94474932dADC7D3FD9E3",
"MockManagedPool": "0x3Fb81f6FB0dd94c6fC7e138887f1CA4CDB5E2999",
"MockStaticAToken": "0xD8B6b96c88ad626EB6209c4876e3B14f45f8803A",
"MockWeightedPool": "0xb2b5B452d53401391155EA48C4451f6E9b0dD058",
"NoProtocolFeeLiquidityBootstrappingPoolFactory": "0x0F3e0c4218b7b0108a3643cFe9D3ec0d4F57c54e",
"NullVotingEscrow": "0x6B1Da720Be2D11d95177ccFc40A917c2688f396c",
"PoolRecoveryHelper": "0x3b8cA519122CdD8efb272b0D3085453404B25bD0",
"ProtocolFeePercentagesProvider": "0x239e55F427D44C3cc793f49bFB507ebe76638a2b",
"ProtocolFeesCollector": "0xce88686553686DA562CE7Cea497CE749DA109f9F",
"ProtocolFeesWithdrawer": "0x8F42aDBbA1B16EaAE3BB5754915E0D06059aDd75",
"RecoveryModeHelper": "0x300Ab2038EAc391f26D9F895dc61F8F66a548833",
"RewardsOnlyGauge": "0x41B953164995c11C81DA73D212ED8Af25741b7Ac",
"Vault": "0xBA12222222228d8Ba445958a75a0704d566BF2C8",
"VotingEscrowDelegationProxy": "0x0c6052254551EAe3ECac77B01DFcf1025418828f",
"WeightedPoolFactory": "0x230a59F4d9ADc147480f03B0D3fFfeCd56c3289a"
}
4 changes: 4 additions & 0 deletions src/assets/images/icons/networks/avalanche.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions src/lib/config/avalanche/contracts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Contracts } from '../types';
import * as avalanche from '@/assets/data/contracts/avalanche.json';

const contracts: Contracts = {
merkleRedeem: '',
merkleOrchard: '',
merkleOrchardV2: '',
multicall: '0xca11bde05977b3631167028862be2a173976ca11',
authorizer: avalanche.Authorizer,
vault: avalanche.Vault,
weightedPoolFactory: avalanche.WeightedPoolFactory,
stablePoolFactory: avalanche.ComposableStablePoolFactory,
lidoRelayer: '',
balancerHelpers: avalanche.BalancerHelpers,
batchRelayer: avalanche.BalancerRelayer,
gaugeFactory: avalanche.ChildChainLiquidityGaugeFactory,
balancerMinter: avalanche.L2BalancerPseudoMinter,
gaugeController: '',
tokenAdmin: '',
veBAL: '',
veDelegationProxy: '',
veBALHelpers: '',
feeDistributor: '',
feeDistributorDeprecated: '',
faucet: '',
gaugeRewardsHelper: avalanche.ChildChainGaugeRewardHelper,
};

export default contracts;
77 changes: 77 additions & 0 deletions src/lib/config/avalanche/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { Config } from '../types';
import keys from './keys';
import contracts from './contracts';
import pools from './pools';
import tokenlists from './tokenlists';
import tokens from './tokens';
import rateProviders from './rateProviders';

const config: Config = {
key: '43114',
chainId: 43114,
chainName: 'Avalanche',
name: 'Avalanche',
shortName: 'Avalanche',
monorepoName: 'avalanche',
slug: 'avalanche',
network: 'avalanche',
trustWalletNetwork: 'avalanchec',
unknown: false,
visibleInUI: false,
testNetwork: false,
rpc: `https://avalanche-mainnet.infura.io/v3/${keys.infura}`,
ws: `wss://api.avax.network/ext/bc/C/ws`,
publicRpc: 'https://avalanche.public-rpc.com',
explorer: 'https://snowtrace.io/',
explorerName: 'Snowtrace',
subgraph:
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-avalanche-v2',
balancerApi: 'https://api.balancer.fi',
poolsUrlV2: '',
subgraphs: {
main: [
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-avalanche-v2',
],
aave: 'https://api.thegraph.com/subgraphs/name/aave/protocol-v2-avalanche',
gauge:
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-gauges-avalanche',
blocks:
'https://api.thegraph.com/subgraphs/name/iliaazhel/avalanche-blocks',
},
bridgeUrl: 'https://core.app/bridge/',
supportsEIP1559: false,
supportsElementPools: false,
blockTime: 2,
nativeAsset: {
name: 'AVAX',
address: '0x0000000000000000000000000000000000000000',
symbol: 'AVAX',
decimals: 18,
deeplinkId: 'avax',
logoURI: 'tokens/avax.svg',
minTransactionBuffer: '0.1',
},
thirdParty: {
coingecko: {
nativeAssetId: 'avalanche-2',
platformId: 'avalanche',
},
apyVision: {
networkName: 'avalanche',
},
},
addresses: {
...contracts,
},
pools,
tokens,
keys,
gauges: {
type: 4,
weight: 0,
},
tokenlists,
rateProviders,
};

export default config;
9 changes: 9 additions & 0 deletions src/lib/config/avalanche/keys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Keys } from '../types';

const keys: Keys = {
infura: 'daaa68ec242643719749dd1caba2fc66',
alchemy: 'ODJ9G5Ipv-Hb2zTWMNbUFIqv9WtqBOc2',
balancerApi: 'da2-7a3ukmnw7bexndpx5x522uafui',
};

export default keys;
109 changes: 109 additions & 0 deletions src/lib/config/avalanche/pools.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import { Protocol } from '@/composables/useProtocols';
import { PoolFeature, Pools } from '@/types/pools';

const pools: Pools = {
IdsMap: {},
Pagination: {
PerPage: 10,
PerPool: 10,
PerPoolInitial: 5,
},
BoostsEnabled: false,
DelegateOwner: '0xba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1b',
ZeroAddress: '0x0000000000000000000000000000000000000000',
DynamicFees: {
Gauntlet: [],
},
BlockList: [''],
IncludedPoolTypes: [
'Weighted',
'Stable',
'MetaStable',
'ComposableStable',
'FX',
'Gyro2',
'Gyro3',
'GyroE',
],
Stable: {
AllowList: [
'0xa1d14d922a575232066520eda11e27760946c991000000000000000000000012', // Boosted Aave v3 USD
'0xa154009870e9b6431305f19b09f9cfd7284d4e7a000000000000000000000013', // sAVAX/Boosted Aave v3 WAVAX
'0xece571847897fd61e764d455dc15cf1cd9de8d6f000000000000000000000014', // yyAVAX/Boosted Aave v3 WAVAX
'0x054e7b0c73e1ee5aed6864fa511658fc2b54bcaa000000000000000000000015', // ggAVAX/Boosted Aave v3 WAVAX
'0x670734d704eb7ef424d75321670f921fbf42e9cf000000000000000000000016', // sAVAX-ankrAVAX
],
},
Investment: {
AllowList: [''],
},
Weighted: {
// Only effective after given timestamp here: usePool.ts#createdAfterTimestamp
// see useDisabledJoinPool.ts#nonAllowedWeightedPoolAfterTimestamp for logic.
AllowList: [
'0xe4a4565ad31a3af8286bc6e6dbb20ba76752557700010000000000000000000b',
'0x3bde1563903ebb564ca37d5736afbb850929cfd7000200000000000000000017', // ankrAVAX-ankrETH
],
},
Factories: {
'0x230a59f4d9adc147480f03b0d3fffecd56c3289a': 'weightedPool',
'0x3b1eb8eb7b43882b385ab30533d9a2bef9052a98': 'composableStablePool',
'0xe42ffa682a26ef8f25891db4882932711d42e467': 'composableStablePool',
},
Stakable: {
VotingGaugePools: [],
AllowList: [],
},
Metadata: {
'0xa1d14d922a575232066520eda11e27760946c991000000000000000000000012': {
name: 'Balancer Boosted Aave v3 USD',
hasIcon: false,
features: {
[PoolFeature.Boosted]: {
featureProtocols: [Protocol.Aave],
},
},
},
'0xa154009870e9b6431305f19b09f9cfd7284d4e7a000000000000000000000013': {
name: 'sAVAX/Boosted Aave v3 WAVAX',
hasIcon: false,
features: {
[PoolFeature.Boosted]: {
featureProtocols: [Protocol.Aave],
},
},
},
'0xece571847897fd61e764d455dc15cf1cd9de8d6f000000000000000000000014': {
name: 'yyAVAX/Boosted Aave v3 WAVAX',
hasIcon: false,
features: {
[PoolFeature.Boosted]: {
featureProtocols: [Protocol.Aave],
},
},
},
'0x054e7b0c73e1ee5aed6864fa511658fc2b54bcaa000000000000000000000015': {
name: 'ggAVAX/Boosted Aave v3 WAVAX',
hasIcon: false,
features: {
[PoolFeature.Boosted]: {
featureProtocols: [Protocol.Aave],
},
},
},
},
Deep: [
'0xa1d14d922a575232066520eda11e27760946c991000000000000000000000012', // Boosted Aave v3 USD
'0xa154009870e9b6431305f19b09f9cfd7284d4e7a000000000000000000000013', // sAVAX/Boosted Aave v3 WAVAX
'0xece571847897fd61e764d455dc15cf1cd9de8d6f000000000000000000000014', // yyAVAX/Boosted Aave v3 WAVAX
'0x054e7b0c73e1ee5aed6864fa511658fc2b54bcaa000000000000000000000015', // ggAVAX/Boosted Aave v3 WAVAX
],
BoostedApr: [],
DisabledJoins: [],
Deprecated: {},
GaugeMigration: {},
BrandedRedirect: {},
Issues: {},
};

export default pools;
9 changes: 9 additions & 0 deletions src/lib/config/avalanche/rateProviders.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { RateProviders } from '../types';

const rateProviders: RateProviders = {
'*': {
'0x0000000000000000000000000000000000000000': true,
},
};

export default rateProviders;
15 changes: 15 additions & 0 deletions src/lib/config/avalanche/tokenlists.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { TokenListURLMap } from '@/types/TokenList';

const tokenlists: TokenListURLMap = {
Balancer: {
Default:
'https://raw.githubusercontent.com/balancer/tokenlists/main/generated/balancer.tokenlist.json',
Vetted:
'https://raw.githubusercontent.com/balancer/tokenlists/main/generated/balancer.tokenlist.json',
},
External: [
'https://unpkg.com/[email protected]/build/quickswap-default.tokenlist.json',
],
};

export default tokenlists;
19 changes: 19 additions & 0 deletions src/lib/config/avalanche/tokens.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { TokenConstants } from '../types';

const tokens: TokenConstants = {
Popular: {
Symbols: ['WBTC', 'WETH', 'DAI', 'USDC', 'BAL', 'AVAX'],
},
InitialSwapTokens: {
input: '0x0000000000000000000000000000000000000000',
output: '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E', // USDC
},
Addresses: {
nativeAsset: '0x0000000000000000000000000000000000000000',
wNativeAsset: '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7',
WETH: '0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB',
BAL: '0xE15bCB9E0EA69e6aB9FA080c4c4A5632896298C3',
},
};

export default tokens;
3 changes: 3 additions & 0 deletions src/lib/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Config } from './types';

import arbitrum from './arbitrum';
import avalanche from './avalanche';
import goerli from './goerli';
import gnosisChain from './gnosis-chain';
import mainnet from './mainnet';
Expand All @@ -19,6 +20,7 @@ export enum Network {
FANTOM = 250,
ZKEVM = 1101,
ARBITRUM = 42161,
AVALANCHE = 43114,
}

const config: Record<Network | number, Config> = {
Expand All @@ -29,6 +31,7 @@ const config: Record<Network | number, Config> = {
[Network.OPTIMISM]: optimism,
[Network.GNOSIS]: gnosisChain,
[Network.ZKEVM]: zkevm,
[Network.AVALANCHE]: avalanche,
};

export default config;
2 changes: 1 addition & 1 deletion src/lib/scripts/contract-addresses.generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function generate() {

fs.writeFileSync(
`./src/assets/data/contracts/${network}.json`,
JSON.stringify(sortedContracts, null, 2)
JSON.stringify(sortedContracts, null, 2) + '\n'
);
});
}
Expand Down

0 comments on commit 720b673

Please sign in to comment.