Skip to content

Commit

Permalink
Merge latest master hotfixes into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
agualis committed Jul 20, 2023
1 parent 801ffdc commit fd756ba
Show file tree
Hide file tree
Showing 16 changed files with 61 additions and 30 deletions.
18 changes: 9 additions & 9 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@balancer/frontend-v2",
"version": "1.114.20",
"version": "1.114.27",
"engines": {
"node": "=16",
"npm": ">=8"
Expand Down Expand Up @@ -42,7 +42,7 @@
"devDependencies": {
"@aave/protocol-js": "^4.3.0",
"@balancer-labs/assets": "github:balancer-labs/assets#master",
"@balancer-labs/sdk": "^1.1.3-beta.13",
"@balancer-labs/sdk": "^1.1.3-beta.14",
"@balancer-labs/typechain": "^1.0.0",
"@balancer-labs/v2-deployments": "^3.2.0",
"@cowprotocol/contracts": "^1.3.1",
Expand Down
2 changes: 1 addition & 1 deletion src/components/contextual/pages/claim/LegacyClaims.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ async function claimAvailableRewards() {
});
txListener(tx, {
onTxConfirmed: () => {
onTxConfirmed: async () => {
isClaiming.value = false;
userClaimsQuery.refetch();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async function handleTransaction(
});
txListener(tx, {
onTxConfirmed: () => {
onTxConfirmed: async () => {
setSyncTxHashes(network, tx.hash);
},
onTxFailed: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from '@/composables/usePoolHelpers';
import { useI18n } from 'vue-i18n';
import { Pool } from '@/services/pool/types';
import useNetwork from '@/composables/useNetwork';
type Props = {
pool: Pool;
Expand All @@ -37,7 +38,8 @@ const showPreview = ref(false);
const { t } = useI18n();
const { veBalTokenInfo } = useVeBal();
const { wrappedNativeAsset, nativeAsset } = useTokens();
const router = useRouter();
const { networkSlug } = useNetwork();
const { isWalletReady, startConnectWithInjectedProvider, isMismatchedNetwork } =
useWeb3();
const {
Expand All @@ -52,6 +54,7 @@ const {
hasAcceptedHighPriceImpact,
hasAmountsOut,
validAmounts,
hasBpt,
} = useExitPool();
const { isWrappedNativeAssetPool } = usePoolHelpers(pool);
Expand Down Expand Up @@ -90,6 +93,10 @@ const excludedTokens = computed((): string[] => {
* CALLBACKS
*/
onBeforeMount(() => {
// If user has no BPT when mounting this component, redirect back to pool page
if (!hasBpt.value)
router.push({ name: 'pool', params: { networkSlug, id: props.pool.id } });
singleAmountOut.address = isPreMintedBptType(pool.value.poolType)
? wrappedNativeAsset.value.address
: pool.value.tokensList[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const withdrawalConfirmed = ref(false);
const { t } = useI18n();
const { getToken } = useTokens();
const { networkSlug } = useNetwork();
const router = useRouter();
const {
bptIn,
Expand All @@ -52,6 +53,7 @@ const {
fiatAmountsOut,
isSingleAssetExit,
shouldExitViaInternalBalance,
hasBpt,
} = useExitPool();
/**
Expand Down Expand Up @@ -106,7 +108,13 @@ const amountsOutMap = computed((): AmountMap => {
* METHODS
*/
function handleClose(): void {
emit('close');
// If user has withdrawn everything, send back to pool page. Else, close
// modal.
if (!hasBpt.value) {
router.push({ name: 'pool', params: { networkSlug, id: props.pool.id } });
} else {
emit('close');
}
}
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/composables/approvals/useRelayerApprovalTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default function useRelayerApprovalTx(
});

approved.value = await txListener(tx, {
onTxConfirmed: () => {
onTxConfirmed: async () => {
approving.value = false;
relayerApproval.refetch();
},
Expand Down
2 changes: 1 addition & 1 deletion src/composables/approvals/useTokenApproval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default function useTokenApproval(
});

txListener(tx, {
onTxConfirmed: () => {
onTxConfirmed: async () => {
approving.value = false;
approved.value = true;
},
Expand Down
2 changes: 1 addition & 1 deletion src/composables/swap/useJoinExit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export default function useJoinExit({
}

await txListener(tx, {
onTxConfirmed: () => {
onTxConfirmed: async () => {
confirming.value = false;
relayerApprovalQuery.refetch();
},
Expand Down
4 changes: 1 addition & 3 deletions src/composables/swap/useSor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,6 @@ export default function useSor({
return;
}

amount = bnum(amount).toString();

const tokenInAddress = tokenInAddressInput.value;
const tokenOutAddress = tokenOutAddressInput.value;

Expand Down Expand Up @@ -591,7 +589,7 @@ export default function useSor({
toFiat(tokenInAmountInput.value, tokenInAddressInput.value) || '0';

txListener(tx, {
onTxConfirmed: () => {
onTxConfirmed: async () => {
trackGoal(Goals.Swapped, bnum(swapUSDValue).times(100).toNumber() || 0);
swapping.value = false;
latestTxHash.value = tx.hash;
Expand Down
12 changes: 5 additions & 7 deletions src/composables/useEthers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,19 @@ import {
} from '@/lib/utils/promise';
import { rpcProviderService } from '@/services/rpc-provider/rpc-provider.service';

import useBlocknative from './useBlocknative';
import { toJsTimestamp } from './useTime';
import { useTokens } from '@/providers/tokens.provider';
import useTransactions from './useTransactions';
import { captureBalancerException } from '@/lib/utils/errors';

type ConfirmedTxCallback = (receipt: TransactionReceipt) => void;
type ConfirmedTxCallback = (receipt: TransactionReceipt) => Promise<void>;
type FailedTxCallback = (txData: TransactionResponse) => void;

// keep a record of processed txs
export const processedTxs = ref<Set<string>>(new Set(''));

export default function useEthers() {
const { finalizeTransaction, updateTransaction } = useTransactions();
const { supportsBlocknative } = useBlocknative();
const { refetchBalances } = useTokens();

async function getTxConfirmedAt(receipt: TransactionReceipt): Promise<Date> {
Expand All @@ -50,7 +48,7 @@ export default function useEthers() {
txListener(
tx,
{
onTxConfirmed: () => {
onTxConfirmed: async () => {
resolve(true);
},
onTxFailed: () => {
Expand Down Expand Up @@ -106,9 +104,9 @@ export default function useEthers() {
if (receipt != null) {
finalizeTransaction(txHash, 'tx', receipt);
}
callbacks.onTxConfirmed(receipt);
if (shouldRefetchBalances && !supportsBlocknative.value) {
refetchBalances();
await callbacks.onTxConfirmed(receipt);
if (shouldRefetchBalances) {
await refetchBalances();
}
confirmed = true;
} catch (error) {
Expand Down
1 change: 1 addition & 0 deletions src/lib/config/arbitrum/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const pools: Pools = {
'0xbe0f30217be1e981add883848d0773a86d2d2cd4000000000000000000000471', // rETH-bb-a-WETH
'0x45c4d1376943ab28802b995acffc04903eb5223f000000000000000000000470', // wstETH-bb-a-WETH
'0xc6eee8cb7643ec2f05f46d569e9ec8ef8b41b389000000000000000000000475', // bb-a-USD
'0x3fd4954a851ead144c2ff72b1f5a38ea5976bd54000000000000000000000480', // ankreth/wsteth
],
},
Investment: {
Expand Down
8 changes: 8 additions & 0 deletions src/lib/config/mainnet/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ const pools: Pools = {
'0x3fa8c89704e5d07565444009e5d9e624b40be813000000000000000000000599', // gho/lusd
'0x9a172e1cb0e99f7e6dcc4c52e4655e8f337d5c0000000000000000000000059a', // gho/mai
'0xc2b021133d1b0cf07dba696fd5dd89338428225b000000000000000000000598', // gho/bb-a-usd
'0xe2d16b0a39f3fbb4389a0e8f1efcbecfb3d1e6e10000000000000000000005a7', // dusd-bb-a-usd
],
},
Investment: {
Expand Down Expand Up @@ -505,6 +506,12 @@ const pools: Pools = {
boosted: true,
boostedProtocols: [BoostedProtocol.Aave],
},
'0xe2d16b0a39f3fbb4389a0e8f1efcbecfb3d1e6e10000000000000000000005a7': {
name: 'DUSD/Boosted Aave v3 USD',
hasIcon: false,
boosted: true,
boostedProtocols: [BoostedProtocol.Aave],
},
},
Deep: [
'0x7b50775383d3d6f0215a8f290f2c9e2eebbeceb20000000000000000000000fe', // bb-a-USD1 (mainnet)
Expand Down Expand Up @@ -548,6 +555,7 @@ const pools: Pools = {
'0x41503c9d499ddbd1dcdf818a1b05e9774203bf46000000000000000000000594', // wstETH-bb-a-WETH-BPT
'0xd7edb56f63b2a0191742aea32df1f98ca81ed9c600000000000000000000058e', // B-wstETH/bb-ma3-weth
'0xc2b021133d1b0cf07dba696fd5dd89338428225b000000000000000000000598', // gho/bb-a-usd
'0xe2d16b0a39f3fbb4389a0e8f1efcbecfb3d1e6e10000000000000000000005a7', // dusd-bb-a-usd
],
BoostedApr: [
'0x7b50775383d3d6f0215a8f290f2c9e2eebbeceb2', // bb-a-USD1 (mainnet)
Expand Down
1 change: 1 addition & 0 deletions src/lib/config/polygon/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ const pools: Pools = {
'0x2814a9f16d7b5b5826df47f702f16279ccd799c8000200000000000000000bd1', // 50wMatic-50stMatic
'0xa874e67a1b203819bce84f161eba4b4eb3f4359b000200000000000000000bcc', // 50USDC-50TRYB
'0xa5a935833f6a5312715f182733eab088452335d7000100000000000000000bee', // 30WBTC-20stMATIC-bb-a-WMATIC
'0xaaf737aeb1e5f1dc9429de4a639fe16c42fa1fe3000200000000000000000bf9', // 50fireEP-50FBX
],
},
Factories: {
Expand Down
13 changes: 12 additions & 1 deletion src/lib/utils/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,15 @@ function isUserNotEnoughGas(error): boolean {
return isErrorOfType(error, messages);
}

/**
* Checks if error is caused by user's RPC
*/
function isBadRpcError(error): boolean {
const messages = [/invalid rpc url/];

return isErrorOfType(error, messages);
}

/**
* Checks if error is a testnet faucet refill error.
*/
Expand All @@ -289,7 +298,9 @@ function isBotError(error): boolean {
* Checks if error is caused by the user or the state of their wallet.
*/
export function isUserError(error): boolean {
return isUserRejected(error) || isUserNotEnoughGas(error);
return (
isUserRejected(error) || isUserNotEnoughGas(error) || isBadRpcError(error)
);
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/pages/pool/withdraw.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { usePoolHelpers } from '@/composables/usePoolHelpers';
import { oneSecondInMs } from '@/composables/useTime';
import { useIntervalFn } from '@vueuse/core';
import { computed } from 'vue';
import { hasFetchedPoolsForSor } from '@/lib/balancer.sdk';
import WithdrawPage from '@/components/contextual/pages/pool/withdraw/WithdrawPage.vue';
import { useTokens } from '@/providers/tokens.provider';
Expand Down

0 comments on commit fd756ba

Please sign in to comment.