Skip to content

Commit

Permalink
fix: nbtc min withdraw tip
Browse files Browse the repository at this point in the history
  • Loading branch information
naturexie committed Jan 20, 2025
1 parent 71f897c commit 842a58e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
10 changes: 8 additions & 2 deletions components/Modal/Action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ import { SubmitButton } from "./components";
import getShadowRecords from "../../api/get-shadows";
import { expandToken, shrinkToken } from "../../store";

export default function Action({ maxBorrowAmount, healthFactor, collateralType, poolAsset }) {
export default function Action({
maxBorrowAmount,
healthFactor,
collateralType,
poolAsset,
isDisabled,
}) {
const [loading, setLoading] = useState(false);
const { amount, useAsCollateral, isMax } = useAppSelector(getSelectedValues);
const { enable_pyth_oracle } = useAppSelector(getConfig); // TODO33 need query from api?
Expand Down Expand Up @@ -192,7 +198,7 @@ export default function Action({ maxBorrowAmount, healthFactor, collateralType,
return (
<SubmitButton
action={action}
disabled={actionDisabled}
disabled={actionDisabled || isDisabled}
loading={loading}
onClick={handleActionButtonClick}
/>
Expand Down
12 changes: 12 additions & 0 deletions components/Modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,17 @@ const Modal = () => {
const isBtcToken = asset.tokenId === NBTCTokenId && selectedWalletId === "btc-wallet";
const isBtcSupply = action === "Supply" && isBtcToken;
const isBtcWithdraw = action === "Withdraw" && isBtcToken;
if (isBtcWithdraw) {
const min_withdraw_amount = 0.00005;
if (new Decimal(amount || 0).lt(min_withdraw_amount)) {
alerts["btcWithdraw"] = {
title: `You must withdraw at least ${min_withdraw_amount} NBTC`,
severity: "error",
};
} else {
delete alerts.btcWithdraw;
}
}
return (
<MUIModal open={isOpen} onClose={handleClose}>
<Wrapper
Expand Down Expand Up @@ -217,6 +228,7 @@ const Modal = () => {
healthFactor={healthFactor}
collateralType={selectedCollateralType}
poolAsset={assets[tokenId]}
isDisabled={alerts["btcWithdraw"]}
/>
</Box>
</ModalContext.Provider>
Expand Down

0 comments on commit 842a58e

Please sign in to comment.