calc

by jarosciak

HTML

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Fee Calculator</title>
     
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/web3.min.js"></script>
  </head>
  <body>
  
<button id="connect-wallet-button">Connect Ethereum Wallet</button>
  
    <label>How many batches do you want to burn:</label>
    <input type="number" id="batch-input" value="10"><br>
    <label>Cycle Total Batches Already Burned This Cycle:</label>
    <input type="number" id="cycle-total-batches-burned-input" value="10"><br>
    <label>Gas Price (Gwei):</label>
    <input type="number" id="gas-price-input" value="30"><br>
    <label>Gas Limit:</label>
    <input type="number" id="gas-limit-input" value="130000"><br>
    <button onclick="calculate()">Calculate</button><br>
    <label>Total transaction cost:</label>
    <span id="total-transaction-cost-output"></span><br>
    <label>Total XEN burned:</label>
    <span id="total-xen-burned-output"></span><br>
    <label>Batches in uint256:</label>
    <span id="batches-in-uint256-output"></span><br>
    <label>Fee:</label>
    <span id="fee-output"></span><br>
    <hr>
    
      <div class="container">
    <b>Ethereum Gas Price</b><br>Enter your API key:<br>
    <input type="text" id="apiKeyInput" placeholder="API key" value="">
    <button id="submitBtn">Submit</button>
    <div class="gas-prices">
      Fast Price: <span id="fastGasPrice">Loading...</span><br>
      Safe Price: <span id="safeGasPrice">Loading...</span><br>
      Proposed Price: <span id="proposeGasPrice">Loading...</span>
    </div>
  </div>
    <script>
      const calcFees = (batch, cycleTotalBatchesBurned, gasPrice, gasLimit) => {
        const protocolFee = batch * (1 - 0.00005 * batch);
        const effectiveGasLimit = gasLimit ?? (cycleTotalBatchesBurned > 0 ? 300000 : 350000);
        const fee = (effectiveGasLimit * gasPrice * protocolFee) / 1e18;
        const...