synthetix-v3
synthetix-v3 copied to clipboard
PayDebt fixes
- [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_SYSTEMfeature 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
modifyCollateralfor 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