Skip to content
Business logic Audit finding Intermediate

No incentive to liquidate small positions could result in protocol going underwater

The liquidation reward for small positions is too low to cover gas and trading costs, so liquidators have no incentive to act. This can leave bad debt and potentially make the protocol insolvent.

dimulski Follow with Al-Qa-qa, 0xleadwizard and 29 others

Originally disclosed on Code4rena

Submitted by dimulski, also found by Al-Qa-qa, 0xleadwizard, pontifex, MrPotatoMagic, 0xlemon, igdbase, AvantGard, xiao, SBSecurity, Ocean_Sky, grearlake, Ryonen, Maroutis, OMEN, bhilare_, SpicyMeatball, Bauchibred, fandonov, Cryptor, darksnow, Aamir, web3km, Stefanov, atoko, Giorgio (1, 2), Sabit, Egis_Security, WildSniper, DarkTower, iamandreiski, T1MOH, and Tigerfrake

The DYAD protocol allows users to deposit as little as 1 WEI via the deposit() function; however, in order to mint the DYAD token the protocol requires user to have a collateral ratio of 150% or above. Liquidators liquidate users for the profit they can make. Currently, the DYAD protocol awards the value of the DYAD token burned (1 DYAD token is always equal to $1 when calculated in the liquidate function) + 20% of the collateral left to the liquidator.

  function liquidate(uint id, uint to) external isValidDNft(id) isValidDNft(to) {
      uint cr = collatRatio(id);
      if (cr >= MIN_COLLATERIZATION_RATIO) revert CrTooHigh();
      dyad.burn(id, msg.sender, dyad.mintedDyad(address(this), id));

      uint cappedCr = cr < 1e18 ? 1e18 : cr;
      uint liquidationEquityShare = (cappedCr - 1e18).mulWadDown(LIQUIDATION_REWARD);
      uint liquidationAssetShare = (liquidationEquityShare + 1e18).divWadDown(cappedCr);

      uint numberOfVaults = vaults[id].length();
      for (uint i = 0; i < numberOfVaults; i++) {
          Vault vault = Vault(vaults[id].at(i));
          uint collateral = vault.id2asset(id).mulWadUp(liquidationAssetShare);
          vault.move(id, to, collateral);
      }
      emit Liquidate(id, msg.sender, to);
  }

If there is no profit to be made than there will be no one to call the liquidate function. Consider the following example:

  • User A deposits collateral worth $75, and mint 50 DYAD tokens equal to $50. The collateral ratio is 75/50 = 150%.

  • The price of the provided collateral drops, and now user A collateral is worth $70, 70/50 = 140% collateral ratio. The position should be liquidated now, so the protocol doesn’t become insolvent.

  • We get the following calculation:

    • cr & cappedCr = 1.4e18.
    • liquidationEquityShare = (1.4e18 - 1e18) * 0.2e18 = 80000000000000000 = 0.08e18.
    • liquidationAssetShare = (0.08e18 + 1e18) / 1.4e18 = 771428571428571428 ≈ 0.77e18.
  • The total amount of collateral the liquidator will receive is 70 * 0.77 = $53.9.

  • The dollar amount he spent for the DYAD token is $50 (assuming no depegs) so the profit for the liquidator will be $53.9 - $50 = $3.9.

The protocol will be deployed on Ethereum where gas is expensive. Because the reward the liquidator will receive is low, after gas costs taking into account that most liquidators are bots, and they will have to acquire the DYAD token on an exchange, experience some slippage, swapping fees, and additional gas cost, the total cost to liquidate small positions outweighs the potential profit of liquidators. In the end, these low value accounts will never get liquidated, leaving the protocol with bad debt and can even cause the protocol to go underwater.

Depending on the gas prices at the time of liquidation (liquidity at DEXes can also be taken into account, as less liquidity leads to bigger slippage) positions in the range of $150 - $200 can be unprofitable for liquidators. This attack can be beneficial to a whale, large competitor, or a group of people actively working together to bring down the stable coin. The incentive for them is there if they have shorted the DYAD token with substantial amount of money. The short gains will outweigh the losses they incur by opening said positions to grief the protocol. Also this is crypto, there have been numerous instances of prices dropping rapidly, and usually at that time gas prices are much higher compared to normal market conditions.

Note: The liquidation mechanism is extremely inefficient, as it requires bots to have a note in order to be able to liquidate a position; however, this is a separate issue, as even the inefficiency of the liquidation mechanism is fixed, small positions still won’t be profitable enough for liquidators.

Recommended Mitigation Steps

Consider setting a minimum amount that users have to deposit before they can mint DYAD stable coin. Minimum amount of $500-600 should be good enough.

Assessed type

Context

shafu0x (DYAD) acknowledged and commented via duplicate Issue #1258:

This is a known issue. We normally would just liquidate small position ourselves.


The original report as published on Code4rena, by dimulski. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Impact

Small undercollateralised positions may never be liquidated, leaving the protocol with bad debt and potentially causing it to become insolvent.

What the attacker needed

A position small enough that liquidation profit is low; high gas prices or low DEX liquidity; liquidators are profit-driven bots

The fix

The report recommends setting a minimum deposit amount (e.g., $500–600) before users can mint DYAD; the project acknowledged the issue as known and said they would liquidate small positions themselves.

How it was found

  1. A user deposits collateral worth $75 and mints 50 DYAD tokens, giving a 150% collateral ratio.
  2. The collateral price drops so the position is worth $70, a 140% ratio, which should be liquidated.
  3. The liquidator would receive about $53.9 of collateral for spending $50 on DYAD tokens, a profit of $3.9.
  4. After gas, slippage, and swap fees, this profit is too small, so the liquidator does not act.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

In a lending protocol, if a borrower's collateral falls below a required level, someone else (a liquidator) is supposed to repay the debt and take the collateral at a discount. Here, for small loans, the discount is so small that after paying transaction fees and exchange costs, the liquidator makes no money. So nobody steps in, and the protocol is left holding unpaid debt.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by dimulski

View all

7 more disclosed reports, best first.

More from DYAD

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.