Skip to content

Commit

Permalink
Merge pull request #423 from balancer/fix-empty-sender-issue
Browse files Browse the repository at this point in the history
fix: Add zero address sender to viem multicall calls to avoid issues with Nethermind/Geth nodes
  • Loading branch information
agualis authored Oct 1, 2024
2 parents 9e08225 + 39bdf35 commit 66c7946
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/nasty-phones-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@balancer/sdk": minor
---

Add zero address sender to multicall calls to avoid issues with Nethermind/Geth nodes
3 changes: 2 additions & 1 deletion src/entities/addLiquidityNested/doAddLiquidityNestedQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
http,
} from 'viem';
import { Hex } from '../../types';
import { BALANCER_RELAYER, CHAINS, ChainId } from '../../utils';
import { BALANCER_RELAYER, CHAINS, ChainId, EMPTY_SENDER } from '../../utils';
import {
balancerRelayerAbi,
permit2Abi,
Expand All @@ -24,6 +24,7 @@ export const doAddLiquidityNestedQuery = async (
});

const { data } = await client.call({
...EMPTY_SENDER,
to: BALANCER_RELAYER[chainId],
data: encodedMulticall,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
http,
} from 'viem';
import { Hex } from '../../types';
import { BALANCER_RELAYER, CHAINS, ChainId } from '../../utils';
import { BALANCER_RELAYER, CHAINS, ChainId, EMPTY_SENDER } from '../../utils';
import { balancerRelayerAbi } from '../../abi';

export const doRemoveLiquidityNestedQuery = async (
Expand All @@ -20,6 +20,7 @@ export const doRemoveLiquidityNestedQuery = async (
});

const { data } = await client.call({
...EMPTY_SENDER,
to: BALANCER_RELAYER[chainId],
data: encodedMulticall,
});
Expand Down
3 changes: 2 additions & 1 deletion src/entities/swap/swaps/v2/auraBalSwaps/joinSwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Hex,
} from 'viem';
import { TokenAmount } from '../../../../tokenAmount';
import { BALANCER_RELAYER, ChainId } from '@/utils';
import { BALANCER_RELAYER, ChainId, EMPTY_SENDER } from '@/utils';
import { balancerRelayerAbi } from '@/abi';
import { Relayer } from '@/entities/relayer';
import { auraBalToken, balWethAddress, auraBAL } from './constants';
Expand Down Expand Up @@ -55,6 +55,7 @@ export async function queryJoinSwap(
});

const { data } = await client.call({
...EMPTY_SENDER,
to: BALANCER_RELAYER[ChainId.MAINNET],
data: encodedMulticall,
});
Expand Down
3 changes: 2 additions & 1 deletion src/entities/swap/swaps/v2/auraBalSwaps/swapExit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Hex,
} from 'viem';
import { TokenAmount } from '../../../../tokenAmount';
import { BALANCER_RELAYER, ChainId } from '@/utils';
import { BALANCER_RELAYER, ChainId, EMPTY_SENDER } from '@/utils';
import { balancerRelayerAbi } from '@/abi';
import { Relayer } from '@/entities/relayer';
import { auraBalToken, balWethAddress, auraBAL } from './constants';
Expand Down Expand Up @@ -56,6 +56,7 @@ export async function querySwapExit(
});

const { data } = await client.call({
...EMPTY_SENDER,
to: BALANCER_RELAYER[ChainId.MAINNET],
data: encodedMulticall,
});
Expand Down
6 changes: 6 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ import {

export const ZERO_ADDRESS: Address =
'0x0000000000000000000000000000000000000000';
/*
Using empty account (undefined by default) in some multicall requests causes failures in some nodes
More info: https://github.com/wevm/viem/issues/2792
*/
export const EMPTY_SENDER = { account: ZERO_ADDRESS };

const NATIVE_ADDRESS: Address = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee';

export const MAX_UINT112 = 5192296858534827628530496329220095n;
Expand Down

0 comments on commit 66c7946

Please sign in to comment.