pub fn find_farms_with_lp(&self, lp_token_name: &str) -> Result<Vec<Farm>, FarmClientError> {
        self.reload_farm_refs_if_stale()?;
        let (protocol, token_a, token_b) = FarmClient::extract_token_names(lp_token_name)?;
        let pattern1 = format!("{}.{}-{}-", protocol, token_a, token_b);
        let pattern2 = format!("{}.{}-{}-", protocol, token_b, token_a);
        let mut res = vec![];
        for (name, _) in self.farm_refs.borrow().data.iter() {
            if name.contains(&pattern1) || name.contains(&pattern2) {
                let farm = self.get_farm(name)?;
                if let Some(lp_token) = self.get_token_by_ref_from_cache(&farm.lp_token_ref)? {
                    if lp_token.name.as_str() == lp_token_name {
                        res.push(farm);
                    }
                }
            }
        }

        if res.is_empty() {
            Err(FarmClientError::RecordNotFound(format!(
                "{} Farm with LP token {}",
                protocol, lp_token_name
            )))
        } else {
            res.sort_by(|a, b| b.version.cmp(&a.version));
            Ok(res)
        }
    }
/// Returns all Farms for the given LP token
Returns all Farms for the given LP token
Returns all Farms for the given LP token
pub fn find_farms_with_lp(&self, lp_token_name: &str) -> Result<Vec<Farm>, FarmClientError> {
        self.reload_farm_refs_if_stale()?;
        let (protocol, token_a, token_b) = FarmClient::extract_token_names(lp_token_name)?;
        let pattern1 = format!("{}.{}-{}-", protocol, token_a, token_b);
        let pattern2 = format!("{}.{}-{}-", protocol, token_b, token_a);
        let mut res = vec![];
        for (name, _) in self.farm_refs.borrow().data.iter() {
            if name.contains(&pattern1) || name.contains(&pattern2) {
                let farm = self.get_farm(name)?;
                if let Some(lp_token) = self.get_token_by_ref_from_cache(&farm.lp_token_ref)? {
                    if lp_token.name.as_str() == lp_token_name {
                        res.push(farm);
                    }
                }
            }
        }
        if res.is_empty() {
            Err(FarmClientError::RecordNotFound(format!(
                "{} Farm with LP token {}",
                protocol, lp_token_name
            )))
        } else {
            res.sort_by(|a, b| b.version.cmp(&a.version));
            Ok(res)
        }
    }
pub fn find_farms_with_lp ( & self , lp_token_name : & str ) -> Result < Vec < Farm > , FarmClientError > { self . reload_farm_refs_if_stale ( ) ? ; let ( protocol , token_a , token_b ) = FarmClient :: extract_token_names ( lp_token_name ) ? ; let pattern1 = format ! ( " " protocol token_a token_b ) ; let pattern2 = format ! ( " " protocol token_b token_a ) ; let mut res = vec ! [ ] ; for ( name , _ ) in self . farm_refs . borrow ( ) . data . iter ( ) { if name . contains ( & pattern1 ) || name . contains ( & pattern2 ) { let farm = self . get_farm ( name ) ? ; if let Some ( lp_token ) = self . get_token_by_ref_from_cache ( & farm . lp_token_ref ) ? { if lp_token . name . as_str ( ) == lp_token_name { res . push ( farm ) ; } } } } if res . is_empty ( ) { Err ( FarmClientError :: RecordNotFound ( format ! ( " " protocol lp_token_name ) ) ) } else { res . sort_by ( | a , b | b . version . cmp ( & a . version ) ) ; Ok ( res ) } }
Returns all Farms for the given LP token
Returns all Farms for the given LP token
&self
lp_token_name
&str
&self
lp_token_name
&str