Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: veYFI gauge #248

Merged
merged 154 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from 152 commits
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
32de2e3
feat: add delegate vote action
xgambitox Jan 16, 2023
c229909
feat: add address validation
xgambitox Jan 16, 2023
02d7787
feat: add input common component
xgambitox Jan 17, 2023
8cd51b9
feat: add gauge vote tab
xgambitox Jan 17, 2023
4bae35f
feat: add base gauge context
xgambitox Jan 17, 2023
812d64c
feat: add gauge actions
xgambitox Jan 18, 2023
71e3286
feat: add table common component
xgambitox Jan 20, 2023
2d0317d
feat: add gauge tab with mock data
xgambitox Jan 20, 2023
3d19e2a
Merge branch 'main' into feat/veyfi-gauges
xgambitox Feb 23, 2023
b47247a
refactor: sort order states
xgambitox Feb 23, 2023
b6b2f71
fix: table sizing
xgambitox Feb 23, 2023
fc0ba64
fix: table header font size
xgambitox Feb 23, 2023
b659c8f
refactor: isNumber cast
xgambitox Feb 23, 2023
cb5fc76
style: readability improvements
xgambitox Feb 23, 2023
718754a
refactor: input placeholder
xgambitox Feb 23, 2023
bdfd9cd
refactor: nullish coalescing
xgambitox Feb 23, 2023
155ff23
refactor: sort numbers
xgambitox Feb 23, 2023
4393a09
refactor: keyBy typing
xgambitox Feb 23, 2023
7464430
refactor: isString util
xgambitox Feb 23, 2023
f5bb55b
style: remove unnecessary unknowns
xgambitox Feb 24, 2023
97e76ff
style: remove unnesessary cast
xgambitox Feb 24, 2023
d1ec775
refactor: replace mt for gap
xgambitox Feb 24, 2023
5168a9f
style: isNumberable better naming
xgambitox Feb 24, 2023
56bf773
fix: gauge tab table span
xgambitox Feb 27, 2023
5a2a31e
fix: update unstake interface changes
xgambitox Feb 27, 2023
fb64f0e
feat: add gauge reward position
xgambitox Feb 27, 2023
73f55a1
feat: add gauge boost
xgambitox Feb 27, 2023
5253c87
refactor: user positions not optional
xgambitox Feb 27, 2023
ebeb370
feat: add base generic dropdown component
xgambitox Mar 1, 2023
c03ef79
feat: add dropdown improvements
xgambitox Mar 1, 2023
7b56c98
feat: add base rewards tab UI
xgambitox Mar 2, 2023
44aecf6
feat: Generic table pagination (#79)
karelianpie Mar 2, 2023
b5fffcf
Merge branch 'feat/veyfi-gauges' of github.com:yearn/yearn.fi into fe…
xgambitox Mar 2, 2023
f9e0b78
feat: add base redeem tab
xgambitox Mar 2, 2023
b1bd192
feat: implement base gauge interactions
xgambitox Mar 3, 2023
b4e7335
feat: optional table pagination
xgambitox Mar 3, 2023
ac6c791
feat: implement base rewards functionality
xgambitox Mar 3, 2023
beea780
Merge branch 'main' into feat/veyfi-gauges
xgambitox Mar 16, 2023
7d70feb
feat: update to latest actions interface
xgambitox Mar 16, 2023
af6e9f6
feat: add base options context
xgambitox Mar 17, 2023
a729619
feat: add options allowance fetcher
xgambitox Mar 17, 2023
223b147
fix: use default provider
xgambitox Mar 17, 2023
953d702
refactor: use unique allowance ID
xgambitox Mar 17, 2023
d1f3be5
feat: add dynamic required eth fetcher
xgambitox Mar 17, 2023
31a99c0
fix: new types directory
xgambitox Mar 17, 2023
39bface
feat: add option actions
xgambitox Mar 20, 2023
f910d81
feat: add contexts to veyfi app wrapper
xgambitox Mar 21, 2023
a4609d5
feat: add base option redeem functionality
xgambitox Mar 21, 2023
3e2ddf3
feat: update contract abi
xgambitox Apr 7, 2023
1c32e73
feat: support bignumbers on tables
xgambitox Apr 13, 2023
689bf7b
feat: import contract ABIs
xgambitox Apr 13, 2023
91649b1
feat: format gauge table columns
xgambitox Apr 14, 2023
fbd34c0
feat: add option price calcs
xgambitox Apr 19, 2023
f7dc5e8
feat: add option price to views
xgambitox Apr 19, 2023
3bea230
feat: update options contracts
xgambitox Apr 20, 2023
d5005b4
fix: gauge staking
xgambitox Apr 20, 2023
3c289b8
fix: calculate boost using fixed number
xgambitox Apr 20, 2023
3bd6132
fix: fetch next boost
xgambitox Apr 20, 2023
354f1a1
feat: display gauges with rewards only
xgambitox Apr 21, 2023
ded04eb
refactor: claim reward actions
xgambitox Apr 21, 2023
93cfac0
fix: option price fetcher
xgambitox Apr 21, 2023
a36b6f2
fix: update redeem option interface
xgambitox Apr 21, 2023
8b9ed18
fix: update gauge abi
xgambitox Apr 21, 2023
4c81162
Merge branch 'main' into feat/veyfi-gauges
xgambitox Apr 21, 2023
00c4c58
fix: allowance key changes
xgambitox Apr 21, 2023
38aebc2
fix: redeem action details
xgambitox Apr 21, 2023
37eaff9
Merge branch 'main' into feat/veyfi-gauges-merged
karelianpie Jun 21, 2023
768a045
refactor: BigNumber -> bigint
karelianpie Jun 21, 2023
ad2d3b8
fix: Expression
karelianpie Jun 21, 2023
56a7042
feat: Migrate useGauge to wagmi
karelianpie Jun 21, 2023
3633209
refactor: Migrate useGauge to wagmi
karelianpie Jun 22, 2023
e25d28e
refactor: Use 1 for chain id
karelianpie Jun 22, 2023
2b01c44
Merge pull request #250 from yearn/feat/veyfi-gauges-merged-use-gauge
karelianpie Jun 23, 2023
8b26dae
feat: Migrate useOption to wagmi
karelianpie Jun 23, 2023
0baaa8c
feat: Migrate RewardsTab to wagmi
karelianpie Jun 23, 2023
a15c066
feat: Assert gauge addresses
karelianpie Jun 26, 2023
c32dd7b
refactor: Use `isDisabled` rather than `disabled` prop
karelianpie Jun 26, 2023
e6bb069
@karelianpie @Majorfi refactor: Use `isDisabled` rather than `disable…
karelianpie Jun 26, 2023
e4ea6d4
Merge pull request #253 from yearn/feat/veyfi-gauges-merged-rewards-tab
karelianpie Jun 26, 2023
f403136
Merge pull request #252 from yearn/feat/veyfi-gauges-merged-use-option
karelianpie Jun 26, 2023
b4edf8b
feat: Migrate RedeemTab to wagmi
karelianpie Jun 24, 2023
4a6156d
Update apps/veyfi/components/RedeemTab.tsx
karelianpie Jun 26, 2023
cedbad7
feat: Assert account address and amount
karelianpie Jun 26, 2023
5d7bb3b
Merge pull request #255 from yearn/feat/veyfi-gauges-merged-redeem-tab
karelianpie Jun 27, 2023
3ae85f8
feat: Migrate VoteTab to wagmi
karelianpie Jun 23, 2023
bc1da6e
refactor: Assert all addresses
karelianpie Jun 26, 2023
4afa420
Merge pull request #254 from yearn/feat/veyfi-gauges-merged-vote-tab
karelianpie Jun 27, 2023
bb00929
Merge branch 'main' into feat/veyfi-gauges-merged
karelianpie Jun 27, 2023
d2556c3
feat: Migrate GaugesTab to wagmi
karelianpie Jun 27, 2023
3b3d924
fix: Remove commented out code
karelianpie Jun 27, 2023
4b577f2
fix: Import the correct assert
karelianpie Jun 27, 2023
c2595b8
refactor: Assert accountAddress
karelianpie Jun 27, 2023
8d0c5fd
Merge pull request #258 from yearn/feat/veyfi-gauges-merged-gauges-tab
karelianpie Jul 3, 2023
4e331d6
Update _app.tsx (#259)
Majorfi Jun 27, 2023
88182d4
fix: Typo (#260)
karelianpie Jun 28, 2023
fdf8317
fix: refresh stuff
Majorfi Jun 28, 2023
51bb3eb
fix: image with fallback
Majorfi Jun 28, 2023
3f1e3c5
fix: wallet connect
Majorfi Jun 29, 2023
7b68ec8
fix: disable wallet connect while waiting for v2 validation
Majorfi Jun 29, 2023
6429fd4
fix: wallet connect
Majorfi Jun 29, 2023
9b5a265
fix: upd style
Majorfi Jun 29, 2023
278f474
feat: clean files
Majorfi Jun 29, 2023
9713247
fix: chain
Majorfi Jun 29, 2023
acb2df4
fix: Use want symbol for Total Deposited (#261)
murderteeth Jun 29, 2023
0d97358
fix: wallet
Majorfi Jun 29, 2023
cb1f28e
fix: networks
Majorfi Jun 29, 2023
37b49d1
fix: add rpc
Majorfi Jun 29, 2023
29b380b
fix: add rpc
Majorfi Jun 29, 2023
9851639
feat: update optimism networks
Majorfi Jun 29, 2023
0f2abbb
fix: On Optimism it shows New on the list but 0 inside
karelianpie Jun 30, 2023
b71b14e
fix: hide cowswap solver on sidechains (#262)
Majorfi Jul 1, 2023
6037af5
fix: opt
Majorfi Jul 2, 2023
973a36e
fix: bump lib for iFrame fix
Majorfi Jul 3, 2023
6a3fbd4
Merge branch 'main' into feat/veyfi-gauges-merged
karelianpie Jul 3, 2023
53cfa44
refactor: Rename toWagmiProvider -> wagmiUtils
karelianpie Jul 3, 2023
deb0103
refactor: Use viem instead of ethers
karelianpie Jul 4, 2023
4f6690f
refactor: Move formatBytes32String -> stringToHex
karelianpie Jul 4, 2023
d27bbc9
feat: Add assert ethRequired
karelianpie Jul 4, 2023
897d384
refactor: Remove unnecessary fn, use approveERC20
karelianpie Jul 4, 2023
eb614fc
Cast to const
karelianpie Jul 4, 2023
e770474
refactor: Use cl()
karelianpie Jul 4, 2023
aea45ed
fix: Remove extra spaces
karelianpie Jul 4, 2023
aca9f1a
fix: Make tailwind css literal
karelianpie Jul 4, 2023
a1eecf5
refactor: Move all constants to the same file
karelianpie Jul 4, 2023
04e8498
Add missing space
karelianpie Jul 4, 2023
ee757fb
fix: Formatting
karelianpie Jul 4, 2023
ac74a39
refactor: Convert fn to wagmi
karelianpie Jul 5, 2023
80b2cc2
refactor: Use separate args rather than array
karelianpie Jul 5, 2023
48a2ec9
fix: Use isDisabled prop
karelianpie Jul 5, 2023
8f097f0
refactor: Use cl, props in multiple lines
karelianpie Jul 5, 2023
ceed89b
refactor: Use cl
karelianpie Jul 5, 2023
edea6e0
refactor: Replace with a useAsync
karelianpie Jul 5, 2023
a6c0e21
refactor: Convert async fn to usCallback
karelianpie Jul 6, 2023
ba0ba55
feat: Use cl()
karelianpie Jul 6, 2023
b13a982
feat: Fetch prices on mount
karelianpie Jul 6, 2023
5e8aa71
feat: Add refreshPrice to the dep array
karelianpie Jul 6, 2023
6299c23
refactor: Replace useSWR with useAsync
karelianpie Jul 6, 2023
215642d
refactor(useGauge): Replace useSWR with useAsync
karelianpie Jul 6, 2023
f414b2e
Merge branch 'main' into feat/veyfi-gauges-merged
karelianpie Jul 6, 2023
bde56fb
Merge branch 'main' into feat/veyfi-gauges-merged
karelianpie Jul 17, 2023
b9424f2
refactor: Remove unnecessary prop
karelianpie Jul 24, 2023
aba6057
feat: Add button role
karelianpie Jul 24, 2023
d56cb8c
feat: Add button role
karelianpie Jul 24, 2023
70ba50e
feat: Move usePagination to common hooks
karelianpie Jul 24, 2023
40cdc3e
refactor: Remove `.toString()`
karelianpie Jul 24, 2023
643631e
refactor: Tailwindcss dynamic classnames
karelianpie Jul 24, 2023
3e981e3
Merge branch 'main' into feat/veyfi-gauges-merged
karelianpie Jul 25, 2023
6c554db
Merge branch 'main' into feat/veyfi-gauges-merged
karelianpie Jul 27, 2023
b632a03
Merge branch 'main' into feat/veyfi-gauges-merged
karelianpie Aug 4, 2023
c8cefe7
Merge branch 'main' into feat/veyfi-gauges-merged
karelianpie Aug 24, 2023
f69dc54
Merge branch 'main' into feat/veyfi-gauges-merged
karelianpie Aug 24, 2023
063c3a0
feat: Add `gauge-voting` feature flag
karelianpie Aug 24, 2023
9309920
chore: Update CHANGELOG
karelianpie Aug 28, 2023
511e4d5
Merge branch 'main' into feat/veyfi-gauges-merged
karelianpie Aug 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
207 changes: 207 additions & 0 deletions apps/common/components/Dropdown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
import React, {Fragment, useState} from 'react';
import {Combobox, Transition} from '@headlessui/react';
import {useThrottledState} from '@react-hookz/web';
import {cl} from '@yearn-finance/web-lib/utils/cl';
import performBatchedUpdates from '@yearn-finance/web-lib/utils/performBatchedUpdates';
import IconChevron from '@common/icons/IconChevron';

import {ImageWithFallback} from './ImageWithFallback';

import type {ReactElement} from 'react';

const DropdownOption = (option: TDropdownOption): ReactElement => {
const {label, description, icon} = option;
return (
<Combobox.Option value={option}>
{({active}): ReactElement => (
<div data-active={active} className={'yearn--dropdown-menu-item w-full hover:bg-neutral-0/40'}>
{icon && (
<div className={'h-6 w-6 rounded-full'}>
<ImageWithFallback
alt={label}
width={24}
height={24}
quality={90}
src={icon}
loading={'eager'}
/>
</div>
)}
<div>
<p className={`font-normal text-neutral-900 ${icon ? 'pl-2' : 'pl-0'}`}>
{label}
</p>
{description && (
<p className={`text-xxs font-normal text-neutral-600 ${icon ? 'pl-2' : 'pl-0'}`}>
{description}
</p>
)}
</div>
</div>
)}
</Combobox.Option>
);
};

const DropdownEmpty = ({isSearching}: {isSearching: boolean}): ReactElement => {
if(isSearching) {
return (
<div className={'relative flex h-14 flex-col items-center justify-center px-4 text-center'}>
<div className={'flex h-10 items-center justify-center'}>
<p className={'text-sm text-neutral-900'}>{'Nothing found.'}</p>
</div>
</div>
);
}

return (
<div className={'relative flex h-14 flex-col items-center justify-center px-4 text-center'}>
<div className={'flex h-10 items-center justify-center'}>
<span className={'loader'} />
</div>
</div>
);
};

export type TDropdownOption = {
id: string;
label: string;
description?: string;
icon?: string;
}

export type TDropdownProps = {
selected?: TDropdownOption;
options: TDropdownOption[];
onChange?: (selected: TDropdownOption) => void;
label?: string;
legend?: string;
isDisabled?: boolean;
className?: string;
}

const Dropdown = ({selected, options, onChange, label, legend, isDisabled, className}: TDropdownProps): ReactElement => {
const [isOpen, set_isOpen] = useThrottledState(false, 400);
const [search, set_search] = useState('');

const isSearching = search !== '';
const filteredOptions = isSearching
? options.filter(({label}): boolean => label.toLowerCase().includes(search.toLowerCase()))
: options;

return (
<div className={className}>
<div className={'relative z-20 flex flex-col space-y-1'}>
{label && <label className={'text-base text-neutral-600'}>{label}</label>}
<div>
{isOpen ? (
<div
className={'fixed inset-0 z-0'}
onClick={(e): void => {
e.stopPropagation();
e.preventDefault();
set_isOpen(false);
}} />
) : null}
<Combobox
value={selected}
onChange={(option: TDropdownOption): void => {
performBatchedUpdates((): void => {
if(onChange) {
onChange(option);
}
set_isOpen(false);
});
}}
disabled={isDisabled}
>
<>
<Combobox.Button
onClick={(): void => set_isOpen((state: boolean): boolean => !state)}
className={cl(
'flex h-10 w-full items-center justify-between p-2 text-base md:px-3',
isDisabled ? 'bg-neutral-300 text-neutral-600' : 'bg-neutral-0 text-neutral-900'
)}>
<div className={'relative flex flex-row items-center'}>
{selected?.icon && (
<div className={'h-6 w-6 rounded-full'}>
<ImageWithFallback
alt={selected.label}
width={24}
height={24}
quality={90}
src={selected.icon}
loading={'eager'}
/>
</div>
)}
<p
className={cl(
'max-w-[90%] overflow-x-hidden text-ellipsis whitespace-nowrap font-normal scrollbar-none md:max-w-full',
selected?.icon ? 'pl-2' : 'pl-0',
isDisabled ? 'text-neutral-600' : 'text-neutral-900'
)}>
<Combobox.Input
className={'w-full cursor-default overflow-x-scroll border-none bg-transparent p-0 outline-none scrollbar-none'}
displayValue={(option?: TDropdownOption): string => option?.label ?? '-' }
spellCheck={false}
onChange={(event): void => {
performBatchedUpdates((): void => {
set_isOpen(true);
set_search(event.target.value);
});
}}
/>
</p>
</div>
<div className={'absolute right-2 md:right-3'}>
<IconChevron
aria-hidden={'true'}
className={`h-6 w-6 transition-transform ${isOpen ? '-rotate-180' : 'rotate-0'}`} />
</div>
</Combobox.Button>
<Transition
as={Fragment}
show={isOpen}
enter={'transition duration-100 ease-out'}
enterFrom={'transform scale-95 opacity-0'}
enterTo={'transform scale-100 opacity-100'}
leave={'transition duration-75 ease-out'}
leaveFrom={'transform scale-100 opacity-100'}
leaveTo={'transform scale-95 opacity-0'}
afterLeave={(): void => {
performBatchedUpdates((): void => {
set_isOpen(false);
set_search('');
});
}}>
<Combobox.Options className={'yearn--dropdown-menu z-50'}>
{filteredOptions.length === 0 ? (
<DropdownEmpty isSearching={isSearching} />
) : (
filteredOptions.map(({id, label, description, icon}): ReactElement => (
<DropdownOption
key={id}
id={id}
label={label}
description={description}
icon={icon}
/>
))
)}
</Combobox.Options>
</Transition>
</>
</Combobox>
</div>
{legend && (
<p className={'pl-2 text-xs font-normal text-neutral-600'}>
{legend}
</p>
)}
</div>
</div>
);
};

export {Dropdown};
63 changes: 63 additions & 0 deletions apps/common/components/Pagination.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import ReactPaginate from 'react-paginate';
import IconPaginationArrow from '@common/icons/IconPaginationArrow';

import type {ReactElement} from 'react';

type TProps = {
range: [from: number, to: number];
pageCount: number;
numberOfItems: number;
onPageChange: (selectedItem: {
selected: number;
}) => void;
}

export function Pagination(props: TProps): ReactElement {
const {range: [from, to], pageCount, numberOfItems, onPageChange} = props;

return (
<>
<div className={'flex flex-1 justify-between sm:hidden'}>
<a
role={'button'}
href={'#'}
karelianpie marked this conversation as resolved.
Show resolved Hide resolved
className={'border-gray-300 text-gray-700 hover:bg-gray-50 relative inline-flex items-center rounded-md border px-4 py-2 text-sm font-medium'}
>
{'Previous'}
</a>
<a
role={'button'}
href={'#'}
karelianpie marked this conversation as resolved.
Show resolved Hide resolved
className={'border-gray-300 text-gray-700 hover:bg-gray-50 relative ml-3 inline-flex items-center rounded-md border px-4 py-2 text-sm font-medium'}
>
{'Next'}
</a>
</div>
<div className={'sm-border hidden sm:flex sm:items-center sm:justify-center'}>
<div className={'ml-3 flex-1'}>
<p className={'text-sm text-[#5B5B5B]'}>
{'Showing '}<span className={'font-medium'}>{from}</span>{' to '}<span className={'font-medium'}>{to}</span>{' of'}{' '}
<span className={'font-medium'}>{numberOfItems}</span> {'results'}
</p>
</div>
<ReactPaginate
className={'inline-flex align-middle'}
pageLinkClassName={'text-[#5B5B5B] hover:border-b-2 inline-flex items-end mx-1.5 mt-2.5 px-0.5 text-xs'}
previousLinkClassName={'inline-flex items-center m-2 font-medium'}
nextLinkClassName={'inline-flex items-center m-2 font-medium'}
breakLinkClassName={'text-[#5B5B5B] inline-flex items-center mx-2 my-2 px-0.5 font-medium'}
activeLinkClassName={'text-gray-900 font-bold border-b-2 items-center mx-2 my-2 px-0.5 md:inline-flex'}
disabledLinkClassName={'cursor-not-allowed hover:bg-neutral-100'}
disabledClassName={'text-neutral-300'}
breakLabel={'...'}
onPageChange={onPageChange}
pageRangeDisplayed={3}
pageCount={pageCount}
previousLabel={<IconPaginationArrow className={'h-5 w-5 transition-transform'} />}
nextLabel={<IconPaginationArrow className={'h-5 w-5 -rotate-180 transition-transform'} />}
/>
<div className={'sm:flex-1'}></div>
</div>
</>
);
}
Loading
Loading