#37807 [SC-Insight] Truncation of mint_amount to zero leading to potential stake loss
Submitted on Dec 16th 2024 at 13:53:22 UTC by @danvinci_20 for Audit Comp | Folks: Liquid Staking
Report ID: #37807
Report Type: Smart Contract
Report severity: Insight
Target: https://github.com/Folks-Finance/algo-liquid-staking-contracts/blob/8bd890fde7981335e9b042a99db432e327681e1a/contracts/xalgo/consensus_v2.py
Impacts:
Griefing (e.g. no profit motive for an attacker, but damage to the users or the protocol)
Description
Brief/Intro
The calculation of the mint_amount in the current implementation of the claim_delay_mint can be truncated to zero if the numerator= (delay_mint_stake× get_x_algo_circulating_supply) is less than the denominator the current algo_balance, this leading to total loss of value especially by small stakes this is possible since the algo_balance can increase over time due to the rewards while the x_algo_citculating_supply remains constant,
Vulnerability Details
This is the current implented functionality it doesn't check for zero-value mint amount and this can lead to loss of value, also the mint_amount is integer type variables and cannot store floating values
The code can be resolved by adding the following line :
This ensure that the execution is reverted for zero amount mint_value to ensure that value are not loss by users most especially small stakers, since the box that contains the minting details is deleted afterwards
Impact details
Likelihood: Moderate (it occurs most times when staked values are small). Impact: High it results in complete loss of stake for affected users
Resolution
Another implementation is to set a minimum value on the amount that can be staked in the implementation of the delay_mint functionality to prevent users from staking very small values.
Proof of Concept
Proof of Concept
Was this helpful?