pub fn before_trade(deps: DepsMut, env: Env) -> Result<Vec<(&str, String)>, LunaVaultError> {
    let mut profit_check = PROFIT.load(deps.storage)?;

    // last_balance call can not be reset until after the loan.
    if profit_check.last_balance != Uint128::zero() {
        return Err(LunaVaultError::Nonzero {});
    }

    profit_check.last_profit = Uint128::zero();

    // Index 0 = total_value
    let info: PoolInfoRaw = POOL_INFO.load(deps.storage)?;
    profit_check.last_balance =
        compute_total_value(&env, deps.as_ref(), &info)?.total_value_in_luna;
    PROFIT.save(deps.storage, &profit_check)?;

    Ok(vec![(
        "value before trade: ",
        profit_check.last_balance.to_string(),
    )])
}
/// Resets last trade and sets current UST balance of caller
Resets last trade and sets current UST balance of caller
Resets last trade and sets current UST balance of caller
pub fn before_trade(deps: DepsMut, env: Env) -> Result<Vec<(&str, String)>, LunaVaultError> {
    let mut profit_check = PROFIT.load(deps.storage)?;
    // last_balance call can not be reset until after the loan.
    if profit_check.last_balance != Uint128::zero() {
        return Err(LunaVaultError::Nonzero {});
    }
    profit_check.last_profit = Uint128::zero();
    // Index 0 = total_value
    let info: PoolInfoRaw = POOL_INFO.load(deps.storage)?;
    profit_check.last_balance =
        compute_total_value(&env, deps.as_ref(), &info)?.total_value_in_luna;
    PROFIT.save(deps.storage, &profit_check)?;
    Ok(vec![(
        "value before trade: ",
        profit_check.last_balance.to_string(),
    )])
}
pub fn before_trade ( deps : DepsMut , env : Env ) -> Result < Vec < ( & str , String ) > , LunaVaultError > { let mut profit_check = PROFIT . load ( deps . storage ) ? ; // last_balance call can not be reset until after the loan. if profit_check . last_balance != Uint128 :: zero ( ) { return Err ( LunaVaultError :: Nonzero { } ) ; } profit_check . last_profit = Uint128 :: zero ( ) ; // Index 0 = total_value let info : PoolInfoRaw = POOL_INFO . load ( deps . storage ) ? ; profit_check . last_balance = compute_total_value ( & env , deps . as_ref ( ) , & info ) ? . total_value_in_luna ; PROFIT . save ( deps . storage , & profit_check ) ? ; Ok ( vec ! [ ( " " profit_check last_balance to_string ( ) ) ] ) }
Resets last trade and sets current UST balance of caller
Resets last trade and sets current UST balance of caller
deps
DepsMut
env
Env
deps
DepsMut
env
Env