flashloan-profit-calculator
Version:
A library for analyzing flashloan transactions and calculating profits
26 lines (25 loc) • 1.05 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const client_sdk_1 = require("@duneanalytics/client-sdk");
const index_1 = require("./index");
const dotenv_1 = __importDefault(require("dotenv"));
dotenv_1.default.config();
const { DUNE_API_KEY } = process.env;
const client = new client_sdk_1.DuneClient(DUNE_API_KEY ?? "");
const queryID = 5196999;
client.runQuery({ queryId: queryID }).then(async (executionResult) => {
const rows = executionResult.result?.rows;
for (const row of rows ?? []) {
const txHash = row.tx_hash;
console.log(`Loan amount: ${row.amount_usd}`);
await (0, index_1.calculateProfitFromTxHash)(txHash)
.then(index_1.displayProfitResults)
.catch((error) => {
console.error(`Error processing transaction ${txHash}:`, error);
// Continue with the next transaction
});
}
});