Mining

Supply Mining APY

[AM(utilization_rate) * mining_speed * larix_price] / total_supply_value
1
let lend_side_mine_ratio = Mining::get_lend_side_ratio(util_rate, bonus.kink_util_rate)?;
2
let lend_side_mine_coeff_diff = mine_speed
3
.try_mul(lend_side_mine_ratio)?
4
.try_mul(slots_elapsed)?
5
.try_div(total_l_token_amount)?;
Copied!

Borrow Mining APY

[(1 - AM(utilization_rate)) * mining_speed * larix_price] / total_borrow_value
1
let borrow_side_mine_amount = bonus.borrow_mining_index
2
.try_sub(mining.borrow_mining_indices[pos])?
3
.try_mul(user_borrow_amount)?
4
.try_div(global_borrow_interest_index)?;
Copied!
AM
1
if self.collateral.mint_total_supply == 0 as u64 {
2
return Ok((Rate::zero(),Rate::zero()));
3
}
4
if self.liquidity.borrowed_amount_wads.lt(&Decimal::one()){
5
return Ok((Rate::one(),Rate::zero()));
6
}
7
8
let utilization_rate = self.liquidity.utilization_rate()?;
9
let kink_rate = Rate::try_from(
10
Decimal::from(self.bonus.kink_util_rate).try_div(Decimal::from(10000 as u64))?
11
)?;
12
if utilization_rate < kink_rate {
13
let normalized_rate = utilization_rate.try_div(kink_rate)?;
14
let min_rate = Rate::from_percent(0);
15
let rate_range = Rate::from_percent(50);
16
let mining_rate = normalized_rate.try_mul(rate_range)?.try_add(min_rate)?;
17
18
Ok((mining_rate,Rate::one().try_sub(mining_rate)?))
19
} else {
20
let normalized_rate = utilization_rate
21
.try_sub(kink_rate)?
22
.try_div(Rate::from_percent(100u8).try_sub(kink_rate)?)?;
23
let min_rate = Rate::from_percent(50);
24
let rate_range = Rate::from_percent(100u8).try_sub(min_rate)?;
25
let mining_rate = normalized_rate.try_mul(rate_range)?.try_add(min_rate)?;
26
Ok((mining_rate,Rate::one().try_sub(mining_rate)?))
27
}
Copied!
Last modified 4mo ago
Copy link
Contents