Skip to content

Commit

Permalink
Merge pull request #6 from helix-bridge/jay/support-v2
Browse files Browse the repository at this point in the history
feat: support swap v2
  • Loading branch information
xiaoch05 authored Jul 17, 2024
2 parents c7018fb + 8f1fcf0 commit a2a248d
Show file tree
Hide file tree
Showing 12 changed files with 188 additions and 183 deletions.
67 changes: 34 additions & 33 deletions apps/web/src/components/Button/GetHelp.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
import { EnvelopeHeartIcon } from 'components/Icons/EnvelopeHeart'
import Row from 'components/Row'
import { SupportArticleURL } from 'constants/supportArticles'
import { Trans } from 'i18n'
import styled from 'styled-components'
import { ExternalLink } from 'theme/components'
// import { EnvelopeHeartIcon } from 'components/Icons/EnvelopeHeart'
// import Row from 'components/Row'
// import { SupportArticleURL } from 'constants/supportArticles'
// import { Trans } from 'i18n'
// import styled from 'styled-components'
// import { ExternalLink } from 'theme/components'

const StyledExternalLink = styled(ExternalLink)`
width: fit-content;
border-radius: 16px;
padding: 4px 8px;
font-size: 14px;
font-weight: 485;
line-height: 20px;
background: ${({ theme }) => theme.surface2};
color: ${({ theme }) => theme.neutral2};
:hover {
background: ${({ theme }) => theme.surface3};
color: ${({ theme }) => theme.neutral1};
path {
fill: ${({ theme }) => theme.neutral1};
}
opacity: unset;
}
stroke: none;
`
// const StyledExternalLink = styled(ExternalLink)`
// width: fit-content;
// border-radius: 16px;
// padding: 4px 8px;
// font-size: 14px;
// font-weight: 485;
// line-height: 20px;
// background: ${({ theme }) => theme.surface2};
// color: ${({ theme }) => theme.neutral2};
// :hover {
// background: ${({ theme }) => theme.surface3};
// color: ${({ theme }) => theme.neutral1};
// path {
// fill: ${({ theme }) => theme.neutral1};
// }
// opacity: unset;
// }
// stroke: none;
// `
export default function GetHelp() {
return (
<StyledExternalLink href={SupportArticleURL.HOME}>
<Row gap="4px">
<EnvelopeHeartIcon />
<Trans i18nKey="common.getHelp.button" />
</Row>
</StyledExternalLink>
)
return null
// return (
// <StyledExternalLink href={SupportArticleURL.HOME}>
// <Row gap="4px">
// <EnvelopeHeartIcon />
// <Trans i18nKey="common.getHelp.button" />
// </Row>
// </StyledExternalLink>
// )
}
16 changes: 8 additions & 8 deletions apps/web/src/components/ConfirmSwapModal/Error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,40 +38,40 @@ function getErrorContent({ errorType, trade }: { errorType: PendingModalError; t
return {
title: <Trans i18nKey="error.tokenApproval" />,
message: <Trans i18nKey="error.access.expiry" />,
supportArticleURL: SupportArticleURL.APPROVALS_EXPLAINER,
// supportArticleURL: SupportArticleURL.APPROVALS_EXPLAINER,
}
case PendingModalError.PERMIT_ERROR:
return {
title: <Trans i18nKey="permit.approval.fail" />,
message: <Trans i18nKey="permit.approval.fail.message" />,
supportArticleURL: SupportArticleURL.APPROVALS_EXPLAINER,
// supportArticleURL: SupportArticleURL.APPROVALS_EXPLAINER,
}
case PendingModalError.XV2_HARD_QUOTE_ERROR:
return {
title: <Trans i18nKey="common.swap.failed" />,
message: <Trans i18nKey="swap.fail.uniswapX" />,
supportArticleURL: SupportArticleURL.UNISWAP_X_FAILURE,
// supportArticleURL: SupportArticleURL.UNISWAP_X_FAILURE,
}
case PendingModalError.CONFIRMATION_ERROR:
if (isLimitTrade(trade)) {
return {
title: <Trans i18nKey="common.limit.failed" />,
supportArticleURL: SupportArticleURL.LIMIT_FAILURE,
// supportArticleURL: SupportArticleURL.LIMIT_FAILURE,
}
} else {
return {
title: <Trans i18nKey="common.swap.failed" />,
message: <Trans i18nKey="swap.fail.message" />,
supportArticleURL: isUniswapXTrade(trade)
? SupportArticleURL.UNISWAP_X_FAILURE
: SupportArticleURL.TRANSACTION_FAILURE,
// supportArticleURL: isUniswapXTrade(trade)
// ? SupportArticleURL.UNISWAP_X_FAILURE
// : SupportArticleURL.TRANSACTION_FAILURE,
}
}
case PendingModalError.WRAP_ERROR:
return {
title: <Trans i18nKey="common.wrap.failed" />,
message: <Trans i18nKey="token.wrap.fail.message" />,
supportArticleURL: SupportArticleURL.WETH_EXPLAINER,
// supportArticleURL: SupportArticleURL.WETH_EXPLAINER,
}
default:
return {
Expand Down
9 changes: 7 additions & 2 deletions apps/web/src/components/Pools/PoolTable/PoolTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ApolloError } from '@apollo/client'
import { ColumnDef, createColumnHelper } from '@tanstack/react-table'
import { InterfaceElementName } from '@uniswap/analytics-events'
import { ChainId, CurrencyAmount, Percent, Token as CoreToken, Currency } from '@uniswap/sdk-core'
import { BRC_BITLAYER_TESTNET, USDC_BITLAYER, USDC_BITLAYER_TESTNET, USDT_BITLAYER_TESTNET, USDT_DARWINIA, WBTC_BITLAYER, WBTC_BITLAYER_TESTNET, WRING_DARWINIA } from '@uniswap/smart-order-router'
import { BRC_BITLAYER_TESTNET, USDC_BITLAYER, USDC_BITLAYER_TESTNET, USDT_BITLAYER, USDT_BITLAYER_TESTNET, USDT_DARWINIA, WBTC_BITLAYER, WBTC_BITLAYER_TESTNET, WRING_DARWINIA } from '@uniswap/smart-order-router'
import { FeeAmount, Pool, Position } from '@uniswap/v3-sdk'
import { ButtonEmphasis, ButtonSize, ThemeButton } from 'components/Button'
import { DoubleCurrencyAndChainLogo } from 'components/DoubleLogo'
Expand Down Expand Up @@ -440,6 +440,11 @@ function getPoolKeys(chainId: ChainId | undefined): [Currency, Currency, FeeAmou
unwrappedToken(WBTC_BITLAYER),
FeeAmount.LOW,
],
[
unwrappedToken(USDT_BITLAYER),
unwrappedToken(WBTC_BITLAYER),
FeeAmount.LOW,
],
]
case ChainId.DARWINIA:
return [
Expand Down Expand Up @@ -682,7 +687,7 @@ function AllPoolsTable({
},
}),
];
}, []);
}, [loading]);

