Created
April 26, 2021 02:38
-
-
Save serweb-labs/f82ea3f38217368df2b9b55afdee0a4d to your computer and use it in GitHub Desktop.
token stake compund optimizator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cci(principal, rate, frequency, years) { | |
return principal * Math.pow(1 + rate / frequency, frequency * years); | |
} | |
var capital = 550; | |
var tokenRate = 1.185; | |
var apr = 2.15; | |
var compoundFee = 0.45; | |
var i = 0; | |
var gain = 0; | |
var nextGain = 0; | |
while (nextGain >= gain) { | |
gain = nextGain; | |
i++; | |
var conv = cci((capital * tokenRate), apr, i, 1); | |
nextGain = conv - (i * compoundFee); | |
} | |
var optimalByYear = i - 1; | |
var optimalHours = (365 / optimalByYear) * 24; | |
var realGain = gain - capital; | |
console.log( | |
'optimal by year', optimalByYear, | |
'optimal by hours', optimalHours, | |
'total', gain, | |
'real gain', realGain | |
); | |
var c = optimalByYear - 1; | |
var t = cci((capital * tokenRate), apr, c, 1) - (c * compoundFee); | |
console.log('control - 1', c, t); | |
c = optimalByYear + 1; | |
var t = cci((capital * tokenRate), apr, c, 1) - (c * compoundFee); | |
console.log('control + 1', c, t); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment