DeFiFoundry
20,000 USDC
View results
Submission Details
Severity: medium
Invalid

FjordToken should be burnable

Summary

The Fjord token, as described in its documentation, is expected to include a burnable feature. However, the current implementation of the Fjord token contract lacks the necessary functions to support token burning. This report identifies the impact of this missing functionality and provides a solution to implement the burn feature.

Vulnerability Details

As you can see from the code below function for burning is missing, consider adding it to the code.

// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity =0.8.21;
import { ERC20 } from "solmate/tokens/ERC20.sol";
contract FjordToken is ERC20 {
constructor() ERC20("Fjord Foundry", "FJO", 18) {
_mint(msg.sender, 100_000_000 ether);
}
}

Impact

Non-compliance with Documentation: Users and developers relying on the documentation will expect burn functionality, leading to confusion and potential loss of trust when they find it missing.

Tools Used

Manual Review

Recommendations

To address this issue, the following burn functions should be added to the FjordToken contract:

Burn Function:

  • Allows token holders to destroy a specified amount of their own tokens.

Burn From Function:

  • Allows an account to burn tokens from another account, given that the caller has sufficient allowance.

Here is the modified contract with the added burn functionality:

// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity =0.8.21;
import { ERC20 } from "solmate/tokens/ERC20.sol";
contract FjordToken is ERC20 {
constructor() ERC20("Fjord Foundry", "FJO", 18) {
_mint(msg.sender, 100_000_000 ether);
}
+ function burn(uint256 amount) external {
+ _burn(msg.sender, amount);
+ }
+ function burnFrom(address account, uint256 amount) external {
+ uint256 currentAllowance = allowance[account][msg.sender];
+ if (currentAllowance != type(uint256).max) {
+ require(currentAllowance >= amount, "ERC20: insufficient allowance");
+ unchecked {
+ approve(account, currentAllowance - amount);
+ }
+ }
+ _burn(account, amount);
+ }
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.