getPoolApr
The getPoolApr
method retrieves the current Annual Percentage Rate (APR) for the pool. This helps users track the pool's performance over the year. The response includes the APR value if successful, or an error message if the call fails.
Usage
import kohin from "./kohinInstance";
const poolApr = await kohin.getPoolApr();
console.log("Current Pool APR:", poolApr);
Parameters
Parameter | Type | Description |
---|---|---|
address | string | The wallet address whose transaction history is being fetched. |
pageCount | number | Pagination parameter for fetching transaction history (default: 1 ). |
Return Value
Returns a Promise
resolving to an object with the following structure:
{
success: boolean; // Indicates whether the API call was successful
data?: { // Data containing the APR value if successful
apr?: string; // Annual Percentage Rate (APR) of the pool (present if successful)
};
error?: string; // Error message (if the call fails)
}
Error Handling
Handle potential errors gracefully by checking the response or using a try-catch
block:
try {
const poolApr = await kohin.getPoolApr();
if (!poolApr.success) {
console.error("Error:", poolApr.error);
// Display the error message to the user
toastify(poolApr.error, "error");
} else {
console.log("Current Pool APR:", poolApr.data?.apr);
}
} catch (error) {
console.error("Unexpected error:", error.message);
// Display a fallback error message
toastify("Failed to fetch pool APR. Please try again.", "error");
}
Example Response
Success Response:
{
"success": true,
"data": {
"apr": "8.5"
}
}
Error Response:
{
"success": false,
"error": "Unable to fetch Pool APR"
}