-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add LBPool #1001
Add LBPool #1001
Conversation
…ptimize weight validation for 2 weights
…x time to avoid time overflow attack; add misc events and errors; change paused vars to be swapEnabled; add setters and getters for swap enabled/swap fee/gradual update params; add 3 hooks for dynamic swap fee percentage, paused blocking swaps, and only owner can join; build out GradualValueChange library
…henever it's developed
…BP's add liquidity hook; change terminology back to what it originally was in the interface
…outer provider exists
…enable swap fee changes by the assigned admin rather than assuming that power has been delegated to governance
…R rather than the placeholder trusted router provider; leave references in comments for future addition
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.
Looks good! I have a couple of minor comments
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.
Just a few minor comments, but otherwise looks great and makes a lot of sense.
Thanks @gerrrg ! And happy holidays btw :)
I'll take it from here.
// could spoof the address of the owner, allowing anyone to call permissioned functions. | ||
|
||
// solhint-disable-next-line var-name-mixedcase | ||
address private immutable _TRUSTED_ROUTER; |
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 see no reason in principle for this to change, but it does pose a maintainability question in case we ever migrate routers and the SDK / frontend need to adapt.
If we expect the lifecycle of these pools to be rather bounded I guess this is fine, as it's the simplest / cheapest approach.
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.
Also let's add a getter here.
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.
The other reason is Daniel said we did want to support at least two from launch: basic and batch. If we have the registry (see PR #1296), we could use that. It would be equivalent to gerrg's original "provider" idea, and the maintenance would be done in the registry, so we wouldn't need to worry about it here. (And then we don't need a getter.)
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.
It would look like:
IBalancerContractRegistry private immutable _contractRegistry;
constructor(
NewPoolParams memory params,
IVault vault,
address owner,
bool swapEnabledOnStart,
IBalancerContractRegistry contractRegistry
) WeightedPool(params, vault) Ownable(owner) {
_contractRegistry = contractRegistry;
}
onBefore hooks:
{
if (_contractRegistry.isActiveBalancerContract(ContractType.ROUTER, router) == false) {
revert RouterNotTrusted();
}
return IRouterCommon(router).getSender() == owner();
}
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.
The other reason is Daniel said we did want to support at least two from launch: basic and batch. If we have the registry (see PR #1296), we could use that. It would be equivalent to gerrg's original "provider" idea, and the maintenance would be done in the registry, so we wouldn't need to worry about it here. (And then we don't need a getter.)
Sounds like an overkill really.
The trusted router is only used to add liquidity, and block non-owners from adding liquidity. You can still use any router to swap.
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.
Right... so really the only benefit would be not having to redeploy if we update the basic router (which should be rare compared to adding a new router or updating something more relay-like such as the CLR router)
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.
@jubeira good point that the router only affects liquidity provision. Definitely makes it less of an issue, though I do still think it would be best to allow any "approved" router
For more context, the singular trusted router setup that is in the contract was 100% meant to be a placeholder until there was a router provider/contact registry. Simplifying it to be a single router made it possible for me to get unblocked in the meantime
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, I'll double check.
I think this is a good starting point anyways.
* | ||
* @param router The address (usually a router contract) that initiated the add liquidity operation | ||
*/ | ||
function onBeforeAddLiquidity( |
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.
What about initialize?
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.
Well initialize doesn't have the router argument, so we can't do the same approach.
But we can create and initialize in the same tx. I'll add a method in the factory.
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.
Agree with the suggestions; ideally would review and merge the registry, then update this one to use it as a source of trusted routers (or we can add a follow-on PR).
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.
Looks better now; seems the initialization method is still pending? I suppose we could do both: keep the factory method, and also add the onBeforeInitialize hook and check _trustedRouter.getSender()
in it.
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.
Looks good! I'm sure we'll continue to iterate on this in follow-ons, but I think it's a fine starting point.
Co-authored-by: EndymionJkb <[email protected]>
Description
tl;dr: Create a weight shifting LBPool for V3.
Note
This PR replaces and obsoletes #971 by turning it into a PR from the add-lbpool branch from w/in this repo rather than my fork.
What
Create a WeightValidation library for improved portability (could use this in standard WP if desired)FP.ONE
BasePoolTest.sol
) to be more generalizable/override-ableWhy
Modernize a highly popular feature from v2
Type of change
Checklist:
main
, or there's a description of how to mergeIssue Resolution
n/a