title_body: How is a stakepool rewarded?
upvoted_answer: Let's assume your pool has the below configuration,
  
  Cost - 340 ADA
  Margin - 1%
  Pledge - 5000 ADA
  Delegation from all delegators - 5000 ADA
  
  We will not discuss the reward calculation timing in this question, as it is a topic for another question.
  When reward calculation happens, pool performance is calculated. Which in simple terms is how much total stake the pool controls across all pools ie. this pool controls (X+Y) note - pledge + delegation and the number of blocks it should ideally mint based on the stake it controls. Based on the performance, a pool is set to receive some ADA, for this pool let's keep that ADA to be 1000 for 1 block minted.
  Now we have,
  Total Rewards for the pool and delegators - 1000 ADA
  Next, the protocol will calculate pool fees. Pool fees are the fixed cost + margin.
  In this case, pool fees are as below
  fixed cost + ((reward-cost)*0.01)
  340 + 6.6 ADA
  Now we have pool fees = 346.6 ADA
  remaining rewards for the delegators = 1000 - 346.6 = 653.4
  Next, the protocol will calculate rewards for the delegators from the remaining ADA, which is a straightforward process, each delegator gets rewards as per the share of their stake.
  Considering there are 3 delegators including the owner's pledge
  
  owner pledge - 5000 ADA (50%)
  delegator 1 - 2500 ADA (25%)
  delegator 2 - 2500 ADA (25%)
  
  The reward distribution is as below,
  Available Rewards to be distributed = 653.4 (note remaining after pool fees)
  
  owners stake rewards - 326.7 ADA
  delegator 1's rewards - 163.35
  delegator 2's rewards - 163.35
  
  Now, NOTE that the owner's stake rewards + pool fees are paid to the reward account itself. The owners don't get the stake rewards into their own accounts.
  so the pool reward account will get = 326.7 (pledge staking reward) + 346.6 (pool fees) = 673.3
  The delegator rewards are paid to the respective staking addresses.
  Important to note, if the pool fee is 100%, which means all of the rewards are taken by the pool and nothing is left for the delegators.
  here's an example of a pool running at 100% fees that it produces 0 rewards for the delegators. PRIVATE POOL