Skip to content

Commit c2fcdd4

Browse files
authored
Merge pull request QuickSwap#1716 from QuickSwap/dev2
2 parents d28f032 + 39ec49d commit c2fcdd4

File tree

7 files changed

+103
-78
lines changed

7 files changed

+103
-78
lines changed

src/components/v3/IncreaseLiquidityV3/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ export default function IncreaseLiquidityV3({
483483
className='v3-increase-liquidity-price-wrapper'
484484
width={priceLower ? '49%' : '100%'}
485485
>
486-
<p>{t('minPrice')}</p>
486+
<p>{t('maxPrice')}</p>
487487
<h6>{formatTickPrice(priceUpper, ticksAtLimit, Bound.UPPER)}</h6>
488488
<p>
489489
{currencyQuote?.symbol} {t('per')} {currencyBase?.symbol}

src/hooks/v3/useV3Positions.ts

Lines changed: 56 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -134,29 +134,53 @@ export function useV3Positions(
134134
): UseV3PositionsResults {
135135
const positionV2Manager = useV3NFTPositionManagerContract();
136136
const positionV4Manager = useV4NFTPositionManagerContract();
137-
const positionManager = isV4 ? positionV4Manager : positionV2Manager;
138137
const uniV3PositionManager = useUNIV3NFTPositionManagerContract();
139138

140-
const algebraBalanceResult = useSingleCallResult(
141-
positionManager,
139+
const algebraV2BalanceResult = useSingleCallResult(
140+
positionV2Manager,
142141
'balanceOf',
143142
[account ?? undefined],
144143
);
145144

146-
const algebraBalance = Number(algebraBalanceResult.result ?? '0');
145+
const algebraV4BalanceResult = useSingleCallResult(
146+
positionV4Manager,
147+
'balanceOf',
148+
[account ?? undefined],
149+
);
150+
151+
const algebraV2Balance = Number(algebraV2BalanceResult.result ?? '0');
152+
const algebraV4Balance = Number(algebraV4BalanceResult.result ?? '0');
153+
154+
const algebraV2TokenResults = useSingleContractMultipleData(
155+
positionV2Manager,
156+
'tokenOfOwnerByIndex',
157+
Array.from({ length: algebraV2Balance }, (_, i) => i).map((v) => [
158+
account ?? undefined,
159+
v,
160+
]),
161+
);
147162

148-
const algebraTokenResults = useSingleContractMultipleData(
149-
positionManager,
163+
const algebraV4TokenResults = useSingleContractMultipleData(
164+
positionV4Manager,
150165
'tokenOfOwnerByIndex',
151-
Array.from({ length: algebraBalance }, (_, i) => i).map((v) => [
166+
Array.from({ length: algebraV4Balance }, (_, i) => i).map((v) => [
152167
account ?? undefined,
153168
v,
154169
]),
155170
);
156171

157-
const algebraIDsLoading = algebraTokenResults.some((call) => call.loading);
172+
const algebraV2IDsLoading = algebraV2TokenResults.some(
173+
(call) => call.loading,
174+
);
175+
const algebraV4IDsLoading = algebraV4TokenResults.some(
176+
(call) => call.loading,
177+
);
158178

159-
const algebraTokenIds = algebraTokenResults
179+
const algebraV2TokenIds = algebraV2TokenResults
180+
.filter((call) => !!call.result)
181+
.map((call) => BigNumber.from(call.result?.toString() ?? '0'));
182+
183+
const algebraV4TokenIds = algebraV4TokenResults
160184
.filter((call) => !!call.result)
161185
.map((call) => BigNumber.from(call.result?.toString() ?? '0'));
162186

@@ -184,12 +208,21 @@ export function useV3Positions(
184208
.map((call) => BigNumber.from(call.result?.toString() ?? '0'));
185209

186210
const {
187-
positions: algebraPositions,
188-
loading: algebraPositionsLoading,
211+
positions: algebraV2Positions,
212+
loading: algebraV2PositionsLoading,
189213
} = useV3PositionsFromTokenIds(
190-
algebraIDsLoading ? [] : algebraTokenIds,
214+
algebraV2IDsLoading ? [] : algebraV2TokenIds,
215+
false,
191216
false,
192-
isV4,
217+
);
218+
219+
const {
220+
positions: algebraV4Positions,
221+
loading: algebraV4PositionsLoading,
222+
} = useV3PositionsFromTokenIds(
223+
algebraV4IDsLoading ? [] : algebraV4TokenIds,
224+
false,
225+
true,
193226
);
194227

195228
const {
@@ -229,6 +262,12 @@ export function useV3Positions(
229262
oldTransferredTokenIds.map((id) => BigNumber.from(id)),
230263
);
231264

265+
const algebraPositions = isV4
266+
? algebraV4Positions
267+
: isV4 === undefined
268+
? (algebraV2Positions ?? []).concat(algebraV4Positions ?? [])
269+
: algebraV2Positions;
270+
232271
const combinedPositions = [
233272
...(algebraPositions ?? [])
234273
.concat(isV4 ? [] : uniV3Positions ?? [])
@@ -260,9 +299,11 @@ export function useV3Positions(
260299

261300
return {
262301
loading:
263-
algebraPositionsLoading ||
302+
algebraV2PositionsLoading ||
303+
algebraV4PositionsLoading ||
264304
uniV3PositionsLoading ||
265-
algebraIDsLoading ||
305+
algebraV2IDsLoading ||
306+
algebraV4IDsLoading ||
266307
univ3IDsLoading ||
267308
_positionsOnFarmerLoading,
268309
positions: combinedPositions,

src/pages/Bridge/BridgePage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ const BridgePage: React.FC = ({}) => {
198198
},
199199
{
200200
value: 'eth',
201-
label: 'Etherium',
201+
label: 'Ethereum',
202202
},
203203
{
204204
value: 'zkevm',

src/pages/FarmPage/V3/AllMerklFarms.tsx

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const AllMerklFarms: React.FC<Props> = ({
3636
}) => {
3737
const { t } = useTranslation();
3838
const { breakpoints } = useTheme();
39-
const { chainId, account } = useActiveWeb3React();
39+
const { chainId } = useActiveWeb3React();
4040
const isMobile = useMediaQuery(breakpoints.down('sm'));
4141
const history = useHistory();
4242

@@ -72,7 +72,7 @@ const AllMerklFarms: React.FC<Props> = ({
7272
);
7373
const [sortBy, setSortBy] = useState(GlobalConst.utils.v3FarmSortBy.pool);
7474
const [sortDesc, setSortDesc] = useState(false);
75-
const [isOld, setIsOld] = useState(true);
75+
7676
const sortMultiplier = sortDesc ? 1 : -1;
7777

7878
const sortColumns = [
@@ -380,13 +380,6 @@ const AllMerklFarms: React.FC<Props> = ({
380380
))}
381381
</Select>
382382
</Box>
383-
<Box className='flex items-center' gridGap={6}>
384-
<small className='text-secondary'>{t('oldFarms')}</small>
385-
<ToggleSwitch
386-
toggled={isOld}
387-
onToggle={() => setIsOld(!isOld)}
388-
/>
389-
</Box>
390383
</Box>
391384
)}
392385
</Box>
@@ -406,17 +399,6 @@ const AllMerklFarms: React.FC<Props> = ({
406399
/>
407400
)}
408401
</Box>
409-
{isMobile && (
410-
<Box className='flex items-center' gridGap={16}>
411-
<Box className='flex items-center' gridGap={6}>
412-
<small className='text-secondary'>{t('oldFarms')}</small>
413-
<ToggleSwitch
414-
toggled={isOld}
415-
onToggle={() => setIsOld(!isOld)}
416-
/>
417-
</Box>
418-
</Box>
419-
)}
420402
</Box>
421403
) : (
422404
<>

src/pages/FarmPage/V3/Farms.tsx

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default function Farms() {
6262
const [selectedSort, setSelectedSort] = useState(
6363
GlobalConst.utils.v3FarmSortBy.pool,
6464
);
65-
const [isOld, setIsOld] = useState(true);
65+
const [isMyFarmsToogle, setIsMyFarmsToogle] = useState(false);
6666

6767
const redirectWithFarmStatus = (status: string) => {
6868
const currentPath = history.location.pathname + history.location.search;
@@ -84,7 +84,7 @@ export default function Farms() {
8484
parsedQuery && parsedQuery.tab ? (parsedQuery.tab as string) : 'farms';
8585

8686
const v3FarmCategories = useMemo(() => {
87-
return isOld
87+
return isMyFarmsToogle
8888
? [
8989
{
9090
text: t('allFarms'),
@@ -114,7 +114,7 @@ export default function Farms() {
114114
link: 'my-rewards',
115115
},
116116
];
117-
}, [t, isOld]);
117+
}, [t, isMyFarmsToogle]);
118118

119119
const onChangeFarmCategory = useCallback(
120120
(selected: SelectorItem) => {
@@ -212,15 +212,6 @@ export default function Farms() {
212212
selectedItem={selectedFarmCategory}
213213
handleChange={onChangeFarmCategory}
214214
/>
215-
{isMobile && !poolId && (
216-
<Box className='flex items-center' gridGap={6}>
217-
<small className='text-secondary'>{t('oldFarms')}</small>
218-
<ToggleSwitch
219-
toggled={isOld}
220-
onToggle={() => setIsOld(!isOld)}
221-
/>
222-
</Box>
223-
)}
224215
<Box
225216
className={
226217
isMobile
@@ -258,10 +249,10 @@ export default function Farms() {
258249
)}
259250
{!isMobile && (
260251
<Box className='flex items-center' gridGap={6}>
261-
<small className='text-secondary'>{t('oldFarms')}</small>
252+
<small className='text-secondary'>My Farms</small>
262253
<ToggleSwitch
263-
toggled={isOld}
264-
onToggle={() => setIsOld(!isOld)}
254+
toggled={isMyFarmsToogle}
255+
onToggle={() => setIsMyFarmsToogle(!isMyFarmsToogle)}
265256
/>
266257
</Box>
267258
)}

src/pages/FarmPage/V3/MyRewardFarms.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ const MyRewardFarms: React.FC<Props> = ({
2929
sortValue,
3030
}) => {
3131
const { t } = useTranslation();
32-
const { breakpoints } = useTheme();
3332
const { account, chainId } = useActiveWeb3React();
3433

3534
const myPositionIds: any = [];

src/pages/PoolsPage/PoolsPage.tsx

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,25 @@ const PoolsPage: React.FC = () => {
9393
</Box>
9494
)}
9595
</Box>
96-
<Box
97-
style={{
98-
display: 'flex',
99-
alignItems: 'center',
100-
gap: '4px',
101-
justifyContent: 'end',
102-
}}
103-
>
104-
<p>
105-
<span>{t('poweredBy')}</span>
106-
</p>
107-
<img src={AlgebraLogo} alt='poweredby' style={{ width: '72px' }} />
108-
</Box>
96+
{['v3', 'v4'].includes(version) && (
97+
<Box
98+
style={{
99+
display: 'flex',
100+
alignItems: 'center',
101+
gap: '4px',
102+
justifyContent: 'end',
103+
}}
104+
>
105+
<p>
106+
<span>{t('poweredBy')}</span>
107+
</p>
108+
<img
109+
src={AlgebraLogo}
110+
alt='poweredby'
111+
style={{ width: '72px' }}
112+
/>
113+
</Box>
114+
)}
109115
{showVersion && (
110116
<Box my={2}>
111117
<VersionToggle />
@@ -122,18 +128,24 @@ const PoolsPage: React.FC = () => {
122128
</Box>
123129
)}
124130
</Box>
125-
<Box
126-
style={{
127-
display: 'flex',
128-
alignItems: 'center',
129-
gap: '4px',
130-
}}
131-
>
132-
<p>
133-
<span>{t('poweredBy')}</span>
134-
</p>
135-
<img src={AlgebraLogo} alt='poweredby' style={{ width: '72px' }} />
136-
</Box>
131+
{['v3', 'v4'].includes(version) && (
132+
<Box
133+
style={{
134+
display: 'flex',
135+
alignItems: 'center',
136+
gap: '4px',
137+
}}
138+
>
139+
<p>
140+
<span>{t('poweredBy')}</span>
141+
</p>
142+
<img
143+
src={AlgebraLogo}
144+
alt='poweredby'
145+
style={{ width: '72px' }}
146+
/>
147+
</Box>
148+
)}
137149
</Box>
138150
)}
139151
{/* <Box margin='24px auto'>

0 commit comments

Comments
 (0)