"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: all[name]
    });
}
_export(exports, {
    formatTxID: function() {
        return formatTxID;
    },
    generateKeyFun: function() {
        return generateKeyFun;
    },
    getAnnualRate: function() {
        return getAnnualRate;
    },
    getInfiniteData: function() {
        return getInfiniteData;
    },
    upperFirstLetter: function() {
        return upperFirstLetter;
    }
});
const _utils = require("@orderly.network/utils");
function formatTxID(value) {
    if (value === undefined || value === null) return "";
    if (value.length < 10) return value;
    return `${value.slice(0, 5)}...${value.slice(-5)}`;
}
function upperFirstLetter(status) {
    if (!status) {
        return status;
    }
    return status.charAt(0).toUpperCase() + status.slice(1).toLowerCase();
}
function generateKeyFun(urlPrefix, args) {
    return (pageIndex, previousPageData)=>{
        // reached the end
        if (previousPageData && !previousPageData.rows?.length) return null;
        const { size = 100 } = args;
        const search = new URLSearchParams([
            [
                "size",
                size.toString()
            ],
            [
                "page",
                `${pageIndex + 1}`
            ]
        ]);
        return `${urlPrefix}?${search.toString()}`;
    };
}
function getInfiniteData(data) {
    if (!data) {
        return null;
    }
    return data?.map((item)=>item.rows)?.flat();
}
function getAnnualRate(fundingRate, fundingPeriod = 8) {
    const period = new _utils.Decimal(24).div(fundingPeriod);
    return new _utils.Decimal(fundingRate).mul(period).mul(365).mul(100).toFixed(2);
}

//# sourceMappingURL=utils.js.map