Skip to content

Commit

Permalink
update to DutchAuction
Browse files Browse the repository at this point in the history
  • Loading branch information
0xdomrom committed Aug 5, 2024
1 parent 7122206 commit db3e861
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/interfaces/IDutchAuction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ interface IDutchAuction {

event AuctionParamsSet(AuctionParams params);

event MtmCutOffSet(int mtmCutOff);

event SMAccountSet(uint smAccount);

event ManagerWhitelisted(address manager, bool whitelisted);
Expand Down
21 changes: 19 additions & 2 deletions src/liquidation/DutchAuction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ contract DutchAuction is IDutchAuction, Ownable2Step, ReentrancyGuard {

mapping(address => bool) public managerWhitelisted;

/// @dev Threshold below which an account gets fully liquidated instead of partially
int public mtmCutoff;

////////////////////////
// Constructor //
////////////////////////
Expand Down Expand Up @@ -104,6 +107,17 @@ contract DutchAuction is IDutchAuction, Ownable2Step, ReentrancyGuard {
emit AuctionParamsSet(_params);
}

/**
* @notice Sets the threshold, below which a bid can liquidate 100% of the account
*/
function setMtmCutoff(int _mtmCutoff) external onlyOwner {
if (_mtmCutoff > 1_000e18) revert DA_InvalidParameter();

mtmCutoff = _mtmCutoff;

emit MtmCutOffSet(_mtmCutoff);
}

/**
* @notice Sets the threshold, below which an auction will block cash withdraw to prevent bank-run
*/
Expand Down Expand Up @@ -231,7 +245,7 @@ contract DutchAuction is IDutchAuction, Ownable2Step, ReentrancyGuard {

/**
* @notice Function used to begin insolvency logic for an auction that started as solvent
* @dev This function can only be called on auctions that has already started as solvent
* @dev This function can only be called on auctions that have already started as solvent and passed the timer
* @param accountId the accountID being liquidated
*/
function convertToInsolventAuction(uint accountId) external nonReentrant {
Expand Down Expand Up @@ -603,9 +617,12 @@ contract DutchAuction is IDutchAuction, Ownable2Step, ReentrancyGuard {
*/
function _getMaxProportion(int markToMarket, int bufferMargin, uint discountPercentage, uint reservedCash)
internal
pure
view
returns (uint)
{
if (markToMarket < mtmCutoff) {
return DecimalMath.UNIT;
}
if (bufferMargin > 0) {
bufferMargin = 0;
}
Expand Down

0 comments on commit db3e861

Please sign in to comment.