You can calculate the optimal lay stake in four steps:
Calculate the back stake.
Determine the back odds and lay odds.
Compute the bookmaker commission and exchange commission.
Apply this formula:
optimal lay stake = ((back odds – bookmaker commission) / (lay odds – exchange commission)) × back stake