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.
- eth_portfolio/__init__.py +16 -0
- eth_portfolio/_argspec.py +42 -0
- eth_portfolio/_cache.py +116 -0
- eth_portfolio/_config.py +3 -0
- eth_portfolio/_db/__init__.py +0 -0
- eth_portfolio/_db/decorators.py +147 -0
- eth_portfolio/_db/entities.py +204 -0
- eth_portfolio/_db/utils.py +595 -0
- eth_portfolio/_decimal.py +122 -0
- eth_portfolio/_decorators.py +71 -0
- eth_portfolio/_exceptions.py +67 -0
- eth_portfolio/_ledgers/__init__.py +0 -0
- eth_portfolio/_ledgers/address.py +892 -0
- eth_portfolio/_ledgers/portfolio.py +327 -0
- eth_portfolio/_loaders/__init__.py +33 -0
- eth_portfolio/_loaders/balances.py +78 -0
- eth_portfolio/_loaders/token_transfer.py +214 -0
- eth_portfolio/_loaders/transaction.py +379 -0
- eth_portfolio/_loaders/utils.py +59 -0
- eth_portfolio/_shitcoins.py +212 -0
- eth_portfolio/_utils.py +286 -0
- eth_portfolio/_ydb/__init__.py +0 -0
- eth_portfolio/_ydb/token_transfers.py +136 -0
- eth_portfolio/address.py +382 -0
- eth_portfolio/buckets.py +181 -0
- eth_portfolio/constants.py +58 -0
- eth_portfolio/portfolio.py +629 -0
- eth_portfolio/protocols/__init__.py +66 -0
- eth_portfolio/protocols/_base.py +107 -0
- eth_portfolio/protocols/convex.py +17 -0
- eth_portfolio/protocols/dsr.py +31 -0
- eth_portfolio/protocols/lending/__init__.py +49 -0
- eth_portfolio/protocols/lending/_base.py +57 -0
- eth_portfolio/protocols/lending/compound.py +185 -0
- eth_portfolio/protocols/lending/liquity.py +110 -0
- eth_portfolio/protocols/lending/maker.py +105 -0
- eth_portfolio/protocols/lending/unit.py +47 -0
- eth_portfolio/protocols/liquity.py +16 -0
- eth_portfolio/py.typed +0 -0
- eth_portfolio/structs/__init__.py +43 -0
- eth_portfolio/structs/modified.py +69 -0
- eth_portfolio/structs/structs.py +637 -0
- eth_portfolio/typing.py +1460 -0
- eth_portfolio-1.1.0.dist-info/METADATA +174 -0
- eth_portfolio-1.1.0.dist-info/RECORD +47 -0
- eth_portfolio-1.1.0.dist-info/WHEEL +5 -0
- eth_portfolio-1.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from y import Contract, Network, get_price
|
|
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.protocols.lending._base import LendingProtocolWithLockedCollateral
|
|
9
|
+
from eth_portfolio.typing import Balance, TokenBalances
|
|
10
|
+
|
|
11
|
+
# NOTE: This only works for YFI collateral, must extend before using for other collaterals
|
|
12
|
+
yfi = "0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e"
|
|
13
|
+
usdp = "0x1456688345527bE1f37E9e627DA0837D6f08C925"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class UnitXyz(LendingProtocolWithLockedCollateral):
|
|
17
|
+
networks = [Network.Mainnet]
|
|
18
|
+
|
|
19
|
+
def __init__(self) -> None:
|
|
20
|
+
self.unitVault = Contract("0xb1cff81b9305166ff1efc49a129ad2afcd7bcf19")
|
|
21
|
+
self.start_block = 11315910
|
|
22
|
+
|
|
23
|
+
@stuck_coro_debugger
|
|
24
|
+
async def _balances(self, address: Address, block: Optional[Block] = None) -> TokenBalances:
|
|
25
|
+
balances: TokenBalances = TokenBalances(block=block)
|
|
26
|
+
if block and block < self.start_block:
|
|
27
|
+
return balances
|
|
28
|
+
bal: int = await self.unitVault.collaterals.coroutine(yfi, address, block_identifier=block)
|
|
29
|
+
if bal:
|
|
30
|
+
bal = Decimal(bal) / 10**18
|
|
31
|
+
balances[yfi] = Balance(
|
|
32
|
+
bal, bal * await get_price(yfi, block, sync=False), token=yfi, block=block
|
|
33
|
+
)
|
|
34
|
+
return balances
|
|
35
|
+
|
|
36
|
+
@stuck_coro_debugger
|
|
37
|
+
async def _debt(self, address: Address, block: Optional[Block] = None) -> TokenBalances:
|
|
38
|
+
balances: TokenBalances = TokenBalances(block=block)
|
|
39
|
+
if block and block < self.start_block:
|
|
40
|
+
return balances
|
|
41
|
+
# NOTE: This only works for YFI based debt, must extend before using for other collaterals
|
|
42
|
+
if debt := await self.unitVault.getTotalDebt.coroutine(
|
|
43
|
+
yfi, address, block_identifier=block
|
|
44
|
+
):
|
|
45
|
+
debt = Decimal(debt) / 10**18
|
|
46
|
+
balances[usdp] = Balance(debt, debt, token=usdp, block=block)
|
|
47
|
+
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]
|