From 5e61cf3ab667c2c169fdc47d6be7aaae6cd0f71e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CF=87=C2=B2?= <88190723+ChiTimesChi@users.noreply.github.com> Date: Tue, 6 Aug 2024 11:42:54 +0100 Subject: [PATCH] feat(synapse-interface): use origin user address for getting bridge quotes (#2969) * feat: pass connected address as `originUserAddress` option * feat: use `originUserAddress` option for gas estimation --- .../pages/state-managed-bridge/index.tsx | 5 ++++- .../synapse-interface/utils/hooks/useGasEstimator.ts | 11 ++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/synapse-interface/pages/state-managed-bridge/index.tsx b/packages/synapse-interface/pages/state-managed-bridge/index.tsx index 0dabb3dd23..f81cdbb114 100644 --- a/packages/synapse-interface/pages/state-managed-bridge/index.tsx +++ b/packages/synapse-interface/pages/state-managed-bridge/index.tsx @@ -163,7 +163,10 @@ const StateManagedBridge = () => { toChainId, fromToken.addresses[fromChainId], toToken.addresses[toChainId], - stringToBigInt(debouncedFromValue, fromToken?.decimals[fromChainId]) + stringToBigInt(debouncedFromValue, fromToken?.decimals[fromChainId]), + { + originUserAddress: address, + } ) const pausedBridgeModules = new Set( diff --git a/packages/synapse-interface/utils/hooks/useGasEstimator.ts b/packages/synapse-interface/utils/hooks/useGasEstimator.ts index 7d6f49984c..3bca6a8f10 100644 --- a/packages/synapse-interface/utils/hooks/useGasEstimator.ts +++ b/packages/synapse-interface/utils/hooks/useGasEstimator.ts @@ -151,7 +151,8 @@ const getBridgeQuote = async ( toChainId: number, fromToken: Token, toToken: Token, - amount: string + amount: string, + userAddress: string ) => { try { return await synapseSDK.bridgeQuote( @@ -159,7 +160,10 @@ const getBridgeQuote = async ( toChainId, fromToken.addresses[fromChainId], toToken.addresses[toChainId], - stringToBigInt(amount, fromToken?.decimals[fromChainId]) + stringToBigInt(amount, fromToken?.decimals[fromChainId]), + { + originUserAddress: userAddress, + } ) } catch (error) { console.error('getBridgeQuote: ', error) @@ -248,7 +252,8 @@ const queryEstimatedBridgeGasLimit = async ( toChainId, fromToken, toToken, - amount + amount, + address // userAddress ) const bridgePayload = await getBridgePayload(