BitcoinRedeemer

This contract facilitates redemption of stBTC tokens to Bitcoin through tBTC redemption process.

tbtcToken

contract ITBTCToken tbtcToken

Interface for tBTC token contract.

stbtc

contract stBTC stbtc

stBTC token contract.

tbtcVault

address tbtcVault

Address of the TBTCVault contract.

TbtcVaultUpdated

event TbtcVaultUpdated(address oldTbtcVault, address newTbtcVault)

Emitted when the TBTCVault contract address is updated.

Parameters

NameTypeDescription

oldTbtcVault

address

Address of the old TBTCVault contract.

newTbtcVault

address

Address of the new TBTCVault contract.

RedemptionRequested

event RedemptionRequested(address owner, uint256 shares, uint256 tbtcAmount)

Emitted when redemption is requested.

Parameters

NameTypeDescription

owner

address

Owner of stBTC tokens.

shares

uint256

Number of stBTC tokens.

tbtcAmount

uint256

Number of tBTC tokens.

TbtcTokenZeroAddress

error TbtcTokenZeroAddress()

Reverts if the tBTC Token address is zero.

StbtcZeroAddress

error StbtcZeroAddress()

Reverts if the stBTC address is zero.

TbtcVaultZeroAddress

error TbtcVaultZeroAddress()

Reverts if the TBTCVault address is zero.

CallerNotAllowed

error CallerNotAllowed(address caller)

Attempted to call receiveApproval by supported token.

EmptyExtraData

error EmptyExtraData()

Attempted to call receiveApproval with empty data.

UnexpectedTbtcTokenOwner

error UnexpectedTbtcTokenOwner()

Attempted to call _redeemSharesAndUnmint with unexpected tBTC token owner.

RedeemerNotOwner

error RedeemerNotOwner(address redeemer, address owner)

Reverts if the redeemer is not the deposit owner.

ApproveAndCallFailed

error ApproveAndCallFailed()

Reverts when approveAndCall to tBTC contract fails.

NotTbtcTokenOwner

error NotTbtcTokenOwner()

Reverts if the new TBTCVault contract is not tBTC token owner.

constructor

constructor() public

initialize

function initialize(address _tbtcToken, address _stbtc, address _tbtcVault) public

Initializes the contract with tBTC token and stBTC token addresses.

Parameters

NameTypeDescription

_tbtcToken

address

The address of the tBTC token contract.

_stbtc

address

The address of the stBTC token contract.

_tbtcVault

address

The address of the TBTCVault contract.

receiveApproval

function receiveApproval(address from, uint256 amount, address, bytes extraData) external

Redeems shares for tBTC and requests bridging to Bitcoin.

Parameters

NameTypeDescription

from

address

Shares token holder executing redemption.

amount

uint256

Amount of shares to redeem.

address

extraData

bytes

Redemption data in a format expected from redemptionData parameter of Bridge's receiveBalanceApproval function.

updateTbtcVault

function updateTbtcVault(address newTbtcVault) external

Updates TBTCVault contract address.

Parameters

NameTypeDescription

newTbtcVault

address

New TBTCVault contract address.

_redeemSharesAndUnmint

function _redeemSharesAndUnmint(address owner, uint256 shares, bytes tbtcRedemptionData) internal

Initiates the redemption process by exchanging stBTC tokens for tBTC tokens and requesting bridging to Bitcoin.

Redeems stBTC shares to receive tBTC and requests redemption of tBTC to Bitcoin via tBTC Bridge. Redemption data in a format expected from redemptionData parameter of Bridge's receiveBalanceApproval. It uses tBTC token owner which is the TBTCVault contract as spender of tBTC requested for redemption. tBTC Bridge redemption process has a path where request can timeout. It is a scenario that is unlikely to happen with the current Bridge setup. This contract remains upgradable to have flexibility to handle adjustments to tBTC Bridge changes. Redemption data should include a redeemer address matching the address of the deposit owner who is redeeming the shares. In case anything goes wrong during the tBTC unminting process, the redeemer will be able to claim the tBTC tokens back from the tBTC Bank contract.

Parameters

NameTypeDescription

owner

address

The owner of the stBTC tokens.

shares

uint256

The number of stBTC tokens to redeem.

tbtcRedemptionData

bytes

Additional data required for the tBTC redemption. See redemptionData parameter description of Bridge.requestRedemption function.

Last updated