-
Notifications
You must be signed in to change notification settings - Fork 57
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
feat: universal bridge adapter #233
Conversation
Signed-off-by: Matt Rice <matthewcrice32@gmail.com>
Socket Security Pull Request Report👍 No new dependency issues detected in pull request Pull request report summary
Bot CommandsTo ignore an alert, reply with a comment starting with Powered by socket.dev |
Signed-off-by: Matt Rice <matthewcrice32@gmail.com>
Signed-off-by: Matt Rice <matthewcrice32@gmail.com>
Signed-off-by: Matt Rice <matthewcrice32@gmail.com>
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.
meta level comment: I think it'd be useful to draft the UMIP changes that would lead to this implementation change. I recall when writing the original UMIP that we wish we had made changes to the contract to make the UMIP easier to write
@@ -706,7 +750,16 @@ abstract contract SpokePool is | |||
// Note: use relayAmount as the max amount to send, so the relay is always completely filled by the contract's | |||
// funds in all cases. As this is a slow relay we set the relayerFeePct to 0. This effectively refunds the | |||
// relayer component of the relayerFee thereby only charging the depositor the LpFee. | |||
uint256 fillAmountPreFees = _fillRelay(relayHash, relayData, relayData.amount, 0, true); | |||
uint256 fillAmountPreFees = _fillRelay( |
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.
Does _fillRelay have any new divide by zero or underflow/overflow checks we need to add now that the fees can be negative?
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 can't think of any -- can you? The total fees cannot be 100% or -100%. They are capped at +-50%, so I think the remaining amount is guaranteed to always be >0.
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.
Did a first pass review, haven't reviewed tests yet only solidity files
Signed-off-by: Matt Rice <matthewcrice32@gmail.com>
// Update fill counter. | ||
_updateCountFromFill( | ||
relayFills[relayHash], | ||
relayFills[relayHash] + fillAmountPreFees, |
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 curious, why fillAmountPreFees
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.
Because the method is responsible for removing the LP fee from that to compute the "liabilities" that this chain will have to pay out as a refund. Does that make sense?
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 LGTM but can you explain the following new params:
- local repayment: can repayment chain still be set to any chain? When is this true vs false? What's the purpose?
- payoutAdjustment: How will this be used by dataworker?
I added explanations in the description. Will also look into adding more comments about this in a follow up! |
if (startingFillAmount == 0 && totalFillAmount - endingFillAmount > 0) { | ||
fillCounter[token] += _computeAmountPostFees(totalFillAmount - endingFillAmount, realizedLPFeePct); | ||
} | ||
|
||
// If this is not the first fill, remove the partial fill that was previously assumed. | ||
if (startingFillAmount != 0) { |
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.
Maybe this is premature, but is there a gas optimisation by making these two if statements mutually exclusive? For example:
if (startingFillAmount == 0) {
if (totalFillAmount - endingFillAmount > 0) {
fillCounter[token] += _computeAmountPostFees(totalFillAmount - endingFillAmount, realizedLPFeePct);
}
} else {
// If this is not the first fill, remove the partial fill that was previously assumed (startingFillAmount > 0).
This modifies the SpokePool to support incentives to move tokens to other chains. This is done by establishing a defined ordering of deposits and fills on each chain and rewarding depositors and relayers for moving the tokens towards the right running balance.
Specific changes: