Skip to content

Commit

Permalink
fix: Limit swap exits (#3945)
Browse files Browse the repository at this point in the history
* fix: Limit swap exits to deep pools

* chore: Add comment
  • Loading branch information
garethfuller authored Aug 11, 2023
1 parent 67a38b9 commit c229197
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import useVeBal from '@/composables/useVeBAL';
import WithdrawPreviewModal from './components/WithdrawPreviewModal/WithdrawPreviewModal.vue';
import { useTokens } from '@/providers/tokens.provider';
import {
isPreMintedBptType,
tokensListExclBpt,
usePoolHelpers,
} from '@/composables/usePoolHelpers';
Expand Down Expand Up @@ -57,6 +56,7 @@ const {
validAmounts,
hasBpt,
shouldUseRecoveryExit,
canSwapExit,
} = useExitPool();
const { isWrappedNativeAssetPool } = usePoolHelpers(pool);
Expand All @@ -76,8 +76,8 @@ const tokensList = computed(() => tokensListExclBpt(pool.value));
// Limit token select modal to a subset.
const subsetTokens = computed((): string[] => {
if (!shouldUseRecoveryExit.value && isPreMintedBptType(pool.value.poolType))
return [];
// Returning an empty array means all tokens are presented in the modal.
if (!shouldUseRecoveryExit.value && canSwapExit.value) return [];
if (isWrappedNativeAssetPool.value)
return [nativeAsset.address, ...tokensList.value];
Expand Down
10 changes: 7 additions & 3 deletions src/providers/local/exit-pool.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,15 @@ export const exitPoolProvider = (
shouldSignRelayer.value ? [relayerApprovalAction.value] : []
);

const canSwapExit = computed(
(): boolean => isDeep(pool.value) && isPreMintedBptType(pool.value.poolType)
);

const shouldUseSwapExit = computed(
(): boolean =>
isSingleAssetExit.value &&
isDeep(pool.value) &&
isPreMintedBptType(pool.value.poolType) &&
!includesAddress(pool.value.tokensList, singleAmountOut.address)
!includesAddress(pool.value.tokensList, singleAmountOut.address) &&
canSwapExit.value
);

const shouldUseGeneralisedExit = computed(
Expand Down Expand Up @@ -604,6 +607,7 @@ export const exitPoolProvider = (
relayerSignature,
relayerApprovalTx,
shouldUseSwapExit,
canSwapExit,
shouldUseRecoveryExit,

// methods
Expand Down

0 comments on commit c229197

Please sign in to comment.