21 lines
883 B
TypeScript
21 lines
883 B
TypeScript
import fs from "fs";
|
|
import path from "path";
|
|
import fetch from "node-fetch";
|
|
|
|
import { DeclCalculator } from "./utils.ts";
|
|
|
|
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 remunerationAmount = 30_000;
|
|
const reimbursementAmount = 6_000;
|
|
const bountyThaxAmount = 2_000;
|
|
|
|
const calculateAmountInTorn = (amountInUsd: number) => Math.floor(amountInUsd / Number(weightedAvgPrice)).toString() + " ether";
|
|
|
|
const { calculateDecl } = new DeclCalculator("uint256", undefined, calculateAmountInTorn);
|
|
const solidityCode = calculateDecl({ remunerationAmount }) + calculateDecl({ reimbursementAmount }) + calculateDecl({ bountyThaxAmount });
|
|
|
|
fs.writeFileSync(path.join(".", "data", "amountsInTORN.txt"), solidityCode);
|