synthetix-v3 icon indicating copy to clipboard operation
synthetix-v3 copied to clipboard

PayDebt fixes

Open sunnyvempati opened this issue 1 year ago • 0 comments

  • [x] Fix debt wipe when attempting to pay with more amount than debt.
  • [x] update global debt when debt is paid.
  • [x] update interest rate on debt payment.
  • [x] add PERPS_SYSTEM feature flag

Some notable considerations:

  • When payDebt() is called with an amount larger than the debt, only upto the debt amount is transferred from caller, so we have eliminated adding excess to USD margin since that would require global collateral validations and other considerations.
  • All deposit/withdraw margin interactions are done via modifyCollateral for a trader.
  • Only way to repay their debt is to call payDebt.
  • Anyone can pay someone else's debt, no reason to have only trader pay their own debt

sunnyvempati avatar Jul 19 '24 16:07 sunnyvempati