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.

Files changed (127) hide show
  1. yearn_treasury/__init__.py +16 -0
  2. yearn_treasury/_db.cp310-win_amd64.pyd +0 -0
  3. yearn_treasury/_db.py +41 -0
  4. yearn_treasury/_ens.cp310-win_amd64.pyd +0 -0
  5. yearn_treasury/_ens.py +14 -0
  6. yearn_treasury/_logging.cp310-win_amd64.pyd +0 -0
  7. yearn_treasury/_logging.py +43 -0
  8. yearn_treasury/address_labels.yaml +39 -0
  9. yearn_treasury/budget/__init__.cp310-win_amd64.pyd +0 -0
  10. yearn_treasury/budget/__init__.py +2 -2
  11. yearn_treasury/budget/_request.cp310-win_amd64.pyd +0 -0
  12. yearn_treasury/budget/_request.py +8 -0
  13. yearn_treasury/budget/_requests.cp310-win_amd64.pyd +0 -0
  14. yearn_treasury/budget/_requests.py +45 -14
  15. yearn_treasury/constants.py +34 -6
  16. yearn_treasury/main.py +77 -43
  17. yearn_treasury/rules/__init__.py +17 -0
  18. yearn_treasury/rules/constants.cp310-win_amd64.pyd +0 -0
  19. yearn_treasury/rules/constants.py +1 -1
  20. yearn_treasury/rules/cost_of_revenue/gas.cp310-win_amd64.pyd +0 -0
  21. yearn_treasury/rules/cost_of_revenue/gas.py +10 -3
  22. yearn_treasury/rules/expense/__init__.cp310-win_amd64.pyd +0 -0
  23. yearn_treasury/rules/expense/general.cp310-win_amd64.pyd +0 -0
  24. yearn_treasury/rules/expense/infrastructure.cp310-win_amd64.pyd +0 -0
  25. yearn_treasury/rules/expense/infrastructure.py +31 -1
  26. yearn_treasury/rules/expense/people.cp310-win_amd64.pyd +0 -0
  27. yearn_treasury/rules/expense/people.py +43 -0
  28. yearn_treasury/rules/expense/security.cp310-win_amd64.pyd +0 -0
  29. yearn_treasury/rules/expense/security.py +51 -27
  30. yearn_treasury/rules/ignore/__init__.py +8 -6
  31. yearn_treasury/rules/ignore/general.cp310-win_amd64.pyd +0 -0
  32. yearn_treasury/rules/ignore/general.py +3 -2
  33. yearn_treasury/rules/ignore/maker.py +48 -64
  34. yearn_treasury/rules/ignore/passthru.py +310 -0
  35. yearn_treasury/rules/ignore/staking.py +23 -18
  36. yearn_treasury/rules/ignore/swaps/__init__.py +18 -5
  37. yearn_treasury/rules/ignore/swaps/aave.py +39 -19
  38. yearn_treasury/rules/ignore/swaps/auctions.cp310-win_amd64.pyd +0 -0
  39. yearn_treasury/rules/ignore/swaps/auctions.py +31 -0
  40. yearn_treasury/rules/ignore/swaps/compound.py +38 -36
  41. yearn_treasury/rules/ignore/swaps/conversion_factory.cp310-win_amd64.pyd +0 -0
  42. yearn_treasury/rules/ignore/swaps/conversion_factory.py +21 -0
  43. yearn_treasury/rules/ignore/swaps/cowswap.py +87 -0
  44. yearn_treasury/rules/ignore/swaps/curve.py +170 -0
  45. yearn_treasury/rules/ignore/swaps/gearbox.cp310-win_amd64.pyd +0 -0
  46. yearn_treasury/rules/ignore/swaps/gearbox.py +37 -0
  47. yearn_treasury/rules/ignore/swaps/iearn.cp310-win_amd64.pyd +0 -0
  48. yearn_treasury/rules/ignore/swaps/iearn.py +43 -0
  49. yearn_treasury/rules/ignore/swaps/otc.cp310-win_amd64.pyd +0 -0
  50. yearn_treasury/rules/ignore/swaps/otc.py +58 -0
  51. yearn_treasury/rules/ignore/swaps/pooltogether.cp310-win_amd64.pyd +0 -0
  52. yearn_treasury/rules/ignore/swaps/pooltogether.py +23 -0
  53. yearn_treasury/rules/ignore/swaps/synthetix.cp310-win_amd64.pyd +0 -0
  54. yearn_treasury/rules/ignore/swaps/synthetix.py +10 -0
  55. yearn_treasury/rules/ignore/swaps/uniswap.py +222 -169
  56. yearn_treasury/rules/ignore/swaps/unwrapper.cp310-win_amd64.pyd +0 -0
  57. yearn_treasury/rules/ignore/swaps/unwrapper.py +17 -0
  58. yearn_treasury/rules/ignore/swaps/vaults.cp310-win_amd64.pyd +0 -0
  59. yearn_treasury/rules/ignore/swaps/vaults.py +264 -0
  60. yearn_treasury/rules/ignore/swaps/woofy.cp310-win_amd64.pyd +0 -0
  61. yearn_treasury/rules/ignore/swaps/woofy.py +80 -0
  62. yearn_treasury/rules/ignore/swaps/yfi.cp310-win_amd64.pyd +0 -0
  63. yearn_treasury/rules/ignore/swaps/yfi.py +111 -0
  64. yearn_treasury/rules/ignore/swaps/yla.cp310-win_amd64.pyd +0 -0
  65. yearn_treasury/rules/ignore/swaps/yla.py +28 -0
  66. yearn_treasury/rules/ignore/unit.cp310-win_amd64.pyd +0 -0
  67. yearn_treasury/rules/ignore/unit.py +40 -0
  68. yearn_treasury/rules/ignore/weth.cp310-win_amd64.pyd +0 -0
  69. yearn_treasury/rules/ignore/weth.py +12 -4
  70. yearn_treasury/rules/ignore/ygov.cp310-win_amd64.pyd +0 -0
  71. yearn_treasury/rules/other_expense/__init__.cp310-win_amd64.pyd +0 -0
  72. yearn_treasury/rules/other_expense/__init__.py +7 -0
  73. yearn_treasury/rules/other_expense/boost.cp310-win_amd64.pyd +0 -0
  74. yearn_treasury/rules/other_expense/boost.py +49 -0
  75. yearn_treasury/rules/other_expense/bugs.cp310-win_amd64.pyd +0 -0
  76. yearn_treasury/rules/other_expense/bugs.py +81 -0
  77. yearn_treasury/rules/other_expense/donations.cp310-win_amd64.pyd +0 -0
  78. yearn_treasury/rules/other_expense/donations.py +43 -0
  79. yearn_treasury/rules/other_expense/dyfi.cp310-win_amd64.pyd +0 -0
  80. yearn_treasury/rules/other_expense/dyfi.py +29 -0
  81. yearn_treasury/rules/other_expense/events.cp310-win_amd64.pyd +0 -0
  82. yearn_treasury/rules/other_expense/events.py +21 -0
  83. yearn_treasury/rules/other_expense/match_on_to_address.yaml +3 -2
  84. yearn_treasury/rules/other_expense/misc.cp310-win_amd64.pyd +0 -0
  85. yearn_treasury/rules/other_expense/misc.py +49 -0
  86. yearn_treasury/rules/other_expense/revshare.cp310-win_amd64.pyd +0 -0
  87. yearn_treasury/rules/other_expense/revshare.py +20 -0
  88. yearn_treasury/rules/other_income/__init__.cp310-win_amd64.pyd +0 -0
  89. yearn_treasury/rules/other_income/__init__.py +2 -77
  90. yearn_treasury/rules/other_income/airdrops.cp310-win_amd64.pyd +0 -0
  91. yearn_treasury/rules/other_income/airdrops.py +30 -0
  92. yearn_treasury/rules/other_income/match_on_hash.yaml +2 -0
  93. yearn_treasury/rules/other_income/misc.cp310-win_amd64.pyd +0 -0
  94. yearn_treasury/rules/other_income/misc.py +80 -0
  95. yearn_treasury/rules/revenue/__init__.py +5 -0
  96. yearn_treasury/rules/revenue/bribes.cp310-win_amd64.pyd +0 -0
  97. yearn_treasury/rules/revenue/farming.cp310-win_amd64.pyd +0 -0
  98. yearn_treasury/rules/revenue/farming.py +56 -0
  99. yearn_treasury/rules/revenue/keepcoins.cp310-win_amd64.pyd +0 -0
  100. yearn_treasury/rules/revenue/seasolver.cp310-win_amd64.pyd +0 -0
  101. yearn_treasury/rules/revenue/seasolver.py +7 -1
  102. yearn_treasury/rules/revenue/vaults.py +97 -34
  103. yearn_treasury/rules/revenue/yteams.cp310-win_amd64.pyd +0 -0
  104. yearn_treasury/rules/revenue/yteams.py +17 -0
  105. yearn_treasury/shitcoins.py +93 -2
  106. yearn_treasury/vaults.cp310-win_amd64.pyd +0 -0
  107. yearn_treasury/vaults.py +30 -22
  108. yearn_treasury/wallets.yaml +54 -0
  109. yearn_treasury/yteams.py +208 -0
  110. yearn_treasury-0.0.48.dist-info/METADATA +86 -0
  111. yearn_treasury-0.0.48.dist-info/RECORD +128 -0
  112. yearn_treasury-0.0.48.dist-info/top_level.txt +2 -0
  113. yearn_treasury__mypyc.cp310-win_amd64.pyd +0 -0
  114. f79b89f5f6693162015b__mypyc.cp310-win_amd64.pyd +0 -0
  115. yearn_treasury/rules/ignore/__init__.cp310-win_amd64.pyd +0 -0
  116. yearn_treasury/rules/ignore/maker.cp310-win_amd64.pyd +0 -0
  117. yearn_treasury/rules/ignore/staking.cp310-win_amd64.pyd +0 -0
  118. yearn_treasury/rules/ignore/swaps/__init__.cp310-win_amd64.pyd +0 -0
  119. yearn_treasury/rules/ignore/swaps/_skip_tokens.cp310-win_amd64.pyd +0 -0
  120. yearn_treasury/rules/ignore/swaps/aave.cp310-win_amd64.pyd +0 -0
  121. yearn_treasury/rules/ignore/swaps/compound.cp310-win_amd64.pyd +0 -0
  122. yearn_treasury/rules/ignore/swaps/uniswap.cp310-win_amd64.pyd +0 -0
  123. yearn_treasury-0.0.8.dist-info/METADATA +0 -69
  124. yearn_treasury-0.0.8.dist-info/RECORD +0 -76
  125. yearn_treasury-0.0.8.dist-info/top_level.txt +0 -2
  126. {yearn_treasury-0.0.8.dist-info → yearn_treasury-0.0.48.dist-info}/WHEEL +0 -0
  127. {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 and "Mint" in tx._events and "Transfer" in tx._events:
21
- for mint in tx._events["Mint"]:
22
- event_args = {"sender", "amount0", "amount1"}
23
- if any(arg not in mint for arg in event_args):
24
- continue
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
- # LP token
27
- if tx.from_address == ZERO_ADDRESS and (
28
- tx.token == mint.address
29
- or
30
- # KP3R/WETH Uni v3 LP -- used while depositing to kLP-KP3R/WETH
31
- mint.address == "0x11B7a6bc0259ed6Cf9DB8F499988F9eCc7167bf5"
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
- # Maybe native asset was used instead of wrapped.
47
- if tokens[0] == WRAPPED_GAS_COIN:
48
- if any(
49
- tokens[1] == transfer.address
50
- and tx.to_address == transfer.values()[:1] == [mint["sender"], mint.address]
51
- for transfer in tx._events["Transfer"]
52
- ):
53
- for int_tx in chain.get_transaction(tx.hash).internal_transfers:
54
- if (
55
- tx.to_address == int_tx["from"] == mint["sender"]
56
- and int_tx["to"] in ROUTERS
57
- ):
58
- for transfer in tx._events["Transfer"]:
59
- if (
60
- transfer[0] == WRAPPED_GAS_COIN == transfer.address
61
- and tx.token == transfer[1]
62
- and transfer[2] == int_tx["value"]
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
- for int_tx in chain.get_transaction(tx.hash).internal_transfers:
73
- if (
74
- tx.to_address == int_tx["from"] == mint["sender"]
75
- and int_tx["to"] in ROUTERS
76
- ):
77
- for transfer in tx._events["Transfer"]:
78
- if (
79
- transfer[0] == WRAPPED_GAS_COIN == transfer.address
80
- and tx.token == transfer[1]
81
- and transfer[2] == int_tx["value"]
82
- ):
83
- return True
84
-
85
- else:
86
- print(f"tokens: {tokens}")
87
-
88
- # Component tokens
89
- elif tx.to_address == mint.address:
90
- return True
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 and "Burn" in tx._events and "Transfer" in tx._events:
102
- for burn in tx._events["Burn"]:
103
- event_args = {"sender", "amount0", "amount1", "to"}
104
- if any(arg not in burn for arg in event_args):
105
- continue
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
- # LP token
108
- if (
109
- TreasuryWallet._get_instance(tx.from_address.address) # type: ignore [union-attr, arg-type]
110
- and tx.from_address == burn["to"]
111
- and tx.token == tx.to_address == burn.address
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
- # Maybe native asset was used instead of wrapped.
127
- if tokens[0] == WRAPPED_GAS_COIN:
128
- if any(
129
- tokens[1] == transfer.address
130
- and tx.token == tx.to_address == transfer.values()[0]
131
- and tx.from_address == transfer.values()[1] == burn["to"]
132
- for transfer in tx._events["Transfer"]
133
- ):
134
- for int_tx in chain.get_transaction(tx.hash).internal_transfers:
135
- if int_tx["from"] in ROUTERS and tx.from_address == int_tx["to"]:
136
- for transfer in tx._events["Transfer"]:
137
- if (
138
- tx.token == transfer[0]
139
- and transfer[1] == transfer.address == WRAPPED_GAS_COIN
140
- and transfer[2] == int_tx["value"]
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
- for int_tx in chain.get_transaction(tx.hash).internal_transfers:
152
- if int_tx["from"] in ROUTERS and tx.from_address == int_tx["to"]:
153
- for transfer in tx._events["Transfer"]:
154
- if (
155
- transfer[0] == tx.token
156
- and transfer[1] == transfer.address == WRAPPED_GAS_COIN
157
- and transfer[2] == int_tx["value"]
158
- ):
159
- return True
160
-
161
- else:
162
- print(f"tokens: {tokens}")
163
-
164
- # Component tokens
165
- elif tx.from_address == burn.address:
166
- return True
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
- elif "Swap" in tx._events:
201
- for swap in tx._events["Swap"]:
202
- # Sell side
203
- if (
204
- TreasuryWallet._get_instance(tx.from_address.address) # type: ignore [union-attr, arg-type]
205
- and tx.to_address == swap.address
206
- ):
207
- pool = await Contract.coroutine(swap.address)
208
- token0 = await pool.token0 # type: ignore [attr-defined]
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
- # The below code only works for v2 swaps, let's skip v3 swaps
215
- if "sqrtPriceX96" in swap:
216
- continue
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
- if tx.token == token0:
219
- if tx.token.scale_value(swap["amount0In"]) == tx.amount:
220
- return True
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
- # Buy side
226
- elif tx.from_address == swap.address and TreasuryWallet._get_instance(
227
- tx.to_address.address # type: ignore [union-attr, arg-type]
228
- ):
229
- pool = await Contract.coroutine(swap.address)
230
- token0 = await pool.token0 # type: ignore [attr-defined]
231
- token1 = await pool.token1 # type: ignore [attr-defined]
232
- if token0 in SKIP_TOKENS or token1 in SKIP_TOKENS:
233
- # This will be recorded elsewhere
234
- continue
235
- if tx.token == token0:
236
- if tx.token.scale_value(swap["amount0Out"]) == tx.amount:
237
- return True
238
- elif tx.token == token1:
239
- if tx.token.scale_value(swap["amount1Out"]) == tx.amount:
240
- return True
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")
@@ -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]