def calculate_diff(user, ledgers, split_pool):
    """ Calculate profit/loss for given user and ledgers """

    win_amount = ledgers['winLedger'].get(user, 0)
    deposited_bets = ledgers['depositedBets'].get(user, 0)
    split_liquidity = ledgers['splitLedger'].get(user, 0)
    share = ledgers['liquidityShares'].get(user, 0)
    total_shares = sum(ledgers['liquidityShares'].values())

    bets_diff = win_amount - deposited_bets

    split_share = (0 if total_shares == 0 else
        split_pool * share / total_shares)

    liquidity_diff = split_share - split_liquidity

    return int(bets_diff + liquidity_diff)