A quick way to calculate the main pot is the smallest all in amount multiple by the number of players who covered that bet amount. Plus any forfeited amounts by maybe a user in the blind that folded before the flop. To cactuate the each side pot is the difference between the next highest bet amount and the previous bet amount multiplied by the number of players who covered that bet.
Here is an simple example to help consider 3 players at the table.
Player A says has 300, player B has 400, and player C has 500.
There is a total of 1200 chips in play between the three players before the hand starts. And lets say all three players end up all in.
Blinds are 50/100 and player A is in small blind for 50, player B is in big blind for 100. Player C is first to act and goes all in for 500. Player A calls 250 more and is all in for 300. Player B calls 300 more all in for 400.
All pots 1200
Main = 900 (smallest bet 300 x 3 players) between players A, B, and C
Side pot 1 = 200 (second smallest 400 - smallest 300 = 100 x 2 players) between players B and C only
Side pot 2 = 100 (third smallest 500 - second smallest 400 = 100 x 1 player) returned to player C
The pots should be evaluated for winners in reverse order from side pot 2, to side pot 1, to the main pot.