@across-protocol/contracts 0.1.0

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 (257) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +661 -0
  3. package/README.md +53 -0
  4. package/artifacts/@eth-optimism/contracts/L2/messaging/IL2ERC20Bridge.sol/IL2ERC20Bridge.dbg.json +4 -0
  5. package/artifacts/@eth-optimism/contracts/L2/messaging/IL2ERC20Bridge.sol/IL2ERC20Bridge.json +252 -0
  6. package/artifacts/@eth-optimism/contracts/libraries/bridge/CrossDomainEnabled.sol/CrossDomainEnabled.dbg.json +4 -0
  7. package/artifacts/@eth-optimism/contracts/libraries/bridge/CrossDomainEnabled.sol/CrossDomainEnabled.json +35 -0
  8. package/artifacts/@eth-optimism/contracts/libraries/bridge/ICrossDomainMessenger.sol/ICrossDomainMessenger.dbg.json +4 -0
  9. package/artifacts/@eth-optimism/contracts/libraries/bridge/ICrossDomainMessenger.sol/ICrossDomainMessenger.json +110 -0
  10. package/artifacts/@eth-optimism/contracts/libraries/constants/Lib_PredeployAddresses.sol/Lib_PredeployAddresses.dbg.json +4 -0
  11. package/artifacts/@eth-optimism/contracts/libraries/constants/Lib_PredeployAddresses.sol/Lib_PredeployAddresses.json +10 -0
  12. package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/AccessControl.dbg.json +4 -0
  13. package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/AccessControl.json +215 -0
  14. package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/IAccessControl.dbg.json +4 -0
  15. package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/IAccessControl.json +108 -0
  16. package/artifacts/@openzeppelin/contracts/access/Ownable.sol/Ownable.dbg.json +4 -0
  17. package/artifacts/@openzeppelin/contracts/access/Ownable.sol/Ownable.json +63 -0
  18. package/artifacts/@openzeppelin/contracts/security/Pausable.sol/Pausable.dbg.json +4 -0
  19. package/artifacts/@openzeppelin/contracts/security/Pausable.sol/Pausable.json +50 -0
  20. package/artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.dbg.json +4 -0
  21. package/artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.json +297 -0
  22. package/artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.dbg.json +4 -0
  23. package/artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.json +194 -0
  24. package/artifacts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol/IERC20Metadata.dbg.json +4 -0
  25. package/artifacts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol/IERC20Metadata.json +233 -0
  26. package/artifacts/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol/SafeERC20.dbg.json +4 -0
  27. package/artifacts/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol/SafeERC20.json +10 -0
  28. package/artifacts/@openzeppelin/contracts/utils/Address.sol/Address.dbg.json +4 -0
  29. package/artifacts/@openzeppelin/contracts/utils/Address.sol/Address.json +10 -0
  30. package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json +4 -0
  31. package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.json +10 -0
  32. package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.dbg.json +4 -0
  33. package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.json +10 -0
  34. package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.dbg.json +4 -0
  35. package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.json +30 -0
  36. package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.dbg.json +4 -0
  37. package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.json +30 -0
  38. package/artifacts/@openzeppelin/contracts/utils/math/SafeMath.sol/SafeMath.dbg.json +4 -0
  39. package/artifacts/@openzeppelin/contracts/utils/math/SafeMath.sol/SafeMath.json +10 -0
  40. package/artifacts/@openzeppelin/contracts/utils/math/SignedSafeMath.sol/SignedSafeMath.dbg.json +4 -0
  41. package/artifacts/@openzeppelin/contracts/utils/math/SignedSafeMath.sol/SignedSafeMath.json +10 -0
  42. package/artifacts/@uma/core/contracts/common/implementation/Lockable.sol/Lockable.dbg.json +4 -0
  43. package/artifacts/@uma/core/contracts/common/implementation/Lockable.sol/Lockable.json +16 -0
  44. package/artifacts/@uma/core/contracts/cross-chain-oracle/chain-adapters/Arbitrum_ParentMessenger.sol/Arbitrum_ParentMessenger.dbg.json +4 -0
  45. package/artifacts/@uma/core/contracts/cross-chain-oracle/chain-adapters/Arbitrum_ParentMessenger.sol/Arbitrum_ParentMessenger.json +611 -0
  46. package/artifacts/@uma/core/contracts/cross-chain-oracle/chain-adapters/ParentMessengerBase.sol/ParentMessengerBase.dbg.json +4 -0
  47. package/artifacts/@uma/core/contracts/cross-chain-oracle/chain-adapters/ParentMessengerBase.sol/ParentMessengerBase.json +297 -0
  48. package/artifacts/@uma/core/contracts/cross-chain-oracle/interfaces/ParentMessengerConsumerInterface.sol/ParentMessengerConsumerInterface.dbg.json +4 -0
  49. package/artifacts/@uma/core/contracts/cross-chain-oracle/interfaces/ParentMessengerConsumerInterface.sol/ParentMessengerConsumerInterface.json +29 -0
  50. package/artifacts/@uma/core/contracts/cross-chain-oracle/interfaces/ParentMessengerInterface.sol/ParentMessengerInterface.dbg.json +4 -0
  51. package/artifacts/@uma/core/contracts/cross-chain-oracle/interfaces/ParentMessengerInterface.sol/ParentMessengerInterface.json +37 -0
  52. package/artifacts/@uma/core/contracts/external/avm/interfaces/iArbitrum_Inbox.sol/IBridge.dbg.json +4 -0
  53. package/artifacts/@uma/core/contracts/external/avm/interfaces/iArbitrum_Inbox.sol/IBridge.json +24 -0
  54. package/artifacts/@uma/core/contracts/external/avm/interfaces/iArbitrum_Inbox.sol/iArbitrum_Inbox.dbg.json +4 -0
  55. package/artifacts/@uma/core/contracts/external/avm/interfaces/iArbitrum_Inbox.sol/iArbitrum_Inbox.json +78 -0
  56. package/artifacts/@uma/core/contracts/external/avm/interfaces/iArbitrum_Outbox.sol/iArbitrum_Outbox.dbg.json +4 -0
  57. package/artifacts/@uma/core/contracts/external/avm/interfaces/iArbitrum_Outbox.sol/iArbitrum_Outbox.json +24 -0
  58. package/artifacts/@uma/core/contracts/insured-bridge/avm/Arbitrum_CrossDomainEnabled.sol/Arbitrum_CrossDomainEnabled.dbg.json +4 -0
  59. package/artifacts/@uma/core/contracts/insured-bridge/avm/Arbitrum_CrossDomainEnabled.sol/Arbitrum_CrossDomainEnabled.json +24 -0
  60. package/artifacts/build-info/1cd64db7a8ac0a153df93d26826ad4e9.json +1653 -0
  61. package/artifacts/build-info/1f738b56edd7602183f2f8d2f23f6e90.json +1592 -0
  62. package/artifacts/build-info/343b9221be36acd9ddaca3f3b83d2e75.json +3943 -0
  63. package/artifacts/build-info/622e561692c193f4cd0ff989b5a231e2.json +5661 -0
  64. package/artifacts/build-info/8e408b49e0ff2873bc28d45221a7ff71.json +277715 -0
  65. package/artifacts/build-info/9d1a3182633612bd337d811d567d5d60.json +2072 -0
  66. package/artifacts/build-info/a8cd9c443d245fe513d6650634b60f93.json +23776 -0
  67. package/artifacts/build-info/d302d9d63fbafb5c8d635cc62cb1cc7c.json +167529 -0
  68. package/artifacts/contracts/common/implementation/AncillaryData.sol/AncillaryData.dbg.json +4 -0
  69. package/artifacts/contracts/common/implementation/AncillaryData.sol/AncillaryData.json +10 -0
  70. package/artifacts/contracts/common/implementation/FixedPoint.sol/FixedPoint.dbg.json +4 -0
  71. package/artifacts/contracts/common/implementation/FixedPoint.sol/FixedPoint.json +10 -0
  72. package/artifacts/contracts/common/implementation/Lockable.sol/Lockable.dbg.json +4 -0
  73. package/artifacts/contracts/common/implementation/Lockable.sol/Lockable.json +16 -0
  74. package/artifacts/contracts/common/implementation/MultiCaller.sol/MultiCaller.dbg.json +4 -0
  75. package/artifacts/contracts/common/implementation/MultiCaller.sol/MultiCaller.json +30 -0
  76. package/artifacts/contracts/common/implementation/Testable.sol/Testable.dbg.json +4 -0
  77. package/artifacts/contracts/common/implementation/Testable.sol/Testable.json +50 -0
  78. package/artifacts/contracts/common/implementation/Timer.sol/Timer.dbg.json +4 -0
  79. package/artifacts/contracts/common/implementation/Timer.sol/Timer.json +42 -0
  80. package/artifacts/contracts/common/interfaces/AddressWhitelistInterface.sol/AddressWhitelistInterface.dbg.json +4 -0
  81. package/artifacts/contracts/common/interfaces/AddressWhitelistInterface.sol/AddressWhitelistInterface.json +69 -0
  82. package/artifacts/contracts/external/avm/AVM_CrossDomainEnabled.sol/AVM_CrossDomainEnabled.dbg.json +4 -0
  83. package/artifacts/contracts/external/avm/AVM_CrossDomainEnabled.sol/AVM_CrossDomainEnabled.json +42 -0
  84. package/artifacts/contracts/external/avm/interfaces/ArbSys.sol/ArbSys.dbg.json +4 -0
  85. package/artifacts/contracts/external/avm/interfaces/ArbSys.sol/ArbSys.json +235 -0
  86. package/artifacts/contracts/external/avm/interfaces/iArbitrum_Inbox.sol/IBridge.dbg.json +4 -0
  87. package/artifacts/contracts/external/avm/interfaces/iArbitrum_Inbox.sol/IBridge.json +24 -0
  88. package/artifacts/contracts/external/avm/interfaces/iArbitrum_Inbox.sol/iArbitrum_Inbox.dbg.json +4 -0
  89. package/artifacts/contracts/external/avm/interfaces/iArbitrum_Inbox.sol/iArbitrum_Inbox.json +78 -0
  90. package/artifacts/contracts/external/avm/interfaces/iArbitrum_Outbox.sol/iArbitrum_Outbox.dbg.json +4 -0
  91. package/artifacts/contracts/external/avm/interfaces/iArbitrum_Outbox.sol/iArbitrum_Outbox.json +24 -0
  92. package/artifacts/contracts/external/chainbridge/Bridge.sol/Bridge.dbg.json +4 -0
  93. package/artifacts/contracts/external/chainbridge/Bridge.sol/Bridge.json +1019 -0
  94. package/artifacts/contracts/external/chainbridge/handlers/GenericHandler.sol/GenericHandler.dbg.json +4 -0
  95. package/artifacts/contracts/external/chainbridge/handlers/GenericHandler.sol/GenericHandler.json +314 -0
  96. package/artifacts/contracts/external/chainbridge/interfaces/IBridge.sol/IBridge.dbg.json +4 -0
  97. package/artifacts/contracts/external/chainbridge/interfaces/IBridge.sol/IBridge.json +47 -0
  98. package/artifacts/contracts/external/chainbridge/interfaces/IDepositExecute.sol/IDepositExecute.dbg.json +4 -0
  99. package/artifacts/contracts/external/chainbridge/interfaces/IDepositExecute.sol/IDepositExecute.json +62 -0
  100. package/artifacts/contracts/external/chainbridge/interfaces/IERCHandler.sol/IERCHandler.dbg.json +4 -0
  101. package/artifacts/contracts/external/chainbridge/interfaces/IERCHandler.sol/IERCHandler.json +65 -0
  102. package/artifacts/contracts/external/chainbridge/interfaces/IGenericHandler.sol/IGenericHandler.dbg.json +4 -0
  103. package/artifacts/contracts/external/chainbridge/interfaces/IGenericHandler.sol/IGenericHandler.json +39 -0
  104. package/artifacts/contracts/external/ovm/OVM_CrossDomainEnabled.sol/OVM_CrossDomainEnabled.dbg.json +4 -0
  105. package/artifacts/contracts/external/ovm/OVM_CrossDomainEnabled.sol/OVM_CrossDomainEnabled.json +35 -0
  106. package/artifacts/contracts/external/ovm/OVM_CrossDomainEnabled.sol/iOVM_CrossDomainMessenger.dbg.json +4 -0
  107. package/artifacts/contracts/external/ovm/OVM_CrossDomainEnabled.sol/iOVM_CrossDomainMessenger.json +86 -0
  108. package/artifacts/contracts/external/polygon/lib/Merkle.sol/Merkle.dbg.json +4 -0
  109. package/artifacts/contracts/external/polygon/lib/Merkle.sol/Merkle.json +10 -0
  110. package/artifacts/contracts/external/polygon/lib/MerklePatriciaProof.sol/MerklePatriciaProof.dbg.json +4 -0
  111. package/artifacts/contracts/external/polygon/lib/MerklePatriciaProof.sol/MerklePatriciaProof.json +10 -0
  112. package/artifacts/contracts/external/polygon/lib/RLPReader.sol/RLPReader.dbg.json +4 -0
  113. package/artifacts/contracts/external/polygon/lib/RLPReader.sol/RLPReader.json +10 -0
  114. package/artifacts/contracts/external/polygon/test/FxChildMock.sol/FxChildMock.dbg.json +4 -0
  115. package/artifacts/contracts/external/polygon/test/FxChildMock.sol/FxChildMock.json +104 -0
  116. package/artifacts/contracts/external/polygon/test/FxChildMock.sol/IFxMessageProcessor.dbg.json +4 -0
  117. package/artifacts/contracts/external/polygon/test/FxChildMock.sol/IFxMessageProcessor.json +34 -0
  118. package/artifacts/contracts/external/polygon/test/FxChildMock.sol/IStateReceiver.dbg.json +4 -0
  119. package/artifacts/contracts/external/polygon/test/FxChildMock.sol/IStateReceiver.json +29 -0
  120. package/artifacts/contracts/external/polygon/test/FxRootMock.sol/FxRootMock.dbg.json +4 -0
  121. package/artifacts/contracts/external/polygon/test/FxRootMock.sol/FxRootMock.json +79 -0
  122. package/artifacts/contracts/external/polygon/test/FxRootMock.sol/IFxStateSender.dbg.json +4 -0
  123. package/artifacts/contracts/external/polygon/test/FxRootMock.sol/IFxStateSender.json +29 -0
  124. package/artifacts/contracts/external/polygon/test/FxRootMock.sol/IStateSender.dbg.json +4 -0
  125. package/artifacts/contracts/external/polygon/test/FxRootMock.sol/IStateSender.json +29 -0
  126. package/artifacts/contracts/external/polygon/test/StateSyncMock.sol/StateSyncMock.dbg.json +4 -0
  127. package/artifacts/contracts/external/polygon/test/StateSyncMock.sol/StateSyncMock.json +54 -0
  128. package/artifacts/contracts/external/polygon/tunnel/FxBaseChildTunnel.sol/FxBaseChildTunnel.dbg.json +4 -0
  129. package/artifacts/contracts/external/polygon/tunnel/FxBaseChildTunnel.sol/FxBaseChildTunnel.json +86 -0
  130. package/artifacts/contracts/external/polygon/tunnel/FxBaseChildTunnel.sol/IFxMessageProcessor.dbg.json +4 -0
  131. package/artifacts/contracts/external/polygon/tunnel/FxBaseChildTunnel.sol/IFxMessageProcessor.json +34 -0
  132. package/artifacts/contracts/external/polygon/tunnel/FxBaseRootTunnel.sol/FxBaseRootTunnel.dbg.json +4 -0
  133. package/artifacts/contracts/external/polygon/tunnel/FxBaseRootTunnel.sol/FxBaseRootTunnel.json +108 -0
  134. package/artifacts/contracts/external/polygon/tunnel/FxBaseRootTunnel.sol/ICheckpointManager.dbg.json +4 -0
  135. package/artifacts/contracts/external/polygon/tunnel/FxBaseRootTunnel.sol/ICheckpointManager.json +50 -0
  136. package/artifacts/contracts/external/polygon/tunnel/FxBaseRootTunnel.sol/IFxStateSender.dbg.json +4 -0
  137. package/artifacts/contracts/external/polygon/tunnel/FxBaseRootTunnel.sol/IFxStateSender.json +29 -0
  138. package/artifacts/contracts/insured-bridge/BridgeAdmin.sol/BridgeAdmin.dbg.json +4 -0
  139. package/artifacts/contracts/insured-bridge/BridgeAdmin.sol/BridgeAdmin.json +662 -0
  140. package/artifacts/contracts/insured-bridge/BridgeDepositBox.sol/BridgeDepositBox.dbg.json +4 -0
  141. package/artifacts/contracts/insured-bridge/BridgeDepositBox.sol/BridgeDepositBox.json +391 -0
  142. package/artifacts/contracts/insured-bridge/BridgeDepositBox.sol/TokenLike.dbg.json +4 -0
  143. package/artifacts/contracts/insured-bridge/BridgeDepositBox.sol/TokenLike.json +30 -0
  144. package/artifacts/contracts/insured-bridge/BridgeDepositBox.sol/WETH9Like.dbg.json +4 -0
  145. package/artifacts/contracts/insured-bridge/BridgeDepositBox.sol/WETH9Like.json +31 -0
  146. package/artifacts/contracts/insured-bridge/BridgePool.sol/BridgePool.dbg.json +4 -0
  147. package/artifacts/contracts/insured-bridge/BridgePool.sol/BridgePool.json +1709 -0
  148. package/artifacts/contracts/insured-bridge/BridgePool.sol/BridgePoolProd.dbg.json +4 -0
  149. package/artifacts/contracts/insured-bridge/BridgePool.sol/BridgePoolProd.json +1709 -0
  150. package/artifacts/contracts/insured-bridge/BridgePool.sol/WETH9Like.dbg.json +4 -0
  151. package/artifacts/contracts/insured-bridge/BridgePool.sol/WETH9Like.json +31 -0
  152. package/artifacts/contracts/insured-bridge/avm/AVM_BridgeDepositBox.sol/AVM_BridgeDepositBox.dbg.json +4 -0
  153. package/artifacts/contracts/insured-bridge/avm/AVM_BridgeDepositBox.sol/AVM_BridgeDepositBox.json +564 -0
  154. package/artifacts/contracts/insured-bridge/avm/AVM_BridgeDepositBox.sol/StandardBridgeLike.dbg.json +4 -0
  155. package/artifacts/contracts/insured-bridge/avm/AVM_BridgeDepositBox.sol/StandardBridgeLike.json +45 -0
  156. package/artifacts/contracts/insured-bridge/avm/Arbitrum_CrossDomainEnabled.sol/Arbitrum_CrossDomainEnabled.dbg.json +4 -0
  157. package/artifacts/contracts/insured-bridge/avm/Arbitrum_CrossDomainEnabled.sol/Arbitrum_CrossDomainEnabled.json +24 -0
  158. package/artifacts/contracts/insured-bridge/avm/Arbitrum_Messenger.sol/Arbitrum_Messenger.dbg.json +4 -0
  159. package/artifacts/contracts/insured-bridge/avm/Arbitrum_Messenger.sol/Arbitrum_Messenger.json +191 -0
  160. package/artifacts/contracts/insured-bridge/interfaces/BridgeAdminInterface.sol/BridgeAdminInterface.dbg.json +4 -0
  161. package/artifacts/contracts/insured-bridge/interfaces/BridgeAdminInterface.sol/BridgeAdminInterface.json +319 -0
  162. package/artifacts/contracts/insured-bridge/interfaces/BridgePoolInterface.sol/BridgePoolInterface.dbg.json +4 -0
  163. package/artifacts/contracts/insured-bridge/interfaces/BridgePoolInterface.sol/BridgePoolInterface.json +63 -0
  164. package/artifacts/contracts/insured-bridge/interfaces/MessengerInterface.sol/MessengerInterface.dbg.json +4 -0
  165. package/artifacts/contracts/insured-bridge/interfaces/MessengerInterface.sol/MessengerInterface.json +54 -0
  166. package/artifacts/contracts/insured-bridge/ovm/OVM_BridgeDepositBox.sol/OVM_BridgeDepositBox.dbg.json +4 -0
  167. package/artifacts/contracts/insured-bridge/ovm/OVM_BridgeDepositBox.sol/OVM_BridgeDepositBox.json +528 -0
  168. package/artifacts/contracts/insured-bridge/ovm/OVM_CrossDomainEnabled.sol/OVM_CrossDomainEnabled.dbg.json +4 -0
  169. package/artifacts/contracts/insured-bridge/ovm/OVM_CrossDomainEnabled.sol/OVM_CrossDomainEnabled.json +35 -0
  170. package/artifacts/contracts/insured-bridge/ovm/OVM_OETH_BridgeDepositBox.sol/OVM_OETH_BridgeDepositBox.dbg.json +4 -0
  171. package/artifacts/contracts/insured-bridge/ovm/OVM_OETH_BridgeDepositBox.sol/OVM_OETH_BridgeDepositBox.json +572 -0
  172. package/artifacts/contracts/insured-bridge/ovm/Optimism_Messenger.sol/Optimism_Messenger.dbg.json +4 -0
  173. package/artifacts/contracts/insured-bridge/ovm/Optimism_Messenger.sol/Optimism_Messenger.json +130 -0
  174. package/artifacts/contracts/insured-bridge/ovm/Optimism_Wrapper.sol/Optimism_Wrapper.dbg.json +4 -0
  175. package/artifacts/contracts/insured-bridge/ovm/Optimism_Wrapper.sol/Optimism_Wrapper.json +142 -0
  176. package/artifacts/contracts/insured-bridge/ovm/Optimism_Wrapper.sol/WETH9Like.dbg.json +4 -0
  177. package/artifacts/contracts/insured-bridge/ovm/Optimism_Wrapper.sol/WETH9Like.json +55 -0
  178. package/artifacts/contracts/insured-bridge/ovm/iOVM_CrossDomainMessenger.sol/iOVM_CrossDomainMessenger.dbg.json +4 -0
  179. package/artifacts/contracts/insured-bridge/ovm/iOVM_CrossDomainMessenger.sol/iOVM_CrossDomainMessenger.json +86 -0
  180. package/artifacts/contracts/insured-bridge/test/Arbitrum_InboxMock.sol/Arbitrum_BridgeMock.dbg.json +4 -0
  181. package/artifacts/contracts/insured-bridge/test/Arbitrum_InboxMock.sol/Arbitrum_BridgeMock.json +68 -0
  182. package/artifacts/contracts/insured-bridge/test/Arbitrum_InboxMock.sol/Arbitrum_InboxMock.dbg.json +4 -0
  183. package/artifacts/contracts/insured-bridge/test/Arbitrum_InboxMock.sol/Arbitrum_InboxMock.json +78 -0
  184. package/artifacts/contracts/insured-bridge/test/Arbitrum_InboxMock.sol/Arbitrum_OutboxMock.dbg.json +4 -0
  185. package/artifacts/contracts/insured-bridge/test/Arbitrum_InboxMock.sol/Arbitrum_OutboxMock.json +24 -0
  186. package/artifacts/contracts/insured-bridge/test/BridgeDepositBoxMock.sol/BridgeDepositBoxMock.dbg.json +4 -0
  187. package/artifacts/contracts/insured-bridge/test/BridgeDepositBoxMock.sol/BridgeDepositBoxMock.json +510 -0
  188. package/artifacts/contracts/insured-bridge/test/MessengerMock.sol/MessengerMock.dbg.json +4 -0
  189. package/artifacts/contracts/insured-bridge/test/MessengerMock.sol/MessengerMock.json +85 -0
  190. package/artifacts/contracts/insured-bridge/test/OVM_L1CrossDomainMessengerMock.sol/OVM_L1CrossDomainMessengerMock.dbg.json +4 -0
  191. package/artifacts/contracts/insured-bridge/test/OVM_L1CrossDomainMessengerMock.sol/OVM_L1CrossDomainMessengerMock.json +110 -0
  192. package/artifacts/contracts/oracle/implementation/Constants.sol/OptimisticOracleConstraints.dbg.json +4 -0
  193. package/artifacts/contracts/oracle/implementation/Constants.sol/OptimisticOracleConstraints.json +24 -0
  194. package/artifacts/contracts/oracle/implementation/Constants.sol/OracleInterfaces.dbg.json +4 -0
  195. package/artifacts/contracts/oracle/implementation/Constants.sol/OracleInterfaces.json +141 -0
  196. package/artifacts/contracts/oracle/interfaces/FinderInterface.sol/FinderInterface.dbg.json +4 -0
  197. package/artifacts/contracts/oracle/interfaces/FinderInterface.sol/FinderInterface.json +48 -0
  198. package/artifacts/contracts/oracle/interfaces/IdentifierWhitelistInterface.sol/IdentifierWhitelistInterface.dbg.json +4 -0
  199. package/artifacts/contracts/oracle/interfaces/IdentifierWhitelistInterface.sol/IdentifierWhitelistInterface.json +56 -0
  200. package/artifacts/contracts/oracle/interfaces/OptimisticOracleInterface.sol/OptimisticOracleInterface.dbg.json +4 -0
  201. package/artifacts/contracts/oracle/interfaces/OptimisticOracleInterface.sol/OptimisticOracleInterface.json +555 -0
  202. package/artifacts/contracts/oracle/interfaces/SkinnyOptimisticOracleInterface.sol/SkinnyOptimisticOracleInterface.dbg.json +4 -0
  203. package/artifacts/contracts/oracle/interfaces/SkinnyOptimisticOracleInterface.sol/SkinnyOptimisticOracleInterface.json +853 -0
  204. package/artifacts/contracts/oracle/interfaces/StoreInterface.sol/StoreInterface.dbg.json +4 -0
  205. package/artifacts/contracts/oracle/interfaces/StoreInterface.sol/StoreInterface.json +124 -0
  206. package/contracts/common/implementation/AncillaryData.sol +144 -0
  207. package/contracts/common/implementation/FixedPoint.sol +763 -0
  208. package/contracts/common/implementation/Lockable.sol +61 -0
  209. package/contracts/common/implementation/MultiCaller.sol +27 -0
  210. package/contracts/common/implementation/Testable.sol +52 -0
  211. package/contracts/common/implementation/Timer.sol +30 -0
  212. package/contracts/common/interfaces/AddressWhitelistInterface.sol +12 -0
  213. package/contracts/external/avm/AVM_CrossDomainEnabled.sol +43 -0
  214. package/contracts/external/avm/interfaces/ArbSys.sol +79 -0
  215. package/contracts/external/avm/interfaces/iArbitrum_Inbox.sol +28 -0
  216. package/contracts/external/avm/interfaces/iArbitrum_Outbox.sol +26 -0
  217. package/contracts/external/chainbridge/Bridge.sol +454 -0
  218. package/contracts/external/chainbridge/handlers/GenericHandler.sol +237 -0
  219. package/contracts/external/chainbridge/interfaces/IBridge.sol +20 -0
  220. package/contracts/external/chainbridge/interfaces/IDepositExecute.sol +29 -0
  221. package/contracts/external/chainbridge/interfaces/IERCHandler.sol +33 -0
  222. package/contracts/external/chainbridge/interfaces/IGenericHandler.sol +23 -0
  223. package/contracts/external/ovm/OVM_CrossDomainEnabled.sol +114 -0
  224. package/contracts/external/polygon/lib/Merkle.sol +36 -0
  225. package/contracts/external/polygon/lib/MerklePatriciaProof.sol +139 -0
  226. package/contracts/external/polygon/lib/RLPReader.sol +251 -0
  227. package/contracts/external/polygon/test/FxChildMock.sol +42 -0
  228. package/contracts/external/polygon/test/FxRootMock.sol +32 -0
  229. package/contracts/external/polygon/test/StateSyncMock.sol +26 -0
  230. package/contracts/external/polygon/tunnel/FxBaseChildTunnel.sol +80 -0
  231. package/contracts/external/polygon/tunnel/FxBaseRootTunnel.sol +185 -0
  232. package/contracts/insured-bridge/BridgeAdmin.sol +394 -0
  233. package/contracts/insured-bridge/BridgeDepositBox.sol +245 -0
  234. package/contracts/insured-bridge/BridgePool.sol +980 -0
  235. package/contracts/insured-bridge/avm/AVM_BridgeDepositBox.sol +144 -0
  236. package/contracts/insured-bridge/avm/Arbitrum_CrossDomainEnabled.sol +67 -0
  237. package/contracts/insured-bridge/avm/Arbitrum_Messenger.sol +72 -0
  238. package/contracts/insured-bridge/interfaces/BridgeAdminInterface.sol +44 -0
  239. package/contracts/insured-bridge/interfaces/BridgePoolInterface.sol +14 -0
  240. package/contracts/insured-bridge/interfaces/MessengerInterface.sol +18 -0
  241. package/contracts/insured-bridge/ovm/OVM_BridgeDepositBox.sol +135 -0
  242. package/contracts/insured-bridge/ovm/OVM_CrossDomainEnabled.sol +84 -0
  243. package/contracts/insured-bridge/ovm/OVM_OETH_BridgeDepositBox.sol +89 -0
  244. package/contracts/insured-bridge/ovm/Optimism_Messenger.sol +34 -0
  245. package/contracts/insured-bridge/ovm/Optimism_Wrapper.sol +59 -0
  246. package/contracts/insured-bridge/ovm/iOVM_CrossDomainMessenger.sol +41 -0
  247. package/contracts/insured-bridge/test/Arbitrum_InboxMock.sol +50 -0
  248. package/contracts/insured-bridge/test/BridgeDepositBoxMock.sol +113 -0
  249. package/contracts/insured-bridge/test/MessengerMock.sol +32 -0
  250. package/contracts/insured-bridge/test/OVM_L1CrossDomainMessengerMock.sol +16 -0
  251. package/contracts/oracle/implementation/Constants.sol +29 -0
  252. package/contracts/oracle/interfaces/FinderInterface.sol +22 -0
  253. package/contracts/oracle/interfaces/IdentifierWhitelistInterface.sol +28 -0
  254. package/contracts/oracle/interfaces/OptimisticOracleInterface.sol +263 -0
  255. package/contracts/oracle/interfaces/SkinnyOptimisticOracleInterface.sol +251 -0
  256. package/contracts/oracle/interfaces/StoreInterface.sol +46 -0
  257. package/package.json +60 -0
