Skip to content

Commit 437f62f

Browse files
authored
SIP-194 Fix Liquidations on L2 (#1621)
1 parent e1cdc23 commit 437f62f

File tree

4 files changed

+40
-46
lines changed

4 files changed

+40
-46
lines changed

contracts/BaseSynthetix.sol

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,22 @@ contract BaseSynthetix is IERC20, ExternStateToken, MixinResolver, ISynthetix {
305305
return issuer().burnSynthsToTargetOnBehalf(burnForAddress, messageSender);
306306
}
307307

308+
function liquidateDelinquentAccount(address account, uint susdAmount)
309+
external
310+
systemActive
311+
optionalProxy
312+
returns (bool)
313+
{
314+
(uint totalRedeemed, uint amountLiquidated) =
315+
issuer().liquidateDelinquentAccount(account, susdAmount, messageSender);
316+
317+
emitAccountLiquidated(account, totalRedeemed, amountLiquidated, messageSender);
318+
319+
// Transfer SNX redeemed to messageSender
320+
// Reverts if amount to redeem is more than balanceOf account, ie due to escrowed balance
321+
return _transferByProxy(account, messageSender, totalRedeemed);
322+
}
323+
308324
function exchangeWithTrackingForInitiator(
309325
bytes32,
310326
uint,
@@ -337,10 +353,6 @@ contract BaseSynthetix is IERC20, ExternStateToken, MixinResolver, ISynthetix {
337353
_notImplemented();
338354
}
339355

340-
function liquidateDelinquentAccount(address, uint) external returns (bool) {
341-
_notImplemented();
342-
}
343-
344356
function mintSecondary(address, uint) external {
345357
_notImplemented();
346358
}
@@ -396,6 +408,25 @@ contract BaseSynthetix is IERC20, ExternStateToken, MixinResolver, ISynthetix {
396408
}
397409

398410
// ========== EVENTS ==========
411+
event AccountLiquidated(address indexed account, uint snxRedeemed, uint amountLiquidated, address liquidator);
412+
bytes32 internal constant ACCOUNTLIQUIDATED_SIG = keccak256("AccountLiquidated(address,uint256,uint256,address)");
413+
414+
function emitAccountLiquidated(
415+
address account,
416+
uint256 snxRedeemed,
417+
uint256 amountLiquidated,
418+
address liquidator
419+
) internal {
420+
proxy._emit(
421+
abi.encode(snxRedeemed, amountLiquidated, liquidator),
422+
2,
423+
ACCOUNTLIQUIDATED_SIG,
424+
addressToBytes32(account),
425+
0,
426+
0
427+
);
428+
}
429+
399430
event SynthExchange(
400431
address indexed account,
401432
bytes32 fromCurrencyKey,

contracts/Synthetix.sol

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -167,22 +167,6 @@ contract Synthetix is BaseSynthetix {
167167
return true;
168168
}
169169

170-
function liquidateDelinquentAccount(address account, uint susdAmount)
171-
external
172-
systemActive
173-
optionalProxy
174-
returns (bool)
175-
{
176-
(uint totalRedeemed, uint amountLiquidated) =
177-
issuer().liquidateDelinquentAccount(account, susdAmount, messageSender);
178-
179-
emitAccountLiquidated(account, totalRedeemed, amountLiquidated, messageSender);
180-
181-
// Transfer SNX redeemed to messageSender
182-
// Reverts if amount to redeem is more than balanceOf account, ie due to escrowed balance
183-
return _transferByProxy(account, messageSender, totalRedeemed);
184-
}
185-
186170
/* Once off function for SIP-60 to migrate SNX balances in the RewardEscrow contract
187171
* To the new RewardEscrowV2 contract
188172
*/
@@ -196,24 +180,6 @@ contract Synthetix is BaseSynthetix {
196180
}
197181

198182
// ========== EVENTS ==========
199-
event AccountLiquidated(address indexed account, uint snxRedeemed, uint amountLiquidated, address liquidator);
200-
bytes32 internal constant ACCOUNTLIQUIDATED_SIG = keccak256("AccountLiquidated(address,uint256,uint256,address)");
201-
202-
function emitAccountLiquidated(
203-
address account,
204-
uint256 snxRedeemed,
205-
uint256 amountLiquidated,
206-
address liquidator
207-
) internal {
208-
proxy._emit(
209-
abi.encode(snxRedeemed, amountLiquidated, liquidator),
210-
2,
211-
ACCOUNTLIQUIDATED_SIG,
212-
addressToBytes32(account),
213-
0,
214-
0
215-
);
216-
}
217183

218184
event AtomicSynthExchange(
219185
address indexed account,

publish/releases.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,11 @@
413413
"layer": "both",
414414
"sources": ["WrapperFactory"],
415415
"released": "both"
416+
},
417+
{
418+
"sip": 194,
419+
"layer": "ovm",
420+
"sources": ["Synthetix"]
416421
}
417422
],
418423
"releases": [

test/contracts/BaseSynthetix.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,6 @@ contract('BaseSynthetix', async accounts => {
183183
});
184184
});
185185

186-
it('liquidateDelinquentAccount should revert no matter who the caller is', async () => {
187-
await onlyGivenAddressCanInvoke({
188-
fnc: baseSynthetix.liquidateDelinquentAccount,
189-
accounts,
190-
args: [account1, amount],
191-
reason: 'Cannot be run on this layer',
192-
});
193-
});
194186
it('mintSecondary should revert no matter who the caller is', async () => {
195187
await onlyGivenAddressCanInvoke({
196188
fnc: baseSynthetix.mintSecondary,

0 commit comments

Comments
 (0)