Skip to content
Business logic Audit finding Beginner

No related function to set fee_protocol

The pool contract defines a protocol fee rate but provides no function to set it, so the protocol can never accumulate fees. An attacker cannot exploit this; it is a missing feature that prevents the protocol from earning revenue.

shaflow2 Follow with prapandey031, zhaojohnson and 4 others

Originally disclosed on Code4rena

Submitted by shaflow2, also found by prapandey031, zhaojohnson, DadeKuma, peanuts, oakcobalt, and wasm_it

There are no related functions to set fee_protocol, which prevents the protocol from accumulating protocol fees.

Proof of Concept

The pool contract defines the protocol fee rate fee_protocol, but there is no function to set it.

#[solidity_storage]
pub struct StoragePool {
    ...
    fee_protocol: StorageU8,
    fee_growth_global_0: StorageU256,
    fee_growth_global_1: StorageU256,
    protocol_fee_0: StorageU128,
    protocol_fee_1: StorageU128,
    ...
}

The contract also defines the collect_protocol and collect_protocol_7540_F_A_9_F functions to collect fees. However, since the protocol fee rate cannot be set, the protocol will never accumulate any protocol fees.

pkg/seawater/src/lib.rs

    #[allow(non_snake_case)]
    pub fn collect_protocol_7540_F_A_9_F(
        &mut self,
        pool: Address,
        amount_0: u128,
        amount_1: u128,
        recipient: Address,
    ) -> Result<(u128, u128), Revert> {
        ...
    }

pkg/seawater/src/pool.rs

    pub fn collect_protocol(
        &mut self,
        amount_0: u128,
        amount_1: u128,
    ) -> Result<(u128, u128), Revert> {
        ...
    }

Recommended Mitigation Steps

Add the relevant functions to enable protocol fees.

pkg/seawater/src/pool.rs:

+    pub fn set_fee_protocol(&mut self, new_fee_protocol: U256) {
+        self.fee_protocol.set(new_fee_protocol);
+    }

pkg/seawater/src/lib.rs:

+    #[allow(non_snake_case)]
+    pub fn set_fee_protocol(
+        &mut self,
+        pool: Address,
+        new_fee_protocol: U256,
+    ) -> Result<(), Revert> {
+        assert_eq_or!(
+            msg::sender(),
+            self.seawater_admin.get(),
+            Error::SeawaterAdminOnly
+        );
+
+        self.pools.setter(pool).set_fee_protocol(new_fee_protocol);
+
+        Ok(())
+    }

af-afk (Superposition) confirmed and commented:

See commit.

0xsomeone (judge) commented:

The submission and its duplicates have correctly identified that there is no mechanism to set the protocol fee in the system, causing fees to never accumulate in the current implementation.

I believe a severity of medium is appropriate given that its only harm is prospective earnings for the protocol itself.


The original report as published on Code4rena, by shaflow2. 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 contract lacks a setter function for the protocol fee rate, leaving it at its default value.

Impact

The protocol cannot accumulate any protocol fees, resulting in lost prospective earnings.

What the attacker needed

None

The fix

Add a function to set the protocol fee rate, restricted to the admin, as was done in a later commit.

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 has a setting for a fee that the protocol should earn, but there is no way to change that setting from its default value. Because the setting stays at zero, the protocol never collects any fees, even though the code to collect them exists.

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 shaflow2

View all

12 more disclosed reports, best first.

More from Superposition

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.