From dd1648420417a0112743fae356c806152619aa32 Mon Sep 17 00:00:00 2001 From: bigboydiamonds <57741810+bigboydiamonds@users.noreply.github.com> Date: Tue, 13 Aug 2024 15:47:14 -0700 Subject: [PATCH] feat: track quoted tokens <> bridge quote --- .../BridgeTransactionButton.tsx | 16 ++++++++++++---- packages/synapse-interface/constants/bridge.ts | 4 ++++ .../pages/state-managed-bridge/index.tsx | 2 ++ packages/synapse-interface/utils/types/index.tsx | 2 ++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/packages/synapse-interface/components/StateManagedBridge/BridgeTransactionButton.tsx b/packages/synapse-interface/components/StateManagedBridge/BridgeTransactionButton.tsx index a90df5f588..4ebc532e19 100644 --- a/packages/synapse-interface/components/StateManagedBridge/BridgeTransactionButton.tsx +++ b/packages/synapse-interface/components/StateManagedBridge/BridgeTransactionButton.tsx @@ -80,12 +80,16 @@ export const BridgeTransactionButton = ({ const stringifiedBridgeQuote = constructStringifiedBridgeSelections( bridgeQuote.inputAmountForQuote, bridgeQuote.originChainId, - bridgeQuote.destChainId + bridgeQuote.originTokenForQuote, + bridgeQuote.destChainId, + bridgeQuote.destTokenForQuote ) const stringifiedBridgeState = constructStringifiedBridgeSelections( debouncedFromValue, fromChainId, - toChainId + fromToken, + toChainId, + toToken ) const bridgeStateMatchesQuote = @@ -207,12 +211,16 @@ export const BridgeTransactionButton = ({ const constructStringifiedBridgeSelections = ( originAmount, originChainId, - destinationChainId + originToken, + destChainId, + destToken ) => { const state = { originAmount, originChainId, - destinationChainId, + originToken, + destChainId, + destToken, } return JSON.stringify(state) } diff --git a/packages/synapse-interface/constants/bridge.ts b/packages/synapse-interface/constants/bridge.ts index 5219d29bac..51575df6d5 100644 --- a/packages/synapse-interface/constants/bridge.ts +++ b/packages/synapse-interface/constants/bridge.ts @@ -5,6 +5,8 @@ export const QUOTE_POLLING_INTERVAL = 10000 export const EMPTY_BRIDGE_QUOTE = { inputAmountForQuote: '', + originTokenForQuote: null, + destTokenForQuote: null, outputAmount: 0n, outputAmountString: '', routerAddress: '', @@ -24,6 +26,8 @@ export const EMPTY_BRIDGE_QUOTE = { export const EMPTY_BRIDGE_QUOTE_ZERO = { inputAmountForQuote: '', + originTokenForQuote: null, + destTokenForQuote: null, outputAmount: 0n, outputAmountString: '0', routerAddress: '', diff --git a/packages/synapse-interface/pages/state-managed-bridge/index.tsx b/packages/synapse-interface/pages/state-managed-bridge/index.tsx index 7060a2aa2e..6519284069 100644 --- a/packages/synapse-interface/pages/state-managed-bridge/index.tsx +++ b/packages/synapse-interface/pages/state-managed-bridge/index.tsx @@ -285,6 +285,8 @@ const StateManagedBridge = () => { dispatch( setBridgeQuote({ inputAmountForQuote: debouncedFromValue, + originTokenForQuote: fromToken, + destTokenForQuote: toToken, outputAmount: toValueBigInt, outputAmountString: commify( formatBigIntToString( diff --git a/packages/synapse-interface/utils/types/index.tsx b/packages/synapse-interface/utils/types/index.tsx index 31660e54ed..3ee2342940 100644 --- a/packages/synapse-interface/utils/types/index.tsx +++ b/packages/synapse-interface/utils/types/index.tsx @@ -71,6 +71,8 @@ type QuoteQuery = { export type BridgeQuote = { inputAmountForQuote: string + originTokenForQuote: Token + destTokenForQuote: Token outputAmount: bigint outputAmountString: string routerAddress: string