Hi
To calculate the amount for a distribute loss or greenup, you need to know the exit price, or predicted exit price.
for a back bet the exit price is the lay_price, and to calculate the amount:
(bm_backp*bm_backa)/lay_price
for a lay bet the exit price is the back_price, and to calculate the amount:
(bm_laya*bm_layp)/back_price