From eab803a787200a0518cf88ba84dc23d569917fa2 Mon Sep 17 00:00:00 2001 From: Zak Date: Tue, 4 Feb 2025 16:41:19 +0000 Subject: [PATCH] feat: add alert for upcoming auto redemption --- src/App.css | 9 +++ src/components/vault/VaultRedemptionAlert.jsx | 59 +++++++++++++++++++ src/pages/vault/Vault.jsx | 6 ++ 3 files changed, 74 insertions(+) create mode 100644 src/components/vault/VaultRedemptionAlert.jsx diff --git a/src/App.css b/src/App.css index 8ce5bb7..bed45d3 100644 --- a/src/App.css +++ b/src/App.css @@ -529,6 +529,15 @@ box-shadow: inset 1px 1px 1px 0px rgba(74, 222, 128, 0.2), 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1) } +.tst-card.warn-card::before { + background: linear-gradient( + 110.28deg, + rgba(255, 190, 0, 0.3) 0.2%, + rgba(255, 190, 0, 0.2) 101.11% + ); + box-shadow: inset 1px 1px 1px 0px rgba(255, 190, 0, 0.2), 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1) +} + /* INPUTS */ input.input { diff --git a/src/components/vault/VaultRedemptionAlert.jsx b/src/components/vault/VaultRedemptionAlert.jsx new file mode 100644 index 0000000..8f75cf9 --- /dev/null +++ b/src/components/vault/VaultRedemptionAlert.jsx @@ -0,0 +1,59 @@ +import { useState, useEffect } from "react"; +import { useNavigate } from "react-router-dom"; +import { + ArrowTrendingUpIcon +} from '@heroicons/react/24/outline'; +import axios from "axios"; + +import Card from "../ui/Card"; +import Typography from "../ui/Typography"; + +const VaultRedemptionAlert = ({ + vaultId, +}) => { + const [redemption, setRedemption] = useState(); + + useEffect(() => { + getUpcomingRedemption(); + }, []); + + const getUpcomingRedemption = async () => { + try { + const response = await axios.get( + `https://smart-vault-api.thestandard.io/redemption` + ); + const data = response.data; + setRedemption(data); + } catch (error) { + console.log(error); + } + }; + + if (redemption) { + if (vaultId === redemption?.tokenID) { + return ( + <> + +
+ + + Upcoming Auto Redemption + + + Your vault is currently the most borrowed against, and may automatically use a portion of your collateral to pay off your debt at a discount if USDs trades below $1. +
+ If you want to avoid the auto redemption you should repay some of your debt now. +
+
+
+ + ) + } + } + + return (<>) +}; + +export default VaultRedemptionAlert; \ No newline at end of file diff --git a/src/pages/vault/Vault.jsx b/src/pages/vault/Vault.jsx index 68e83a2..ef35027 100644 --- a/src/pages/vault/Vault.jsx +++ b/src/pages/vault/Vault.jsx @@ -34,6 +34,7 @@ import VaultSend from "../../components/vault/VaultSend"; import TokenTotalPie from "../../components/vault/TokenTotalPie"; import VaultNFT from "../../components/vault/VaultNFT"; import VaultSavingsSummary from "../../components/vault/VaultSavingsSummary"; +import VaultRedemptionAlert from "../../components/vault/VaultRedemptionAlert"; import YieldParentNew from "../../components/vault/yield/YieldParentNew"; @@ -277,6 +278,11 @@ const Vault = () => {
+ {vaultType === 'USDs' ? ( + + ) : null}