eth-portfolio 1.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of eth-portfolio might be problematic. Click here for more details.

Files changed (47) hide show
  1. eth_portfolio/__init__.py +16 -0
  2. eth_portfolio/_argspec.py +42 -0
  3. eth_portfolio/_cache.py +116 -0
  4. eth_portfolio/_config.py +3 -0
  5. eth_portfolio/_db/__init__.py +0 -0
  6. eth_portfolio/_db/decorators.py +147 -0
  7. eth_portfolio/_db/entities.py +204 -0
  8. eth_portfolio/_db/utils.py +595 -0
  9. eth_portfolio/_decimal.py +122 -0
  10. eth_portfolio/_decorators.py +71 -0
  11. eth_portfolio/_exceptions.py +67 -0
  12. eth_portfolio/_ledgers/__init__.py +0 -0
  13. eth_portfolio/_ledgers/address.py +892 -0
  14. eth_portfolio/_ledgers/portfolio.py +327 -0
  15. eth_portfolio/_loaders/__init__.py +33 -0
  16. eth_portfolio/_loaders/balances.py +78 -0
  17. eth_portfolio/_loaders/token_transfer.py +214 -0
  18. eth_portfolio/_loaders/transaction.py +379 -0
  19. eth_portfolio/_loaders/utils.py +59 -0
  20. eth_portfolio/_shitcoins.py +212 -0
  21. eth_portfolio/_utils.py +286 -0
  22. eth_portfolio/_ydb/__init__.py +0 -0
  23. eth_portfolio/_ydb/token_transfers.py +136 -0
  24. eth_portfolio/address.py +382 -0
  25. eth_portfolio/buckets.py +181 -0
  26. eth_portfolio/constants.py +58 -0
  27. eth_portfolio/portfolio.py +629 -0
  28. eth_portfolio/protocols/__init__.py +66 -0
  29. eth_portfolio/protocols/_base.py +107 -0
  30. eth_portfolio/protocols/convex.py +17 -0
  31. eth_portfolio/protocols/dsr.py +31 -0
  32. eth_portfolio/protocols/lending/__init__.py +49 -0
  33. eth_portfolio/protocols/lending/_base.py +57 -0
  34. eth_portfolio/protocols/lending/compound.py +185 -0
  35. eth_portfolio/protocols/lending/liquity.py +110 -0
  36. eth_portfolio/protocols/lending/maker.py +105 -0
  37. eth_portfolio/protocols/lending/unit.py +47 -0
  38. eth_portfolio/protocols/liquity.py +16 -0
  39. eth_portfolio/py.typed +0 -0
  40. eth_portfolio/structs/__init__.py +43 -0
  41. eth_portfolio/structs/modified.py +69 -0
  42. eth_portfolio/structs/structs.py +637 -0
  43. eth_portfolio/typing.py +1460 -0
  44. eth_portfolio-1.1.0.dist-info/METADATA +174 -0
  45. eth_portfolio-1.1.0.dist-info/RECORD +47 -0
  46. eth_portfolio-1.1.0.dist-info/WHEEL +5 -0
  47. eth_portfolio-1.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,382 @@
