Skip to content

Commit

Permalink
Check revealed tBTC Vault matches the expected
Browse files Browse the repository at this point in the history
The tBTC Depositor contract expects tokens to be processed by a specific
tBTC Vault. We need to make sure that this is the same vault as the one
staker selected in the deposit transaction.
  • Loading branch information
nkuba committed Jan 22, 2024
1 parent 01c8feb commit 4d5cdbb
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions core/contracts/tbtc/TbtcDepositor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ contract TbtcDepositor is Ownable {
/// contract doesn't match the current contract address.
error UnexpectedDepositor(address bridgeDepositRequestDepositor);

/// @dev Vault address stored in the Deposit Request in the tBTC Bridge
/// contract doesn't match the expected tBTC Vault contract address.
error UnexpectedTbtcVault(address bridgeDepositRequestVault);

/// @dev Deposit was not completed on the tBTC side and tBTC was not minted
/// to the depositor contract. It is thrown when the deposit neither has
/// been optimistically minted nor swept.
Expand Down Expand Up @@ -244,6 +248,16 @@ contract TbtcDepositor is Ownable {
(, , request.tbtcDepositTxMaxFee, ) = bridge.depositParameters();
request.tbtcOptimisticMintingFeeDivisor = tbtcVault
.optimisticMintingFeeDivisor();

// Get deposit details from tBTC Bridge contract.
IBridge.DepositRequest memory bridgeDepositRequest = bridge.deposits(
depositKey
);

// Check if Vault revealed to the tBTC Bridge contract matches the
// tBTC Vault supported by this contract.
if (bridgeDepositRequest.vault != address(tbtcVault))
revert UnexpectedTbtcVault(bridgeDepositRequest.vault);
}

/// @notice This function should be called for previously initialized stake
Expand Down

0 comments on commit 4d5cdbb

Please sign in to comment.