Skip to content
Audit finding Intermediate

Debt Decay Faster Than Expected

The debt decay reference time increment is rounded down instead of up, causing debt to decay faster than specified. This leads market makers to sell bond tokens at a lower price than expected.

xiaoming90 Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2022-11-bond-judging/issues/12

Found by

xiaoming90

Summary

The debt decay at a rate faster than expected, causing market makers to sell bond tokens at a lower price than expected.

Vulnerability Detail

The following definition of the debt decay reference time following any purchases at time t taken from the whitepaper. The second variable, which is the delay increment, is rounded up. Following is taken from Page 15 of the whitepaper - Definition 27

However, the actual implementation in the codebase differs from the specification. At Line 514, the delay increment is rounded down instead.

https://github.com/sherlock-audit/2022-11-bond/blob/main/src/bases/BondBaseSDA.sol#L514

Solidity
File: BondBaseSDA.sol
513:         // Set last decay timestamp based on size of purchase to linearize decay
514:         uint256 lastDecayIncrement = debtDecayInterval.mulDiv(payout_, lastTuneDebt);
515:         metadata[id_].lastDecay += uint48(lastDecayIncrement);

Impact

When the delay increment (TD) is rounded down, the debt decay reference time increment will be smaller than expected. The debt component will then decay at a faster rate. As a result, the market price will not be adjusted in an optimized manner, and the market price will fall faster than expected, causing market makers to sell bond tokens at a lower price than expected.

Following is taken from Page 8 of the whitepaper - Definition 8

Code Snippet

https://github.com/sherlock-audit/2022-11-bond/blob/main/src/bases/BondBaseSDA.sol#L514

Tool used

Manual Review

Recommendation

When computing the lastDecayIncrement, the result should be rounded up.

Diff
// Set last decay timestamp based on size of purchase to linearize decay
- uint256 lastDecayIncrement = debtDecayInterval.mulDiv(payout_, lastTuneDebt);
+ uint256 lastDecayIncrement = debtDecayInterval.mulDivUp(payout_, lastTuneDebt);
metadata[id_].lastDecay += uint48(lastDecayIncrement);

Discussion

Evert0x

Message from sponsor


Agree that the rounding should be to match the specification. This was inadvertently changed when another change was implemented. Good catch.

xiaoming9090

Fixed in https://github.com/Bond-Protocol/bonds/commit/071d2a450779dd3413224831934727dcb77e3045

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

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

Root cause

The code used integer division that rounds down (mulDiv) instead of rounding up (mulDivUp) when computing the last decay increment, contrary to the specification.

Impact

The market price falls faster than expected, causing market makers to sell bond tokens at a lower price than expected.

What the attacker needed

None

The fix

The code was fixed by using mulDivUp to round up the lastDecayIncrement.

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 some financial smart contracts, the price of a bond token is adjusted over time through a process called 'debt decay'. The code that calculates how much time to add after a purchase used rounding down instead of rounding up, which made the price drop faster than intended. This meant people selling these tokens got less money than they should have.

More by xiaoming90

View all

122 more disclosed reports, best first.

More from Bond Options

View all

The newest disclosed reports for this program.

Similar reports

Same bug class and techniques, clearest first.