pub fn sweep(deps: DepsMut, env: Env, denom: String) -> Result<Response, ContractError> {
    // Read the config, glow_token, and terraswap_factory_addr
    let config = CONFIG.load(deps.storage)?;
    let glow_token = config.glow_token;
    let terraswap_factory_addr = config.terraswap_factory;

    // Get the pair info
    let pair_info: PairInfo = query_pair_info(
        &deps.querier,
        terraswap_factory_addr,
        &[
            AssetInfo::NativeToken {
                denom: denom.to_string(),
            },
            AssetInfo::Token {
                contract_addr: glow_token.to_string(),
            },
        ],
    )?;

    // Sweep the entire balance worth of the denom to glow
    let amount = query_balance(&deps.querier, env.contract.address, denom.to_string())?;
    let swap_asset = Asset {
        info: AssetInfo::NativeToken {
            denom: denom.to_string(),
        },
        amount,
    };

    // Deduct tax first
    let amount = (swap_asset.deduct_tax(&deps.querier)?).amount;

    // Response which sweeps all the contracts UST for GLOW
    Ok(Response::new()
        .add_message(CosmosMsg::Wasm(WasmMsg::Execute {
            contract_addr: pair_info.contract_addr,
            msg: to_binary(&TerraswapExecuteMsg::Swap {
                offer_asset: Asset {
                    amount,
                    ..swap_asset
                },
                max_spread: None,
                belief_price: None,
                to: None,
            })?,
            funds: vec![Coin {
                denom: denom.to_string(),
                amount,
            }],
        }))
        .add_attributes(vec![
            attr("action", "sweep"),
            attr(
                "collected_rewards",
                format!("{:?}{:?}", amount.to_string(), denom),
            ),
        ]))
}
/// Sweep
/// Anyone can execute sweep function to swap
/// asset native denom => GLOW token
Sweep
Anyone can execute sweep function to swap
asset native denom => GLOW token
Sweep Anyone can execute sweep function to swap asset native denom = > GLOW token
pub fn sweep(deps: DepsMut, env: Env, denom: String) -> Result<Response, ContractError> {
    // Read the config, glow_token, and terraswap_factory_addr
    let config = CONFIG.load(deps.storage)?;
    let glow_token = config.glow_token;
    let terraswap_factory_addr = config.terraswap_factory;
    // Get the pair info
    let pair_info: PairInfo = query_pair_info(
        &deps.querier,
        terraswap_factory_addr,
        &[
            AssetInfo::NativeToken {
                denom: denom.to_string(),
            },
            AssetInfo::Token {
                contract_addr: glow_token.to_string(),
            },
        ],
    )?;
    // Sweep the entire balance worth of the denom to glow
    let amount = query_balance(&deps.querier, env.contract.address, denom.to_string())?;
    let swap_asset = Asset {
        info: AssetInfo::NativeToken {
            denom: denom.to_string(),
        },
        amount,
    };
    // Deduct tax first
    let amount = (swap_asset.deduct_tax(&deps.querier)?).amount;
    // Response which sweeps all the contracts UST for GLOW
    Ok(Response::new()
        .add_message(CosmosMsg::Wasm(WasmMsg::Execute {
            contract_addr: pair_info.contract_addr,
            msg: to_binary(&TerraswapExecuteMsg::Swap {
                offer_asset: Asset {
                    amount,
                    ..swap_asset
                },
                max_spread: None,
                belief_price: None,
                to: None,
            })?,
            funds: vec![Coin {
                denom: denom.to_string(),
                amount,
            }],
        }))
        .add_attributes(vec![
            attr("action", "sweep"),
            attr(
                "collected_rewards",
                format!("{:?}{:?}", amount.to_string(), denom),
            ),
        ]))
}
pub fn sweep ( deps : DepsMut , env : Env , denom : String ) -> Result < Response , ContractError > { // Read the config, glow_token, and terraswap_factory_addr let config = CONFIG . load ( deps . storage ) ? ; let glow_token = config . glow_token ; let terraswap_factory_addr = config . terraswap_factory ; // Get the pair info let pair_info : PairInfo = query_pair_info ( & deps . querier , terraswap_factory_addr , & [ AssetInfo :: NativeToken { denom : denom . to_string ( ) , } , AssetInfo :: Token { contract_addr : glow_token . to_string ( ) , } , ] , ) ? ; // Sweep the entire balance worth of the denom to glow let amount = query_balance ( & deps . querier , env . contract . address , denom . to_string ( ) ) ? ; let swap_asset = Asset { info : AssetInfo :: NativeToken { denom : denom . to_string ( ) , } , amount , } ; // Deduct tax first let amount = ( swap_asset . deduct_tax ( & deps . querier ) ? ) . amount ; // Response which sweeps all the contracts UST for GLOW Ok ( Response :: new ( ) . add_message ( CosmosMsg :: Wasm ( WasmMsg :: Execute { contract_addr : pair_info . contract_addr , msg : to_binary ( & TerraswapExecuteMsg :: Swap { offer_asset : Asset { amount , .. swap_asset } , max_spread : None , belief_price : None , to : None , } ) ? , funds : vec ! [ Coin { denom denom to_string ( ) amount } ] , } ) ) . add_attributes ( vec ! [ attr ( " " " " ) attr ( " " format ( " " amount to_string ( ) denom ) ) ] ) ) }
Sweep
Anyone can execute sweep function to swap
asset native denom => GLOW token
Sweep Anyone can execute sweep function to swap asset native denom = > GLOW token
deps
DepsMut
env
Env
denom
String