sujithsomraaj / lifi-stargate-v2-audit

3 Day Review [10 Jun 2024 - 13 Jun 2024]
0 stars 0 forks source link

Remove unused `receive` function in `StargateFacetV2` #6

Open sujithsomraaj opened 5 months ago

sujithsomraaj commented 5 months ago

Context: StargateFacetV2.sol#L165

Description: The receive function accepts native token transfers to the contract. However, there is no direct use case for the functions in the StargateFacetV2 contract; if so, they could be well documented. Since most functions are payable, there is no explicit requirement for an additional receiving function.

Recommendation: Add relevant documentation on why the receive function is required. Else consider removing it if not explicitly required to avoid handling unexpected native token transfers into the diamond contract.

LI.FI:

Researcher:

0xDEnYO commented 5 months ago

There is a variety of use cases that require a receive function. e.g. if we swap from ERC20 to Native prior to bridging as well as in case of potential refunds. Our diamond has a receive function so usually it is covered by that and facets dont need their own. However, the facet contract is not (fully) usable as standalone contract if it doesnt have that receive function (although we are not using it standalone). Therefore I would leave it in there since it makes the contract "complete" (and doesnt cost much more to deploy).

Other opinions? @maxklenk

maxklenk commented 5 months ago

As the facets should not be called directly we don't really need that. Also we don't have it in our Facets as far as I know. Funds sent directly to the facets would not be recoverable. I would remove it.

0xDEnYO commented 5 months ago

Removed