@instadapp/interop-x 0.0.0-dev.a861339 → 0.0.0-dev.a9047d2

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.
Files changed (309) hide show
  1. package/.github/workflows/ci.yml +19 -0
  2. package/dist/package.json +22 -12
  3. package/dist/src/abi/aaveV2Resolver.json +832 -0
  4. package/dist/src/abi/aaveV3Resolver.json +628 -0
  5. package/dist/src/abi/balanceResolver.json +211 -0
  6. package/dist/src/abi/connectors/index.js +36 -0
  7. package/dist/src/abi/connectors/v1/aave.js +148 -0
  8. package/dist/src/abi/connectors/v1/aave_claim.js +4 -0
  9. package/dist/src/abi/connectors/v1/aave_migrate.js +109 -0
  10. package/dist/src/abi/connectors/v1/aave_polygon_migrate.js +110 -0
  11. package/dist/src/abi/connectors/v1/aave_stake.js +4 -0
  12. package/dist/src/abi/connectors/v1/aave_v1_import.js +54 -0
  13. package/dist/src/abi/connectors/v1/aave_v2.js +230 -0
  14. package/dist/src/abi/connectors/v1/aave_v2_import.js +59 -0
  15. package/dist/src/abi/connectors/v1/authority.js +100 -0
  16. package/dist/src/abi/connectors/v1/basic.js +136 -0
  17. package/dist/src/abi/connectors/v1/chi.js +36 -0
  18. package/dist/src/abi/connectors/v1/comp.js +4 -0
  19. package/dist/src/abi/connectors/v1/compound.js +4 -0
  20. package/dist/src/abi/connectors/v1/compoundImport.js +69 -0
  21. package/dist/src/abi/connectors/v1/compoundImport_v2.js +4 -0
  22. package/dist/src/abi/connectors/v1/compound_old.js +448 -0
  23. package/dist/src/abi/connectors/v1/curve.js +140 -0
  24. package/dist/src/abi/connectors/v1/curve_claim.js +63 -0
  25. package/dist/src/abi/connectors/v1/curve_gauge.js +158 -0
  26. package/dist/src/abi/connectors/v1/curve_sbtc.js +140 -0
  27. package/dist/src/abi/connectors/v1/curve_susd.js +140 -0
  28. package/dist/src/abi/connectors/v1/curve_three.js +79 -0
  29. package/dist/src/abi/connectors/v1/curve_y.js +140 -0
  30. package/dist/src/abi/connectors/v1/dsa_migrate_v1_to_v2.js +4 -0
  31. package/dist/src/abi/connectors/v1/dydx.js +148 -0
  32. package/dist/src/abi/connectors/v1/dydx_flash.js +52 -0
  33. package/dist/src/abi/connectors/v1/fee.js +50 -0
  34. package/dist/src/abi/connectors/v1/gelato.js +1138 -0
  35. package/dist/src/abi/connectors/v1/index.js +58 -0
  36. package/dist/src/abi/connectors/v1/instapool.js +439 -0
  37. package/dist/src/abi/connectors/v1/instapool_v2.js +126 -0
  38. package/dist/src/abi/connectors/v1/kyber.js +117 -0
  39. package/dist/src/abi/connectors/v1/maker.js +480 -0
  40. package/dist/src/abi/connectors/v1/maker_old.js +300 -0
  41. package/dist/src/abi/connectors/v1/math.js +43 -0
  42. package/dist/src/abi/connectors/v1/migrate.js +46 -0
  43. package/dist/src/abi/connectors/v1/oasis.js +198 -0
  44. package/dist/src/abi/connectors/v1/oneInch.js +160 -0
  45. package/dist/src/abi/connectors/v1/polygon_bridge.js +4 -0
  46. package/dist/src/abi/connectors/v1/refinance.js +4 -0
  47. package/dist/src/abi/connectors/v1/staking.js +220 -0
  48. package/dist/src/abi/connectors/v1/swerve.js +179 -0
  49. package/dist/src/abi/connectors/v1/uniswap.js +297 -0
  50. package/dist/src/abi/connectors/v2/1INCH-A.js +4 -0
  51. package/dist/src/abi/connectors/v2/1INCH-B.js +4 -0
  52. package/dist/src/abi/connectors/v2/AAVE-CLAIM-A.js +4 -0
  53. package/dist/src/abi/connectors/v2/AAVE-CLAIM-B.js +166 -0
  54. package/dist/src/abi/connectors/v2/AAVE-STAKE-A.js +4 -0
  55. package/dist/src/abi/connectors/v2/AAVE-V1-A.js +130 -0
  56. package/dist/src/abi/connectors/v2/AAVE-V1-IMPORT-A.js +4 -0
  57. package/dist/src/abi/connectors/v2/AAVE-V2-A.js +230 -0
  58. package/dist/src/abi/connectors/v2/AAVE-V2-IMPORT-A.js +4 -0
  59. package/dist/src/abi/connectors/v2/AAVE-V2-IMPORT-B.js +225 -0
  60. package/dist/src/abi/connectors/v2/AUTHORITY-A.js +100 -0
  61. package/dist/src/abi/connectors/v2/B-COMPOUND-A.js +4 -0
  62. package/dist/src/abi/connectors/v2/B-LIQUITY-A.js +4 -0
  63. package/dist/src/abi/connectors/v2/B-MAKERDAO-A.js +4 -0
  64. package/dist/src/abi/connectors/v2/BASIC-A.js +136 -0
  65. package/dist/src/abi/connectors/v2/BASIC-B.js +4 -0
  66. package/dist/src/abi/connectors/v2/BASIC-C.js +4 -0
  67. package/dist/src/abi/connectors/v2/COMP-A.js +4 -0
  68. package/dist/src/abi/connectors/v2/COMPOUND-A.js +4 -0
  69. package/dist/src/abi/connectors/v2/COMPOUND-IMPORT-A.js +4 -0
  70. package/dist/src/abi/connectors/v2/COMPOUND-IMPORT-B.js +195 -0
  71. package/dist/src/abi/connectors/v2/G-UNISWAP-A.js +4 -0
  72. package/dist/src/abi/connectors/v2/GELATO-AAVE-A.js +4 -0
  73. package/dist/src/abi/connectors/v2/INST-A.js +4 -0
  74. package/dist/src/abi/connectors/v2/INST-LM-A.js +4 -0
  75. package/dist/src/abi/connectors/v2/INST-STAKING-A.js +4 -0
  76. package/dist/src/abi/connectors/v2/INST-STAKING-B.js +4 -0
  77. package/dist/src/abi/connectors/v2/INSTAPOOL-A.js +4 -0
  78. package/dist/src/abi/connectors/v2/LIQUITY-A.js +4 -0
  79. package/dist/src/abi/connectors/v2/MAKERDAO-A.js +4 -0
  80. package/dist/src/abi/connectors/v2/MAKERDAO-CLAIM-A.js +136 -0
  81. package/dist/src/abi/connectors/v2/PARASWAP-A.js +4 -0
  82. package/dist/src/abi/connectors/v2/POLYGON-BRIDGE-A.js +4 -0
  83. package/dist/src/abi/connectors/v2/REFINANCE-A.js +4 -0
  84. package/dist/src/abi/connectors/v2/REFLEXER-A.js +4 -0
  85. package/dist/src/abi/connectors/v2/STAKE-ERC20-A.js +4 -0
  86. package/dist/src/abi/connectors/v2/UNISWAP-A.js +297 -0
  87. package/dist/src/abi/connectors/v2/UNISWAP-V2-A.js +4 -0
  88. package/dist/src/abi/connectors/v2/UNISWAP-V3-A.js +4 -0
  89. package/dist/src/abi/connectors/v2/UNISWAP-V3-STAKE-A.js +4 -0
  90. package/dist/src/abi/connectors/v2/WETH-A.js +4 -0
  91. package/dist/src/abi/connectors/v2/YEARN-VAULT-A.js +4 -0
  92. package/dist/src/abi/connectors/v2/index.js +89 -0
  93. package/dist/src/abi/index.js +12 -2
  94. package/dist/src/abi/instList.json +232 -0
  95. package/dist/src/abi/interopX.json +1436 -0
  96. package/dist/src/api/index.js +8 -1
  97. package/dist/src/constants/addresses.js +12 -7
  98. package/dist/src/constants/blockConfirmations.js +8 -0
  99. package/dist/src/constants/capPerChain.js +8 -0
  100. package/dist/src/constants/index.js +3 -0
  101. package/dist/src/constants/tokens.js +30 -7
  102. package/dist/src/constants/wrappedNativeToken.js +8 -0
  103. package/dist/src/crons/index.js +3 -0
  104. package/dist/src/crons/prices.js +16 -0
  105. package/dist/src/db/models/transaction.js +26 -18
  106. package/dist/src/errors/index.js +30 -0
  107. package/dist/src/gnosis/actions/aaveV2/index.js +11 -0
  108. package/dist/src/gnosis/actions/aaveV2/source.js +100 -0
  109. package/dist/src/gnosis/actions/aaveV2/target.js +101 -0
  110. package/dist/src/gnosis/actions/aaveV3/index.js +11 -0
  111. package/dist/src/gnosis/actions/aaveV3/source.js +74 -0
  112. package/dist/src/gnosis/actions/aaveV3/target.js +87 -0
  113. package/dist/src/gnosis/actions/index.js +4 -2
  114. package/dist/src/gnosis/index.js +3 -3
  115. package/dist/src/index.js +2 -1
  116. package/dist/src/net/protocol/dial/SignatureDialProtocol.js +2 -2
  117. package/dist/src/providers/index.js +17 -0
  118. package/dist/src/providers/retry-provider.js +45 -0
  119. package/dist/src/services/Prices.js +74 -0
  120. package/dist/src/services/index.js +8 -0
  121. package/dist/src/tasks/InteropX/ProcessSubmitEvents.js +273 -0
  122. package/dist/src/tasks/InteropX/ProcessValidateEvents.js +203 -0
  123. package/dist/src/tasks/InteropX/SyncLogExecuteEvents.js +113 -0
  124. package/dist/src/tasks/{InteropXContract/SyncBridgeRequestEvents.js → InteropX/SyncLogSubmitEvents.js} +28 -18
  125. package/dist/src/tasks/InteropX/SyncLogValidateEvents.js +106 -0
  126. package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +6 -3
  127. package/dist/src/tasks/index.js +19 -12
  128. package/dist/src/typechain/{InteropXContract.js → AaveV2Resolver.js} +0 -0
  129. package/dist/src/typechain/AaveV3Resolver.js +2 -0
  130. package/dist/src/typechain/BalanceResolver.js +2 -0
  131. package/dist/src/typechain/InstList.js +2 -0
  132. package/dist/src/typechain/InteropX.js +2 -0
  133. package/dist/src/typechain/factories/AaveV2Resolver__factory.js +1191 -0
  134. package/dist/src/typechain/factories/AaveV3Resolver__factory.js +887 -0
  135. package/dist/src/typechain/factories/BalanceResolver__factory.js +228 -0
  136. package/dist/src/typechain/factories/InstList__factory.js +249 -0
  137. package/dist/src/typechain/factories/InteropX__factory.js +1928 -0
  138. package/dist/src/typechain/factories/index.js +11 -3
  139. package/dist/src/typechain/index.js +11 -3
  140. package/dist/src/utils/async.js +18 -0
  141. package/dist/src/utils/dsa.js +24 -0
  142. package/dist/src/utils/formatting.js +67 -0
  143. package/dist/src/utils/gnosis.js +87 -0
  144. package/dist/src/utils/http.js +10 -0
  145. package/dist/src/utils/index.js +22 -165
  146. package/dist/src/utils/interop.js +16 -0
  147. package/dist/src/utils/tokens.js +22 -0
  148. package/dist/src/utils/validate.js +107 -0
  149. package/dist/src/utils/web3.js +93 -0
  150. package/package.json +22 -12
  151. package/src/abi/aaveV2Resolver.json +832 -0
  152. package/src/abi/aaveV3Resolver.json +628 -0
  153. package/src/abi/balanceResolver.json +211 -0
  154. package/src/abi/connectors/index.ts +14 -0
  155. package/src/abi/connectors/v1/aave.ts +147 -0
  156. package/src/abi/connectors/v1/aave_claim.ts +3 -0
  157. package/src/abi/connectors/v1/aave_migrate.ts +108 -0
  158. package/src/abi/connectors/v1/aave_polygon_migrate.ts +109 -0
  159. package/src/abi/connectors/v1/aave_stake.ts +3 -0
  160. package/src/abi/connectors/v1/aave_v1_import.ts +53 -0
  161. package/src/abi/connectors/v1/aave_v2.ts +229 -0
  162. package/src/abi/connectors/v1/aave_v2_import.ts +58 -0
  163. package/src/abi/connectors/v1/authority.ts +99 -0
  164. package/src/abi/connectors/v1/basic.ts +135 -0
  165. package/src/abi/connectors/v1/chi.ts +35 -0
  166. package/src/abi/connectors/v1/comp.ts +3 -0
  167. package/src/abi/connectors/v1/compound.ts +3 -0
  168. package/src/abi/connectors/v1/compoundImport.ts +68 -0
  169. package/src/abi/connectors/v1/compoundImport_v2.ts +3 -0
  170. package/src/abi/connectors/v1/compound_old.ts +447 -0
  171. package/src/abi/connectors/v1/curve.ts +139 -0
  172. package/src/abi/connectors/v1/curve_claim.ts +62 -0
  173. package/src/abi/connectors/v1/curve_gauge.ts +157 -0
  174. package/src/abi/connectors/v1/curve_sbtc.ts +139 -0
  175. package/src/abi/connectors/v1/curve_susd.ts +139 -0
  176. package/src/abi/connectors/v1/curve_three.ts +78 -0
  177. package/src/abi/connectors/v1/curve_y.ts +139 -0
  178. package/src/abi/connectors/v1/dsa_migrate_v1_to_v2.ts +3 -0
  179. package/src/abi/connectors/v1/dydx.ts +147 -0
  180. package/src/abi/connectors/v1/dydx_flash.ts +51 -0
  181. package/src/abi/connectors/v1/fee.ts +49 -0
  182. package/src/abi/connectors/v1/gelato.ts +1137 -0
  183. package/src/abi/connectors/v1/index.ts +42 -0
  184. package/src/abi/connectors/v1/instapool.ts +438 -0
  185. package/src/abi/connectors/v1/instapool_v2.ts +125 -0
  186. package/src/abi/connectors/v1/kyber.ts +116 -0
  187. package/src/abi/connectors/v1/maker.ts +479 -0
  188. package/src/abi/connectors/v1/maker_old.ts +299 -0
  189. package/src/abi/connectors/v1/math.ts +42 -0
  190. package/src/abi/connectors/v1/migrate.ts +45 -0
  191. package/src/abi/connectors/v1/oasis.ts +197 -0
  192. package/src/abi/connectors/v1/oneInch.ts +159 -0
  193. package/src/abi/connectors/v1/polygon_bridge.ts +3 -0
  194. package/src/abi/connectors/v1/refinance.ts +3 -0
  195. package/src/abi/connectors/v1/staking.ts +219 -0
  196. package/src/abi/connectors/v1/swerve.ts +178 -0
  197. package/src/abi/connectors/v1/uniswap.ts +297 -0
  198. package/src/abi/connectors/v2/1INCH-A.ts +3 -0
  199. package/src/abi/connectors/v2/1INCH-B.ts +3 -0
  200. package/src/abi/connectors/v2/AAVE-CLAIM-A.ts +3 -0
  201. package/src/abi/connectors/v2/AAVE-CLAIM-B.ts +165 -0
  202. package/src/abi/connectors/v2/AAVE-STAKE-A.ts +3 -0
  203. package/src/abi/connectors/v2/AAVE-V1-A.ts +130 -0
  204. package/src/abi/connectors/v2/AAVE-V1-IMPORT-A.ts +3 -0
  205. package/src/abi/connectors/v2/AAVE-V2-A.ts +229 -0
  206. package/src/abi/connectors/v2/AAVE-V2-IMPORT-A.ts +3 -0
  207. package/src/abi/connectors/v2/AAVE-V2-IMPORT-B.ts +224 -0
  208. package/src/abi/connectors/v2/AUTHORITY-A.ts +99 -0
  209. package/src/abi/connectors/v2/B-COMPOUND-A.ts +3 -0
  210. package/src/abi/connectors/v2/B-LIQUITY-A.ts +3 -0
  211. package/src/abi/connectors/v2/B-MAKERDAO-A.ts +3 -0
  212. package/src/abi/connectors/v2/BASIC-A.ts +135 -0
  213. package/src/abi/connectors/v2/BASIC-B.ts +3 -0
  214. package/src/abi/connectors/v2/BASIC-C.ts +3 -0
  215. package/src/abi/connectors/v2/COMP-A.ts +3 -0
  216. package/src/abi/connectors/v2/COMPOUND-A.ts +3 -0
  217. package/src/abi/connectors/v2/COMPOUND-IMPORT-A.ts +3 -0
  218. package/src/abi/connectors/v2/COMPOUND-IMPORT-B.ts +194 -0
  219. package/src/abi/connectors/v2/G-UNISWAP-A.ts +3 -0
  220. package/src/abi/connectors/v2/GELATO-AAVE-A.ts +3 -0
  221. package/src/abi/connectors/v2/INST-A.ts +3 -0
  222. package/src/abi/connectors/v2/INST-LM-A.ts +3 -0
  223. package/src/abi/connectors/v2/INST-STAKING-A.ts +3 -0
  224. package/src/abi/connectors/v2/INST-STAKING-B.ts +3 -0
  225. package/src/abi/connectors/v2/INSTAPOOL-A.ts +3 -0
  226. package/src/abi/connectors/v2/LIQUITY-A.ts +3 -0
  227. package/src/abi/connectors/v2/MAKERDAO-A.ts +3 -0
  228. package/src/abi/connectors/v2/MAKERDAO-CLAIM-A.ts +135 -0
  229. package/src/abi/connectors/v2/PARASWAP-A.ts +3 -0
  230. package/src/abi/connectors/v2/POLYGON-BRIDGE-A.ts +3 -0
  231. package/src/abi/connectors/v2/REFINANCE-A.ts +3 -0
  232. package/src/abi/connectors/v2/REFLEXER-A.ts +3 -0
  233. package/src/abi/connectors/v2/STAKE-ERC20-A.ts +3 -0
  234. package/src/abi/connectors/v2/UNISWAP-A.ts +297 -0
  235. package/src/abi/connectors/v2/UNISWAP-V2-A.ts +3 -0
  236. package/src/abi/connectors/v2/UNISWAP-V3-A.ts +3 -0
  237. package/src/abi/connectors/v2/UNISWAP-V3-STAKE-A.ts +3 -0
  238. package/src/abi/connectors/v2/WETH-A.ts +3 -0
  239. package/src/abi/connectors/v2/YEARN-VAULT-A.ts +3 -0
  240. package/src/abi/connectors/v2/index.ts +87 -0
  241. package/src/abi/index.ts +15 -5
  242. package/src/abi/instList.json +232 -0
  243. package/src/abi/interopX.json +1436 -0
  244. package/src/api/index.ts +9 -1
  245. package/src/constants/addresses.ts +24 -8
  246. package/src/constants/blockConfirmations.ts +5 -0
  247. package/src/constants/capPerChain.ts +5 -0
  248. package/src/constants/index.ts +3 -0
  249. package/src/constants/tokens.ts +31 -8
  250. package/src/constants/wrappedNativeToken.ts +5 -0
  251. package/src/crons/index.ts +1 -0
  252. package/src/crons/prices.ts +12 -0
  253. package/src/db/models/transaction.ts +147 -98
  254. package/src/errors/index.ts +26 -0
  255. package/src/gnosis/actions/aaveV2/index.ts +9 -0
  256. package/src/gnosis/actions/aaveV2/source.ts +183 -0
  257. package/src/gnosis/actions/aaveV2/target.ts +168 -0
  258. package/src/gnosis/actions/aaveV3/index.ts +9 -0
  259. package/src/gnosis/actions/aaveV3/source.ts +119 -0
  260. package/src/gnosis/actions/aaveV3/target.ts +142 -0
  261. package/src/gnosis/actions/index.ts +4 -2
  262. package/src/gnosis/index.ts +3 -3
  263. package/src/index.ts +1 -0
  264. package/src/net/protocol/dial/SignatureDialProtocol.ts +3 -2
  265. package/src/providers/index.ts +1 -0
  266. package/src/providers/retry-provider.ts +51 -0
  267. package/src/services/Prices.ts +89 -0
  268. package/src/services/index.ts +1 -0
  269. package/src/tasks/InteropX/ProcessSubmitEvents.ts +385 -0
  270. package/src/tasks/InteropX/ProcessValidateEvents.ts +297 -0
  271. package/src/tasks/InteropX/SyncLogExecuteEvents.ts +161 -0
  272. package/src/tasks/InteropX/SyncLogSubmitEvents.ts +138 -0
  273. package/src/tasks/InteropX/SyncLogValidateEvents.ts +151 -0
  274. package/src/tasks/Transactions/SyncTransactionStatusTask.ts +6 -3
  275. package/src/tasks/index.ts +20 -12
  276. package/src/typechain/AaveV2Resolver.ts +1017 -0
  277. package/src/typechain/AaveV3Resolver.ts +935 -0
  278. package/src/typechain/BalanceResolver.ts +266 -0
  279. package/src/typechain/InstList.ts +402 -0
  280. package/src/typechain/InteropX.ts +1216 -0
  281. package/src/typechain/factories/AaveV2Resolver__factory.ts +1198 -0
  282. package/src/typechain/factories/AaveV3Resolver__factory.ts +894 -0
  283. package/src/typechain/factories/BalanceResolver__factory.ts +235 -0
  284. package/src/typechain/factories/InstList__factory.ts +253 -0
  285. package/src/typechain/factories/InteropX__factory.ts +1932 -0
  286. package/src/typechain/factories/index.ts +5 -1
  287. package/src/typechain/index.ts +10 -2
  288. package/src/utils/async.ts +22 -0
  289. package/src/utils/dsa.ts +30 -0
  290. package/src/utils/formatting.ts +68 -0
  291. package/src/utils/gnosis.ts +166 -0
  292. package/src/utils/http.ts +6 -0
  293. package/src/utils/index.ts +9 -240
  294. package/src/utils/interop.ts +28 -0
  295. package/src/utils/tokens.ts +21 -0
  296. package/src/utils/validate.ts +171 -0
  297. package/src/utils/web3.ts +132 -0
  298. package/dist/src/abi/interopXContract.json +0 -391
  299. package/dist/src/gnosis/actions/withdraw/index.js +0 -41
  300. package/dist/src/tasks/InteropXContract/ProcessBridgeRequestEvents.js +0 -147
  301. package/dist/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.js +0 -80
  302. package/dist/src/typechain/factories/InteropXContract__factory.js +0 -526
  303. package/src/abi/interopXContract.json +0 -391
  304. package/src/gnosis/actions/withdraw/index.ts +0 -56
  305. package/src/tasks/InteropXContract/ProcessBridgeRequestEvents.ts +0 -211
  306. package/src/tasks/InteropXContract/SyncBridgeRequestEvents.ts +0 -116
  307. package/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.ts +0 -112
  308. package/src/typechain/InteropXContract.ts +0 -524
  309. package/src/typechain/factories/InteropXContract__factory.ts +0 -533
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const abi_1 = __importDefault(require("@/abi"));
7
+ const config_1 = __importDefault(require("@/config"));
8
+ const constants_1 = require("@/constants");
9
+ const providers_1 = require("@/providers");
10
+ const utils_1 = require("@/utils");
11
+ const ethers_1 = require("ethers");
12
+ const ethers_multisend_1 = require("ethers-multisend");
13
+ async function default_1(transaction) {
14
+ const transactions = [];
15
+ const logs = [];
16
+ const { sourceSpells, position, actionId, sourceSender, sourceDsaId, targetDsaId, sourceChainId, targetChainId, vnonce, metadata, } = transaction.validateEvent;
17
+ const targetChainProvider = new providers_1.JsonRpcRetryProvider((0, utils_1.getRpcProviderUrl)(targetChainId));
18
+ const targetWallet = new ethers_1.ethers.Wallet(config_1.default.privateKey, targetChainProvider);
19
+ const targetInstListContract = (0, utils_1.getContract)(constants_1.addresses[targetChainId].instList, abi_1.default.instList, targetChainProvider);
20
+ const targetDsaAddress = await targetInstListContract.accountAddr(targetDsaId);
21
+ const dsaAddress = constants_1.addresses[targetChainId].dsaAddress;
22
+ const interopAddress = constants_1.addresses[targetChainId].interopX;
23
+ const contract = (0, utils_1.getContract)(interopAddress, abi_1.default.interopX, targetWallet);
24
+ const targetSpells = [];
25
+ const commonSpells = [];
26
+ for (const supplyToken of position.supply) {
27
+ let spellData = {
28
+ connector: "AAVE-V3-A",
29
+ method: "deposit",
30
+ args: [supplyToken.targetToken, supplyToken.amount, "0", "0"],
31
+ };
32
+ targetSpells.push({
33
+ connector: spellData.connector,
34
+ data: (0, utils_1.encodeConnectorMethod)(spellData),
35
+ });
36
+ let spellDataBasicWithdraw = {
37
+ connector: "BASIC-A",
38
+ method: "withdraw",
39
+ args: [supplyToken.targetToken, supplyToken.amount, targetDsaAddress, "0", "0"],
40
+ };
41
+ commonSpells.push({
42
+ connector: spellDataBasicWithdraw.connector,
43
+ data: (0, utils_1.encodeConnectorMethod)(spellDataBasicWithdraw),
44
+ });
45
+ }
46
+ for (const withdrawToken of position.withdraw) {
47
+ let spellData = {
48
+ connector: "AAVE-V3-A",
49
+ method: "borrow",
50
+ args: [
51
+ withdrawToken.targetToken,
52
+ withdrawToken.amount,
53
+ "2",
54
+ "0",
55
+ "0",
56
+ ],
57
+ };
58
+ targetSpells.push({
59
+ connector: spellData.connector,
60
+ data: (0, utils_1.encodeConnectorMethod)(spellData),
61
+ });
62
+ let spellData2 = {
63
+ connector: "BASIC-A",
64
+ method: "withdraw",
65
+ args: [
66
+ withdrawToken.targetToken,
67
+ withdrawToken.amount,
68
+ dsaAddress,
69
+ "0",
70
+ "0",
71
+ ],
72
+ };
73
+ targetSpells.push({
74
+ connector: spellData.connector,
75
+ data: (0, utils_1.encodeConnectorMethod)(spellData2),
76
+ });
77
+ }
78
+ const { data } = await contract.populateTransaction.targetAction(sourceSpells, targetSpells, commonSpells, position, actionId, sourceSender, sourceDsaId, targetDsaId, sourceChainId, targetChainId, vnonce, metadata);
79
+ transactions.push({
80
+ to: interopAddress,
81
+ data: data,
82
+ value: "0",
83
+ operation: ethers_multisend_1.OperationType.Call,
84
+ });
85
+ return { transactions, logs };
86
+ }
87
+ exports.default = default_1;
@@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const withdraw_1 = __importDefault(require("./withdraw"));
6
+ const aaveV2_1 = __importDefault(require("./aaveV2"));
7
+ const aaveV3_1 = __importDefault(require("./aaveV3"));
7
8
  exports.default = {
8
- withdraw: withdraw_1.default,
9
+ 'A:AAVE-V2:AAVE-V2': aaveV2_1.default,
10
+ 'A:AAVE-V3:AAVE-V3': aaveV3_1.default,
9
11
  };
