-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathBaseERC20.sol
More file actions
59 lines (46 loc) · 1.82 KB
/
BaseERC20.sol
File metadata and controls
59 lines (46 loc) · 1.82 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.4;
import {ERC20} from "solmate/tokens/ERC20.sol";
import {Gate} from "../Gate.sol";
/// @title BaseERC20
/// @author zefram.eth
/// @notice The base ERC20 contract used by NegativeYieldToken and PerpetualYieldToken
/// @dev Uses the same number of decimals as the vault's underlying token
contract BaseERC20 is ERC20 {
/// -----------------------------------------------------------------------
/// Errors
/// -----------------------------------------------------------------------
error Error_NotGate();
/// -----------------------------------------------------------------------
/// Immutable parameters
/// -----------------------------------------------------------------------
Gate public immutable gate;
address public immutable vault;
/// -----------------------------------------------------------------------
/// Constructor
/// -----------------------------------------------------------------------
constructor(
string memory name_,
string memory symbol_,
Gate gate_,
address vault_
) ERC20(name_, symbol_, gate_.getUnderlyingOfVault(vault_).decimals()) {
gate = gate_;
vault = vault_;
}
/// -----------------------------------------------------------------------
/// Gate-callable functions
/// -----------------------------------------------------------------------
function gateMint(address to, uint256 amount) external virtual {
if (msg.sender != address(gate)) {
revert Error_NotGate();
}
_mint(to, amount);
}
function gateBurn(address from, uint256 amount) external virtual {
if (msg.sender != address(gate)) {
revert Error_NotGate();
}
_burn(from, amount);
}
}