pub fn compute_total_value(_env: &Env, deps: Deps, info: &PoolInfoRaw) -> VaultResult<TotalValue> {
    let state = STATE.load(deps.storage)?;
    // get liquid Luna in the vault
    let luna_info = info.asset_infos[0].to_normal(deps.api)?;
    let luna_amount = query_asset_balance(deps, &luna_info, info.contract_addr.clone())?;

    // get Luna from the passive strategy
    // first, get the amount of LP tokens that we have
    // then, query the pool to find out the underlying Luna assets we are entitled to
    let astro_lp_info = info.asset_infos[1].to_normal(deps.api)?;
    let astro_lp_amount = query_asset_balance(deps, &astro_lp_info, info.contract_addr.clone())?;
    let astro_lp_assets: [astroport::asset::Asset; 2] = deps.querier.query_wasm_smart(
        state.astro_lp_address.clone(),
        &astroport::pair_stable_bluna::QueryMsg::Share {
            amount: astro_lp_amount,
        },
    )?;
    // NOTICE: we are assuming that the assets in the LP are equivalent to 1 Luna
    let astroport_lp_value_in_luna = astro_lp_assets
        .iter()
        .fold(Uint128::zero(), |accum, asset| accum + asset.amount);

    // NOTICE: we are assuming that bLuna is equivalent to 1 Luna
    let bluna_value_in_luna = astro_lp_assets
        .iter()
        .find(|asset| asset.info == astroport::asset::token_asset_info(state.bluna_address.clone()))
        .ok_or_else(|| LunaVaultError::generic_err("Failed to get bLuna asset from astro LP"))?
        .amount;

    // NOTICE: we are assuming that cLuna is equivalent to 1 Luna
    let cluna_info = info.asset_infos[3].to_normal(deps.api)?;
    let cluna_value_in_luna = query_asset_balance(deps, &cluna_info, info.contract_addr.clone())?;

    // amount of bluna burning on Anchor
    let bluna_hub_address =
        query_contract_from_mem(deps, &state.memory_address, ANCHOR_BLUNA_HUB_ID)?;
    let bluna_value_burning_in_luna =
        anchor::query_unbond_requests(deps, bluna_hub_address, info.contract_addr.clone())?
            .requests
            .iter()
            .fold(Uint128::zero(), |acc, unbond_request| {
                acc + unbond_request.1 // pending unbond amount
            });

    // amount of cluna burning on Prism
    let cluna_hub_address =
        query_contract_from_mem(deps, &state.memory_address, PRISM_CLUNA_HUB_ID)?;
    let cluna_value_burning_in_luna =
        prism::query_unbond_requests(deps, cluna_hub_address, info.contract_addr.clone())?
            .requests
            .iter()
            .fold(Uint128::zero(), |acc, unbond_request| {
                acc + unbond_request.1 // pending unbond amount
            });

    let total_deposits_in_luna = luna_amount
        + astroport_lp_value_in_luna
        + bluna_value_in_luna
        + cluna_value_in_luna
        + bluna_value_burning_in_luna
        + cluna_value_burning_in_luna;
    Ok(TotalValue {
        total_value_in_luna: total_deposits_in_luna,
        luna_amount,
        astroport_lp_value_in_luna,
        bluna_value_in_luna,
        cluna_value_in_luna,
        bluna_value_burning_in_luna,
        cluna_value_burning_in_luna,
    })
}
/// compute total vault value of deposits in LUNA and return a tuple with those values.
/// (total, luna, astro lp, bluna, cluna)
compute total vault value of deposits in LUNA and return a tuple with those values.
(total, luna, astro lp, bluna, cluna)
compute total vault value of deposits in LUNA and return a tuple with those values . ( total luna astro lp bluna cluna )
pub fn compute_total_value(_env: &Env, deps: Deps, info: &PoolInfoRaw) -> VaultResult<TotalValue> {
    let state = STATE.load(deps.storage)?;
    // get liquid Luna in the vault
    let luna_info = info.asset_infos[0].to_normal(deps.api)?;
    let luna_amount = query_asset_balance(deps, &luna_info, info.contract_addr.clone())?;
    // get Luna from the passive strategy
    // first, get the amount of LP tokens that we have
    // then, query the pool to find out the underlying Luna assets we are entitled to
    let astro_lp_info = info.asset_infos[1].to_normal(deps.api)?;
    let astro_lp_amount = query_asset_balance(deps, &astro_lp_info, info.contract_addr.clone())?;
    let astro_lp_assets: [astroport::asset::Asset; 2] = deps.querier.query_wasm_smart(
        state.astro_lp_address.clone(),
        &astroport::pair_stable_bluna::QueryMsg::Share {
            amount: astro_lp_amount,
        },
    )?;
    // NOTICE: we are assuming that the assets in the LP are equivalent to 1 Luna
    let astroport_lp_value_in_luna = astro_lp_assets
        .iter()
        .fold(Uint128::zero(), |accum, asset| accum + asset.amount);
    // NOTICE: we are assuming that bLuna is equivalent to 1 Luna
    let bluna_value_in_luna = astro_lp_assets
        .iter()
        .find(|asset| asset.info == astroport::asset::token_asset_info(state.bluna_address.clone()))
        .ok_or_else(|| LunaVaultError::generic_err("Failed to get bLuna asset from astro LP"))?
        .amount;
    // NOTICE: we are assuming that cLuna is equivalent to 1 Luna
    let cluna_info = info.asset_infos[3].to_normal(deps.api)?;
    let cluna_value_in_luna = query_asset_balance(deps, &cluna_info, info.contract_addr.clone())?;
    // amount of bluna burning on Anchor
    let bluna_hub_address =
        query_contract_from_mem(deps, &state.memory_address, ANCHOR_BLUNA_HUB_ID)?;
    let bluna_value_burning_in_luna =
        anchor::query_unbond_requests(deps, bluna_hub_address, info.contract_addr.clone())?
            .requests
            .iter()
            .fold(Uint128::zero(), |acc, unbond_request| {
                acc + unbond_request.1 // pending unbond amount
            });
    // amount of cluna burning on Prism
    let cluna_hub_address =
        query_contract_from_mem(deps, &state.memory_address, PRISM_CLUNA_HUB_ID)?;
    let cluna_value_burning_in_luna =
        prism::query_unbond_requests(deps, cluna_hub_address, info.contract_addr.clone())?
            .requests
            .iter()
            .fold(Uint128::zero(), |acc, unbond_request| {
                acc + unbond_request.1 // pending unbond amount
            });
    let total_deposits_in_luna = luna_amount
        + astroport_lp_value_in_luna
        + bluna_value_in_luna
        + cluna_value_in_luna
        + bluna_value_burning_in_luna
        + cluna_value_burning_in_luna;
    Ok(TotalValue {
        total_value_in_luna: total_deposits_in_luna,
        luna_amount,
        astroport_lp_value_in_luna,
        bluna_value_in_luna,
        cluna_value_in_luna,
        bluna_value_burning_in_luna,
        cluna_value_burning_in_luna,
    })
}
pub fn compute_total_value ( _env : & Env , deps : Deps , info : & PoolInfoRaw ) -> VaultResult < TotalValue > { let state = STATE . load ( deps . storage ) ? ; // get liquid Luna in the vault let luna_info = info . asset_infos [ 0 ] . to_normal ( deps . api ) ? ; let luna_amount = query_asset_balance ( deps , & luna_info , info . contract_addr . clone ( ) ) ? ; // get Luna from the passive strategy // first, get the amount of LP tokens that we have // then, query the pool to find out the underlying Luna assets we are entitled to let astro_lp_info = info . asset_infos [ 1 ] . to_normal ( deps . api ) ? ; let astro_lp_amount = query_asset_balance ( deps , & astro_lp_info , info . contract_addr . clone ( ) ) ? ; let astro_lp_assets : [ astroport :: asset :: Asset ; 2 ] = deps . querier . query_wasm_smart ( state . astro_lp_address . clone ( ) , & astroport :: pair_stable_bluna :: QueryMsg :: Share { amount : astro_lp_amount , } , ) ? ; // NOTICE: we are assuming that the assets in the LP are equivalent to 1 Luna let astroport_lp_value_in_luna = astro_lp_assets . iter ( ) . fold ( Uint128 :: zero ( ) , | accum , asset | accum + asset . amount ) ; // NOTICE: we are assuming that bLuna is equivalent to 1 Luna let bluna_value_in_luna = astro_lp_assets . iter ( ) . find ( | asset | asset . info == astroport :: asset :: token_asset_info ( state . bluna_address . clone ( ) ) ) . ok_or_else ( | | LunaVaultError :: generic_err ( " " ) ) ? . amount ; // NOTICE: we are assuming that cLuna is equivalent to 1 Luna let cluna_info = info . asset_infos [ 3 ] . to_normal ( deps . api ) ? ; let cluna_value_in_luna = query_asset_balance ( deps , & cluna_info , info . contract_addr . clone ( ) ) ? ; // amount of bluna burning on Anchor let bluna_hub_address = query_contract_from_mem ( deps , & state . memory_address , ANCHOR_BLUNA_HUB_ID ) ? ; let bluna_value_burning_in_luna = anchor :: query_unbond_requests ( deps , bluna_hub_address , info . contract_addr . clone ( ) ) ? . requests . iter ( ) . fold ( Uint128 :: zero ( ) , | acc , unbond_request | { acc + unbond_request . 1 // pending unbond amount } ) ; // amount of cluna burning on Prism let cluna_hub_address = query_contract_from_mem ( deps , & state . memory_address , PRISM_CLUNA_HUB_ID ) ? ; let cluna_value_burning_in_luna = prism :: query_unbond_requests ( deps , cluna_hub_address , info . contract_addr . clone ( ) ) ? . requests . iter ( ) . fold ( Uint128 :: zero ( ) , | acc , unbond_request | { acc + unbond_request . 1 // pending unbond amount } ) ; let total_deposits_in_luna = luna_amount + astroport_lp_value_in_luna + bluna_value_in_luna + cluna_value_in_luna + bluna_value_burning_in_luna + cluna_value_burning_in_luna ; Ok ( TotalValue { total_value_in_luna : total_deposits_in_luna , luna_amount , astroport_lp_value_in_luna , bluna_value_in_luna , cluna_value_in_luna , bluna_value_burning_in_luna , cluna_value_burning_in_luna , } ) }
compute total vault value of deposits in LUNA and return a tuple with those values.
compute total vault value of deposits in LUNA and return a tuple with those values .
_env
&Env
deps
Deps
info
&PoolInfoRaw
_env
&Env
deps
Deps
info
&PoolInfoRaw