@@ -8,13 +8,13 @@ const ethers_multisend_1 = require("ethers-multisend");
8
8
  const actions_1 = __importDefault(require("./actions"));
9
9
  const buildGnosisAction = async (transaction, type) => {
10
10
  // type = type || (transaction.sourceStatus === 'success' ? 'target' : 'source')
11
- if (actions_1.default.hasOwnProperty(transaction.action)) {
12
- const { transactions, logs } = await actions_1.default[transaction.action](transaction, type);
11
+ if (actions_1.default.hasOwnProperty(transaction.actionId)) {
12
+ const { transactions, logs } = await actions_1.default[transaction.actionId](transaction, type);
13
13
  return {
14
14
  data: (0, ethers_multisend_1.encodeMulti)(transactions).data,
15
15
  logs
16
16
  };
17
17
  }
18
- throw new Error(`Unknown action: ${transaction.action}`);
18
+ throw new Error(`Unknown action: ${transaction.actionId}`);
19
19
  };
20
20
  exports.buildGnosisAction = buildGnosisAction;
package/dist/src/index.js CHANGED
@@ -13,7 +13,7 @@ const package_json_1 = __importDefault(require("../package.json"));
13
13
  dotenv_1.default.config();
14
14
  const logger_1 = __importDefault(require("@/logger"));
15
15
  const logger = new logger_1.default('Process');
16
- const GIT_SHORT_HASH = 'a861339';
16
+ const GIT_SHORT_HASH = 'a9047d2';
17
17
  const printUsage = () => {
18
18
  console.log();
19
19
  console.log(`Interop X Node (v${package_json_1.default.version} - rev.${GIT_SHORT_HASH})`);
@@ -69,6 +69,7 @@ const net_1 = require("@/net");
69
69
  const api_1 = require("@/api");
70
70
  const db_1 = require("./db");
71
71
  const utils_1 = require("./utils");
72
+ require("./crons");
72
73
  async function main() {
73
74
  (0, net_1.startPeer)({});
74
75
  const tasks = new tasks_1.Tasks();
@@ -40,9 +40,9 @@ class SignatureDialProtocol extends BaseDialProtocol_1.BaseDialProtocol {
40
40
  }
41
41
  const { data: gnosisData } = await (0, gnosis_1.buildGnosisAction)(transaction, data.type);
42
42
  const signedData = await (0, utils_1.signGnosisSafeTx)({
43
- to: constants_1.addresses[transaction.sourceChainId].multisend,
43
+ to: constants_1.addresses[data.chainId].multisend,
44
44
  data: gnosisData,
45
- chainId: transaction.sourceChainId,
45
+ chainId: data.chainId,
46
46
  safeTxGas: data.safeTxGas,
47
47
  nonce: data.safeNonce,
48
48
  }, { signer });
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./retry-provider"), exports);
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.JsonRpcRetryProvider = exports.retryOperation = exports.promiseTimeout = void 0;
7
+ const ethers_1 = require("ethers");
8
+ const waait_1 = __importDefault(require("waait"));
9
+ const bluebird_1 = __importDefault(require("bluebird"));
10
+ function promiseTimeout(ms, promise) {
11
+ return bluebird_1.default.resolve(promise).timeout(ms);
12
+ }
13
+ exports.promiseTimeout = promiseTimeout;
14
+ function retryOperation(retriesLeft, operation, options) {
15
+ return new Promise((resolve, reject) => {
16
+ const { timeouts } = options;
17
+ // Find the timeout for this specific iteration
18
+ const timeout = timeouts[timeouts.length - retriesLeft];
19
+ // Wrap the original operation in a timeout
20
+ const execution = promiseTimeout(timeout, operation());
21
+ // If the promise is successful, resolve it and bubble the result up
22
+ return execution.then(resolve).catch((reason) => {
23
+ // If there are any retries left, we call the same retryOperation function again,
24
+ // but decrementing the number of retries left by 1
25
+ if (retriesLeft - 1 > 0) {
26
+ // Delay the new attempt slightly
27
+ return (0, waait_1.default)(options.delay || 50)
28
+ .then(retryOperation.bind(null, retriesLeft - 1, operation, options))
29
+ .then(resolve)
30
+ .catch(reject);
31
+ }
32
+ // Reject (and bubble the result up) if there are no more retries
33
+ return reject(reason);
34
+ });
35
+ });
36
+ }
37
+ exports.retryOperation = retryOperation;
38
+ class JsonRpcRetryProvider extends ethers_1.ethers.providers.JsonRpcProvider {
39
+ perform(method, params) {
40
+ const timeouts = [5000, 10000];
41
+ const operation = () => super.perform(method, params);
42
+ return retryOperation(2, operation, { timeouts, delay: 50 });
43
+ }
44
+ }
45
+ exports.JsonRpcRetryProvider = JsonRpcRetryProvider;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const web3_utils_1 = __importDefault(require("web3-utils"));
7
+ const path_1 = __importDefault(require("path"));
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const constants_1 = require("@/constants");
10
+ const expand_home_dir_1 = __importDefault(require("expand-home-dir"));
11
+ const config_1 = __importDefault(require("@/config"));
12
+ const utils_1 = require("@/utils");
13
+ const basePath = (0, expand_home_dir_1.default)(`~/.interop-x/data/${config_1.default.publicAddress}/${config_1.default.staging ? 'staging' : ''}`);
14
+ const mainnetPricesFilePath = path_1.default.resolve(basePath, "./mainnetPrices.json");
15
+ const networkTokenPricesFilePath = path_1.default.resolve(basePath, "./networkTokenPrices.json");
16
+ class Prices {
17
+ static async fetch() {
18
+ if (!fs_1.default.existsSync(mainnetPricesFilePath)) {
19
+ fs_1.default.writeFileSync(mainnetPricesFilePath, JSON.stringify({}));
20
+ }
21
+ if (!fs_1.default.existsSync(networkTokenPricesFilePath)) {
22
+ fs_1.default.writeFileSync(networkTokenPricesFilePath, JSON.stringify({}));
23
+ }
24
+ this.mainnetPrices = JSON.parse(fs_1.default.readFileSync(mainnetPricesFilePath, "utf8"));
25
+ this.networkTokenPrices = JSON.parse(fs_1.default.readFileSync(networkTokenPricesFilePath, "utf8"));
26
+ try {
27
+ const path = constants_1.tokens["1"]
28
+ .filter((a) => a.symbol !== "ETH")
29
+ .map((token) => token.address)
30
+ .join(",");
31
+ const [response, ethResponse, avaxResponse, polygonResponse] = await Promise.all([
32
+ utils_1.http.get("https://api.coingecko.com/api/v3/simple/token_price/ethereum", {
33
+ params: { contract_addresses: path, vs_currencies: "usd" },
34
+ }),
35
+ utils_1.http.get("https://api.coingecko.com/api/v3/simple/price", {
36
+ params: { ids: "ethereum", vs_currencies: "usd" },
37
+ }),
38
+ utils_1.http.get("https://api.coingecko.com/api/v3/simple/price", {
39
+ params: { ids: "avalanche-2", vs_currencies: "usd" },
40
+ }),
41
+ utils_1.http.get("https://api.coingecko.com/api/v3/simple/price", {
42
+ params: { ids: "matic-network", vs_currencies: "usd" },
43
+ }),
44
+ ]);
45
+ this.networkTokenPrices = {
46
+ "1": ethResponse.data.ethereum.usd.toString(),
47
+ "137": polygonResponse.data["matic-network"].usd.toString(),
48
+ "43114": avaxResponse.data["avalanche-2"].usd.toString(),
49
+ };
50
+ const data = response.data;
51
+ for (const key in data) {
52
+ const _key = web3_utils_1.default.toChecksumAddress(key);
53
+ if (!data[key].usd)
54
+ continue;
55
+ this.mainnetPrices[_key] = data[key].usd.toString();
56
+ }
57
+ this.mainnetPrices["0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"] =
58
+ ethResponse.data.ethereum.usd.toString();
59
+ }
60
+ catch (error) { }
61
+ fs_1.default.writeFileSync(mainnetPricesFilePath, JSON.stringify(this.mainnetPrices));
62
+ fs_1.default.writeFileSync(networkTokenPricesFilePath, JSON.stringify(this.networkTokenPrices));
63
+ return this.mainnetPrices;
64
+ }
65
+ static getMainnetPrices() {
66
+ return this.mainnetPrices;
67
+ }
68
+ static getNetworkTokenPrices() {
69
+ return this.networkTokenPrices;
70
+ }
71
+ }
72
+ Prices.mainnetPrices = {};
73
+ Prices.networkTokenPrices = {};
74
+ exports.default = Prices;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Prices = void 0;
7
+ var Prices_1 = require("./Prices");
8
+ Object.defineProperty(exports, "Prices", { enumerable: true, get: function () { return __importDefault(Prices_1).default; } });
@@ -0,0 +1,273 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const BaseTask_1 = require("../BaseTask");
7
+ const logger_1 = __importDefault(require("@/logger"));
8
+ const ethers_1 = require("ethers");
9
+ const abi_1 = __importDefault(require("@/abi"));
10
+ const db_1 = require("@/db");
11
+ const utils_1 = require("@/utils");
12
+ const constants_1 = require("@/constants");
13
+ const config_1 = __importDefault(require("@/config"));
14
+ const moment_1 = __importDefault(require("moment"));
15
+ const sequelize_1 = require("sequelize");
16
+ const gnosis_1 = require("@/gnosis");
17
+ const net_1 = require("@/net");
18
+ const waait_1 = __importDefault(require("waait"));
19
+ const errors_1 = require("@/errors");
20
+ const bignumber_js_1 = require("bignumber.js");
21
+ const dedent_1 = __importDefault(require("dedent"));
22
+ const providers_1 = require("@/providers");
23
+ class ProcessSubmitEvents extends BaseTask_1.BaseTask {
24
+ constructor({ chainId }) {
25
+ super({
26
+ logger: new logger_1.default("InteropX::ProcessSubmitEvents"),
27
+ });
28
+ this.leadNodeOnly = true;
29
+ this.blockConfirmationsCount = 12;
30
+ this.chainId = chainId;
31
+ }
32
+ async pollHandler() {
33
+ var _a;
34
+ const currentBlockNumber = await this.sourceProvider.getBlockNumber();
35
+ const transaction = await db_1.Transaction.findOne({
36
+ where: {
37
+ status: "pending",
38
+ sourceStatus: "pending",
39
+ sourceChainId: this.chainId,
40
+ submitBlockNumber: {
41
+ [sequelize_1.Op.lt]: currentBlockNumber - this.blockConfirmationsCount,
42
+ },
43
+ sourceDelayUntil: {
44
+ [sequelize_1.Op.or]: {
45
+ [sequelize_1.Op.is]: null,
46
+ [sequelize_1.Op.lt]: new Date(),
47
+ },
48
+ },
49
+ submitEvent: { $ne: null },
50
+ createdAt: {
51
+ [sequelize_1.Op.gt]: (0, moment_1.default)().subtract({ hours: 12 }).toDate(),
52
+ },
53
+ },
54
+ });
55
+ if (!transaction) {
56
+ return;
57
+ }
58
+ this.logger.debug(`Processing transaction ${transaction.transactionHash}`);
59
+ transaction.sourceStatus = "proccessing";
60
+ await transaction.save();
61
+ const { submitEvent: { position, sourceChainId, targetChainId } } = transaction;
62
+ try {
63
+ (0, utils_1.validateChains)({ sourceChainId, targetChainId });
64
+ }
65
+ catch (error) {
66
+ transaction.sourceErrors = [error.message];
67
+ transaction.sourceStatus = "failed";
68
+ transaction.targetStatus = "failed";
69
+ transaction.status = "failed";
70
+ await transaction.save();
71
+ return;
72
+ }
73
+ const walletBalance = (await this.sourceWallet.getBalance()).toString();
74
+ const currentGasPrice = (await this.sourceWallet.getGasPrice()).toString();
75
+ const minBalanceRequired = new bignumber_js_1.BigNumber(currentGasPrice)
76
+ .multipliedBy(4000000)
77
+ .multipliedBy(2); // 2x balance
78
+ if (new bignumber_js_1.BigNumber(walletBalance).isLessThan(minBalanceRequired)) {
79
+ console.log((0, dedent_1.default) `Not enough balance in wallet ${(0, utils_1.getExplorerUrl)(sourceChainId, '/address/' + this.sourceWallet.address)} on ${(0, utils_1.chainIdToName)(sourceChainId)}
80
+ Balance: ${ethers_1.ethers.utils.parseEther(walletBalance)} ${(0, utils_1.getChainIdNativeSymbol)(sourceChainId)}
81
+ Required Balance: ${ethers_1.ethers.utils.parseEther(minBalanceRequired.toString())}
82
+ Require more: ${ethers_1.ethers.utils.parseEther(minBalanceRequired.minus(walletBalance).toString())}`);
83
+ transaction.sourceDelayUntil = (0, moment_1.default)().add({ minutes: 5 }).toDate();
84
+ transaction.sourceStatus = "pending";
85
+ await transaction.save();
86
+ return;
87
+ }
88
+ try {
89
+ await (0, utils_1.validateLiquidityCap)(position, sourceChainId, targetChainId);
90
+ }
91
+ catch (error) {
92
+ transaction.sourceErrors = [error.message];
93
+ transaction.sourceStatus = "failed";
94
+ transaction.targetStatus = "failed";
95
+ transaction.status = "failed";
96
+ await transaction.save();
97
+ return;
98
+ }
99
+ try {
100
+ await (0, utils_1.validateSourceLiquidity)({
101
+ position,
102
+ sourceChainId,
103
+ sourceProvider: this.sourceProvider,
104
+ });
105
+ }
106
+ catch (error) {
107
+ if (error instanceof errors_1.UnsupportedChaindIdError) {
108
+ console.log(`Dropping transaction ${transaction.transactionHash}`);
109
+ transaction.sourceErrors = [error.message];
110
+ transaction.sourceStatus = "failed";
111
+ transaction.targetStatus = "failed";
112
+ transaction.status = "failed";
113
+ await transaction.save();
114
+ }
115
+ else {
116
+ transaction.sourceStatus = "pending";
117
+ transaction.sourceErrors = [error.message];
118
+ transaction.sourceDelayUntil = (0, moment_1.default)().add({ minutes: 5 }).toDate();
119
+ await transaction.save();
120
+ console.log("[validateSourceLiquidity][Warning]", error.message);
121
+ return;
122
+ }
123
+ }
124
+ const ownersThreshold = await this.sourceGnosisContract.getThreshold();
125
+ await (0, waait_1.default)(10000);
126
+ this.logger.debug(`Build gnosis action for ${transaction.transactionHash}`);
127
+ let data, logs = [];
128
+ try {
129
+ ({ data, logs } = await (0, gnosis_1.buildGnosisAction)(transaction, "source"));
130
+ }
131
+ catch (error) {
132
+ if (error instanceof errors_1.LiquidityError) {
133
+ await transaction.save();
134
+ transaction.sourceDelayUntil = new Date(Date.now() + 60 * 5 * 1000);
135
+ transaction.sourceStatus = "pending";
136
+ await transaction.save();
137
+ throw error;
138
+ return;
139
+ }
140
+ transaction.sourceStatus = "failed";
141
+ transaction.sourceErrors = [error.message];
142
+ transaction.targetStatus = "failed";
143
+ transaction.status = "failed";
144
+ await transaction.save();
145
+ net_1.protocol.sendTransaction(transaction);
146
+ return;
147
+ }
148
+ this.logger.debug(`Generating gnosis tx for ${transaction.transactionHash}`);
149
+ let gnosisTx = await (0, utils_1.generateGnosisTransaction)({
150
+ baseGas: "0",
151
+ data,
152
+ gasPrice: "0",
153
+ gasToken: "0x0000000000000000000000000000000000000000",
154
+ nonce: "0",
155
+ operation: "1",
156
+ refundReceiver: "0x0000000000000000000000000000000000000000",
157
+ safeAddress: this.sourceGnosisContract.address,
158
+ safeTxGas: "79668",
159
+ to: constants_1.addresses[transaction.sourceChainId].multisend,
160
+ value: "0",
161
+ }, this.sourceGnosisContract);
162
+ async function getGnosisOwnerPeerIds({ gnosisContract }) {
163
+ const owners = await gnosisContract
164
+ .getOwners()
165
+ .then((owners) => owners.map((owner) => owner.toLowerCase()));
166
+ return net_1.peerPool.activePeers
167
+ .filter((peer) => owners.includes(peer.publicAddress.toLowerCase()))
168
+ .map((peer) => peer.id);
169
+ }
170
+ const ownerPeerIds = await getGnosisOwnerPeerIds({
171
+ gnosisContract: this.sourceGnosisContract,
172
+ });
173
+ console.log(`Collecting signatures for execution ${transaction.transactionHash} `);
174
+ console.log(ownerPeerIds);
175
+ console.log(data);
176
+ const message = (0, utils_1.generateGnosisSignatureMessage)({
177
+ to: constants_1.addresses[this.chainId].multisend,
178
+ data,
179
+ chainId: this.chainId,
180
+ safeTxGas: gnosisTx.safeTxGas,
181
+ nonce: gnosisTx.safeNonce,
182
+ });
183
+ const signatures = await net_1.protocol.requestSignatures({
184
+ type: "source",
185
+ transactionHash: transaction.transactionHash,
186
+ safeTxGas: gnosisTx.safeTxGas,
187
+ safeNonce: gnosisTx.nonce,
188
+ chainId: this.chainId,
189
+ }, ownerPeerIds);
190
+ const validSignatures = signatures
191
+ .filter((s) => !!s.data && s.data !== "0x")
192
+ .filter((s) => {
193
+ try {
194
+ const address = (0, utils_1.getGnosisSignatureAddress)({
195
+ message,
196
+ signature: s.data,
197
+ chainId: this.chainId,
198
+ });
199
+ return (address === null || address === void 0 ? void 0 : address.toLowerCase()) === s.signer.toLowerCase();
200
+ }
201
+ catch (error) {
202
+ return false;
203
+ }
204
+ });
205
+ console.log({
206
+ signatures,
207
+ validSignatures,
208
+ ownersThreshold: ownersThreshold.toString(),
209
+ });
210
+ if (validSignatures.length === 0 ||
211
+ ownersThreshold.gt(validSignatures.length)) {
212
+ await transaction.save();
213
+ transaction.sourceDelayUntil = new Date(Date.now() + 30 * 1000);
214
+ transaction.sourceStatus = "pending";
215
+ await transaction.save();
216
+ const errorMessage = (_a = signatures.find((s) => !!s.error)) === null || _a === void 0 ? void 0 : _a.error;
217
+ throw new Error(`Not enough signatures` + (errorMessage ? `: ${errorMessage} ` : ""));
218
+ }
219
+ console.log(`Executing transaction for execution ${transaction.transactionHash}`);
220
+ const { data: txData } = await this.sourceGnosisContract.populateTransaction.execTransaction(gnosisTx.to, gnosisTx.value, gnosisTx.data, gnosisTx.operation, gnosisTx.safeTxGas, gnosisTx.baseGas, gnosisTx.gasPrice, gnosisTx.gasToken, gnosisTx.refundReceiver, (0, utils_1.buildSignatureBytes)(validSignatures));
221
+ const [gasPrice, gasLimit] = await Promise.all([
222
+ this.sourceProvider.getGasPrice(),
223
+ this.sourceProvider.estimateGas({
224
+ from: this.sourceWallet.address,
225
+ to: this.sourceGnosisContract.address,
226
+ data: txData,
227
+ }),
228
+ ]);
229
+ const txSent = await this.sourceWallet.sendTransaction({
230
+ from: this.sourceWallet.address,
231
+ to: this.sourceGnosisContract.address,
232
+ gasPrice: gasPrice.mul(120).div(100),
233
+ gasLimit: 5000000,
234
+ data: txData,
235
+ });
236
+ console.log(txSent);
237
+ const receipt = await txSent.wait();
238
+ const parsedLogs = [];
239
+ receipt.logs.forEach((log) => {
240
+ try {
241
+ parsedLogs.push(this.sourceGnosisContract.interface.parseLog(log));
242
+ }
243
+ catch (e) { }
244
+ });
245
+ if (parsedLogs.find((e) => e.name === "ExecutionSuccess")) {
246
+ console.log("ExecutionSuccess");
247
+ transaction.sourceStatus = "success";
248
+ if (txSent.blockNumber)
249
+ transaction.sourceBlockNumber = txSent.blockNumber;
250
+ transaction.sourceTransactionHash = txSent.hash;
251
+ transaction.sourceLogs = logs;
252
+ await transaction.save();
253
+ }
254
+ else {
255
+ console.log("ExecutionFailure");
256
+ transaction.sourceStatus = "failed";
257
+ if (txSent.blockNumber)
258
+ transaction.sourceBlockNumber = txSent.blockNumber;
259
+ transaction.sourceTransactionHash = txSent.hash;
260
+ transaction.status = "failed";
261
+ await transaction.save();
262
+ }
263
+ net_1.protocol.sendTransaction(transaction);
264
+ }
265
+ async start() {
266
+ this.blockConfirmationsCount = constants_1.blockConfirmations[this.chainId] + 1;
267
+ this.sourceProvider = new providers_1.JsonRpcRetryProvider((0, utils_1.getRpcProviderUrl)(this.chainId));
268
+ this.sourceWallet = new ethers_1.ethers.Wallet(config_1.default.privateKey, this.sourceProvider);
269
+ this.sourceGnosisContract = (0, utils_1.getContract)(constants_1.addresses[this.chainId].gnosisSafe, abi_1.default.gnosisSafe, this.sourceWallet);
270
+ await super.start();
271
+ }
272
+ }
273
+ exports.default = ProcessSubmitEvents;