Skip to content

Commit 8e6ab05

Browse files
committed
Refactor add liquidity
Continue Update packages typesVersions Update import
1 parent 5793c05 commit 8e6ab05

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2604
-2604
lines changed

apps/kyberswap-interface/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
"ChromeAndroid >= 52"
4040
],
4141
"dependencies": {
42-
"@kyber/rpc-client": "workspace:*",
4342
"@across-protocol/app-sdk": "^0.4.4",
4443
"@bitcoinerlab/secp256k1": "^1.2.0",
4544
"@defuse-protocol/one-click-sdk-typescript": "^0.1.2",
@@ -192,6 +191,8 @@
192191
"@babel/preset-react": "^7.18.6",
193192
"@babel/preset-typescript": "^7.21.4",
194193
"@cypress/grep": "^3.1.5",
194+
"@kyber/hooks": "workspace:^",
195+
"@kyber/rpc-client": "workspace:*",
195196
"@kyber/schema": "workspace:^",
196197
"@kyber/token-selector": "workspace:^",
197198
"@kyber/ui": "workspace:^",

apps/kyberswap-interface/src/components/TradeRouting/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,10 @@ const Routing = ({
184184
handleScroll()
185185
}, [tradeComposition, maxHeight, handleScroll])
186186

187-
const isSwapRouteV3 = tradeComposition?.every(item => 'pool' in item)
187+
const isSwapRouteV3 =
188+
(tradeComposition as Array<SwapRouteV2 | SwapRouteV3> | undefined)?.every(
189+
(item): item is SwapRouteV3 => 'pool' in item,
190+
) ?? false
188191

189192
return (
190193
<Shadow ref={shadowRef}>

apps/kyberswap-interface/src/pages/Earns/PoolDetail/AddLiquidity/README.md

Lines changed: 0 additions & 96 deletions
This file was deleted.

apps/kyberswap-interface/src/pages/Earns/PoolDetail/AddLiquidity/components/AddLiquidityReviewModal.tsx

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,19 @@ import Modal from 'components/Modal'
88
import { HStack, Stack } from 'components/Stack'
99
import TokenLogo from 'components/TokenLogo'
1010
import useTheme from 'hooks/useTheme'
11-
import { AddLiquidityReviewData } from 'pages/Earns/PoolDetail/AddLiquidity/hooks/useAddLiquidityReviewData'
12-
import { EARN_DEXES, Exchange } from 'pages/Earns/constants'
11+
import { AddLiquidityReviewData } from 'pages/Earns/PoolDetail/AddLiquidity/hooks/useReviewData'
1312
import { CloseIcon } from 'theme/components'
1413
import { formatDisplayNumber } from 'utils/numbers'
1514

1615
interface AddLiquidityReviewModalProps {
1716
isOpen?: boolean
18-
exchange?: string
19-
data?: AddLiquidityReviewData | null
17+
review?: AddLiquidityReviewData
2018
confirmText?: string
2119
confirmDisabled?: boolean
2220
confirmLoading?: boolean
2321
txHash?: string
2422
txStatus?: 'success' | 'failed' | 'cancelled' | ''
2523
txError?: string | null
26-
slippage?: number
27-
suggestedSlippage?: number
2824
transactionExplorerUrl?: string
2925
onDismiss?: () => void
3026
onConfirm?: () => void
@@ -196,16 +192,13 @@ const formatBpsLabel = (value?: number) => {
196192

197193
export default function AddLiquidityReviewModal({
198194
isOpen = false,
199-
exchange,
200-
data,
195+
review,
201196
confirmText = 'Add Liquidity',
202197
confirmDisabled = false,
203198
confirmLoading = false,
204199
txHash,
205200
txStatus = '',
206201
txError,
207-
slippage,
208-
suggestedSlippage,
209202
transactionExplorerUrl,
210203
onDismiss,
211204
onConfirm,
@@ -214,12 +207,16 @@ export default function AddLiquidityReviewModal({
214207
onViewPosition,
215208
}: AddLiquidityReviewModalProps) {
216209
const theme = useTheme()
217-
const protocol = exchange ? EARN_DEXES[exchange as Exchange] : undefined
218-
const header = data?.header
219-
const zapInItems = data?.zapInItems || []
220-
const estimate = data?.estimate
221-
const priceInfo = data?.priceInfo
222-
const warnings = data?.warnings || []
210+
211+
const header = review?.header
212+
const estimate = review?.estimate
213+
const priceInfo = review?.priceInfo
214+
const warnings = review?.warnings || []
215+
const zapInItems = review?.zapInItems || []
216+
217+
const totalInputUsd = review?.totalInputUsd || 0
218+
const slippage = estimate?.slippage
219+
const suggestedSlippage = estimate?.suggestedSlippage
223220

224221
if (confirmLoading || txHash || txError || txStatus) {
225222
const translatedErrorMessage = txError ? translateFriendlyErrorMessage(txError) : undefined
@@ -282,10 +279,10 @@ export default function AddLiquidityReviewModal({
282279
<Stack gap={4} minWidth={0}>
283280
<PairText color={theme.text}>{header.pairLabel}</PairText>
284281
<HStack align="center" gap={8} wrap="wrap">
285-
{protocol ? (
282+
{header.protocolName ? (
286283
<HStack align="center" gap={6}>
287-
{protocol.logo ? <ProtocolLogo alt={protocol.name} src={protocol.logo} /> : null}
288-
<LabelText color={theme.subText}>{protocol.name}</LabelText>
284+
{header.protocolLogo ? <ProtocolLogo alt={header.protocolName} src={header.protocolLogo} /> : null}
285+
<LabelText color={theme.subText}>{header.protocolName}</LabelText>
289286
</HStack>
290287
) : null}
291288
{header.feeLabel ? (
@@ -302,7 +299,7 @@ export default function AddLiquidityReviewModal({
302299
<HStack align="center" justify="space-between">
303300
<BodyText color={theme.subText}>Zap-in Amount</BodyText>
304301
<TotalText color={theme.text}>
305-
{formatDisplayNumber(data?.totalInputUsd || 0, { style: 'currency', significantDigits: 6 })}
302+
{formatDisplayNumber(totalInputUsd, { style: 'currency', significantDigits: 6 })}
306303
</TotalText>
307304
</HStack>
308305
<Stack gap={8}>

apps/kyberswap-interface/src/pages/Earns/PoolDetail/AddLiquidity/components/AddLiquidityRouteInsights.tsx

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)