forked from BowTiedDevil/degenbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexceptions.py
135 lines (95 loc) · 3.21 KB
/
exceptions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Base exception
class DegenbotError(Exception):
"""
Base exception, intended as a generic exception and a base class for
for all more-specific exceptions raised by various degenbot modules
"""
class DeprecationError(ValueError):
"""
Thrown when a feature, class, method, etc. is deprecated.
Subclasses `ValueError` instead of `Exception`, less likely to be ignored.
"""
# 1st level exceptions (derived from `DegenbotError`)
class ArbitrageError(DegenbotError):
"""
Exception raised inside arbitrage helpers
"""
class BlockUnavailableError(DegenbotError):
"""
Exception raised when a call for a specific block fails (trie node unavailable)
"""
class Erc20TokenError(DegenbotError):
"""
Exception raised inside ERC-20 token helpers
"""
class EVMRevertError(DegenbotError):
"""
Thrown when a simulated EVM contract operation would revert
"""
class LiquidityPoolError(DegenbotError):
"""
Exception raised inside liquidity pool helpers
"""
class ManagerError(DegenbotError):
"""
Exception raised inside manager helpers
"""
class TransactionError(DegenbotError):
"""
Exception raised inside transaction simulation helpers
"""
# 2nd level exceptions for Arbitrage classes
class ArbCalculationError(ArbitrageError):
"""
Thrown when an arbitrage calculation fails
"""
class InvalidSwapPathError(ArbitrageError):
"""
Thrown in arbitrage helper constructors when the provided path is invalid
"""
pass
class ZeroLiquidityError(ArbitrageError):
"""
Thrown by the arbitrage helper if a pool in the path has no liquidity in the direction of the proposed swap
"""
# 2nd level exceptions for Uniswap Liquidity Pool classes
class BitmapWordUnavailableError(LiquidityPoolError):
"""
Thrown by the ported V3 swap function when the bitmap word is not available.
This should be caught by the helper to perform automatic fetching, and should
not be raised to the calling function
"""
class ExternalUpdateError(LiquidityPoolError):
"""
Thrown when an external update does not pass sanity checks
"""
class MissingTickWordError(LiquidityPoolError):
"""
Thrown by the TickBitmap library when calling for an operation on a word that
should be available, but is not
"""
class ZeroSwapError(LiquidityPoolError):
"""
Thrown if a swap calculation resulted or would result in zero output
"""
# 2nd level exceptions for Transaction classes
class LedgerError(TransactionError):
"""
Thrown when the ledger does not align with the expected state
"""
class TransactionEncodingError(TransactionError):
"""
Thrown when a transaction input cannot be decoded using the known ABI
"""
# 2nd level exceptions for AllPools class
class PoolAlreadyExistsError(ManagerError):
"""
Thrown by the AllPools class if a caller attempts to store a pool helper
at an already-known address.
"""
# 2nd level exceptions for Uniswap Manager classes
class PoolNotAssociated(ManagerError):
"""
Thrown by a UniswapV2LiquidityPoolManager or UniswapV3LiquidityPoolManager
class if a requested pool address is not associated with the DEX.
"""