UNPKG

flashloan-profit-calculator

Version:

A library for analyzing flashloan transactions and calculating profits

23 lines (22 loc) 893 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.decodeTransferInput = decodeTransferInput; exports.decodeTransferFromInput = decodeTransferFromInput; exports.decodeWithdrawInput = decodeWithdrawInput; function decodeTransferInput(input) { const data = input.slice(10); // Remove function signature const to = `0x${data.slice(24, 64)}`; const amount = BigInt(`0x${data.slice(64, 128)}`); return [to, amount]; } function decodeTransferFromInput(input) { const data = input.slice(10); // Remove function signature const from = `0x${data.slice(24, 64)}`; const to = `0x${data.slice(88, 128)}`; const amount = BigInt(`0x${data.slice(128, 192)}`); return [from, to, amount]; } function decodeWithdrawInput(input) { const data = input.slice(10); // Remove function signature return BigInt(`0x${data.slice(24, 64)}`); }