-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added example for a custom ERC20 wrapper
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
pragma solidity 0.8.19; | ||
|
||
// This file contains show how to create a custom ERC20 Wrapper | ||
|
||
// This abstract contract provides storage padding for the proxy | ||
import { CustomSuperTokenBase } from "@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/CustomSuperTokenBase.sol"; | ||
// Implementation of UUPSProxy (see https://eips.ethereum.org/EIPS/eip-1822) | ||
import { UUPSProxy } from "./base/UUPSProxy.sol"; | ||
// Superfluid framework interfaces we need | ||
import { ISuperToken, ISuperTokenFactory, IERC20 } from "@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol"; | ||
// for the underlying token | ||
import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; | ||
|
||
/// @title The Proxy contract for a Custom ERC20 Wrapper | ||
contract CustomERC20WrapperProxy is CustomSuperTokenBase, UUPSProxy { | ||
|
||
// This shall be invoked exactly once after deployment, needed for the token contract to become operational. | ||
function initialize( | ||
IERC20Metadata underlyingToken, | ||
ISuperTokenFactory factory, | ||
string memory name, | ||
string memory symbol | ||
) external { | ||
// This call to the factory invokes `UUPSProxy.initialize`, which connects the proxy to the canonical SuperToken implementation. | ||
// It also emits an event which facilitates discovery of this token. | ||
ISuperTokenFactory(factory).initializeCustomSuperToken(address(this)); | ||
|
||
// This initializes the token storage and sets the `initialized` flag of OpenZeppelin Initializable. | ||
// This makes sure that it will revert if invoked more than once. | ||
ISuperToken(address(this)).initialize(underlyingToken, underlyingToken.decimals(), name, symbol); | ||
} | ||
|
||
// add custom functionality here... | ||
} | ||
|
||
interface ICustomERC20Wrapper is ISuperToken {} |