forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add BalanceClaimer and contracts update (#3)
feat: add BalanceClaimer and contracts update --------- Signed-off-by: 0xRaccoon <[email protected]> Co-authored-by: teddy <[email protected]>
- Loading branch information
1 parent
df11f76
commit e0d5c85
Showing
34 changed files
with
2,821 additions
and
23 deletions.
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.