The function sortArray is only called by getAnchorPrice() in Router.sol
Then it is only used to get the second element of the sorted array.
With this knowledge it is possible to write a function that is more efficient.
Sort functions are relative expensive functions.
Proof of Concept
Router.sol:
function getAnchorPrice() public view returns (uint anchorPrice) {
....
uint[] memory _sortedAnchorFeed = iUTILS(UTILS()).sortArray(arrayPrices);
anchorPrice = _sortedAnchorFeed[2];
Tools Used
Recommended Mitigation Steps
Make a partial sort function that only returns the required value
Handle
gpersoon
Vulnerability details
Impact
The function sortArray is only called by getAnchorPrice() in Router.sol Then it is only used to get the second element of the sorted array. With this knowledge it is possible to write a function that is more efficient. Sort functions are relative expensive functions.
Proof of Concept
Router.sol: function getAnchorPrice() public view returns (uint anchorPrice) { ....
uint[] memory _sortedAnchorFeed = iUTILS(UTILS()).sortArray(arrayPrices);
anchorPrice = _sortedAnchorFeed[2];
Tools Used
Recommended Mitigation Steps
Make a partial sort function that only returns the required value