aavegotchi / aavegotchi-realm-diamond

23 stars 9 forks source link

Call getAvailableAlchemica outside loop in claimAvailableAlchemica function #6

Closed mudgen closed 2 years ago

mudgen commented 2 years ago

getAvailableAlchemica is a fairly gas expensive function with multiple state reads. It is called within a loop in the claimAvailableAlchemica function here: https://github.com/aavegotchi/aavegotchi-realm-diamond/blob/cee38d37307c49dc41cdb737a962d5d313c1cd4f/contracts/RealmDiamond/facets/AlchemicaFacet.sol#L259

It could be called once before the loop, though I see it might be a little difficult to integrate that code.

mudgen commented 2 years ago

Good job.