-
Notifications
You must be signed in to change notification settings - Fork 75
feat(hubpool): Add Initial initiateRelayerRefund implementation #10
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
Conversation
Signed-off-by: Matt Rice <matthewcrice32@gmail.com>
Co-authored-by: Chris Maree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
| // SPDX-License-Identifier: GPL-3.0-only | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; |
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.
changes in this file were due to running the linter config.
| import "./interfaces/BridgeAdminInterface.sol"; | ||
|
|
||
|
|
||
| contract BridgeAdmin is BridgeAdminInterface { |
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.
why not just import this from uma/core?
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.
Ah I see that this would be a brand new contract
| mapping(address => LPToken) public lpTokens; // Mapping of L1TokenAddress to the associated LPToken. | ||
|
|
||
| // Address of L1Weth. Enable LPs to deposit/receive ETH, if they choose, when adding/removing liquidity. | ||
| WETH9Like public l1Weth; |
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.
in general do we prefer storing contracts as addresses or as interfaces? I stored weth as an address in the SpokePool for example but we should just standardize
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.
ye, good point. my main question which should inform this decision is is this more expensive to store? is this more expensive to use?
my main reason for doing it this way is it means you dont need to do any type casting when using the interface which makes things a bit easier.
contracts/HubPool.sol
Outdated
| IERC20 public bondToken; | ||
|
|
||
| // The bondToken's final fee from the UMA Store is scaled by this number to increase the bonding amount. | ||
| uint256 public bondTokenFinalFeeMultiplier; |
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.
Can we make this a uint64?
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.
for context, I use uint64 for all percentage values in spokepool
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? you dont want a 2^256-1 * final fee?
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.
but ye we can. I'll change the type to uint64
| address _bridgeAdmin, | ||
| address _bondToken, | ||
| uint256 _bondTokenFinalFeeMultiplier, | ||
| address _timerAddress |
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.
nit: group similar types together
contracts/HubPool.sol
Outdated
| *************************************************/ | ||
|
|
||
| function setBondToken(address _bondToken) public onlyOwner { | ||
| bondToken = IERC20(_bondToken); |
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.
These should emit events since they change state
contracts/HubPool.sol
Outdated
| status: RefundRequestStatus.Pending | ||
| }) | ||
| ); | ||
| uint256 relayerRefundId = relayerRefundRequests.length - 1; |
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.
int: should the ID be a smaller type like uint64?
nicholaspai
left a comment
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.
LGTM i agree with the structure but have nits on types
mrice32
left a comment
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.
LGTM! A few minor comments
contracts/HubPool.sol
Outdated
| emit BondTokenSet(newBondToken); | ||
| } | ||
|
|
||
| function setBondTokenFinalFeeMultiplier(uint64 newBondTokenFinalFeeMultiplier) public onlyOwner { |
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.
This is interesting. I totally get the rationale: it's easier to just set the final fees and have this move around as a result since they're kinda a valuation anchor, but do you think this is weird in that it relies on internal UMA system variables for setting its own security bounds? Like if the UMA voting system changed and spam were less of a concern, so final fees were dropped by 95%, we probably wouldn't want this value to change as a result, right?
It's also not super hard to manage this since it's only one bond and one token for the entire Across v2 system.
As a side note: this also means that we need to be sure that the bond token is an approved UMA collateral currency.
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.
this is all true! would you prefer it to simply have one number that is set within the contract and we don't pull anything from the store? my logic was that the store is a reasnoble bond size that can be scaled. we can easily just define one number in this contract that sets the bond for everything
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.
OK I've changed this. we now have a bondAmount that the owner can set. much cleaner
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.
agreed with this, its cleaner and in the same spirit of the UMA final fee
| ); | ||
|
|
||
| // Pull bonds from from the caller. | ||
| bondToken.safeTransferFrom(msg.sender, address(this), bondAmount); |
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.
This is annoying, but how do we deal with a changing bond amount mid-refund? I know this code is to pull the bond, but do you think we need to store the bond amount for each refund request?
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 dont change it if there is a pending refund I guess. if we set the bond as a variable directly (not using the store) this becomes easier.
This was renamed in all other events and function prototypes, but it appears to have been missed here. Having it named relayer rather than exclusiveRelayer creates friction when unpacking the event in the sdk. This PR has already been merged into the public contracts-v2; I'm cherry-picking it here for consistency.
Adds initial
initiateRelayerRefundPR.