@keep-network/tbtc-v2 1.6.0-dev.15 → 1.6.0-dev.16

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 (147) hide show
  1. package/artifacts/BLS.json +1 -1
  2. package/artifacts/Bank.json +3 -3
  3. package/artifacts/BeaconAuthorization.json +1 -1
  4. package/artifacts/BeaconDkg.json +1 -1
  5. package/artifacts/BeaconDkgValidator.json +1 -1
  6. package/artifacts/BeaconInactivity.json +1 -1
  7. package/artifacts/BeaconSortitionPool.json +3 -3
  8. package/artifacts/Bridge.json +5 -5
  9. package/artifacts/BridgeGovernance.json +2 -2
  10. package/artifacts/BridgeGovernanceParameters.json +2 -2
  11. package/artifacts/Deposit.json +2 -2
  12. package/artifacts/DepositSweep.json +2 -2
  13. package/artifacts/DonationVault.json +3 -3
  14. package/artifacts/EcdsaDkgValidator.json +1 -1
  15. package/artifacts/EcdsaInactivity.json +1 -1
  16. package/artifacts/EcdsaSortitionPool.json +3 -3
  17. package/artifacts/Fraud.json +2 -2
  18. package/artifacts/LightRelay.json +18 -18
  19. package/artifacts/LightRelayMaintainerProxy.json +8 -8
  20. package/artifacts/MaintainerProxy.json +19 -19
  21. package/artifacts/MovingFunds.json +2 -2
  22. package/artifacts/NuCypherToken.json +2 -2
  23. package/artifacts/RandomBeacon.json +2 -2
  24. package/artifacts/RandomBeaconChaosnet.json +2 -2
  25. package/artifacts/RandomBeaconGovernance.json +2 -2
  26. package/artifacts/Redemption.json +2 -2
  27. package/artifacts/ReimbursementPool.json +2 -2
  28. package/artifacts/T.json +2 -2
  29. package/artifacts/TBTC.json +3 -3
  30. package/artifacts/TBTCToken.json +3 -3
  31. package/artifacts/TBTCVault.json +23 -23
  32. package/artifacts/TokenStaking.json +1 -1
  33. package/artifacts/TokenholderGovernor.json +9 -9
  34. package/artifacts/TokenholderTimelock.json +8 -8
  35. package/artifacts/VendingMachine.json +3 -3
  36. package/artifacts/VendingMachineNuCypher.json +1 -1
  37. package/artifacts/VendingMachineV2.json +3 -3
  38. package/artifacts/VendingMachineV3.json +3 -3
  39. package/artifacts/WalletProposalValidator.json +2 -2
  40. package/artifacts/WalletRegistry.json +5 -5
  41. package/artifacts/WalletRegistryGovernance.json +2 -2
  42. package/artifacts/Wallets.json +2 -2
  43. package/artifacts/solcInputs/{1788e81ec23cfa014c2c13441f296723.json → 8bdb4098420884547fe701093440e1b8.json} +12 -0
  44. package/build/contracts/GovernanceUtils.sol/GovernanceUtils.dbg.json +1 -1
  45. package/build/contracts/bank/Bank.sol/Bank.dbg.json +1 -1
  46. package/build/contracts/bank/IReceiveBalanceApproval.sol/IReceiveBalanceApproval.dbg.json +1 -1
  47. package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.dbg.json +1 -1
  48. package/build/contracts/bridge/Bridge.sol/Bridge.dbg.json +1 -1
  49. package/build/contracts/bridge/BridgeGovernanceParameters.sol/BridgeGovernanceParameters.dbg.json +1 -1
  50. package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +1 -1
  51. package/build/contracts/bridge/Deposit.sol/Deposit.dbg.json +1 -1
  52. package/build/contracts/bridge/DepositSweep.sol/DepositSweep.dbg.json +1 -1
  53. package/build/contracts/bridge/EcdsaLib.sol/EcdsaLib.dbg.json +1 -1
  54. package/build/contracts/bridge/Fraud.sol/Fraud.dbg.json +1 -1
  55. package/build/contracts/bridge/Heartbeat.sol/Heartbeat.dbg.json +1 -1
  56. package/build/contracts/bridge/IRelay.sol/IRelay.dbg.json +1 -1
  57. package/build/contracts/bridge/MovingFunds.sol/MovingFunds.dbg.json +1 -1
  58. package/build/contracts/bridge/Redemption.sol/OutboundTx.dbg.json +1 -1
  59. package/build/contracts/bridge/Redemption.sol/Redemption.dbg.json +1 -1
  60. package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
  61. package/build/contracts/bridge/VendingMachineV2.sol/VendingMachineV2.dbg.json +1 -1
  62. package/build/contracts/bridge/VendingMachineV3.sol/VendingMachineV3.dbg.json +1 -1
  63. package/build/contracts/bridge/WalletProposalValidator.sol/WalletProposalValidator.dbg.json +1 -1
  64. package/build/contracts/bridge/Wallets.sol/Wallets.dbg.json +1 -1
  65. package/build/contracts/integrator/AbstractTBTCDepositor.sol/AbstractTBTCDepositor.dbg.json +4 -0
  66. package/build/contracts/integrator/AbstractTBTCDepositor.sol/AbstractTBTCDepositor.json +113 -0
  67. package/build/contracts/integrator/IBridge.sol/IBridge.dbg.json +4 -0
  68. package/build/contracts/integrator/IBridge.sol/IBridge.json +172 -0
  69. package/build/contracts/integrator/IBridge.sol/IBridgeTypes.dbg.json +4 -0
  70. package/build/contracts/integrator/IBridge.sol/IBridgeTypes.json +10 -0
  71. package/build/contracts/integrator/ITBTCVault.sol/ITBTCVault.dbg.json +4 -0
  72. package/build/contracts/integrator/ITBTCVault.sol/ITBTCVault.json +48 -0
  73. package/build/contracts/l2/L2TBTC.sol/L2TBTC.dbg.json +1 -1
  74. package/build/contracts/l2/L2WormholeGateway.sol/IWormholeTokenBridge.dbg.json +1 -1
  75. package/build/contracts/l2/L2WormholeGateway.sol/L2WormholeGateway.dbg.json +1 -1
  76. package/build/contracts/maintainer/MaintainerProxy.sol/MaintainerProxy.dbg.json +1 -1
  77. package/build/contracts/relay/LightRelay.sol/ILightRelay.dbg.json +1 -1
  78. package/build/contracts/relay/LightRelay.sol/LightRelay.dbg.json +1 -1
  79. package/build/contracts/relay/LightRelay.sol/RelayUtils.dbg.json +1 -1
  80. package/build/contracts/relay/LightRelayMaintainerProxy.sol/LightRelayMaintainerProxy.dbg.json +1 -1
  81. package/build/contracts/token/TBTC.sol/TBTC.dbg.json +1 -1
  82. package/build/contracts/vault/DonationVault.sol/DonationVault.dbg.json +1 -1
  83. package/build/contracts/vault/IVault.sol/IVault.dbg.json +1 -1
  84. package/build/contracts/vault/TBTCOptimisticMinting.sol/TBTCOptimisticMinting.dbg.json +1 -1
  85. package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +1 -1
  86. package/contracts/integrator/AbstractTBTCDepositor.sol +308 -0
  87. package/contracts/integrator/IBridge.sol +80 -0
  88. package/contracts/integrator/ITBTCVault.sol +28 -0
  89. package/export/artifacts/@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol/BTCUtils.json +20 -20
  90. package/export/artifacts/@keep-network/ecdsa/contracts/EcdsaDkgValidator.sol/EcdsaDkgValidator.json +1986 -1986
  91. package/export/artifacts/@keep-network/ecdsa/contracts/libraries/EcdsaDkg.sol/EcdsaDkg.json +20 -20
  92. package/export/artifacts/@keep-network/ecdsa/contracts/libraries/EcdsaInactivity.sol/EcdsaInactivity.json +1836 -1836
  93. package/export/artifacts/@keep-network/random-beacon/contracts/ReimbursementPool.sol/ReimbursementPool.json +545 -545
  94. package/export/artifacts/@keep-network/sortition-pools/contracts/Chaosnet.sol/Chaosnet.json +506 -506
  95. package/export/artifacts/@keep-network/sortition-pools/contracts/Rewards.sol/Rewards.json +23 -23
  96. package/export/artifacts/@keep-network/sortition-pools/contracts/SortitionPool.sol/SortitionPool.json +2456 -2456
  97. package/export/artifacts/@keep-network/sortition-pools/contracts/SortitionTree.sol/SortitionTree.json +465 -465
  98. package/export/artifacts/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol/ERC1967Proxy.json +568 -568
  99. package/export/artifacts/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.json +603 -603
  100. package/export/artifacts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json +1001 -1001
  101. package/export/artifacts/@openzeppelin/contracts/token/ERC721/ERC721.sol/ERC721.json +1877 -1877
  102. package/export/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol/ERC20Upgradeable.json +654 -654
  103. package/export/artifacts/@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol/ERC20WithPermit.json +2534 -2534
  104. package/export/artifacts/@thesis/solidity-contracts/contracts/token/MisfundRecovery.sol/MisfundRecovery.json +736 -736
  105. package/export/artifacts/contracts/bank/Bank.sol/Bank.json +1872 -1872
  106. package/export/artifacts/contracts/bridge/Bridge.sol/Bridge.json +7234 -7234
  107. package/export/artifacts/contracts/bridge/VendingMachine.sol/VendingMachine.json +1257 -1257
  108. package/export/artifacts/contracts/bridge/VendingMachineV2.sol/VendingMachineV2.json +972 -972
  109. package/export/artifacts/contracts/bridge/VendingMachineV3.sol/VendingMachineV3.json +1122 -1122
  110. package/export/artifacts/contracts/bridge/WalletProposalValidator.sol/WalletProposalValidator.json +5028 -5028
  111. package/export/artifacts/contracts/l2/L2TBTC.sol/L2TBTC.json +3002 -3002
  112. package/export/artifacts/contracts/l2/L2WormholeGateway.sol/L2WormholeGateway.json +2490 -2490
  113. package/export/artifacts/contracts/maintainer/MaintainerProxy.sol/MaintainerProxy.json +2456 -2456
  114. package/export/artifacts/contracts/relay/LightRelay.sol/LightRelay.json +1922 -1922
  115. package/export/artifacts/contracts/relay/LightRelayMaintainerProxy.sol/LightRelayMaintainerProxy.json +1013 -1013
  116. package/export/artifacts/contracts/test/BankStub.sol/BankStub.json +1874 -1874
  117. package/export/artifacts/contracts/test/BridgeStub.sol/BridgeStub.json +8259 -8259
  118. package/export/artifacts/contracts/test/HeartbeatStub.sol/HeartbeatStub.json +130 -130
  119. package/export/artifacts/contracts/test/LightRelayStub.sol/LightRelayStub.json +2047 -2047
  120. package/export/artifacts/contracts/test/ReceiveApprovalStub.sol/ReceiveApprovalStub.json +354 -354
  121. package/export/artifacts/contracts/test/SepoliaLightRelay.sol/SepoliaLightRelay.json +1924 -1924
  122. package/export/artifacts/contracts/test/SystemTestRelay.sol/SystemTestRelay.json +568 -568
  123. package/export/artifacts/contracts/test/TestBitcoinTx.sol/TestBitcoinTx.json +1249 -1249
  124. package/export/artifacts/contracts/test/TestERC20.sol/TestERC20.json +2291 -2291
  125. package/export/artifacts/contracts/test/TestERC721.sol/TestERC721.json +1698 -1698
  126. package/export/artifacts/contracts/test/TestEcdsaLib.sol/TestEcdsaLib.json +189 -189
  127. package/export/artifacts/contracts/test/TestTBTCDepositor.sol/MockBridge.json +4871 -0
  128. package/export/artifacts/contracts/test/TestTBTCDepositor.sol/MockTBTCVault.json +1523 -0
  129. package/export/artifacts/contracts/test/TestTBTCDepositor.sol/TestTBTCDepositor.json +11101 -0
  130. package/export/artifacts/contracts/test/WormholeBridgeStub.sol/WormholeBridgeStub.json +1447 -1447
  131. package/export/artifacts/contracts/token/TBTC.sol/TBTC.json +2847 -2847
  132. package/export/artifacts/contracts/vault/DonationVault.sol/DonationVault.json +858 -858
  133. package/export/artifacts/contracts/vault/TBTCVault.sol/TBTCVault.json +3489 -3489
  134. package/export/typechain/AbstractTBTCDepositor.js +2 -0
  135. package/export/typechain/IBridge.js +2 -0
  136. package/export/typechain/ITBTCVault.js +2 -0
  137. package/export/typechain/MockBridge.js +2 -0
  138. package/export/typechain/MockTBTCVault.js +2 -0
  139. package/export/typechain/TestTBTCDepositor.js +2 -0
  140. package/export/typechain/factories/AbstractTBTCDepositor__factory.js +124 -0
  141. package/export/typechain/factories/IBridge__factory.js +183 -0
  142. package/export/typechain/factories/ITBTCVault__factory.js +59 -0
  143. package/export/typechain/factories/MockBridge__factory.js +290 -0
  144. package/export/typechain/factories/MockTBTCVault__factory.js +166 -0
  145. package/export/typechain/factories/TestTBTCDepositor__factory.js +356 -0
  146. package/export/typechain/index.js +14 -1
  147. package/package.json +1 -1
