-
Notifications
You must be signed in to change notification settings - Fork 75
feat: add slow relay functionality #28
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
976af4b
feat: add slow relay functionality
mrice32 1ffad81
WIP
mrice32 abeee00
WIP
mrice32 13472b8
WIP
mrice32 3fae4b0
WIP
mrice32 4ebec18
Merge branch 'master' into slow_relay
mrice32 4485b80
fixes
mrice32 2e2ce87
WIP
mrice32 ed1cb93
Apply suggestions from code review
mrice32 c760af8
WIP
mrice32 204f134
Merge branch 'master' into slow_relay
mrice32 acbfbd7
update names
mrice32 84d05a3
correct find and replace
mrice32 385e0b5
WIP
mrice32 42565d4
WIP
mrice32 e3aaf76
WIP
mrice32 cbc55f1
WIP
mrice32 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| // SPDX-License-Identifier: GPL-3.0-only | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
| import "./interfaces/AdapterInterface.sol"; | ||
|
|
||
| interface HubPoolInterface { | ||
| struct PoolRebalanceLeaf { | ||
| // Used as the index in the bitmap to track whether this leaf has been executed or not. | ||
| uint256 leafId; | ||
| // This is used to know which chain to send cross-chain transactions to (and which SpokePool to sent to). | ||
| uint256 chainId; | ||
| // The following arrays are required to be the same length. They are parallel arrays for the given chainId and should be ordered by the `l1Tokens` field. | ||
| // All whitelisted tokens with nonzero relays on this chain in this bundle in the order of whitelisting. | ||
| address[] l1Tokens; | ||
| uint256[] bundleLpFees; // Total LP fee amount per token in this bundle, encompassing all associated bundled relays. | ||
| // This array is grouped with the two above, and it represents the amount to send or request back from the | ||
| // SpokePool. If positive, the pool will pay the SpokePool. If negative the SpokePool will pay the HubPool. | ||
| // There can be arbitrarily complex rebalancing rules defined offchain. This number is only nonzero | ||
| // when the rules indicate that a rebalancing action should occur. When a rebalance does not occur, | ||
| // runningBalances for this token should change by the total relays - deposits in this bundle. When a rebalance | ||
| // does occur, runningBalances should be set to zero for this token and the netSendAmounts should be set to the | ||
| // previous runningBalances + relays - deposits in this bundle. | ||
| int256[] netSendAmounts; | ||
| // This is only here to be emitted in an event to track a running unpaid balance between the L2 pool and the L1 pool. | ||
| // A positive number indicates that the HubPool owes the SpokePool funds. A negative number indicates that the | ||
| // SpokePool owes the HubPool funds. See the comment above for the dynamics of this and netSendAmounts | ||
| int256[] runningBalances; | ||
| } | ||
|
|
||
| function setBond(IERC20 newBondToken, uint256 newBondAmount) external; | ||
|
|
||
| function setCrossChainContracts( | ||
| uint256 l2ChainId, | ||
| address adapter, | ||
| address spokePool | ||
| ) external; | ||
|
|
||
| function whitelistRoute( | ||
| uint256 destinationChainId, | ||
| address originToken, | ||
| address destinationToken | ||
| ) external; | ||
|
|
||
| function enableL1TokenForLiquidityProvision(address l1Token, bool isWeth) external; | ||
|
|
||
| function disableL1TokenForLiquidityProvision(address l1Token) external; | ||
|
|
||
| function addLiquidity(address l1Token, uint256 l1TokenAmount) external payable; | ||
|
|
||
| function removeLiquidity( | ||
| address l1Token, | ||
| uint256 lpTokenAmount, | ||
| bool sendEth | ||
| ) external; | ||
|
|
||
| function exchangeRateCurrent(address l1Token) external returns (uint256); | ||
|
|
||
| function liquidityUtilizationPostRelay(address token, uint256 relayedAmount) external returns (uint256); | ||
|
|
||
| function initiateRelayerRefund( | ||
| uint256[] memory bundleEvaluationBlockNumbers, | ||
| uint64 poolRebalanceLeafCount, | ||
| bytes32 poolRebalanceRoot, | ||
| bytes32 destinationDistributionRoot, | ||
| bytes32 slowRelayFulfillmentRoot | ||
| ) external; | ||
|
|
||
| function executeRelayerRefund(PoolRebalanceLeaf memory poolRebalanceLeaf, bytes32[] memory proof) external; | ||
|
|
||
| function disputeRelayerRefund() external; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
+1 moving these to the spoke/hub pool interface i think that makes a lot of sense