import { useMemo, useState, useEffect } from "react";
const useLtv = ({ api, getAccount, account, subAccType, }) => {
    const [ltv, setLtv] = useState();
    useEffect(() => {
        let unsub;
        if (api && subAccType) {
            (async () => {
                try {
                    const subacc = getAccount(subAccType);
                    if (subacc?.address) {
                    }
                }
                catch (err) {
                    if (err instanceof Error) {
                        console.error(err.message);
                    }
                }
            })();
        }
        else if (api && account) {
            (async () => {
                try {
                }
                catch (err) {
                    if (err instanceof Error) {
                        console.error(err.message);
                    }
                }
            })();
        }
        return () => {
            if (unsub) {
                unsub();
            }
        };
    }, [api, getAccount, account, subAccType]);
    return ltv;
};
/// TODO: query ltvs for all accs with queryMulti (?)
export const useLtvs = ({ api, getAccount, account, }) => {
    const subaccs = useMemo(() => {
        return {
            borrower: getAccount("Borrower"),
            bailsman: getAccount("Bailsman"),
        };
    }, [getAccount]);
    const masterLtv = useLtv({
        api,
        getAccount,
        account,
    });
    const borrowerLtv = useLtv({
        api,
        getAccount,
        subAccType: "Borrower",
    });
    const bailsmanLtv = useLtv({
        api,
        getAccount,
        subAccType: "Bailsman",
    });
    return {
        master: masterLtv?.ltv,
        borrower: borrowerLtv?.ltv,
        bailsman: bailsmanLtv?.ltv,
    };
};
//# sourceMappingURL=ltvs.js.map