When you attack a planet, the most resources you can plunder is 60% (40% base resource protection) in one hit. So if the planet has: 1,000,000 metal 500,000 crystal 250,000 gasYou can only plunder a maximum of: 600,000 metal 300,000 crystal 150,000 gas

In the next attack wave, since the planet will now have: 400,000 metal 200,000 crystal 100,000 gasYou can only plunder a maximum of: 240,000 metal 120,000 crystal 90,000 gas

When a planet has an underground bunker, the amount of resources you can plunder is:

There is a maximum of lvl15 Underground bunker. With no underground bunker an attack can take up to 60%. With a lvl1 bunker, an attack can take up to 59%. With a maxed out bunker, an attack can only take 45% of a planets resources in a single hit.

There is an exception to a player having the base resource protection of 40%. When the defending player has a Pirate Badge (skull) from negative glory, they lose a certain amount of the base resource protection.

The Underground bunker protection still works for players with the Pirate Badge, simply alter the above formula based on the Pirate Badge base resource protection.

In all, farming hits vs any planet will require multiple waves to clear all the resources. However, if done efficiently, very rarely will a single planet require more than 6 waves to clean off all the resources.