@@ -0,0 +1,394 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-only
2
+ pragma solidity ^0.8.0;
3
+
4
+ import "./interfaces//BridgePoolInterface.sol";
5
+ import "./interfaces/BridgeAdminInterface.sol";
6
+ import "./interfaces/MessengerInterface.sol";
7
+ import "../oracle/interfaces/IdentifierWhitelistInterface.sol";
8
+ import "../oracle/interfaces/FinderInterface.sol";
9
+ import "../oracle/implementation/Constants.sol";
10
+ import "../common/interfaces/AddressWhitelistInterface.sol";
11
+ import "../common/implementation/Lockable.sol";
12
+
13
+ import "@openzeppelin/contracts/access/Ownable.sol";
14
+
15
+ /**
16
+ * @notice Administrative contract deployed on L1 that has implicit references to all L2 DepositBoxes.
17
+ * @dev This contract is
18
+ * responsible for making global variables accessible to BridgePool contracts, which house passive liquidity and
19
+ * enable relaying of L2 deposits.
20
+ * @dev The owner of this contract can also call permissioned functions on registered L2 DepositBoxes.
21
+ */
22
+ contract BridgeAdmin is BridgeAdminInterface, Ownable, Lockable {
23
+ // Finder used to point to latest OptimisticOracle and other DVM contracts.
24
+ address public override finder;
25
+
26
+ // This contract can relay messages to any number of L2 DepositBoxes, one per L2 network, each identified by a
27
+ // unique network ID. To relay a message, both the deposit box contract address and a messenger contract address
28
+ // need to be stored. The messenger implementation differs for each L2 because L1 --> L2 messaging is non-standard.
29
+ // The deposit box contract originate the deposits that can be fulfilled by BridgePool contracts on L1.
30
+ mapping(uint256 => DepositUtilityContracts) private _depositContracts;
31
+
32
+ // L1 token addresses are mapped to their canonical token address on L2 and the BridgePool contract that houses
33
+ // relay liquidity for any deposits of the canonical L2 token.
34
+ mapping(address => L1TokenRelationships) private _whitelistedTokens;
35
+
36
+ // Set upon construction and can be reset by Owner.
37
+ uint32 public override optimisticOracleLiveness;
38
+ uint64 public override proposerBondPct;
39
+ bytes32 public override identifier;
40
+
41
+ // Add this modifier to methods that are expected to bridge messages to a L2 Deposit contract, which
42
+ // will cause unexpected behavior if the deposit or messenger helper contract isn't set and valid.
43
+ modifier canRelay(uint256 chainId) {
44
+ _validateDepositContracts(
45
+ _depositContracts[chainId].depositContract,
46
+ _depositContracts[chainId].messengerContract
47
+ );
48
+ _;
49
+ }
50
+
51
+ /**
52
+ * @notice Construct the Bridge Admin
53
+ * @param _finder DVM finder to find other UMA ecosystem contracts.
54
+ * @param _optimisticOracleLiveness Timeout that all bridging actions from L2->L1 must wait for a OptimisticOracle response.
55
+ * @param _proposerBondPct Percentage of the bridged amount that a relayer must put up as a bond.
56
+ * @param _identifier Identifier used when querying the OO for a cross bridge transfer action.
57
+ */
58
+ constructor(
59
+ address _finder,
60
+ uint32 _optimisticOracleLiveness,
61
+ uint64 _proposerBondPct,
62
+ bytes32 _identifier
63
+ ) {
64
+ finder = _finder;
65
+ require(address(_getCollateralWhitelist()) != address(0), "Invalid finder");
66
+ _setOptimisticOracleLiveness(_optimisticOracleLiveness);
67
+ _setProposerBondPct(_proposerBondPct);
68
+ _setIdentifier(_identifier);
69
+ }
70
+
71
+ /**************************************
72
+ * ADMIN FUNCTIONS *
73
+ **************************************/
74
+
75
+ /**
76
+ * @notice Sets a price identifier to use for relayed deposits. BridgePools reads the identifier from this contract.
77
+ * @dev Can only be called by the current owner.
78
+ * @param _identifier New identifier to set.
79
+ */
80
+ function setIdentifier(bytes32 _identifier) public onlyOwner nonReentrant() {
81
+ _setIdentifier(_identifier);
82
+ }
83
+
84
+ /**
85
+ * @notice Sets challenge period for relayed deposits. BridgePools will read this value from this contract.
86
+ * @dev Can only be called by the current owner.
87
+ * @param liveness New OptimisticOracle liveness period to set for relay price requests.
88
+ */
89
+ function setOptimisticOracleLiveness(uint32 liveness) public onlyOwner nonReentrant() {
90
+ _setOptimisticOracleLiveness(liveness);
91
+ }
92
+
93
+ /**
94
+ * @notice Sets challenge period for relayed deposits. BridgePools will read this value from this contract.
95
+ * @dev Can only be called by the current owner.
96
+ * @param _proposerBondPct New OptimisticOracle proposer bond % to set for relay price requests. 1e18 = 100%.
97
+ */
98
+ function setProposerBondPct(uint64 _proposerBondPct) public onlyOwner nonReentrant() {
99
+ _setProposerBondPct(_proposerBondPct);
100
+ }
101
+
102
+ /**
103
+ * @notice Associates the L2 deposit and L1 messenger helper addresses with an L2 network ID.
104
+ * @dev Only callable by the current owner.
105
+ * @param chainId L2 network ID to set addresses for.
106
+ * @param depositContract Address of L2 deposit contract.
107
+ * @param messengerContract Address of L1 helper contract that relays messages to L2.
108
+ */
109
+ function setDepositContract(
110
+ uint256 chainId,
111
+ address depositContract,
112
+ address messengerContract
113
+ ) public onlyOwner nonReentrant() {
114
+ _validateDepositContracts(depositContract, messengerContract);
115
+ _depositContracts[chainId].depositContract = depositContract;
116
+ _depositContracts[chainId].messengerContract = messengerContract;
117
+ emit SetDepositContracts(chainId, depositContract, messengerContract);
118
+ }
119
+
120
+ /**
121
+ * @notice Enables the current owner to transfer ownership of a set of owned bridge pools to a new owner.
122
+ * @dev Only callable by the current owner.
123
+ * @param bridgePools array of bridge pools to transfer ownership.
124
+ * @param newAdmin new admin contract to set ownership to.
125
+ */
126
+ function transferBridgePoolAdmin(address[] memory bridgePools, address newAdmin) public onlyOwner nonReentrant() {
127
+ for (uint8 i = 0; i < bridgePools.length; i++) {
128
+ BridgePoolInterface(bridgePools[i]).changeAdmin(newAdmin);
129
+ }
130
+ emit BridgePoolsAdminTransferred(bridgePools, newAdmin);
131
+ }
132
+
133
+ /**
134
+ * @notice Enable the current owner to change the decay rate at which LP shares accumulate fees for a particular
135
+ * BridgePool. The higher this value, the faster LP shares realize pending fees.
136
+ * @dev Only callable by the current owner.
137
+ * @param bridgePool Bridge Pool to change LP fee rate for.
138
+ * @param newLpFeeRate The new rate to set for the `bridgePool`.
139
+ */
140
+ function setLpFeeRatePerSecond(address bridgePool, uint64 newLpFeeRate) public onlyOwner nonReentrant() {
141
+ BridgePoolInterface(bridgePool).setLpFeeRatePerSecond(newLpFeeRate);
142
+ emit SetLpFeeRate(bridgePool, newLpFeeRate);
143
+ }
144
+
145
+ /**************************************************
146
+ * CROSSDOMAIN ADMIN FUNCTIONS *
147
+ **************************************************/
148
+
149
+ /**
150
+ * @notice Set new contract as the admin address in the L2 Deposit contract.
151
+ * @dev Only callable by the current owner.
152
+ * @dev msg.value must equal to l1CallValue.
153
+ * @param chainId L2 network ID where Deposit contract is deployed.
154
+ * @param admin New admin address to set on L2.
155
+ * @param l1CallValue Amount of ETH to include in msg.value. Used to pay for L2 fees, but its exact usage varies
156
+ * depending on the L2 network that this contract sends a message to.
157
+ * @param l2Gas Gas limit to set for relayed message on L2.
158
+ * @param l2GasPrice Gas price bid to set for relayed message on L2.
159
+ * @param maxSubmissionCost: Arbitrum only: fee deducted from L2 sender's balance to pay for L2 gas.
160
+ */
161
+ function setCrossDomainAdmin(
162
+ uint256 chainId,
163
+ address admin,
164
+ uint256 l1CallValue,
165
+ uint256 l2Gas,
166
+ uint256 l2GasPrice,
167
+ uint256 maxSubmissionCost
168
+ ) public payable onlyOwner canRelay(chainId) nonReentrant() {
169
+ require(admin != address(0), "Admin cannot be zero address");
170
+ _relayMessage(
171
+ _depositContracts[chainId].messengerContract,
172
+ l1CallValue,
173
+ _depositContracts[chainId].depositContract,
174
+ msg.sender,
175
+ l2Gas,
176
+ l2GasPrice,
177
+ maxSubmissionCost,
178
+ abi.encodeWithSignature("setCrossDomainAdmin(address)", admin)
179
+ );
180
+ emit SetCrossDomainAdmin(chainId, admin);
181
+ }
182
+
183
+ /**
184
+ * @notice Sets the minimum time between L2-->L1 token withdrawals in the L2 Deposit contract.
185
+ * @dev Only callable by the current owner.
186
+ * @dev msg.value must equal to l1CallValue.
187
+ * @param chainId L2 network ID where Deposit contract is deployed.
188
+ * @param minimumBridgingDelay the new minimum delay.
189
+ * @param l1CallValue Amount of ETH to include in msg.value. Used to pay for L2 fees, but its exact usage varies
190
+ * depending on the L2 network that this contract sends a message to.
191
+ * @param l2Gas Gas limit to set for relayed message on L2.
192
+ * @param l2GasPrice Gas price bid to set for relayed message on L2.
193
+ * @param maxSubmissionCost: Arbitrum only: fee deducted from L2 sender's balance to pay for L2 gas.
194
+ */
195
+ function setMinimumBridgingDelay(
196
+ uint256 chainId,
197
+ uint64 minimumBridgingDelay,
198
+ uint256 l1CallValue,
199
+ uint256 l2Gas,
200
+ uint256 l2GasPrice,
201
+ uint256 maxSubmissionCost
202
+ ) public payable onlyOwner canRelay(chainId) nonReentrant() {
203
+ _relayMessage(
204
+ _depositContracts[chainId].messengerContract,
205
+ l1CallValue,
206
+ _depositContracts[chainId].depositContract,
207
+ msg.sender,
208
+ l2Gas,
209
+ l2GasPrice,
210
+ maxSubmissionCost,
211
+ abi.encodeWithSignature("setMinimumBridgingDelay(uint64)", minimumBridgingDelay)
212
+ );
213
+ emit SetMinimumBridgingDelay(chainId, minimumBridgingDelay);
214
+ }
215
+
216
+ /**
217
+ * @notice Owner can pause/unpause L2 deposits for a tokens.
218
+ * @dev Only callable by Owner of this contract. Will set the same setting in the L2 Deposit contract via the cross
219
+ * domain messenger.
220
+ * @dev msg.value must equal to l1CallValue.
221
+ * @param chainId L2 network ID where Deposit contract is deployed.
222
+ * @param l1Token address of L1 Token to enable/disable deposits and relays for.
223
+ * @param depositsEnabled bool to set if the deposit box should accept/reject deposits.
224
+ * @param l1CallValue Amount of ETH to include in msg.value. Used to pay for L2 fees, but its exact usage varies
225
+ * depending on the L2 network that this contract sends a message to.
226
+ * @param l2Gas Gas limit to set for relayed message on L2.
227
+ * @param l2GasPrice Gas price bid to set for relayed message on L2.
228
+ * @param maxSubmissionCost: Arbitrum only: fee deducted from L2 sender's balance to pay for L2 gas.
229
+ */
230
+ function setEnableDepositsAndRelays(
231
+ uint256 chainId,
232
+ address l1Token,
233
+ bool depositsEnabled,
234
+ uint256 l1CallValue,
235
+ uint256 l2Gas,
236
+ uint256 l2GasPrice,
237
+ uint256 maxSubmissionCost
238
+ ) public payable onlyOwner canRelay(chainId) nonReentrant() {
239
+ // Disable relays on the BridgePool.
240
+ BridgePoolInterface(_whitelistedTokens[l1Token].bridgePool).setRelaysEnabled(depositsEnabled);
241
+
242
+ // Send cross-chain message to the associated bridgeDepositBox to disable deposits.
243
+ address l2Token = _whitelistedTokens[l1Token].l2Tokens[chainId];
244
+ _relayMessage(
245
+ _depositContracts[chainId].messengerContract,
246
+ l1CallValue,
247
+ _depositContracts[chainId].depositContract,
248
+ msg.sender,
249
+ l2Gas,
250
+ l2GasPrice,
251
+ maxSubmissionCost,
252
+ abi.encodeWithSignature("setEnableDeposits(address,bool)", l2Token, depositsEnabled)
253
+ );
254
+ emit DepositsEnabled(chainId, l2Token, depositsEnabled);
255
+ }
256
+
257
+ /**
258
+ * @notice Privileged account can associate a whitelisted token with its linked token address on L2. The linked L2
259
+ * token can thereafter be deposited into the Deposit contract on L2 and relayed via the BridgePool contract.
260
+ * @dev msg.value must equal to l1CallValue.
261
+ * @dev This method is also used to to update the address of the bridgePool within a BridgeDepositBox through the
262
+ * re-whitelisting of a previously whitelisted token to update the address of the bridge pool in the deposit box.
263
+ * @dev Only callable by Owner of this contract. Also initiates a cross-chain call to the L2 Deposit contract to
264
+ * whitelist the token mapping.
265
+ * @param chainId L2 network ID where Deposit contract is deployed.
266
+ * @param l1Token Address of L1 token that can be used to relay L2 token deposits.
267
+ * @param l2Token Address of L2 token whose deposits are fulfilled by `l1Token`.
268
+ * @param bridgePool Address of BridgePool which manages liquidity to fulfill L2-->L1 relays.
269
+ * @param l1CallValue Amount of ETH to include in msg.value. Used to pay for L2 fees, but its exact usage varies
270
+ * depending on the L2 network that this contract sends a message to.
271
+ * @param l2Gas Gas limit to set for relayed message on L2.
272
+ * @param l2GasPrice Gas price bid to set for relayed message on L2.
273
+ * @param maxSubmissionCost: Arbitrum only: fee deducted from L2 sender's balance to pay for L2 gas.
274
+ */
275
+ function whitelistToken(
276
+ uint256 chainId,
277
+ address l1Token,
278
+ address l2Token,
279
+ address bridgePool,
280
+ uint256 l1CallValue,
281
+ uint256 l2Gas,
282
+ uint256 l2GasPrice,
283
+ uint256 maxSubmissionCost
284
+ ) public payable onlyOwner canRelay(chainId) nonReentrant() {
285
+ require(bridgePool != address(0), "BridgePool cannot be zero address");
286
+ require(l2Token != address(0), "L2 token cannot be zero address");
287
+ require(_getCollateralWhitelist().isOnWhitelist(address(l1Token)), "L1Token token not whitelisted");
288
+
289
+ require(address(BridgePoolInterface(bridgePool).l1Token()) == l1Token, "Bridge pool has different L1 token");
290
+
291
+ // Braces to resolve Stack too deep compile error
292
+ {
293
+ L1TokenRelationships storage l1TokenRelationships = _whitelistedTokens[l1Token];
294
+ l1TokenRelationships.l2Tokens[chainId] = l2Token; // Set the L2Token at the index of the chainId.
295
+ l1TokenRelationships.bridgePool = bridgePool;
296
+ }
297
+
298
+ _relayMessage(
299
+ _depositContracts[chainId].messengerContract,
300
+ l1CallValue,
301
+ _depositContracts[chainId].depositContract,
302
+ msg.sender,
303
+ l2Gas,
304
+ l2GasPrice,
305
+ maxSubmissionCost,
306
+ abi.encodeWithSignature("whitelistToken(address,address,address)", l1Token, l2Token, bridgePool)
307
+ );
308
+ emit WhitelistToken(chainId, l1Token, l2Token, bridgePool);
309
+ }
310
+
311
+ /**************************************
312
+ * VIEW FUNCTIONS *
313
+ **************************************/
314
+ function depositContracts(uint256 chainId) external view override returns (DepositUtilityContracts memory) {
315
+ return _depositContracts[chainId];
316
+ }
317
+
318
+ function whitelistedTokens(address l1Token, uint256 chainId)
319
+ external
320
+ view
321
+ override
322
+ returns (address l2Token, address bridgePool)
323
+ {
324
+ return (_whitelistedTokens[l1Token].l2Tokens[chainId], _whitelistedTokens[l1Token].bridgePool);
325
+ }
326
+
327
+ /**************************************
328
+ * INTERNAL FUNCTIONS *
329
+ **************************************/
330
+
331
+ function _getIdentifierWhitelist() private view returns (IdentifierWhitelistInterface) {
332
+ return
333
+ IdentifierWhitelistInterface(
334
+ FinderInterface(finder).getImplementationAddress(OracleInterfaces.IdentifierWhitelist)
335
+ );
336
+ }
337
+
338
+ function _getCollateralWhitelist() private view returns (AddressWhitelistInterface) {
339
+ return
340
+ AddressWhitelistInterface(
341
+ FinderInterface(finder).getImplementationAddress(OracleInterfaces.CollateralWhitelist)
342
+ );
343
+ }
344
+
345
+ function _setIdentifier(bytes32 _identifier) private {
346
+ require(_getIdentifierWhitelist().isIdentifierSupported(_identifier), "Identifier not registered");
347
+ identifier = _identifier;
348
+ emit SetRelayIdentifier(identifier);
349
+ }
350
+
351
+ function _setOptimisticOracleLiveness(uint32 liveness) private {
352
+ // The following constraints are copied from a similar function in the OptimisticOracle contract:
353
+ // - https://github.com/UMAprotocol/protocol/blob/dd211c4e3825fe007d1161025a34e9901b26031a/packages/core/contracts/oracle/implementation/OptimisticOracle.sol#L621
354
+ require(liveness < 5200 weeks, "Liveness too large");
355
+ require(liveness > 0, "Liveness cannot be 0");
356
+ optimisticOracleLiveness = liveness;
357
+ emit SetOptimisticOracleLiveness(optimisticOracleLiveness);
358
+ }
359
+
360
+ function _setProposerBondPct(uint64 _proposerBondPct) private {
361
+ proposerBondPct = _proposerBondPct;
362
+ emit SetProposerBondPct(proposerBondPct);
363
+ }
364
+
365
+ function _validateDepositContracts(address depositContract, address messengerContract) private pure {
366
+ require(
367
+ (depositContract != address(0)) && (messengerContract != address(0)),
368
+ "Invalid deposit or messenger contract"
369
+ );
370
+ }
371
+
372
+ // Send msg.value == l1CallValue to Messenger, which can then use it in any way to execute cross domain message.
373
+ function _relayMessage(
374
+ address messengerContract,
375
+ uint256 l1CallValue,
376
+ address target,
377
+ address user,
378
+ uint256 l2Gas,
379
+ uint256 l2GasPrice,
380
+ uint256 maxSubmissionCost,
381
+ bytes memory message
382
+ ) private {
383
+ require(l1CallValue == msg.value, "Wrong number of ETH sent");
384
+ MessengerInterface(messengerContract).relayMessage{ value: l1CallValue }(
385
+ target,
386
+ user,
387
+ l1CallValue,
388
+ l2Gas,
389
+ l2GasPrice,
390
+ maxSubmissionCost,
391
+ message
392
+ );
393
+ }
394
+ }
@@ -0,0 +1,245 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-only
2
+ pragma solidity ^0.8.0;
3
+
4
+ import "../common/implementation/Testable.sol";
5
+ import "../common/implementation/Lockable.sol";
6
+
7
+ import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
8
+ import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
9
+
10
+ interface TokenLike {
11
+ function balanceOf(address guy) external returns (uint256 wad);
12
+ }
13
+
14
+ interface WETH9Like {
15
+ function deposit() external payable;
16
+
17
+ function withdraw(uint256 wad) external;
18
+ }
19
+
20
+ /**
21
+ * @title OVM Bridge Deposit Box.
22
+ * @notice Accepts deposits on Optimism L2 to relay to Ethereum L1 as part of the UMA insured bridge system.
23
+ */
24
+
25
+ abstract contract BridgeDepositBox is Testable, Lockable {
26
+ using SafeERC20 for IERC20;
27
+ /*************************************
28
+ * OVM DEPOSIT BOX DATA STRUCTURES *
29
+ *************************************/
30
+
31
+ // ChainID of the L2 this deposit box is deployed on.
32
+ uint256 public chainId;
33
+
34
+ // Address of WETH on L1. If the deposited token maps to this L1 token then wrap ETH to WETH on the users behalf.
35
+ address public l1Weth;
36
+
37
+ // Track the total number of deposits. Used as a unique identifier for bridged transfers.
38
+ uint256 public numberOfDeposits;
39
+
40
+ struct L2TokenRelationships {
41
+ address l1Token;
42
+ address l1BridgePool;
43
+ uint64 lastBridgeTime;
44
+ bool depositsEnabled;
45
+ }
46
+
47
+ // Mapping of whitelisted L2Token to L2TokenRelationships. Contains L1 TokenAddress and the last time this token
48
+ // type was bridged. Used to rate limit bridging actions to rate limit withdraws to L1.
49
+ mapping(address => L2TokenRelationships) public whitelistedTokens;
50
+
51
+ // Minimum time that must elapse between bridging actions for a given token. Used to rate limit bridging back to L1.
52
+ uint64 public minimumBridgingDelay;
53
+
54
+ /****************************************
55
+ * EVENTS *
56
+ ****************************************/
57
+
58
+ event SetMinimumBridgingDelay(uint64 newMinimumBridgingDelay);
59
+ event WhitelistToken(address l1Token, address l2Token, uint64 lastBridgeTime, address bridgePool);
60
+ event DepositsEnabled(address l2Token, bool depositsEnabled);
61
+ event FundsDeposited(
62
+ uint256 chainId,
63
+ uint256 depositId,
64
+ address l1Recipient,
65
+ address l2Sender,
66
+ address l1Token,
67
+ address l2Token,
68
+ uint256 amount,
69
+ uint64 slowRelayFeePct,
70
+ uint64 instantRelayFeePct,
71
+ uint64 quoteTimestamp
72
+ );
73
+ event TokensBridged(address indexed l2Token, uint256 numberOfTokensBridged, uint256 l1Gas, address indexed caller);
74
+
75
+ /****************************************
76
+ * MODIFIERS *
77
+ ****************************************/
78
+
79
+ modifier onlyIfDepositsEnabled(address l2Token) {
80
+ require(whitelistedTokens[l2Token].depositsEnabled, "Contract is disabled");
81
+ _;
82
+ }
83
+
84
+ /**
85
+ * @notice Construct the Bridge Deposit Box
86
+ * @param _minimumBridgingDelay Minimum seconds that must elapse between L2 -> L1 token transfer to prevent dos.
87
+ * @param _chainId Chain identifier for the Bridge deposit box.
88
+ * @param _l1Weth Address of Weth on L1. Used to inform if the deposit should wrap ETH to WETH, if deposit is ETH.
89
+ * @param timerAddress Timer used to synchronize contract time in testing. Set to 0x000... in production.
90
+ */
91
+ constructor(
92
+ uint64 _minimumBridgingDelay,
93
+ uint256 _chainId,
94
+ address _l1Weth,
95
+ address timerAddress
96
+ ) Testable(timerAddress) {
97
+ _setMinimumBridgingDelay(_minimumBridgingDelay);
98
+ chainId = _chainId;
99
+ l1Weth = _l1Weth;
100
+ }
101
+
102
+ /**************************************
103
+ * ADMIN FUNCTIONS *
104
+ **************************************/
105
+
106
+ /**
107
+ * @notice Changes the minimum time in seconds that must elapse between withdraws from L2 -> L1.
108
+ * @param newMinimumBridgingDelay the new minimum delay.
109
+ */
110
+ function _setMinimumBridgingDelay(uint64 newMinimumBridgingDelay) internal {
111
+ minimumBridgingDelay = newMinimumBridgingDelay;
112
+ emit SetMinimumBridgingDelay(minimumBridgingDelay);
113
+ }
114
+
115
+ /**
116
+ * @notice Enables L1 owner to whitelist a L1 Token <-> L2 Token pair for bridging.
117
+ * @param l1Token Address of the canonical L1 token. This is the token users will receive on Ethereum.
118
+ * @param l2Token Address of the L2 token representation. This is the token users would deposit on optimism.
119
+ * @param l1BridgePool Address of the L1 withdrawal pool linked to this L2+L1 token.
120
+ */
121
+ function _whitelistToken(
122
+ address l1Token,
123
+ address l2Token,
124
+ address l1BridgePool
125
+ ) internal {
126
+ whitelistedTokens[l2Token] = L2TokenRelationships({
127
+ l1Token: l1Token,
128
+ l1BridgePool: l1BridgePool,
129
+ lastBridgeTime: uint64(getCurrentTime()),
130
+ depositsEnabled: true
131
+ });
132
+
133
+ emit WhitelistToken(l1Token, l2Token, uint64(getCurrentTime()), l1BridgePool);
134
+ }
135
+
136
+ /**
137
+ * @notice L1 owner can enable/disable deposits for a whitelisted token.
138
+ * @param l2Token address of L2 token to enable/disable deposits for.
139
+ * @param depositsEnabled bool to set if the deposit box should accept/reject deposits.
140
+ */
141
+ function _setEnableDeposits(address l2Token, bool depositsEnabled) internal {
142
+ whitelistedTokens[l2Token].depositsEnabled = depositsEnabled;
143
+ emit DepositsEnabled(l2Token, depositsEnabled);
144
+ }
145
+
146
+ function bridgeTokens(address l2Token, uint32 l2Gas) public virtual;
147
+
148
+ /**************************************
149
+ * DEPOSITOR FUNCTIONS *
150
+ **************************************/
151
+
152
+ /**
153
+ * @notice Called by L2 user to bridge funds between L2 and L1.
154
+ * @dev Emits the `FundsDeposited` event which relayers listen for as part of the bridging action.
155
+ * @dev The caller must first approve this contract to spend `amount` of `l2Token`.
156
+ * @param l1Recipient L1 address that should receive the tokens.
157
+ * @param l2Token L2 token to deposit.
158
+ * @param amount How many L2 tokens should be deposited.
159
+ * @param slowRelayFeePct Max fraction of `amount` that the depositor is willing to pay as a slow relay fee.
160
+ * @param instantRelayFeePct Fraction of `amount` that the depositor is willing to pay as an instant relay fee.
161
+ * @param quoteTimestamp Timestamp, at which the depositor will be quoted for L1 liquidity. This enables the
162
+ * depositor to know the L1 fees before submitting their deposit. Must be within 10 mins of the current time.
163
+ */
164
+ function deposit(
165
+ address l1Recipient,
166
+ address l2Token,
167
+ uint256 amount,
168
+ uint64 slowRelayFeePct,
169
+ uint64 instantRelayFeePct,
170
+ uint64 quoteTimestamp
171
+ ) public payable onlyIfDepositsEnabled(l2Token) nonReentrant() {
172
+ require(isWhitelistToken(l2Token), "deposit token not whitelisted");
173
+ // We limit the sum of slow and instant relay fees to 50% to prevent the user spending all their funds on fees.
174
+ // The realizedLPFeePct on L1 is limited to 50% so the total spent on fees does not ever exceed 100%.
175
+ require(slowRelayFeePct <= 0.25e18, "slowRelayFeePct must be <= 25%");
176
+ require(instantRelayFeePct <= 0.25e18, "instantRelayFeePct must be <= 25%");
177
+
178
+ // Note that the OVM's notion of `block.timestamp` is different to the main ethereum L1 EVM. The OVM timestamp
179
+ // corresponds to the L1 timestamp of the last confirmed L1 ⇒ L2 transaction. The quoteTime must be within 10
180
+ // mins of the current time to allow for this variance.
181
+ // Note also that `quoteTimestamp` cannot be less than 10 minutes otherwise the following arithmetic can result
182
+ // in underflow. This isn't a problem as the deposit will revert, but the error might be unexpected for clients.
183
+ // Consider requiring `quoteTimestamp >= 10 minutes`.
184
+ require(
185
+ getCurrentTime() >= quoteTimestamp - 10 minutes && getCurrentTime() <= quoteTimestamp + 10 minutes,
186
+ "deposit mined after deadline"
187
+ );
188
+ // If the address of the L1 token is the l1Weth and there is a msg.value with the transaction then the user
189
+ // is sending ETH. In this case, the ETH should be deposited to WETH, which is then bridged to L1.
190
+ if (whitelistedTokens[l2Token].l1Token == l1Weth && msg.value > 0) {
191
+ require(msg.value == amount, "msg.value must match amount");
192
+ WETH9Like(address(l2Token)).deposit{ value: msg.value }();
193
+ }
194
+ // Else, it is a normal ERC20. In this case pull the token from the users wallet as per normal.
195
+ // Note: this includes the case where the L2 user has WETH (already wrapped ETH) and wants to bridge them. In
196
+ // this case the msg.value will be set to 0, indicating a "normal" ERC20 bridging action.
197
+ else IERC20(l2Token).safeTransferFrom(msg.sender, address(this), amount);
198
+
199
+ emit FundsDeposited(
200
+ chainId,
201
+ numberOfDeposits, // depositId: the current number of deposits acts as a deposit ID (nonce).
202
+ l1Recipient,
203
+ msg.sender,
204
+ whitelistedTokens[l2Token].l1Token,
205
+ l2Token,
206
+ amount,
207
+ slowRelayFeePct,
208
+ instantRelayFeePct,
209
+ quoteTimestamp
210
+ );
211
+
212
+ numberOfDeposits += 1;
213
+ }
214
+
215
+ /**************************************
216
+ * VIEW FUNCTIONS *
217
+ **************************************/
218
+
219
+ /**
220
+ * @notice Checks if a given L2 token is whitelisted.
221
+ * @dev Check the whitelisted token's `lastBridgeTime` parameter since its guaranteed to be != 0 once
222
+ * the token has been whitelisted.
223
+ * @param l2Token L2 token to check against the whitelist.
224
+ * @return true if token is whitelised.
225
+ */
226
+ function isWhitelistToken(address l2Token) public view returns (bool) {
227
+ return whitelistedTokens[l2Token].lastBridgeTime != 0;
228
+ }
229
+
230
+ function _hasEnoughTimeElapsedToBridge(address l2Token) internal view returns (bool) {
231
+ return getCurrentTime() > whitelistedTokens[l2Token].lastBridgeTime + minimumBridgingDelay;
232
+ }
233
+
234
+ /**
235
+ * @notice Designed to be called by implementing contract in `bridgeTokens` method which sends this contract's
236
+ * balance of tokens from L2 to L1 via the canonical token bridge. Tokens that can be bridged are whitelisted
237
+ * and have had enough time elapsed since the latest bridge (or the time at which at was whitelisted).
238
+ * @dev This function is also public for caller convenience.
239
+ * @param l2Token L2 token to check bridging status.
240
+ * @return true if token is whitelised and enough time has elapsed since the previous bridge.
241
+ */
242
+ function canBridge(address l2Token) public view returns (bool) {
243
+ return isWhitelistToken(l2Token) && _hasEnoughTimeElapsedToBridge(l2Token);
244
+ }
245
+ }