From bd873fcfc78152caad2174a66978f041bf41110d Mon Sep 17 00:00:00 2001 From: Ansaf Ahmed <40786269+1saf@users.noreply.github.com> Date: Tue, 10 Aug 2021 18:04:41 +0100 Subject: [PATCH] Hotfix/1.12.5 (#654) * fix: add a network key to addressmap to make sure that addressmap pulls tokens for the appropraite nwtwork * update: tick version --- package-lock.json | 7 ++----- package.json | 2 +- src/components/cards/TradeCard/GasReimbursement.vue | 4 +++- src/components/cards/TradeCardGP/TradeCardGP.vue | 4 +++- src/components/forms/pool_actions/InvestForm.vue | 5 +++-- src/components/inputs/TokenSearchInput.vue | 4 ++-- src/components/navs/AppNav/AppNavClaimBtn.vue | 6 +++++- src/composables/usePool.ts | 8 +++++--- src/constants/tokens.ts | 12 +++++++++--- src/services/claim.ts | 3 ++- 10 files changed, 35 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index 426d50caf2..4818a02cae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@balancer-labs/frontend-v2", - "version": "1.12.4", + "version": "1.12.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@balancer-labs/frontend-v2", - "version": "1.12.4", + "version": "1.12.5", "license": "MIT", "dependencies": { "@balancer-labs/assets": "github:balancer-labs/assets#master", @@ -33388,7 +33388,6 @@ "integrity": "sha512-IWnb10ImrzRMT2qw9785p3wYEI6U9gjsg6H2zKcRJQP5dEboqeX3OFjUKfXkaIWii4nz8MtJjBg5t4BdEYqLdw==", "dev": true, "requires": { - "@babel/core": "^7.12.10", "@babel/generator": "^7.12.11", "@babel/parser": "^7.12.11", "@babel/plugin-transform-react-jsx": "^7.12.12", @@ -36843,7 +36842,6 @@ "@vue/babel-preset-app": { "version": "4.5.12", "requires": { - "@babel/core": "^7.11.0", "@babel/helper-compilation-targets": "^7.9.6", "@babel/helper-module-imports": "^7.8.3", "@babel/plugin-proposal-class-properties": "^7.8.3", @@ -36856,7 +36854,6 @@ "@vue/babel-plugin-jsx": "^1.0.3", "@vue/babel-preset-jsx": "^1.2.4", "babel-plugin-dynamic-import-node": "^2.3.3", - "core-js": "^3.6.5", "core-js-compat": "^3.6.5", "semver": "^6.1.0" } diff --git a/package.json b/package.json index 0b78b02076..586ba858e8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@balancer-labs/frontend-v2", - "version": "1.12.4", + "version": "1.12.5", "engines": { "node": "14.x", "npm": ">=7" diff --git a/src/components/cards/TradeCard/GasReimbursement.vue b/src/components/cards/TradeCard/GasReimbursement.vue index af1153fe1c..e488ebfddb 100644 --- a/src/components/cards/TradeCard/GasReimbursement.vue +++ b/src/components/cards/TradeCard/GasReimbursement.vue @@ -71,7 +71,9 @@ export default defineComponent({ const ethPrice = priceFor(appNetworkConfig.nativeAsset.address); const balPrice = priceFor( - coingeckoService.prices.addressMapOut(TOKENS.AddressMap.BAL) + coingeckoService.prices.addressMapOut( + TOKENS.AddressMap[appNetworkConfig.key].BAL + ) ); const gasPrice = store.state.market.gasPrice || 0; diff --git a/src/components/cards/TradeCardGP/TradeCardGP.vue b/src/components/cards/TradeCardGP/TradeCardGP.vue index ee1a497da8..b442e11c2f 100644 --- a/src/components/cards/TradeCardGP/TradeCardGP.vue +++ b/src/components/cards/TradeCardGP/TradeCardGP.vue @@ -113,6 +113,7 @@ import TradeSettingsPopover, { import { configService } from '@/services/config/config.service'; import TradePairGP from './TradePairGP.vue'; +import useWeb3 from '@/services/web3/useWeb3'; const { nativeAsset } = configService.network; @@ -130,6 +131,7 @@ export default defineComponent({ const { t } = useI18n(); const { bp } = useBreakpoints(); const { fNum } = useNumbers(); + const { appNetworkConfig } = useWeb3(); // DATA const exactIn = ref(true); @@ -311,7 +313,7 @@ export default defineComponent({ } function switchToWETH() { - tokenInAddress.value = TOKENS.AddressMap.WETH; + tokenInAddress.value = TOKENS.AddressMap[appNetworkConfig.key].WETH; } // INIT diff --git a/src/components/forms/pool_actions/InvestForm.vue b/src/components/forms/pool_actions/InvestForm.vue index 457647c967..96a7ee9aa3 100644 --- a/src/components/forms/pool_actions/InvestForm.vue +++ b/src/components/forms/pool_actions/InvestForm.vue @@ -151,8 +151,8 @@ :to="{ name: 'trade', params: { - assetIn: TOKENS.AddressMap.ETH, - assetOut: TOKENS.AddressMap.WETH + assetIn: TOKENS.AddressMap[appNetworkConfig.key].ETH, + assetOut: TOKENS.AddressMap[appNetworkConfig.key].WETH } }" class="text-xs text-gray-500 underline" @@ -679,6 +679,7 @@ export default defineComponent({ TOKENS, // computed tokens, + appNetworkConfig, hasValidInputs, hasAmounts, approving, diff --git a/src/components/inputs/TokenSearchInput.vue b/src/components/inputs/TokenSearchInput.vue index e28b14a621..6164381a13 100644 --- a/src/components/inputs/TokenSearchInput.vue +++ b/src/components/inputs/TokenSearchInput.vue @@ -89,7 +89,7 @@ export default defineComponent({ * COMPOSABLES */ const { tokens, balances, dynamicDataLoading } = useTokens(); - const { account } = useWeb3(); + const { account, appNetworkConfig } = useWeb3(); /** * COMPUTED @@ -122,7 +122,7 @@ export default defineComponent({ // special case for ETH where we want it to filter as WETH regardless // as ETH is the native asset if (getAddress(token) === NATIVE_ASSET_ADDRESS) { - _token = TOKENS.AddressMap.WETH; + _token = TOKENS.AddressMap[appNetworkConfig.key].WETH; } // const newSelected = [...props.modelValue, _token]; emit('add', _token); diff --git a/src/components/navs/AppNav/AppNavClaimBtn.vue b/src/components/navs/AppNav/AppNavClaimBtn.vue index b0ff46643f..2566230b3e 100644 --- a/src/components/navs/AppNav/AppNavClaimBtn.vue +++ b/src/components/navs/AppNav/AppNavClaimBtn.vue @@ -138,7 +138,11 @@ export default defineComponent({ const { priceFor } = useTokens(); const balPrice = computed(() => - priceFor(coingeckoService.prices.addressMapOut(TOKENS.AddressMap.BAL)) + priceFor( + coingeckoService.prices.addressMapOut( + TOKENS.AddressMap[appNetworkConfig.key].BAL + ) + ) ); // COMPUTED diff --git a/src/composables/usePool.ts b/src/composables/usePool.ts index 4306949e71..4cfbfb87c3 100644 --- a/src/composables/usePool.ts +++ b/src/composables/usePool.ts @@ -6,6 +6,7 @@ import { PoolType } from '@/services/balancer/subgraph/types'; import { TOKENS } from '@/constants/tokens'; +import useWeb3 from '@/services/web3/useWeb3'; type AnyPool = Pool | FullPool | DecoratedPoolWithShares; @@ -17,14 +18,15 @@ export function isWeighted(pool: AnyPool): boolean { return pool.poolType === PoolType.Weighted; } -export function isWeth(pool: AnyPool): boolean { - return pool.tokenAddresses.includes(TOKENS.AddressMap.WETH); +export function isWeth(pool: AnyPool, networkId: string): boolean { + return pool.tokenAddresses.includes(TOKENS.AddressMap[networkId].WETH); } export function usePool(pool: Ref) { + const { appNetworkConfig } = useWeb3(); const isStablePool = computed(() => isStable(pool.value)); const isWeightedPool = computed(() => isWeighted(pool.value)); - const isWethPool = computed(() => isWeth(pool.value)); + const isWethPool = computed(() => isWeth(pool.value, appNetworkConfig.key)); return { // computed diff --git a/src/constants/tokens.ts b/src/constants/tokens.ts index cf5116e607..233e800c04 100644 --- a/src/constants/tokens.ts +++ b/src/constants/tokens.ts @@ -5,9 +5,15 @@ export const TOKENS = { Symbols: ['WBTC', 'DAI', 'USDC', 'BAL', 'AAVE', 'WETH'] }, AddressMap: { - ETH: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', - WETH: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', - BAL: '0xba100000625a3754423978a60c9317c58a424e3d' + '1': { + ETH: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', + WETH: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', + BAL: '0xba100000625a3754423978a60c9317c58a424e3d' + }, + '137': { + WETH: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619', + BAL: '0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3' + } }, Prices: { ChainMap: { diff --git a/src/services/claim.ts b/src/services/claim.ts index ce498e18f0..69149b300e 100644 --- a/src/services/claim.ts +++ b/src/services/claim.ts @@ -144,9 +144,10 @@ export async function getCurrentRewardsEstimate( incentive => incentive.token_address == coingeckoService.prices - .addressMapOut(TOKENS.AddressMap.BAL) + .addressMapOut(TOKENS.AddressMap[String(network)].BAL) .toLowerCase() ); + const rewards = liquidityProviders .reduce( (total, { current_estimate }) => total.plus(current_estimate),