@@ -313,6 +313,15 @@
313
313
  "contracts/hardhat-dependency-compiler/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol": {
314
314
  "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol';\n"
315
315
  },
316
+ "contracts/integrator/AbstractTBTCDepositor.sol": {
317
+ "content": "// SPDX-License-Identifier: GPL-3.0-only\n\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n\npragma solidity ^0.8.0;\n\nimport {BTCUtils} from \"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\";\n\nimport \"./IBridge.sol\";\nimport \"./ITBTCVault.sol\";\n\n/// @title Abstract AbstractTBTCDepositor contract.\n/// @notice This abstract contract is meant to facilitate integration of protocols\n/// aiming to use tBTC as an underlying Bitcoin bridge.\n///\n/// Such an integrator is supposed to:\n/// - Create a child contract inheriting from this abstract contract\n/// - Call the `__AbstractTBTCDepositor_initialize` initializer function\n/// - Use the `_initializeDeposit` and `_finalizeDeposit` as part of their\n/// business logic in order to initialize and finalize deposits.\n///\n/// @dev Example usage:\n/// ```\n/// // Example upgradeable integrator contract.\n/// contract ExampleTBTCIntegrator is AbstractTBTCDepositor, Initializable {\n/// /// @custom:oz-upgrades-unsafe-allow constructor\n/// constructor() {\n/// // Prevents the contract from being initialized again.\n/// _disableInitializers();\n/// }\n///\n/// function initialize(\n/// address _bridge,\n/// address _tbtcVault\n/// ) external initializer {\n/// __AbstractTBTCDepositor_initialize(_bridge, _tbtcVault);\n/// }\n///\n/// function startProcess(\n/// IBridgeTypes.BitcoinTxInfo calldata fundingTx,\n/// IBridgeTypes.DepositRevealInfo calldata reveal\n/// ) external {\n/// // Embed necessary context as extra data.\n/// bytes32 extraData = ...;\n///\n/// uint256 depositKey = _initializeDeposit(\n/// fundingTx,\n/// reveal,\n/// extraData\n/// );\n///\n/// // Use the depositKey to track the process.\n/// }\n///\n/// function finalizeProcess(uint256 depositKey) external {\n/// (uint256 tbtcAmount, bytes32 extraData) = _finalizeDeposit(depositKey);\n///\n/// // Do something with the minted TBTC using context\n/// // embedded in the extraData.\n/// }\n/// }\nabstract contract AbstractTBTCDepositor {\n using BTCUtils for bytes;\n\n /// @notice Multiplier to convert satoshi to TBTC token units.\n uint256 public constant SATOSHI_MULTIPLIER = 10**10;\n\n /// @notice Bridge contract address.\n IBridge public bridge;\n /// @notice TBTCVault contract address.\n ITBTCVault public tbtcVault;\n /// @notice Mapping holding information about pending deposits that have\n /// been initialized but not finalized yet. If the deposit is not\n /// in this mapping it means it has already been finalized or it\n /// has not been initialized yet.\n mapping(uint256 => bool) public pendingDeposits;\n\n // Reserved storage space that allows adding more variables without affecting\n // the storage layout of the child contracts. The convention from OpenZeppelin\n // suggests the storage space should add up to 50 slots. If more variables are\n // added in the upcoming versions one need to reduce the array size accordingly.\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n // slither-disable-next-line unused-state\n uint256[47] private __gap;\n\n event DepositInitialized(uint256 indexed depositKey, uint32 initializedAt);\n\n event DepositFinalized(\n uint256 indexed depositKey,\n uint256 tbtcAmount,\n uint32 finalizedAt\n );\n\n /// @notice Initializes the contract. MUST BE CALLED from the child\n /// contract initializer.\n // slither-disable-next-line dead-code\n function __AbstractTBTCDepositor_initialize(\n address _bridge,\n address _tbtcVault\n ) internal {\n require(\n address(bridge) == address(0) && address(tbtcVault) == address(0),\n \"AbstractTBTCDepositor already initialized\"\n );\n\n require(_bridge != address(0), \"Bridge address cannot be zero\");\n require(_tbtcVault != address(0), \"TBTCVault address cannot be zero\");\n\n bridge = IBridge(_bridge);\n tbtcVault = ITBTCVault(_tbtcVault);\n }\n\n /// @notice Initializes a deposit by revealing it to the Bridge.\n /// @param fundingTx Bitcoin funding transaction data, see `IBridgeTypes.BitcoinTxInfo`.\n /// @param reveal Deposit reveal data, see `IBridgeTypes.DepositRevealInfo` struct.\n /// @param extraData 32-byte deposit extra data.\n /// @return depositKey Deposit key computed as\n /// `keccak256(fundingTxHash | reveal.fundingOutputIndex)`. This\n /// key can be used to refer to the deposit in the Bridge and\n /// TBTCVault contracts.\n /// @dev Requirements:\n /// - The revealed vault address must match the TBTCVault address,\n /// - All requirements from {Bridge#revealDepositWithExtraData}\n /// function must be met.\n // slither-disable-next-line dead-code\n function _initializeDeposit(\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\n IBridgeTypes.DepositRevealInfo calldata reveal,\n bytes32 extraData\n ) internal returns (uint256) {\n require(reveal.vault == address(tbtcVault), \"Vault address mismatch\");\n\n uint256 depositKey = _calculateDepositKey(\n _calculateBitcoinTxHash(fundingTx),\n reveal.fundingOutputIndex\n );\n\n pendingDeposits[depositKey] = true;\n\n emit DepositInitialized(\n depositKey,\n /* solhint-disable-next-line not-rely-on-time */\n uint32(block.timestamp)\n );\n\n // The Bridge does not allow to reveal the same deposit twice and\n // revealed deposits stay there forever. The transaction will revert\n // if the deposit has already been revealed so, there is no need to do\n // an explicit check here.\n bridge.revealDepositWithExtraData(fundingTx, reveal, extraData);\n\n return depositKey;\n }\n\n /// @notice Finalizes a deposit by calculating the amount of TBTC minted\n /// for the deposit\n /// @param depositKey Deposit key identifying the deposit.\n /// @return tbtcAmount Approximate amount of TBTC minted for the deposit.\n /// @return extraData 32-byte deposit extra data.\n /// @dev Requirements:\n /// - The deposit must be initialized but not finalized\n /// (in the context of this contract) yet.\n /// - The deposit must be finalized on the Bridge side. That means the\n /// deposit must be either swept or optimistically minted.\n /// @dev IMPORTANT NOTE: The tbtcAmount returned by this function is an\n /// approximation. See documentation of the `calculateTbtcAmount`\n /// responsible for calculating this value for more details.\n // slither-disable-next-line dead-code\n function _finalizeDeposit(uint256 depositKey)\n internal\n returns (uint256 tbtcAmount, bytes32 extraData)\n {\n require(pendingDeposits[depositKey], \"Deposit not initialized\");\n\n IBridgeTypes.DepositRequest memory deposit = bridge.deposits(\n depositKey\n );\n (, uint64 finalizedAt) = tbtcVault.optimisticMintingRequests(\n depositKey\n );\n\n require(\n deposit.sweptAt != 0 || finalizedAt != 0,\n \"Deposit not finalized by the bridge\"\n );\n\n // We can safely delete the deposit from the pending deposits mapping.\n // This deposit cannot be initialized again because the bridge does not\n // allow to reveal the same deposit twice. Deleting the deposit from\n // the mapping will also prevent the finalizeDeposit function from\n // being called again for the same deposit.\n // slither-disable-next-line reentrancy-no-eth\n delete pendingDeposits[depositKey];\n\n tbtcAmount = _calculateTbtcAmount(deposit.amount, deposit.treasuryFee);\n\n // slither-disable-next-line reentrancy-events\n emit DepositFinalized(\n depositKey,\n tbtcAmount,\n /* solhint-disable-next-line not-rely-on-time */\n uint32(block.timestamp)\n );\n\n extraData = deposit.extraData;\n }\n\n /// @notice Calculates the amount of TBTC minted for the deposit.\n /// @param depositAmountSat Deposit amount in satoshi (1e8 precision).\n /// This is the actual amount deposited by the deposit creator, i.e.\n /// the gross amount the Bridge's fees are cut from.\n /// @param depositTreasuryFeeSat Deposit treasury fee in satoshi (1e8 precision).\n /// This is an accurate value of the treasury fee that was actually\n /// cut upon minting.\n /// @return tbtcAmount Approximate amount of TBTC minted for the deposit.\n /// @dev IMPORTANT NOTE: The tbtcAmount returned by this function may\n /// not correspond to the actual amount of TBTC minted for the deposit.\n /// Although the treasury fee cut upon minting is known precisely,\n /// this is not the case for the optimistic minting fee and the Bitcoin\n /// transaction fee. To overcome that problem, this function just takes\n /// the current maximum allowed values of both fees, at the moment of deposit\n /// finalization. For the great majority of the deposits, such an\n /// algorithm will return a tbtcAmount slightly lesser than the\n /// actual amount of TBTC minted for the deposit. This will cause\n /// some TBTC to be left in the contract and ensure there is enough\n /// liquidity to finalize the deposit. However, in some rare cases,\n /// where the actual values of those fees change between the deposit\n /// minting and finalization, the tbtcAmount returned by this function\n /// may be greater than the actual amount of TBTC minted for the deposit.\n /// If this happens and the reserve coming from previous deposits\n /// leftovers does not provide enough liquidity, the deposit will have\n /// to wait for finalization until the reserve is refilled by subsequent\n /// deposits or a manual top-up. The integrator is responsible for\n /// handling such cases.\n // slither-disable-next-line dead-code\n function _calculateTbtcAmount(\n uint64 depositAmountSat,\n uint64 depositTreasuryFeeSat\n ) internal view virtual returns (uint256) {\n // Both deposit amount and treasury fee are in the 1e8 satoshi precision.\n // We need to convert them to the 1e18 TBTC precision.\n uint256 amountSubTreasury = (depositAmountSat - depositTreasuryFeeSat) *\n SATOSHI_MULTIPLIER;\n\n uint256 omFeeDivisor = tbtcVault.optimisticMintingFeeDivisor();\n uint256 omFee = omFeeDivisor > 0\n ? (amountSubTreasury / omFeeDivisor)\n : 0;\n\n // The deposit transaction max fee is in the 1e8 satoshi precision.\n // We need to convert them to the 1e18 TBTC precision.\n (, , uint64 depositTxMaxFee, ) = bridge.depositParameters();\n uint256 txMaxFee = depositTxMaxFee * SATOSHI_MULTIPLIER;\n\n return amountSubTreasury - omFee - txMaxFee;\n }\n\n /// @notice Calculates the deposit key for the given funding transaction\n /// hash and funding output index.\n /// @param fundingTxHash Funding transaction hash.\n /// @param fundingOutputIndex Funding output index.\n /// @return depositKey Deposit key computed as\n /// `keccak256(fundingTxHash | reveal.fundingOutputIndex)`. This\n /// key can be used to refer to the deposit in the Bridge and\n /// TBTCVault contracts.\n // slither-disable-next-line dead-code\n function _calculateDepositKey(\n bytes32 fundingTxHash,\n uint32 fundingOutputIndex\n ) internal pure returns (uint256) {\n return\n uint256(\n keccak256(abi.encodePacked(fundingTxHash, fundingOutputIndex))\n );\n }\n\n /// @notice Calculates the Bitcoin transaction hash for the given Bitcoin\n /// transaction data.\n /// @param txInfo Bitcoin transaction data, see `IBridgeTypes.BitcoinTxInfo` struct.\n /// @return txHash Bitcoin transaction hash.\n // slither-disable-next-line dead-code\n function _calculateBitcoinTxHash(IBridgeTypes.BitcoinTxInfo calldata txInfo)\n internal\n view\n returns (bytes32)\n {\n return\n abi\n .encodePacked(\n txInfo.version,\n txInfo.inputVector,\n txInfo.outputVector,\n txInfo.locktime\n )\n .hash256View();\n }\n}\n"
318
+ },
319
+ "contracts/integrator/IBridge.sol": {
320
+ "content": "// SPDX-License-Identifier: GPL-3.0-only\n\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n\npragma solidity ^0.8.0;\n\n/// @notice Namespace which groups all types relevant to the IBridge interface.\n/// @dev This is a mirror of the real types used in the Bridge contract.\n/// This way, the `integrator` subpackage does not need to import\n/// anything from the `bridge` subpackage and explicitly depend on it.\n/// This simplifies the dependency graph for integrators.\nlibrary IBridgeTypes {\n /// @dev See bridge/BitcoinTx.sol#Info\n struct BitcoinTxInfo {\n bytes4 version;\n bytes inputVector;\n bytes outputVector;\n bytes4 locktime;\n }\n\n /// @dev See bridge/Deposit.sol#DepositRevealInfo\n struct DepositRevealInfo {\n uint32 fundingOutputIndex;\n bytes8 blindingFactor;\n bytes20 walletPubKeyHash;\n bytes20 refundPubKeyHash;\n bytes4 refundLocktime;\n address vault;\n }\n\n /// @dev See bridge/Deposit.sol#DepositRequest\n struct DepositRequest {\n address depositor;\n uint64 amount;\n uint32 revealedAt;\n address vault;\n uint64 treasuryFee;\n uint32 sweptAt;\n bytes32 extraData;\n }\n}\n\n/// @notice Interface of the Bridge contract.\n/// @dev See bridge/Bridge.sol\ninterface IBridge {\n /// @dev See {Bridge#revealDepositWithExtraData}\n function revealDepositWithExtraData(\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\n IBridgeTypes.DepositRevealInfo calldata reveal,\n bytes32 extraData\n ) external;\n\n /// @dev See {Bridge#deposits}\n function deposits(uint256 depositKey)\n external\n view\n returns (IBridgeTypes.DepositRequest memory);\n\n /// @dev See {Bridge#depositParameters}\n function depositParameters()\n external\n view\n returns (\n uint64 depositDustThreshold,\n uint64 depositTreasuryFeeDivisor,\n uint64 depositTxMaxFee,\n uint32 depositRevealAheadPeriod\n );\n}\n"
321
+ },
322
+ "contracts/integrator/ITBTCVault.sol": {
323
+ "content": "// SPDX-License-Identifier: GPL-3.0-only\n\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n\npragma solidity ^0.8.0;\n\n/// @notice Interface of the TBTCVault contract.\n/// @dev See vault/TBTCVault.sol\ninterface ITBTCVault {\n /// @dev See {TBTCVault#optimisticMintingRequests}\n function optimisticMintingRequests(uint256 depositKey)\n external\n returns (uint64 requestedAt, uint64 finalizedAt);\n\n /// @dev See {TBTCVault#optimisticMintingFeeDivisor}\n function optimisticMintingFeeDivisor() external view returns (uint32);\n}\n"
324
+ },
316
325
  "contracts/l2/L2TBTC.sol": {
317
326
  "content": "// SPDX-License-Identifier: GPL-3.0-only\n\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\n\n/// @title L2TBTC\n/// @notice Canonical L2/sidechain token implementation. tBTC token is minted on\n/// L1 and locked there to be moved to L2/sidechain. By deploying\n/// a canonical token on each L2/sidechain, we can ensure the supply of\n/// tBTC remains sacrosanct, while enabling quick, interoperable\n/// cross-chain bridges and localizing ecosystem risk.\n///\n/// This contract is flexible enough to:\n/// - Delegate minting authority to a native bridge on the chain, if\n/// present.\n/// - Delegate minting authority to a short list of ecosystem bridges.\n/// - Have mints and burns paused by any one of n guardians, allowing\n/// avoidance of contagion in case of a chain- or bridge-specific\n/// incident.\n/// - Be governed and upgradeable.\n///\n/// The token is burnable by the token holder and supports EIP2612\n/// permits. Token holder can authorize a transfer of their token with\n/// a signature conforming EIP712 standard instead of an on-chain\n/// transaction from their address. Anyone can submit this signature on\n/// the user's behalf by calling the permit function, paying gas fees,\n/// and possibly performing other actions in the same transaction.\n/// The governance can recover ERC20 and ERC721 tokens sent mistakenly\n/// to L2TBTC token contract.\ncontract L2TBTC is\n ERC20Upgradeable,\n ERC20BurnableUpgradeable,\n ERC20PermitUpgradeable,\n OwnableUpgradeable,\n PausableUpgradeable\n{\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /// @notice Indicates if the given address is a minter. Only minters can\n /// mint the token.\n mapping(address => bool) public isMinter;\n\n /// @notice List of all minters.\n address[] public minters;\n\n /// @notice Indicates if the given address is a guardian. Only guardians can\n /// pause token mints and burns.\n mapping(address => bool) public isGuardian;\n\n /// @notice List of all guardians.\n address[] public guardians;\n\n event MinterAdded(address indexed minter);\n event MinterRemoved(address indexed minter);\n\n event GuardianAdded(address indexed guardian);\n event GuardianRemoved(address indexed guardian);\n\n modifier onlyMinter() {\n require(isMinter[msg.sender], \"Caller is not a minter\");\n _;\n }\n\n modifier onlyGuardian() {\n require(isGuardian[msg.sender], \"Caller is not a guardian\");\n _;\n }\n\n /// @notice Initializes the token contract.\n /// @param _name The name of the token.\n /// @param _symbol The symbol of the token, usually a shorter version of the\n /// name.\n function initialize(string memory _name, string memory _symbol)\n external\n initializer\n {\n // OpenZeppelin upgradeable contracts documentation says:\n //\n // \"Use with multiple inheritance requires special care. Initializer\n // functions are not linearized by the compiler like constructors.\n // Because of this, each __{ContractName}_init function embeds the\n // linearized calls to all parent initializers. As a consequence,\n // calling two of these init functions can potentially initialize the\n // same contract twice.\"\n //\n // Note that ERC20 extensions do not linearize calls to ERC20Upgradeable\n // initializer so we call all extension initializers individually. At\n // the same time, ERC20PermitUpgradeable does linearize the call to\n // EIP712Upgradeable so we are not using the unchained initializer\n // versions.\n __ERC20_init(_name, _symbol);\n __ERC20Burnable_init();\n __ERC20Permit_init(_name);\n __Ownable_init();\n __Pausable_init();\n }\n\n /// @notice Adds the address to the minters list.\n /// @dev Requirements:\n /// - The caller must be the contract owner.\n /// - `minter` must not be a minter address already.\n /// @param minter The address to be added as a minter.\n function addMinter(address minter) external onlyOwner {\n require(!isMinter[minter], \"This address is already a minter\");\n isMinter[minter] = true;\n minters.push(minter);\n emit MinterAdded(minter);\n }\n\n /// @notice Removes the address from the minters list.\n /// @dev Requirements:\n /// - The caller must be the contract owner.\n /// - `minter` must be a minter address.\n /// @param minter The address to be removed from the minters list.\n function removeMinter(address minter) external onlyOwner {\n require(isMinter[minter], \"This address is not a minter\");\n delete isMinter[minter];\n\n // We do not expect too many minters so a simple loop is safe.\n for (uint256 i = 0; i < minters.length; i++) {\n if (minters[i] == minter) {\n minters[i] = minters[minters.length - 1];\n // slither-disable-next-line costly-loop\n minters.pop();\n break;\n }\n }\n\n emit MinterRemoved(minter);\n }\n\n /// @notice Adds the address to the guardians list.\n /// @dev Requirements:\n /// - The caller must be the contract owner.\n /// - `guardian` must not be a guardian address already.\n /// @param guardian The address to be added as a guardian.\n function addGuardian(address guardian) external onlyOwner {\n require(!isGuardian[guardian], \"This address is already a guardian\");\n isGuardian[guardian] = true;\n guardians.push(guardian);\n emit GuardianAdded(guardian);\n }\n\n /// @notice Removes the address from the guardians list.\n /// @dev Requirements:\n /// - The caller must be the contract owner.\n /// - `guardian` must be a guardian address.\n /// @param guardian The address to be removed from the guardians list.\n function removeGuardian(address guardian) external onlyOwner {\n require(isGuardian[guardian], \"This address is not a guardian\");\n delete isGuardian[guardian];\n\n // We do not expect too many guardians so a simple loop is safe.\n for (uint256 i = 0; i < guardians.length; i++) {\n if (guardians[i] == guardian) {\n guardians[i] = guardians[guardians.length - 1];\n // slither-disable-next-line costly-loop\n guardians.pop();\n break;\n }\n }\n\n emit GuardianRemoved(guardian);\n }\n\n /// @notice Allows the governance of the token contract to recover any ERC20\n /// sent mistakenly to the token contract address.\n /// @param token The address of the token to be recovered.\n /// @param recipient The token recipient address that will receive recovered\n /// tokens.\n /// @param amount The amount to be recovered.\n function recoverERC20(\n IERC20Upgradeable token,\n address recipient,\n uint256 amount\n ) external onlyOwner {\n token.safeTransfer(recipient, amount);\n }\n\n /// @notice Allows the governance of the token contract to recover any\n /// ERC721 sent mistakenly to the token contract address.\n /// @param token The address of the token to be recovered.\n /// @param recipient The token recipient address that will receive the\n /// recovered token.\n /// @param tokenId The ID of the ERC721 token to be recovered.\n function recoverERC721(\n IERC721Upgradeable token,\n address recipient,\n uint256 tokenId,\n bytes calldata data\n ) external onlyOwner {\n token.safeTransferFrom(address(this), recipient, tokenId, data);\n }\n\n /// @notice Allows one of the guardians to pause mints and burns allowing\n /// avoidance of contagion in case of a chain- or bridge-specific\n /// incident.\n /// @dev Requirements:\n /// - The caller must be a guardian.\n /// - The contract must not be already paused.\n function pause() external onlyGuardian {\n _pause();\n }\n\n /// @notice Allows the governance to unpause mints and burns previously\n /// paused by one of the guardians.\n /// @dev Requirements:\n /// - The caller must be the contract owner.\n /// - The contract must be paused.\n function unpause() external onlyOwner {\n _unpause();\n }\n\n /// @notice Allows one of the minters to mint `amount` tokens and assign\n /// them to `account`, increasing the total supply. Emits\n /// a `Transfer` event with `from` set to the zero address.\n /// @dev Requirements:\n /// - The caller must be a minter.\n /// - `account` must not be the zero address.\n /// @param account The address to receive tokens.\n /// @param amount The amount of token to be minted.\n function mint(address account, uint256 amount)\n external\n whenNotPaused\n onlyMinter\n {\n _mint(account, amount);\n }\n\n /// @notice Destroys `amount` tokens from the caller. Emits a `Transfer`\n /// event with `to` set to the zero address.\n /// @dev Requirements:\n /// - The caller must have at least `amount` tokens.\n /// @param amount The amount of token to be burned.\n function burn(uint256 amount) public override whenNotPaused {\n super.burn(amount);\n }\n\n /// @notice Destroys `amount` tokens from `account`, deducting from the\n /// caller's allowance. Emits a `Transfer` event with `to` set to\n /// the zero address.\n /// @dev Requirements:\n /// - The che caller must have allowance for `accounts`'s tokens of at\n /// least `amount`.\n /// - `account` must not be the zero address.\n /// - `account` must have at least `amount` tokens.\n /// @param account The address owning tokens to be burned.\n /// @param amount The amount of token to be burned.\n function burnFrom(address account, uint256 amount)\n public\n override\n whenNotPaused\n {\n super.burnFrom(account, amount);\n }\n\n /// @notice Allows to fetch a list of all minters.\n function getMinters() external view returns (address[] memory) {\n return minters;\n }\n\n /// @notice Allows to fetch a list of all guardians.\n function getGuardians() external view returns (address[] memory) {\n return guardians;\n }\n}\n"
318
327
  },
