Description:Description: In the current implementation of NominationAgent, funds are not completely withdrawn when an owner attempts to remove an agent. After withdrawing all funds, rewards are distributed in following way:
let incentive = balance * incentive_percentage as u128 / BIPS;
let compound_amount = balance - incentive;
self.staked += compound_amount;
// Bond AZERO to nomination pool
self.env()
.call_runtime(&RuntimeCall::NominationPools(
NominationCall::BondExtra {
extra: BondExtra::FreeBalance {
balance: compound_amount,
}
}
))?;
// Send incentive AZERO to vault which will handle distribution to caller
if incentive > 0 {
Self::env().transfer(vault, incentive)?;
}
it means that the agent tries to stake balance-incentive again. so there is no way to withdraw all funds from the agent.
Impact: Loss of funds for the protocol and users.
Scenario:
The owner wants to remove agent A.
After withdrawing all funds, there is still some remaining balance.
There is no mechanism to withdraw or transfer this remaining balance.
Revised Code File (Optional):
Consider implementing a secondary function that allows the owner to withdraw funds or transfer them to another agent when removing an agent. This ensures that all funds are completely removed from the agent.
Github username: @0xmahdirostami Twitter username: 0xmahdirostami Submission hash (on-chain): 0xfbea11e4b4edcba33cf047244fe121cf1ebd3dcda0135c6e7013da96f384aadf Severity: high
Description: Description: In the current implementation of
NominationAgent
, funds are not completely withdrawn when an owner attempts to remove an agent. After withdrawing all funds, rewards are distributed in following way:it means that the agent tries to stake
balance-incentive
again. so there is no way to withdraw all funds from the agent.Impact: Loss of funds for the protocol and users.
Scenario:
Revised Code File (Optional): Consider implementing a secondary function that allows the owner to withdraw funds or transfer them to another agent when removing an agent. This ensures that all funds are completely removed from the agent.