Mining

Supply Mining APY

[AM(utilization_rate) * mining_speed * larix_price] / total_supply_value

let lend_side_mine_ratio = Mining::get_lend_side_ratio(util_rate, bonus.kink_util_rate)?;   
let lend_side_mine_coeff_diff = mine_speed
.try_mul(lend_side_mine_ratio)?
.try_mul(slots_elapsed)?
.try_div(total_l_token_amount)?;

Borrow Mining APY

[(1 - AM(utilization_rate)) * mining_speed * larix_price] / total_borrow_value

let borrow_side_mine_amount = bonus.borrow_mining_index
.try_sub(mining.borrow_mining_indices[pos])?
.try_mul(user_borrow_amount)?
.try_div(global_borrow_interest_index)?;

AM

if self.collateral.mint_total_supply == 0 as u64 {
            return Ok((Rate::zero(),Rate::zero()));
        }
        if self.liquidity.borrowed_amount_wads.lt(&Decimal::one()){
            return Ok((Rate::one(),Rate::zero()));
        }
        
        let utilization_rate = self.liquidity.utilization_rate()?;
        let kink_rate =  Rate::try_from(
                            Decimal::from(self.bonus.kink_util_rate).try_div(Decimal::from(10000 as u64))?
                                )?;
        if  utilization_rate < kink_rate {
            let normalized_rate = utilization_rate.try_div(kink_rate)?;
            let min_rate = Rate::from_percent(0);
            let rate_range = Rate::from_percent(50);
            let mining_rate = normalized_rate.try_mul(rate_range)?.try_add(min_rate)?;
        
            Ok((mining_rate,Rate::one().try_sub(mining_rate)?))
        } else {
            let normalized_rate = utilization_rate
                .try_sub(kink_rate)?
                .try_div(Rate::from_percent(100u8).try_sub(kink_rate)?)?;
            let min_rate = Rate::from_percent(50);
            let rate_range = Rate::from_percent(100u8).try_sub(min_rate)?;
            let mining_rate = normalized_rate.try_mul(rate_range)?.try_add(min_rate)?;
            Ok((mining_rate,Rate::one().try_sub(mining_rate)?))
        }

Last updated