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

Configuration for ApeSwap deployments #1

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion balancer-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ape.swap/swap-v2-sdk",
"version": "0.1.17",
"version": "0.0.1-alpha.2",
"description": "JavaScript SDK for interacting with the Balancer Protocol V2",
"license": "GPL-3.0-only",
"homepage": "https://github.com/ApeSwapFinance/apeswap-swap-v2-sdk/balancer-js#readme",
Expand All @@ -20,6 +20,7 @@
"dist/"
],
"scripts": {
"prepublish": "yarn build",
"build": "rimraf dist && rollup -c",
"dev": "rollup -c -w",
"test": "ts-mocha --paths --recursive -p tsconfig.testing.json 'src/**/*.spec.ts'",
Expand Down
178 changes: 75 additions & 103 deletions balancer-js/src/lib/constants/config.ts
Original file line number Diff line number Diff line change
@@ -1,143 +1,115 @@
import { Network } from './network';
import { BalancerNetworkConfig } from '@/types';

export const balancerVault = '0xBA12222222228d8Ba445958a75a0704d566BF2C8';

export const BALANCER_NETWORK_CONFIG: Record<Network, BalancerNetworkConfig> = {
[Network.MAINNET]: {
chainId: Network.MAINNET, //1
addresses: {
contracts: {
vault: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
multicall: '0xeefba1e63905ef1d7acba5a8513c70307c1ce441',
lidoRelayer: '0xdcdbf71A870cc60C6F9B621E28a7D3Ffd6Dd4965',
},
tokens: {
wrappedNativeAsset: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
lbpRaisingTokens: [
'0x6B175474E89094C44Da98b954EedeAC495271d0F',
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
'0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
],
stETH: '0xae7ab96520de3a18e5e111b5eaab095312d7fe84',
wstETH: '0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
},
/**
* // NOTE: Balancer has deployed the same vault address on every chain which allows them to use a single address here around
* the SDK. ApeSwap has deployed a DUMMY vault on BSC along with the production vault for testing along with Ola,
* which makes this singular address tricky.
*
* For testing purposes we are using the DUMMY vault.
*/
const BSC_PRODUCTION = {
chainId: Network.BSC, //56
addresses: {
contracts: {
vault: '0x000a9e000a35f2cBbE4326578E19dd8Fb4913719',
multicall: '0xC50F4c1E81c873B2204D7eFf7069Ffec6Fbe136D',
},
urls: {
subgraph:
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-v2',
},
pools: {
wETHwstETH: {
id: '0x32296969ef14eb0c6d29669c550d4a0449130230000200000000000000000080',
address: '0x32296969ef14eb0c6d29669c550d4a0449130230',
},
tokens: {
wrappedNativeAsset: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c',
},
},
[Network.POLYGON]: {
chainId: Network.POLYGON, //137
addresses: {
contracts: {
vault: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
multicall: '0xa1B2b503959aedD81512C37e9dce48164ec6a94d',
},
tokens: {
wrappedNativeAsset: '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270',
},
},
urls: {
subgraph:
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-polygon-v2',
},
pools: {},
urls: {
// FIXME: Need to add subgraph url
subgraph: '',
},
[Network.ARBITRUM]: {
chainId: Network.ARBITRUM, //42161
addresses: {
contracts: {
vault: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
multicall: '0x269ff446d9892c9e19082564df3f5e8741e190a1',
},
tokens: {
wrappedNativeAsset: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
},
pools: {},
};

const BSC_DUMMY = {
chainId: Network.BSC, //56
addresses: {
contracts: {
vault: '0x42B7888FFf938C54faeDF52485C8323c4Fc8C99B',
multicall: '0xC50F4c1E81c873B2204D7eFf7069Ffec6Fbe136D',
},
urls: {
subgraph:
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-arbitrum-v2',
tokens: {
wrappedNativeAsset: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c',
},
pools: {},
},
[Network.KOVAN]: {
chainId: Network.KOVAN, //42
addresses: {
contracts: {
vault: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
multicall: '0x2cc8688C5f75E365aaEEb4ea8D6a480405A48D2A',
},
tokens: {
wrappedNativeAsset: '0xdFCeA9088c8A88A76FF74892C1457C17dfeef9C1',
},
},
urls: {
subgraph:
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-kovan-v2',
},
pools: {},
urls: {
subgraph:
'https://balancer.apeswapgraphs.com/subgraphs/name/apeswap/balancer-v2',
},
[Network.ROPSTEN]: {
chainId: Network.ROPSTEN, //3
pools: {},
};


const useDummy = Boolean(process.env.VUE_APP_DUMMY);
const bscConfig = process.env.VUE_APP_DUMMY ? BSC_DUMMY : BSC_PRODUCTION;
export const apeswapVault = bscConfig.addresses.contracts.vault;
// TODO: Remove log
console.log(`swap-v2-sdk/config.ts:: using apeswapVault: ${apeswapVault}.`);
if (useDummy) {
console.log(`swap-v2-sdk/config.ts:: using BSC DUMMY config.`);
}

export const APESWAP_NETWORK_CONFIG: Record<Network, BalancerNetworkConfig> = {
[Network.BSC]: bscConfig,
[Network.BSC_TESTNET]: {
chainId: Network.BSC_TESTNET, //97
addresses: {
contracts: {
vault: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
multicall: '0x53c43764255c17bd724f74c4ef150724ac50a3ed',
vault: '0x000a9e000a35f2cBbE4326578E19dd8Fb4913719',
multicall: '0x7b6838b362f05bA2a0CAA8F9c1B34F3D619e7413',
},
tokens: {
wrappedNativeAsset: '0xdFCeA9088c8A88A76FF74892C1457C17dfeef9C1',
wrappedNativeAsset: '0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd',
},
},
urls: {
subgraph: '',
},
pools: {},
},
[Network.RINKEBY]: {
chainId: Network.RINKEBY, //4
// NOTE: Balancer mainnet config
[Network.MAINNET]: {
chainId: Network.MAINNET as any, //1
addresses: {
contracts: {
vault: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
multicall: '0x42ad527de7d4e9d9d011ac45b31d8551f8fe9821',
multicall: '0xeefba1e63905ef1d7acba5a8513c70307c1ce441',
lidoRelayer: '0xdcdbf71A870cc60C6F9B621E28a7D3Ffd6Dd4965',
},
tokens: {
wrappedNativeAsset: '0xdFCeA9088c8A88A76FF74892C1457C17dfeef9C1',
wrappedNativeAsset: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
lbpRaisingTokens: [
'0x6B175474E89094C44Da98b954EedeAC495271d0F',
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
'0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
],
stETH: '0xae7ab96520de3a18e5e111b5eaab095312d7fe84',
wstETH: '0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
},
},
urls: {
subgraph:
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-rinkeby-v2',
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-v2',
},
pools: {},
},
[Network.GOERLI]: {
chainId: Network.GOERLI, //5
addresses: {
contracts: {
vault: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
multicall: '0x77dCa2C955b15e9dE4dbBCf1246B4B85b651e50e',
},
tokens: {
wrappedNativeAsset: '0xdFCeA9088c8A88A76FF74892C1457C17dfeef9C1',
pools: {
wETHwstETH: {
id: '0x32296969ef14eb0c6d29669c550d4a0449130230000200000000000000000080',
address: '0x32296969ef14eb0c6d29669c550d4a0449130230',
},
},
urls: {
subgraph:
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-goerli-v2',
},
pools: {},
},
};

export const networkAddresses = (
chainId: number
): BalancerNetworkConfig['addresses'] =>
BALANCER_NETWORK_CONFIG[chainId as Network].addresses;
APESWAP_NETWORK_CONFIG[chainId as Network].addresses;

// TODO: Dynamic vault address?
// export const apeswapVault = (chainId: number): string =>
// APESWAP_NETWORK_CONFIG[chainId as Network].addresses.contracts.vault;
143 changes: 143 additions & 0 deletions balancer-js/src/lib/constants/configBalancer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
import { Network } from './networkBalancer';
import { BalancerNetworkConfig } from '@/types';

export const balancerVault = '0xBA12222222228d8Ba445958a75a0704d566BF2C8';

export const BALANCER_NETWORK_CONFIG: Record<Network, BalancerNetworkConfig> = {
[Network.MAINNET]: {
chainId: Network.MAINNET as any, //1
addresses: {
contracts: {
vault: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
multicall: '0xeefba1e63905ef1d7acba5a8513c70307c1ce441',
lidoRelayer: '0xdcdbf71A870cc60C6F9B621E28a7D3Ffd6Dd4965',
},
tokens: {
wrappedNativeAsset: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
lbpRaisingTokens: [
'0x6B175474E89094C44Da98b954EedeAC495271d0F',
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
'0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
],
stETH: '0xae7ab96520de3a18e5e111b5eaab095312d7fe84',
wstETH: '0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
},
},
urls: {
subgraph:
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-v2',
},
pools: {
wETHwstETH: {
id: '0x32296969ef14eb0c6d29669c550d4a0449130230000200000000000000000080',
address: '0x32296969ef14eb0c6d29669c550d4a0449130230',
},
},
},
[Network.POLYGON]: {
chainId: Network.POLYGON as any, //137
addresses: {
contracts: {
vault: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
multicall: '0xa1B2b503959aedD81512C37e9dce48164ec6a94d',
},
tokens: {
wrappedNativeAsset: '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270',
},
},
urls: {
subgraph:
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-polygon-v2',
},
pools: {},
},
[Network.ARBITRUM]: {
chainId: Network.ARBITRUM as any, //42161
addresses: {
contracts: {
vault: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
multicall: '0x269ff446d9892c9e19082564df3f5e8741e190a1',
},
tokens: {
wrappedNativeAsset: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
},
},
urls: {
subgraph:
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-arbitrum-v2',
},
pools: {},
},
[Network.KOVAN]: {
chainId: Network.KOVAN as any, //42
addresses: {
contracts: {
vault: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
multicall: '0x2cc8688C5f75E365aaEEb4ea8D6a480405A48D2A',
},
tokens: {
wrappedNativeAsset: '0xdFCeA9088c8A88A76FF74892C1457C17dfeef9C1',
},
},
urls: {
subgraph:
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-kovan-v2',
},
pools: {},
},
[Network.ROPSTEN]: {
chainId: Network.ROPSTEN as any, //3
addresses: {
contracts: {
vault: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
multicall: '0x53c43764255c17bd724f74c4ef150724ac50a3ed',
},
tokens: {
wrappedNativeAsset: '0xdFCeA9088c8A88A76FF74892C1457C17dfeef9C1',
},
},
urls: {
subgraph: '',
},
pools: {},
},
[Network.RINKEBY]: {
chainId: Network.RINKEBY as any, //4
addresses: {
contracts: {
vault: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
multicall: '0x42ad527de7d4e9d9d011ac45b31d8551f8fe9821',
},
tokens: {
wrappedNativeAsset: '0xdFCeA9088c8A88A76FF74892C1457C17dfeef9C1',
},
},
urls: {
subgraph:
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-rinkeby-v2',
},
pools: {},
},
[Network.GOERLI]: {
chainId: Network.GOERLI as any, //5
addresses: {
contracts: {
vault: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
multicall: '0x77dCa2C955b15e9dE4dbBCf1246B4B85b651e50e',
},
tokens: {
wrappedNativeAsset: '0xdFCeA9088c8A88A76FF74892C1457C17dfeef9C1',
},
},
urls: {
subgraph:
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-goerli-v2',
},
pools: {},
},
};

export const networkAddresses = (
chainId: number
): BalancerNetworkConfig['addresses'] =>
BALANCER_NETWORK_CONFIG[chainId as Network].addresses;
Loading