fn provide_liquidity(
        &mut self,
        lp: &Addr,
        btc: u128,
        cash: u128,
        slippage_tolerance: impl Into<Option<Decimal>>,
    ) -> Result<&mut Self> {
        if cash > 0 {
            self.app
                .execute_contract(
                    lp.clone(),
                    self.cash.clone(),
                    &cw20_base::msg::ExecuteMsg::IncreaseAllowance {
                        spender: self.pair.to_string(),
                        amount: Uint128::new(cash),
                        expires: None,
                    },
                    &[],
                )
                .map_err(|err| anyhow!(err))?;
        }

        self.app
            .execute_contract(
                lp.clone(),
                self.pair.clone(),
                &ExecuteMsg::ProvideLiquidity {
                    assets: [
                        Asset {
                            info: AssetInfo::Native("btc".to_owned()),
                            amount: Uint128::new(btc),
                        },
                        Asset {
                            info: AssetInfo::Token(self.cash.clone()),
                            amount: Uint128::new(cash),
                        },
                    ],
                    slippage_tolerance: slippage_tolerance.into(),
                },
                &coins(btc, "btc"),
            )
            .map_err(|err| anyhow!(err))?;

        Ok(self)
    }
/// Helper executing providing liquidity for pair
///
/// First if any cash is provided, increases allowance for it so it can actually be send. Then
/// `ProvideLiquidity` message is send to pair contract
Helper executing providing liquidity for pair
First if any cash is provided, increases allowance for it so it can actually be send. Then
`ProvideLiquidity` message is send to pair contract
Helper executing providing liquidity for pair First if any cash is provided increases allowance for it so it can actually be send . Then ` ProvideLiquidity ` message is send to pair contract
fn provide_liquidity(
        &mut self,
        lp: &Addr,
        btc: u128,
        cash: u128,
        slippage_tolerance: impl Into<Option<Decimal>>,
    ) -> Result<&mut Self> {
        if cash > 0 {
            self.app
                .execute_contract(
                    lp.clone(),
                    self.cash.clone(),
                    &cw20_base::msg::ExecuteMsg::IncreaseAllowance {
                        spender: self.pair.to_string(),
                        amount: Uint128::new(cash),
                        expires: None,
                    },
                    &[],
                )
                .map_err(|err| anyhow!(err))?;
        }
        self.app
            .execute_contract(
                lp.clone(),
                self.pair.clone(),
                &ExecuteMsg::ProvideLiquidity {
                    assets: [
                        Asset {
                            info: AssetInfo::Native("btc".to_owned()),
                            amount: Uint128::new(btc),
                        },
                        Asset {
                            info: AssetInfo::Token(self.cash.clone()),
                            amount: Uint128::new(cash),
                        },
                    ],
                    slippage_tolerance: slippage_tolerance.into(),
                },
                &coins(btc, "btc"),
            )
            .map_err(|err| anyhow!(err))?;
        Ok(self)
    }
fn provide_liquidity ( & mut self , lp : & Addr , btc : u128 , cash : u128 , slippage_tolerance : impl Into < Option < Decimal > > , ) -> Result < & mut Self > { if cash > 0 { self . app . execute_contract ( lp . clone ( ) , self . cash . clone ( ) , & cw20_base :: msg :: ExecuteMsg :: IncreaseAllowance { spender : self . pair . to_string ( ) , amount : Uint128 :: new ( cash ) , expires : None , } , & [ ] , ) . map_err ( | err | anyhow ! ( err ) ) ? ; } self . app . execute_contract ( lp . clone ( ) , self . pair . clone ( ) , & ExecuteMsg :: ProvideLiquidity { assets : [ Asset { info : AssetInfo :: Native ( " " . to_owned ( ) ) , amount : Uint128 :: new ( btc ) , } , Asset { info : AssetInfo :: Token ( self . cash . clone ( ) ) , amount : Uint128 :: new ( cash ) , } , ] , slippage_tolerance : slippage_tolerance . into ( ) , } , & coins ( btc , " " ) , ) . map_err ( | err | anyhow ! ( err ) ) ? ; Ok ( self ) }
Helper executing providing liquidity for pair
First if any cash is provided, increases allowance for it so it can actually be send.
Helper executing providing liquidity for pair First if any cash is provided increases allowance for it so it can actually be send .
&mut self
lp
&Addr
btc
u128
cash
u128
slippage_tolerance
impl Into<Option<Decimal>>
&mut self
lp
&Addr
btc
u128
cash
u128
slippage_tolerance
impl Into<Option<Decimal>>