Skip to content

Commit

Permalink
liquidation type
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhochu committed Feb 28, 2024
1 parent 9ac921f commit 0b13486
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
45 changes: 42 additions & 3 deletions screens/Dashboard/liquidations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,50 @@ const columns = [
return <div className="text-gray-300 truncate">{getDateString(createdAt * 1000)}</div>;
},
},
{
header: () => (
<div style={{ whiteSpace: "normal" }}>
Collateral<div>Type</div>
</div>
),
cell: ({ originalData }) => {
const { LiquidatedAssets } = originalData || {};
return <div>{LiquidatedAssets?.[0]?.data?.isLpToken ? "LP token" : "Single token"}</div>;
},
},
{
header: () => (
<div style={{ whiteSpace: "normal" }}>
Liquidation<div>Type</div>
</div>
),
cell: ({ originalData }) => {
const { liquidation_type } = originalData || {};
return <div>{liquidation_type || "-"}</div>;
},
},
{
header: () => (
<div style={{ whiteSpace: "normal" }}>
Health Factor<div>before Liquidate</div>
</div>
),
cell: ({ originalData }) => {
const { healthFactor_before } = originalData || {};
const { healthFactor_before, liquidation_type } = originalData || {};
if (liquidation_type === "ForceClose") {
return "-";
}
return <div>{(Number(healthFactor_before) * 100).toFixed(2)}%</div>;
},
},
{
header: () => <div style={{ whiteSpace: "normal" }}>Repaid Assets Amount</div>,
cell: ({ originalData }) => {
const { RepaidAssets } = originalData || {};
if (!RepaidAssets?.length) {
return "-";
}

const node = RepaidAssets?.map((d, i) => {
const isLast = RepaidAssets.length === i + 1;
const { metadata, config } = d.data || {};
Expand All @@ -118,6 +147,10 @@ const columns = [
header: () => <div style={{ whiteSpace: "normal" }}>Liquidated Assets</div>,
cell: ({ originalData }) => {
const { LiquidatedAssets } = originalData || {};
if (!LiquidatedAssets?.length) {
return "-";
}

const node = LiquidatedAssets?.map((d) => {
const { metadata, config } = d.data || {};
const { extra_decimals } = config || {};
Expand All @@ -142,8 +175,14 @@ const columns = [
</div>
),
cell: ({ originalData }) => {
const { healthFactor_after } = originalData || {};
return <div>{(Number(healthFactor_after) * 100).toFixed(2)}%</div>;
const { healthFactor_after, liquidation_type } = originalData || {};
if (liquidation_type === "ForceClose") {
return <div style={{ textAlign: "right" }}>-</div>;
}

return (
<div style={{ textAlign: "right" }}>{(Number(healthFactor_after) * 100).toFixed(2)}%</div>
);
},
},
];
Expand Down
4 changes: 3 additions & 1 deletion screens/Dashboard/modalHistoryInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ const ModalHistoryInfo = ({ isOpen, onClose, tab }) => {
const { unreadLiquidation, fetchUnreadLiquidation } = useUnreadLiquidation();

useEffect(() => {
setTabIndex(tab);
if (tab !== undefined) {
setTabIndex(tab);
}
}, [tab]);

const handleTabChange = (i) => {
Expand Down

0 comments on commit 0b13486

Please sign in to comment.