-
Notifications
You must be signed in to change notification settings - Fork 51
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
<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> | ||
); |
There was a problem hiding this comment.
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
<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> |
There was a problem hiding this comment.
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
/> | ||
<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> |
There was a problem hiding this comment.
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
apps/common/components/Input.tsx
Outdated
|
||
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> | ||
); | ||
} |
There was a problem hiding this comment.
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
// 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); | ||
} |
There was a problem hiding this comment.
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
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(); | ||
} |
There was a problem hiding this comment.
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
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(); | ||
} |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
abi: stakingType === 'OP Boost' ? STAKING_REWARDS_ABI : VEYFI_GAUGE_ABI, | ||
functionName: stakingType === 'OP Boost' ? 'stakingToken' : 'asset' |
There was a problem hiding this comment.
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
28dcd9f
to
b6e074b
Compare
No description provided.