-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b47984
commit 4596650
Showing
6 changed files
with
121 additions
and
49 deletions.
There are no files selected for viewing
This file was deleted.
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,39 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
|
||
import {ERC20Upgradeable} from "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol"; | ||
import {Ownable2StepUpgradeable} from | ||
"lib/openzeppelin-contracts-upgradeable/contracts/access/Ownable2StepUpgradeable.sol"; | ||
import {ERC20VotesUpgradeable} from | ||
"lib/openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/ERC20VotesUpgradeable.sol"; | ||
import { | ||
ERC20PermitUpgradeable, | ||
NoncesUpgradeable | ||
} from "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/ERC20PermitUpgradeable.sol"; | ||
|
||
contract MorphoTokenVotesNoWrapper is ERC20VotesUpgradeable, ERC20PermitUpgradeable, Ownable2StepUpgradeable { | ||
string constant NAME = "Morpho"; | ||
string constant SYMBOL = "Morpho"; | ||
address constant DAO = address(0x0); | ||
address constant LEGACY_MORPHO = address(0x0); | ||
|
||
function initialize() public initializer { | ||
ERC20VotesUpgradeable.__ERC20Votes_init_unchained(); | ||
ERC20Upgradeable.__ERC20_init_unchained(NAME, SYMBOL); | ||
Ownable2StepUpgradeable.__Ownable2Step_init(); | ||
ERC20PermitUpgradeable.__ERC20Permit_init(NAME); | ||
|
||
_mint(DAO, 1_000_000_000e18); // Mint 1B to the DAO. | ||
} | ||
|
||
function _update(address from, address to, uint256 value) | ||
internal | ||
override(ERC20Upgradeable, ERC20VotesUpgradeable) | ||
{ | ||
ERC20VotesUpgradeable._update(from, to, value); | ||
} | ||
|
||
function nonces(address owner) public view override(ERC20PermitUpgradeable, NoncesUpgradeable) returns (uint256) { | ||
return ERC20PermitUpgradeable.nonces(owner); | ||
} | ||
} |
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,59 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
|
||
import { | ||
IERC20, ERC20Upgradeable | ||
} from "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC20/ERC20Upgradeable.sol"; | ||
import {Ownable2StepUpgradeable} from | ||
"lib/openzeppelin-contracts-upgradeable/contracts/access/Ownable2StepUpgradeable.sol"; | ||
import {ERC20VotesUpgradeable} from | ||
"lib/openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/ERC20VotesUpgradeable.sol"; | ||
import {ERC20WrapperUpgradeable} from | ||
"lib/openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/ERC20WrapperUpgradeable.sol"; | ||
import { | ||
ERC20PermitUpgradeable, | ||
NoncesUpgradeable | ||
} from "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/ERC20PermitUpgradeable.sol"; | ||
|
||
contract MorphoTokenVotesWrapper is | ||
ERC20VotesUpgradeable, | ||
ERC20WrapperUpgradeable, | ||
ERC20PermitUpgradeable, | ||
Ownable2StepUpgradeable | ||
{ | ||
string constant NAME = "Morpho"; | ||
string constant SYMBOL = "Morpho"; | ||
address constant LEGACY_MORPHO = address(0x0); | ||
address constant DAO = address(0x0); | ||
|
||
function initialize() public initializer { | ||
ERC20VotesUpgradeable.__ERC20Votes_init_unchained(); | ||
ERC20Upgradeable.__ERC20_init_unchained(NAME, SYMBOL); | ||
Ownable2StepUpgradeable.__Ownable2Step_init(); | ||
ERC20PermitUpgradeable.__ERC20Permit_init(NAME); | ||
ERC20WrapperUpgradeable.__ERC20Wrapper_init_unchained(IERC20(LEGACY_MORPHO)); | ||
} | ||
|
||
function _update(address from, address to, uint256 value) | ||
internal | ||
override(ERC20Upgradeable, ERC20VotesUpgradeable) | ||
{ | ||
ERC20VotesUpgradeable._update(from, to, value); | ||
} | ||
|
||
function nonces(address owner) public view override(ERC20PermitUpgradeable, NoncesUpgradeable) returns (uint256) { | ||
return ERC20PermitUpgradeable.nonces(owner); | ||
} | ||
|
||
function decimals() public view override(ERC20Upgradeable, ERC20WrapperUpgradeable) returns (uint8) { | ||
return ERC20WrapperUpgradeable.decimals(); | ||
} | ||
|
||
// No need to override depositFor as it wraps 1:1 legacy tokens to new tokens. | ||
// We would also mint 1B MORPHO tokens to the DAO at initialization and do the same thing as in `Wrapper` contract here. | ||
// function depositFor(address account, uint256 amount) public override returns (bool) | ||
|
||
function withdrawTo(address, uint256) public override pure returns (bool) { | ||
return false; | ||
} | ||
} |
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,20 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
|
||
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
|
||
interface IBurn { | ||
function burn(uint256 amount) external; | ||
} | ||
|
||
contract Wrapper { | ||
address public constant LEGACY_MORPHO = address(0x0); | ||
address public constant DAO = address(0x0); | ||
address public constant MORPHO = address(0x0); | ||
|
||
function wrap(uint256 amount) external { | ||
IERC20(LEGACY_MORPHO).transferFrom(msg.sender, address(this), amount); | ||
IBurn(LEGACY_MORPHO).burn(amount); | ||
IERC20(MORPHO).transferFrom(DAO, msg.sender, 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