Compounding / Staking - best moment for max. returns

MartinRW

New member
Joined
Oct 7, 2020
Messages
6
Hi all,

I'm for days now trying to figure this out and I can't get it to work completely. Hopefully somebody here is bright enough to help me out on this matter as it really fascinates me and I can't get my head around it for now.
It's based on yield farming; which became recently very popular in the crypto space

In short; there is an investment that returns interest in specific ways. Adding the interest received to the investment however comes with a certain cost. I want to find out what is the best moment to take the interest and add it to the investment to generate higher gains from interest.

So the case is the following:

I invest 1000 token A in pot 1
Each token A has a value of $0,50

In return I receive a nice interest in tokens; 0,117% per HOUR
The money in pot 1 stays $1000 and the received interest goes to a different pot (2) that does not generate interest.

So after 1 hour:
Pot 1: 1000 token A
Pot 2: 1,17 token A

After 2 hours:
Pot 1: 1000 token A
Pot 2: 2,34 token A
etc.

So to be smart will be to add the tokens A from pot 2 as quick as possible all the time to pot A; so they start generating interest as well.
However; taking out the interest received from pot 2 and adding it to pot 1 costs $0,20

So far the "restaking process is pretty straigthforward; with my limited math knowledge I can work out the results for staking every X hours and deducting it to a sweet spot.

But now the fun part starts (where I get lost and your magic minds come into play):

The amount invested in POT 1 comes with an equal (free) amount of token B in a pot 3
Token B has a value of 0 itself, but generates another Token C in pot 4
This works like interest; every hour 0,22% of the amount in pot 3 --> 0,22% Token C in pot 4
Token C has a value of $0,08 or 0,15 token A.
Adding more token token A to pot 3 costs $0,10


So let me make this visible again

At T0
Pot 1: 1000 token A
Pot 2: 0 token A

Pot 3: 1000 token B
Pot 4: 0 token C

After 1 hour:
Pot 1: 1000 token A
Pot 2: 1,17 token A and 1,17 token B

Pot 3: 1000 token B
Pot 4: 2,2 token C


Especially his last part makes me completely confused:
How can I find out after how many hours I should restake token A in pot 1 and token B in pot 3 to get the most gains?
And should I sell token C to add more token A to improve these gains?

Really hope somebody can help here.
I can understand if it's not completely clear; i find it pretty hard to explain actually but really tried the best i could.
If any questions please let me know.
 
I don't need a completely ready solution by the way (would be nice, but def. not necessary)
Would already be very happy with some views about how to approach this.
 
Nobody responded yet, but I am still trying to figure it out myself as well.
Already starting over completely from scratch for the fifth time.

Maybe good if I make a start here myself in how I approach this,
Its just for the first (easier) part of the calculation.
Once we have that maybe we can play around with the more complex part.


What I do first is to write out the basic info:

Token A start amount
1000​
Token A gained per hour
1,171458​
Token A gained per day
28,115​
Percent made per day
2,8115​
Percent made per hour
0,117146​
$ Price Token A
0,5​
$ Gains per day
14,0575​
$ Price restake
0,25​
Restake cost counted in Token A
0,017784​


Then I make a sheet with on:
Vertical axis: the amount of hours after which I add/compound the interest received on Token A from pot 2 to pot1 (So the interest gained will start to gain interest)
Horizontal axis: The amount of times compounded after X hours.


Compound after hoursT0
1​
2​
3​
4​
1
1000​
1000,7​
1001,3​
1002,0​
1002,7​
2
1000​
1001,8​
1003,7​
1005,5​
1007,4​
4
1000​
1004,2​
1008,4​
1012,6​
1016,9​
8
1000​
1008,9​
1017,8​
1026,9​
1036,0​
16
1000​
1018,2​
1036,8​
1055,8​
1075,1
32
1000​
1037,0​
1075,4
1115,2​
1156,5​
64
1000​
1074,5
1154,5​
1240,6​
1333,1​


The formula for this starts under T1 and looks like this:

Result = StartA + ( CompHours* PercGainHour * StartA ) - RestCostA

Where:
StartA = Token A Start Amount (1000)
CompHours = the value on vertical axis
PercGainHour = percent made per hour divded by 100 (0,00117146)
RestCostA = Restake Cost counted in Token A


Ofcourse the excel sheet is way bigger; but from this i can already see that the optimum frequency should be somewhere between 16 and 64 hours.
As the sheet shows that as a result after 64 hours:
4 x Restaking every 16 hours gives --> 1075,1 Token A (gained 75,1)
2 x Restaking every 32 hours gives --> 1075,4 Token A (gained 75,4)
1 x Restaking every 64 hours gives --> 1074,5 Token A (gained 74,5)


Can somebody tell me if this first part is correct? Should I change something? Or is there a completely different / better way to approach this?
For now I am just trying to figure it out just by trying and trying and trying... :)
 
Last edited:
Please note:
I have created a different thread about something similar; but a lot more complicated with some extra variables.
Because nobody responds there I am creating a second thread just to try to understand at least the core, most basic part, of the problem.



Situation
Investment of X dollars receives Y% interest per hour (this interest is NOT automatically added to the investment)

There is a price to pay for every time you add the received interest to the investment.


