-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fee accrual as 1155 balance #289
Conversation
protocolFeesAccrued[currency] -= amountCollected; | ||
amountCollected = (amount == 0) ? balanceOf(address(protocolFeeController), currency.toId()) : amount; | ||
|
||
_burn(address(protocolFeeController), currency.toId(), amountCollected); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not an official reviewer so I could be wrong. I just want someone more knowledgeable to take a look.
I wonder if we want to call _burn
when msg.sender == address(protocolFeeController)
since it's calling currency.transfer
below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review!
In this singleton design, all ERC20s are held by the Pool Manager contract. Individual pool balances of ERC20s (aka currencies) are being accounted for within this Pool Manager contract.
This internal call burn()
is decreasing the ERC1155 balance (or "internal" balance) of the protocol fee controller's fee token (some ERC20). Then, currency.transfer
is transferring (ERC20.transfer()
) the fee token rom the pool manager to the (external) protocol fee controller.
Let me know if that makes sense or if I'm misunderstanding something! Thanks!
recipient = (recipient == address(0)) ? hookAddress : recipient; | ||
|
||
hookFeesAccrued[hookAddress][currency] -= amountCollected; | ||
_burn(hookAddress, currency.toId(), amountCollected); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
thanks for the PR @kevin-fruitful (and @hiroshitash for the review)! i'm inclined to leave this on ice for a while, not because it's bad, but because a) the state of 1155 tokens in the pool manager is a bit up in the air (see #294), and b) using 1155 balances would probably complicate designs where custom hooks are custodying funds as 1155 balances keeping the PR open as a reference though, and it might make sense to merge depending on where we land with 1155! |
Hi! Going to close this PR now for a few reasons
Thanks again for your submission |
Related Issue
Referencing issue #203
Description of changes
Removed the 2 mappings
protocolFeesAccrued
andhookFeesAccrued
.swap
andmodifyPosition
now mint ERC1155 currencies to theprotocolFeeController
and a pool'shook
contract.collectProtocolFees
andcollectHookFees
now burn ERC1155 currencies.Respective tests have been updated. Implemented
onERC1155Received
andonERC1155BatchReceived
forProtocolFeeControllerTest
andMockHooks
test contracts.Additional thoughts
Change
_balances
from private to internal such that the variable can be read directly instead of going throughbalanceOf
.