Bank
Bank
Bank is a central component tracking Bitcoin balances. Balances can be transferred between balance owners, and balance owners can approve their balances to be spent by others. Balances in the Bank are updated for depositors who deposited their Bitcoin into the Bridge and only the Bridge can increase balances.
Bank is a governable contract and the Governance can upgrade the Bridge address.
bridge
balanceOf
The balance of the given account in the Bank. Zero by default.
allowance
The remaining amount of balance a spender will be allowed to transfer on behalf of an owner using transferBalanceFrom
. Zero by default.
nonces
Returns the current nonce for an EIP2612 permission for the provided balance owner to protect against replay attacks. Used to construct an EIP2612 signature provided to the permit
function.
cachedChainId
cachedDomainSeparator
PERMIT_TYPEHASH
Returns an EIP2612 Permit message hash. Used to construct an EIP2612 signature provided to the permit
function.
BalanceTransferred
BalanceApproved
BalanceIncreased
BalanceDecreased
BridgeUpdated
onlyBridge
constructor
updateBridge
Allows the Governance to upgrade the Bridge address.
The function does not implement any governance delay and does not check the status of the Bridge. The Governance implementation needs to ensure all requirements for the upgrade are satisfied before executing this function. Requirements:
The new Bridge address must not be zero.
Parameters
_bridge
address
The new Bridge address.
transferBalance
Moves the given amount
of balance from the caller to recipient
.
Requirements:
recipient
cannot be the zero address,the caller must have a balance of at least
amount
.
Parameters
recipient
address
The recipient of the balance.
amount
uint256
The amount of the balance transferred.
approveBalance
Sets amount
as the allowance of spender
over the caller's balance. Does not allow updating an existing allowance to a value that is non-zero to avoid someone using both the old and the new allowance by unfortunate transaction ordering. To update an allowance to a non-zero value please set it to zero first or use increaseBalanceAllowance
or decreaseBalanceAllowance
for an atomic update.
If the amount
is set to type(uint256).max
, transferBalanceFrom
will not reduce an allowance.
Parameters
spender
address
The address that will be allowed to spend the balance.
amount
uint256
The amount the spender is allowed to spend.
approveBalanceAndCall
Sets the amount
as an allowance of a smart contract spender
over the caller's balance and calls the spender
via receiveBalanceApproval
.
If the amount
is set to type(uint256).max
, the potential transferBalanceFrom
executed in receiveBalanceApproval
of spender
will not reduce an allowance. Beware that changing an allowance with this function brings the risk that spender
may use both the old and the new allowance by unfortunate transaction ordering. Please use increaseBalanceAllowance
and decreaseBalanceAllowance
to eliminate the risk.
Parameters
spender
address
The smart contract that will be allowed to spend the balance.
amount
uint256
The amount the spender contract is allowed to spend.
extraData
bytes
Extra data passed to the spender
contract via receiveBalanceApproval
call.
increaseBalanceAllowance
Atomically increases the caller's balance allowance granted to spender
by the given addedValue
.
Parameters
spender
address
The spender address for which the allowance is increased.
addedValue
uint256
The amount by which the allowance is increased.
decreaseBalanceAllowance
Atomically decreases the caller's balance allowance granted to spender
by the given subtractedValue
.
Requirements:
spender
must not be the zero address,the current allowance for
spender
must not be lower than thesubtractedValue
.
Parameters
spender
address
The spender address for which the allowance is decreased.
subtractedValue
uint256
The amount by which the allowance is decreased.
transferBalanceFrom
Moves amount
of balance from spender
to recipient
using the allowance mechanism. amount
is then deducted from the caller's allowance unless the allowance was made for type(uint256).max
.
Requirements:
recipient
cannot be the zero address,spender
must have a balance of at leastamount
,the caller must have an allowance for
spender
's balance of at leastamount
.
Parameters
spender
address
The address from which the balance is transferred.
recipient
address
The address to which the balance is transferred.
amount
uint256
The amount of balance that is transferred.
permit
An EIP2612 approval made with secp256k1 signature. Users can authorize a transfer of their balance with a signature conforming to the EIP712 standard, rather than an on-chain transaction from their address. Anyone can submit this signature on the user's behalf by calling the permit
function, paying gas fees, and possibly performing other actions in the same transaction.
The deadline argument can be set to type(uint256).max to create permits that effectively never expire. If the
amountis set to
type(uint256).maxthen
transferBalanceFromwill not reduce an allowance. Beware that changing an allowance with this function brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. Please use
increaseBalanceAllowanceand
decreaseBalanceAllowance` to eliminate the risk.
Parameters
owner
address
The balance owner who signed the permission.
spender
address
The address that will be allowed to spend the balance.
amount
uint256
The amount the spender is allowed to spend.
deadline
uint256
The UNIX time until which the permit is valid.
v
uint8
V part of the permit signature.
r
bytes32
R part of the permit signature.
s
bytes32
S part of the permit signature.
increaseBalances
Increases balances of the provided recipients
by the provided amounts
. Can only be called by the Bridge.
Requirements:
length of
recipients
andamounts
must be the same,none of
recipients
addresses must point to the Bank.
Parameters
recipients
address[]
Balance increase recipients.
amounts
uint256[]
Amounts by which balances are increased.
increaseBalance
Increases balance of the provided recipient
by the provided amount
. Can only be called by the Bridge.
Requirements:
recipient
address must not point to the Bank.
Parameters
recipient
address
Balance increase recipient.
amount
uint256
Amount by which the balance is increased.
increaseBalanceAndCall
Increases the given smart contract vault
's balance and notifies the vault
contract about it. Can be called only by the Bridge.
Requirements:
vault
must implementIVault
interface,length of
recipients
andamounts
must be the same.
Parameters
vault
address
Address of IVault
recipient contract.
recipients
address[]
Balance increase recipients.
amounts
uint256[]
Amounts by which balances are increased.
decreaseBalance
Decreases caller's balance by the provided amount
. There is no way to restore the balance so do not call this function unless you really know what you are doing!
Requirements:
The caller must have a balance of at least
amount
.
Parameters
amount
uint256
The amount by which the balance is decreased.
DOMAIN_SEPARATOR
Returns hash of EIP712 Domain struct with TBTC Bank
as a signing domain and Bank contract as a verifying contract. Used to construct an EIP2612 signature provided to the permit
function.
_increaseBalance
Last updated