mars-protocol / rover

Smart contracts for Rover
GNU General Public License v3.0
1 stars 1 forks source link

Fix Protocol Liquidation Fee calculation #185

Closed piobab closed 1 year ago

piobab commented 1 year ago

It uses PLF update from this PR https://github.com/mars-protocol/rover/pull/185 Only test cases are updated accordingly based on new logic and spreadsheet.

Should be:

debt_value_to_repay = debt_amount_to_repay * debt_2_price

collateral_amount_to_liquidate = debt_value_to_repay * (1 + LB) / collateral_1_price

protocol_fee_value = debt_value_to_repay * LB * PLF

protocol_fee_amount = protocol_fee_value / collateral_1_price

collateral_amount_received_by_liquidator = collateral_amount_to_liquidate - protocol_fee_amount
piobab commented 1 year ago

Rebased with latest changes from master.