/// Find or add collateral by deposit reserve

Find or add collateral by deposit reserve
Find or add collateral by deposit reserve
pub fn find_or_add_collateral_to_deposits(
        &mut self,
        deposit_reserve: Pubkey,
        l_token_mining_index: Decimal,
    ) -> Result<(&TicketCollateral, usize), ProgramError> {
        if let Some(collateral_index) = self._find_collateral_index_in_deposits(deposit_reserve) {
            return Ok((&self.deposits[collateral_index], collateral_index));
        }
        // if self.deposits.len() + self.borrows.len() >= MAX_OBLIGATION_RESERVES {
        if self.deposits.len() >= MAX_OBLIGATION_RESERVES {
            msg!(
                "Obligation cannot have more than {} deposits combined",
                MAX_OBLIGATION_RESERVES
            );
            return Err(PoolingError::ObligationReserveLimit.into());
        }
        let collateral = TicketCollateral::new(deposit_reserve, l_token_mining_index);
        self.deposits.push(collateral);
        Ok((self.deposits.last().unwrap(), self.deposits.len() - 1))
    }
pub fn find_or_add_collateral_to_deposits ( & mut self , deposit_reserve : Pubkey , l_token_mining_index : Decimal , ) -> Result < ( & TicketCollateral , usize ) , ProgramError > { if let Some ( collateral_index ) = self . _find_collateral_index_in_deposits ( deposit_reserve ) { return Ok ( ( & self . deposits [ collateral_index ] , collateral_index ) ) ; } // if self.deposits.len() + self.borrows.len() >= MAX_OBLIGATION_RESERVES {
 if self . deposits . len ( ) >= MAX_OBLIGATION_RESERVES { msg ! ( " " MAX_OBLIGATION_RESERVES ) ; return Err ( PoolingError :: ObligationReserveLimit . into ( ) ) ; } let collateral = TicketCollateral :: new ( deposit_reserve , l_token_mining_index ) ; self . deposits . push ( collateral ) ; Ok ( ( self . deposits . last ( ) . unwrap ( ) , self . deposits . len ( ) - 1 ) ) }
Find or add collateral by deposit reserve
Find or add collateral by deposit reserve
&mut self
deposit_reserve
Pubkey
l_token_mining_index
Decimal