Minting stake tokens is not updating the pool's borrowing fee rate
Summary
When users mint new stake tokens, they provide liquidity to the pool, increasing the total amount and decreasing the borrowed utilization. However, this rate is not updated.
Vulnerability Detail
When users mint stake tokens, they add liquidity to the pool and increase the total amount held in the pool:
Unfair accrual of borrowing fees. It can yield on lesser/higher fees for lps and position holders. It can also delay or cause unfair liquidations. Hence, high.
mstpr-brainbot
High
Minting stake tokens is not updating the pool's borrowing fee rate
Summary
When users mint new stake tokens, they provide liquidity to the pool, increasing the total amount and decreasing the borrowed utilization. However, this rate is not updated.
Vulnerability Detail
When users mint stake tokens, they add liquidity to the pool and increase the total amount held in the pool:
As we can see, the borrowing rate calculation will change accordingly. However, the rate is not updated:
Impact
Unfair accrual of borrowing fees. It can yield on lesser/higher fees for lps and position holders. It can also delay or cause unfair liquidations. Hence, high.
Code Snippet
https://github.com/sherlock-audit/2024-05-elfi-protocol/blob/8a1a01804a7de7f73a04d794bf6b8104528681ad/elfi-perp-contracts/contracts/process/MintProcess.sol#L45-L91
https://github.com/sherlock-audit/2024-05-elfi-protocol/blob/8a1a01804a7de7f73a04d794bf6b8104528681ad/elfi-perp-contracts/contracts/process/MintProcess.sol#L130-L213
https://github.com/sherlock-audit/2024-05-elfi-protocol/blob/8a1a01804a7de7f73a04d794bf6b8104528681ad/elfi-perp-contracts/contracts/process/MarketQueryProcess.sol#L82C5-L108
Tool used
Manual Review
Recommendation
Just like the opening orders update the rates after the pools base amounts changes.