jezer0x/barren-wuffet

Event declared twice

Closed this issue · 2 comments

Psyf commented

The following event is declared twice, one in the Subscriptions.sol Library and once in the ISubscription.sol interface (implemented by Fund.sol).
event Deposit(address subscriber, uint256 subIdx, address token, uint256 balance);

When a Contract uses a library, underneath the hood it is a delegateCall. So when Fund calls a library function from SubLib, it's a delegateCall from Fund to SubLib (which is why libraries can't access storage directly, and have to be passed a pointer specifically).

If we don't include the event in ISubscription however, the event is never emitted (since the abi for Fund doesn't have the event?)

A similar problem arises when we're emitting events from Utils.create_position and Utils.close_positions.

Not having the event in the abi manifests problems in Matcha Tests and The Graph's subgraphs.

There are 2 solutions:

  • copypasta the events in 2 places. Manual and error-prone labour of making sure they're synced.
  • modify the contract such that the library is not responsible for emitting events.
Psyf commented
Psyf commented

Fixed in graph::1c271cf