1
+ """
2
+ This module defines the :class:`~PortfolioAddress` class, which represents an address managed by the `eth-portfolio` system.
3
+ The :class:`~PortfolioAddress` class is designed to manage different aspects of an Ethereum address within the portfolio,
4
+ such as transactions, transfers, balances, and interactions with both external and lending protocols.
5
+
6
+ Key components and functionalities provided by the :class:`~eth_portfolio.address.PortfolioAddress` class include:
7
+ - Handling Ethereum and token balances
8
+ - Managing debt and collateral from lending protocols
9
+ - Tracking transactions and transfers (both internal and token transfers)
10
+ - Providing comprehensive balance descriptions at specific block heights
11
+
12
+ The class leverages asynchronous operations using the `a_sync` library to efficiently gather and process data.
13
+ It also integrates with various submodules from `eth-portfolio` to load balances, manage ledgers, and interact
14
+ with external protocols.
15
+ """
16
+
17
+ import logging
18
+ from asyncio import gather
19
+ from typing import Dict, Optional
20
+
21
+ import a_sync
22
+ import dank_mids
23
+ import eth_retry
24
+ import y
25
+ from a_sync.exceptions import MappingIsEmptyError
26
+ from y import convert
27
+ from y._decorators import stuck_coro_debugger
28
+ from y.datatypes import Address, Block
29
+
30
+ from eth_portfolio import protocols
31
+ from eth_portfolio._ledgers.address import (
32
+ AddressInternalTransfersLedger,
33
+ AddressLedgerBase,
34
+ AddressTokenTransfersLedger,
35
+ AddressTransactionsLedger,
36
+ PandableLedgerEntryList,
37
+ )
38
+ from eth_portfolio._loaders import balances
39
+ from eth_portfolio._utils import _LedgeredBase, _get_price
40
+ from eth_portfolio.typing import Balance, RemoteTokenBalances, TokenBalances, WalletBalances
41
+
42
+
43
+ logger = logging.getLogger(__name__)
44
+
45
+
46
+ class PortfolioAddress(_LedgeredBase[AddressLedgerBase]):
47
+ """
48
+ Represents a portfolio address within the eth-portfolio system.
49
+
50
+ This class is designed to manage different aspects of an Ethereum address within the portfolio,
51
+ such as transactions, transfers, balances, and interactions with both external and lending protocols.
52
+
53
+ Key components and functionalities provided by the :class:`~eth_portfolio.address.PortfolioAddress` class include:
54
+ - Handling Ethereum and token balances
55
+ - Managing debt and collateral from lending protocols
56
+ - Tracking transactions and transfers (both internal and token transfers)
57
+ - Providing comprehensive balance descriptions at specific block heights
58
+
59
+ The class leverages asynchronous operations using the `a_sync` library to efficiently gather and process data.
60
+ It also integrates with various submodules from `eth-portfolio` to load balances, manage ledgers, and interact
61
+ with external protocols.
62
+ """
63
+
64
+ def __init__(
65
+ self,
66
+ address: Address,
67
+ start_block: Block,
68
+ load_prices: bool,
69
+ num_workers_transactions: int = 1000,
70
+ asynchronous: bool = False,
71
+ ) -> None: # type: ignore
72
+ """
73
+ Initializes the :class:`~PortfolioAddress` instance.
74
+
75
+ Args:
76
+ address: The Ethereum address to manage.
77
+ start_block: The block number from which to start tracking.
78
+ load_prices: Flag indicating if price loading is enabled.
79
+ num_workers_transactions (optional): Number of workers for transaction processing. Defaults to 1000.
80
+ asynchronous (optional): Flag for asynchronous operation. Defaults to False.
81
+
82
+ Raises:
83
+ TypeError: If `asynchronous` is not a boolean.
84
+
85
+ Examples:
86
+ >>> address = PortfolioAddress('0x1234...', 0, True)
87
+ >>> print(address)
88
+
89
+ >>> address = PortfolioAddress('0x1234...', 0, False, num_workers_transactions=500, asynchronous=True)
90
+ >>> print(address)
91
+
92
+ See Also:
93
+ - :class:`~eth_portfolio.portfolio.Portfolio`
94
+ - :class:`~eth_portfolio._ledgers.address.AddressTransactionsLedger`
95
+ - :class:`~eth_portfolio._ledgers.address.AddressInternalTransfersLedger`
96
+ - :class:`~eth_portfolio._ledgers.address.AddressTokenTransfersLedger`
97
+ """
98
+ self.address = convert.to_address(address)
99
+ """
100
+ The address being managed.
101
+ """
102
+ if not isinstance(asynchronous, bool):
103
+ raise TypeError(f"`asynchronous` must be a boolean, you passed {type(asynchronous)}")
104
+ self.asynchronous = asynchronous
105
+ """
106
+ Flag indicating if the operations are asynchronous.
107
+ """
108
+ self.load_prices = load_prices
109
+ """
110
+ Indicates if price loading is enabled.
111
+ """
112
+
113
+ super().__init__(start_block)
114
+
115
+ self.transactions = AddressTransactionsLedger(self, num_workers_transactions)
116
+ """
117
+ Ledger for tracking transactions.
118
+ """
119
+ self.internal_transfers = AddressInternalTransfersLedger(self)
120
+ """
121
+ Ledger for tracking internal transfers.
122
+ """
123
+ self.token_transfers = AddressTokenTransfersLedger(self)
124
+ """
125
+ Ledger for tracking token transfers.
126
+ """
127
+
128
+ def __str__(self) -> str:
129
+ """
130
+ Returns the string representation of the address.
131
+
132
+ Returns:
133
+ The address as a string.
134
+ """
135
+ return self.address
136
+
137
+ def __repr__(self) -> str:
138
+ """
139
+ Returns the string representation of the PortfolioAddress instance.
140
+
141
+ Returns:
142
+ The string representation.
143
+ """
144
+ return f"<{self.__class__.__name__} address={self.address} at {hex(id(self))}>"
145
+
146
+ def __eq__(self, other: object) -> bool:
147
+ """
148
+ Checks equality with another object.
149
+
150
+ Args:
151
+ other: The object to compare with.
152
+
153
+ Returns:
154
+ True if equal, False otherwise.
155
+ """
156
+ if isinstance(other, PortfolioAddress):
157
+ return self.address == other.address
158
+ elif isinstance(other, str):
159
+ return self.address == convert.to_address(other)
160
+ return False
161
+
162
+ def __hash__(self) -> int:
163
+ """
164
+ Returns the hash of the address.
165
+
166
+ Returns:
167
+ The hash value.
168
+ """
169
+ return hash(self.address)
170
+
171
+ # Primary functions
172
+
173
+ @stuck_coro_debugger
174
+ async def describe(self, block: int) -> WalletBalances:
175
+ """
176
+ Describes all of the wallet's balances at a given block.
177
+
178
+ Args:
179
+ block: The block number.
180
+
181
+ Returns:
182
+ :class:`~eth_portfolio.typing.WalletBalances`: The wallet balances.
183
+
184
+ Raises:
185
+ TypeError: If block is not an integer.
186
+
187
+ Examples:
188
+ >>> wallet_balances = await address.describe(12345678)
189
+ """
190
+ if not isinstance(block, int):
191
+ raise TypeError(f"Block must be an integer. You passed {type(block)} {block}")
192
+ coros = {
193
+ "assets": self.assets(block, sync=False),
194
+ "debt": self.debt(block, sync=False),
195
+ "external": self.external_balances(block, sync=False),
196
+ }
197
+ data = await a_sync.gather(coros)
198
+ for ds in data.values():
199
+ assert ds.block, ds
200
+ for t, d in ds.items():
201
+ assert d.block, ds
202
+ return WalletBalances(data, block=block)
203
+
204
+ @stuck_coro_debugger
205
+ async def assets(self, block: Optional[Block] = None) -> TokenBalances:
206
+ """
207
+ Retrieves the balances for every asset in the wallet at a given block.
208
+
209
+ Args:
210
+ block (optional): The block number to query. Defaults to None, which uses the latest block.
211
+
212
+ Returns:
213
+ :class:`~eth_portfolio.typing.TokenBalances`: The asset balances at `block`.
214
+
215
+ Examples:
216
+ >>> assets = await address.assets(12345678)
217
+ """
218
+ return await self.balances(block=block, sync=False)
219
+
220
+ @stuck_coro_debugger
221
+ async def debt(self, block: Optional[Block] = None) -> RemoteTokenBalances:
222
+ """
223
+ Retrieves all debt balances for the wallet at a given block.
224
+
225
+ Args:
226
+ block (optional): The block number. Defaults to None, which uses the latest block.
227
+
228
+ Returns:
229
+ :class:`~eth_portfolio.typing.RemoteTokenBalances`: The debt balances at `block`.
230
+
231
+ Examples:
232
+ >>> debt = await address.debt(12345678)
233
+ """
234
+ return await protocols.lending.debt(self.address, block=block)
235
+
236
+ @stuck_coro_debugger
237
+ async def external_balances(self, block: Optional[Block] = None) -> RemoteTokenBalances:
238
+ """
239
+ Retrieves the balances owned by the wallet, but not held *in* the wallet, at a given block.
240
+
241
+ Args:
242
+ block (optional): The block number. Defaults to None, which uses the latest block.
243
+
244
+ Returns:
245
+ :class:`~eth_portfolio.typing.RemoteTokenBalances`: The external balances.
246
+
247
+ Examples:
248
+ >>> external_balances = await address.external_balances(12345678)
249
+ """
250
+ balances = await gather(self.staking(block, sync=False), self.collateral(block, sync=False))
251
+ return sum(balances) # type: ignore [arg-type, return-value]
252
+
253
+ # Assets
254
+
255
+ @stuck_coro_debugger
256
+ async def balances(self, block: Optional[Block]) -> TokenBalances:
257
+ """
258
+ Retrieves balances for all assets in the wallet at a given block.
259
+
260
+ Args:
261
+ block: The block number.
262
+
263
+ Returns:
264
+ :class:`~eth_portfolio.typing.TokenBalances`: The balances.
265
+
266
+ Examples:
267
+ >>> balances = await address.balances(12345678)
268
+ """
269
+ eth_balance, token_balances = await gather(
270
+ self.eth_balance(block, sync=False),
271
+ self.token_balances(block, sync=False),
272
+ )
273
+ token_balances[y.EEE_ADDRESS] = eth_balance
274
+ return token_balances
275
+
276
+ @eth_retry.auto_retry
277
+ @stuck_coro_debugger
278
+ async def eth_balance(self, block: Optional[Block]) -> Balance:
279
+ """
280
+ Retrieves the ETH balance for the wallet at a given block.
281
+
282
+ Args:
283
+ block: The block number.
284
+
285
+ Returns:
286
+ :class:`~eth_portfolio.typing.Balance`: The ETH balance at `block`.
287
+
288
+ Examples:
289
+ >>> eth_balance = await address.eth_balance(12345678)
290
+ """
291
+ if balance := await dank_mids.eth.get_balance(self.address, block_identifier=block):
292
+ price = await _get_price(y.WRAPPED_GAS_COIN, block)
293
+ return Balance(
294
+ balance.scaled,
295
+ round(balance.scaled * price, 18),
296
+ token=y.EEE_ADDRESS,
297
+ block=block,
298
+ )
299
+ return Balance(token=y.EEE_ADDRESS, block=block)
300
+
301
+ @stuck_coro_debugger
302
+ async def token_balances(self, block) -> TokenBalances:
303
+ """
304
+ Retrieves the balances for all tokens in the wallet at a given block.
305
+
306
+ Args:
307
+ block: The block number.
308
+
309
+ Returns:
310
+ :class:`~eth_portfolio.typing.TokenBalances`: The token balances at `block`.
311
+
312
+ Examples:
313
+ >>> token_balances = await address.token_balances(12345678)
314
+ """
315
+ try:
316
+ data = a_sync.map(
317
+ balances.load_token_balance,
318
+ self.token_transfers._yield_tokens_at_block(block=block),
319
+ address=self.address,
320
+ block=block,
321
+ )
322
+ return TokenBalances(await data, block=block)
323
+ except MappingIsEmptyError:
324
+ return TokenBalances(block=block)
325
+
326
+ @stuck_coro_debugger
327
+ async def collateral(self, block: Optional[Block] = None) -> RemoteTokenBalances:
328
+ """
329
+ Retrieves all balances held by lending protocols on behalf of the wallet at a given block.
330
+
331
+ Args:
332
+ block (optional): The block number. Defaults to None, which uses the latest block.
333
+
334
+ Returns:
335
+ :class:`~eth_portfolio.typing.RemoteTokenBalances`: The collateral balances.
336
+
337
+ Examples:
338
+ >>> collateral = await address.collateral(12345678)
339
+ """
340
+ return await protocols.lending.collateral(self.address, block=block)
341
+
342
+ @stuck_coro_debugger
343
+ async def staking(self, block: Optional[Block] = None) -> RemoteTokenBalances:
344
+ """
345
+ Retrieves all balances staked in protocols supported by eth_portfolio on behalf of the wallet at a given block.
346
+
347
+ Args:
348
+ block (optional): The block number. Defaults to None, which uses the latest block.
349
+
350
+ Returns:
351
+ :class:`~eth_portfolio.typing.RemoteTokenBalances`: The staked balances.
352
+
353
+ Examples:
354
+ >>> staking_balances = await address.staking(12345678)
355
+ """
356
+ return await protocols.balances(self.address, block=block)
357
+
358
+ # Ledger Entries
359
+
360
+ @stuck_coro_debugger
361
+ async def all(self, start_block: Block, end_block: Block) -> Dict[str, PandableLedgerEntryList]:
362
+ """
363
+ Retrieves all ledger entries between two blocks.
364
+
365
+ Args:
366
+ start_block: The starting block number.
367
+ end_block: The ending block number.
368
+
369
+ Returns:
370
+ Dict[str, :class:`~eth_portfolio._ledgers.address.PandableLedgerEntryList`]: The ledger entries.
371
+
372
+ Examples:
373
+ >>> all_entries = await address.all(12000000, 12345678)
374
+ """
375
+ coros = {
376
+ "transactions": self.transactions.get(start_block, end_block, sync=False),
377
+ "internal_transactions": self.internal_transfers.get(
378
+ start_block, end_block, sync=False
379
+ ),
380
+ "token_transfers": self.token_transfers.get(start_block, end_block, sync=False),
381
+ }
382
+ return await a_sync.gather(coros)
@@ -0,0 +1,181 @@
1
+ import logging
2
+ from asyncio import gather
3
+ from typing import Optional, Set
4
+
5
+ from async_lru import alru_cache
6
+ from brownie import chain
7
+ from y.constants import STABLECOINS, WRAPPED_GAS_COIN
8
+ from y.datatypes import Address, AnyAddressType
9
+ from y.prices.lending.aave import aave
10
+ from y.prices.lending.compound import CToken, compound
11
+ from y.prices.stable_swap.curve import curve
12
+ from y.prices.yearn import YearnInspiredVault, is_yearn_vault
13
+
14
+ from eth_portfolio.constants import BTC_LIKE, ETH_LIKE, INTL_STABLECOINS
15
+
16
+ logger = logging.getLogger(__name__)
17
+
18
+ OTHER_LONG_TERM_ASSETS: Set[Address] = {}.get(chain.id, set())
19
+
20
+
21
+ async def get_token_bucket(token: AnyAddressType) -> str:
22
+ """
23
+ Categorize a token into a specific bucket based on its type.
24
+
25
+ This function attempts to categorize a given token into predefined buckets
26
+ such as "Cash & cash equivalents", "ETH", "BTC", "Other long term assets",
27
+ or "Other short term assets". The categorization is based on the token's
28
+ characteristics and its presence in specific sets like :data:`ETH_LIKE`, :data:`BTC_LIKE`,
29
+ and :data:`OTHER_LONG_TERM_ASSETS`.
30
+
31
+ Args:
32
+ token: The address of the token to categorize.
33
+
34
+ Returns:
35
+ A string representing the bucket category of the token.
36
+
37
+ Raises:
38
+ ValueError: If the token's source has not been verified and the error message
39
+ does not match the expected pattern.
40
+
41
+ Example:
42
+ Categorize a stablecoin:
43
+
44
+ >>> await get_token_bucket("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48")
45
+ 'Cash & cash equivalents'
46
+
47
+ Categorize an ETH-like token:
48
+
49
+ >>> await get_token_bucket("0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE")
50
+ 'ETH'
51
+
52
+ See Also:
53
+ - :func:`_unwrap_token`
54
+ - :func:`_is_stable`
55
+ """
56
+ token = str(token)
57
+ try:
58
+ token = str(await _unwrap_token(token))
59
+ except ValueError as e:
60
+ if str(e).startswith("Source for") and str(e).endswith("has not been verified"):
61
+ return "Other short term assets"
62
+ raise
63
+
64
+ if _is_stable(token):
65
+ return "Cash & cash equivalents"
66
+ if token in ETH_LIKE:
67
+ return "ETH"
68
+ if token in BTC_LIKE:
69
+ return "BTC"
70
+ if token in OTHER_LONG_TERM_ASSETS:
71
+ return "Other long term assets"
72
+ return "Other short term assets"
73
+
74
+
75
+ @alru_cache(maxsize=None)
76
+ async def _unwrap_token(token) -> str:
77
+ """
78
+ Recursively unwrap a token to its underlying asset.
79
+
80
+ This function attempts to unwrap a given token to its underlying asset by
81
+ checking if the token is a Yearn vault, a Curve pool, an Aave aToken, or a
82
+ Compound market. It recursively retrieves the underlying asset until it
83
+ reaches the base token.
84
+
85
+ Args:
86
+ token: The address of the token to unwrap.
87
+
88
+ Returns:
89
+ The address of the underlying asset.
90
+
91
+ Example:
92
+ Unwrap a Yearn vault token:
93
+
94
+ >>> await _unwrap_token("0x5f18C75AbDAe578b483E5F43f12a39cF75b973a9")
95
+ '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
96
+
97
+ See Also:
98
+ - :func:`y.prices.yearn.is_yearn_vault`
99
+ - :class:`y.prices.yearn.YearnInspiredVault`
100
+ - :class:`y.prices.stable_swap.curve`
101
+ - :class:`y.prices.lending.aave`
102
+ - :class:`y.prices.lending.compound.CToken`
103
+ """
104
+ if str(token) in {"ETH", "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"}:
105
+ return token
106
+
107
+ if await is_yearn_vault(token, sync=False):
108
+ underlying = await YearnInspiredVault(token, asynchronous=True).underlying
109
+ return await _unwrap_token(underlying)
110
+ if curve and (pool := await curve.get_pool(token)):
111
+ pool_tokens = set(await gather(*[_unwrap_token(coin) for coin in await pool.coins]))
112
+ if pool_bucket := _pool_bucket(pool_tokens):
113
+ return pool_bucket # type: ignore
114
+ if aave and await aave.is_atoken(token):
115
+ return str(await aave.underlying(token))
116
+ if compound and await compound.is_compound_market(token):
117
+ try:
118
+ return str(await CToken(token, asynchronous=True).underlying)
119
+ except AttributeError:
120
+ return WRAPPED_GAS_COIN
121
+ return token
122
+
123
+
124
+ def _pool_bucket(pool_tokens: set) -> Optional[str]:
125
+ """
126
+ Determine the bucket for a set of pool tokens.
127
+
128
+ This function checks if a set of pool tokens belongs to specific categories
129
+ such as BTC-like, ETH-like, or stablecoins, and returns the corresponding
130
+ bucket.
131
+
132
+ Args:
133
+ pool_tokens: A set of token addresses representing the pool tokens.
134
+
135
+ Returns:
136
+ A string representing the bucket category of the pool tokens, or None if
137
+ no specific category is found.
138
+
139
+ Example:
140
+ Determine the bucket for a BTC-like pool:
141
+
142
+ >>> _pool_bucket({"0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599"})
143
+ '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599'
144
+
145
+ See Also:
146
+ - :data:`BTC_LIKE`
147
+ - :data:`ETH_LIKE`
148
+ - :data:`STABLECOINS`
149
+ - :data:`INTL_STABLECOINS`
150
+ """
151
+ logger.debug("Pool tokens: %s", pool_tokens)
152
+ if pool_tokens < BTC_LIKE:
153
+ return list(BTC_LIKE)[0]
154
+ if pool_tokens < ETH_LIKE:
155
+ return list(ETH_LIKE)[0]
156
+ if pool_tokens < STABLECOINS.keys():
157
+ return list(STABLECOINS.keys())[0]
158
+ return list(INTL_STABLECOINS)[0] if pool_tokens < INTL_STABLECOINS else None
159
+
160
+
161
+ def _is_stable(token: Address) -> bool:
162
+ """
163
+ Check if a token is a stablecoin.
164
+
165
+ This function checks if a given token is present in the :data:`STABLECOINS` or
166
+ :data:`INTL_STABLECOINS` sets, indicating that it is a stablecoin.
167
+
168
+ Args:
169
+ token: The address of the token to check.
170
+
171
+ Example:
172
+ Check if a token is a stablecoin:
173
+
174
+ >>> _is_stable("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48")
175
+ True
176
+
177
+ See Also:
178
+ - :data:`STABLECOINS`
179
+ - :data:`INTL_STABLECOINS`
180
+ """
181
+ return token in STABLECOINS or token in INTL_STABLECOINS
@@ -0,0 +1,58 @@
1
+ import os
2
+
3
+ from a_sync.executor import PruningThreadPoolExecutor
4
+ from brownie import chain
5
+ from y import Network, convert, weth
6
+
7
+ ERC20_TRANSFER_EVENT_HASH = "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
8
+ ERC677_TRANSFER_EVENT_HASH = "0xe19260aff97b920c7df27010903aeb9c8d2be5d310a2c67824cf3f15396e4c16"
9
+
10
+ NUM_WALLETS = int(os.environ.get("NUM_WALLETS", "10"))
11
+ ADDRESSES = [
12
+ convert.to_address(address)
13
+ for address in {os.environ.get(f"PORTFOLIO_ADDRESS_{i}", None) for i in range(NUM_WALLETS)}
14
+ if address is not None
15
+ ]
16
+
17
+ TRANSFER_SIGS = [ERC20_TRANSFER_EVENT_HASH, ERC677_TRANSFER_EVENT_HASH]
18
+
19
+ ETH_LIKE = {
20
+ Network.Mainnet: {
21
+ "ETH",
22
+ weth.address,
23
+ "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
24
+ "0x5e74C9036fb86BD7eCdcb084a0673EFc32eA31cb", # seth
25
+ "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", # eth
26
+ "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84", # steth
27
+ "0x9559Aaa82d9649C7A7b220E7c461d2E74c9a3593", # reth
28
+ "0xE95A203B1a91a908F9B9CE46459d101078c2c3cb", # ankreth
29
+ },
30
+ }.get(chain.id, set())
31
+
32
+ BTC_LIKE = {
33
+ Network.Mainnet: {
34
+ "0xEB4C2781e4ebA804CE9a9803C67d0893436bB27D", # renbtc
35
+ "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", # wbtc
36
+ "0xfE18be6b3Bd88A2D2A7f928d00292E7a9963CfC6", # sbtc
37
+ "0x8064d9Ae6cDf087b1bcd5BDf3531bD5d8C537a68", # obtc
38
+ "0x9BE89D2a4cd102D8Fecc6BF9dA793be995C22541", # bbtc
39
+ "0x0316EB71485b0Ab14103307bf65a021042c6d380", # hbtc
40
+ "0x5228a22e72ccC52d415EcFd199F99D0665E7733b", # pbtc
41
+ "0x8dAEBADE922dF735c38C80C7eBD708Af50815fAa", # tbtc
42
+ },
43
+ }.get(chain.id, set())
44
+
45
+ INTL_STABLECOINS = {
46
+ Network.Mainnet: {
47
+ "0xD71eCFF9342A5Ced620049e616c5035F1dB98620", # sEUR
48
+ "0xC581b735A1688071A1746c968e0798D642EDE491", # EURT
49
+ "0xdB25f211AB05b1c97D595516F45794528a807ad8", # EURS
50
+ "0x96E61422b6A9bA0e068B6c5ADd4fFaBC6a4aae27", # ibEUR
51
+ "0x269895a3dF4D73b077Fc823dD6dA1B95f72Aaf9B", # sKRW
52
+ "0x3F1B0278A9ee595635B61817630cC19DE792f506", # sAUD
53
+ "0x97fe22E7341a0Cd8Db6F6C021A24Dc8f4DAD855F", # sGBP
54
+ "0xF6b1C627e95BFc3c1b4c9B825a032Ff0fBf3e07d", # sJPY
55
+ "0x0F83287FF768D1c1e17a42F44d644D7F22e8ee1d", # sCHF
56
+ "0x269895a3dF4D73b077Fc823dD6dA1B95f72Aaf9B", # sKRW
57
+ },
58
+ }.get(chain.id, set())