Skip to content

Commit

Permalink
Add tBTC token reference in tBTC Depositor contract
Browse files Browse the repository at this point in the history
Instead of reading the tBTC token address from Acre.asset(), we define
it in this contract.
  • Loading branch information
nkuba committed Jan 22, 2024
1 parent c4c19b3 commit 01c8feb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 6 additions & 5 deletions core/contracts/tbtc/TbtcDepositor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ contract TbtcDepositor is Ownable {
IBridge public bridge;
/// @notice tBTC Vault contract.
ITBTCVault public tbtcVault;
/// @notice tBTC Token contract.
IERC20 public immutable tbtcToken;
/// @notice Acre contract.
Acre public acre;

Expand Down Expand Up @@ -159,10 +161,12 @@ contract TbtcDepositor is Ownable {
constructor(
IBridge _bridge,
ITBTCVault _tbtcVault,
IERC20 _tbtcToken,
Acre _acre
) Ownable(msg.sender) {
bridge = _bridge;
tbtcVault = _tbtcVault;
tbtcToken = _tbtcToken;
acre = _acre;

depositorFeeDivisor = 0; // Depositor fee is disabled initially.
Expand Down Expand Up @@ -384,10 +388,7 @@ contract TbtcDepositor is Ownable {
emit StakeFinalized(depositKey, msg.sender);

// Stake tBTC in Acre.
IERC20(acre.asset()).safeIncreaseAllowance(
address(acre),
request.amountToStake
);
tbtcToken.safeIncreaseAllowance(address(acre), request.amountToStake);
acre.stake(request.amountToStake, receiver, referral);
}

Expand Down Expand Up @@ -424,7 +425,7 @@ contract TbtcDepositor is Ownable {

emit StakeRecalled(depositKey, msg.sender);

IERC20(acre.asset()).safeTransfer(receiver, request.amountToStake);
tbtcToken.safeTransfer(receiver, request.amountToStake);
}

/// @notice Updates the depositor fee divisor.
Expand Down
3 changes: 2 additions & 1 deletion core/deploy/03_deploy_tbtc_depositor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {

const bridge = await deployments.get("Bridge")
const tbtcVault = await deployments.get("TBTCVault")
const tbtc = await deployments.get("TBTC")
const acre = await deployments.get("Acre")

await deployments.deploy("TbtcDepositor", {
from: deployer,
args: [bridge.address, tbtcVault.address, acre.address],
args: [bridge.address, tbtcVault.address, tbtc.address, acre.address],
log: true,
waitConfirmations: 1,
})
Expand Down

0 comments on commit 01c8feb

Please sign in to comment.