pub fn receive_cw20(
    deps: DepsMut,
    env: Env,
    msg_info: MessageInfo,
    cw20_msg: Cw20ReceiveMsg,
) -> VaultResult {
    match from_binary(&cw20_msg.msg)? {
        DepositHookMsg::WithdrawLiquidity {} => {
            let state: State = STATE.load(deps.storage)?;
            if msg_info.sender != state.liquidity_token_addr {
                return Err(VaultError::NotLPToken {
                    token: msg_info.sender.to_string(),
                });
            }
            try_withdraw_liquidity(deps, env, cw20_msg.sender, cw20_msg.amount)
        }
        DepositHookMsg::ProvideLiquidity {} => {
            // Construct deposit asset
            let asset = Asset {
                info: AssetInfo::Token {
                    contract_addr: msg_info.sender.to_string(),
                },
                amount: cw20_msg.amount,
            };
            try_provide_liquidity(deps, msg_info, asset, Some(cw20_msg.sender))
        }
    }
}
/// handler function invoked when the vault dapp contract receives
/// a transaction. In this case it is triggered when either a LP tokens received
/// by the contract or when the deposit asset is a cw20 asset.
handler function invoked when the vault dapp contract receives
a transaction. In this case it is triggered when either a LP tokens received
by the contract or when the deposit asset is a cw20 asset.
handler function invoked when the vault dapp contract receives a transaction . In this case it is triggered when either a LP tokens received by the contract or when the deposit asset is a cw20 asset .
pub fn receive_cw20(
    deps: DepsMut,
    env: Env,
    msg_info: MessageInfo,
    cw20_msg: Cw20ReceiveMsg,
) -> VaultResult {
    match from_binary(&cw20_msg.msg)? {
        DepositHookMsg::WithdrawLiquidity {} => {
            let state: State = STATE.load(deps.storage)?;
            if msg_info.sender != state.liquidity_token_addr {
                return Err(VaultError::NotLPToken {
                    token: msg_info.sender.to_string(),
                });
            }
            try_withdraw_liquidity(deps, env, cw20_msg.sender, cw20_msg.amount)
        }
        DepositHookMsg::ProvideLiquidity {} => {
            // Construct deposit asset
            let asset = Asset {
                info: AssetInfo::Token {
                    contract_addr: msg_info.sender.to_string(),
                },
                amount: cw20_msg.amount,
            };
            try_provide_liquidity(deps, msg_info, asset, Some(cw20_msg.sender))
        }
    }
}
pub fn receive_cw20 ( deps : DepsMut , env : Env , msg_info : MessageInfo , cw20_msg : Cw20ReceiveMsg , ) -> VaultResult { match from_binary ( & cw20_msg . msg ) ? { DepositHookMsg :: WithdrawLiquidity { } => { let state : State = STATE . load ( deps . storage ) ? ; if msg_info . sender != state . liquidity_token_addr { return Err ( VaultError :: NotLPToken { token : msg_info . sender . to_string ( ) , } ) ; } try_withdraw_liquidity ( deps , env , cw20_msg . sender , cw20_msg . amount ) } DepositHookMsg :: ProvideLiquidity { } => { // Construct deposit asset let asset = Asset { info : AssetInfo :: Token { contract_addr : msg_info . sender . to_string ( ) , } , amount : cw20_msg . amount , } ; try_provide_liquidity ( deps , msg_info , asset , Some ( cw20_msg . sender ) ) } } }
handler function invoked when the vault dapp contract receives
a transaction.
handler function invoked when the vault dapp contract receives a transaction .
deps
DepsMut
env
Env
msg_info
MessageInfo
cw20_msg
Cw20ReceiveMsg
deps
DepsMut
env
Env
msg_info
MessageInfo
cw20_msg
Cw20ReceiveMsg