re-al-Foundation / rwa-contracts

0 stars 0 forks source link

[RHR-01M] Inefficient LP Provision Portions #63

Closed chasebrownn closed 5 months ago

chasebrownn commented 5 months ago

RHR-01M: Inefficient LP Provision Portions

Type Severity Location
Mathematical Operations RoyaltyHandler.sol:L263-L264

Description:

The RoyaltyHandler::_handleRoyalties function will inefficiently calculate the portion of funds to swap so as to provide liquidity by dividing the input amount by 2.

Impact:

The liquidity provision mechanism within RoyaltyHandler::_handleRoyalties is presently inefficient and will not be able to provide liquidity reliably for an imbalanced pair.

Example:

// lp
uint256 tokensForEth = amountForLp / 2;
amountForLp -= tokensForEth;

_swapTokensForETH(tokensForEth);
_addLiquidity(amountForLp, WETH.balanceOf(address(this)));

Recommendation:

We advise an efficient LP provision formula to be utilized, such as Alpha Homora's V2 optimal one-sided liquidity provision mechanism, ensuring that the liquidity ultimately provided takes advantage of as many funds as possible.

chasebrownn commented 5 months ago

Acknowledged. I understand this isnt the most efficient method for one-sided LP-injection, but this will suffice until we can come back around post-launch to handle it more effectively. The RoyaltyHandler is meant to be a plug-and-play component to the RWAToken so this contract can easily be upgraded in the near future.