FENIX Reward Calculator
by jarosciak
HTML
<!DOCTYPE html>
<html>
<head>
<title>FENIX Token Calculator</title>
</head>
<body>
<h1>FENIX Token Calculator</h1>
<form>
<label for="stakeSize">Stake Size:</label>
<input type="text" id="stakeSize" name="stakeSize"><br>
<label for="stakeTerm">Stake Term (days):</label>
<input type="text" id="stakeTerm" name="stakeTerm"><br>
<label for="xenBurn">XEN Burn Amount:</label>
<input type="text" id="xenBurn" name="xenBurn"><br>
<button type="button" onclick="calculateReward()">Calculate Reward</button>
</form>
<br>
<p id="reward"></p>
<script>
// Constants defined in the contract
const ANNUAL_INFLATION_RATE = 3.141592653589793238;
const SIZE_BONUS_RATE = 0.1;
const TIME_BONUS_RATE = 0.2;
const ONE_EIGHTY_DAYS = 180;
const ONE_YEAR_DAYS = 365;
const TIME_BONUS = 1820;
const XEN_RATIO = 10000;
function calculateReward() {
// Get the stake size, term and xen burn amount from the form
const stakeSize = document.getElementById("stakeSize").value;
const stakeTerm = document.getElementById("stakeTerm").value;
const xenBurn = document.getElementById("xenBurn").value;
// Do some basic validation
if (stakeSize <= 0) {
alert("Invalid stake size");
return;
}
if (stakeTerm <= 0) {
alert("Invalid stake term");
return;
}
if (xenBurn <= 0) {
alert("Invalid XEN burn amount");
return;
}
// Calculate the base reward
let reward = stakeSize * ANNUAL_INFLATION_RATE;
// Calculate the size bonus
reward += stakeSize * SIZE_BONUS_RATE;
// Calculate the time bonus
if (stakeTerm >= ONE_EIGHTY_DAYS) {
reward += stakeSize * TIME_BONUS_RATE;
}
// Calculate the Xen bonus
reward += xenBurn * TIME_BONUS / XEN_RATIO;
// Display...