yearn-treasury 0.0.8__cp310-cp310-win_amd64.whl → 0.0.48__cp310-cp310-win_amd64.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 yearn-treasury might be problematic. Click here for more details.
- yearn_treasury/__init__.py +16 -0
- yearn_treasury/_db.cp310-win_amd64.pyd +0 -0
- yearn_treasury/_db.py +41 -0
- yearn_treasury/_ens.cp310-win_amd64.pyd +0 -0
- yearn_treasury/_ens.py +14 -0
- yearn_treasury/_logging.cp310-win_amd64.pyd +0 -0
- yearn_treasury/_logging.py +43 -0
- yearn_treasury/address_labels.yaml +39 -0
- yearn_treasury/budget/__init__.cp310-win_amd64.pyd +0 -0
- yearn_treasury/budget/__init__.py +2 -2
- yearn_treasury/budget/_request.cp310-win_amd64.pyd +0 -0
- yearn_treasury/budget/_request.py +8 -0
- yearn_treasury/budget/_requests.cp310-win_amd64.pyd +0 -0
- yearn_treasury/budget/_requests.py +45 -14
- yearn_treasury/constants.py +34 -6
- yearn_treasury/main.py +77 -43
- yearn_treasury/rules/__init__.py +17 -0
- yearn_treasury/rules/constants.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/constants.py +1 -1
- yearn_treasury/rules/cost_of_revenue/gas.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/cost_of_revenue/gas.py +10 -3
- yearn_treasury/rules/expense/__init__.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/expense/general.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/expense/infrastructure.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/expense/infrastructure.py +31 -1
- yearn_treasury/rules/expense/people.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/expense/people.py +43 -0
- yearn_treasury/rules/expense/security.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/expense/security.py +51 -27
- yearn_treasury/rules/ignore/__init__.py +8 -6
- yearn_treasury/rules/ignore/general.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/ignore/general.py +3 -2
- yearn_treasury/rules/ignore/maker.py +48 -64
- yearn_treasury/rules/ignore/passthru.py +310 -0
- yearn_treasury/rules/ignore/staking.py +23 -18
- yearn_treasury/rules/ignore/swaps/__init__.py +18 -5
- yearn_treasury/rules/ignore/swaps/aave.py +39 -19
- yearn_treasury/rules/ignore/swaps/auctions.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/ignore/swaps/auctions.py +31 -0
- yearn_treasury/rules/ignore/swaps/compound.py +38 -36
- yearn_treasury/rules/ignore/swaps/conversion_factory.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/ignore/swaps/conversion_factory.py +21 -0
- yearn_treasury/rules/ignore/swaps/cowswap.py +87 -0
- yearn_treasury/rules/ignore/swaps/curve.py +170 -0
- yearn_treasury/rules/ignore/swaps/gearbox.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/ignore/swaps/gearbox.py +37 -0
- yearn_treasury/rules/ignore/swaps/iearn.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/ignore/swaps/iearn.py +43 -0
- yearn_treasury/rules/ignore/swaps/otc.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/ignore/swaps/otc.py +58 -0
- yearn_treasury/rules/ignore/swaps/pooltogether.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/ignore/swaps/pooltogether.py +23 -0
- yearn_treasury/rules/ignore/swaps/synthetix.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/ignore/swaps/synthetix.py +10 -0
- yearn_treasury/rules/ignore/swaps/uniswap.py +222 -169
- yearn_treasury/rules/ignore/swaps/unwrapper.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/ignore/swaps/unwrapper.py +17 -0
- yearn_treasury/rules/ignore/swaps/vaults.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/ignore/swaps/vaults.py +264 -0
- yearn_treasury/rules/ignore/swaps/woofy.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/ignore/swaps/woofy.py +80 -0
- yearn_treasury/rules/ignore/swaps/yfi.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/ignore/swaps/yfi.py +111 -0
- yearn_treasury/rules/ignore/swaps/yla.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/ignore/swaps/yla.py +28 -0
- yearn_treasury/rules/ignore/unit.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/ignore/unit.py +40 -0
- yearn_treasury/rules/ignore/weth.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/ignore/weth.py +12 -4
- yearn_treasury/rules/ignore/ygov.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/other_expense/__init__.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/other_expense/__init__.py +7 -0
- yearn_treasury/rules/other_expense/boost.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/other_expense/boost.py +49 -0
- yearn_treasury/rules/other_expense/bugs.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/other_expense/bugs.py +81 -0
- yearn_treasury/rules/other_expense/donations.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/other_expense/donations.py +43 -0
- yearn_treasury/rules/other_expense/dyfi.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/other_expense/dyfi.py +29 -0
- yearn_treasury/rules/other_expense/events.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/other_expense/events.py +21 -0
- yearn_treasury/rules/other_expense/match_on_to_address.yaml +3 -2
- yearn_treasury/rules/other_expense/misc.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/other_expense/misc.py +49 -0
- yearn_treasury/rules/other_expense/revshare.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/other_expense/revshare.py +20 -0
- yearn_treasury/rules/other_income/__init__.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/other_income/__init__.py +2 -77
- yearn_treasury/rules/other_income/airdrops.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/other_income/airdrops.py +30 -0
- yearn_treasury/rules/other_income/match_on_hash.yaml +2 -0
- yearn_treasury/rules/other_income/misc.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/other_income/misc.py +80 -0
- yearn_treasury/rules/revenue/__init__.py +5 -0
- yearn_treasury/rules/revenue/bribes.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/revenue/farming.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/revenue/farming.py +56 -0
- yearn_treasury/rules/revenue/keepcoins.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/revenue/seasolver.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/revenue/seasolver.py +7 -1
- yearn_treasury/rules/revenue/vaults.py +97 -34
- yearn_treasury/rules/revenue/yteams.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/revenue/yteams.py +17 -0
- yearn_treasury/shitcoins.py +93 -2
- yearn_treasury/vaults.cp310-win_amd64.pyd +0 -0
- yearn_treasury/vaults.py +30 -22
- yearn_treasury/wallets.yaml +54 -0
- yearn_treasury/yteams.py +208 -0
- yearn_treasury-0.0.48.dist-info/METADATA +86 -0
- yearn_treasury-0.0.48.dist-info/RECORD +128 -0
- yearn_treasury-0.0.48.dist-info/top_level.txt +2 -0
- yearn_treasury__mypyc.cp310-win_amd64.pyd +0 -0
- f79b89f5f6693162015b__mypyc.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/ignore/__init__.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/ignore/maker.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/ignore/staking.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/ignore/swaps/__init__.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/ignore/swaps/_skip_tokens.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/ignore/swaps/aave.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/ignore/swaps/compound.cp310-win_amd64.pyd +0 -0
- yearn_treasury/rules/ignore/swaps/uniswap.cp310-win_amd64.pyd +0 -0
- yearn_treasury-0.0.8.dist-info/METADATA +0 -69
- yearn_treasury-0.0.8.dist-info/RECORD +0 -76
- yearn_treasury-0.0.8.dist-info/top_level.txt +0 -2
- {yearn_treasury-0.0.8.dist-info → yearn_treasury-0.0.48.dist-info}/WHEEL +0 -0
- {yearn_treasury-0.0.8.dist-info → yearn_treasury-0.0.48.dist-info}/entry_points.txt +0 -0
|
@@ -17,77 +17,90 @@ ROUTERS: Final = ("0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F",)
|
|
|
17
17
|
|
|
18
18
|
@uniswap("Add Liquidity")
|
|
19
19
|
async def is_uniswap_deposit(tx: TreasuryTx) -> bool:
|
|
20
|
-
if tx.to_address
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
if tx.to_address:
|
|
21
|
+
try:
|
|
22
|
+
events = tx.events
|
|
23
|
+
except KeyError as e:
|
|
24
|
+
if e.args[0] == "components":
|
|
25
|
+
return False
|
|
26
|
+
raise
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
):
|
|
33
|
-
lp = tx.token.contract
|
|
34
|
-
tokens = [await lp.token0, await lp.token1]
|
|
35
|
-
if all(
|
|
36
|
-
any(
|
|
37
|
-
token == transfer.address
|
|
38
|
-
and tx.to_address == transfer.values()[0]
|
|
39
|
-
and transfer.values()[1] == mint.address
|
|
40
|
-
for transfer in tx._events["Transfer"]
|
|
41
|
-
)
|
|
42
|
-
for token in tokens
|
|
43
|
-
):
|
|
44
|
-
return True
|
|
28
|
+
if "Mint" in events and "Transfer" in events:
|
|
29
|
+
transfers = events["Transfer"]
|
|
30
|
+
for mint in events["Mint"]:
|
|
31
|
+
event_args = {"sender", "amount0", "amount1"}
|
|
32
|
+
if any(arg not in mint for arg in event_args):
|
|
33
|
+
continue
|
|
45
34
|
|
|
46
|
-
#
|
|
47
|
-
if
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
):
|
|
64
|
-
return True
|
|
65
|
-
|
|
66
|
-
elif tokens[1] == WRAPPED_GAS_COIN:
|
|
67
|
-
if any(
|
|
68
|
-
tokens[0] == transfer.address
|
|
69
|
-
and tx.to_address == transfer.values()[:1] == [mint["sender"], mint.address]
|
|
70
|
-
for transfer in tx._events["Transfer"]
|
|
35
|
+
# LP token
|
|
36
|
+
if tx.from_address == ZERO_ADDRESS and (
|
|
37
|
+
tx.token == mint.address
|
|
38
|
+
or
|
|
39
|
+
# KP3R/WETH Uni v3 LP -- used while depositing to kLP-KP3R/WETH
|
|
40
|
+
mint.address == "0x11B7a6bc0259ed6Cf9DB8F499988F9eCc7167bf5"
|
|
41
|
+
):
|
|
42
|
+
lp = tx.token.contract
|
|
43
|
+
tokens = [await lp.token0, await lp.token1]
|
|
44
|
+
if all(
|
|
45
|
+
any(
|
|
46
|
+
token == transfer.address
|
|
47
|
+
and tx.to_address == transfer[0]
|
|
48
|
+
and transfer[1] == mint.address
|
|
49
|
+
for transfer in events["Transfer"]
|
|
50
|
+
)
|
|
51
|
+
for token in tokens
|
|
71
52
|
):
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
53
|
+
return True
|
|
54
|
+
|
|
55
|
+
# Maybe native asset was used instead of wrapped.
|
|
56
|
+
if tokens[0] == WRAPPED_GAS_COIN:
|
|
57
|
+
if any(
|
|
58
|
+
tokens[1] == transfer.address
|
|
59
|
+
and tx.to_address
|
|
60
|
+
== transfer.values()[:1] # type: ignore [index]
|
|
61
|
+
== [mint["sender"], mint.address]
|
|
62
|
+
for transfer in transfers
|
|
63
|
+
):
|
|
64
|
+
for int_tx in chain.get_transaction(tx.hash).internal_transfers:
|
|
65
|
+
if (
|
|
66
|
+
tx.to_address == int_tx["from"] == mint["sender"]
|
|
67
|
+
and int_tx["to"] in ROUTERS
|
|
68
|
+
):
|
|
69
|
+
for transfer in transfers:
|
|
70
|
+
if (
|
|
71
|
+
transfer[0] == WRAPPED_GAS_COIN == transfer.address
|
|
72
|
+
and tx.token == transfer[1]
|
|
73
|
+
and transfer[2] == int_tx["value"]
|
|
74
|
+
):
|
|
75
|
+
return True
|
|
76
|
+
|
|
77
|
+
elif tokens[1] == WRAPPED_GAS_COIN:
|
|
78
|
+
if any(
|
|
79
|
+
tokens[0] == transfer.address
|
|
80
|
+
and tx.to_address
|
|
81
|
+
== transfer.values()[:1] # type: ignore [index]
|
|
82
|
+
== [mint["sender"], mint.address]
|
|
83
|
+
for transfer in transfers
|
|
84
|
+
):
|
|
85
|
+
for int_tx in chain.get_transaction(tx.hash).internal_transfers:
|
|
86
|
+
if (
|
|
87
|
+
tx.to_address == int_tx["from"] == mint["sender"]
|
|
88
|
+
and int_tx["to"] in ROUTERS
|
|
89
|
+
):
|
|
90
|
+
for transfer in transfers:
|
|
91
|
+
if (
|
|
92
|
+
transfer[0] == WRAPPED_GAS_COIN == transfer.address
|
|
93
|
+
and tx.token == transfer[1]
|
|
94
|
+
and transfer[2] == int_tx["value"]
|
|
95
|
+
):
|
|
96
|
+
return True
|
|
97
|
+
|
|
98
|
+
else:
|
|
99
|
+
print(f"tokens: {tokens}")
|
|
100
|
+
|
|
101
|
+
# Component tokens
|
|
102
|
+
elif tx.to_address == mint.address:
|
|
103
|
+
return True
|
|
91
104
|
|
|
92
105
|
if CHAINID == Network.Mainnet:
|
|
93
106
|
return (
|
|
@@ -98,76 +111,88 @@ async def is_uniswap_deposit(tx: TreasuryTx) -> bool:
|
|
|
98
111
|
|
|
99
112
|
@uniswap("Remove Liquidity")
|
|
100
113
|
async def is_uniswap_withdrawal(tx: TreasuryTx) -> bool:
|
|
101
|
-
if tx.to_address
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
114
|
+
if tx.to_address:
|
|
115
|
+
try:
|
|
116
|
+
events = tx.events
|
|
117
|
+
except KeyError as e:
|
|
118
|
+
if e.args[0] == "components":
|
|
119
|
+
return False
|
|
120
|
+
raise
|
|
106
121
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
lp = tx.token.contract
|
|
114
|
-
tokens = [await lp.token0, await lp.token1]
|
|
115
|
-
if tx.token == tx.to_address and all(
|
|
116
|
-
any(
|
|
117
|
-
token == transfer.address
|
|
118
|
-
and tx.to_address == transfer.values()[0]
|
|
119
|
-
and tx.from_address == transfer.values()[1] == burn["to"]
|
|
120
|
-
for transfer in tx._events["Transfer"]
|
|
121
|
-
)
|
|
122
|
-
for token in tokens
|
|
123
|
-
):
|
|
124
|
-
return True
|
|
122
|
+
if "Burn" in events and "Transfer" in events:
|
|
123
|
+
transfers = events["Transfer"]
|
|
124
|
+
for burn in events["Burn"]:
|
|
125
|
+
event_args = {"sender", "amount0", "amount1", "to"}
|
|
126
|
+
if any(arg not in burn for arg in event_args):
|
|
127
|
+
continue
|
|
125
128
|
|
|
126
|
-
#
|
|
127
|
-
if
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
return True
|
|
143
|
-
|
|
144
|
-
elif tokens[1] == WRAPPED_GAS_COIN:
|
|
145
|
-
if any(
|
|
146
|
-
tokens[0] == transfer.address
|
|
147
|
-
and tx.token == tx.to_address == transfer.values()[0]
|
|
148
|
-
and tx.from_address == transfer.values()[1] == burn["to"]
|
|
149
|
-
for transfer in tx._events["Transfer"]
|
|
129
|
+
# LP token
|
|
130
|
+
if (
|
|
131
|
+
TreasuryWallet._get_instance(tx.from_address.address) # type: ignore [union-attr, arg-type]
|
|
132
|
+
and tx.from_address == burn["to"]
|
|
133
|
+
and tx.token == tx.to_address == burn.address
|
|
134
|
+
):
|
|
135
|
+
lp = tx.token.contract
|
|
136
|
+
tokens = [await lp.token0, await lp.token1]
|
|
137
|
+
if tx.token == tx.to_address and all(
|
|
138
|
+
any(
|
|
139
|
+
token == transfer.address
|
|
140
|
+
and tx.to_address == transfer[0]
|
|
141
|
+
and tx.from_address == transfer[1] == burn["to"]
|
|
142
|
+
for transfer in transfers
|
|
143
|
+
)
|
|
144
|
+
for token in tokens
|
|
150
145
|
):
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
146
|
+
return True
|
|
147
|
+
|
|
148
|
+
# Maybe native asset was used instead of wrapped.
|
|
149
|
+
if tokens[0] == WRAPPED_GAS_COIN:
|
|
150
|
+
if any(
|
|
151
|
+
tokens[1] == transfer.address
|
|
152
|
+
and tx.token == tx.to_address == transfer[0]
|
|
153
|
+
and tx.from_address == transfer[1] == burn["to"]
|
|
154
|
+
for transfer in transfers
|
|
155
|
+
):
|
|
156
|
+
for int_tx in chain.get_transaction(tx.hash).internal_transfers:
|
|
157
|
+
if int_tx["from"] in ROUTERS and tx.from_address == int_tx["to"]:
|
|
158
|
+
for transfer in transfers:
|
|
159
|
+
if (
|
|
160
|
+
tx.token == transfer[0]
|
|
161
|
+
and transfer[1] == transfer.address == WRAPPED_GAS_COIN
|
|
162
|
+
and transfer[2] == int_tx["value"]
|
|
163
|
+
):
|
|
164
|
+
return True
|
|
165
|
+
|
|
166
|
+
elif tokens[1] == WRAPPED_GAS_COIN:
|
|
167
|
+
if any(
|
|
168
|
+
tokens[0] == transfer.address
|
|
169
|
+
and tx.token == tx.to_address == transfer[0]
|
|
170
|
+
and tx.from_address == transfer[1] == burn["to"]
|
|
171
|
+
for transfer in transfers
|
|
172
|
+
):
|
|
173
|
+
for int_tx in chain.get_transaction(tx.hash).internal_transfers:
|
|
174
|
+
if int_tx["from"] in ROUTERS and tx.from_address == int_tx["to"]:
|
|
175
|
+
for transfer in transfers:
|
|
176
|
+
if (
|
|
177
|
+
transfer[0] == tx.token
|
|
178
|
+
and transfer[1] == transfer.address == WRAPPED_GAS_COIN
|
|
179
|
+
and transfer[2] == int_tx["value"]
|
|
180
|
+
):
|
|
181
|
+
return True
|
|
182
|
+
|
|
183
|
+
else:
|
|
184
|
+
print(f"tokens: {tokens}")
|
|
185
|
+
|
|
186
|
+
# Component tokens
|
|
187
|
+
elif tx.from_address == burn.address:
|
|
188
|
+
return True
|
|
167
189
|
|
|
168
190
|
return CHAINID == Network.Mainnet and tx.hash in (
|
|
169
191
|
"0xf0723677162cdf8105c0f752a8c03c53803cb9dd9a6649f3b9bc5d26822d531f",
|
|
170
192
|
"0xaf1b7f138fb8bf3f5e13a680cb4a9b7983ec71a75836111c03dee6ae530db176", # v3
|
|
193
|
+
# these use ETH not WETH so they dont match
|
|
194
|
+
"0x5b05dfd3305c471df0ad944237edc2dbb14b268f7415252de566a5ab283002af",
|
|
195
|
+
"0x46ab9b383751f612ea0de8c0c6e9fa86e7324de04b032ecb48161989b7dbdbf7",
|
|
171
196
|
)
|
|
172
197
|
|
|
173
198
|
|
|
@@ -197,45 +222,73 @@ async def is_uniswap_swap(tx: TreasuryTx) -> bool:
|
|
|
197
222
|
return True
|
|
198
223
|
|
|
199
224
|
# All other swaps
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
)
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
token1 = await pool.token1 # type: ignore [attr-defined]
|
|
210
|
-
if token0 in SKIP_TOKENS or token1 in SKIP_TOKENS:
|
|
211
|
-
# This will be recorded elsewhere
|
|
212
|
-
continue
|
|
225
|
+
for swap in tx.get_events("Swap"):
|
|
226
|
+
# Sell side
|
|
227
|
+
if (
|
|
228
|
+
TreasuryWallet._get_instance(tx.from_address.address) # type: ignore [union-attr, arg-type]
|
|
229
|
+
and tx.to_address == swap.address
|
|
230
|
+
):
|
|
231
|
+
pool = await Contract.coroutine(swap.address)
|
|
232
|
+
if not is_pool(pool): # type: ignore [arg-type]
|
|
233
|
+
continue
|
|
213
234
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
235
|
+
token0 = await pool.token0 # type: ignore [attr-defined]
|
|
236
|
+
token1 = await pool.token1 # type: ignore [attr-defined]
|
|
237
|
+
if token0 in SKIP_TOKENS or token1 in SKIP_TOKENS:
|
|
238
|
+
# This will be recorded elsewhere
|
|
239
|
+
continue
|
|
217
240
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
elif tx.token == token1:
|
|
222
|
-
if tx.token.scale_value(swap["amount1In"]) == tx.amount:
|
|
223
|
-
return True
|
|
241
|
+
# The below code only works for v2 swaps, let's skip v3 swaps
|
|
242
|
+
if "sqrtPriceX96" in swap:
|
|
243
|
+
continue
|
|
224
244
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
tx.
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
245
|
+
if tx.token == token0:
|
|
246
|
+
# TODO: get rid of this rounding when we migrate to postgres
|
|
247
|
+
event_amount = round(tx.token.scale_value(swap["amount0In"]), 10)
|
|
248
|
+
if event_amount == round(tx.amount, 10):
|
|
249
|
+
return True
|
|
250
|
+
print(
|
|
251
|
+
f"Uniswap sell token0 amount does not match: {round(tx.amount, 10)} {event_amount}"
|
|
252
|
+
)
|
|
253
|
+
elif tx.token == token1:
|
|
254
|
+
# TODO: get rid of this rounding when we migrate to postgres
|
|
255
|
+
event_amount = round(tx.token.scale_value(swap["amount1In"]), 10)
|
|
256
|
+
if event_amount == round(tx.amount, 10):
|
|
257
|
+
return True
|
|
258
|
+
print(
|
|
259
|
+
f"Uniswap sell token1 amount does not match: {round(tx.amount, 10)} {event_amount}"
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
# Buy side
|
|
263
|
+
elif tx.from_address == swap.address and TreasuryWallet._get_instance(
|
|
264
|
+
tx.to_address.address # type: ignore [union-attr, arg-type]
|
|
265
|
+
):
|
|
266
|
+
pool = await Contract.coroutine(swap.address)
|
|
267
|
+
if not is_pool(pool): # type: ignore [arg-type]
|
|
268
|
+
continue
|
|
269
|
+
token0 = await pool.token0 # type: ignore [attr-defined]
|
|
270
|
+
token1 = await pool.token1 # type: ignore [attr-defined]
|
|
271
|
+
if token0 in SKIP_TOKENS or token1 in SKIP_TOKENS:
|
|
272
|
+
# This will be recorded elsewhere
|
|
273
|
+
continue
|
|
274
|
+
if "amount0Out" in swap and tx.token == token0:
|
|
275
|
+
# TODO: get rid of this rounding when we migrate to postgres
|
|
276
|
+
event_amount = round(tx.token.scale_value(swap["amount0Out"]), 9)
|
|
277
|
+
if event_amount == round(tx.amount, 9):
|
|
278
|
+
return True
|
|
279
|
+
print(
|
|
280
|
+
f"Uniswap buy token0 amount does not match: {round(tx.amount, 9)} {event_amount}"
|
|
281
|
+
)
|
|
282
|
+
elif "amount1Out" in swap and tx.token == token1:
|
|
283
|
+
# TODO: get rid of this rounding when we migrate to postgres
|
|
284
|
+
event_amount = round(tx.token.scale_value(swap["amount1Out"]), 10)
|
|
285
|
+
if event_amount == round(tx.amount, 10):
|
|
286
|
+
return True
|
|
287
|
+
print(
|
|
288
|
+
f"Uniswap buy token1 amount does not match: {round(tx.amount, 10)} {event_amount}"
|
|
289
|
+
)
|
|
241
290
|
return False
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
def is_pool(pool: Contract) -> bool:
|
|
294
|
+
return hasattr(pool, "token0") and hasattr(pool, "token1")
|
|
Binary file
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Ignore rules for the Unwrapper contract.
|
|
3
|
+
|
|
4
|
+
This module defines matching logic for swaps involving the Unwrapper
|
|
5
|
+
contract, so those transactions can be ignored from analytics and
|
|
6
|
+
reporting.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from dao_treasury import TreasuryTx
|
|
10
|
+
from y import Network
|
|
11
|
+
|
|
12
|
+
from yearn_treasury.rules.ignore.swaps import swaps
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@swaps("Unwrapper", Network.Mainnet)
|
|
16
|
+
def is_unwrapper(tx: TreasuryTx) -> bool:
|
|
17
|
+
return "Contract: Unwrapper" in [tx.from_nickname, tx.to_nickname]
|
|
Binary file
|