11import { PartnerFeeAction , Pool , ProtocolFeeAction , RefundAction , ZapAction , ZapRouteDetail } from '@kyber/schema'
22import { getZapImpact } from '@kyber/utils'
3- import { rgba } from 'polished'
43import { useMemo } from 'react'
54import { Text } from 'rebass'
65import styled from 'styled-components'
@@ -12,50 +11,24 @@ import { getOutputTokenItems } from 'pages/Earns/PoolDetail/AddLiquidity/utils'
1211import { formatDisplayNumber } from 'utils/numbers'
1312
1413const Card = styled ( Stack ) `
15- padding: 20px;
16- border-radius: 20px;
1714 background: ${ ( { theme } ) => theme . buttonGray } ;
18- `
19-
20- const SectionLabel = styled ( Text ) `
21- color: ${ ( { theme } ) => theme . subText } ;
22- font-size: 14px;
23- `
24-
25- const ValueText = styled ( Text ) `
26- font-weight: 500;
27- `
28-
29- const TotalText = styled ( Text ) `
30- font-weight: 500;
31- `
32-
33- const EstimateTokenBox = styled ( Stack ) `
34- flex: 1 1 0;
35- min-width: 0;
36- gap: 4px;
15+ border-radius: 12px;
16+ padding: 12px 16px;
3717`
3818
3919const Divider = styled . div `
40- width: 100% ;
20+ background: ${ ( { theme } ) => theme . tabActive } ;
4121 height: 1px;
42- background: ${ ( { theme } ) => theme . border } ;
22+ width: 100% ;
4323`
4424
4525const MetricCard = styled ( Stack ) `
26+ background: ${ ( { theme } ) => theme . tabActive } ;
27+ border-radius: 12px;
4628 flex: 1 1 0;
29+ gap: 4px;
4730 min-width: 0;
48- gap: 8px;
49- padding: 12px;
50- border-radius: 12px;
51- background: ${ ( { theme } ) => theme . tabActive } ;
52- `
53-
54- const MetricTitle = styled ( Text ) `
55- width: fit-content;
56- color: ${ ( { theme } ) => theme . subText } ;
57- font-size: 12px;
58- border-bottom: 1px dotted ${ ( { theme } ) => rgba ( theme . border , 0.24 ) } ;
31+ padding: 8px 12px;
5932`
6033
6134type EstimateInfoProps = {
@@ -125,55 +98,64 @@ const EstimateInfo = ({ pool, route, slippage }: EstimateInfoProps) => {
12598 const estimate = useMemo ( ( ) => buildEstimate ( { pool, route, slippage } ) , [ pool , route , slippage ] )
12699
127100 return (
128- < Card gap = { 16 } >
129- < HStack align = "center" justify = "space-between" >
130- < SectionLabel > Est. Liquidity Value</ SectionLabel >
131- < TotalText color = { theme . text } >
132- { formatDisplayNumber ( estimate . totalUsd , { style : 'currency' , significantDigits : 6 } ) }
133- </ TotalText >
134- </ HStack >
135-
136- < HStack align = "flex-start" gap = { 12 } wrap = "wrap" >
137- { estimate . items . map ( item => (
138- < EstimateTokenBox key = { item . token . address } >
139- < HStack minWidth = { 0 } align = "center" gap = { 6 } >
140- < TokenLogo src = { item . token . logo } size = { 16 } />
141- < ValueText color = { theme . text } >
142- { formatDisplayNumber ( item . amount , { significantDigits : 8 } ) } { item . token . symbol }
143- </ ValueText >
144- </ HStack >
145- < SectionLabel >
146- ~{ formatDisplayNumber ( item . usdValue , { style : 'currency' , significantDigits : 6 } ) }
147- </ SectionLabel >
148- </ EstimateTokenBox >
149- ) ) }
150- </ HStack >
101+ < Card gap = { 8 } >
102+ < Stack gap = { 12 } >
103+ < HStack align = "center" justify = "space-between" >
104+ < Text color = { theme . subText } > Est. Liquidity Value</ Text >
105+ < Text color = { theme . text } fontWeight = { 500 } >
106+ { formatDisplayNumber ( estimate . totalUsd , { style : 'currency' , significantDigits : 6 } ) }
107+ </ Text >
108+ </ HStack >
109+
110+ < HStack align = "flex-start" gap = { 12 } wrap = "wrap" >
111+ { estimate . items . map ( ( item , index ) => (
112+ < Stack key = { item . token . address } flex = "1 1 0" gap = { 4 } minWidth = { 0 } align = { index ? 'flex-end' : 'flex-start' } >
113+ < HStack align = "center" gap = { 4 } minWidth = { 0 } wrap = "wrap" >
114+ < TokenLogo src = { item . token . logo } size = { 16 } />
115+ < Text color = { theme . text } >
116+ { formatDisplayNumber ( item . amount , { significantDigits : 6 } ) } { item . token . symbol }
117+ </ Text >
118+ </ HStack >
119+
120+ < Text color = { theme . subText } >
121+ ~{ formatDisplayNumber ( item . usdValue , { style : 'currency' , significantDigits : 6 } ) }
122+ </ Text >
123+ </ Stack >
124+ ) ) }
125+ </ HStack >
126+ </ Stack >
151127
152128 < Divider />
153129
154- < HStack align = "center" justify = "space-between" >
155- < MetricTitle as = "div" > Max Slippage</ MetricTitle >
156- < ValueText color = { theme . text } > { formatBpsLabel ( estimate . slippage ) } </ ValueText >
157- </ HStack >
158-
159- < HStack align = "stretch" gap = { 12 } wrap = "wrap" >
160- < MetricCard >
161- < MetricTitle > Est. Remaining</ MetricTitle >
162- < ValueText color = { theme . text } >
163- { formatDisplayNumber ( estimate . remainingUsd , { style : 'currency' , significantDigits : 6 } ) }
164- </ ValueText >
165- </ MetricCard >
166-
167- < MetricCard >
168- < MetricTitle > Zap Impact</ MetricTitle >
169- < ValueText color = { theme . text } > { estimate . zapImpact ?. display || '--' } </ ValueText >
170- </ MetricCard >
171-
172- < MetricCard >
173- < MetricTitle > Zap Fee</ MetricTitle >
174- < ValueText color = { theme . text } > { formatPercent ( estimate . zapFeePercent ) } </ ValueText >
175- </ MetricCard >
176- </ HStack >
130+ < Stack gap = { 8 } >
131+ < HStack align = "center" justify = "space-between" >
132+ < Text color = { theme . subText } > Max Slippage</ Text >
133+ < Text color = { theme . text } fontWeight = { 500 } >
134+ { formatBpsLabel ( estimate . slippage ) }
135+ </ Text >
136+ </ HStack >
137+
138+ < HStack align = "stretch" gap = { 8 } wrap = "wrap" >
139+ < MetricCard >
140+ < Text color = { theme . subText } > Est. Remaining</ Text >
141+ < Text color = { theme . text } fontWeight = { 500 } >
142+ { formatDisplayNumber ( estimate . remainingUsd , { style : 'currency' , significantDigits : 6 } ) }
143+ </ Text >
144+ </ MetricCard >
145+ < MetricCard >
146+ < Text color = { theme . subText } > Zap Impact</ Text >
147+ < Text color = { theme . text } fontWeight = { 500 } >
148+ { estimate . zapImpact ?. display }
149+ </ Text >
150+ </ MetricCard >
151+ < MetricCard >
152+ < Text color = { theme . subText } > Zap Fee</ Text >
153+ < Text color = { theme . text } fontWeight = { 500 } >
154+ { formatPercent ( estimate . zapFeePercent ) }
155+ </ Text >
156+ </ MetricCard >
157+ </ HStack >
158+ </ Stack >
177159 </ Card >
178160 )
179161}
0 commit comments