proposal-39-one-year-reimbu.../scripts/calculateReimbursement.ts

18 lines
686 B
TypeScript

import fs from "fs";
import path from "path";
import fetch from "node-fetch";
const rpcMonthlyPrice = 1000;
const servicesMonthlyPrice = 600;
const amountInUsd = (rpcMonthlyPrice + servicesMonthlyPrice) * 12;
const binanceApiLink = "https://api.binance.com/api/v3/ticker?symbol=TORNBUSD&windowSize=7d";
const res = await fetch(binanceApiLink);
const { weightedAvgPrice } = (await res.json()) as { weightedAvgPrice: string };
const amountInTorn = Math.floor((amountInUsd + (amountInUsd * 20) / 100) / Number(weightedAvgPrice));
fs.writeFileSync(path.join(".", "data", "amountInTorn.txt"), `uint256 public constant reimbursementAmount = ${amountInTorn} ether;`, {
flag: "w+",
});