Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

legacymarket: prevent self liquidation on v2x once LM is enabled #2246

Merged
merged 4 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading