编译器
0.8.20+commit.a1b79de6
文件 1 的 25:AccessControl.sol
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
return _roles[role].members[account];
}
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(account),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
return _roles[role].adminRole;
}
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}
文件 2 的 25:Address.sol
pragma solidity ^0.8.1;
library Address {
function isContract(address account) internal view returns (bool) {
return account.code.length > 0;
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
文件 3 的 25:Context.sol
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
文件 4 的 25:ECDSA.sol
pragma solidity ^0.8.0;
import "../Strings.sol";
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return;
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
}
}
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {
assembly {
mstore(0x00, "\x19Ethereum Signed Message:\n32")
mstore(0x1c, hash)
message := keccak256(0x00, 0x3c)
}
}
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
}
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {
assembly {
let ptr := mload(0x40)
mstore(ptr, "\x19\x01")
mstore(add(ptr, 0x02), domainSeparator)
mstore(add(ptr, 0x22), structHash)
data := keccak256(ptr, 0x42)
}
}
function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x00", validator, data));
}
}
文件 5 的 25:ERC165.sol
pragma solidity ^0.8.0;
import "./IERC165.sol";
abstract contract ERC165 is IERC165 {
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
文件 6 的 25:EnumerableSet.sol
pragma solidity ^0.8.0;
library EnumerableSet {
struct Set {
bytes32[] _values;
mapping(bytes32 => uint256) _indexes;
}
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
function _remove(Set storage set, bytes32 value) private returns (bool) {
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
set._values[toDeleteIndex] = lastValue;
set._indexes[lastValue] = valueIndex;
}
set._values.pop();
delete set._indexes[value];
return true;
} else {
return false;
}
}
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
struct Bytes32Set {
Set _inner;
}
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
assembly {
result := store
}
return result;
}
struct AddressSet {
Set _inner;
}
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
assembly {
result := store
}
return result;
}
struct UintSet {
Set _inner;
}
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
assembly {
result := store
}
return result;
}
}
文件 7 的 25:EthenaMinting.sol
pragma solidity 0.8.20;
import "./SingleAdminAccessControl.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "@openzeppelin/contracts/interfaces/IERC1271.sol";
import "./interfaces/IUSDe.sol";
import "./interfaces/IEthenaMinting.sol";
import "./interfaces/IWETH9.sol";
contract EthenaMinting is IEthenaMinting, SingleAdminAccessControl, ReentrancyGuard {
using SafeERC20 for IERC20;
using EnumerableSet for EnumerableSet.AddressSet;
bytes32 private constant EIP712_DOMAIN =
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
bytes32 private constant ROUTE_TYPE = keccak256("Route(address[] addresses,uint128[] ratios)");
bytes32 private constant ORDER_TYPE = keccak256(
"Order(string order_id,uint8 order_type,uint128 expiry,uint120 nonce,address benefactor,address beneficiary,address collateral_asset,uint128 collateral_amount,uint128 usde_amount)"
);
bytes32 private constant MINTER_ROLE = keccak256("MINTER_ROLE");
bytes32 private constant REDEEMER_ROLE = keccak256("REDEEMER_ROLE");
bytes32 private constant COLLATERAL_MANAGER_ROLE = keccak256("COLLATERAL_MANAGER_ROLE");
bytes32 private constant GATEKEEPER_ROLE = keccak256("GATEKEEPER_ROLE");
bytes32 private constant EIP712_DOMAIN_TYPEHASH = keccak256(abi.encodePacked(EIP712_DOMAIN));
bytes4 private constant EIP1271_MAGICVALUE = bytes4(keccak256("isValidSignature(bytes32,bytes)"));
address private constant NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
bytes32 private constant EIP_712_NAME = keccak256("EthenaMinting");
bytes32 private constant EIP712_REVISION = keccak256("1");
uint128 private constant ROUTE_REQUIRED_RATIO = 10_000;
uint128 private constant STABLES_RATIO_MULTIPLIER = 10000;
IWETH9 private immutable WETH;
IUSDe public immutable usde;
EnumerableSet.AddressSet private _whitelistedBenefactors;
mapping(address => EnumerableSet.AddressSet) private _approvedBeneficiariesPerBenefactor;
EnumerableSet.AddressSet private _custodianAddresses;
uint256 private immutable _chainId;
bytes32 private immutable _domainSeparator;
mapping(address => mapping(uint256 => uint256)) private _orderBitmaps;
mapping(address => mapping(address => DelegatedSignerStatus)) public delegatedSigner;
uint128 public stablesDeltaLimit;
GlobalConfig public globalConfig;
mapping(uint256 => BlockTotals) public totalPerBlock;
mapping(uint256 => mapping(address => BlockTotals)) public totalPerBlockPerAsset;
mapping(address => TokenConfig) public tokenConfig;
modifier belowMaxMintPerBlock(uint128 mintAmount, address asset) {
TokenConfig memory _config = tokenConfig[asset];
if (!_config.isActive) revert UnsupportedAsset();
if (totalPerBlockPerAsset[block.number][asset].mintedPerBlock + mintAmount > _config.maxMintPerBlock) {
revert MaxMintPerBlockExceeded();
}
_;
}
modifier belowMaxRedeemPerBlock(uint128 redeemAmount, address asset) {
TokenConfig memory _config = tokenConfig[asset];
if (!_config.isActive) revert UnsupportedAsset();
if (totalPerBlockPerAsset[block.number][asset].redeemedPerBlock + redeemAmount > _config.maxRedeemPerBlock) {
revert MaxRedeemPerBlockExceeded();
}
_;
}
modifier belowGlobalMaxMintPerBlock(uint128 mintAmount) {
uint128 totalMintedThisBlock = totalPerBlock[uint128(block.number)].mintedPerBlock;
if (totalMintedThisBlock + mintAmount > globalConfig.globalMaxMintPerBlock) revert GlobalMaxMintPerBlockExceeded();
_;
}
modifier belowGlobalMaxRedeemPerBlock(uint128 redeemAmount) {
uint128 totalRedeemedThisBlock = totalPerBlock[block.number].redeemedPerBlock;
if (totalRedeemedThisBlock + redeemAmount > globalConfig.globalMaxRedeemPerBlock) {
revert GlobalMaxRedeemPerBlockExceeded();
}
_;
}
constructor(
IUSDe _usde,
IWETH9 _weth,
address[] memory _assets,
TokenConfig[] memory _tokenConfig,
GlobalConfig memory _globalConfig,
address[] memory _custodians,
address _admin
) {
if (address(_usde) == address(0)) revert InvalidUSDeAddress();
if (address(_weth) == address(0)) revert InvalidZeroAddress();
if (_tokenConfig.length == 0) revert NoAssetsProvided();
if (_assets.length == 0) revert NoAssetsProvided();
if (_admin == address(0)) revert InvalidZeroAddress();
usde = _usde;
WETH = _weth;
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
if (_tokenConfig.length != _assets.length) {
revert InvalidAssetAddress();
}
for (uint128 j = 0; j < _custodians.length;) {
addCustodianAddress(_custodians[j]);
unchecked {
++j;
}
}
globalConfig = _globalConfig;
for (uint128 k = 0; k < _tokenConfig.length;) {
if (tokenConfig[_assets[k]].isActive || _assets[k] == address(0) || _assets[k] == address(usde)) {
revert InvalidAssetAddress();
}
_setTokenConfig(_assets[k], _tokenConfig[k]);
unchecked {
++k;
}
}
if (msg.sender != _admin) {
_grantRole(DEFAULT_ADMIN_ROLE, _admin);
}
_chainId = block.chainid;
_domainSeparator = _computeDomainSeparator();
emit USDeSet(address(_usde));
}
receive() external payable {
emit Received(msg.sender, msg.value);
}
function mint(Order calldata order, Route calldata route, Signature calldata signature)
external
override
nonReentrant
onlyRole(MINTER_ROLE)
belowMaxMintPerBlock(order.usde_amount, order.collateral_asset)
belowGlobalMaxMintPerBlock(order.usde_amount)
{
if (order.order_type != OrderType.MINT) revert InvalidOrder();
verifyOrder(order, signature);
if (!verifyRoute(route)) revert InvalidRoute();
_deduplicateOrder(order.benefactor, order.nonce);
totalPerBlockPerAsset[block.number][order.collateral_asset].mintedPerBlock += order.usde_amount;
totalPerBlock[block.number].mintedPerBlock += order.usde_amount;
_transferCollateral(
order.collateral_amount, order.collateral_asset, order.benefactor, route.addresses, route.ratios
);
usde.mint(order.beneficiary, order.usde_amount);
emit Mint(
order.order_id,
order.benefactor,
order.beneficiary,
msg.sender,
order.collateral_asset,
order.collateral_amount,
order.usde_amount
);
}
function mintWETH(Order calldata order, Route calldata route, Signature calldata signature)
external
nonReentrant
onlyRole(MINTER_ROLE)
belowMaxMintPerBlock(order.usde_amount, order.collateral_asset)
belowGlobalMaxMintPerBlock(order.usde_amount)
{
if (order.order_type != OrderType.MINT) revert InvalidOrder();
verifyOrder(order, signature);
if (!verifyRoute(route)) revert InvalidRoute();
_deduplicateOrder(order.benefactor, order.nonce);
totalPerBlockPerAsset[block.number][order.collateral_asset].mintedPerBlock += order.usde_amount;
totalPerBlock[block.number].mintedPerBlock += order.usde_amount;
_transferEthCollateral(
order.collateral_amount, order.collateral_asset, order.benefactor, route.addresses, route.ratios
);
usde.mint(order.beneficiary, order.usde_amount);
emit Mint(
order.order_id,
order.benefactor,
order.beneficiary,
msg.sender,
order.collateral_asset,
order.collateral_amount,
order.usde_amount
);
}
function redeem(Order calldata order, Signature calldata signature)
external
override
nonReentrant
onlyRole(REDEEMER_ROLE)
belowMaxRedeemPerBlock(order.usde_amount, order.collateral_asset)
belowGlobalMaxRedeemPerBlock(order.usde_amount)
{
if (order.order_type != OrderType.REDEEM) revert InvalidOrder();
verifyOrder(order, signature);
_deduplicateOrder(order.benefactor, order.nonce);
totalPerBlockPerAsset[block.number][order.collateral_asset].redeemedPerBlock += order.usde_amount;
totalPerBlock[block.number].redeemedPerBlock += order.usde_amount;
usde.burnFrom(order.benefactor, order.usde_amount);
_transferToBeneficiary(order.beneficiary, order.collateral_asset, order.collateral_amount);
emit Redeem(
order.order_id,
order.benefactor,
order.beneficiary,
msg.sender,
order.collateral_asset,
order.collateral_amount,
order.usde_amount
);
}
function setGlobalMaxMintPerBlock(uint128 _globalMaxMintPerBlock) external onlyRole(DEFAULT_ADMIN_ROLE) {
globalConfig.globalMaxMintPerBlock = _globalMaxMintPerBlock;
}
function setGlobalMaxRedeemPerBlock(uint128 _globalMaxRedeemPerBlock) external onlyRole(DEFAULT_ADMIN_ROLE) {
globalConfig.globalMaxRedeemPerBlock = _globalMaxRedeemPerBlock;
}
function disableMintRedeem() external onlyRole(GATEKEEPER_ROLE) {
globalConfig.globalMaxMintPerBlock = 0;
globalConfig.globalMaxRedeemPerBlock = 0;
}
function setDelegatedSigner(address _delegateTo) external {
delegatedSigner[_delegateTo][msg.sender] = DelegatedSignerStatus.PENDING;
emit DelegatedSignerInitiated(_delegateTo, msg.sender);
}
function confirmDelegatedSigner(address _delegatedBy) external {
if (delegatedSigner[msg.sender][_delegatedBy] != DelegatedSignerStatus.PENDING) {
revert DelegationNotInitiated();
}
delegatedSigner[msg.sender][_delegatedBy] = DelegatedSignerStatus.ACCEPTED;
emit DelegatedSignerAdded(msg.sender, _delegatedBy);
}
function removeDelegatedSigner(address _removedSigner) external {
delegatedSigner[_removedSigner][msg.sender] = DelegatedSignerStatus.REJECTED;
emit DelegatedSignerRemoved(_removedSigner, msg.sender);
}
function transferToCustody(address wallet, address asset, uint128 amount)
external
nonReentrant
onlyRole(COLLATERAL_MANAGER_ROLE)
{
if (wallet == address(0) || !_custodianAddresses.contains(wallet)) revert InvalidAddress();
if (asset == NATIVE_TOKEN) {
(bool success,) = wallet.call{value: amount}("");
if (!success) revert TransferFailed();
} else {
IERC20(asset).safeTransfer(wallet, amount);
}
emit CustodyTransfer(wallet, asset, amount);
}
function removeSupportedAsset(address asset) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (!tokenConfig[asset].isActive) revert InvalidAssetAddress();
delete tokenConfig[asset];
emit AssetRemoved(asset);
}
function isSupportedAsset(address asset) external view returns (bool) {
return tokenConfig[asset].isActive;
}
function removeCustodianAddress(address custodian) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (!_custodianAddresses.remove(custodian)) revert InvalidCustodianAddress();
emit CustodianAddressRemoved(custodian);
}
function removeMinterRole(address minter) external onlyRole(GATEKEEPER_ROLE) {
_revokeRole(MINTER_ROLE, minter);
}
function removeRedeemerRole(address redeemer) external onlyRole(GATEKEEPER_ROLE) {
_revokeRole(REDEEMER_ROLE, redeemer);
}
function removeCollateralManagerRole(address collateralManager) external onlyRole(GATEKEEPER_ROLE) {
_revokeRole(COLLATERAL_MANAGER_ROLE, collateralManager);
}
function removeWhitelistedBenefactor(address benefactor) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (!_whitelistedBenefactors.remove(benefactor)) revert InvalidAddress();
emit BenefactorRemoved(benefactor);
}
function addCustodianAddress(address custodian) public onlyRole(DEFAULT_ADMIN_ROLE) {
if (custodian == address(0) || custodian == address(usde) || !_custodianAddresses.add(custodian)) {
revert InvalidCustodianAddress();
}
emit CustodianAddressAdded(custodian);
}
function addWhitelistedBenefactor(address benefactor) public onlyRole(DEFAULT_ADMIN_ROLE) {
if (benefactor == address(0) || !_whitelistedBenefactors.add(benefactor)) {
revert InvalidBenefactorAddress();
}
emit BenefactorAdded(benefactor);
}
function setApprovedBeneficiary(address beneficiary, bool status) public {
if (status) {
if (!_approvedBeneficiariesPerBenefactor[msg.sender].add(beneficiary)) {
revert InvalidBeneficiaryAddress();
}
else {
emit BeneficiaryAdded(msg.sender, beneficiary);
}
} else {
if (!_approvedBeneficiariesPerBenefactor[msg.sender].remove(beneficiary)) {
revert InvalidBeneficiaryAddress();
} else {
emit BeneficiaryRemoved(msg.sender, beneficiary);
}
}
}
function getDomainSeparator() public view returns (bytes32) {
if (block.chainid == _chainId) {
return _domainSeparator;
}
return _computeDomainSeparator();
}
function hashOrder(Order calldata order) public view override returns (bytes32) {
return ECDSA.toTypedDataHash(getDomainSeparator(), keccak256(encodeOrder(order)));
}
function encodeOrder(Order calldata order) public pure returns (bytes memory) {
return abi.encode(
ORDER_TYPE,
keccak256(bytes(order.order_id)),
order.order_type,
order.expiry,
order.nonce,
order.benefactor,
order.beneficiary,
order.collateral_asset,
order.collateral_amount,
order.usde_amount
);
}
function verifyOrder(Order calldata order, Signature calldata signature)
public
view
override
returns (bytes32 taker_order_hash)
{
taker_order_hash = hashOrder(order);
if (signature.signature_type == SignatureType.EIP712) {
address signer = ECDSA.recover(taker_order_hash, signature.signature_bytes);
if (!(signer == order.benefactor || delegatedSigner[signer][order.benefactor] == DelegatedSignerStatus.ACCEPTED))
{
revert InvalidEIP712Signature();
}
} else if (signature.signature_type == SignatureType.EIP1271) {
if (
IERC1271(order.benefactor).isValidSignature(taker_order_hash, signature.signature_bytes) != EIP1271_MAGICVALUE
) {
revert InvalidEIP1271Signature();
}
} else {
revert UnknownSignatureType();
}
if (!_whitelistedBenefactors.contains(order.benefactor)) {
revert BenefactorNotWhitelisted();
}
if (order.benefactor != order.beneficiary) {
if (!_approvedBeneficiariesPerBenefactor[order.benefactor].contains(order.beneficiary)) {
revert BeneficiaryNotApproved();
}
}
TokenType typeOfToken = tokenConfig[order.collateral_asset].tokenType;
if (typeOfToken == TokenType.STABLE) {
if (!verifyStablesLimit(order.collateral_amount, order.usde_amount, order.collateral_asset, order.order_type)) {
revert InvalidStablePrice();
}
}
if (order.beneficiary == address(0)) revert InvalidAddress();
if (order.collateral_amount == 0 || order.usde_amount == 0) revert InvalidAmount();
if (block.timestamp > order.expiry) revert SignatureExpired();
}
function verifyRoute(Route calldata route) public view override returns (bool) {
uint128 totalRatio = 0;
if (route.addresses.length != route.ratios.length) {
return false;
}
if (route.addresses.length == 0) {
return false;
}
for (uint128 i = 0; i < route.addresses.length;) {
if (!_custodianAddresses.contains(route.addresses[i]) || route.addresses[i] == address(0) || route.ratios[i] == 0)
{
return false;
}
totalRatio += route.ratios[i];
unchecked {
++i;
}
}
return (totalRatio == ROUTE_REQUIRED_RATIO);
}
function verifyNonce(address sender, uint128 nonce) public view override returns (uint128, uint256, uint256) {
if (nonce == 0) revert InvalidNonce();
uint128 invalidatorSlot = uint64(nonce) >> 8;
uint256 invalidatorBit = 1 << uint8(nonce);
uint256 invalidator = _orderBitmaps[sender][invalidatorSlot];
if (invalidator & invalidatorBit != 0) revert InvalidNonce();
return (invalidatorSlot, invalidator, invalidatorBit);
}
function verifyStablesLimit(
uint128 collateralAmount,
uint128 usdeAmount,
address collateralAsset,
OrderType orderType
) public view returns (bool) {
uint128 usdeDecimals = _getDecimals(address(usde));
uint128 collateralDecimals = _getDecimals(collateralAsset);
uint128 normalizedCollateralAmount;
uint128 scale = uint128(
usdeDecimals > collateralDecimals
? 10 ** (usdeDecimals - collateralDecimals)
: 10 ** (collateralDecimals - usdeDecimals)
);
normalizedCollateralAmount = usdeDecimals > collateralDecimals ? collateralAmount * scale : collateralAmount / scale;
uint128 difference = normalizedCollateralAmount > usdeAmount
? normalizedCollateralAmount - usdeAmount
: usdeAmount - normalizedCollateralAmount;
uint128 differenceInBps = (difference * STABLES_RATIO_MULTIPLIER) / usdeAmount;
if (orderType == OrderType.MINT) {
return usdeAmount > normalizedCollateralAmount ? differenceInBps <= stablesDeltaLimit : true;
} else {
return normalizedCollateralAmount > usdeAmount ? differenceInBps <= stablesDeltaLimit : true;
}
}
function _deduplicateOrder(address sender, uint128 nonce) private {
(uint128 invalidatorSlot, uint256 invalidator, uint256 invalidatorBit) = verifyNonce(sender, nonce);
_orderBitmaps[sender][invalidatorSlot] = invalidator | invalidatorBit;
}
function _transferToBeneficiary(address beneficiary, address asset, uint128 amount) internal {
if (asset == NATIVE_TOKEN) {
if (address(this).balance < amount) revert InvalidAmount();
(bool success,) = (beneficiary).call{value: amount}("");
if (!success) revert TransferFailed();
} else {
if (!tokenConfig[asset].isActive) revert UnsupportedAsset();
IERC20(asset).safeTransfer(beneficiary, amount);
}
}
function _transferCollateral(
uint128 amount,
address asset,
address benefactor,
address[] calldata addresses,
uint128[] calldata ratios
) internal {
if (!tokenConfig[asset].isActive || asset == NATIVE_TOKEN) revert UnsupportedAsset();
IERC20 token = IERC20(asset);
uint128 totalTransferred = 0;
for (uint128 i = 0; i < addresses.length;) {
uint128 amountToTransfer = (amount * ratios[i]) / ROUTE_REQUIRED_RATIO;
token.safeTransferFrom(benefactor, addresses[i], amountToTransfer);
totalTransferred += amountToTransfer;
unchecked {
++i;
}
}
uint128 remainingBalance = amount - totalTransferred;
if (remainingBalance > 0) {
token.safeTransferFrom(benefactor, addresses[addresses.length - 1], remainingBalance);
}
}
function _transferEthCollateral(
uint128 amount,
address asset,
address benefactor,
address[] calldata addresses,
uint128[] calldata ratios
) internal {
if (!tokenConfig[asset].isActive || asset == NATIVE_TOKEN || asset != address(WETH)) revert UnsupportedAsset();
IERC20 token = IERC20(asset);
token.safeTransferFrom(benefactor, address(this), amount);
WETH.withdraw(amount);
uint128 totalTransferred = 0;
for (uint128 i = 0; i < addresses.length;) {
uint128 amountToTransfer = (amount * ratios[i]) / ROUTE_REQUIRED_RATIO;
(bool success,) = addresses[i].call{value: amountToTransfer}("");
if (!success) revert TransferFailed();
totalTransferred += amountToTransfer;
unchecked {
++i;
}
}
uint128 remainingBalance = amount - totalTransferred;
if (remainingBalance > 0) {
(bool success,) = addresses[addresses.length - 1].call{value: remainingBalance}("");
if (!success) revert TransferFailed();
}
}
function _setTokenConfig(address asset, TokenConfig memory _tokenConfig) internal {
if (_tokenConfig.maxMintPerBlock == 0 || _tokenConfig.maxRedeemPerBlock == 0) {
revert InvalidAmount();
}
_tokenConfig.isActive = true;
tokenConfig[asset] = _tokenConfig;
}
function addSupportedAsset(address asset, TokenConfig memory _tokenConfig) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (tokenConfig[asset].isActive || asset == address(0) || asset == address(usde)) {
revert InvalidAssetAddress();
}
_setTokenConfig(asset, _tokenConfig);
emit AssetAdded(asset);
}
function setMaxMintPerBlock(uint128 _maxMintPerBlock, address asset) external onlyRole(DEFAULT_ADMIN_ROLE) {
_setMaxMintPerBlock(_maxMintPerBlock, asset);
}
function _setMaxMintPerBlock(uint128 _maxMintPerBlock, address asset) internal {
uint128 oldMaxMintPerBlock = tokenConfig[asset].maxMintPerBlock;
tokenConfig[asset].maxMintPerBlock = _maxMintPerBlock;
emit MaxMintPerBlockChanged(oldMaxMintPerBlock, _maxMintPerBlock, asset);
}
function setMaxRedeemPerBlock(uint128 _maxRedeemPerBlock, address asset) external onlyRole(DEFAULT_ADMIN_ROLE) {
_setMaxRedeemPerBlock(_maxRedeemPerBlock, asset);
}
function _setMaxRedeemPerBlock(uint128 _maxRedeemPerBlock, address asset) internal {
uint128 oldMaxRedeemPerBlock = tokenConfig[asset].maxRedeemPerBlock;
tokenConfig[asset].maxRedeemPerBlock = _maxRedeemPerBlock;
emit MaxRedeemPerBlockChanged(oldMaxRedeemPerBlock, _maxRedeemPerBlock, asset);
}
function _computeDomainSeparator() internal view returns (bytes32) {
return keccak256(abi.encode(EIP712_DOMAIN, EIP_712_NAME, EIP712_REVISION, block.chainid, address(this)));
}
function setTokenType(address asset, TokenType tokenType) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (!tokenConfig[asset].isActive) revert UnsupportedAsset();
tokenConfig[asset].tokenType = tokenType;
emit TokenTypeSet(asset, uint(tokenType));
}
function setStablesDeltaLimit(uint128 _stablesDeltaLimit) external onlyRole(DEFAULT_ADMIN_ROLE) {
stablesDeltaLimit = _stablesDeltaLimit;
}
function _getDecimals(address token) internal view returns (uint128) {
uint8 decimals = IERC20Metadata(token).decimals();
return uint128(decimals);
}
function isCustodianAddress(address custodian) public view returns (bool) {
return _custodianAddresses.contains(custodian);
}
function isWhitelistedBenefactor(address benefactor) public view returns (bool) {
return _whitelistedBenefactors.contains(benefactor);
}
function isApprovedBeneficiary(address benefactor, address beneficiary) public view returns (bool) {
return _approvedBeneficiariesPerBenefactor[benefactor].contains(beneficiary);
}
}
文件 8 的 25:IAccessControl.sol
pragma solidity ^0.8.0;
interface IAccessControl {
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
function hasRole(bytes32 role, address account) external view returns (bool);
function getRoleAdmin(bytes32 role) external view returns (bytes32);
function grantRole(bytes32 role, address account) external;
function revokeRole(bytes32 role, address account) external;
function renounceRole(bytes32 role, address account) external;
}
文件 9 的 25:IERC1271.sol
pragma solidity ^0.8.0;
interface IERC1271 {
function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);
}
文件 10 的 25:IERC165.sol
pragma solidity ^0.8.0;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 11 的 25:IERC20.sol
pragma solidity ^0.8.0;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
文件 12 的 25:IERC20Metadata.sol
pragma solidity ^0.8.0;
import "../IERC20.sol";
interface IERC20Metadata is IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
文件 13 的 25:IERC20Permit.sol
pragma solidity ^0.8.0;
interface IERC20Permit {
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
function nonces(address owner) external view returns (uint256);
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
文件 14 的 25:IERC5313.sol
pragma solidity ^0.8.0;
interface IERC5313 {
function owner() external view returns (address);
}
文件 15 的 25:IEthenaMinting.sol
pragma solidity 0.8.20;
import "./IEthenaMintingEvents.sol";
interface IEthenaMinting is IEthenaMintingEvents {
enum Role {
Minter,
Redeemer
}
enum OrderType {
MINT,
REDEEM
}
enum TokenType {
STABLE,
ASSET
}
enum SignatureType {
EIP712,
EIP1271
}
enum DelegatedSignerStatus {
REJECTED,
PENDING,
ACCEPTED
}
struct Signature {
SignatureType signature_type;
bytes signature_bytes;
}
struct Route {
address[] addresses;
uint128[] ratios;
}
struct Order {
string order_id;
OrderType order_type;
uint120 expiry;
uint128 nonce;
address benefactor;
address beneficiary;
address collateral_asset;
uint128 collateral_amount;
uint128 usde_amount;
}
struct TokenConfig {
TokenType tokenType;
bool isActive;
uint128 maxMintPerBlock;
uint128 maxRedeemPerBlock;
}
struct BlockTotals {
uint128 mintedPerBlock;
uint128 redeemedPerBlock;
}
struct GlobalConfig {
uint128 globalMaxMintPerBlock;
uint128 globalMaxRedeemPerBlock;
}
error InvalidAddress();
error InvalidUSDeAddress();
error InvalidZeroAddress();
error InvalidAssetAddress();
error InvalidBenefactorAddress();
error InvalidBeneficiaryAddress();
error InvalidCustodianAddress();
error InvalidOrder();
error InvalidAmount();
error InvalidRoute();
error InvalidStablePrice();
error UnknownSignatureType();
error UnsupportedAsset();
error NoAssetsProvided();
error BenefactorNotWhitelisted();
error BeneficiaryNotApproved();
error InvalidEIP712Signature();
error InvalidEIP1271Signature();
error InvalidNonce();
error SignatureExpired();
error TransferFailed();
error DelegationNotInitiated();
error MaxMintPerBlockExceeded();
error MaxRedeemPerBlockExceeded();
error GlobalMaxMintPerBlockExceeded();
error GlobalMaxRedeemPerBlockExceeded();
function hashOrder(Order calldata order) external view returns (bytes32);
function verifyOrder(Order calldata order, Signature calldata signature) external view returns (bytes32);
function verifyRoute(Route calldata route) external view returns (bool);
function verifyNonce(address sender, uint128 nonce) external view returns (uint128, uint256, uint256);
function verifyStablesLimit(uint128 collateralAmount, uint128 usdeAmount, address collateralAsset, OrderType orderType) external view returns (bool);
function mint(Order calldata order, Route calldata route, Signature calldata signature) external;
function mintWETH(Order calldata order, Route calldata route, Signature calldata signature) external;
function redeem(Order calldata order, Signature calldata signature) external;
}
文件 16 的 25:IEthenaMintingEvents.sol
pragma solidity 0.8.20;
interface IEthenaMintingEvents {
event Received(address, uint256);
event Mint(
string indexed order_id,
address indexed benefactor,
address indexed beneficiary,
address minter,
address collateral_asset,
uint256 collateral_amount,
uint256 usde_amount
);
event Redeem(
string indexed order_id,
address indexed benefactor,
address indexed beneficiary,
address redeemer,
address collateral_asset,
uint256 collateral_amount,
uint256 usde_amount
);
event AssetAdded(address indexed asset);
event AssetRemoved(address indexed asset);
event BenefactorAdded(address indexed benefactor);
event BeneficiaryAdded(address indexed benefactor, address indexed beneficiary);
event BenefactorRemoved(address indexed benefactor);
event BeneficiaryRemoved(address indexed benefactor, address indexed beneficiary);
event CustodianAddressAdded(address indexed custodian);
event CustodianAddressRemoved(address indexed custodian);
event CustodyTransfer(address indexed wallet, address indexed asset, uint256 amount);
event USDeSet(address indexed USDe);
event MaxMintPerBlockChanged(uint256 oldMaxMintPerBlock, uint256 newMaxMintPerBlock, address indexed asset);
event MaxRedeemPerBlockChanged(uint256 oldMaxRedeemPerBlock, uint256 newMaxRedeemPerBlock, address indexed asset);
event DelegatedSignerAdded(address indexed signer, address indexed delegator);
event DelegatedSignerRemoved(address indexed signer, address indexed delegator);
event DelegatedSignerInitiated(address indexed signer, address indexed delegator);
event TokenTypeSet(address indexed token, uint tokenType);
}
文件 17 的 25:ISingleAdminAccessControl.sol
pragma solidity 0.8.20;
interface ISingleAdminAccessControl {
error InvalidAdminChange();
error NotPendingAdmin();
event AdminTransferred(address indexed oldAdmin, address indexed newAdmin);
event AdminTransferRequested(address indexed oldAdmin, address indexed newAdmin);
}
文件 18 的 25:IUSDe.sol
pragma solidity 0.8.20;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
interface IUSDe is IERC20, IERC20Permit, IERC20Metadata {
function mint(address _to, uint256 _amount) external;
function burn(uint256 _amount) external;
function burnFrom(address account, uint256 amount) external;
function grantRole(bytes32 role, address account) external;
function setMinter(address newMinter) external;
}
文件 19 的 25:IWETH9.sol
pragma solidity 0.8.20;
interface IWETH9 {
function deposit() external payable;
function withdraw(uint256 wad) external payable;
function totalSupply() external returns (uint256);
function approve(address guy, uint256 wad) external returns (bool);
}
文件 20 的 25:Math.sol
pragma solidity ^0.8.0;
library Math {
enum Rounding {
Down,
Up,
Zero
}
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
function average(uint256 a, uint256 b) internal pure returns (uint256) {
return (a & b) + (a ^ b) / 2;
}
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
return a == 0 ? 0 : (a - 1) / b + 1;
}
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
uint256 prod0;
uint256 prod1;
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
if (prod1 == 0) {
return prod0 / denominator;
}
require(denominator > prod1, "Math: mulDiv overflow");
uint256 remainder;
assembly {
remainder := mulmod(x, y, denominator)
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
uint256 twos = denominator & (~denominator + 1);
assembly {
denominator := div(denominator, twos)
prod0 := div(prod0, twos)
twos := add(div(sub(0, twos), twos), 1)
}
prod0 |= prod1 * twos;
uint256 inverse = (3 * denominator) ^ 2;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
result = prod0 * inverse;
return result;
}
}
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 result = 1 << (log2(a) >> 1);
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
}
}
}
文件 21 的 25:ReentrancyGuard.sol
pragma solidity ^0.8.0;
abstract contract ReentrancyGuard {
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
_status = _ENTERED;
}
function _nonReentrantAfter() private {
_status = _NOT_ENTERED;
}
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}
文件 22 的 25:SafeERC20.sol
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";
library SafeERC20 {
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(IERC20 token, address spender, uint256 value) internal {
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
function _callOptionalReturn(IERC20 token, bytes memory data) private {
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}
文件 23 的 25:SignedMath.sol
pragma solidity ^0.8.0;
library SignedMath {
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
function average(int256 a, int256 b) internal pure returns (int256) {
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
function abs(int256 n) internal pure returns (uint256) {
unchecked {
return uint256(n >= 0 ? n : -n);
}
}
}
文件 24 的 25:SingleAdminAccessControl.sol
pragma solidity 0.8.20;
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/interfaces/IERC5313.sol";
import "./interfaces/ISingleAdminAccessControl.sol";
abstract contract SingleAdminAccessControl is IERC5313, ISingleAdminAccessControl, AccessControl {
address private _currentDefaultAdmin;
address private _pendingDefaultAdmin;
modifier notAdmin(bytes32 role) {
if (role == DEFAULT_ADMIN_ROLE) revert InvalidAdminChange();
_;
}
function transferAdmin(address newAdmin) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (newAdmin == msg.sender) revert InvalidAdminChange();
_pendingDefaultAdmin = newAdmin;
emit AdminTransferRequested(_currentDefaultAdmin, newAdmin);
}
function acceptAdmin() external {
if (msg.sender != _pendingDefaultAdmin) revert NotPendingAdmin();
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
}
function grantRole(bytes32 role, address account) public override onlyRole(DEFAULT_ADMIN_ROLE) notAdmin(role) {
_grantRole(role, account);
}
function revokeRole(bytes32 role, address account) public override onlyRole(DEFAULT_ADMIN_ROLE) notAdmin(role) {
_revokeRole(role, account);
}
function renounceRole(bytes32 role, address account) public virtual override notAdmin(role) {
super.renounceRole(role, account);
}
function owner() public view virtual returns (address) {
return _currentDefaultAdmin;
}
function _grantRole(bytes32 role, address account) internal override {
if (role == DEFAULT_ADMIN_ROLE) {
emit AdminTransferred(_currentDefaultAdmin, account);
_revokeRole(DEFAULT_ADMIN_ROLE, _currentDefaultAdmin);
_currentDefaultAdmin = account;
delete _pendingDefaultAdmin;
}
super._grantRole(role, account);
}
}
文件 25 的 25:Strings.sol
pragma solidity ^0.8.0;
import "./math/Math.sol";
import "./math/SignedMath.sol";
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
}
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}
{
"compilationTarget": {
"contracts/EthenaMinting.sol": "EthenaMinting"
},
"evmVersion": "shanghai",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 20000
},
"remappings": [
":@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
":ds-test/=lib/forge-std/lib/ds-test/src/",
":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
":forge-std/=lib/forge-std/src/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/",
":openzeppelin/=lib/openzeppelin-contracts/contracts/"
]
}
[{"inputs":[{"internalType":"contract IUSDe","name":"_usde","type":"address"},{"internalType":"contract IWETH9","name":"_weth","type":"address"},{"internalType":"address[]","name":"_assets","type":"address[]"},{"components":[{"internalType":"enum IEthenaMinting.TokenType","name":"tokenType","type":"uint8"},{"internalType":"bool","name":"isActive","type":"bool"},{"internalType":"uint128","name":"maxMintPerBlock","type":"uint128"},{"internalType":"uint128","name":"maxRedeemPerBlock","type":"uint128"}],"internalType":"struct IEthenaMinting.TokenConfig[]","name":"_tokenConfig","type":"tuple[]"},{"components":[{"internalType":"uint128","name":"globalMaxMintPerBlock","type":"uint128"},{"internalType":"uint128","name":"globalMaxRedeemPerBlock","type":"uint128"}],"internalType":"struct IEthenaMinting.GlobalConfig","name":"_globalConfig","type":"tuple"},{"internalType":"address[]","name":"_custodians","type":"address[]"},{"internalType":"address","name":"_admin","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"BenefactorNotWhitelisted","type":"error"},{"inputs":[],"name":"BeneficiaryNotApproved","type":"error"},{"inputs":[],"name":"DelegationNotInitiated","type":"error"},{"inputs":[],"name":"GlobalMaxMintPerBlockExceeded","type":"error"},{"inputs":[],"name":"GlobalMaxRedeemPerBlockExceeded","type":"error"},{"inputs":[],"name":"InvalidAddress","type":"error"},{"inputs":[],"name":"InvalidAdminChange","type":"error"},{"inputs":[],"name":"InvalidAmount","type":"error"},{"inputs":[],"name":"InvalidAssetAddress","type":"error"},{"inputs":[],"name":"InvalidBenefactorAddress","type":"error"},{"inputs":[],"name":"InvalidBeneficiaryAddress","type":"error"},{"inputs":[],"name":"InvalidCustodianAddress","type":"error"},{"inputs":[],"name":"InvalidEIP1271Signature","type":"error"},{"inputs":[],"name":"InvalidEIP712Signature","type":"error"},{"inputs":[],"name":"InvalidNonce","type":"error"},{"inputs":[],"name":"InvalidOrder","type":"error"},{"inputs":[],"name":"InvalidRoute","type":"error"},{"inputs":[],"name":"InvalidStablePrice","type":"error"},{"inputs":[],"name":"InvalidUSDeAddress","type":"error"},{"inputs":[],"name":"InvalidZeroAddress","type":"error"},{"inputs":[],"name":"MaxMintPerBlockExceeded","type":"error"},{"inputs":[],"name":"MaxRedeemPerBlockExceeded","type":"error"},{"inputs":[],"name":"NoAssetsProvided","type":"error"},{"inputs":[],"name":"NotPendingAdmin","type":"error"},{"inputs":[],"name":"SignatureExpired","type":"error"},{"inputs":[],"name":"TransferFailed","type":"error"},{"inputs":[],"name":"UnknownSignatureType","type":"error"},{"inputs":[],"name":"UnsupportedAsset","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldAdmin","type":"address"},{"indexed":true,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminTransferRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldAdmin","type":"address"},{"indexed":true,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"}],"name":"AssetAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"}],"name":"AssetRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"benefactor","type":"address"}],"name":"BenefactorAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"benefactor","type":"address"}],"name":"BenefactorRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"benefactor","type":"address"},{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"}],"name":"BeneficiaryAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"benefactor","type":"address"},{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"}],"name":"BeneficiaryRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"custodian","type":"address"}],"name":"CustodianAddressAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"custodian","type":"address"}],"name":"CustodianAddressRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wallet","type":"address"},{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"CustodyTransfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"signer","type":"address"},{"indexed":true,"internalType":"address","name":"delegator","type":"address"}],"name":"DelegatedSignerAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"signer","type":"address"},{"indexed":true,"internalType":"address","name":"delegator","type":"address"}],"name":"DelegatedSignerInitiated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"signer","type":"address"},{"indexed":true,"internalType":"address","name":"delegator","type":"address"}],"name":"DelegatedSignerRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldMaxMintPerBlock","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newMaxMintPerBlock","type":"uint256"},{"indexed":true,"internalType":"address","name":"asset","type":"address"}],"name":"MaxMintPerBlockChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldMaxRedeemPerBlock","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newMaxRedeemPerBlock","type":"uint256"},{"indexed":true,"internalType":"address","name":"asset","type":"address"}],"name":"MaxRedeemPerBlockChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"string","name":"order_id","type":"string"},{"indexed":true,"internalType":"address","name":"benefactor","type":"address"},{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"address","name":"minter","type":"address"},{"indexed":false,"internalType":"address","name":"collateral_asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"collateral_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"usde_amount","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"","type":"address"},{"indexed":false,"internalType":"uint256","name":"","type":"uint256"}],"name":"Received","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"string","name":"order_id","type":"string"},{"indexed":true,"internalType":"address","name":"benefactor","type":"address"},{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"address","name":"redeemer","type":"address"},{"indexed":false,"internalType":"address","name":"collateral_asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"collateral_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"usde_amount","type":"uint256"}],"name":"Redeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenType","type":"uint256"}],"name":"TokenTypeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"USDe","type":"address"}],"name":"USDeSet","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"custodian","type":"address"}],"name":"addCustodianAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"components":[{"internalType":"enum IEthenaMinting.TokenType","name":"tokenType","type":"uint8"},{"internalType":"bool","name":"isActive","type":"bool"},{"internalType":"uint128","name":"maxMintPerBlock","type":"uint128"},{"internalType":"uint128","name":"maxRedeemPerBlock","type":"uint128"}],"internalType":"struct IEthenaMinting.TokenConfig","name":"_tokenConfig","type":"tuple"}],"name":"addSupportedAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"benefactor","type":"address"}],"name":"addWhitelistedBenefactor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegatedBy","type":"address"}],"name":"confirmDelegatedSigner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"delegatedSigner","outputs":[{"internalType":"enum IEthenaMinting.DelegatedSignerStatus","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"disableMintRedeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"order_id","type":"string"},{"internalType":"enum IEthenaMinting.OrderType","name":"order_type","type":"uint8"},{"internalType":"uint120","name":"expiry","type":"uint120"},{"internalType":"uint128","name":"nonce","type":"uint128"},{"internalType":"address","name":"benefactor","type":"address"},{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"address","name":"collateral_asset","type":"address"},{"internalType":"uint128","name":"collateral_amount","type":"uint128"},{"internalType":"uint128","name":"usde_amount","type":"uint128"}],"internalType":"struct IEthenaMinting.Order","name":"order","type":"tuple"}],"name":"encodeOrder","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"getDomainSeparator","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"globalConfig","outputs":[{"internalType":"uint128","name":"globalMaxMintPerBlock","type":"uint128"},{"internalType":"uint128","name":"globalMaxRedeemPerBlock","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"order_id","type":"string"},{"internalType":"enum IEthenaMinting.OrderType","name":"order_type","type":"uint8"},{"internalType":"uint120","name":"expiry","type":"uint120"},{"internalType":"uint128","name":"nonce","type":"uint128"},{"internalType":"address","name":"benefactor","type":"address"},{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"address","name":"collateral_asset","type":"address"},{"internalType":"uint128","name":"collateral_amount","type":"uint128"},{"internalType":"uint128","name":"usde_amount","type":"uint128"}],"internalType":"struct IEthenaMinting.Order","name":"order","type":"tuple"}],"name":"hashOrder","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"benefactor","type":"address"},{"internalType":"address","name":"beneficiary","type":"address"}],"name":"isApprovedBeneficiary","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"custodian","type":"address"}],"name":"isCustodianAddress","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"isSupportedAsset","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"benefactor","type":"address"}],"name":"isWhitelistedBenefactor","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"order_id","type":"string"},{"internalType":"enum IEthenaMinting.OrderType","name":"order_type","type":"uint8"},{"internalType":"uint120","name":"expiry","type":"uint120"},{"internalType":"uint128","name":"nonce","type":"uint128"},{"internalType":"address","name":"benefactor","type":"address"},{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"address","name":"collateral_asset","type":"address"},{"internalType":"uint128","name":"collateral_amount","type":"uint128"},{"internalType":"uint128","name":"usde_amount","type":"uint128"}],"internalType":"struct IEthenaMinting.Order","name":"order","type":"tuple"},{"components":[{"internalType":"address[]","name":"addresses","type":"address[]"},{"internalType":"uint128[]","name":"ratios","type":"uint128[]"}],"internalType":"struct IEthenaMinting.Route","name":"route","type":"tuple"},{"components":[{"internalType":"enum IEthenaMinting.SignatureType","name":"signature_type","type":"uint8"},{"internalType":"bytes","name":"signature_bytes","type":"bytes"}],"internalType":"struct IEthenaMinting.Signature","name":"signature","type":"tuple"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"order_id","type":"string"},{"internalType":"enum IEthenaMinting.OrderType","name":"order_type","type":"uint8"},{"internalType":"uint120","name":"expiry","type":"uint120"},{"internalType":"uint128","name":"nonce","type":"uint128"},{"internalType":"address","name":"benefactor","type":"address"},{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"address","name":"collateral_asset","type":"address"},{"internalType":"uint128","name":"collateral_amount","type":"uint128"},{"internalType":"uint128","name":"usde_amount","type":"uint128"}],"internalType":"struct IEthenaMinting.Order","name":"order","type":"tuple"},{"components":[{"internalType":"address[]","name":"addresses","type":"address[]"},{"internalType":"uint128[]","name":"ratios","type":"uint128[]"}],"internalType":"struct IEthenaMinting.Route","name":"route","type":"tuple"},{"components":[{"internalType":"enum IEthenaMinting.SignatureType","name":"signature_type","type":"uint8"},{"internalType":"bytes","name":"signature_bytes","type":"bytes"}],"internalType":"struct IEthenaMinting.Signature","name":"signature","type":"tuple"}],"name":"mintWETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"order_id","type":"string"},{"internalType":"enum IEthenaMinting.OrderType","name":"order_type","type":"uint8"},{"internalType":"uint120","name":"expiry","type":"uint120"},{"internalType":"uint128","name":"nonce","type":"uint128"},{"internalType":"address","name":"benefactor","type":"address"},{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"address","name":"collateral_asset","type":"address"},{"internalType":"uint128","name":"collateral_amount","type":"uint128"},{"internalType":"uint128","name":"usde_amount","type":"uint128"}],"internalType":"struct IEthenaMinting.Order","name":"order","type":"tuple"},{"components":[{"internalType":"enum IEthenaMinting.SignatureType","name":"signature_type","type":"uint8"},{"internalType":"bytes","name":"signature_bytes","type":"bytes"}],"internalType":"struct IEthenaMinting.Signature","name":"signature","type":"tuple"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"collateralManager","type":"address"}],"name":"removeCollateralManagerRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"custodian","type":"address"}],"name":"removeCustodianAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_removedSigner","type":"address"}],"name":"removeDelegatedSigner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"minter","type":"address"}],"name":"removeMinterRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"redeemer","type":"address"}],"name":"removeRedeemerRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"removeSupportedAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"benefactor","type":"address"}],"name":"removeWhitelistedBenefactor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"bool","name":"status","type":"bool"}],"name":"setApprovedBeneficiary","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegateTo","type":"address"}],"name":"setDelegatedSigner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"_globalMaxMintPerBlock","type":"uint128"}],"name":"setGlobalMaxMintPerBlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"_globalMaxRedeemPerBlock","type":"uint128"}],"name":"setGlobalMaxRedeemPerBlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"_maxMintPerBlock","type":"uint128"},{"internalType":"address","name":"asset","type":"address"}],"name":"setMaxMintPerBlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"_maxRedeemPerBlock","type":"uint128"},{"internalType":"address","name":"asset","type":"address"}],"name":"setMaxRedeemPerBlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"_stablesDeltaLimit","type":"uint128"}],"name":"setStablesDeltaLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"enum IEthenaMinting.TokenType","name":"tokenType","type":"uint8"}],"name":"setTokenType","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stablesDeltaLimit","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenConfig","outputs":[{"internalType":"enum IEthenaMinting.TokenType","name":"tokenType","type":"uint8"},{"internalType":"bool","name":"isActive","type":"bool"},{"internalType":"uint128","name":"maxMintPerBlock","type":"uint128"},{"internalType":"uint128","name":"maxRedeemPerBlock","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"totalPerBlock","outputs":[{"internalType":"uint128","name":"mintedPerBlock","type":"uint128"},{"internalType":"uint128","name":"redeemedPerBlock","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"totalPerBlockPerAsset","outputs":[{"internalType":"uint128","name":"mintedPerBlock","type":"uint128"},{"internalType":"uint128","name":"redeemedPerBlock","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newAdmin","type":"address"}],"name":"transferAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"wallet","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint128","name":"amount","type":"uint128"}],"name":"transferToCustody","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"usde","outputs":[{"internalType":"contract IUSDe","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint128","name":"nonce","type":"uint128"}],"name":"verifyNonce","outputs":[{"internalType":"uint128","name":"","type":"uint128"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"order_id","type":"string"},{"internalType":"enum IEthenaMinting.OrderType","name":"order_type","type":"uint8"},{"internalType":"uint120","name":"expiry","type":"uint120"},{"internalType":"uint128","name":"nonce","type":"uint128"},{"internalType":"address","name":"benefactor","type":"address"},{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"address","name":"collateral_asset","type":"address"},{"internalType":"uint128","name":"collateral_amount","type":"uint128"},{"internalType":"uint128","name":"usde_amount","type":"uint128"}],"internalType":"struct IEthenaMinting.Order","name":"order","type":"tuple"},{"components":[{"internalType":"enum IEthenaMinting.SignatureType","name":"signature_type","type":"uint8"},{"internalType":"bytes","name":"signature_bytes","type":"bytes"}],"internalType":"struct IEthenaMinting.Signature","name":"signature","type":"tuple"}],"name":"verifyOrder","outputs":[{"internalType":"bytes32","name":"taker_order_hash","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address[]","name":"addresses","type":"address[]"},{"internalType":"uint128[]","name":"ratios","type":"uint128[]"}],"internalType":"struct IEthenaMinting.Route","name":"route","type":"tuple"}],"name":"verifyRoute","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint128","name":"collateralAmount","type":"uint128"},{"internalType":"uint128","name":"usdeAmount","type":"uint128"},{"internalType":"address","name":"collateralAsset","type":"address"},{"internalType":"enum IEthenaMinting.OrderType","name":"orderType","type":"uint8"}],"name":"verifyStablesLimit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]