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: useMaxRedeem for some situations #549

Merged
merged 3 commits into from
Apr 25, 2024
Merged

feat: useMaxRedeem for some situations #549

merged 3 commits into from
Apr 25, 2024

Conversation

Majorfi
Copy link
Collaborator

@Majorfi Majorfi commented Apr 24, 2024

Use max redeem to determine the max amount a user can withdraw

Copy link

vercel bot commented Apr 24, 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 24, 2024 11:13am

Comment on lines +32 to +71
function AmountWithOptionalTooltip(props: {
canOnlyWithdrawSome: boolean;
maxPossibleToWithdraw: TNormalizedBN;
tokenSymbol: string;
}): ReactElement {
if (props.canOnlyWithdrawSome) {
return (
<div className={'flex flex-row items-center justify-between space-x-2'}>
<label
htmlFor={'fromAmount'}
className={'hidden text-base text-neutral-600 md:inline'}>
{'Amount'}
</label>
<span className={'tooltip'}>
<IconQuestion className={'hidden opacity-40 md:block'} />
<span className={'tooltipLight top-full w-full pt-1'}>
<div
className={
'font-number mr-[-360px] max-w-sm border border-neutral-300 bg-neutral-100 p-1 px-2 text-center text-xxs text-neutral-900'
}>
<p className={'font-number whitespace-pre text-wrap text-left text-neutral-400 md:text-xs'}>
{`This Vault is not always totally liquid (don’t worry anon, funds are Safu).\n\nYou can currently withdraw up to ${formatAmount(props.maxPossibleToWithdraw.normalized, 6)} ${props.tokenSymbol}.\n\nLike the best things in life, liquidity comes and goes so feel free to check back later.`}
</p>
</div>
</span>
</span>
</div>
);
}
return (
<div>
<label
htmlFor={'fromAmount'}
className={'hidden text-base text-neutral-600 md:inline'}>
{'Amount'}
</label>
</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.

Display a little (?) with a message if the user can only withdraw part of it's vault deposit

@@ -213,7 +255,7 @@ export function VaultDetailsQuickActionsFrom(): ReactElement {
onChangeAmount(
isDepositing
? maxDepositPossible(toAddress(actionParams?.selectedOptionFrom?.value))
: userBalance
: maxWithdrawPossible().safeLimit
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Instead of just the user's balance, we use the safeLimit (either user balance of maxRedeem with some security)

@Majorfi Majorfi marked this pull request as ready for review April 25, 2024 08:53
@Majorfi Majorfi merged commit 4fb1ecd into main Apr 25, 2024
9 checks passed
@Majorfi Majorfi deleted the feat/v3-maxRedeem branch April 25, 2024 08:53
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.

2 participants