Skip to content
Business logic Audit finding Intermediate

Abrupt fee transition from 8.76% to 1% at slot 250 due to incorrect linear decrease formula

The fee calculation in a bonding curve contract uses a linear decrease formula that does not reach the intended 1% fee at slot 250, causing a sudden drop from 8.76% to 1% at slot 251. This economic discontinuity could lead to unfair fee charges for users trading around that slot.

Evo Follow with 0xcb90f054, Albort and 6 others

Originally disclosed on Code4rena

Submitted by Evo, also found by 0xcb90f054, Albort, Arjuna, debo, ETHworker, ETHworker, ETHworker, and Spearmint

https://github.com/code-423n4/2025-01-pump-science/blob/main/programs/pump-science/src/state/bonding_curve/curve.rs#L31-L41

Fee transition creates a significant 7.76% economic discontinuity at slot 250-251 boundary, causing incorrect fees implementation as protocol intended.

Proof of Concept

The issue occurs in the fee calculation logic in curve.rs:

pub fn calculate_fee(&self, amount: u64, current_slot: u64) -> Result<u64> {
	///code

    if slots_passed < 150 {
        // Phase 1: 99% fees
        sol_fee = bps_mul(9900, amount, 10_000).unwrap();
    } else if slots_passed >= 150 && slots_passed <= 250 {
        // Phase 2: Linear decrease - Issue occurs here
        let fee_bps = (-8_300_000_i64)
            .checked_mul(slots_passed as i64)
            .ok_or(ContractError::ArithmeticError)?
            .checked_add(2_162_600_000)
            .ok_or(ContractError::ArithmeticError)?
            .checked_div(100_000)
            .ok_or(ContractError::ArithmeticError)?;
        sol_fee = bps_mul(fee_bps as u64, amount, 10_000).unwrap();
    } else if slots_passed > 250 {
        // Phase 3: 1% fees
        sol_fee = bps_mul(100, amount, 10_000).unwrap();
    }

The linear decrease formula during Phase 2 (slots 150-250) creates an incorrect transition:

  • Phase 2 last slot (250):

    • Formula: (-8300000 * 250 + 2162600000) / 100000
    • Result: 876 basis points = 8.76% fee
  • Phase 3 first slot (251):

    • Fixed 100 basis points = 1% fee
    • Sudden 7.76% drop from previous slot

Key fee percentages showing the discontinuity:

  • Slot 248: 10.42%
  • Slot 249: 9.59%
  • Slot 250: 8.76%
  • Slot 251: 1.00% (abrupt drop)
  • Slot 252: 1.00%

The linear decrease formula coefficients (-8300000 and 2162600_000) were not properly calibrated to reach 1% at slot 250, causing this economic discontinuity at the phase transition.

Proof of Concept

Typescript simulation:

interface FeeCalculation {
 slot: number;
 feeBps: number;
 feePercentage: number;
 phase: string;
 details?: string;
}

function calculateFee(slot: number): FeeCalculation {
 let feeBps: number;
 let phase: string;
 let details: string = '';

 if (slot < 150) {
   feeBps = 9900;
   phase = "Phase 1: Fixed 99%";
 } else if (slot >= 150 && slot <= 250) {
   const multiplier = -8300000;
   const additive = 2162600000;

   const step1 = multiplier * slot;
   const step2 = step1 + additive;
   feeBps = Math.floor(step2 / 100000);

   phase = "Phase 2: Linear Decrease";
   details = `
     Step 1 (multiply): ${multiplier} * ${slot} = ${step1}
     Step 2 (add): ${step1} + ${additive} = ${step2}
     Step 3 (divide): ${step2} / 100000 = ${feeBps}
   `;
 } else {
   feeBps = 100;
   phase = "Phase 3: Fixed 1%";
 }

 return {
   slot,
   feeBps,
   feePercentage: feeBps / 100,
   phase,
   details
 };
}

function printAllFees(): void {
 for (let slot = 0; slot <= 252; slot++) {
   const result = calculateFee(slot);
   console.log(`Slot ${slot.toString().padStart(3, ' ')}: ${result.feePercentage.toFixed(2)}% - ${result.phase}`);
   if (result.details) {
     console.log(result.details);
   }
   console.log('-'.repeat(50));
 }
}

// Call function to print all fees
printAllFees();

// Test specific slots
const testSlots = [149, 150, 200, 250, 251];
testSlots.forEach(slot => {
 const result = calculateFee(slot);
 console.log(`\nDetailed analysis for slot ${slot}:`);
 console.log(JSON.stringify(result, null, 2));
});

OUTPUT:

LOG]: "Slot 250: 8.76% - Phase 2: Linear Decrease"
[LOG]: "
     Step 1 (multiply): -8300000 * 250 = -2075000000
     Step 2 (add): -2075000000 + 2162600000 = 87600000
     Step 3 (divide): 87600000 / 100000 = 876
   "
