Skip to content

Commit

Permalink
added example for a custom ERC20 wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
d10r committed Aug 6, 2024
1 parent 87e0591 commit 39a78d9
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions contracts/CustomERC20Wrapper.sol
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 {}

0 comments on commit 39a78d9

Please sign in to comment.