diff --git a/src/components/RepayInput/index.tsx b/src/components/RepayInput/index.tsx
index 6c759b8..190b449 100644
--- a/src/components/RepayInput/index.tsx
+++ b/src/components/RepayInput/index.tsx
@@ -38,6 +38,9 @@ export const RepayInput = (props: {
const obligation = props.obligation;
const liquidityMint = useMint(repayReserve.info.liquidityMint);
+ const { balance: tokenBalance } = useUserBalance(
+ repayReserve.info.liquidityMint
+ );
const borrowAmountLamports = wadToLamports(
obligation.info.borrowAmountWad
@@ -53,14 +56,15 @@ export const RepayInput = (props: {
const convert = useCallback(
(val: string | number) => {
+ const minAmount = Math.min(tokenBalance || Infinity, borrowAmount);
setLastTyped("repay");
if (typeof val === "string") {
- return (parseFloat(val) / borrowAmount) * 100;
+ return (parseFloat(val) / minAmount) * 100;
} else {
- return (val * borrowAmount) / 100;
+ return (val * minAmount) / 100;
}
},
- [borrowAmount]
+ [borrowAmount, tokenBalance]
);
const { value, setValue, pct, setPct, type } = useSliderInput(convert);
@@ -211,7 +215,7 @@ export const RepayInput = (props: {
setLastTyped("repay");
}}
disabled={true}
- hideBalance={true}
+ useWalletBalance={true}
/>
@@ -221,7 +225,7 @@ export const RepayInput = (props: {
flexDirection: "row",
justifyContent: "space-evenly",
alignItems: "center",
- marginBottom: 20
+ marginBottom: 20,
}}
>
,
parser?: AccountParser
) => {
- if(obj.data.length === 0) {
+ if (obj.data.length === 0) {
return;
}
diff --git a/src/models/account.ts b/src/models/account.ts
index c9fa53d..022a077 100644
--- a/src/models/account.ts
+++ b/src/models/account.ts
@@ -39,7 +39,7 @@ export function approve(
)
);
- if(autoRevoke) {
+ if (autoRevoke) {
cleanupInstructions.push(
Token.createRevokeInstruction(tokenProgram, account, owner, [])
);
diff --git a/src/views/borrow/index.tsx b/src/views/borrow/index.tsx
index e3f13a8..339fe7a 100644
--- a/src/views/borrow/index.tsx
+++ b/src/views/borrow/index.tsx
@@ -18,7 +18,11 @@ export const BorrowView = () => {
{reserveAccounts.map((account) => (
-