Skip to main content

Fetching Maximum Deposit

The getMaxDeposit method retrieves the maximum deposit amount allowed for a given contract or pool. This helps users know the upper limit for their deposit.

Usage

import kohin from "./kohinInstance";

const maxDeposit = await kohin.getMaxDeposit();

if (maxDeposit.success) {
console.log("Maximum Deposit:", maxDeposit.maxDeposit);
} else {
console.error("Error fetching maximum deposit:", maxDeposit.error);
}

Return Value

The getMaxDeposit method returns an object with the following structure:

{
success: boolean; // Indicates if the operation was successful
error?: string; // Error message if the operation failed
maxDeposit?: number; // The maximum deposit value
}

Error Handling

Here's how you can handle errors while fetching the maximum deposit:

try {
const res = await kohin.getMaxDeposit();

if (res.success) {
console.log("Maximum Deposit:", res.maxDeposit);
} else {
console.error("Error fetching maximum deposit:", res.error);
}
} catch (error: any) {
console.error("Unexpected error while fetching maximum deposit:", error);
}

Example Response

Success Response:

{
"success": true,
"maxDeposit": 10000
}

Error Response:

{
"success": false,
"error": "Unable to fetch maximum deposit."
}