Skip to content

Commit

Permalink
fix bugs related with Router and ticks and add LUX icons
Browse files Browse the repository at this point in the history
  • Loading branch information
foxier25 committed Oct 11, 2024
1 parent 83f60d3 commit c3596d7
Show file tree
Hide file tree
Showing 14 changed files with 99 additions and 44 deletions.
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"wake.compiler.solc.remappings": [
"@openzeppelin/=node_modules/@openzeppelin/",
"@uniswap/=node_modules/@uniswap/",
"base64-sol/=node_modules/base64-sol/",
"openzeppelin-solidity-2.3.0/=node_modules/openzeppelin-solidity-2.3.0/"
]
}
Binary file added src/assets/images/lux-Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/assets/svg/lux_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion src/components/NetworkAlert/NetworkAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const SHOULD_SHOW_ALERT = {
[SupportedChainId.POLYGON_MUMBAI]: true,
[SupportedChainId.CELO]: true,
[SupportedChainId.CELO_ALFAJORES]: true,
[SupportedChainId.LUX]: true,
}

type NetworkAlertChains = keyof typeof SHOULD_SHOW_ALERT
Expand All @@ -53,6 +54,8 @@ const BG_COLORS_BY_DARK_MODE_AND_CHAIN_ID: {
'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(90, 190, 170, 0.15) 0%, rgba(80, 160, 40, 0.15) 100%)',
[SupportedChainId.CELO_ALFAJORES]:
'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(90, 190, 170, 0.15) 0%, rgba(80, 160, 40, 0.15) 100%)',
[SupportedChainId.LUX]:
'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(90, 190, 170, 0.15) 0%, rgba(80, 160, 40, 0.15) 100%)',
[SupportedChainId.OPTIMISM]:
'radial-gradient(948% 292% at 42% 0%, rgba(255, 58, 212, 0.01) 0%, rgba(255, 255, 255, 0.04) 100%),radial-gradient(98% 96% at 2% 0%, rgba(255, 39, 39, 0.01) 0%, rgba(235, 0, 255, 0.01) 96%)',
[SupportedChainId.OPTIMISM_GOERLI]:
Expand All @@ -69,6 +72,8 @@ const BG_COLORS_BY_DARK_MODE_AND_CHAIN_ID: {
'radial-gradient(182.71% 205.59% at 2.81% 7.69%, rgba(130, 71, 229, 0.2) 0%, rgba(167, 202, 255, 0.2) 100%)',
[SupportedChainId.CELO]:
'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(63, 208, 137, 0.15) 0%, rgba(49, 205, 50, 0.15) 100%)',
[SupportedChainId.LUX]:
'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(63, 208, 137, 0.15) 0%, rgba(49, 205, 50, 0.15) 100%)',
[SupportedChainId.CELO_ALFAJORES]:
'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(63, 208, 137, 0.15) 0%, rgba(49, 205, 50, 0.15) 100%)',
[SupportedChainId.OPTIMISM]:
Expand Down Expand Up @@ -133,6 +138,7 @@ const TEXT_COLORS: { [chainId in NetworkAlertChains]: string } = {
[SupportedChainId.POLYGON]: 'rgba(130, 71, 229)',
[SupportedChainId.POLYGON_MUMBAI]: 'rgba(130, 71, 229)',
[SupportedChainId.CELO]: 'rgba(53, 178, 97)',
[SupportedChainId.LUX]: 'rgba(53, 178, 97)',
[SupportedChainId.CELO_ALFAJORES]: 'rgba(53, 178, 97)',
[SupportedChainId.OPTIMISM]: '#ff3856',
[SupportedChainId.OPTIMISM_GOERLI]: '#ff3856',
Expand All @@ -154,7 +160,6 @@ export function NetworkAlert() {

const { label, logoUrl, bridge } = getChainInfo(chainId)
const textColor = TEXT_COLORS[chainId]

return bridge ? (
<RootWrapper>
<ContentWrapper chainId={chainId} darkMode={darkMode} logoUrl={logoUrl}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/TransactionConfirmationModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function TransactionSubmittedContent({
{chainId && hash && (
<ExternalLink href={getExplorerLink(chainId, hash, ExplorerDataType.TRANSACTION)}>
<Text fontWeight={600} fontSize={14} color={theme.accentAction}>
<Trans>View on Etherscan</Trans>
<Trans>View on Explorer</Trans>
</Text>
</ExternalLink>
)}
Expand Down
3 changes: 2 additions & 1 deletion src/constants/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const V2_ROUTER_ADDRESS: AddressMap = constructSameAddressMap('0x7a250d56
const CELO_V3_CORE_FACTORY_ADDRESSES = '0xAfE208a311B21f13EF87E33A90049fC17A7acDEc'
const CELO_ROUTER_ADDRESS = '0x5615CDAb10dc425a742d643d949a7F474C01abc4'
const LUX_V3_FACTORY_ADDRESS = "0x0650683db720c793ff7e609A08b5fc2792c91f39";
const LUX_ROUTER_ADDRESS = '0xE7b0662a7A45d32a8Ce13A0545bA246F32B86a95';
const LUX_ROUTER_ADDRESS = '0x56bd288aeA22072b5b99Bf3b59C7787B8d5aE7ff';
const CELO_V3_MIGRATOR_ADDRESSES = '0x3cFd4d48EDfDCC53D3f173F596f621064614C582'
const CELO_MULTICALL_ADDRESS = '0x633987602DE5C4F337e3DbF265303A1080324204'
const CELO_QUOTER_ADDRESSES = '0x82825d0554fA07f7FC52Ab63c961F330fdEFa8E8'
Expand Down Expand Up @@ -152,4 +152,5 @@ export const TICK_LENS_ADDRESSES: AddressMap = {
[SupportedChainId.ARBITRUM_RINKEBY]: '0xbfd8137f7d1516D3ea5cA83523914859ec47F573',
[SupportedChainId.CELO]: CELO_TICK_LENS_ADDRESSES,
[SupportedChainId.CELO_ALFAJORES]: CELO_TICK_LENS_ADDRESSES,
[SupportedChainId.LUX]: "0xc3a0F0213CAA01635667B280ffFee18B9c702d6D",
}
8 changes: 5 additions & 3 deletions src/constants/chainInfo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import celoCircleLogoUrl from 'assets/images/celoCircle.png'
import ethereumLogoUrl from 'assets/images/ethereum-logo.png'
import luxLogoUrl from 'assets/images/lux-Logo.png'
import polygonCircleLogoUrl from 'assets/images/polygonCircle.png'
import { default as arbitrumCircleLogoUrl, default as arbitrumLogoUrl } from 'assets/svg/arbitrum_logo.svg'
import celoLogo from 'assets/svg/celo_logo.svg'
Expand Down Expand Up @@ -220,12 +221,13 @@ const CHAIN_INFO: ChainInfoMap = {
[SupportedChainId.LUX]: {
networkType: NetworkType.L1,
blockWaitMsBeforeWarning: ms`10m`,
bridge: 'https://bridge.lux.network/',
docs: 'https://docs.lux.fi/',
logoUrl: celoLogo,
label: "Lux",
nativeCurrency: { name: 'Lux', symbol: 'LUX', decimals: 18 },
explorer: 'https://explore.lux.network',
infoLink: 'https://info.uniswap.org/#/lux/',
logoUrl: luxLogoUrl,
label: "Lux",
nativeCurrency: { name: 'Lux', symbol: 'LUX', decimals: 18 },
},
}

Expand Down
34 changes: 28 additions & 6 deletions src/constants/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export const USDT_LUX = new Token(
'0xd25F88CBdAe3c2CCA3Bb75FC4E723b44C0Ea362F',
18,
"USDT",
"Tether USD",
"LUX USDT",
);
export const WBTC_POLYGON = new Token(
SupportedChainId.POLYGON,
Expand Down Expand Up @@ -280,7 +280,7 @@ export const CUSD_CELO = new Token(
'cUSD',
'Celo Dollar'
);
const LUX_LUX = new Token(SupportedChainId.LUX, "0x53B1aAA5b6DDFD4eD00D0A7b5Ef333dc74B605b5", 18, "LUX", "LUX");
// const LUX_LUX = new Token(SupportedChainId.LUX, "0x53B1aAA5b6DDFD4eD00D0A7b5Ef333dc74B605b5", 18, "LUX", "LUX");
export const CEUR_CELO = new Token(
SupportedChainId.CELO,
'0xD8763CBa276a3738E6DE85b4b3bF5FDed6D6cA73',
Expand Down Expand Up @@ -402,15 +402,19 @@ export const WRAPPED_NATIVE_CURRENCY: { [chainId: number]: Token | undefined } =
SupportedChainId.LUX,
'0x53B1aAA5b6DDFD4eD00D0A7b5Ef333dc74B605b5',
18,
'LUX',
'Lux native asset'
'WLUX',
'Wrapped LUX'
),
}

export function isCelo(chainId: number): chainId is SupportedChainId.CELO | SupportedChainId.CELO_ALFAJORES {
return chainId === SupportedChainId.CELO_ALFAJORES || chainId === SupportedChainId.CELO
}

export function isLUX(chainId: number): chainId is SupportedChainId.LUX {
return chainId === SupportedChainId.LUX
}

function getCeloNativeCurrency(chainId: number) {
switch (chainId) {
case SupportedChainId.CELO_ALFAJORES:
Expand Down Expand Up @@ -444,6 +448,24 @@ class MaticNativeCurrency extends NativeCurrency {
}
}

class LuxNativeCurrency extends NativeCurrency {
equals(other: Currency): boolean {
return other.isNative && other.chainId === this.chainId
}

get wrapped(): Token {
if (!isLUX(this.chainId)) throw new Error('Not LUX')
const wrapped = WRAPPED_NATIVE_CURRENCY[this.chainId]
invariant(wrapped instanceof Token)
return wrapped
}

public constructor(chainId: number) {
if (!isLUX(chainId)) throw new Error('Not LUX')
super(chainId, 18, 'LUX', 'LUX')
}
}

class ExtendedEther extends Ether {
public get wrapped(): Token {
const wrapped = WRAPPED_NATIVE_CURRENCY[this.chainId]
Expand All @@ -466,8 +488,8 @@ export function nativeOnChain(chainId: number): NativeCurrency | Token {
nativeCurrency = new MaticNativeCurrency(chainId)
} else if (isCelo(chainId)) {
nativeCurrency = getCeloNativeCurrency(chainId)
} else if(chainId === SupportedChainId.LUX) {
nativeCurrency = LUX_LUX;
} else if(isLUX(chainId)) {
nativeCurrency = new LuxNativeCurrency(chainId);
} else {
nativeCurrency = ExtendedEther.onChain(chainId)
}
Expand Down
3 changes: 2 additions & 1 deletion src/graphql/data/__generated__/types-and-hooks.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions src/hooks/useBestTrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ export function useBestTrade(
)

const [clientSideRouter] = useClientSideRouter()
// const routingAPITrade = useRoutingAPITrade(
// tradeType,
// autoRouterSupported && isWindowVisible ? debouncedAmount : undefined,
// debouncedOtherCurrency,
// clientSideRouter ? RouterPreference.CLIENT : RouterPreference.API
// )

// const isLoading = routingAPITrade.state === TradeState.LOADING
const useFallback = !autoRouterSupported;
const routingAPITrade = useRoutingAPITrade(
tradeType,
autoRouterSupported && isWindowVisible ? debouncedAmount : undefined,
debouncedOtherCurrency,
clientSideRouter ? RouterPreference.CLIENT : RouterPreference.API
)

const isLoading = routingAPITrade.state === TradeState.LOADING
const useFallback = autoRouterSupported && routingAPITrade.state === TradeState.NO_ROUTE_FOUND;

// only use client side router if routing api trade failed or is not supported
const bestV3Trade = useClientSideV3Trade(
tradeType,
Expand All @@ -53,9 +53,9 @@ export function useBestTrade(
// only return gas estimate from api if routing api trade is used
return useMemo(
() => ({
...bestV3Trade,
// ...(isLoading ? { state: TradeState.LOADING } : {}),
...(useFallback ? bestV3Trade : routingAPITrade),
...(isLoading ? { state: TradeState.LOADING } : {}),
}),
[bestV3Trade, useFallback]
[bestV3Trade, isLoading, routingAPITrade, useFallback]
)
}
40 changes: 25 additions & 15 deletions src/lib/hooks/useCurrencyLogoURIs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import { isAddress } from 'utils'

import EthereumLogo from '../../assets/images/ethereum-logo.png'
import CeloLogo from '../../assets/svg/celo_logo.svg'
import LuxLogo from '../../assets/svg/lux_logo.svg'
import MaticLogo from '../../assets/svg/matic-token-icon.svg'
import { isCelo, NATIVE_CHAIN_ID, nativeOnChain } from '../../constants/tokens'
import { isCelo, isLUX, NATIVE_CHAIN_ID, nativeOnChain } from '../../constants/tokens'

type Network = 'ethereum' | 'arbitrum' | 'optimism' | 'polygon'

Expand All @@ -25,32 +26,41 @@ export function chainIdToNetworkName(networkId: SupportedChainId): Network {
}
}

export function getNativeLogoURI(chainId: SupportedChainId = SupportedChainId.MAINNET): string {
switch (chainId) {
case SupportedChainId.POLYGON:
case SupportedChainId.POLYGON_MUMBAI:
return MaticLogo
case SupportedChainId.CELO:
case SupportedChainId.CELO_ALFAJORES:
return CeloLogo
default:
return EthereumLogo
}
}

function getTokenLogoURI(address: string, chainId: SupportedChainId = SupportedChainId.MAINNET): string | void {
const networkName = chainIdToNetworkName(chainId)
const networksWithUrls = [SupportedChainId.ARBITRUM_ONE, SupportedChainId.MAINNET, SupportedChainId.OPTIMISM]
if (networksWithUrls.includes(chainId)) {
return `https://raw.githubusercontent.com/Uniswap/assets/master/blockchains/${networkName}/assets/${address}/logo.png`
}

// Celo logo logo is hosted elsewhere.
// Celo logo is hosted elsewhere.
if (isCelo(chainId)) {
if (address === nativeOnChain(chainId).wrapped.address) {
return 'https://raw.githubusercontent.com/ubeswap/default-token-list/master/assets/asset_CELO.png'
}
}

// Lux logo is hosted elsewhere.
if (isLUX(chainId)) {
if (address === nativeOnChain(chainId).wrapped.address) {
return 'https://cdn.lux.network/bridge/currencies/lux.png'
}
}
}

export function getNativeLogoURI(chainId: SupportedChainId = SupportedChainId.MAINNET): string {
switch (chainId) {
case SupportedChainId.POLYGON:
case SupportedChainId.POLYGON_MUMBAI:
return MaticLogo
case SupportedChainId.CELO:
case SupportedChainId.CELO_ALFAJORES:
return CeloLogo
case SupportedChainId.LUX:
return LuxLogo
default:
return EthereumLogo
}
}

export default function useCurrencyLogoURIs(
Expand Down
6 changes: 3 additions & 3 deletions src/nft/components/collection/TransactionCompleteModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ const TxCompleteModal = () => {
</Row>
<a href={txHashUrl} target="_blank" rel="noreferrer" style={{ textDecoration: 'none' }}>
<Box color="textSecondary" fontWeight="normal">
<Trans>View on Etherscan</Trans>
<Trans>View on Explorer</Trans>
</Box>
</a>
</Box>
Expand Down Expand Up @@ -247,7 +247,7 @@ const TxCompleteModal = () => {
color="textSecondary"
className={styles.totalEthCost}
>
View on Etherscan
View on Explorer
</Box>
</a>
</Box>
Expand Down Expand Up @@ -358,7 +358,7 @@ const TxCompleteModal = () => {
<p className={styles.totalUsdRefund}>{formatUSDPriceWithCommas(totalUSDRefund)}</p>
<Box className={styles.walletAddress} marginLeft="auto" marginRight="0">
<a href={txHashUrl} target="_blank" rel="noreferrer">
<Box className={styles.addressHash}>View on Etherscan</Box>
<Box className={styles.addressHash}>View on Explorer</Box>
</a>
</Box>
<p className={styles.totalEthCost}>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/CreateProposal/ProposalSubmissionModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const ProposalSubmissionModal = ({
{hash && (
<ExternalLink href={getExplorerLink(1, hash, ExplorerDataType.TRANSACTION)}>
<Text fontWeight={500} fontSize={14} color={theme.accentAction}>
<Trans>View on Etherscan</Trans>
<Trans>View on Explorer</Trans>
</Text>
</ExternalLink>
)}
Expand Down
1 change: 1 addition & 0 deletions src/utils/getExplorerLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const BLOCK_EXPLORER_PREFIXES: { [chainId: number]: string } = {
[SupportedChainId.POLYGON_MUMBAI]: 'https://mumbai.polygonscan.com',
[SupportedChainId.CELO]: 'https://celoscan.io',
[SupportedChainId.CELO_ALFAJORES]: 'https://alfajores-blockscout.celo-testnet.org',
[SupportedChainId.LUX]: 'https://explore.lux.network/',
}

export enum ExplorerDataType {
Expand Down

0 comments on commit c3596d7

Please sign in to comment.