-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathPoolInfo.vy
108 lines (90 loc) · 3.51 KB
/
PoolInfo.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
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
102
103
104
105
106
107
108
"""
@title Curve Registry PoolInfo
@license MIT
@author Curve.Fi
@notice Large getters designed for off-chain use
"""
MAX_COINS: constant(int128) = 8
interface AddressProvider:
def get_registry() -> address: view
def admin() -> address: view
interface Registry:
def get_coins(_pool: address) -> address[MAX_COINS]: view
def get_underlying_coins(_pool: address) -> address[MAX_COINS]: view
def get_decimals(_pool: address) -> uint256[MAX_COINS]: view
def get_underlying_decimals(_pool: address) -> uint256[MAX_COINS]: view
def get_balances(_pool: address) -> uint256[MAX_COINS]: view
def get_underlying_balances(_pool: address) -> uint256[MAX_COINS]: view
def get_rates(_pool: address) -> uint256[MAX_COINS]: view
def get_lp_token(_pool: address) -> address: view
def get_parameters(_pool: address) -> PoolParams: view
def is_meta(_pool: address) -> bool: view
def get_pool_name(_pool: address) -> String[64]: view
struct PoolParams:
A: uint256
future_A: uint256
fee: uint256
admin_fee: uint256
future_fee: uint256
future_admin_fee: uint256
future_owner: address
initial_A: uint256
initial_A_time: uint256
future_A_time: uint256
struct PoolInfo:
balances: uint256[MAX_COINS]
underlying_balances: uint256[MAX_COINS]
decimals: uint256[MAX_COINS]
underlying_decimals: uint256[MAX_COINS]
rates: uint256[MAX_COINS]
lp_token: address
params: PoolParams
is_meta: bool
name: String[64]
struct PoolCoins:
coins: address[MAX_COINS]
underlying_coins: address[MAX_COINS]
decimals: uint256[MAX_COINS]
underlying_decimals: uint256[MAX_COINS]
address_provider: public(AddressProvider)
@deploy
def __init__(_provider: address):
self.address_provider = AddressProvider(_provider)
@view
@external
def get_pool_coins(_pool: address) -> PoolCoins:
"""
@notice Get information on coins in a pool
@dev Empty values in the returned arrays may be ignored
@param _pool Pool address
@return Coin addresses, underlying coin addresses, underlying coin decimals
"""
registry: address = staticcall self.address_provider.get_registry()
return PoolCoins(
coins=staticcall Registry(registry).get_coins(_pool),
underlying_coins=staticcall Registry(registry).get_underlying_coins(_pool),
decimals=staticcall Registry(registry).get_decimals(_pool),
underlying_decimals=staticcall Registry(registry).get_underlying_decimals(_pool),
)
@view
@external
def get_pool_info(_pool: address) -> PoolInfo:
"""
@notice Get information on a pool
@dev Reverts if the pool address is unknown
@param _pool Pool address
@return balances, underlying balances, decimals, underlying decimals,
lp token, amplification coefficient, fees
"""
registry: address = staticcall self.address_provider.get_registry()
return PoolInfo(
balances=staticcall Registry(registry).get_balances(_pool),
underlying_balances=staticcall Registry(registry).get_underlying_balances(_pool),
decimals=staticcall Registry(registry).get_decimals(_pool),
underlying_decimals=staticcall Registry(registry).get_underlying_decimals(_pool),
rates=staticcall Registry(registry).get_rates(_pool),
lp_token=staticcall Registry(registry).get_lp_token(_pool),
params=staticcall Registry(registry).get_parameters(_pool),
is_meta=staticcall Registry(registry).is_meta(_pool),
name=staticcall Registry(registry).get_pool_name(_pool),
)