Phoenix-Protocol-Group / phoenix-contracts

Source code of the smart contracts of the Phoenix DeFi hub DEX protocol
GNU General Public License v3.0
10 stars 6 forks source link

PHOAM-025: Unused parameter min_bond #358

Closed gangov closed 1 month ago

gangov commented 1 month ago

Location

./contracts/stake_rewards/src/contract.rs:89

Description When initializing the contract, the initialize function below receives a min_bond parameter. However, after being saved into storage, it is not utilized.

fn initialize(
  env: Env,
  admin: Address,
  staking_contract: Address,
  reward_token: Address,
  max_complexity: u32,
  min_reward: i128,
  min_bond: i128,
) {

While this does not pose a risk to the contract's users, having unused parameters and information adds unnecessary complexity to the contract's maintenance and consumes unnecessary storage space.

Recommendation Remove this parameter if it is not used. Also, check for additional unused parameters or variables.

gangov commented 1 month ago

variable in question is being used in stake_rewards/distritubion.rs

pub fn calc_power(
    config: &Config,
    stakes: i128,
    multiplier: Decimal,
    token_per_power: i32,
) -> i128 {
    if stakes < config.min_bond {
        0
    } else {
        stakes * multiplier / token_per_power as i128
    }
}
gangov commented 1 month ago

closing this one as per the last comment

ueco-jb commented 1 month ago

Did you explain this to the coinspect team as well?

gangov commented 1 month ago

Did you explain this to the coinspect team as well?

no, I haven't. Adding it now in a separate msg, besides the sheet update