-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dApp: Deposit limit when TVL cap is exceeded (#826)
Closes: #827 Closes: #805 ### Changes: - Add information about the TVL cap excess - Add information about the remaining TVL - Disable the deposit button when the TVL cap is exceeded - Hide the withdrawal button for guests and first time users ### Preview: <img width="649" alt="image" src="https://github.com/user-attachments/assets/19928043-3a03-4466-8b18-b3986227da67"> <img width="651" alt="image" src="https://github.com/user-attachments/assets/120be7cd-da99-4695-8181-511b45ab3418"> ### Note: - ~~To start with latest TVL changes I set the origin branch to [`tvl-component`](https://github.com/thesis/acre/tree/tvl-component).~~ - If you'd like to test the functionality you can manually modify the cap value in [`src/constants/staking.ts`](https://github.com/thesis/acre/blob/tvl-cap-deposit-limit/dapp/src/constants/staking.ts#L4) file.
- Loading branch information
Showing
3 changed files
with
83 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from "react" | ||
import { Box, HStack, StackProps, VStack } from "@chakra-ui/react" | ||
import { useAllActivitiesCount, useStatistics, useWallet } from "#/hooks" | ||
import { BoltFilled } from "#/assets/icons" | ||
import { TextMd } from "#/components/shared/Typography" | ||
import { CurrencyBalance } from "#/components/shared/CurrencyBalance" | ||
|
||
type AcreTVLMessageProps = Omit<StackProps, "children"> | ||
|
||
export default function AcreTVLMessage(props: AcreTVLMessageProps) { | ||
const { tvl } = useStatistics() | ||
const { isConnected } = useWallet() | ||
const activitiesCount = useAllActivitiesCount() | ||
|
||
const isFirstTimeUser = activitiesCount === 0 | ||
|
||
if (isConnected && !isFirstTimeUser && !tvl.isCapExceeded) { | ||
return null | ||
} | ||
|
||
return ( | ||
<HStack align="start" spacing={1} color="grey.500" {...props}> | ||
<BoltFilled color="orange.400" my={1} /> | ||
{tvl.isCapExceeded ? ( | ||
<VStack align="start" spacing={0}> | ||
<TextMd fontWeight="semibold" color="grey.700"> | ||
Deposit cap reached! | ||
</TextMd> | ||
<TextMd>Stay tuned for the next deposit cycle.</TextMd> | ||
</VStack> | ||
) : ( | ||
<TextMd as="div"> | ||
<CurrencyBalance | ||
amount={tvl.remaining} | ||
currency="bitcoin" | ||
shouldBeFormatted={false} | ||
desiredDecimals={2} | ||
color="grey.700" | ||
/> | ||
<Box as="span"> remaining until deposit cap</Box> | ||
</TextMd> | ||
)} | ||
</HStack> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters