For calculating the swap APR we are going to calculate the USD amount of fees in the previous 24hours and annualize it.
We first need to get the TVL in USD
Reserve TVL in USD
Same for the total reserve, we can get the amount of each reserve in the pool and then multiplying for each token USD price. The sum of those is the total reserve value in USD terms.
Now that we have the TVL we get the fees in the last 24 hours for each token in USD terms and pick the minimum, then we subtract any protocol fee and lastly we annualize the 24hours fee in USD.