forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 0
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: add BalanceClaimer and contracts update #3
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d508c61
feat: add BalanceClaimer and contracts update
0xRaccoon e97cce4
fix: test rename rollback
0xRaccoon 35f7817
test: add BalanceClaimer unit and integration tests
0xRaccoon deace94
fix: removed balanceClaimer from intialize
0xRaccoon fb17a30
fix: addressed pr comments
0xRaccoon 9176545
fix: tests
0xRaccoon 57d67be
chore: add winddown deploy scripts
0xRaccoon aa30267
fix: polish deploy scripts
0xRaccoon a8e8fe5
fix: addressed pr comments
0xRaccoon 29f8629
fix: constant name in local deploy script
0xRaccoon 1404bca
fix: use snakecase for immutable members
0xRaccoon 028c189
test: medusa testing campaign (#4)
0xteddybear b13bc1b
fix: removed test merkle root
0xRaccoon 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 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,29 @@ | ||
name: CI | ||
|
||
on: [push] | ||
|
||
jobs: | ||
medusa-tests: | ||
name: Medusa Test | ||
runs-on: ubuntu-latest | ||
container: ghcr.io/defi-wonderland/eth-security-toolbox-ci:dev | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Setup Node.js 16.x | ||
uses: actions/setup-node@master | ||
with: | ||
node-version: 16.x | ||
cache: yarn | ||
|
||
- name: Install dependencies | ||
working-directory: ./packages/contracts-bedrock | ||
run: yarn --frozen-lockfile --network-concurrency 1 | ||
|
||
- name: Run Medusa | ||
working-directory: ./packages/contracts-bedrock | ||
run: medusa fuzz --test-limit 200000 |
This file contains 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 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 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
71 changes: 71 additions & 0 deletions
71
packages/contracts-bedrock/contracts/L1/interfaces/winddown/IBalanceClaimer.sol
This file contains 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,71 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.15; | ||
|
||
import { IEthBalanceWithdrawer } from "./IEthBalanceWithdrawer.sol"; | ||
import { IErc20BalanceWithdrawer } from "./IErc20BalanceWithdrawer.sol"; | ||
|
||
|
||
/** | ||
* @title IBalanceClaimer | ||
* @notice Interface for the BalanceClaimer contract | ||
*/ | ||
interface IBalanceClaimer { | ||
/** | ||
* @notice Emitted when a user claims their balance | ||
* @param user The user who claimed their balance | ||
* @param ethBalance The eth balance of the user | ||
* @param erc20TokenBalances The ERC20 token balances of the user | ||
*/ | ||
event BalanceClaimed( | ||
address indexed user, | ||
uint256 ethBalance, | ||
IErc20BalanceWithdrawer.Erc20BalanceClaim[] erc20TokenBalances | ||
); | ||
|
||
/// @notice Thrown when the user has no balance to claim | ||
error NoBalanceToClaim(); | ||
|
||
/// @notice Thrown when the merkle root is invalid | ||
error InvalidMerkleRoot(); | ||
|
||
/// @notice the root of the merkle tree | ||
function ROOT() external view returns (bytes32); | ||
|
||
/// @notice OptimismPortal ethBalanceWithdrawer contract | ||
function ETH_BALANCE_WITHDRAWER() external view returns (IEthBalanceWithdrawer); | ||
|
||
/// @notice erc20BalanceWithdrawer contract | ||
function ERC20_BALANCE_WITHDRAWER() external view returns (IErc20BalanceWithdrawer); | ||
|
||
/// @notice return users who claimed their balances | ||
function claimed(address) external view returns (bool); | ||
|
||
/** | ||
* @notice Claims the tokens for the user | ||
* @param _proof The merkle proof | ||
* @param _user The user address | ||
* @param _ethBalance The eth balance of the user | ||
* @param _erc20Claim The ERC20 tokens balances of the user | ||
*/ | ||
function claim( | ||
bytes32[] calldata _proof, | ||
address _user, | ||
uint256 _ethBalance, | ||
IErc20BalanceWithdrawer.Erc20BalanceClaim[] calldata _erc20Claim | ||
) external; | ||
|
||
/** | ||
* @notice Checks if the user can claim the tokens | ||
* @param _proof The merkle proof | ||
* @param _user The user address | ||
* @param _ethBalance The eth balance of the user | ||
* @param _erc20Claim The ERC20 tokens balances of the user | ||
* @return _canClaimTokens True if the user can claim the tokens | ||
*/ | ||
function canClaim( | ||
bytes32[] calldata _proof, | ||
address _user, | ||
uint256 _ethBalance, | ||
IErc20BalanceWithdrawer.Erc20BalanceClaim[] calldata _erc20Claim | ||
) external view returns (bool _canClaimTokens); | ||
} |
37 changes: 37 additions & 0 deletions
37
packages/contracts-bedrock/contracts/L1/interfaces/winddown/IErc20BalanceWithdrawer.sol
This file contains 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,37 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.15; | ||
|
||
import { IBalanceClaimer } from "./IBalanceClaimer.sol"; | ||
|
||
/** | ||
* @title IErc20BalanceWithdrawer | ||
* @notice Interface for the Erc20BalanceWithdrawer contract | ||
*/ | ||
interface IErc20BalanceWithdrawer { | ||
/** | ||
* @notice Struct for ERC20 balance claim | ||
* @param token The ERC20 token address | ||
* @param balance The balance of the user | ||
*/ | ||
struct Erc20BalanceClaim { | ||
address token; | ||
uint256 balance; | ||
} | ||
|
||
/// @notice Thrown when the caller is not the BalanceClaimer contract | ||
error CallerNotBalanceClaimer(); | ||
|
||
/** | ||
* @notice Withdraws the ERC20 balance to the user. | ||
* @param _user Address of the user. | ||
* @param _erc20Claim Array of Erc20BalanceClaim structs containing the token address | ||
*/ | ||
function withdrawErc20Balance(address _user, Erc20BalanceClaim[] calldata _erc20Claim) | ||
external; | ||
|
||
/** | ||
* @notice Address of the balance claimer contract. | ||
* @dev This contract is responsible for claiming the ERC20 balances of the bridge. | ||
*/ | ||
function BALANCE_CLAIMER() external view returns (address); | ||
} |
30 changes: 30 additions & 0 deletions
30
packages/contracts-bedrock/contracts/L1/interfaces/winddown/IEthBalanceWithdrawer.sol
This file contains 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,30 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.15; | ||
|
||
import { IBalanceClaimer } from "./IBalanceClaimer.sol"; | ||
|
||
/** | ||
* @title IEthBalanceWithdrawer | ||
* @notice Interface for the EthBalanceWithdrawer contract | ||
*/ | ||
interface IEthBalanceWithdrawer { | ||
/// @notice Thrown when the caller is not the BalanceClaimer contract | ||
error CallerNotBalanceClaimer(); | ||
|
||
/// @notice Thrown when the eth transfer fails | ||
error EthTransferFailed(); | ||
|
||
/** | ||
* @notice Withdraws the ETH balance to the user. | ||
* @param _user Address of the user. | ||
* @param _ethClaim Amount of ETH to withdraw. | ||
* @dev This function is only callable by the BalanceClaimer contract. | ||
*/ | ||
function withdrawEthBalance(address _user, uint256 _ethClaim) external; | ||
|
||
/** | ||
* @notice Address of the BalanceClaimer contract. | ||
* @dev This contract is responsible for claiming the ETH balances of the OptimismPortal. | ||
*/ | ||
function BALANCE_CLAIMER() external view returns (address); | ||
} |
Oops, something went wrong.
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.
can we check
/packages/contracts-bedrock/README.md
?Specifically that is mandatory to use foundry version:
foundryup -C da2392e58bb8a7fefeba46b40c4df1afad8ccd22