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

Disable consolidate button #3201

Merged
merged 3 commits into from
Sep 21, 2024
Merged
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
131 changes: 0 additions & 131 deletions src/views/Lending/Cooler/positions/ConsolidateLoan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,137 +59,6 @@ export const ConsolidateLoans = ({
console.log("consolidate loans");
return (
<>
<PrimaryButton onClick={() => setOpen(!open)}>Consolidate Loans</PrimaryButton>
<Modal
maxWidth="476px"
minHeight="200px"
open={open}
headerContent={
<Box display="flex" alignItems="center" gap="6px">
<SvgIcon component={lendAndBorrowIcon} /> <Box fontWeight="500">Consolidate Loans</Box>
</Box>
}
onClose={() => setOpen(false)}
>
<>
<InfoNotification>
All existing open loans for this Cooler and Clearinghouse will be repaid and consolidated into a new loan
with a {duration} day duration. You must hold enough DAI in your wallet to cover the interest owed at
consolidation.
</InfoNotification>
<Box
display="flex"
flexDirection="row"
justifyContent="space-between"
alignItems="center"
mb={"9px"}
mt={"21px"}
>
<Typography sx={{ fontSize: "15px", lineHeight: "21px" }}>Loans to Consolidate</Typography>
<Box display="flex" flexDirection="column" textAlign="right">
<Typography sx={{ fontSize: "15px", lineHeight: "21px" }}>{loans.length}</Typography>
</Box>
</Box>
<Box
display="flex"
flexDirection="row"
justifyContent="space-between"
alignItems="center"
mb={"9px"}
mt={"21px"}
>
<Typography sx={{ fontSize: "15px", lineHeight: "21px" }}>New Principal Amount</Typography>
<Box display="flex" flexDirection="column" textAlign="right">
<Typography sx={{ fontSize: "15px", lineHeight: "21px" }}>
{formatNumber(parseFloat(formatEther(totals.principal)), 4)} DAI
</Typography>
</Box>
</Box>
<Box
display="flex"
flexDirection="row"
justifyContent="space-between"
alignItems="center"
mb={"9px"}
mt={"21px"}
>
<Typography sx={{ fontSize: "15px", lineHeight: "21px" }}>Interest Owed At Consolidation</Typography>
<Box display="flex" flexDirection="column" textAlign="right">
<Typography sx={{ fontSize: "15px", lineHeight: "21px" }}>
{formatNumber(parseFloat(formatEther(totals.interest)), 4)} DAI
</Typography>
</Box>
</Box>
<Box
display="flex"
flexDirection="row"
justifyContent="space-between"
alignItems="center"
mb={"9px"}
mt={"21px"}
>
<Typography sx={{ fontSize: "15px", lineHeight: "21px" }}>New Maturity Date</Typography>
<Box display="flex" flexDirection="column" textAlign="right">
<Typography sx={{ fontSize: "15px", lineHeight: "21px" }}>
{maturityDate.toLocaleDateString([], {
month: "long",
day: "numeric",
year: "numeric",
}) || ""}{" "}
{maturityDate.toLocaleTimeString([], {
hour: "2-digit",
minute: "2-digit",
})}
</Typography>
</Box>
</Box>
{insufficientCollateral ? (
<PrimaryButton disabled fullWidth>
Insufficient DAI Balance
</PrimaryButton>
) : (
<TokenAllowanceGuard
tokenAddressMap={DAI_ADDRESSES}
spenderAddressMap={COOLER_CONSOLIDATION_ADDRESSES}
isVertical
message={<>Approve DAI for Spending on the Consolidation Contract</>}
spendAmount={new DecimalBigNumber(ethers.constants.MaxUint256, 18)}
approvalText="Approve DAI for Spending"
>
<TokenAllowanceGuard
tokenAddressMap={GOHM_ADDRESSES}
spenderAddressMap={COOLER_CONSOLIDATION_ADDRESSES}
isVertical
message={<>Approve gOHM for Spending on the Consolidation Contract</>}
spendAmount={new DecimalBigNumber(totals.collateral, 18)}
approvalText="Approve gOHM for Spending"
>
<PrimaryButton
onClick={() => {
coolerMutation.mutate(
{
coolerAddress,
clearingHouseAddress,
loanIds,
},
{
onSuccess: () => {
setOpen(false);
},
},
);
}}
loading={coolerMutation.isLoading}
disabled={coolerMutation.isLoading}
fullWidth
>
Consolidate Loans
</PrimaryButton>
</TokenAllowanceGuard>
</TokenAllowanceGuard>
)}
</>
</Modal>
</>
);
};
9 changes: 0 additions & 9 deletions src/views/Lending/Cooler/positions/Positions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,6 @@ export const CoolerPositions = () => {
>
Borrow DAI & Open Position
</PrimaryButton>
{clearingHouse && loans.length > 1 && (
<ConsolidateLoans
coolerAddress={coolerAddress}
clearingHouseAddress={clearingHouse.clearingHouseAddress}
loans={loans}
duration={clearingHouse.duration}
debtAddress={clearingHouse.debtAddress}
/>
)}
</Box>
</>
)}
Expand Down
Loading