hats-finance / Common--Stableswap-0xd4d9a2772202ce33b24901d3fc94e95a84b37430

Apache License 2.0
0 stars 0 forks source link

Function can be declared as `&self` isntead of `&mut self` #5

Open hats-bug-reporter[bot] opened 2 months ago

hats-bug-reporter[bot] commented 2 months ago

Github username: @coreggon11 Twitter username: krikoeth Submission hash (on-chain): 0x66b206cbd9a06db535ff0cd9a130935be56ab7a786e7ac1939650f1bf3cb7b7b Severity: low

Description:

Description

The function get_amounts_for_liquidity_mint accepts &mut self as the argument. However, this funciton does not change the contract's state, therefore the self parameter should not be mutable.

Recommendation

Consider changing the function parameter:

        #[ink(message)]
        fn get_amounts_for_liquidity_mint(
-           &mut self,
+           &self,
            liquidity: u128,
        ) -> Result<Vec<u128>, StablePoolError> {
            Ok(math::compute_amounts_given_lp(
                liquidity,
                &self.reserves(),
                self.psp22.total_supply(),
            )?)
        }

The suggested change should also be done in the StablePool trait.

JanKuczma commented 2 months ago

Invalid submission: it does not change the intended behavior of the contract