-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from euler-xyz/remove-erc20-collateral
Remove ERC20Collateral, add ERC20EVCCompatible
- Loading branch information
Showing
12 changed files
with
54 additions
and
103 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,28 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import {ERC20, Context} from "openzeppelin-contracts/token/ERC20/ERC20.sol"; | ||
import {ERC20Permit} from "openzeppelin-contracts/token/ERC20/extensions/ERC20Permit.sol"; | ||
import {EVCUtil} from "ethereum-vault-connector/utils/EVCUtil.sol"; | ||
|
||
/// @title ERC20EVCCompatible | ||
/// @custom:security-contact [email protected] | ||
/// @author Euler Labs (https://www.eulerlabs.com/) | ||
/// @notice ERC20EVCCompatible is an ERC20-compatible token with the EVC support. | ||
abstract contract ERC20EVCCompatible is EVCUtil, ERC20Permit { | ||
constructor(address _evc_, string memory _name_, string memory _symbol_) | ||
EVCUtil(_evc_) | ||
ERC20(_name_, _symbol_) | ||
ERC20Permit(_name_) | ||
{} | ||
|
||
/// @notice Retrieves the message sender in the context of the EVC. | ||
/// @dev Overriden due to the conflict with the Context definition. | ||
/// @dev This function returns the account on behalf of which the current operation is being performed, which is | ||
/// either msg.sender or the account authenticated by the EVC. | ||
/// @return The address of the message sender. | ||
function _msgSender() internal view virtual override (EVCUtil, Context) returns (address) { | ||
return EVCUtil._msgSender(); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -4,17 +4,15 @@ pragma solidity ^0.8.0; | |
|
||
import {Ownable} from "openzeppelin-contracts/access/Ownable.sol"; | ||
import {EnumerableSet} from "openzeppelin-contracts/utils/structs/EnumerableSet.sol"; | ||
import {IEVC, EVCUtil} from "ethereum-vault-connector/utils/EVCUtil.sol"; | ||
import {ERC20Collateral, ERC20, Context} from "./ERC20Collateral.sol"; | ||
import {ERC20EVCCompatible, Context} from "./ERC20EVCCompatible.sol"; | ||
import {IEVault} from "../EVault/IEVault.sol"; | ||
|
||
/// @title ESynth | ||
/// @custom:security-contact [email protected] | ||
/// @author Euler Labs (https://www.eulerlabs.com/) | ||
/// @notice ESynth is an ERC20-compatible token with the EVC support which, thanks to relying on the EVC authentication | ||
/// and requesting the account status checks on token transfers and burns, allows it to be used as collateral in other | ||
/// vault. It is meant to be used as an underlying asset of the synthetic asset vault. | ||
contract ESynth is ERC20Collateral, Ownable { | ||
/// @notice ESynth is an ERC20-compatible token with the EVC support. It is meant to be used as an underlying asset of | ||
/// the synthetic asset vault. | ||
contract ESynth is ERC20EVCCompatible, Ownable { | ||
using EnumerableSet for EnumerableSet.AddressSet; | ||
|
||
struct MinterData { | ||
|
@@ -35,8 +33,8 @@ contract ESynth is ERC20Collateral, Ownable { | |
error E_CapacityReached(); | ||
error E_NotEVCCompatible(); | ||
|
||
constructor(IEVC evc_, string memory name_, string memory symbol_) | ||
ERC20Collateral(evc_, name_, symbol_) | ||
constructor(address evc_, string memory name_, string memory symbol_) | ||
ERC20EVCCompatible(evc_, name_, symbol_) | ||
Ownable(msg.sender) | ||
{ | ||
ignoredForTotalSupply.add(address(this)); | ||
|
@@ -54,7 +52,7 @@ contract ESynth is ERC20Collateral, Ownable { | |
/// @notice Mints a certain amount of tokens to the account. | ||
/// @param account The account to mint the tokens to. | ||
/// @param amount The amount of tokens to mint. | ||
function mint(address account, uint256 amount) external nonReentrant { | ||
function mint(address account, uint256 amount) external { | ||
address sender = _msgSender(); | ||
MinterData memory minterCache = minters[sender]; | ||
|
||
|
@@ -80,7 +78,7 @@ contract ESynth is ERC20Collateral, Ownable { | |
/// have an allowance for the sender. | ||
/// @param burnFrom The account to burn the tokens from. | ||
/// @param amount The amount of tokens to burn. | ||
function burn(address burnFrom, uint256 amount) external nonReentrant { | ||
function burn(address burnFrom, uint256 amount) external { | ||
address sender = _msgSender(); | ||
MinterData memory minterCache = minters[sender]; | ||
|
||
|
@@ -129,8 +127,8 @@ contract ESynth is ERC20Collateral, Ownable { | |
/// @dev This function returns the account on behalf of which the current operation is being performed, which is | ||
/// either msg.sender or the account authenticated by the EVC. | ||
/// @return msgSender The address of the message sender. | ||
function _msgSender() internal view virtual override (ERC20Collateral, Context) returns (address msgSender) { | ||
return ERC20Collateral._msgSender(); | ||
function _msgSender() internal view virtual override (ERC20EVCCompatible, Context) returns (address msgSender) { | ||
return ERC20EVCCompatible._msgSender(); | ||
} | ||
|
||
// -------- TotalSupply Management -------- | ||
|
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
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