Snowman Merkle Airdrop

First Flight #42
Beginner FriendlyFoundrySolidityNFT
100 EXP
Submission Details
Impact: high
Likelihood: high

Precision Handling Mismatch Causes Economic Model Failure

Author Revealed upon completion

Description

The contract implements a double-precision multiplier (10¹⁸ in constructor + implicit 10¹⁸ in fee calculation) without compensating division. While mathematically consistent with the code, this approach:

  • Forces deployers to use counterintuitive fee values

  • Requires deployers to calculate fees as desired_wei / 10¹⁸

  • Creates 10¹⁸x mismatch between natural inputs and actual economics

Impact:

  • Economic Model Failure: Token pricing becomes impractical

  • Deployer Errors: Guaranteed misconfiguration due to unnatural input requirements

  • Protocol Viability: Real-world usability destroyed unless deployer understands hidden precision requirement

Risk

Likelihood:

• 100% of deployments affected
• Natural inputs cause catastrophic errors
• Requires precise counterintuitive math

Impact:

• Permanent economic failure if misconfigured
• Requires redeployment to correct
• Financial losses guaranteed

Proof of Concept

Normal Deployment Scenario (Disaster):

  • Deployer wants 0.01 ETH/token

  • Sets _buyFee = 0.01 * 10¹⁸ = 10¹⁶ (natural wei conversion)

  • Actual fee per token:

(10¹⁶ × 10¹⁸) = 10³⁴ wei = 10,000,000,000 ETH

Exceeds global ETH supply

Correct Input (Unnatural):

  • Deployer wants 1 ETH/token

  • Must set _buyFee = 1 (not 10¹⁸)

  • Actual fee: (1 × 10¹⁸) wei = 1 ETH` (works but contradicts standard wei practice)

Recommended Mitigation

// OPTION 1: Remove constructor multiplier (recommended)
constructor(...) {
s_buyFee = _buyFee; // Store raw wei value
}
// OPTION 2: Compensate in buySnow
function buySnow(uint256 amount) external payable {
uint256 totalFee = (s_buyFee * amount) / PRECISION;
// ... rest of logic ...
}

Essential Safeguards:

// Validate fee magnitude
require(_buyFee > 1e9 && _buyFee < 1e30, "Invalid fee range");
// Document input requirements
/// @param _buyFee Fee in "precision units" (1 = 10⁻¹⁸ ETH)

Support

FAQs

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