From 62ac06529dedbc8c7405f7586909c2d1b8229d72 Mon Sep 17 00:00:00 2001 From: Gareth Fuller Date: Wed, 31 Jan 2024 13:18:45 +0000 Subject: [PATCH] chore: Init (#5171) --- .../AddLiquidityForm/AddLiquidityForm.vue | 50 +++---------------- .../components/AddLiquidityTotals.vue | 31 +++++++++++- 2 files changed, 37 insertions(+), 44 deletions(-) diff --git a/src/components/forms/pool_actions/AddLiquidityForm/AddLiquidityForm.vue b/src/components/forms/pool_actions/AddLiquidityForm/AddLiquidityForm.vue index fee0b52ce2..7435f07ef3 100644 --- a/src/components/forms/pool_actions/AddLiquidityForm/AddLiquidityForm.vue +++ b/src/components/forms/pool_actions/AddLiquidityForm/AddLiquidityForm.vue @@ -6,7 +6,7 @@ import StakePreviewModal from '@/components/contextual/pages/pool/staking/StakeP import TokenInput from '@/components/inputs/TokenInput/TokenInput.vue'; import { tokenWeight, usePoolHelpers } from '@/composables/usePoolHelpers'; import { LOW_LIQUIDITY_THRESHOLD } from '@/constants/poolLiquidity'; -import { bnum, includesAddress, isSameAddress } from '@/lib/utils'; +import { bnum, includesAddress } from '@/lib/utils'; import { isRequired } from '@/lib/utils/validations'; import { Pool } from '@/services/pool/types'; import useWeb3 from '@/services/web3/useWeb3'; @@ -15,11 +15,9 @@ import useVeBal from '@/composables/useVeBAL'; import AddLiquidityPreview from './components/AddLiquidityPreview/AddLiquidityPreview.vue'; import AddLiquidityTotals from './components/AddLiquidityTotals.vue'; -import MissingPoolTokensAlert from './components/MissingPoolTokensAlert.vue'; import { useTokens } from '@/providers/tokens.provider'; import { isEqual } from 'lodash'; import { useJoinPool } from '@/providers/local/join-pool.provider'; -import { useUserTokens } from '@/providers/local/user-tokens.provider'; /** * TYPES @@ -42,12 +40,9 @@ const showStakeModal = ref(false); /** * COMPOSABLES */ -const { - managedPoolWithSwappingHalted, - isDeepPool, - isPreMintedBptPool, - poolJoinTokens, -} = usePoolHelpers(toRef(props, 'pool')); +const { managedPoolWithSwappingHalted, poolJoinTokens } = usePoolHelpers( + toRef(props, 'pool') +); const { veBalTokenInfo } = useVeBal(); const { isWalletReady, startConnectWithInjectedProvider, isMismatchedNetwork } = useWeb3(); @@ -64,8 +59,6 @@ const { setTokensIn, } = useJoinPool(); -const { tokensWithBalance } = useUserTokens(); - /** * COMPUTED */ @@ -85,20 +78,6 @@ const excludedTokens = computed((): string[] => { return tokens; }); -const joinTokensWithBalance = computed(() => - poolJoinTokens.value.filter( - address => - includesAddress(tokensWithBalance.value, address) || - isSameAddress(address, wrappedNativeAsset.value.address) - ) -); - -const joinTokensWithoutBalance = computed(() => - poolJoinTokens.value.filter( - address => !includesAddress(tokensWithBalance.value, address) - ) -); - async function initializeTokensForm(isSingleAssetJoin: boolean) { if (isSingleAssetJoin) { // Single asset joins are only relevant for Composable pools where swap @@ -106,7 +85,7 @@ async function initializeTokensForm(isSingleAssetJoin: boolean) { // asset. setTokensIn([wrappedNativeAsset.value.address]); } else { - setTokensIn(joinTokensWithBalance.value); + setTokensIn(poolJoinTokens.value); } } @@ -150,19 +129,13 @@ onBeforeMount(() => { * WATCHERS */ watch( - [isSingleAssetJoin, joinTokensWithBalance], - ( - [isSingleAsset, newJoinTokensWithBalance], - [prevIsSingleAsset, prevJoinTokensWithBalance] - ) => { + [isSingleAssetJoin, poolJoinTokens], + ([isSingleAsset, newJoinTokens], [prevIsSingleAsset, prevJoinToken]) => { // Initialize token form if token balances change (ie. After investing, transaction confirmed or when account changes) // only if preview modal is not open if (!showPreview.value) { const hasTabChanged = prevIsSingleAsset !== isSingleAsset; - const hasUserTokensChanged = !isEqual( - prevJoinTokensWithBalance, - newJoinTokensWithBalance - ); + const hasUserTokensChanged = !isEqual(prevJoinToken, newJoinTokens); if (hasUserTokensChanged || hasTabChanged) { initializeTokensForm(isSingleAsset); } @@ -207,13 +180,6 @@ watch( @update:address="onTokenChange" /> - -
(); */ const { fNum } = useNumbers(); const { isWalletReady } = useWeb3(); +const { slippage } = useUserSettings(); const { highPriceImpact, @@ -24,6 +26,7 @@ const { priceImpact, supportsProportionalOptimization, fiatValueIn, + bptOut, } = useJoinPool(); const { @@ -60,7 +63,31 @@ const {
-
+
+
LP tokens
+
+
+ + {{ fNum(bptOut, FNumFormats.token) }} + + + + + + +
+
+
+
{{ $t('priceImpact') }}
@@ -134,7 +161,7 @@ const { @apply text-lg font-bold dark:bg-gray-800; } -.price-impact-row { +.secondary-row { @apply text-sm rounded-b-lg; }