-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v3' into nambrot/default-gas-policy-2
- Loading branch information
Showing
56 changed files
with
720 additions
and
388 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
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,62 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity >=0.8.0; | ||
|
||
import {HypERC20} from "./HypERC20.sol"; | ||
|
||
import {TokenRouter} from "./libs/TokenRouter.sol"; | ||
import {FastTokenRouter} from "./libs/FastTokenRouter.sol"; | ||
import {TokenMessage} from "./libs/TokenMessage.sol"; | ||
|
||
import {ERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; | ||
|
||
/** | ||
* @title Hyperlane ERC20 Token Router that extends ERC20 with remote transfer functionality. | ||
* @author Abacus Works | ||
* @dev Supply on each chain is not constant but the aggregate supply across all chains is. | ||
*/ | ||
contract FastHypERC20 is FastTokenRouter, HypERC20 { | ||
constructor( | ||
uint8 __decimals, | ||
address _mailbox | ||
) HypERC20(__decimals, _mailbox) {} | ||
|
||
/** | ||
* @dev delegates transfer logic to `_transferTo`. | ||
* @inheritdoc TokenRouter | ||
*/ | ||
function _handle( | ||
uint32 _origin, | ||
bytes32 _sender, | ||
bytes calldata _message | ||
) internal virtual override(FastTokenRouter, TokenRouter) { | ||
FastTokenRouter._handle(_origin, _sender, _message); | ||
} | ||
|
||
/** | ||
* @dev Mints `_amount` of tokens to `_recipient`. | ||
* @inheritdoc FastTokenRouter | ||
*/ | ||
function _fastTransferTo( | ||
address _recipient, | ||
uint256 _amount | ||
) internal override { | ||
_mint(_recipient, _amount); | ||
} | ||
|
||
/** | ||
* @dev Burns `_amount` of tokens from `_recipient`. | ||
* @inheritdoc FastTokenRouter | ||
*/ | ||
function _fastRecieveFrom( | ||
address _sender, | ||
uint256 _amount | ||
) internal override { | ||
_burn(_sender, _amount); | ||
} | ||
|
||
function balanceOf( | ||
address _account | ||
) public view virtual override(TokenRouter, HypERC20) returns (uint256) { | ||
return HypERC20.balanceOf(_account); | ||
} | ||
} |
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,61 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity >=0.8.0; | ||
|
||
import {HypERC20Collateral} from "./HypERC20Collateral.sol"; | ||
import {TokenRouter} from "./libs/TokenRouter.sol"; | ||
import {FastTokenRouter} from "./libs/FastTokenRouter.sol"; | ||
|
||
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; | ||
|
||
/** | ||
* @title Hyperlane ERC20 Token Collateral that wraps an existing ERC20 with remote transfer functionality. | ||
* @author Abacus Works | ||
*/ | ||
contract FastHypERC20Collateral is FastTokenRouter, HypERC20Collateral { | ||
using SafeERC20 for IERC20; | ||
|
||
/** | ||
* @notice Constructor | ||
* @param erc20 Address of the token to keep as collateral | ||
* @param _mailbox Address of the mailbox address | ||
*/ | ||
constructor( | ||
address erc20, | ||
address _mailbox | ||
) HypERC20Collateral(erc20, _mailbox) {} | ||
|
||
/** | ||
* @dev delegates transfer logic to `_transferTo`. | ||
* @inheritdoc FastTokenRouter | ||
*/ | ||
function _handle( | ||
uint32 _origin, | ||
bytes32 _sender, | ||
bytes calldata _message | ||
) internal virtual override(FastTokenRouter, TokenRouter) { | ||
FastTokenRouter._handle(_origin, _sender, _message); | ||
} | ||
|
||
/** | ||
* @dev Transfers `_amount` of `wrappedToken` to `_recipient`. | ||
* @inheritdoc FastTokenRouter | ||
*/ | ||
function _fastTransferTo( | ||
address _recipient, | ||
uint256 _amount | ||
) internal override { | ||
wrappedToken.safeTransfer(_recipient, _amount); | ||
} | ||
|
||
/** | ||
* @dev Transfers in `_amount` of `wrappedToken` from `_recipient`. | ||
* @inheritdoc FastTokenRouter | ||
*/ | ||
function _fastRecieveFrom( | ||
address _sender, | ||
uint256 _amount | ||
) internal override { | ||
wrappedToken.safeTransferFrom(_sender, address(this), _amount); | ||
} | ||
} |
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
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.