generated from ZeframLou/foundry-template
-
Notifications
You must be signed in to change notification settings - Fork 15
/
ERC20Gate.sol
101 lines (90 loc) · 2.48 KB
/
ERC20Gate.sol
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.13;
import {ERC20} from "solmate/tokens/ERC20.sol";
import {Gate} from "../Gate.sol";
import {Factory} from "../Factory.sol";
/// @title ERC20Gate
/// @author zefram.eth
/// @notice Abstract implementation of Gate for protocols using ERC20 vault shares.
abstract contract ERC20Gate is Gate {
/// -----------------------------------------------------------------------
/// Initialization
/// -----------------------------------------------------------------------
constructor(Factory factory_) Gate(factory_) {}
/// -----------------------------------------------------------------------
/// Getters
/// -----------------------------------------------------------------------
function getVaultShareBalance(address vault)
public
view
virtual
override
returns (uint256)
{
return ERC20(vault).balanceOf(address(this));
}
/// @inheritdoc Gate
function vaultSharesIsERC20() public pure virtual override returns (bool) {
return true;
}
/// @inheritdoc Gate
function negativeYieldTokenName(address vault)
external
view
virtual
override
returns (string memory)
{
return
string(
abi.encodePacked(
"Timeless ",
ERC20(vault).name(),
" Negative Yield Token"
)
);
}
/// @inheritdoc Gate
function negativeYieldTokenSymbol(address vault)
external
view
virtual
override
returns (string memory)
{
return
string(
abi.encodePacked(unicode"∞-", ERC20(vault).symbol(), "-NYT")
);
}
/// @inheritdoc Gate
function perpetualYieldTokenName(address vault)
external
view
virtual
override
returns (string memory)
{
return
string(
abi.encodePacked(
"Timeless ",
ERC20(vault).name(),
" Perpetual Yield Token"
)
);
}
/// @inheritdoc Gate
function perpetualYieldTokenSymbol(address vault)
external
view
virtual
override
returns (string memory)
{
return
string(
abi.encodePacked(unicode"∞-", ERC20(vault).symbol(), "-PYT")
);
}
}