pub fn receive_cw20(
    deps: DepsMut,
    env: Env,
    msg_info: MessageInfo,
    cw20_msg: Cw20ReceiveMsg,
) -> VaultResult {
    match from_binary(&cw20_msg.msg)? {
        Cw20HookMsg::Swap { .. } => Err(StableVaultError::NoSwapAvailable {}),
        Cw20HookMsg::WithdrawLiquidity {} => {
            let info: PoolInfoRaw = POOL_INFO.load(deps.storage)?;
            if deps.api.addr_validate(&msg_info.sender.to_string())? != info.liquidity_token {
                return Err(StableVaultError::Unauthorized {});
            }
            try_withdraw_liquidity(deps, env, cw20_msg.sender, cw20_msg.amount)
        }
    }
}
/// handler function invoked when the stablecoin-vault contract receives
/// a transaction. In this case it is triggered when the LP tokens are deposited
/// into the contract
handler function invoked when the stablecoin-vault contract receives
a transaction. In this case it is triggered when the LP tokens are deposited
into the contract
handler function invoked when the stablecoin - vault contract receives a transaction . In this case it is triggered when the LP tokens are deposited into the contract
pub fn receive_cw20(
    deps: DepsMut,
    env: Env,
    msg_info: MessageInfo,
    cw20_msg: Cw20ReceiveMsg,
) -> VaultResult {
    match from_binary(&cw20_msg.msg)? {
        Cw20HookMsg::Swap { .. } => Err(StableVaultError::NoSwapAvailable {}),
        Cw20HookMsg::WithdrawLiquidity {} => {
            let info: PoolInfoRaw = POOL_INFO.load(deps.storage)?;
            if deps.api.addr_validate(&msg_info.sender.to_string())? != info.liquidity_token {
                return Err(StableVaultError::Unauthorized {});
            }
            try_withdraw_liquidity(deps, env, cw20_msg.sender, cw20_msg.amount)
        }
    }
}
pub fn receive_cw20 ( deps : DepsMut , env : Env , msg_info : MessageInfo , cw20_msg : Cw20ReceiveMsg , ) -> VaultResult { match from_binary ( & cw20_msg . msg ) ? { Cw20HookMsg :: Swap { .. } => Err ( StableVaultError :: NoSwapAvailable { } ) , Cw20HookMsg :: WithdrawLiquidity { } => { let info : PoolInfoRaw = POOL_INFO . load ( deps . storage ) ? ; if deps . api . addr_validate ( & msg_info . sender . to_string ( ) ) ? != info . liquidity_token { return Err ( StableVaultError :: Unauthorized { } ) ; } try_withdraw_liquidity ( deps , env , cw20_msg . sender , cw20_msg . amount ) } } }
handler function invoked when the stablecoin-vault contract receives
a transaction.
handler function invoked when the stablecoin - vault contract receives a transaction .
deps
DepsMut
env
Env
msg_info
MessageInfo
cw20_msg
Cw20ReceiveMsg
deps
DepsMut
env
Env
msg_info
MessageInfo
cw20_msg
Cw20ReceiveMsg