-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVault.vy
68 lines (46 loc) · 1.35 KB
/
Vault.vy
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
# pragma version 0.3.10
"""
@title Vault
@author CurveFi
@notice Holds the chain native asset and ERC20s
"""
from vyper.interfaces import ERC20
event CommitOwnership:
future_owner: address
event ApplyOwnership:
owner: address
NATIVE: constant(address) = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
owner: public(address)
future_owner: public(address)
@external
def __init__(_owner: address):
self.owner = _owner
log ApplyOwnership(_owner)
@external
def transfer(_token: address, _to: address, _value: uint256):
"""
@notice Transfer an asset
@param _token The token to transfer, or NATIVE if transferring the chain native asset
@param _to The destination of the asset
@param _value The amount of the asset to transfer
"""
assert msg.sender == self.owner
if _token == NATIVE:
send(_to, _value)
else:
assert ERC20(_token).transfer(_to, _value, default_return_value=True)
@external
def commit_future_owner(_future_owner: address):
assert msg.sender == self.owner
self.future_owner = _future_owner
log CommitOwnership(_future_owner)
@external
def apply_future_owner():
assert msg.sender == self.owner
future_owner: address = self.future_owner
self.owner = future_owner
log ApplyOwnership(future_owner)
@payable
@external
def __default__():
assert len(msg.data) == 0