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

upd: apr tooltip + withdraw fix #393

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "stability-ui",
"type": "module",
"version": "0.7.8-alpha",
"version": "0.7.9-alpha",
"scripts": {
"dev": "astro dev",
"start": "astro dev",
Expand Down
8 changes: 8 additions & 0 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,14 @@ const {
position:relative;
}

.tippy-box[data-theme~="custom"] {
background-color: #26282f !important;
color: white !important;
}
.tippy-box[data-theme~="custom"] .tippy-arrow {
color:#26282f !important;
}

.tooltip .visible__tooltip {
width:250px;
left:50%;
Expand Down
81 changes: 36 additions & 45 deletions src/modules/SonicVaults/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import { useWeb3Modal } from "@web3modal/wagmi/react";

import Tippy from "@tippyjs/react";

// import { formatUnits} from "viem";

import { useStore } from "@nanostores/react";
Expand All @@ -10,7 +12,6 @@

// import { deployments } from "@stabilitydao/stability";

import { APRModal } from "./components/modals/APRModal";
import { VSHoldModal } from "./components/modals/VSHoldModal";
import { ColumnSort } from "./components/ColumnSort";
import { Pagination } from "./components/Pagination";
Expand Down Expand Up @@ -64,6 +65,8 @@

import { PlatformABI } from "@web3";

import "tippy.js/dist/tippy.css";

import type {
TVault,
TTableColumn,
Expand All @@ -72,7 +75,7 @@
// TPendingPlatformUpgrade,
// TAddress,
// TUpgradesTable,
TEarningData,
// TEarningData,
TVaults,
TAPRPeriod,
TPendingPlatformUpgrade,
Expand Down Expand Up @@ -141,14 +144,6 @@

const [localVaults, setLocalVaults] = useState<TVault[]>([]);
const [filteredVaults, setFilteredVaults] = useState<TVault[]>([]);
const [aprModal, setAprModal] = useState({
earningData: {} as TEarningData,
daily: 0,
lastHardWork: "0",
symbol: "",
state: false,
pool: {},
});

const [vsHoldModal, setVsHoldModal] = useState<TVSHoldModalState>({
assetsVsHold: [],
Expand Down Expand Up @@ -236,7 +231,7 @@

const fetchPlatformUpdates = async () => {
try {
const pendingPlatformUpgrade: any = await $publicClient?.readContract({

Check warning on line 234 in src/modules/SonicVaults/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
address: deployments[$currentChainID]?.core.platform,
abi: PlatformABI,
functionName: "pendingPlatformUpgrade",
Expand Down Expand Up @@ -306,12 +301,12 @@
}

/////***** TIME CHECK *****/////
const lockTime: any = await $publicClient?.readContract({

Check warning on line 304 in src/modules/SonicVaults/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
address: deployments[$currentChainID].core.platform,
abi: PlatformABI,
functionName: "TIME_LOCK",
});
const platformUpgradeTimelock: any = await $publicClient?.readContract({

Check warning on line 309 in src/modules/SonicVaults/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
address: deployments[$currentChainID].core.platform,
abi: PlatformABI,
functionName: "platformUpgradeTimelock",
Expand Down Expand Up @@ -765,35 +760,12 @@
)}
</div>
</td>
<td
onClick={(e) => {
if (isMobile) {
e.stopPropagation();
setAprModal({
earningData: vault.earningData,
daily: vault.daily,
lastHardWork: vault.lastHardWork,
symbol: vault?.risk?.symbol as string,
state: true,
pool: vault?.pool,
});
}
}}
className="px-2 min-[1130px]:px-3 py-2 tooltip cursor-help"
>
<div
className={`whitespace-nowrap w-full text-end flex items-center justify-end gap-[2px] ${
vault?.risk?.isRektStrategy
? "text-[#818181]"
: "text-[#eaecef]"
}`}
>
<p className="text-end">
{formatNumber(aprValue, "formatAPR")}%
</p>
</div>
<div className="visible__tooltip">
<div className="flex items-start flex-col gap-4">

<Tippy
theme="custom"
delay={0}
content={
<div className="flex font-manrope items-start flex-col gap-4 w-[250px] bg-[#26282f] px-5 py-[10px]">
<div className="flex flex-col gap-1 w-full">
{!!vault?.risk?.isRektStrategy && (
<div className="flex flex-col items-center gap-2 mb-[10px]">
Expand Down Expand Up @@ -859,9 +831,31 @@
/>
</div>
</div>
<i></i>
</div>
</td>
}
placement="top"
>
<td
onClick={(e) => {
if (isMobile) {
e.stopPropagation();
}
}}
className="px-2 min-[1130px]:px-3 py-2 tooltip cursor-help"
>
<div
className={`whitespace-nowrap w-full text-end flex items-center justify-end gap-[2px] ${
vault?.risk?.isRektStrategy
? "text-[#818181]"
: "text-[#eaecef]"
}`}
>
<p className="text-end">
{formatNumber(aprValue, "formatAPR")}%
</p>
</div>
</td>
</Tippy>

{/* <td
onClick={(e) => {
if (isMobile) {
Expand Down Expand Up @@ -1051,9 +1045,6 @@
tab={currentTab}
setTab={setCurrentTab}
/>
{aprModal.state && (
<APRModal state={aprModal} setModalState={setAprModal} />
)}
{vsHoldModal.state && (
<VSHoldModal state={vsHoldModal} setModalState={setVsHoldModal} />
)}
Expand Down
5 changes: 3 additions & 2 deletions src/modules/Vault/components/InfoBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { formatFromBigInt, formatNumber } from "@utils";
import { CHAINS } from "@constants";

import type { TAPRPeriod, TVault } from "@types";
import {seeds} from "@stabilitydao/stability";
import { seeds } from "@stabilitydao/stability";

interface IProps {
network: string;
Expand Down Expand Up @@ -65,7 +65,7 @@ const InfoBar: React.FC<IProps> = memo(({ network, vault }) => {
}, [$aprFilter, userBalances]);

useEffect(() => {
if (vault?.balance && vault?.shareprice) {
if (vault?.shareprice) {
const vaultBalance = BigInt(vault?.balance);
const shareBalance = Number(
formatFromBigInt(vault?.balance, 18).toFixed(5)
Expand All @@ -80,6 +80,7 @@ const InfoBar: React.FC<IProps> = memo(({ network, vault }) => {
setUserBalances({ shareBalance, USDBalance });
}
}, [vault]);

const vaultChain = useMemo(
() => CHAINS.find((item) => item.id === network),
[network]
Expand Down
4 changes: 4 additions & 0 deletions src/modules/Vault/components/InvestForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@

if (tab === "Deposit") {
setInputs(
(prevInputs: any) =>

Check warning on line 346 in src/modules/Vault/components/InvestForm/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
({
...prevInputs,
[asset]: amount,
Expand All @@ -357,7 +357,7 @@
previewDeposit(asset, amount);
}
} else {
const preview: TVaultInput | any = {};

Check warning on line 360 in src/modules/Vault/components/InvestForm/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
for (let i = 0; i < option.length; i++) {
preview[option[i]] = amount as string;
}
Expand All @@ -378,7 +378,7 @@
};

const resetInputs = (options: string[] = option) => {
const reset: TVaultInput | any = {};

Check warning on line 381 in src/modules/Vault/components/InvestForm/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

for (let i = 0; i < options.length; i++) {
reset[options[i]] = "";
Expand Down Expand Up @@ -1455,6 +1455,7 @@
if (shortId === "IQMF" || shortId === "IRMF") {
localAssets = vault.assets.map((asset) => asset.address);
}

if (underlyingToken?.address === option[0]) {
const decimalPercent = BigInt(Math.floor(Number(settings.slippage)));

Expand Down Expand Up @@ -1511,6 +1512,7 @@
if (transaction.status === "success") {
resetFormAfterTx();
}

lastTx.set(transaction?.transactionHash);
setLoader(false);
} catch (err) {
Expand Down Expand Up @@ -1584,6 +1586,7 @@
if (transaction.status === "success") {
resetFormAfterTx();
}

lastTx.set(transaction?.transactionHash);
setLoader(false);
} catch (err) {
Expand Down Expand Up @@ -1674,6 +1677,7 @@
if (transaction.status === "success") {
resetFormAfterTx();
}

lastTx.set(transaction?.transactionHash);
setLoader(false);
} catch (err) {
Expand Down
Loading