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

chore: Balancer sor swap errors should be tagged as fatal #3645

Merged
merged 1 commit into from
Jul 6, 2023
Merged
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
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