From 82eded2dc37e38ab0a4b506a561d4e123f59b8df Mon Sep 17 00:00:00 2001 From: Gareth Fuller Date: Tue, 4 Jul 2023 14:24:57 +0100 Subject: [PATCH 1/5] feat: Re-enable native asset joins for deep pools --- .../forms/pool_actions/AddLiquidityForm/AddLiquidityForm.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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] : []; } From efbc3d7280558514c75f73eb3694253bf664ec54 Mon Sep 17 00:00:00 2001 From: Gareth Fuller Date: Tue, 4 Jul 2023 14:25:56 +0100 Subject: [PATCH 2/5] chore: Log query inputs --- .../pools/joins/handlers/generalised-join.handler.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) 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..728223b5b1 100644 --- a/src/services/balancer/pools/joins/handlers/generalised-join.handler.ts +++ b/src/services/balancer/pools/joins/handlers/generalised-join.handler.ts @@ -67,6 +67,16 @@ export class GeneralisedJoinHandler implements JoinPoolHandler { console.log({ simulationType }); + console.log('inputs', { + poolId, + tokenAddresses, + evmAmountsIn, + signerAddress, + slippage, + simulationType, + relayerSignature, + }); + this.lastJoinRes = await this.sdk.pools.generalisedJoin( poolId, tokenAddresses, From 6e1c7b34f2f98f2b04d76385f2e9a8bb2229f24c Mon Sep 17 00:00:00 2001 From: Gareth Fuller Date: Wed, 5 Jul 2023 09:24:06 +0100 Subject: [PATCH 3/5] chore: Ensure zero addrress is passed for native asset joins --- .../handlers/generalised-join.handler.ts | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) 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 728223b5b1..7f71d421aa 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 @@ -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; @@ -67,16 +71,7 @@ export class GeneralisedJoinHandler implements JoinPoolHandler { console.log({ simulationType }); - console.log('inputs', { - poolId, - tokenAddresses, - evmAmountsIn, - signerAddress, - slippage, - simulationType, - relayerSignature, - }); - + console.log('tokenAddresses', tokenAddresses); this.lastJoinRes = await this.sdk.pools.generalisedJoin( poolId, tokenAddresses, @@ -106,4 +101,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; + } } From 546dfa6d7e2d5ebb33e4bb0424ac7ed44a18f384 Mon Sep 17 00:00:00 2001 From: Gareth Fuller Date: Wed, 5 Jul 2023 09:33:09 +0100 Subject: [PATCH 4/5] chore: Pass value to sendTransaction --- .../pools/joins/handlers/generalised-join.handler.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 7f71d421aa..3495e9dc77 100644 --- a/src/services/balancer/pools/joins/handlers/generalised-join.handler.ts +++ b/src/services/balancer/pools/joins/handlers/generalised-join.handler.ts @@ -32,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({ @@ -71,7 +71,6 @@ export class GeneralisedJoinHandler implements JoinPoolHandler { console.log({ simulationType }); - console.log('tokenAddresses', tokenAddresses); this.lastJoinRes = await this.sdk.pools.generalisedJoin( poolId, tokenAddresses, From 3d20414a2abc184435cfe9356dde3506ad360a7e Mon Sep 17 00:00:00 2001 From: Gareth Fuller Date: Wed, 5 Jul 2023 09:54:48 +0100 Subject: [PATCH 5/5] chore: Fix test --- .../pools/joins/handlers/generalised-join.handler.spec.ts | 2 ++ tests/unit/builders/signer.ts | 1 + 2 files changed, 3 insertions(+) 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/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();