Skip to content

Commit

Permalink
Quickfix/ultrasound issues (#296)
Browse files Browse the repository at this point in the history
* supply fix

* max issue

---------

Co-authored-by: jmzwar <[email protected]>
  • Loading branch information
jmzwar and jmzwar authored Jun 6, 2024
1 parent 40ccece commit eba2471
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
12 changes: 9 additions & 3 deletions ultrasound/ui/components/BurnSNXModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export function BurnSNXModal({ isOpen, onClose }: { isOpen: boolean; onClose: ()

const { data: snxBalance } = useTokenBalance('0x22e6966B799c4D5B13BE962E1D117b56327FDa66');
const { data: usdcBalance } = useTokenBalance('0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913');

const { data: contractBalance } = SNXUSDBalanceOfBuyBackContract(
'0x632cAa10A56343C5e6C0c066735840c096291B18'
);
Expand All @@ -41,6 +42,7 @@ export function BurnSNXModal({ isOpen, onClose }: { isOpen: boolean; onClose: ()
amount: amount ? amount.toBN() : 0,
spender: '0x632cAa10A56343C5e6C0c066735840c096291B18',
});

const { mutateAsync, isPending } = useSellSNX();

return (
Expand Down Expand Up @@ -128,16 +130,20 @@ export function BurnSNXModal({ isOpen, onClose }: { isOpen: boolean; onClose: ()
Burnable:{' '}
{contractBalance &&
SNXPrice &&
new Wei(contractBalance, 18).div(SNXPrice).toNumber().toFixed(2)}
// Mul by 0.98 to account for 2% slippage
new Wei(contractBalance, 18).mul(0.98).div(SNXPrice).toNumber().toFixed(2)}
<Button
size="xs"
variant="unstyled"
color="cyan.500"
ml="2"
fontSize="12px"
onClick={() => {
setAmount(new Wei(contractBalance, 18).div(SNXPrice));
setReceivingUSDCAmount(new Wei(contractBalance, 18).div(SNXPrice).toNumber());
const balance = new Wei(contractBalance, 18);
const snxAmount = balance.mul(0.98).div(SNXPrice);

setAmount(snxAmount);
setReceivingUSDCAmount(balance.toNumber());
}}
>
Max
Expand Down
5 changes: 4 additions & 1 deletion ultrasound/ui/hooks/useBurnEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,15 @@ export function useBurnEvents() {
{} as Record<string, number>
);

const totalBurned = events.reduce((cur, prev) => cur + prev.snxAmount, 0);
const currentSupply = Number(utils.formatEther(totalSupply)) - totalBurned;

return {
totalBurns: events.length,
groupedByMonths,
groupedByLast30Days,
supplyChange7Days,
totalSupply: Number(utils.formatEther(totalSupply)).toLocaleString('en-US', {
totalSupply: currentSupply.toLocaleString('en-US', {
maximumFractionDigits: 2,
}),
SNXPrice:
Expand Down

0 comments on commit eba2471

Please sign in to comment.