[LOG]: "--------------------------------------------------"
[LOG]: "Slot 251: 1.00% - Phase 3: Fixed 1%"
[LOG]: "--------------------------------------------------"
[LOG]: "Slot 252: 1.00% - Phase 3: Fixed 1%"
[LOG]: "--------------------------------------------------"
[LOG]: "
Detailed analysis for slot 149:"
[LOG]: "{
  "slot": 149,
  "feeBps": 9900,
  "feePercentage": 99,
  "phase": "Phase 1: Fixed 99%",
  "details": ""
}"
[LOG]: "
Detailed analysis for slot 150:"
[LOG]: "{
  "slot": 150,
  "feeBps": 9176,
  "feePercentage": 91.76,
  "phase": "Phase 2: Linear Decrease",
  "details": "\n     Step 1 (multiply): -8300000 * 150 = -1245000000\n     Step 2 (add): -1245000000 + 2162600000 = 917600000\n     Step 3 (divide): 917600000 / 100000 = 9176\n   "
}"
[LOG]: "
Detailed analysis for slot 200:"
[LOG]: "{
  "slot": 200,
  "feeBps": 5026,
  "feePercentage": 50.26,
  "phase": "Phase 2: Linear Decrease",
  "details": "\n     Step 1 (multiply): -8300000 * 200 = -1660000000\n     Step 2 (add): -1660000000 + 2162600000 = 502600000\n     Step 3 (divide): 502600000 / 100000 = 5026\n   "
}"
[LOG]: "
Detailed analysis for slot 250:"
[LOG]: "{
  "slot": 250,
  "feeBps": 876,
  "feePercentage": 8.76,
  "phase": "Phase 2: Linear Decrease",
  "details": "\n     Step 1 (multiply): -8300000 * 250 = -2075000000\n     Step 2 (add): -2075000000 + 2162600000 = 87600000\n     Step 3 (divide): 87600000 / 100000 = 876\n   "
}"
[LOG]: "
Detailed analysis for slot 251:"
[LOG]: "{
  "slot": 251,
  "feeBps": 100,
  "feePercentage": 1,
  "phase": "Phase 3: Fixed 1%",
  "details": ""
}"

Recommended Mitigation Steps

Recalibrate the linear decrease formula coefficients to ensure the fee percentage reaches exactly 1% at slot 250, maintaining a smooth transition between Phase 2 and Phase 3.

Kulture (Pump Science) acknowledged


The original report as published on Code4rena, by Evo. 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

Root cause

Likely the linear decrease formula coefficients were not calibrated to reach 1% at slot 250, causing a discontinuity at the phase transition.

Impact

Traders may pay significantly higher fees than intended just before slot 251, and the abrupt drop could distort trading incentives.

What the attacker needed

None

The fix

The linear decrease formula coefficients should be recalibrated to ensure the fee reaches exactly 1% at slot 250, maintaining a smooth transition.

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.

A smart contract charges a fee that decreases over time. The code was supposed to smoothly lower the fee to 1% by a certain point, but instead it jumps from about 9% to 1% in one step. This means users pay much higher fees than expected just before the jump.

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 Evo

View all

7 more disclosed reports, best first.

More from Pump Science

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.