"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CompoundPositionPresenter = void 0;
const lodash_1 = require("lodash");
const position_presenter_template_1 = require("../../../position/template/position-presenter.template");
class CompoundPositionPresenter extends position_presenter_template_1.PositionPresenterTemplate {
    constructor() {
        super(...arguments);
        this.explorePresentationConfig = {
            tabs: [
                {
                    label: 'Lending',
                    viewType: 'split',
                    views: [
                        {
                            viewType: 'list',
                            label: 'Supply',
                            groupIds: ['supply'],
                        },
                        {
                            viewType: 'list',
                            label: 'Borrow',
                            groupIds: ['borrow'],
                        },
                    ],
                },
            ],
        };
    }
    metadataItemsForBalanceGroup(groupLabel, balances, _dataProps) {
        if (groupLabel === 'Lending') {
            const collaterals = balances.filter(balance => balance.balanceUSD > 0);
            const debt = balances.filter(balance => balance.balanceUSD < 0);
            const totalCollateralUSD = (0, lodash_1.sumBy)(collaterals, a => a.balanceUSD);
            const totalDebtUSD = (0, lodash_1.sumBy)(debt, a => a.balanceUSD);
            const utilRatio = (Math.abs(totalDebtUSD) / totalCollateralUSD) * 100;
            return [
                {
                    label: 'Collateral',
                    value: totalCollateralUSD,
                    type: 'dollar',
                },
                {
                    label: 'Debt',
                    value: totalDebtUSD,
                    type: 'dollar',
                },
                {
                    label: 'Utilization Rate',
                    value: utilRatio,
                    type: 'pct',
                },
            ];
        }
        return [];
    }
}
exports.CompoundPositionPresenter = CompoundPositionPresenter;
//# sourceMappingURL=compound.position-presenter.js.map