@@ -361,6 +370,9 @@
361
370
  "contracts/test/TestERC721.sol": {
362
371
  "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\n\ncontract TestERC721 is ERC721 {\n string public constant NAME = \"Test ERC721 Token\";\n string public constant SYMBOL = \"TT\";\n\n constructor() ERC721(NAME, SYMBOL) {}\n\n function mint(address to, uint256 tokenId) public {\n _mint(to, tokenId);\n }\n}\n"
363
372
  },
373
+ "contracts/test/TestTBTCDepositor.sol": {
374
+ "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity ^0.8.0;\n\nimport {BTCUtils} from \"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\";\n\nimport \"../integrator/AbstractTBTCDepositor.sol\";\nimport \"../integrator/IBridge.sol\";\nimport \"../integrator/ITBTCVault.sol\";\n\ncontract TestTBTCDepositor is AbstractTBTCDepositor {\n event InitializeDepositReturned(uint256 depositKey);\n\n event FinalizeDepositReturned(uint256 tbtcAmount, bytes32 extraData);\n\n function initialize(address _bridge, address _tbtcVault) external {\n __AbstractTBTCDepositor_initialize(_bridge, _tbtcVault);\n }\n\n function initializeDepositPublic(\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\n IBridgeTypes.DepositRevealInfo calldata reveal,\n bytes32 extraData\n ) external {\n uint256 depositKey = _initializeDeposit(fundingTx, reveal, extraData);\n emit InitializeDepositReturned(depositKey);\n }\n\n function finalizeDepositPublic(uint256 depositKey) external {\n (uint256 tbtcAmount, bytes32 extraData) = _finalizeDeposit(depositKey);\n emit FinalizeDepositReturned(tbtcAmount, extraData);\n }\n\n function calculateTbtcAmountPublic(\n uint64 depositAmountSat,\n uint64 depositTreasuryFeeSat\n ) external view returns (uint256) {\n return _calculateTbtcAmount(depositAmountSat, depositTreasuryFeeSat);\n }\n}\n\ncontract MockBridge is IBridge {\n using BTCUtils for bytes;\n\n mapping(uint256 => IBridgeTypes.DepositRequest) internal _deposits;\n\n uint64 internal _depositTxMaxFee = 1 * 1e7; // 0.1 BTC\n\n event DepositRevealed(uint256 depositKey);\n\n function revealDepositWithExtraData(\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\n IBridgeTypes.DepositRevealInfo calldata reveal,\n bytes32 extraData\n ) external {\n bytes32 fundingTxHash = abi\n .encodePacked(\n fundingTx.version,\n fundingTx.inputVector,\n fundingTx.outputVector,\n fundingTx.locktime\n )\n .hash256View();\n\n uint256 depositKey = uint256(\n keccak256(\n abi.encodePacked(fundingTxHash, reveal.fundingOutputIndex)\n )\n );\n\n require(\n _deposits[depositKey].revealedAt == 0,\n \"Deposit already revealed\"\n );\n\n IBridgeTypes.DepositRequest memory request;\n\n request.depositor = msg.sender;\n request.amount = uint64(10 * 1e8); // 10 BTC\n /* solhint-disable-next-line not-rely-on-time */\n request.revealedAt = uint32(block.timestamp);\n request.vault = reveal.vault;\n request.treasuryFee = uint64(1 * 1e8); // 1 BTC\n request.sweptAt = 0;\n request.extraData = extraData;\n\n _deposits[depositKey] = request;\n\n emit DepositRevealed(depositKey);\n }\n\n function sweepDeposit(uint256 depositKey) external {\n require(_deposits[depositKey].revealedAt != 0, \"Deposit not revealed\");\n require(_deposits[depositKey].sweptAt == 0, \"Deposit already swept\");\n /* solhint-disable-next-line not-rely-on-time */\n _deposits[depositKey].sweptAt = uint32(block.timestamp);\n }\n\n function deposits(uint256 depositKey)\n external\n view\n returns (IBridgeTypes.DepositRequest memory)\n {\n return _deposits[depositKey];\n }\n\n function depositParameters()\n external\n view\n returns (\n uint64 depositDustThreshold,\n uint64 depositTreasuryFeeDivisor,\n uint64 depositTxMaxFee,\n uint32 depositRevealAheadPeriod\n )\n {\n depositDustThreshold = 0;\n depositTreasuryFeeDivisor = 0;\n depositTxMaxFee = _depositTxMaxFee;\n depositRevealAheadPeriod = 0;\n }\n\n function setDepositTxMaxFee(uint64 value) external {\n _depositTxMaxFee = value;\n }\n}\n\ncontract MockTBTCVault is ITBTCVault {\n struct Request {\n uint64 requestedAt;\n uint64 finalizedAt;\n }\n\n mapping(uint256 => Request) internal _requests;\n\n uint32 public optimisticMintingFeeDivisor = 100; // 1%\n\n function optimisticMintingRequests(uint256 depositKey)\n external\n returns (uint64 requestedAt, uint64 finalizedAt)\n {\n Request memory request = _requests[depositKey];\n return (request.requestedAt, request.finalizedAt);\n }\n\n function createOptimisticMintingRequest(uint256 depositKey) external {\n require(\n _requests[depositKey].requestedAt == 0,\n \"Request already exists\"\n );\n /* solhint-disable-next-line not-rely-on-time */\n _requests[depositKey].requestedAt = uint64(block.timestamp);\n }\n\n function finalizeOptimisticMintingRequest(uint256 depositKey) external {\n require(\n _requests[depositKey].requestedAt != 0,\n \"Request does not exist\"\n );\n require(\n _requests[depositKey].finalizedAt == 0,\n \"Request already finalized\"\n );\n /* solhint-disable-next-line not-rely-on-time */\n _requests[depositKey].finalizedAt = uint64(block.timestamp);\n }\n\n function setOptimisticMintingFeeDivisor(uint32 value) external {\n optimisticMintingFeeDivisor = value;\n }\n}\n"
375
+ },
364
376
  "contracts/test/WormholeBridgeStub.sol": {
365
377
  "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"./TestERC20.sol\";\nimport \"../l2/L2WormholeGateway.sol\";\n\n/// @dev Stub contract used in L2WormholeGateway unit tests.\n/// Stub contract is used instead of a smock because of the token transfer\n/// that needs to happen in completeTransferWithPayload function.\ncontract WormholeBridgeStub is IWormholeTokenBridge {\n TestERC20 public wormholeToken;\n\n uint256 public transferAmount;\n bytes32 public receiverAddress;\n\n // Two simple events allowing to assert Wormhole bridge functions are\n // called.\n event WormholeBridgeStub_completeTransferWithPayload(bytes encodedVm);\n event WormholeBridgeStub_transferTokens(\n address token,\n uint256 amount,\n uint16 recipientChain,\n bytes32 recipient,\n uint256 arbiterFee,\n uint32 nonce\n );\n event WormholeBridgeStub_transferTokensWithPayload(\n address token,\n uint256 amount,\n uint16 recipientChain,\n bytes32 recipient,\n uint32 nonce,\n bytes payload\n );\n\n constructor(TestERC20 _wormholeToken) {\n wormholeToken = _wormholeToken;\n }\n\n function completeTransferWithPayload(bytes memory encodedVm)\n external\n returns (bytes memory)\n {\n emit WormholeBridgeStub_completeTransferWithPayload(encodedVm);\n wormholeToken.mint(msg.sender, transferAmount);\n\n // In a real implementation, encodedVm is parsed. To avoid copy-pasting\n // Wormhole code to this contract and then encoding parmaters in unit\n // tests, we allow to set the receiver address on the stub contract and\n // we return it here. The rest of the parameters does not matter.\n IWormholeTokenBridge.TransferWithPayload memory transfer = IWormholeTokenBridge\n .TransferWithPayload(\n 1, // payloadID\n 2, // amount\n 0x3000000000000000000000000000000000000000000000000000000000000000, // tokenAddress\n 4, // tokenChain\n 0x5000000000000000000000000000000000000000000000000000000000000000, // to\n 6, // toChain\n 0x7000000000000000000000000000000000000000000000000000000000000000, // fromAddress\n abi.encode(receiverAddress) // payload\n );\n\n return abi.encode(transfer);\n }\n\n function transferTokens(\n address token,\n uint256 amount,\n uint16 recipientChain,\n bytes32 recipient,\n uint256 arbiterFee,\n uint32 nonce\n ) external payable returns (uint64 sequence) {\n emit WormholeBridgeStub_transferTokens(\n token,\n amount,\n recipientChain,\n recipient,\n arbiterFee,\n nonce\n );\n return 777;\n }\n\n function transferTokensWithPayload(\n address token,\n uint256 amount,\n uint16 recipientChain,\n bytes32 recipient,\n uint32 nonce,\n bytes memory payload\n ) external payable returns (uint64 sequence) {\n emit WormholeBridgeStub_transferTokensWithPayload(\n token,\n amount,\n recipientChain,\n recipient,\n nonce,\n payload\n );\n return 888;\n }\n\n function parseTransferWithPayload(bytes memory encoded)\n external\n pure\n returns (IWormholeTokenBridge.TransferWithPayload memory transfer)\n {\n return abi.decode(encoded, (IWormholeTokenBridge.TransferWithPayload));\n }\n\n function setTransferAmount(uint256 _transferAmount) external {\n transferAmount = _transferAmount;\n }\n\n function setReceiverAddress(bytes32 _receiverAddress) external {\n receiverAddress = _receiverAddress;\n }\n\n // Allows to mint Wormhole tBTC for depositWormholeTbtc unit tests.\n function mintWormholeToken(address to, uint256 amount) external {\n wormholeToken.mint(to, amount);\n }\n}\n"
366
378
  },
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../build-info/b5f1e8cf3b3e0a9bb2a81d4dff3fdda7.json"
3
+ "buildInfo": "../../build-info/d51cc3cb76791b35eb7e8d6276e01849.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/b5f1e8cf3b3e0a9bb2a81d4dff3fdda7.json"
3
+ "buildInfo": "../../../build-info/d51cc3cb76791b35eb7e8d6276e01849.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/b5f1e8cf3b3e0a9bb2a81d4dff3fdda7.json"
3
+ "buildInfo": "../../../build-info/d51cc3cb76791b35eb7e8d6276e01849.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/b5f1e8cf3b3e0a9bb2a81d4dff3fdda7.json"
3
+ "buildInfo": "../../../build-info/d51cc3cb76791b35eb7e8d6276e01849.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/b5f1e8cf3b3e0a9bb2a81d4dff3fdda7.json"
3
+ "buildInfo": "../../../build-info/d51cc3cb76791b35eb7e8d6276e01849.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/b5f1e8cf3b3e0a9bb2a81d4dff3fdda7.json"
3
+ "buildInfo": "../../../build-info/d51cc3cb76791b35eb7e8d6276e01849.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/b5f1e8cf3b3e0a9bb2a81d4dff3fdda7.json"
3
+ "buildInfo": "../../../build-info/d51cc3cb76791b35eb7e8d6276e01849.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/b5f1e8cf3b3e0a9bb2a81d4dff3fdda7.json"
3
+ "buildInfo": "../../../build-info/d51cc3cb76791b35eb7e8d6276e01849.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/b5f1e8cf3b3e0a9bb2a81d4dff3fdda7.json"
3
+ "buildInfo": "../../../build-info/d51cc3cb76791b35eb7e8d6276e01849.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/b5f1e8cf3b3e0a9bb2a81d4dff3fdda7.json"
3
+ "buildInfo": "../../../build-info/d51cc3cb76791b35eb7e8d6276e01849.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/b5f1e8cf3b3e0a9bb2a81d4dff3fdda7.json"
3
+ "buildInfo": "../../../build-info/d51cc3cb76791b35eb7e8d6276e01849.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/b5f1e8cf3b3e0a9bb2a81d4dff3fdda7.json"
3
+ "buildInfo": "../../../build-info/d51cc3cb76791b35eb7e8d6276e01849.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/b5f1e8cf3b3e0a9bb2a81d4dff3fdda7.json"
3
+ "buildInfo": "../../../build-info/d51cc3cb76791b35eb7e8d6276e01849.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/b5f1e8cf3b3e0a9bb2a81d4dff3fdda7.json"
3
+ "buildInfo": "../../../build-info/d51cc3cb76791b35eb7e8d6276e01849.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/b5f1e8cf3b3e0a9bb2a81d4dff3fdda7.json"
3
+ "buildInfo": "../../../build-info/d51cc3cb76791b35eb7e8d6276e01849.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/b5f1e8cf3b3e0a9bb2a81d4dff3fdda7.json"
3
+ "buildInfo": "../../../build-info/d51cc3cb76791b35eb7e8d6276e01849.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/b5f1e8cf3b3e0a9bb2a81d4dff3fdda7.json"
3
+ "buildInfo": "../../../build-info/d51cc3cb76791b35eb7e8d6276e01849.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/b5f1e8cf3b3e0a9bb2a81d4dff3fdda7.json"
3
+ "buildInfo": "../../../build-info/d51cc3cb76791b35eb7e8d6276e01849.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/b5f1e8cf3b3e0a9bb2a81d4dff3fdda7.json"
3
+ "buildInfo": "../../../build-info/d51cc3cb76791b35eb7e8d6276e01849.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/b5f1e8cf3b3e0a9bb2a81d4dff3fdda7.json"
3
+ "buildInfo": "../../../build-info/d51cc3cb76791b35eb7e8d6276e01849.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/b5f1e8cf3b3e0a9bb2a81d4dff3fdda7.json"
3
+ "buildInfo": "../../../build-info/d51cc3cb76791b35eb7e8d6276e01849.json"
4
4
  }
@@ -0,0 +1,4 @@
1
+ {
2
+ "_format": "hh-sol-dbg-1",
3
+ "buildInfo": "../../../build-info/d51cc3cb76791b35eb7e8d6276e01849.json"
4
+ }
@@ -0,0 +1,113 @@
1
+ {
2
+ "_format": "hh-sol-artifact-1",
3
+ "contractName": "AbstractTBTCDepositor",
4
+ "sourceName": "contracts/integrator/AbstractTBTCDepositor.sol",
5
+ "abi": [
6
+ {
7
+ "anonymous": false,
8
+ "inputs": [
9
+ {
10
+ "indexed": true,
11
+ "internalType": "uint256",
12
+ "name": "depositKey",
13
+ "type": "uint256"
14
+ },
15
+ {
16
+ "indexed": false,
17
+ "internalType": "uint256",
18
+ "name": "tbtcAmount",
19
+ "type": "uint256"
20
+ },
21
+ {
22
+ "indexed": false,
23
+ "internalType": "uint32",
24
+ "name": "finalizedAt",
25
+ "type": "uint32"
26
+ }
27
+ ],
28
+ "name": "DepositFinalized",
29
+ "type": "event"
30
+ },
31
+ {
32
+ "anonymous": false,
33
+ "inputs": [
34
+ {
35
+ "indexed": true,
36
+ "internalType": "uint256",
37
+ "name": "depositKey",
38
+ "type": "uint256"
39
+ },
40
+ {
41
+ "indexed": false,
42
+ "internalType": "uint32",
43
+ "name": "initializedAt",
44
+ "type": "uint32"
45
+ }
46
+ ],
47
+ "name": "DepositInitialized",
48
+ "type": "event"
49
+ },
50
+ {
51
+ "inputs": [],
52
+ "name": "SATOSHI_MULTIPLIER",
53
+ "outputs": [
54
+ {
55
+ "internalType": "uint256",
56
+ "name": "",
57
+ "type": "uint256"
58
+ }
59
+ ],
60
+ "stateMutability": "view",
61
+ "type": "function"
62
+ },
63
+ {
64
+ "inputs": [],
65
+ "name": "bridge",
66
+ "outputs": [
67
+ {
68
+ "internalType": "contract IBridge",
69
+ "name": "",
70
+ "type": "address"
71
+ }
72
+ ],
73
+ "stateMutability": "view",
74
+ "type": "function"
75
+ },
76
+ {
77
+ "inputs": [
78
+ {
79
+ "internalType": "uint256",
80
+ "name": "",
81
+ "type": "uint256"
82
+ }
83
+ ],
84
+ "name": "pendingDeposits",
85
+ "outputs": [
86
+ {
87
+ "internalType": "bool",
88
+ "name": "",
89
+ "type": "bool"
90
+ }
91
+ ],
92
+ "stateMutability": "view",
93
+ "type": "function"
94
+ },
95
+ {
96
+ "inputs": [],
97
+ "name": "tbtcVault",
98
+ "outputs": [
99
+ {
100
+ "internalType": "contract ITBTCVault",
101
+ "name": "",
102
+ "type": "address"
103
+ }
104
+ ],
105
+ "stateMutability": "view",
106
+ "type": "function"
107
+ }
108
+ ],
109
+ "bytecode": "0x",
110
+ "deployedBytecode": "0x",
111
+ "linkReferences": {},
112
+ "deployedLinkReferences": {}
113
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "_format": "hh-sol-dbg-1",
3
+ "buildInfo": "../../../build-info/d51cc3cb76791b35eb7e8d6276e01849.json"
4
+ }
@@ -0,0 +1,172 @@
1
+ {
2
+ "_format": "hh-sol-artifact-1",
3
+ "contractName": "IBridge",
4
+ "sourceName": "contracts/integrator/IBridge.sol",
5
+ "abi": [
6
+ {
7
+ "inputs": [],
8
+ "name": "depositParameters",
9
+ "outputs": [
10
+ {
11
+ "internalType": "uint64",
12
+ "name": "depositDustThreshold",
13
+ "type": "uint64"
14
+ },
15
+ {
16
+ "internalType": "uint64",
17
+ "name": "depositTreasuryFeeDivisor",
18
+ "type": "uint64"
19
+ },
20
+ {
21
+ "internalType": "uint64",
22
+ "name": "depositTxMaxFee",
23
+ "type": "uint64"
24
+ },
25
+ {
26
+ "internalType": "uint32",
27
+ "name": "depositRevealAheadPeriod",
28
+ "type": "uint32"
29
+ }
30
+ ],
31
+ "stateMutability": "view",
32
+ "type": "function"
33
+ },
34
+ {
35
+ "inputs": [
36
+ {
37
+ "internalType": "uint256",
38
+ "name": "depositKey",
39
+ "type": "uint256"
40
+ }
41
+ ],
42
+ "name": "deposits",
43
+ "outputs": [
44
+ {
45
+ "components": [
46
+ {
47
+ "internalType": "address",
48
+ "name": "depositor",
49
+ "type": "address"
50
+ },
51
+ {
52
+ "internalType": "uint64",
53
+ "name": "amount",
54
+ "type": "uint64"
55
+ },
56
+ {
57
+ "internalType": "uint32",
58
+ "name": "revealedAt",
59
+ "type": "uint32"
60
+ },
61
+ {
62
+ "internalType": "address",
63
+ "name": "vault",
64
+ "type": "address"
65
+ },
66
+ {
67
+ "internalType": "uint64",
68
+ "name": "treasuryFee",
69
+ "type": "uint64"
70
+ },
71
+ {
72
+ "internalType": "uint32",
73
+ "name": "sweptAt",
74
+ "type": "uint32"
75
+ },
76
+ {
77
+ "internalType": "bytes32",
78
+ "name": "extraData",
79
+ "type": "bytes32"
80
+ }
81
+ ],
82
+ "internalType": "struct IBridgeTypes.DepositRequest",
83
+ "name": "",
84
+ "type": "tuple"
85
+ }
86
+ ],
87
+ "stateMutability": "view",
88
+ "type": "function"
89
+ },
90
+ {
91
+ "inputs": [
92
+ {
93
+ "components": [
94
+ {
95
+ "internalType": "bytes4",
96
+ "name": "version",
97
+ "type": "bytes4"
98
+ },
99
+ {
100
+ "internalType": "bytes",
101
+ "name": "inputVector",
102
+ "type": "bytes"
103
+ },
104
+ {
105
+ "internalType": "bytes",
106
+ "name": "outputVector",
107
+ "type": "bytes"
108
+ },
109
+ {
110
+ "internalType": "bytes4",
111
+ "name": "locktime",
112
+ "type": "bytes4"
113
+ }
114
+ ],
115
+ "internalType": "struct IBridgeTypes.BitcoinTxInfo",
116
+ "name": "fundingTx",
117
+ "type": "tuple"
118
+ },
119
+ {
120
+ "components": [
121
+ {
122
+ "internalType": "uint32",
123
+ "name": "fundingOutputIndex",
124
+ "type": "uint32"
125
+ },
126
+ {
127
+ "internalType": "bytes8",
128
+ "name": "blindingFactor",
129
+ "type": "bytes8"
130
+ },
131
+ {
132
+ "internalType": "bytes20",
133
+ "name": "walletPubKeyHash",
134
+ "type": "bytes20"
135
+ },
136
+ {
137
+ "internalType": "bytes20",
138
+ "name": "refundPubKeyHash",
139
+ "type": "bytes20"
140
+ },
141
+ {
142
+ "internalType": "bytes4",
143
+ "name": "refundLocktime",
144
+ "type": "bytes4"
145
+ },
146
+ {
147
+ "internalType": "address",
148
+ "name": "vault",
149
+ "type": "address"
150
+ }
151
+ ],
152
+ "internalType": "struct IBridgeTypes.DepositRevealInfo",
153
+ "name": "reveal",
154
+ "type": "tuple"
155
+ },
156
+ {
157
+ "internalType": "bytes32",
158
+ "name": "extraData",
159
+ "type": "bytes32"
160
+ }
161
+ ],
162
+ "name": "revealDepositWithExtraData",
163
+ "outputs": [],
164
+ "stateMutability": "nonpayable",
165
+ "type": "function"
166
+ }
167
+ ],
168
+ "bytecode": "0x",
169
+ "deployedBytecode": "0x",
170
+ "linkReferences": {},
171
+ "deployedLinkReferences": {}
172
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "_format": "hh-sol-dbg-1",
3
+ "buildInfo": "../../../build-info/d51cc3cb76791b35eb7e8d6276e01849.json"
4
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "_format": "hh-sol-artifact-1",
3
+ "contractName": "IBridgeTypes",
4
+ "sourceName": "contracts/integrator/IBridge.sol",
5
+ "abi": [],
6
+ "bytecode": "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212200450dfe4da4d6283feff622803b649709e272778add3b40416c8c18864e15bf464736f6c63430008110033",
7
+ "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212200450dfe4da4d6283feff622803b649709e272778add3b40416c8c18864e15bf464736f6c63430008110033",
8
+ "linkReferences": {},
9
+ "deployedLinkReferences": {}
10
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "_format": "hh-sol-dbg-1",
3
+ "buildInfo": "../../../build-info/d51cc3cb76791b35eb7e8d6276e01849.json"
4
+ }