The DebtToken contract emits the Transfer event multiple times for the same operation - once in _update()
, once explicitly in mint()
, and once through the parent ERC20
implementation. This redundancy can cause confusion for off-chain applications and indexers tracking token transfers.
The Transfer event is emitted in three locations:
in _update():
In mint():
Through the parent ERC20 implementation when calling _mint() which calls _update() which calls super._update() :
In order to run the test you need to:
Run foundryup
to get the latest version of Foundry
Install hardhat-foundry: npm install --save-dev @nomicfoundation/hardhat-foundry
Import it in your Hardhat config: require("@nomicfoundation/hardhat-foundry");
Make sure you've set the BASE_RPC_URL
in the .env
file or comment out the forking
option in the hardhat config.
Run npx hardhat init-foundry
There is one file in the test folder that will throw an error during compilation so rename the file in test/unit/libraries/ReserveLibraryMock.sol
to => ReserveLibraryMock.sol_broken
so it doesn't get compiled anymore (we don't need it anyways).
Create a new folder test/foundry
Paste the below code into a new test file i.e.: FoundryTest.t.sol
Run the test: forge test --mc FoundryTest -vvvv
If you look at your terminal you can see that three Transfer events get emitted:
There is no direct impact on the protocol but on off-chain applications like blockchain explorers etc.. this leads to:
Confusion for off-chain applications tracking token transfers
Increased gas costs due to redundant event emissions
Potential issues with protocols integrating with the DebtToken that rely on Transfer events
Foundry
Terminal
Manual Review
Remove redundant Transfer event emissions in DebtToken::_update() and mint() and standardize on a single emission point. The recommended approach is to rely on the ERC20 implementation's event emission.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.