fpbrault / stellar-aqua-amm-viewer

https://amm.stellar.beign.es/
MIT License
1 stars 0 forks source link

"Daily Reward" Calculations are Incorrect #8

Open AnthonyJPerez opened 2 years ago

AnthonyJPerez commented 2 years ago

The current formula used for the Daily Reward calculation assumes that the total number of shares of a pool are fixed, when in fact the number of shares would grow by the amount being "estimated" to be put into the pool to gain rewards. This has the effect of inflating the rewards, drastically so for pools with low Pool Values.

Example:

PAIR⬍ VOTE %⬍ REWARD PER $⬍ REWARD PER $ (DAY)⬍ TOTAL VALUE INVESTED⬍ REWARD PER HOUR⬍ HOURLY REWARD⬍ DAILY REWARD⬍ TOTAL SHARES⬍ POOL VALUE⬍ DAILY AMM REWARD⬍
AQUA/KELP 5.0% 0.11458 AQUA 2.75 AQUA 10000  1145.81 AQUA 12.79$ 307.06$ 457036 $53456 147000 AQUA

You can see here that when inputting $10,000 into the AQUA/KELP pool (with 1 AQUA == $0.01128374), it currently renders $311.82 as the estimated daily rewards, based on the current formula:

const delta = value - row.values.totalValueInvested;
//const newPoolValue = delta + row.values.poolValue;
const rewardPerHour = ((value / (delta + row.values.poolValue)) * row.values.dailyReward) / 24;
updateMyData(index, "totalValueInvested", value);
updateMyData(index, "rewardPerHour", rewardPerHour);
updateMyData(index, "rewardPerHourUSD", value * row.values.rewardPerDollar);
updateMyData(index, "rewardPerDayUSD", value * row.values.rewardPerDollar * 24);

However.. in this example inserting $10,000 into this pool would represent a near 20% increase in the number of LP shares. The daily reward should be $261.03 after depositing $10,000 into this pool. This calculation would be to take into account the new pool value (replacing 'delta' with 'value':

const rewardPerHour = ((value / (value + row.values.poolValue)) * row.values.dailyReward) / 24;
fpbrault commented 2 years ago

Thanks! I already am aware of this, and I actually need to fix #4 first.