Skip to main content

Fetching Early Withdrawal Fee

The earlyWithdrawalFee method fetches the fee associated with early withdrawal from the pool, if applicable.

Usage

import kohin from "./kohinInstance";

const earlyWithdrawalFee = await kohin.earlyWithdrawalFee();

if (earlyWithdrawalFee.success) {
console.log("Early Withdrawal Fee:", earlyWithdrawalFee.earlyWithdrawalFee);
} else {
console.error(
"Error fetching early withdrawal fee:",
earlyWithdrawalFee.error
);
}

Return Value

The earlyWithdrawalFee method returns an object with the following structure:

{
success: boolean; // Indicates if the operation was successful
error?: string; // Error message if the operation failed
earlyWithdrawalFee?: number; // The early withdrawal fee value
}

Error Handling

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

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

if (res.success) {
console.log("Early Withdrawal Fee:", res.earlyWithdrawalFee);
} else {
console.error("Error fetching early withdrawal fee:", res.error);
}
} catch (error: any) {
console.error("Unexpected error while fetching early withdrawal fee:", error);
}

Example Response

Success Response:

{
"success": true,
"earlyWithdrawalFee": 2
}

Error Response:

{
"success": false,
"error": "Unable to fetch early withdrawal fee."
}