The basic question I have is:
Is it possible, and if yes; how can you calculate/find the optimum frequency (in hours) to compound the interest received to the investment to maximize gains?
 
Situation
Investment of X dollars receives Y% interest per hour (this interest is NOT automatically added to the investment)

There is a price to pay for every time you add the received interest to the investment.


The basic question I have is:
Is it possible, and if yes; how can you calculate/find the optimum frequency (in hours) to compound the interest received to the investment to maximize gains?

Here's a screenshot of typing "compound interest formula" into Google...

interest.png

Please check the following:-

If the interest rate is 0.1% per hour, and you intend investing the money for 100 hours then t=100 and r=0.001. If you want interest applied every x hours, then n=1/x. Let this be eqation2.

...in your scenario you also need to subtract (from A) the charge for applying the interest. If charge is "c" then the total amount to subtract will be n*c*t. Can you write this out, but switch to using "x" instead of "n" using equation2?

To find the maximum, you'll need to differentiate that expression with respect to "x" to see where the turning point is. Is this something that you are familiar with and could attempt yourself?
 
Thank you so much for your reply.
You don't know how much i appreciate somebody is willing to point me in the good direction here.

So if I read all correct, the formula should look like this for my case:

thumbnail_IMG_3510.jpg



I have created the formula for re-investing during a period of 40 hours; every 4 hours at a cost of $ 0,25 per re-invest. Start amount 1000 and interest 0,1% per hour.

So then
P = 1000
r = 0,001
n = 1
t = 40
x = 4
c = 0,25

thumbnail_IMG_3512.jpg


The outcome for this fomula is 1000,7277340

But I can already see that the last part is not correct:
If the total time is 40 hours, re-investing is done every 4 hours and every re-invest costs 0,25 then shouldn't the last part be:
c*(t/x)
instead of x*c*t?


Am I heading the correct way?


edit: I can already see that the last part should be integrated in the formula --> the cost for reinvesting should not be done at "once" in the end. Not sure how to integrate that in a correct way.
 
Last edited:
You're welcome for the reply. I don't guarantee that you'll find a nice answer, but I do find your question interesting so I'll engage in a conversation with you. Hopefully we can make some progress - but this is a "real world" problem (unlike a homework question which will usually have a nice answer at the end).

In your above post, if x=4, then n=1/4 but you wrote n=1. Also r/(1/x) = r*x. And yes, the last part ought to be c*t/x.

BUT- in post#5 I assumed the "interest charge" is paid in a lump sum at the end of the investment period. Like this...

Scenario A
TimeAmount in account
01000
4 hours1000 * (1 + 4*0.001) = 1004
8 hours1004 * (1 + 4*0.001) = 1008.016
12 hours1008.016 * (1 + 4*0.001) - 3*0.25 = 1011.298064
...interest charge applied at the end (shown in bold). Using the formula above 1000*(1 + 4*0.001)^(12/4) - 0.25*12/4 = 1011.298064

OR would the charge be subtracted piecewise at the same time that interest is paid? Like this (see bold figures)...

Scenario B
TimeAmount in account
01000
4 hours1000 * (1 + 4*0.001) - 0.25 = 1003.75
8 hours1003.75 * (1 + 4*0.001) - 0.25 = 1007.515
12 hours1007.515 * (1 + 4*0.001) - 0.25 =1011.29506

There's a small difference in the end amount of these two scenarios. Under some circumstances this difference may be bigger. So which scenario do you have? EDIT: This is probably what you meant by "the cost for reinvesting should not be done at once in the end".

(Also, how is the amount in the account rounded? 2 decimal places?)
 
Last edited:
Thank you so much again.
I love this kind of stuff; even though my mathematical knowledge is limited an dusty

In your above post, if x=4, then n=1/4 but you wrote n=1. Also r/(1/x) = r*x. And yes, the last part ought to be c*t/x.
Yes, you are right. Should have been n there instead of 1.

Scenario B is the correct one.
and the amount is rounded in 18 decimal places (very common in crypto)

I had already verified the formula in pretty much exactly the same way as you did.
And it's working perfect, apart from the deduction of 0,25 for everytime the interest is added to the investment

It literally kept me awake last night; I just don't see how to fit that 0,25 cost per x in the formula.
My guess is that something needs to happen with P - probably need to calculate a new, sort of average value for P that integrates the average growth generated by the rest of the formula.

What I mean with that is that for every x (4 hours) 0,25 needs to be deducted from P
After 4 hours that 0,25 is 0,024900398 % of 1004
After 8 hours that 0,25 is 0,024801194 % of 1008,016
So the amount of 0,25 is becoming a lower percentage of P over time.

Maybe I am totally confusing things now; but my guess is it should be somewhere in that direction...
Can be completely wrong though :geek:?
 
Last edited:
I know how we can obatin the final amount in scenario B. We can write the amount in the account as a "Recurrence relation"...

f(0) = p
f(1) = f(0)*a - c
f(2) = f(1)*a - c
...
f(y) = f(y-1)*a - c

where a = (1+r*x)

I put this into WolframAlpha (click) to obtain the solution:-

f(y) = (c - a^y*( c + p - a*p))/(a - 1)

The final amount is f(t/x), so can you substitute y=t/x and a=(1+r*x) into the above and perhaps simplify a bit?
 
Top