// Calculate the entitlement per token held
uint256 supply = this.totalSupply();
for (uint i = 0; i < distributableERC20s.length; i++) {
uint256 balance = IERC20(distributableERC20s[i]).balanceOf(
address(this)
);
uint256 entitlement = balance / supply;
>> erc20EntitlementPerUnit.push(entitlement);
}
Note that the entitlements are pushed into the array in the same order that tokens are stored in distributableERC20s. If the contract owner attempts to change distributable tokens with setDistributableERC20s during the distribution phase
function setDistributableERC20s(
address[] memory _distributableERC20s
) public onlyOwner {
distributableERC20s = _distributableERC20s;
}
Judge has assessed an item in Issue #51 as 2 risk. The relevant finding follows:
Updating distributableERC20s array during distribution phase may break the entitlement accounting
https://github.com/code-423n4/2024-02-althea-liquid-infrastructure/blob/main/liquid-infrastructure/contracts/LiquidInfrastructureERC20.sol#L205 When
distribute
function is called, the contract precalculates entitlement values for tokens stored indistributableERC20s
arrayNote that the entitlements are pushed into the array in the same order that tokens are stored in
distributableERC20s
. If the contract owner attempts to change distributable tokens withsetDistributableERC20s
during the distribution phase, and new tokens are stored in a different order, wrong amounts will be distributed. https://github.com/code-423n4/2024-02-althea-liquid-infrastructure/blob/main/liquid-infrastructure/contracts/LiquidInfrastructureERC20.sol#L220
Consider adding this check to
setDistributableERC20s