Skip to content

Commit

Permalink
legacymarket: prevent self liquidation on v2x once LM is enabled (#2246)
Browse files Browse the repository at this point in the history
* legacymarket: prevent self liquidation on v2x once LM is enabled

* add test case

---------

Co-authored-by: meb <[email protected]>
  • Loading branch information
dbeal-eth and barrasso authored Jul 23, 2024
1 parent e293898 commit 987f18e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions contracts/BaseSynthetix.sol
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ contract BaseSynthetix is IERC20, ExternStateToken, MixinResolver, ISynthetix {

/// @notice Allows an account to self-liquidate anytime its c-ratio is below the target issuance ratio.
function liquidateSelf() external systemActive optionalProxy returns (bool) {
require(resolver.getAddress(CONTRACT_V3_LEGACYMARKET) == address(0), "Must liquidate using V3");

// must store liquidated account address because below functions may attempt to transfer SNX which changes messageSender
address liquidatedAccount = messageSender;

Expand Down
3 changes: 3 additions & 0 deletions test/contracts/Liquidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ contract('Liquidator', accounts => {
'Must liquidate using V3'
);
});
it('when liquidateSelf() is invoked, it reverts with must liquidate using V3', async () => {
await assert.revert(synthetix.liquidateSelf({ from: alice }), 'Must liquidate using V3');
});
});
describe('protected methods', () => {
describe('only internal contracts can call', () => {
Expand Down

0 comments on commit 987f18e

Please sign in to comment.