From 987f18e4f73fbfee3b984fd56934780e1df1508d Mon Sep 17 00:00:00 2001 From: dbeal Date: Tue, 23 Jul 2024 21:45:42 +0900 Subject: [PATCH] legacymarket: prevent self liquidation on v2x once LM is enabled (#2246) * legacymarket: prevent self liquidation on v2x once LM is enabled * add test case --------- Co-authored-by: meb <4982406+barrasso@users.noreply.github.com> --- contracts/BaseSynthetix.sol | 2 ++ test/contracts/Liquidator.js | 3 +++ 2 files changed, 5 insertions(+) diff --git a/contracts/BaseSynthetix.sol b/contracts/BaseSynthetix.sol index f681782211..80400445a1 100644 --- a/contracts/BaseSynthetix.sol +++ b/contracts/BaseSynthetix.sol @@ -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; diff --git a/test/contracts/Liquidator.js b/test/contracts/Liquidator.js index 61d831e624..3818d3d0e9 100644 --- a/test/contracts/Liquidator.js +++ b/test/contracts/Liquidator.js @@ -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', () => {