"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.withConvertMantissa = void 0;
const ethers_1 = require("ethers");
const daysPerYear = 365;
function withConvertMantissa(Base) {
    return class ConvertMantissa extends Base {
        /**
         * Directly taken from the compound.finance docs:
         * https://compound.finance/docs#protocol-math
         */
        ratePerBlockToAPY(ratePerBlock, blocksPerMin) {
            const blocksPerDay = blocksPerMin * 60 * 24;
            const rateAsNumber = Number(ethers_1.utils.formatUnits(ratePerBlock, 18));
            return (Math.pow(rateAsNumber * blocksPerDay + 1, daysPerYear) - 1) * 100;
        }
    };
}
exports.withConvertMantissa = withConvertMantissa;
