The home for Hyperlane core contracts, sdk packages, and other infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
hyperlane-monorepo/solidity/contracts/token/extensions/HypFiatToken.sol

33 lines
1.1 KiB

// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity >=0.8.0;
import {IFiatToken} from "../interfaces/IFiatToken.sol";
import {HypERC20Collateral} from "../HypERC20Collateral.sol";
// see https://github.com/circlefin/stablecoin-evm/blob/master/doc/tokendesign.md#issuing-and-destroying-tokens
contract HypFiatToken is HypERC20Collateral {
constructor(
address _fiatToken,
address _mailbox
) HypERC20Collateral(_fiatToken, _mailbox) {}
function _transferFromSender(
uint256 _amount
) internal override returns (bytes memory metadata) {
// transfer amount to address(this)
metadata = super._transferFromSender(_amount);
// burn amount of address(this) balance
IFiatToken(address(wrappedToken)).burn(_amount);
}
function _transferTo(
address _recipient,
uint256 _amount,
bytes calldata /*metadata*/
) internal override {
require(
IFiatToken(address(wrappedToken)).mint(_recipient, _amount),
"FiatToken mint failed"
);
}
}