eth-portfolio-temp 0.0.39.dev0__cp312-cp312-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.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-temp might be problematic. Click here for more details.

Files changed (83) hide show
  1. 295eace8438df6ec133b__mypyc.cpython-312-i386-linux-gnu.so +0 -0
  2. eth_portfolio/__init__.py +25 -0
  3. eth_portfolio/_argspec.cpython-312-i386-linux-gnu.so +0 -0
  4. eth_portfolio/_argspec.py +42 -0
  5. eth_portfolio/_cache.py +121 -0
  6. eth_portfolio/_config.cpython-312-i386-linux-gnu.so +0 -0
  7. eth_portfolio/_config.py +4 -0
  8. eth_portfolio/_db/__init__.py +0 -0
  9. eth_portfolio/_db/decorators.py +147 -0
  10. eth_portfolio/_db/entities.py +311 -0
  11. eth_portfolio/_db/utils.py +606 -0
  12. eth_portfolio/_decimal.py +155 -0
  13. eth_portfolio/_decorators.py +84 -0
  14. eth_portfolio/_exceptions.py +67 -0
  15. eth_portfolio/_ledgers/__init__.py +0 -0
  16. eth_portfolio/_ledgers/address.py +938 -0
  17. eth_portfolio/_ledgers/portfolio.py +327 -0
  18. eth_portfolio/_loaders/__init__.py +33 -0
  19. eth_portfolio/_loaders/_nonce.cpython-312-i386-linux-gnu.so +0 -0
  20. eth_portfolio/_loaders/_nonce.py +196 -0
  21. eth_portfolio/_loaders/balances.cpython-312-i386-linux-gnu.so +0 -0
  22. eth_portfolio/_loaders/balances.py +94 -0
  23. eth_portfolio/_loaders/token_transfer.py +217 -0
  24. eth_portfolio/_loaders/transaction.py +240 -0
  25. eth_portfolio/_loaders/utils.cpython-312-i386-linux-gnu.so +0 -0
  26. eth_portfolio/_loaders/utils.py +68 -0
  27. eth_portfolio/_shitcoins.cpython-312-i386-linux-gnu.so +0 -0
  28. eth_portfolio/_shitcoins.py +277 -0
  29. eth_portfolio/_stableish.cpython-312-i386-linux-gnu.so +0 -0
  30. eth_portfolio/_stableish.py +42 -0
  31. eth_portfolio/_submodules.py +73 -0
  32. eth_portfolio/_utils.py +223 -0
  33. eth_portfolio/_ydb/__init__.py +0 -0
  34. eth_portfolio/_ydb/token_transfers.py +150 -0
  35. eth_portfolio/address.py +396 -0
  36. eth_portfolio/buckets.py +194 -0
  37. eth_portfolio/constants.cpython-312-i386-linux-gnu.so +0 -0
  38. eth_portfolio/constants.py +82 -0
  39. eth_portfolio/portfolio.py +661 -0
  40. eth_portfolio/protocols/__init__.py +67 -0
  41. eth_portfolio/protocols/_base.py +108 -0
  42. eth_portfolio/protocols/convex.py +17 -0
  43. eth_portfolio/protocols/dsr.py +51 -0
  44. eth_portfolio/protocols/lending/README.md +6 -0
  45. eth_portfolio/protocols/lending/__init__.py +50 -0
  46. eth_portfolio/protocols/lending/_base.py +57 -0
  47. eth_portfolio/protocols/lending/compound.py +187 -0
  48. eth_portfolio/protocols/lending/liquity.py +110 -0
  49. eth_portfolio/protocols/lending/maker.py +105 -0
  50. eth_portfolio/protocols/lending/unit.py +46 -0
  51. eth_portfolio/protocols/liquity.py +16 -0
  52. eth_portfolio/py.typed +0 -0
  53. eth_portfolio/structs/__init__.py +43 -0
  54. eth_portfolio/structs/modified.py +69 -0
  55. eth_portfolio/structs/structs.py +637 -0
  56. eth_portfolio/typing/__init__.py +1447 -0
  57. eth_portfolio/typing/balance/single.py +176 -0
  58. eth_portfolio_scripts/__init__.py +20 -0
  59. eth_portfolio_scripts/_args.py +26 -0
  60. eth_portfolio_scripts/_logging.py +15 -0
  61. eth_portfolio_scripts/_portfolio.py +181 -0
  62. eth_portfolio_scripts/_utils.py +92 -0
  63. eth_portfolio_scripts/balances.cpython-312-i386-linux-gnu.so +0 -0
  64. eth_portfolio_scripts/balances.py +49 -0
  65. eth_portfolio_scripts/docker/.grafana/dashboards/Portfolio/Balances.json +1962 -0
  66. eth_portfolio_scripts/docker/.grafana/dashboards/dashboards.yaml +10 -0
  67. eth_portfolio_scripts/docker/.grafana/datasources/datasources.yml +11 -0
  68. eth_portfolio_scripts/docker/__init__.cpython-312-i386-linux-gnu.so +0 -0
  69. eth_portfolio_scripts/docker/__init__.py +16 -0
  70. eth_portfolio_scripts/docker/check.cpython-312-i386-linux-gnu.so +0 -0
  71. eth_portfolio_scripts/docker/check.py +56 -0
  72. eth_portfolio_scripts/docker/docker-compose.yaml +61 -0
  73. eth_portfolio_scripts/docker/docker_compose.cpython-312-i386-linux-gnu.so +0 -0
  74. eth_portfolio_scripts/docker/docker_compose.py +78 -0
  75. eth_portfolio_scripts/main.py +113 -0
  76. eth_portfolio_scripts/py.typed +1 -0
  77. eth_portfolio_scripts/victoria/__init__.py +70 -0
  78. eth_portfolio_scripts/victoria/types.py +38 -0
  79. eth_portfolio_temp-0.0.39.dev0.dist-info/METADATA +25 -0
  80. eth_portfolio_temp-0.0.39.dev0.dist-info/RECORD +83 -0
  81. eth_portfolio_temp-0.0.39.dev0.dist-info/WHEEL +7 -0
  82. eth_portfolio_temp-0.0.39.dev0.dist-info/entry_points.txt +2 -0
  83. eth_portfolio_temp-0.0.39.dev0.dist-info/top_level.txt +3 -0
