Checking Minimum Liquidity Requirement (MLR) Before Buying Cover
The checkMLRBeforeBuyCover method validates the liquidity requirements and the MLR ratio before allowing the user to buy cover for a specific bet amount. It ensures that sufficient liquidity is available on the platform to fulfill the request.
Although with buyCover method we are already checking mlr before proceeding, but you can also use this method for conditional checks as you choice.
Usage
const mlrValidation = await kohin.checkMLRBeforeBuyCover({ betAmount: 500 });
if (mlrValidation.success) {
  console.log("MLR validation passed. Cover can be purchased.");
} else {
  console.error("Error:", mlrValidation.error);
}
Parameters
The CalculatePremiumParams interface defines the input parameters for the method:
export interface CalculatePremiumParams {
  betId: number; // Unique identifier for the bet
  betType: BetTypes; // Type of the bet: "Combo" or "Single"
  odds: number; // The odds associated with the bet
  betAmount: number; // Amount of money placed on the bet
  numLegs: number; // Number of legs (events) in the bet
}
Return Value
The checkMLRBeforeBuyCover method returns an object with the following structure:
{
  success: boolean;   // Indicates if the operation was successful
  error?: string;     // Error message if the operation failed
}
Error Handling
Here's how you can handle errors while validating MLR:
try {
  const mlrCheck = await kohin.checkMLRBeforeBuyCover({ betAmount: 500 });
  if (mlrCheck.success) {
    console.log("MLR validation passed. Cover can be purchased.");
  } else {
    console.error("Validation failed:", mlrCheck.error);
  }
} catch (error: any) {
  console.error("Unexpected error while validating MLR:", error);
}
Example Response
Success Response:
{
  "success": "true"
}
Error Response:
- Insufficient Liquidity:
 
{
  "success": false,
  "error": "There is insufficient liquidity to insure the bet amount on platform. Please try later."
}
- Platform Liquidity Not Sufficient:
 
{
  "success": false,
  "error": "The platform's available liquidity is not sufficient to buy this cover. Please check back later or contact our support team on Discord for assistance."
}
- Unable to Fetch Data:
 
{
  "success": false,
  "error": "Unable to fetch required info to move further. Please try again!"
}