Last active
March 20, 2021 18:47
-
-
Save roguealexander/191b3a376baf3c44a32476ba7ae3d636 to your computer and use it in GitHub Desktop.
Stakenet Masternode Value Calculations
This file contains 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
Data - // stored as reactive variables. If converting to react the data would exist in the state | |
Computed Properties - // when Data changes, these update automatically. If converting to react these would be in the component body and update each rerender | |
// In computed properties, this._______ refers to the variable in data (state in react), can also be referred to as variables | |
// ex: (computed property) xsnPrice: function() { ... }, can be referred to in another computed property as this.xsnPrice | |
Helper Functions: | |
toFinString: function (x, fixed = 2) { | |
if (x < 1000000) { | |
return x.toFixed(fixed).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); | |
} else if (x < 1000000000) { | |
return (x / 1000000).toFixed(fixed).toString() + 'M' | |
} else { | |
return (x / 1000000000).toFixed(fixed).toString() + 'B' | |
} | |
}, | |
example: | |
currentXsnPriceString: function() { | |
return this.toFinString(this.currentXsnPrice, 3) | |
} // $0.494 | |
// XSN PRICE // | |
Data: | |
xsnPriceLog: 23 // Log Slider Value, 0 - 100 | |
Computed Property: | |
xsnPrice: function() { | |
if (this.xsnPriceLog == 100) return 1000 | |
if (this.xsnPriceLog > 98) return 500 | |
return Math.round(Math.exp(Math.log(1) + ((Math.log(500) - Math.log(1)) / 100) * this.xsnPriceLog)) | |
} | |
// TRADING VOLUME // | |
Data: | |
tradingVolumeLog: 30 // Log Slider Value, 0 - 100 | |
Computed Property: | |
tradingVolume: function() { | |
const val = Math.round(this.tradingVolumeLog < 50 ? (this.tradingVolumeLog * 20) / 2 : (((this.tradingVolumeLog - 50) * 100 * 3.9) + 500)) | |
return val > 1000 ? Math.round(val / 500) * 500 : val | |
} | |
// MASTERNODES OWNED // | |
Data: | |
ownedNodesLog: 2 // Log Slider Value, 0 - 100 | |
Computed Property: | |
ownedNodes: function() { | |
return Math.round(this.ownedNodesLog < 50 ? this.ownedNodesLog / 2 : (((this.ownedNodesLog - 50) * 1.5) + 25)) | |
} | |
// MASTERNODE COUNT // | |
Data: | |
masternodeCount: 2700 // Raw Value used in slider | |
// DAY MONTH YEAR // | |
Data: | |
dayMonthYear: "month" // Should be enum of Day, Month, Year, but mn calculator not in TS so couldn't do enum. | |
// ORDERBOOK HOSTING ENABLED // | |
Data: | |
orderbookHostingEnabled: true // Used to calculate orderbook rewards, included in total rewards calculation | |
// ORDERBOOK MASTERNODE COUNT // | |
Data: | |
orderbookMNs: 1500 // Raw slider value, Currently separate from normal masternode slider but could probably be combined if desired | |
// OUTPUT COMPUTED PROPERTIES (all computed properties) // | |
dayMonthYearMultiplier: function() { | |
return (this.dayMonthYear === 'day' ? 1 : this.dayMonthYear === 'month' ? 30 : 365) | |
}, | |
blockRewards: function () { | |
return (this.ownedNodes / this.masternodeCount) * (1440 * 9) * this.xsnPrice * this.dayMonthYearMultiplier | |
}, | |
blockRewardsString: function () { | |
return this.toFinString(this.blockRewards) | |
}, | |
orderbookRewards: function() { | |
return Math.max(0.225, (0.45 - (0.000225 * this.tradingVolume))) * (this.tradingVolume * 0.0025 * 1000000) * (this.ownedNodes / this.orderbookMNs) * this.dayMonthYearMultiplier | |
}, | |
orderbookRewardsString: function() { | |
return this.toFinString(this.orderbookRewards); | |
}, | |
mnHostingCost: function() { | |
return this.ownedNodes * (this.orderbookHostingEnabled ? 2.5 : 0.15) * this.dayMonthYearMultiplier | |
}, | |
mnHostingCostString: function() { | |
return this.toFinString(this.mnHostingCost); | |
}, | |
mnCollateralValue: function () { | |
return this.xsnPrice * this.ownedNodes * 15000 | |
}, | |
mnCollateralValueString: function () { | |
return this.toFinString(this.mnCollateralValue) | |
}, | |
totalRewards: function() { | |
return this.blockRewards + (this.orderbookHostingEnabled ? this.orderbookRewards : 0) - this.mnHostingCost | |
}, | |
totalRewardsString: function() { | |
return this.toFinString(this.totalRewards) | |
}, | |
roi: function() { | |
return ((((this.mnCollateralValue + this.totalRewards) / this.mnCollateralValue) - 1) * 100).toFixed(2) | |
}, | |
daysUntilFreeMasternode: function() { | |
return ((15000 * this.xsnPrice) / (this.totalRewards / this.dayMonthYearMultiplier)).toFixed(1) + ' days' | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment