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: initial staking upd #542

Merged
merged 6 commits into from
Apr 15, 2024
Merged

feat: initial staking upd #542

merged 6 commits into from
Apr 15, 2024

Conversation

Majorfi
Copy link
Collaborator

@Majorfi Majorfi commented Apr 10, 2024

No description provided.

Copy link

vercel bot commented Apr 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
yearnfi ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 15, 2024 2:05pm

Comment on lines 30 to 42
<div className={'col-span-12 mt-0'}>
<div className={'w-full bg-neutral-900 p-6 text-neutral-0'}>
<b className={'text-lg'}>{'Great news! You can earn even more!'}</b>
<div className={'mt-2 flex flex-col gap-2'}>
<p>
{
'This Vault is receiving an Optimism Boost. Deposit and stake your tokens to receive OP rewards. Nice!'
}
</p>
</div>
</div>
</div>
);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This copy will be updated

Comment on lines 51 to 69
<p>
{`You can earn from ${formatAmount(extraAPR * 10)}% to ${formatAmount(extraAPR * 100)}% extra APR by depositing your tokens into the veYFI gauge!`}
</p>
<p>
{
'You can stake vault tokens and earn dYFI rewards. Based on your veYFI weight, you can boost your rewards by up to 10x proportional to the number of vault tokens deposited.'
}
</p>
<p className={'block'}>
{'Learn more about veYFI rewards in the '}
<a
className={'underline'}
href={'https://docs.yearn.fi/getting-started/products/veyfi'}
target={'_blank'}
rel={'noreferrer'}>
{'FAQ'}
</a>
{'.'}
</p>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This copy will be updated

Comment on lines 248 to 262
/>
<Button
className={'w-full md:mt-7 md:w-[200px]'}
className={'w-full md:w-[200px]'}
onClick={onUnstake}
isBusy={unstakeStatus.pending}
isDisabled={!isActive || Number(normalizedStakeBalance.normalized) <= 0}>
{'Claim & Exit'}
</Button>
<Button
className={'w-full md:w-[200px]'}
onClick={onClaim}
isBusy={claimStatus.pending}
isDisabled={!isActive || isZero(normalizedRewardBalance.raw)}>
{'Claim'}
</Button>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put both buttons on the same line to match flow in Juiced vaults

Comment on lines 46 to 73

export function FakeInput(
props: Omit<TAmountInputProps, 'value' | 'placeholder' | 'onChange' | 'isDisabled' | 'error'> & {value: ReactNode}
): ReactElement {
const {value, label, legend, className = ''} = props;
return (
<div className={`w-full ${className}`}>
{label && <p className={'mb-1 w-full truncate text-base text-neutral-600'}>{label}</p>}
<div className={'relative flex w-full items-center justify-center'}>
<div
className={cl(
`h-10 w-full border-0 border-none bg-neutral-300 p-2 font-mono text-base font-normal outline-none`,
value === undefined ? 'text-neutral-600/60' : ''
)}
aria-label={label}>
{value || '0.00'}
</div>
</div>
{legend && (
<legend
className={`mt-1 pl-0.5 text-xs text-neutral-600 opacity-70 md:mr-0`}
suppressHydrationWarning>
{legend}
</legend>
)}
</div>
);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like an input, but is not an input.
Mostly to display some animation with the <Counter> component for live earning rewards

Comment on lines 252 to 266
// eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-vars
function cloneForForknet(tokens: TUseBalancesTokens[]): TUseBalancesTokens[] {
const clonedTokens: TUseBalancesTokens[] = [];
tokens.forEach((token): void => {
clonedTokens.push({...token});
if (token.chainID === 1) {
clonedTokens.push({...token, chainID: 1337});
}
});
return clonedTokens;
}
const shouldEnableForknet = true;
if (shouldEnableForknet) {
return cloneForForknet(allTokens);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code allows us to fetch balances for a forknet and have available balances for it to test

Comment on lines 141 to 151
const result = await stakeVeYFIAction({
connector: provider,
chainID: currentVault.chainID,
contractAddress: toAddress(stakingRewards?.address),
amount: vaultToken.balance.raw,
statusHandler: set_stakeStatus
});
if (result.isSuccessful) {
refreshData();
updateStakingRewards();
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When depositing in a Gauge to receive dYFI, the contract isn't the same as the stake for OP token. We need to adapt the call we will do based on the staking source

Comment on lines 187 to 198
const result = await unstakeVeYFIAction({
connector: provider,
chainID: currentVault.chainID,
contractAddress: toAddress(stakingRewards?.address),
amount: normalizedStakeBalance.raw,
willClaim: true,
statusHandler: set_unstakeStatus
});
if (result.isSuccessful) {
refreshData();
updateStakingRewards();
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When depositing in a Gauge to receive dYFI, the contract isn't the same as the stake for OP token. We need to adapt the call we will do based on the staking source

</div>
<div className={'flex flex-col gap-4 md:flex-row'}>
<Input
<FakeInput
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the input is not editable, no need to use an actual input

Comment on lines 31 to 32
abi: stakingType === 'OP Boost' ? STAKING_REWARDS_ABI : VEYFI_GAUGE_ABI,
functionName: stakingType === 'OP Boost' ? 'stakingToken' : 'asset'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the staking source, we need to change the ABI source or the function name

@Majorfi Majorfi marked this pull request as ready for review April 15, 2024 14:05
@Majorfi Majorfi merged commit 5a61164 into main Apr 15, 2024
9 checks passed
@Majorfi Majorfi deleted the feat/stakingUpd branch April 15, 2024 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant