Skip to content

Commit

Permalink
chore: Balancer sor swap errors should be tagged as fatal (#3645)
Browse files Browse the repository at this point in the history
  • Loading branch information
garethfuller authored Jul 6, 2023
1 parent 696e736 commit f29329c
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/composables/swap/useSor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export default function useSor({
const poolsLoading = ref(true);

// COMPOSABLES
const { getProvider: getWeb3Provider, appNetworkConfig } = useWeb3();
const { account, getProvider: getWeb3Provider, appNetworkConfig } = useWeb3();
const provider = computed(() => getWeb3Provider());
const { trackGoal, Goals } = useFathom();
const { txListener } = useEthers();
Expand Down Expand Up @@ -635,7 +635,7 @@ export default function useSor({
}
trackSwapEvent();
} catch (error) {
handleSwapException(error as Error);
handleSwapException(error as Error, tokenInAddress, tokenOutAddress);
}
return;
} else if (wrapType.value == WrapType.Unwrap) {
Expand All @@ -655,7 +655,7 @@ export default function useSor({
}
trackSwapEvent();
} catch (error) {
handleSwapException(error as Error);
handleSwapException(error as Error, tokenInAddress, tokenOutAddress);
}
return;
}
Expand All @@ -679,7 +679,7 @@ export default function useSor({
}
trackSwapEvent();
} catch (error) {
handleSwapException(error as Error);
handleSwapException(error as Error, tokenInAddress, tokenOutAddress);
}
} else {
const tokenInAmountMax = getMaxIn(tokenInAmountScaled);
Expand All @@ -700,7 +700,7 @@ export default function useSor({
}
trackSwapEvent();
} catch (error) {
handleSwapException(error as Error);
handleSwapException(error as Error, tokenInAddress, tokenOutAddress);
}
}
}
Expand Down Expand Up @@ -797,11 +797,22 @@ export default function useSor({
return amount;
}

function handleSwapException(error: Error) {
function handleSwapException(
error: Error,
tokenIn: string,
tokenOut: string
) {
if (!isUserError(error)) {
console.trace(error);
state.submissionError = t('swapException', ['Balancer']);
captureException(new Error(state.submissionError, { cause: error }));
captureException(new Error(state.submissionError, { cause: error }), {
level: 'fatal',
extra: {
sender: account.value,
tokenIn,
tokenOut,
},
});
}
swapping.value = false;
confirming.value = false;
Expand Down

1 comment on commit f29329c

@vercel
Copy link

@vercel vercel bot commented on f29329c Jul 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.