[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
PERPS_SYSTEM
feature flagSome notable considerations:
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.modifyCollateral
for a trader.payDebt
.