models.py 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. """Models from Database Schemas."""
  2. from app import db
  3. class Address(db.Model):
  4. __tablename__: str = 'address'
  5. id: db.Column = db.Column(db.Integer, primary_key = True)
  6. address: db.Column = db.Column(
  7. db.String(128),
  8. index = True,
  9. unique = True,
  10. nullable = False,
  11. )
  12. entity: db.Column = db.Column(db.Integer, nullable = False)
  13. meta_data: db.Column = db.Column(db.String(256))
  14. user_cluster: db.Column = db.Column(db.Integer)
  15. exchange_cluster: db.Column = db.Column(db.Integer)
  16. conf: db.Column = db.Column(db.Float)
  17. heuristic: db.Column = db.Column(db.Integer)
  18. def __repr__(self) -> str:
  19. return f'<Address {self.address}>'
  20. class DepositTransaction(db.Model):
  21. """
  22. Store transactions from EOA to deposit addresses computed during DAR.
  23. """
  24. __tablename__: str = 'deposit_transaction'
  25. id: db.Column = db.Column(db.Integer, primary_key = True)
  26. address: db.Column = db.Column(
  27. db.String(128),
  28. index = True,
  29. nullable = False,
  30. )
  31. deposit: db.Column = db.Column(
  32. db.String(128),
  33. nullable = False,
  34. )
  35. transaction: db.Column = db.Column(
  36. db.String(256),
  37. index = True,
  38. unique = True,
  39. nullable = False,
  40. )
  41. block_number: db.Column = db.Column(db.Integer)
  42. block_ts: db.Column = db.Column(db.DateTime)
  43. conf: db.Column = db.Column(db.Float)
  44. def __repr__(self) -> str:
  45. return f'<DepositTransaction {self.address}>'
  46. class Embedding(db.Model):
  47. __tablename__: str = 'embedding'
  48. id: db.Column = db.Column(db.Integer, primary_key = True)
  49. address: db.Column = db.Column(
  50. db.String(128),
  51. index = True,
  52. unique = True,
  53. nullable = False,
  54. )
  55. neighbors: db.Column = db.Column(db.String(512), nullable = False)
  56. distances: db.Column = db.Column(db.String(512), nullable = False)
  57. def __repr__(self) -> str:
  58. return f'<Embedding {self.address}>'
  59. class ExactMatch(db.Model):
  60. __tablename__: str = 'exact_match'
  61. id: db.Column = db.Column(db.Integer, primary_key = True)
  62. address: db.Column = db.Column(
  63. db.String(128),
  64. index = True,
  65. nullable = False,
  66. )
  67. transaction: db.Column = db.Column(
  68. db.String(256),
  69. index = True,
  70. nullable = False,
  71. )
  72. block_number: db.Column = db.Column(db.Integer)
  73. block_ts: db.Column = db.Column(db.DateTime)
  74. meta_data: db.Column = db.Column(db.String(256))
  75. cluster: db.Column = db.Column(db.Integer)
  76. def __repr__(self) -> str:
  77. return f'<ExactMatch {self.address}>'
  78. class GasPrice(db.Model):
  79. __tablename__: str = 'gas_price'
  80. id: db.Column = db.Column(db.Integer, primary_key = True)
  81. address: db.Column = db.Column(
  82. db.String(128),
  83. index = True,
  84. nullable = False,
  85. )
  86. transaction: db.Column = db.Column(
  87. db.String(256),
  88. index = True,
  89. nullable = False,
  90. )
  91. block_number: db.Column = db.Column(db.Integer)
  92. block_ts: db.Column = db.Column(db.DateTime)
  93. meta_data: db.Column = db.Column(db.String(256))
  94. cluster: db.Column = db.Column(db.Integer)
  95. def __repr__(self) -> str:
  96. return f'<GasPrice {self.address}>'
  97. class MultiDenom(db.Model):
  98. __tablename__: str = 'multi_denom'
  99. id: db.Column = db.Column(db.Integer, primary_key = True)
  100. address: db.Column = db.Column(
  101. db.String(128),
  102. index = True,
  103. nullable = False,
  104. )
  105. transaction: db.Column = db.Column(
  106. db.String(256),
  107. index = True,
  108. nullable = False,
  109. )
  110. block_number: db.Column = db.Column(db.Integer)
  111. block_ts: db.Column = db.Column(db.DateTime)
  112. meta_data: db.Column = db.Column(db.String(256))
  113. cluster: db.Column = db.Column(db.Integer)
  114. def __repr__(self) -> str:
  115. return f'<MultiDenom {self.address}>'
  116. class LinkedTransaction(db.Model):
  117. __tablename__: str = 'linked_transaction'
  118. id: db.Column = db.Column(db.Integer, primary_key = True)
  119. address: db.Column = db.Column(
  120. db.String(128),
  121. index = True,
  122. nullable = False,
  123. )
  124. transaction: db.Column = db.Column(
  125. db.String(256),
  126. index = True,
  127. nullable = False,
  128. )
  129. block_number: db.Column = db.Column(db.Integer)
  130. block_ts: db.Column = db.Column(db.DateTime)
  131. meta_data: db.Column = db.Column(db.String(256))
  132. cluster: db.Column = db.Column(db.Integer)
  133. def __repr__(self) -> str:
  134. return f'<LinkedTransaction {self.address}>'
  135. class TornMining(db.Model):
  136. __tablename__: str = 'torn_mine'
  137. id: db.Column = db.Column(db.Integer, primary_key = True)
  138. address: db.Column = db.Column(
  139. db.String(128),
  140. index = True,
  141. nullable = False,
  142. )
  143. transaction: db.Column = db.Column(
  144. db.String(256),
  145. index = True,
  146. nullable = False,
  147. )
  148. block_number: db.Column = db.Column(db.Integer)
  149. block_ts: db.Column = db.Column(db.DateTime)
  150. meta_data: db.Column = db.Column(db.String(256))
  151. cluster: db.Column = db.Column(db.Integer)
  152. def __repr__(self) -> str:
  153. return f'<TornMining {self.address}>'
  154. class TornadoDeposit(db.Model):
  155. __tablename__: str = 'tornado_deposit'
  156. id: db.Column = db.Column(db.Integer, primary_key = True)
  157. hash: db.Column = db.Column(db.String(128), index = True, nullable = False)
  158. transaction_index = db.Column(db.Integer, nullable = False)
  159. from_address = db.Column(db.String(128), nullable = False)
  160. to_address = db.Column(db.String(128), nullable = False)
  161. gas = db.Column(db.Float)
  162. gas_price = db.Column(db.Float)
  163. block_number = db.Column(db.Integer, nullable = False)
  164. block_hash = db.Column(db.String(128), index = True, nullable = False)
  165. tornado_cash_address = db.Column(db.String(128), index = True, nullable = False)
  166. def __repr__(self) -> str:
  167. return f'<TornadoDeposit {self.hash}>'
  168. class TornadoWithdraw(db.Model):
  169. __tablename__: str = 'tornado_withdraw'
  170. id: db.Column = db.Column(db.Integer, primary_key = True)
  171. hash: db.Column = db.Column(db.String(128), index = True, nullable = False)
  172. transaction_index = db.Column(db.Integer, nullable = False)
  173. from_address = db.Column(db.String(128), nullable = False)
  174. to_address = db.Column(db.String(128), nullable = False)
  175. gas = db.Column(db.Float)
  176. gas_price = db.Column(db.Float)
  177. block_number = db.Column(db.Integer, nullable = False)
  178. block_hash = db.Column(db.String(128), index = True, nullable = False)
  179. tornado_cash_address = db.Column(db.String(128), index = True, nullable = False)
  180. recipient_address = db.Column(db.String(128), index = True, nullable = False)
  181. def __repr__(self) -> str:
  182. return f'<TornadoWithdraw {self.hash}>'
  183. class TornadoPool(db.Model):
  184. """
  185. Stores an address and transaction that deposits into a tornado pool.
  186. """
  187. __tablename__: str = 'tornado_pool'
  188. id: db.Column = db.Column(db.Integer, primary_key = True)
  189. transaction: db.Column = db.Column(db.String(128), index = True, nullable = False)
  190. address: db.Column = db.Column(db.String(128), index = True, nullable = False)
  191. pool: db.Column = db.Column(db.String(128), index = True, nullable = False)
  192. def __repr__(self) -> str:
  193. return f'<TornadoPool {self.pool}>'