@@ -0,0 +1,105 @@
1
+ from asyncio import gather
2
+ from typing import List, Optional
3
+
4
+ from a_sync import igather
5
+ from async_lru import alru_cache
6
+ from dank_mids.exceptions import Revert
7
+ from eth_typing import HexStr
8
+ from y import Contract, Network, contract_creation_block_async, get_price
9
+ from y._decorators import stuck_coro_debugger
10
+ from y.constants import dai
11
+ from y.datatypes import Address, Block
12
+
13
+ from eth_portfolio._utils import Decimal
14
+ from eth_portfolio.protocols.lending._base import LendingProtocolWithLockedCollateral
15
+ from eth_portfolio.typing import Balance, TokenBalances
16
+
17
+ try:
18
+ # this is only available in 4.0.0+
19
+ from eth_abi import encode
20
+
21
+ encode_bytes = lambda bytestring: encode(["bytes32"], [bytestring])
22
+ except ImportError:
23
+ from eth_abi import encode_single
24
+
25
+ encode_bytes = lambda bytestring: encode_single("bytes32", bytestring)
26
+
27
+ yfi = "0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e"
28
+ dai: Contract
29
+
30
+
31
+ class Maker(LendingProtocolWithLockedCollateral):
32
+ networks = [Network.Mainnet]
33
+
34
+ def __init__(self) -> None:
35
+ self.proxy_registry = Contract("0x4678f0a6958e4D2Bc4F1BAF7Bc52E8F3564f3fE4")
36
+ self.cdp_manager = Contract("0x5ef30b9986345249bc32d8928B7ee64DE9435E39")
37
+ self.ilk_registry = Contract("0x5a464C28D19848f44199D003BeF5ecc87d090F87")
38
+ self.vat = Contract("0x35D1b3F3D7966A1DFe207aa4514C12a259A0492B")
39
+
40
+ @stuck_coro_debugger
41
+ async def _balances(self, address: Address, block: Optional[Block] = None) -> TokenBalances:
42
+ ilks, urn = await gather(self.get_ilks(block), self._urn(address))
43
+
44
+ gem_coros = igather(map(self.get_gem, map(str, ilks)))
45
+ ink_coros = igather(
46
+ self.vat.urns.coroutine(ilk, urn, block_identifier=block) for ilk in ilks
47
+ )
48
+
49
+ gems, ink_data = await gather(gem_coros, ink_coros)
50
+
51
+ balances: TokenBalances = TokenBalances(block=block)
52
+ for token, data in zip(gems, ink_data):
53
+ if ink := data.dict()["ink"]:
54
+ balance = ink / Decimal(10**18)
55
+ value = round(balance * Decimal(await get_price(token, block, sync=False)), 18)
56
+ balances[token] = Balance(balance, value, token=token, block=block)
57
+ return balances
58
+
59
+ @stuck_coro_debugger
60
+ async def _debt(self, address: Address, block: Optional[int] = None) -> TokenBalances:
61
+ if block is not None and block <= await contract_creation_block_async(self.ilk_registry):
62
+ return TokenBalances(block=block)
63
+
64
+ ilks, urn = await gather(self.get_ilks(block), self._urn(address))
65
+
66
+ data = await igather(
67
+ gather(
68
+ self.vat.urns.coroutine(ilk, urn, block_identifier=block),
69
+ self.vat.ilks.coroutine(ilk, block_identifier=block),
70
+ )
71
+ for ilk in ilks
72
+ )
73
+
74
+ balances: TokenBalances = TokenBalances(block=block)
75
+ for urns, ilk_info in data:
76
+ art = urns.dict()["art"]
77
+ rate = ilk_info.dict()["rate"]
78
+ debt = art * rate / Decimal(1e45)
79
+ balances[dai.address] += Balance(debt, debt, token=dai, block=block)
80
+ return balances
81
+
82
+ async def get_ilks(self, block: Optional[int]) -> List[HexStr]:
83
+ """List all ilks (cdp keys of sorts) for MakerDAO"""
84
+ try:
85
+ return await self.ilk_registry.list.coroutine(block_identifier=block)
86
+ except Revert:
87
+ return []
88
+
89
+ @alru_cache
90
+ async def get_gem(self, ilk: bytes) -> str:
91
+ return await self.ilk_registry.gem.coroutine(ilk)
92
+
93
+ @alru_cache
94
+ async def _proxy(self, address: Address) -> Address:
95
+ return await self.proxy_registry.proxies.coroutine(address)
96
+
97
+ @alru_cache
98
+ async def _cdp(self, address: Address) -> Address:
99
+ proxy = await self._proxy(address)
100
+ return await self.cdp_manager.first.coroutine(proxy)
101
+
102
+ @alru_cache
103
+ async def _urn(self, address: Address) -> Address:
104
+ cdp = await self._cdp(address)
105
+ return await self.cdp_manager.urns.coroutine(cdp)
@@ -0,0 +1,46 @@
1
+ from typing import Optional
2
+
3
+ from y import Contract, Network
4
+ from y._decorators import stuck_coro_debugger
5
+ from y.datatypes import Address, Block
6
+
7
+ from eth_portfolio._decimal import Decimal
8
+ from eth_portfolio._utils import _get_price
9
+ from eth_portfolio.protocols.lending._base import LendingProtocolWithLockedCollateral
10
+ from eth_portfolio.typing import Balance, TokenBalances
11
+
12
+ # NOTE: This only works for YFI collateral, must extend before using for other collaterals
13
+ yfi = "0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e"
14
+ usdp = "0x1456688345527bE1f37E9e627DA0837D6f08C925"
15
+
16
+
17
+ class UnitXyz(LendingProtocolWithLockedCollateral):
18
+ networks = [Network.Mainnet]
19
+
20
+ def __init__(self) -> None:
21
+ self.unitVault = Contract("0xb1cff81b9305166ff1efc49a129ad2afcd7bcf19")
22
+ self.start_block = 11315910
23
+
24
+ @stuck_coro_debugger
25
+ async def _balances(self, address: Address, block: Optional[Block] = None) -> TokenBalances:
26
+ balances: TokenBalances = TokenBalances(block=block)
27
+ if block and block < self.start_block:
28
+ return balances
29
+ bal: int = await self.unitVault.collaterals.coroutine(yfi, address, block_identifier=block)
30
+ if bal:
31
+ bal = Decimal(bal) / 10**18
32
+ balances[yfi] = Balance(bal, bal * await _get_price(yfi, block), token=yfi, block=block)
33
+ return balances
34
+
35
+ @stuck_coro_debugger
36
+ async def _debt(self, address: Address, block: Optional[Block] = None) -> TokenBalances:
37
+ balances: TokenBalances = TokenBalances(block=block)
38
+ if block and block < self.start_block:
39
+ return balances
40
+ # NOTE: This only works for YFI based debt, must extend before using for other collaterals
41
+ if debt := await self.unitVault.getTotalDebt.coroutine(
42
+ yfi, address, block_identifier=block
43
+ ):
44
+ debt = Decimal(debt) / 10**18
45
+ balances[usdp] = Balance(debt, debt, token=usdp, block=block)
46
+ return balances
@@ -0,0 +1,16 @@
1
+ from eth_portfolio.protocols._base import SingleTokenStakingPoolABC
2
+ from y import ERC20, Network
3
+
4
+
5
+ class LqtyStakingPool(SingleTokenStakingPoolABC):
6
+ networks = [Network.Mainnet]
7
+ contract_address = "0x4f9Fbb3f1E99B56e0Fe2892e623Ed36A76Fc605d"
8
+ balance_method_name = "stakes"
9
+ token = ERC20("0x6DEA81C8171D0bA574754EF6F8b412F2Ed88c54D") # LQTY
10
+
11
+
12
+ class LiquityStabilityPool(SingleTokenStakingPoolABC):
13
+ networks = [Network.Mainnet]
14
+ contract_address = "0x66017D22b0f8556afDd19FC67041899Eb65a21bb"
15
+ balance_method_name = "getCompoundedLUSDDeposit"
16
+ token = ERC20("0x5f98805A4E8be255a32880FDeC7F6728C6568bA0") # LUSD
eth_portfolio/py.typed ADDED
File without changes
@@ -0,0 +1,43 @@
1
+ """
2
+ This module provides the primary union type and specific ledger entry types used in the `eth_portfolio` package.
3
+
4
+ The `__all__` list defines the public API for this module, which includes the main union type `LedgerEntry` and its specific types: `Transaction`, `InternalTransfer`, `TokenTransfer`, and `TransactionRLP`.
5
+
6
+ Examples:
7
+ Importing the main union type and specific ledger entry types:
8
+
9
+ >>> from eth_portfolio.structs import LedgerEntry, Transaction, InternalTransfer, TokenTransfer, TransactionRLP
10
+
11
+ Using the `LedgerEntry` union type to annotate a variable that can hold any ledger entry type:
12
+
13
+ >>> entry: LedgerEntry = Transaction(...)
14
+ >>> entry = InternalTransfer(...)
15
+ >>> entry = TokenTransfer(...)
16
+ >>> entry = TransactionRLP(...)
17
+
18
+ See Also:
19
+ - :class:`~eth_portfolio.structs.structs.LedgerEntry`
20
+ - :class:`~eth_portfolio.structs.structs.Transaction`
21
+ - :class:`~eth_portfolio.structs.structs.InternalTransfer`
22
+ - :class:`~eth_portfolio.structs.structs.TokenTransfer`
23
+ - :class:`~eth_portfolio.structs.structs.TransactionRLP`
24
+ """
25
+
26
+ from eth_portfolio.structs.structs import (
27
+ InternalTransfer,
28
+ LedgerEntry,
29
+ TokenTransfer,
30
+ Transaction,
31
+ TransactionRLP,
32
+ )
33
+
34
+ __all__ = [
35
+ # main union type
36
+ "LedgerEntry",
37
+ # LedgerEntry types
38
+ "Transaction",
39
+ "InternalTransfer",
40
+ "TokenTransfer",
41
+ # TODO figure out how to get rid of this
42
+ "TransactionRLP",
43
+ ]
@@ -0,0 +1,69 @@
1
+ from typing import Union
2
+
3
+ from evmspec.structs.trace import call, create, reward, suicide
4
+
5
+
6
+ class CallTrace(
7
+ call.Trace,
8
+ frozen=True,
9
+ kw_only=True,
10
+ array_like=True,
11
+ forbid_unknown_fields=True,
12
+ omit_defaults=True,
13
+ repr_omit_defaults=True,
14
+ ): # type: ignore [call-arg]
15
+ """
16
+ It works just like a :class:`evmspec.trace.call.Trace` but it encodes to a tuple instead of a dict to save space since keys are known.
17
+ """
18
+
19
+
20
+ class CreateTrace(
21
+ create.Trace,
22
+ frozen=True,
23
+ kw_only=True,
24
+ array_like=True,
25
+ forbid_unknown_fields=True,
26
+ omit_defaults=True,
27
+ repr_omit_defaults=True,
28
+ ): # type: ignore [call-arg]
29
+ """
30
+ It works just like a :class:`evmspec.trace.create.Trace` but it encodes to a tuple instead of a dict to save space since keys are known.
31
+ """
32
+
33
+
34
+ class RewardTrace(
35
+ reward.Trace,
36
+ frozen=True,
37
+ kw_only=True,
38
+ array_like=True,
39
+ forbid_unknown_fields=True,
40
+ omit_defaults=True,
41
+ repr_omit_defaults=True,
42
+ ): # type: ignore [call-arg]
43
+ """
44
+ It works just like a :class:`evmspec.trace.reward.Trace` but it encodes to a tuple instead of a dict to save space since keys are known.
45
+ """
46
+
47
+
48
+ class SuicideTrace(
49
+ suicide.Trace,
50
+ frozen=True,
51
+ kw_only=True,
52
+ array_like=True,
53
+ forbid_unknown_fields=True,
54
+ omit_defaults=True,
55
+ repr_omit_defaults=True,
56
+ ): # type: ignore [call-arg]
57
+ """
58
+ It works just like a :class:`evmspec.trace.suicide.Trace` but it encodes to a tuple instead of a dict to save space since keys are known.
59
+ """
60
+
61
+
62
+ _modified_trace_type_map = {
63
+ call.Trace: CallTrace,
64
+ create.Trace: CreateTrace,
65
+ reward.Trace: RewardTrace,
66
+ suicide.Trace: SuicideTrace,
67
+ }
68
+
69
+ ModifiedTrace = Union[CallTrace, CreateTrace, RewardTrace, SuicideTrace]