diff --git a/src/components/forms/pool_actions/AddLiquidityForm/AddLiquidityForm.vue b/src/components/forms/pool_actions/AddLiquidityForm/AddLiquidityForm.vue index f9ba3c5998..52c7586e93 100644 --- a/src/components/forms/pool_actions/AddLiquidityForm/AddLiquidityForm.vue +++ b/src/components/forms/pool_actions/AddLiquidityForm/AddLiquidityForm.vue @@ -125,7 +125,7 @@ function tokenOptions(address: string): string[] { return includesAddress( [wrappedNativeAsset.value.address, nativeAsset.address], address - ) && !isDeepPool.value + ) ? [wrappedNativeAsset.value.address, nativeAsset.address] : []; } diff --git a/src/services/balancer/pools/joins/handlers/generalised-join.handler.spec.ts b/src/services/balancer/pools/joins/handlers/generalised-join.handler.spec.ts index e24d938514..8d37dfe0e6 100644 --- a/src/services/balancer/pools/joins/handlers/generalised-join.handler.spec.ts +++ b/src/services/balancer/pools/joins/handlers/generalised-join.handler.spec.ts @@ -9,6 +9,7 @@ import { buildJoinParams } from '@tests/unit/builders/join-exit.builders'; import { defaultGasLimit, defaultTransactionResponse, + defaultTxValue, } from '@tests/unit/builders/signer'; import { GeneralisedJoinHandler } from './generalised-join.handler'; import { initContractConcernWithDefaultMocks } from '@/dependencies/contract.concern.mocks'; @@ -31,5 +32,6 @@ test('Successfully executes a generalized join transaction', async () => { data: defaultGeneralizedJoinResponse.encodedCall, to: defaultGeneralizedJoinResponse.to, gasLimit: defaultGasLimit, + value: defaultTxValue, }); }); diff --git a/src/services/balancer/pools/joins/handlers/generalised-join.handler.ts b/src/services/balancer/pools/joins/handlers/generalised-join.handler.ts index b29fc55818..3495e9dc77 100644 --- a/src/services/balancer/pools/joins/handlers/generalised-join.handler.ts +++ b/src/services/balancer/pools/joins/handlers/generalised-join.handler.ts @@ -4,8 +4,10 @@ import { TransactionResponse } from '@ethersproject/abstract-provider'; import { Ref } from 'vue'; import { JoinParams, JoinPoolHandler, QueryOutput } from './join-pool.handler'; import { formatFixed, parseFixed } from '@ethersproject/bignumber'; -import { bnum, selectByAddress } from '@/lib/utils'; +import { bnum, isSameAddress, selectByAddress } from '@/lib/utils'; import { TransactionBuilder } from '@/services/web3/transactions/transaction.builder'; +import { configService } from '@/services/config/config.service'; +import { AddressZero } from '@ethersproject/constants'; type JoinResponse = Awaited< ReturnType @@ -30,9 +32,9 @@ export class GeneralisedJoinHandler implements JoinPoolHandler { } const txBuilder = new TransactionBuilder(params.signer); - const { to, encodedCall } = this.lastJoinRes; + const { to, encodedCall, value } = this.lastJoinRes; - return txBuilder.raw.sendTransaction({ to, data: encodedCall }); + return txBuilder.raw.sendTransaction({ to, data: encodedCall, value }); } async queryJoin({ @@ -52,7 +54,9 @@ export class GeneralisedJoinHandler implements JoinPoolHandler { return parseFixed(value || '0', token.decimals).toString(); }); - const tokenAddresses: string[] = amountsIn.map(({ address }) => address); + const tokenAddresses: string[] = amountsIn.map(({ address }) => + this.formatTokenAddress(address) + ); const signerAddress = await signer.getAddress(); const slippage = slippageBsp.toString(); const poolId = this.pool.value.id; @@ -96,4 +100,18 @@ export class GeneralisedJoinHandler implements JoinPoolHandler { priceImpact, }; } + + /** + * If native asset addres, replaces with zero address because the vault only checks + * for the zero address when joining with native asset. + */ + private formatTokenAddress(address: string): string { + const { nativeAsset } = configService.network.tokens.Addresses; + + if (isSameAddress(address, nativeAsset)) { + return AddressZero; + } + + return address; + } } diff --git a/tests/unit/builders/signer.ts b/tests/unit/builders/signer.ts index 52b6bda90e..192f2ac5f7 100644 --- a/tests/unit/builders/signer.ts +++ b/tests/unit/builders/signer.ts @@ -10,6 +10,7 @@ defaultTransactionResponse.data = 'default data'; export const defaultGasLimit = 2; const defaultEstimatedGas = BigNumber.from(defaultGasLimit); +export const defaultTxValue = BigNumber.from(0); export function aSigner(...options: Partial[]): JsonRpcSigner { const defaultSigner = mock();