-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'sprint-1-poc' of github.com:immutable/zkevm-bridge-cont…
…racts into SMR-1773-axelar-local
- Loading branch information
Showing
15 changed files
with
786 additions
and
107 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
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,13 @@ | ||
name: Slither Analysis | ||
|
||
on: [push] | ||
|
||
jobs: | ||
analyze: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: crytic/[email protected] | ||
with: | ||
fail-on: high | ||
slither-args: --filter-paths "./lib|./test" |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: test | ||
name: Build and Test | ||
|
||
on: workflow_dispatch | ||
on: [push] | ||
|
||
env: | ||
FOUNDRY_PROFILE: ci | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity ^0.8.21; | ||
|
||
import {IWIMX} from "../interfaces/child/IWIMX.sol"; | ||
import {Address} from "@openzeppelin/contracts/utils/Address.sol"; | ||
|
||
/** | ||
* @notice WIMX is a wrapped IMX contract that allows users to wrap their native IMX. | ||
* @dev This contract is adapted from the official Wrapped ETH contract. | ||
*/ | ||
contract WIMX is IWIMX { | ||
string public name = "Wrapped IMX"; | ||
string public symbol = "WIMX"; | ||
uint8 public decimals = 18; | ||
|
||
mapping(address => uint256) public balanceOf; | ||
mapping(address => mapping(address => uint256)) public allowance; | ||
|
||
/** | ||
* @notice Fallback function on recieving native IMX. | ||
*/ | ||
receive() external payable { | ||
deposit(); | ||
} | ||
|
||
/** | ||
* @notice Deposit native IMX in the function call and mint the equal amount of wrapped IMX to msg.sender. | ||
*/ | ||
function deposit() public payable { | ||
balanceOf[msg.sender] += msg.value; | ||
emit Deposit(msg.sender, msg.value); | ||
} | ||
|
||
/** | ||
* @notice Withdraw given amount of native IMX to msg.sender and burn the equal amount of wrapped IMX. | ||
* @param wad The amount to withdraw. | ||
*/ | ||
function withdraw(uint256 wad) public { | ||
require(balanceOf[msg.sender] >= wad, "Wrapped IMX: Insufficient balance"); | ||
balanceOf[msg.sender] -= wad; | ||
|
||
Address.sendValue(payable(msg.sender), wad); | ||
emit Withdrawal(msg.sender, wad); | ||
} | ||
|
||
/** | ||
* @notice Obtain the current total supply of wrapped IMX. | ||
* @return uint The amount of supplied wrapped IMX. | ||
*/ | ||
function totalSupply() public view returns (uint256) { | ||
return address(this).balance; | ||
} | ||
|
||
/** | ||
* @notice Approve given spender the ability to spend a given amount of msg.sender's tokens. | ||
* @param guy Approved spender. | ||
* @param wad Amount of allowance. | ||
* @return bool Returns true if function call is successful. | ||
*/ | ||
function approve(address guy, uint256 wad) public returns (bool) { | ||
allowance[msg.sender][guy] = wad; | ||
emit Approval(msg.sender, guy, wad); | ||
return true; | ||
} | ||
|
||
/** | ||
* @notice Transfer given amount of tokens from msg.sender to given destination. | ||
* @param dst Destination of this transfer. | ||
* @param wad Amount of this transfer. | ||
* @return bool Returns true if function call is successful. | ||
*/ | ||
function transfer(address dst, uint256 wad) public returns (bool) { | ||
return transferFrom(msg.sender, dst, wad); | ||
} | ||
|
||
/** | ||
* @notice Transfer given amount of tokens from given source to given destination. | ||
* @param src Source of this transfer. | ||
* @param dst Destination of this transfer. | ||
* @param wad Amount of this transfer. | ||
* @return bool Returns true if function call is successful. | ||
*/ | ||
function transferFrom(address src, address dst, uint256 wad) public returns (bool) { | ||
require(balanceOf[src] >= wad, "Wrapped IMX: Insufficient balance"); | ||
|
||
if (src != msg.sender && allowance[src][msg.sender] != type(uint256).max) { | ||
require(allowance[src][msg.sender] >= wad, "Wrapped IMX: Insufficient allowance"); | ||
allowance[src][msg.sender] -= wad; | ||
} | ||
|
||
balanceOf[src] -= wad; | ||
balanceOf[dst] += wad; | ||
|
||
emit Transfer(src, dst, wad); | ||
|
||
return true; | ||
} | ||
} |
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: Apache 2.0 | ||
pragma solidity ^0.8.21; | ||
|
||
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
|
||
/** | ||
* @dev Interface of Wrapped IMX. | ||
*/ | ||
interface IWIMX is IERC20 { | ||
/** | ||
* @dev Emitted when `value` native IMX are deposited from `account`. | ||
*/ | ||
event Deposit(address indexed account, uint256 value); | ||
|
||
/** | ||
* @dev Emitted when `value` wIMX tokens are withdrawn to `account`. | ||
*/ | ||
event Withdrawal(address indexed account, uint256 value); | ||
|
||
/** | ||
* @notice Deposit native IMX in the function call and mint the equal amount of wrapped IMX to msg.sender. | ||
*/ | ||
function deposit() external payable; | ||
|
||
/** | ||
* @notice Withdraw given amount of native IMX to msg.sender and burn the equal amount of wrapped IMX. | ||
* @param value The amount to withdraw. | ||
*/ | ||
function withdraw(uint256 value) external; | ||
} |
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
Oops, something went wrong.