Skip to content

Commit

Permalink
feat: max button update (#315)
Browse files Browse the repository at this point in the history
* feat: max button update

* feat: updated price calc for max button
  • Loading branch information
MrX-SNX authored Jun 19, 2024
1 parent 820fc35 commit 52284db
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions ultrasound/ui/components/BurnSNXModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,19 @@ export function BurnSNXModal({ isOpen, onClose }: { isOpen: boolean; onClose: ()
ml="2"
fontSize="12px"
onClick={() => {
const balance = new Wei(contractBalance, 18);
const snxAmount = balance.mul(0.98).div(SNXPrice);

setAmount(snxAmount);
setReceivingUSDCAmount(balance.toNumber());
if (SNXPrice && snxBalance) {
const balance = new Wei(contractBalance, 18);
const snxAmount = balance.mul(0.98).div(SNXPrice);
if (snxAmount.gt(snxBalance)) {
setAmount(snxBalance);
setReceivingUSDCAmount(
snxBalance.mul(SNXPrice.add(SNXPrice.mul(0.01))).toNumber() || 0
);
} else {
setAmount(snxAmount);
setReceivingUSDCAmount(balance.toNumber());
}
}
}}
>
Max
Expand Down

0 comments on commit 52284db

Please sign in to comment.