return <Table columns={columns} data={data} />;
}
3 changes: 2 additions & 1 deletion apps/web/src/constants/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import {
WRAPPED_NATIVE_CURRENCY,
nativeOnChain,
} from './tokens'
import { BRC_BITLAYER_TESTNET, USDC_BITLAYER, USDT_DARWINIA } from '@uniswap/smart-order-router'
import { BRC_BITLAYER_TESTNET, USDC_BITLAYER, USDT_BITLAYER, USDT_DARWINIA } from '@uniswap/smart-order-router'

type ChainTokenList = {
readonly [chainId: number]: Token[]
Expand Down Expand Up @@ -182,6 +182,7 @@ export const COMMON_BASES: ChainCurrencyList = {
[ChainId.BITLAYER]: [
nativeOnChain(ChainId.BITLAYER),
USDC_BITLAYER,
USDT_BITLAYER,
WRAPPED_NATIVE_CURRENCY[ChainId.BITLAYER] as Token,
].map(buildCurrencyInfo),
[ChainId.DARWINIA]: [
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/i18n/locales/source/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"account.porfolio.activity.cancelledBelow": "This order was canceled because your balance went below the input amount.",
"account.portfolio.activity.signLimit": "This order will not fill because your balance went below the input amount. Increase your balance to fix.",
"account.transactionSummary.addLiquidity": "Add {{ baseSymbol }}/{{ quoteSymbol }} V3 liquidity",
"account.transactionSummary.addLiquidityv2": "Add {{base} and {{quote}} to Uniswap V2",
"account.transactionSummary.addLiquidityv2": "Add {{base}} and {{quote}} to Swap V2",
"account.transactionSummary.approve": "Approve {{sym}}",
"account.transactionSummary.claimFor": "Claim {{currency}} for {{name}}",
"account.transactionSummary.claimReward": "Claim UNI reward for",
Expand Down Expand Up @@ -991,7 +991,7 @@
"uniswapX.learnMore": "Learn more about swapping with UniswapX",
"uniswapx.v2QuoteFailed": "UniswapX v2 hard quote failed. Retry with classic swap.",
"unitag.addressClaim": "Enter an address to trigger a UNI claim. If the address has any claimable UNI it will be sent to them on submission.",
"v2.notAvailable": "Uniswap V2 is not available on this network.",
"v2.notAvailable": "Swap V2 is not available on this network.",
"v2.switchTo": "Switch to v2",
"v3.blast.yield.usdbAndWeth": "On Blast, USDB and WETH are rebasing tokens that automatically earn yield. Due to incompatibility with Uniswap v3, LP positions with USDB or WETH won’t earn rebasing yield, but will in Uniswap v2.",
"v3.continue": "Continue on v3",
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/pages/Pool/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,10 @@ export default function Pool() {
<ThemedText.LargeHeader>
<Trans i18nKey="pool.positions" />
</ThemedText.LargeHeader>
{/* <PoolVersionMenu protocolVersion={ProtocolVersion.V3} /> */}
{/* {networkSupportsV2 && <PoolVersionMenu protocolVersion={ProtocolVersion.V3} />} */}
</Row>
<ButtonRow>
{networkSupportsV2 && (
{/* {networkSupportsV2 && (
<PoolMenu
modal={ApplicationModal.POOL_OVERVIEW_OPTIONS}
menuItems={menuItems}
Expand All @@ -284,7 +284,7 @@ export default function Pool() {
</MoreOptionsButton>
)}
/>
)}
)} */}
<ResponsiveButtonPrimary data-cy="join-pool-button" id="join-pool-button" as={Link} to={`/add/${NATIVE_CURRENCY[account.chainId ?? -1] ?? 'ETH'}`}>
+ <Trans i18nKey="pool.newPosition" />
</ResponsiveButtonPrimary>
Expand Down
4 changes: 1 addition & 3 deletions apps/web/src/state/routing/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ const DEFAULT_QUERY_PARAMS = {

function getClientParams(chainId: ChainId) {
if (isChainSupportedByHelixSwap(chainId)) {
return {
protocols: [Protocol.V3],
}
return { protocols: [Protocol.V3, Protocol.V2] }
}
return CLIENT_PARAMS
}
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"@commitlint/config-conventional": "^17.4.2",
"@crowdin/cli": "3.14.0",
"@ethersproject/keccak256": "5.7.0",
"@helix-bridge/router-sdk": "1.1.0",
"@helix-bridge/sdk-core": "1.1.0",
"@helix-bridge/smart-order-router": "1.2.0",
"@helix-bridge/uniswapx-sdk": "1.1.0",
"@helix-bridge/universal-router-sdk": "1.1.0",
"@helix-bridge/v2-sdk": "1.1.0",
"@helix-bridge/v3-sdk": "1.1.0",
"@helix-bridge/router-sdk": "1.2.0",
"@helix-bridge/sdk-core": "1.2.0",
"@helix-bridge/smart-order-router": "1.3.0",
"@helix-bridge/uniswapx-sdk": "1.2.0",
"@helix-bridge/universal-router-sdk": "1.2.0",
"@helix-bridge/v2-sdk": "1.2.0",
"@helix-bridge/v3-sdk": "1.2.0",
"@manypkg/cli": "^0.19.2",
"danger": "11.2.6",
"depcheck": "1.4.7",
Expand Down
14 changes: 7 additions & 7 deletions package.json.res
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"@commitlint/config-conventional": "^17.4.2",
"@crowdin/cli": "3.14.0",
"@ethersproject/keccak256": "5.7.0",
"@helix-bridge/router-sdk": "1.1.0",
"@helix-bridge/sdk-core": "1.1.0",
"@helix-bridge/smart-order-router": "1.2.0",
"@helix-bridge/uniswapx-sdk": "1.1.0",
"@helix-bridge/universal-router-sdk": "1.1.0",
"@helix-bridge/v2-sdk": "1.1.0",
"@helix-bridge/v3-sdk": "1.1.0",
"@helix-bridge/router-sdk": "1.2.0",
"@helix-bridge/sdk-core": "1.2.0",
"@helix-bridge/smart-order-router": "1.3.0",
"@helix-bridge/uniswapx-sdk": "1.2.0",
"@helix-bridge/universal-router-sdk": "1.2.0",
"@helix-bridge/v2-sdk": "1.2.0",
"@helix-bridge/v3-sdk": "1.2.0",
"@manypkg/cli": "^0.19.2",
"danger": "11.2.6",
"depcheck": "1.4.7",
Expand Down
4 changes: 2 additions & 2 deletions packages/uniswap/src/constants/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ export const UNIVERSE_CHAIN_INFO = {
name: 'Wrapped BTC',
symbol: 'WBTC',
decimals: 18,
address: '0x5F8D4232367759bCe5d9488D3ade77FCFF6B9b6B',
address: '0x3e57d6946f893314324C975AA9CEBBdF3232967E',
},
} as const satisfies UniverseChainInfo,
[UniverseChainId.BITLAYER]: {
Expand Down Expand Up @@ -1122,7 +1122,7 @@ export const UNIVERSE_CHAIN_INFO = {
},
networkLayer: NetworkLayer.L2,
pendingTransactionsRetryOptions: undefined,
spotPriceStablecoinAmount: CurrencyAmount.fromRawAmount(USDC_BITLAYER_TESTNET, 1e4),
spotPriceStablecoinAmount: CurrencyAmount.fromRawAmount(USDT_BITLAYER, 1e4),
stablecoins: [USDC_BITLAYER, USDT_BITLAYER],
statusPage: undefined,
supportsClientSideRouting: true,
Expand Down
Loading

0 comments on commit a2a248d

Please sign in to comment.