-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathPureSuperToken.sol
More file actions
43 lines (37 loc) · 2.04 KB
/
PureSuperToken.sol
File metadata and controls
43 lines (37 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity ^0.8.26;
// This file contains everything we need for a minimal Pure SuperToken.
// 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 "@superfluid-finance/ethereum-contracts/contracts/upgradability/UUPSProxy.sol";
// Superfluid framework interfaces we need
import {
ISuperToken,
ISuperTokenFactory,
IERC20
} from "@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol";
/// @title The Proxy contract for a Pure SuperToken with preminted initial supply.
contract PureSuperTokenProxy is CustomSuperTokenBase, UUPSProxy {
// This shall be invoked exactly once after deployment, needed for the token contract to become operational.
function initialize(
ISuperTokenFactory factory,
string memory name,
string memory symbol,
address receiver,
uint256 initialSupply
) 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(IERC20(address(0)), 18, name, symbol);
// This mints the specified initial supply to the specified receiver.
ISuperToken(address(this)).selfMint(receiver, initialSupply, "");
}
}
// The token interface is just an alias of ISuperToken
// since we need no custom logic (other than for initialization) in the proxy.
interface IPureSuperToken is ISuperToken {}