-
Notifications
You must be signed in to change notification settings - Fork 4
Description
- Calculate C = A / B - 1. Then D = growFraction * claimFraction / 10000 and E = growFraction * liquidityFraction / 10000
Finally the price that you cannot drop prices below is:
currentPrice * 10000 / (10000 + D or E)
REAL EXAMPLE:
growFraction = 50%
claimFraction = 80%
liquidityFraction = 20%
All-time-high goes up by 90% since last time that someone called claim(). This is what we have:
C = 90% - 50% = 40%
D = 40% * 80% = 32%
E = 40% * 20% = 8%
Now we can drop the price by 4% from current price for addLiquidity(), and by 8% for claim().
The prices you can't go below is (in terms of current price):
claim: currentPrice * 10000 / (10000 + 3200)
liq: currentPrice * 10000 / (10000 + 800)
And another way to put it is (in terms of old all-time-high price)
claim: currentPrice - previousAllTimeHighPrice * 3200 / 10000
liq: currentPrice - previousAllTimeHighPrice * 800 / 10000
Probably the second way is better. When I say "drop by 10%" I mean in terms 10% of the previous all-time-high price. This is an important point because if A = 100 rises by 50% it becomes 150, but then taking 66% leads you back to A = 100. So when I say "rise by 50% and drop by 50%" I mean in terms of the previous price (before applying 50%).
Figure out the availableToClaim() from there.
Adding availableToClaim
Since the all-time-high price can rise multiple times without anyone claiming anything, the availableToClaim should probably be accumulating. So that means, something liike this: for every 50% rise in all-time-high price, enough tokens can be minted to liquidity and claim, to drop the price by 10% and 20% respectively (in terms of the previous all-time-high price, not current price). This should be able to accumulate. And eventually people can add that much liquidity and claim that many tokens, even if the price has dropped again below the all-time high.
So for example, if the price goes:
100 -> 190 // it rose by 40% more than growFraction, so now we can drop the price by 40%: 32% to availableToClaim and 8% to liquidiy
190-> 140 // it dropped back down, the availableToClaim remains the same
140 -> 285 // now it exceeded all time high of 190 by exactly 50%, so there is no additional availableToClaim yet, but about to be
285 -> 300 // now you see it rose above previous all-time-high of 190, by 57%. So 80% of 7% is added to availableToClaim, and 20% of 7% is added to availableToLiquidity.
300 -> 500 // even more is added to availableToClaim and availableToLiquidity.
500 -> 300 // the accumulated amounts are still available, until used up
that's how it should work