TBTCVault
TBTCVault
TBTC is a fully Bitcoin-backed ERC-20 token pegged to the price of Bitcoin. It facilitates Bitcoin holders to act on the Ethereum blockchain and access the decentralized finance (DeFi) ecosystem. TBTC Vault mints and unmints TBTC based on Bitcoin balances in the Bank.
TBTC Vault is the owner of TBTC token contract and is the only contract minting the token.
bank
tbtcToken
newVault
The address of a new TBTC vault. Set only when the upgrade process is pending. Once the upgrade gets finalized, the new TBTC vault will become an owner of TBTC token.
upgradeInitiatedTimestamp
The timestamp at which an upgrade to a new TBTC vault was initiated. Set only when the upgrade process is pending.
Minted
Unminted
UpgradeInitiated
UpgradeFinalized
onlyBank
constructor
mint
Mints the given amount
of TBTC to the caller previously transferring amount / SATOSHI_MULTIPLIER
of the Bank balance from caller to TBTC Vault. If amount
is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's Bank balance.
TBTC Vault must have an allowance for caller's balance in the Bank for at least amount / SATOSHI_MULTIPLIER
.
Parameters
receiveBalanceApproval
Transfers satoshis
of the Bank balance from the caller to TBTC Vault and mints satoshis * SATOSHI_MULTIPLIER
of TBTC to the caller.
Can only be called by the Bank via approveBalanceAndCall
.
Parameters
receiveBalanceIncrease
Mints the same amount of TBTC as the deposited satoshis amount multiplied by SATOSHI_MULTIPLIER for each depositor in the array. Can only be called by the Bank after the Bridge swept deposits and Bank increased balance for the vault.
Fails if depositors
array is empty. Expects the length of depositors
and depositedSatoshiAmounts
is the same.
unmint
Burns amount
of TBTC from the caller's balance and transfers amount / SATOSHI_MULTIPLIER
back to the caller's balance in the Bank. If amount
is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's account.
Caller must have at least amount
of TBTC approved to TBTC Vault.
Parameters
unmintAndRedeem
Burns amount
of TBTC from the caller's balance and transfers amount / SATOSHI_MULTIPLIER
of Bank balance to the Bridge requesting redemption based on the provided redemptionData
. If amount
is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's account.
Caller must have at least amount
of TBTC approved to TBTC Vault.
Parameters
receiveApproval
Burns amount
of TBTC from the caller's balance. If extraData
is empty, transfers amount
back to the caller's balance in the Bank. If extraData
is not empty, requests redemption in the Bridge using the extraData
as a redemptionData
parameter to Bridge's receiveBalanceApproval
function. If amount
is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's account. Note that it may left a token approval equal to the remainder.
This function is doing the same as unmint
or unmintAndRedeem
(depending on extraData
parameter) but it allows to execute unminting without a separate approval transaction. The function can be called only via approveAndCall
of TBTC token.
Parameters
initiateUpgrade
Initiates vault upgrade process. The upgrade process needs to be finalized with a call to finalizeUpgrade
function after the UPGRADE_GOVERNANCE_DELAY
passes. Only the governance can initiate the upgrade.
Parameters
finalizeUpgrade
Allows the governance to finalize vault upgrade process. The upgrade process needs to be first initiated with a call to initiateUpgrade
and the GOVERNANCE_DELAY
needs to pass. Once the upgrade is finalized, the new vault becomes the owner of the TBTC token and receives the whole Bank balance of this vault.
recoverERC20FromToken
Allows the governance of the TBTCVault to recover any ERC20 token sent mistakenly to the TBTC token contract address.
Parameters
recoverERC721FromToken
Allows the governance of the TBTCVault to recover any ERC721 token sent mistakenly to the TBTC token contract address.
Parameters
recoverERC20
Allows the governance of the TBTCVault to recover any ERC20 token sent - mistakenly or not - to the vault address. This function should be used to withdraw TBTC v1 tokens transferred to TBTCVault as a result of VendingMachine > TBTCVault upgrade.
Parameters
recoverERC721
Allows the governance of the TBTCVault to recover any ERC721 token sent mistakenly to the vault address.
Parameters
amountToSatoshis
Returns the amount of TBTC to be minted/unminted, the remainder, and the Bank balance to be transferred for the given mint/unmint. Note that if the amount
is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's account when minting or unminting.
Return Values
_mint
Mints the given amount of TBTC to the given depositor's address. Implemented by TBTCVault.
_unmint
amount
MUST be divisible by SATOSHI_MULTIPLIER with no change.
_unmintAndRedeem
amount
MUST be divisible by SATOSHI_MULTIPLIER with no change.
Last updated