"use strict";
var __read = (this && this.__read) || function (o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
        if (ar || !(i in from)) {
            if (!ar) ar = Array.prototype.slice.call(from, 0, i);
            ar[i] = from[i];
        }
    }
    return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.calcAssetRisk = exports.assetsConfig = void 0;
var riskUtils_1 = require("../riskUtils");
var singleStrategyRisk_1 = require("../singleStrategyRisk");
function fieldMappings(records) {
    return records.map(function (record) { return ({
        id: record.id,
        fields: record.fields,
    }); });
}
var table = 'ASSETS';
var fields = [
    'Name',
    // 'ALL',
    'messari_asset_id',
    'Depeg',
    'Total_Override',
];
exports.assetsConfig = {
    table: table,
    fields: __spreadArray([], __read(fields), false),
    fieldMappings: fieldMappings,
};
function calcAssetRisk(_a, messariAssetData, depegRisk) {
    var _b, _c, _d;
    var id = _a.id, Name = _a.Name, Total_Override = _a.Total_Override;
    var score = 0;
    if (depegRisk === null || depegRisk === void 0 ? void 0 : depegRisk.score)
        score += depegRisk === null || depegRisk === void 0 ? void 0 : depegRisk.score;
    var assetVol30d = (_c = (_b = messariAssetData === null || messariAssetData === void 0 ? void 0 : messariAssetData.risk_metrics) === null || _b === void 0 ? void 0 : _b.volatility_stats) === null || _c === void 0 ? void 0 : _c.volatility_last_30_days;
    var realAssetVol24h = (_d = messariAssetData === null || messariAssetData === void 0 ? void 0 : messariAssetData.market_data) === null || _d === void 0 ? void 0 : _d.real_volume_last_24_hours;
    return {
        id: id,
        name: "".concat(Name, " Risk"),
        score: Total_Override !== null && Total_Override !== void 0 ? Total_Override : score,
        items: (0, singleStrategyRisk_1.defined)([
            depegRisk,
            (0, riskUtils_1.getItem)('Asset Volatility 30d', assetVol30d),
            (0, riskUtils_1.getItem)('Real Asset Volume 24h', realAssetVol24h),
        ]),
    };
}
exports.calcAssetRisk = calcAssetRisk;
//# sourceMappingURL=assetsConfig.js.map