Skip to content

Commit

Permalink
Merge d23cb0a into 751857d
Browse files Browse the repository at this point in the history
  • Loading branch information
abtestingalpha authored Aug 13, 2024
2 parents 751857d + d23cb0a commit fef82f9
Show file tree
Hide file tree
Showing 17 changed files with 301 additions and 895 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getValidAddress, isValidAddress } from '@/utils/isValidAddress'
import { EMPTY_BRIDGE_QUOTE } from '@/constants/bridge'
import { CHAINS_BY_ID } from '@constants/chains'
import * as CHAINS from '@constants/chains/master'
import { useBridgeQuoteState } from '@/slices/bridgeQuote/hooks'

export const BridgeExchangeRateInfo = () => {
/* TODO:
Expand Down Expand Up @@ -55,10 +56,11 @@ const DestinationAddress = () => {
}

const Slippage = () => {
const { fromValue } = useBridgeState()

const {
fromValue,
bridgeQuote: { exchangeRate },
} = useBridgeState()
} = useBridgeQuoteState()

const { formattedPercentSlippage, safeFromAmount, underFee, textColor } =
useExchangeRateInfo(fromValue, exchangeRate)
Expand All @@ -77,7 +79,7 @@ const Slippage = () => {
const Router = () => {
const {
bridgeQuote: { bridgeModuleName },
} = useBridgeState()
} = useBridgeQuoteState()
return (
<div className="flex justify-between">
<span className="text-zinc-500 dark:text-zinc-400">Router</span>
Expand All @@ -87,7 +89,8 @@ const Router = () => {
}

const TimeEstimate = () => {
const { fromToken, bridgeQuote } = useBridgeState()
const { fromToken } = useBridgeState()
const { bridgeQuote } = useBridgeQuoteState()

let showText
let showTime
Expand Down Expand Up @@ -125,10 +128,10 @@ const TimeEstimate = () => {

const GasDropLabel = () => {
let decimalsToDisplay
const { toChainId } = useBridgeState()
const {
bridgeQuote: { gasDropAmount },
toChainId,
} = useBridgeState()
} = useBridgeQuoteState()
const symbol = CHAINS_BY_ID[toChainId]?.nativeCurrency.symbol

if ([CHAINS.FANTOM.id].includes(toChainId)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMemo } from 'react'
import { TransactionButton } from '@/components/buttons/TransactionButton'
import { EMPTY_BRIDGE_QUOTE, EMPTY_BRIDGE_QUOTE_ZERO } from '@/constants/bridge'
import { EMPTY_BRIDGE_QUOTE } from '@/constants/bridge'
import { useAccount, useAccountEffect, useSwitchChain } from 'wagmi'
import { useEffect, useState } from 'react'
import { isAddress } from 'viem'
Expand All @@ -12,6 +12,7 @@ import { usePortfolioBalances } from '@/slices/portfolio/hooks'
import { useAppDispatch } from '@/store/hooks'
import { setIsDestinationWarningAccepted } from '@/slices/bridgeDisplaySlice'
import { useWalletState } from '@/slices/wallet/hooks'
import { useBridgeQuoteState } from '@/slices/bridgeQuote/hooks'

export const BridgeTransactionButton = ({
approveTxn,
Expand Down Expand Up @@ -43,10 +44,10 @@ export const BridgeTransactionButton = ({
toToken,
fromChainId,
toChainId,
isLoading,
bridgeQuote,
} = useBridgeState()

const { isLoading, bridgeQuote } = useBridgeQuoteState()

const { isWalletPending } = useWalletState()
const { showDestinationWarning, isDestinationWarningAccepted } =
useBridgeDisplayState()
Expand Down Expand Up @@ -89,7 +90,6 @@ export const BridgeTransactionButton = ({
const isButtonDisabled =
isLoading ||
isWalletPending ||
bridgeQuote === EMPTY_BRIDGE_QUOTE_ZERO ||
bridgeQuote === EMPTY_BRIDGE_QUOTE ||
(destinationAddress && !isAddress(destinationAddress)) ||
(isConnected && !sufficientBalance) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import { CHAINS_BY_ID } from '@/constants/chains'
import { setToChainId, setToToken } from '@/slices/bridge/reducer'
import { useBridgeDisplayState, useBridgeState } from '@/slices/bridge/hooks'
import { useWalletState } from '@/slices/wallet/hooks'
import { useBridgeQuoteState } from '@/slices/bridgeQuote/hooks'

export const OutputContainer = () => {
const { address } = useAccount()
const { bridgeQuote, isLoading } = useBridgeState()
const { bridgeQuote, isLoading } = useBridgeQuoteState()
const { showDestinationAddress } = useBridgeDisplayState()

const showValue =
Expand Down
18 changes: 1 addition & 17 deletions packages/synapse-interface/constants/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,9 @@ export const EMPTY_BRIDGE_QUOTE = {
timestamp: null,
originChainId: null,
destChainId: null,
requestId: null,
}

export const EMPTY_BRIDGE_QUOTE_ZERO = {
outputAmount: 0n,
outputAmountString: '0',
routerAddress: '',
allowance: 0n,
exchangeRate: 0n,
feeAmount: 0n,
delta: 0n,
originQuery: null,
destQuery: null,
estimatedTime: null,
bridgeModuleName: null,
gasDropAmount: 0n,
timestamp: null,
originChainId: null,
destChainId: null,
}
/**
* ETH Only Bridge Config used to calculate swap fees
*
Expand Down
Loading

0 comments on commit fef82f9

Please sign in to comment.