Ankr ETH2 Reward Bearing Certificate
ERC20
This contract is an ERC20 token.
Name
Ankr ETH2 Reward Bearing Certificate
Symbol
aETHc
Decimals
18
Total Supply
50,481 aETHc
About link description
ankrETH (aEth) is a cryptocurrency and operates on the Ethereum platform. ankrETH has a current supply of 29,330.034 with 29,330 in circulation. The last known price of ankrETH is 1,886.62361032 USD and is up 0.15 over the last 24 hours. It is currently trading on 2 active market(s) with $14,907.37 traded over the last 24 hours. More information can be found at https://stkr.io/.
Identical Contracts
The following contracts have identical source code.
Stats
Public Functions
27
Event Types
5
Code Size
244,145 bytes
Library Use
Uses SafeMath for uint256.
Uses TypedMemView for bytes.
Uses TypedMemView for bytes29.
Uses ViewBTC for bytes29.
Uses ViewSPV for bytes29.
Events (5) keyboard_arrow_up
Constants (8) keyboard_arrow_up
PERMIT_TYPEHASH Constant
bytes32 help
0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9
State Variables (24) keyboard_arrow_up
Functions
name keyboard_arrow_up
symbol keyboard_arrow_up
decimals keyboard_arrow_up
totalSupply keyboard_arrow_up
balanceOf keyboard_arrow_up
transfer keyboard_arrow_up
Requirements help
Source Code
function transfer(address recipient, uint256 amount)
public
virtual
override
returns (bool)
{
_transfer(_msgSender(), recipient, amount);
return true;
}
allowance keyboard_arrow_up
approve keyboard_arrow_up
Requirements help
Source Code
function approve(address spender, uint256 amount)
public
virtual
override
returns (bool)
{
_approve(_msgSender(), spender, amount);
return true;
}
transferFrom keyboard_arrow_up
Requirements help
Source Code
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(
sender,
_msgSender(),
_allowances[sender][_msgSender()].sub(
amount,
"ERC20: transfer amount exceeds allowance"
)
);
return true;
}
increaseAllowance keyboard_arrow_up
Requirements help
Source Code
function increaseAllowance(address spender, uint256 addedValue)
public
virtual
returns (bool)
{
_approve(
_msgSender(),
spender,
_allowances[_msgSender()][spender].add(addedValue)
);
return true;
}
decreaseAllowance keyboard_arrow_up
Requirements help
Source Code
function decreaseAllowance(address spender, uint256 subtractedValue)
public
virtual
returns (bool)
{
_approve(
_msgSender(),
spender,
_allowances[_msgSender()][spender].sub(
subtractedValue,
"ERC20: decreased allowance below zero"
)
);
return true;
}
cap keyboard_arrow_up
owner keyboard_arrow_up
renounceOwnership keyboard_arrow_up
transferOwnership keyboard_arrow_up
Modifiers help
onlyOwner checks for the following:
Source Code
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
flashMint keyboard_arrow_up
Requirements help
Source Code
function flashMint(uint256 amount, bytes32 data) external override lock {
// do not exceed cap
require(
totalSupply().add(amount) <= BTC_CAP,
"can not borrow more than BTC cap"
);
// mint tokens
_mint(msg.sender, amount);
// hand control to borrower
IBorrower(msg.sender).executeOnFlashMint(amount, data);
uint256 fee = amount.div(devFundDivRate.mul(FEE_FACTOR));
// burn tokens
_burn(msg.sender, amount.add(fee)); // reverts if `msg.sender` does not have enough
_mint(owner(), fee);
emit FlashMint(msg.sender, amount, data, fee);
}
setDevFundDivRate keyboard_arrow_up
initialize keyboard_arrow_up
Parameters help
Modifiers help
initializer checks for the following:
Source Code
function initialize(
address _relay,
address _strudel,
uint256 _minConfs,
uint256 _relayReward
) public initializer {
relay = IRelay(_relay);
strudel = StrudelToken(_strudel);
numConfs = _minConfs;
relayReward = _relayReward;
// chain constructors?
__Flash_init("Strudel BTC", "VBTC");
__ERC20Capped_init(BTC_CAP);
uint256 chainId;
assembly {
chainId := chainid()
}
DOMAIN_SEPARATOR = keccak256(
abi.encode(
keccak256(
"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
),
keccak256(bytes("Strudel BTC")),
keccak256(bytes("1")),
chainId,
address(this)
)
);
}
proofOpReturnAndMint keyboard_arrow_up
Parameters help
Requirements help
Source Code
function proofOpReturnAndMint(
bytes calldata _header,
bytes calldata _proof,
bytes4 _version,
bytes4 _locktime,
uint256 _index,
uint32 _crossingOutputIndex,
bytes calldata _vin,
bytes calldata _vout
) external returns (bool) {
return
_provideProof(
_header,
_proof,
_version,
_locktime,
_index,
_crossingOutputIndex,
_vin,
_vout
);
}
proofP2FSHAndMint keyboard_arrow_up
Parameters help
Source Code
function proofP2FSHAndMint(
bytes calldata _header,
bytes calldata _proof,
uint256 _index,
bytes32 _txid
) external virtual returns (bool) {
require(false, "not implemented");
}
burnFrom keyboard_arrow_up
Requirements help
Source Code
function burnFrom(address _account, uint256 _amount) external {
uint256 decreasedAllowance = allowance(_account, _msgSender()).sub(
_amount,
"ERC20: burn amount exceeds allowance"
);
_approve(_account, _msgSender(), decreasedAllowance);
_burn(_account, _amount);
}
burn keyboard_arrow_up
approveAndCall keyboard_arrow_up
Source Code
function approveAndCall(
ITokenRecipient _spender,
uint256 _value,
bytes calldata _extraData
) external returns (bool) {
// not external to allow bytes memory parameters
if (approve(address(_spender), _value)) {
_spender.receiveApproval(msg.sender, _value, address(this), _extraData);
return true;
}
return false;
}
permit keyboard_arrow_up
Parameters help
Requirements help
Source Code
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external {
require(deadline >= block.timestamp, "vBTC: EXPIRED");
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
DOMAIN_SEPARATOR,
keccak256(
abi.encode(
PERMIT_TYPEHASH,
owner,
spender,
value,
nonces[owner]++,
deadline
)
)
)
);
address recoveredAddress = ecrecover(digest, v, r, s);
require(
recoveredAddress != address(0) && recoveredAddress == owner,
"VBTC: INVALID_SIGNATURE"
);
_approve(owner, spender, value);
}
setRelayReward keyboard_arrow_up
setRelayAddress keyboard_arrow_up
setNumConfs keyboard_arrow_up
Modifiers help
onlyOwner checks for the following:
Source Code
function setNumConfs(uint256 _numConfs) external onlyOwner {
require(_numConfs > 0, "!newNumConfs-0");
require(_numConfs < 100, "!newNumConfs-useless");
numConfs = _numConfs;
}
Internal Functions
Internal functions are parts of the contract that can't be used directly, but instead are used by the public functions listed above.
internal VbtcToken._beforeTokenTransfer keyboard_arrow_up
Source Code
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual override(ERC20CappedUpgradeSafe, ERC20UpgradeSafe) {
super._beforeTokenTransfer(from, to, amount);
}
internal VbtcToken.makeCompressedOutpoint keyboard_arrow_up
Source Code
function makeCompressedOutpoint(bytes32 _txid, uint32 _index)
internal
pure
returns (bytes32)
{
// sacrifice 4 bytes instead of hashing
return ((_txid >> 32) << 32) | bytes32(uint256(_index));
}
internal VbtcToken._checkInclusion keyboard_arrow_up
Parameters help
Source Code
function _checkInclusion(
bytes29 _header, // Header
bytes29 _proof, // MerkleArray
uint256 _index,
bytes32 _txid
) internal view returns (bool) {
// check the txn is included in the header
require(
ViewSPV.prove(_txid, _header.merkleRoot(), _proof, _index),
"Bad inclusion proof"
);
// check the header is included in the chain
bytes32 headerHash = _header.hash256();
bytes32 GCD = relay.getLastReorgCommonAncestor();
require(
relay.isAncestor(headerHash, GCD, 2500),
"GCD does not confirm header"
);
// check offset to tip
bytes32 bestKnownDigest = relay.getBestKnownDigest();
uint256 height = relay.findHeight(headerHash);
require(height > 0, "height not found in relay");
uint256 offset = relay.findHeight(bestKnownDigest).sub(height);
require(offset >= numConfs, "Insufficient confirmations");
return true;
}
internal VbtcToken._provideProof keyboard_arrow_up
Parameters help
Requirements help
Source Code
function _provideProof(
bytes memory _header,
bytes memory _proof,
bytes4 _version,
bytes4 _locktime,
uint256 _index,
uint32 _crossingOutputIndex,
bytes memory _vin,
bytes memory _vout
) internal returns (bool) {
bytes32 txId = abi
.encodePacked(_version, _vin, _vout, _locktime)
.ref(0)
.hash256();
bytes32 outpoint = makeCompressedOutpoint(txId, _crossingOutputIndex);
require(!knownOutpoints[outpoint], "already processed outputs");
_checkInclusion(
_header.ref(0).tryAsHeader().assertValid(),
_proof.ref(0).tryAsMerkleArray().assertValid(),
_index,
txId
);
// mark processed
knownOutpoints[outpoint] = true;
// do payouts
address account;
uint256 amount;
(account, amount) = doPayouts(_vout.ref(0).tryAsVout(), _crossingOutputIndex);
emit Crossing(txId, account, amount, _crossingOutputIndex);
return true;
}
internal VbtcToken.doPayouts keyboard_arrow_up
Requirements help
Source Code
function doPayouts(bytes29 _vout, uint32 _crossingOutputIndex)
internal
returns (address account, uint256 amount)
{
bytes29 output = _vout.indexVout(_crossingOutputIndex);
// extract receiver and address
amount = output.value() * 10**10; // wei / satosh = 10^18 / 10^8 = 10^10
require(amount > 0, "output has 0 value");
bytes29 opReturnPayload = output.scriptPubkey().opReturnPayload();
require(
opReturnPayload.len() == ADDR_LEN + 3,
"invalid op-return payload length"
);
require(
bytes3(opReturnPayload.index(0, 3)) == PROTOCOL_ID,
"invalid protocol id"
);
account = address(bytes20(opReturnPayload.index(3, ADDR_LEN)));
uint256 sqrtVbtcBefore = Babylonian.sqrt(totalSupply());
_mint(account, amount);
uint256 sqrtVbtcAfter = Babylonian.sqrt(totalSupply());
// calculate the reward as area h(x) = f(x) - g(x), where f(x) = x^2 and g(x) = |minted|
// pay out only the delta to the previous claim: H(after) - H(before)
// this caps all minting rewards to 2/3 of BTC_CAP
uint256 rewardAmount = BTC_CAP
.mul(3)
.mul(sqrtVbtcAfter)
.add(sqrtVbtcBefore**3)
.sub(BTC_CAP.mul(3).mul(sqrtVbtcBefore))
.sub(sqrtVbtcAfter**3)
.div(3)
.div(BTC_CAP_SQRT);
strudel.mint(account, rewardAmount);
strudel.mint(owner(), rewardAmount.div(devFundDivRate));
}
internal FlashERC20.__Flash_init keyboard_arrow_up
Modifiers help
initializer checks for the following:
Source Code
function __Flash_init(string memory name, string memory symbol)
internal
initializer
{
devFundDivRate = 17;
_status = _NOT_ENTERED;
__ERC20_init(name, symbol);
__Ownable_init();
}
internal Initializable.isConstructor keyboard_arrow_up
Parameters help
This function has no parameters.
Source Code
function isConstructor() private view returns (bool) {
// extcodesize checks the size of the code stored in an address, and
// address returns the current address. Since the code is still not
// deployed when running a constructor, any checks on its code size will
// yield zero, making it an effective way to detect if a contract is
// under construction or not.
address self = address(this);
uint256 cs;
assembly {
cs := extcodesize(self)
}
return cs == 0;
}
internal ContextUpgradeSafe.__Context_init keyboard_arrow_up
internal ContextUpgradeSafe.__Context_init_unchained keyboard_arrow_up
internal ContextUpgradeSafe._msgSender keyboard_arrow_up
internal ContextUpgradeSafe._msgData keyboard_arrow_up
Parameters help
This function has no parameters.
Source Code
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
internal Initializable.isConstructor keyboard_arrow_up
Parameters help
This function has no parameters.
Source Code
function isConstructor() private view returns (bool) {
// extcodesize checks the size of the code stored in an address, and
// address returns the current address. Since the code is still not
// deployed when running a constructor, any checks on its code size will
// yield zero, making it an effective way to detect if a contract is
// under construction or not.
address self = address(this);
uint256 cs;
assembly {
cs := extcodesize(self)
}
return cs == 0;
}
internal ERC20UpgradeSafe.__ERC20_init keyboard_arrow_up
Modifiers help
initializer checks for the following:
Source Code
function __ERC20_init(string memory name, string memory symbol)
internal
initializer
{
__Context_init_unchained();
__ERC20_init_unchained(name, symbol);
}
internal ERC20UpgradeSafe.__ERC20_init_unchained keyboard_arrow_up
Modifiers help
initializer checks for the following:
Source Code
function __ERC20_init_unchained(string memory name, string memory symbol)
internal
initializer
{
_name = name;
_symbol = symbol;
_decimals = 18;
}
internal ERC20UpgradeSafe._transfer keyboard_arrow_up
Requirements help
Source Code
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(
amount,
"ERC20: transfer amount exceeds balance"
);
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
internal ERC20UpgradeSafe._mint keyboard_arrow_up
Requirements help
Source Code
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
internal ERC20UpgradeSafe._burn keyboard_arrow_up
Requirements help
Source Code
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(
amount,
"ERC20: burn amount exceeds balance"
);
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
internal ERC20UpgradeSafe._approve keyboard_arrow_up
Requirements help
Source Code
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
internal ERC20UpgradeSafe._setupDecimals keyboard_arrow_up
internal ERC20UpgradeSafe._beforeTokenTransfer keyboard_arrow_up
internal Initializable.isConstructor keyboard_arrow_up
Parameters help
This function has no parameters.
Source Code
function isConstructor() private view returns (bool) {
// extcodesize checks the size of the code stored in an address, and
// address returns the current address. Since the code is still not
// deployed when running a constructor, any checks on its code size will
// yield zero, making it an effective way to detect if a contract is
// under construction or not.
address self = address(this);
uint256 cs;
assembly {
cs := extcodesize(self)
}
return cs == 0;
}
internal ContextUpgradeSafe.__Context_init keyboard_arrow_up
internal ContextUpgradeSafe.__Context_init_unchained keyboard_arrow_up
internal ContextUpgradeSafe._msgSender keyboard_arrow_up
internal ContextUpgradeSafe._msgData keyboard_arrow_up
Parameters help
This function has no parameters.
Source Code
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
internal Initializable.isConstructor keyboard_arrow_up
Parameters help
This function has no parameters.
Source Code
function isConstructor() private view returns (bool) {
// extcodesize checks the size of the code stored in an address, and
// address returns the current address. Since the code is still not
// deployed when running a constructor, any checks on its code size will
// yield zero, making it an effective way to detect if a contract is
// under construction or not.
address self = address(this);
uint256 cs;
assembly {
cs := extcodesize(self)
}
return cs == 0;
}
internal OwnableUpgradeSafe.__Ownable_init keyboard_arrow_up
internal OwnableUpgradeSafe.__Ownable_init_unchained keyboard_arrow_up
internal Initializable.isConstructor keyboard_arrow_up
Parameters help
This function has no parameters.
Source Code
function isConstructor() private view returns (bool) {
// extcodesize checks the size of the code stored in an address, and
// address returns the current address. Since the code is still not
// deployed when running a constructor, any checks on its code size will
// yield zero, making it an effective way to detect if a contract is
// under construction or not.
address self = address(this);
uint256 cs;
assembly {
cs := extcodesize(self)
}
return cs == 0;
}
internal ContextUpgradeSafe.__Context_init keyboard_arrow_up
internal ContextUpgradeSafe.__Context_init_unchained keyboard_arrow_up
internal ContextUpgradeSafe._msgSender keyboard_arrow_up
internal ContextUpgradeSafe._msgData keyboard_arrow_up
Parameters help
This function has no parameters.
Source Code
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
internal Initializable.isConstructor keyboard_arrow_up
Parameters help
This function has no parameters.
Source Code
function isConstructor() private view returns (bool) {
// extcodesize checks the size of the code stored in an address, and
// address returns the current address. Since the code is still not
// deployed when running a constructor, any checks on its code size will
// yield zero, making it an effective way to detect if a contract is
// under construction or not.
address self = address(this);
uint256 cs;
assembly {
cs := extcodesize(self)
}
return cs == 0;
}
internal ERC20CappedUpgradeSafe.__ERC20Capped_init keyboard_arrow_up
Modifiers help
initializer checks for the following:
Source Code
function __ERC20Capped_init(uint256 cap) internal initializer {
__Context_init_unchained();
__ERC20Capped_init_unchained(cap);
}
internal ERC20CappedUpgradeSafe.__ERC20Capped_init_unchained keyboard_arrow_up
Modifiers help
initializer checks for the following:
Source Code
function __ERC20Capped_init_unchained(uint256 cap) internal initializer {
require(cap > 0, "ERC20Capped: cap is 0");
_cap = cap;
}
internal ERC20CappedUpgradeSafe._beforeTokenTransfer keyboard_arrow_up
Source Code
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual override {
super._beforeTokenTransfer(from, to, amount);
if (from == address(0)) {
// When minting tokens
require(totalSupply().add(amount) <= _cap, "ERC20Capped: cap exceeded");
}
}
internal Initializable.isConstructor keyboard_arrow_up
Parameters help
This function has no parameters.
Source Code
function isConstructor() private view returns (bool) {
// extcodesize checks the size of the code stored in an address, and
// address returns the current address. Since the code is still not
// deployed when running a constructor, any checks on its code size will
// yield zero, making it an effective way to detect if a contract is
// under construction or not.
address self = address(this);
uint256 cs;
assembly {
cs := extcodesize(self)
}
return cs == 0;
}
internal ERC20UpgradeSafe.__ERC20_init keyboard_arrow_up
Modifiers help
initializer checks for the following:
Source Code
function __ERC20_init(string memory name, string memory symbol)
internal
initializer
{
__Context_init_unchained();
__ERC20_init_unchained(name, symbol);
}
internal ERC20UpgradeSafe.__ERC20_init_unchained keyboard_arrow_up
Modifiers help
initializer checks for the following:
Source Code
function __ERC20_init_unchained(string memory name, string memory symbol)
internal
initializer
{
_name = name;
_symbol = symbol;
_decimals = 18;
}
internal ERC20UpgradeSafe._transfer keyboard_arrow_up
Requirements help
Source Code
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(
amount,
"ERC20: transfer amount exceeds balance"
);
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
internal ERC20UpgradeSafe._mint keyboard_arrow_up
Requirements help
Source Code
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
internal ERC20UpgradeSafe._burn keyboard_arrow_up
Requirements help
Source Code
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(
amount,
"ERC20: burn amount exceeds balance"
);
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
internal ERC20UpgradeSafe._approve keyboard_arrow_up
Requirements help
Source Code
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
internal ERC20UpgradeSafe._setupDecimals keyboard_arrow_up
internal ERC20UpgradeSafe._beforeTokenTransfer keyboard_arrow_up
internal Initializable.isConstructor keyboard_arrow_up
Parameters help
This function has no parameters.
Source Code
function isConstructor() private view returns (bool) {
// extcodesize checks the size of the code stored in an address, and
// address returns the current address. Since the code is still not
// deployed when running a constructor, any checks on its code size will
// yield zero, making it an effective way to detect if a contract is
// under construction or not.
address self = address(this);
uint256 cs;
assembly {
cs := extcodesize(self)
}
return cs == 0;
}
internal ContextUpgradeSafe.__Context_init keyboard_arrow_up
internal ContextUpgradeSafe.__Context_init_unchained keyboard_arrow_up
internal ContextUpgradeSafe._msgSender keyboard_arrow_up
internal ContextUpgradeSafe._msgData keyboard_arrow_up
Parameters help
This function has no parameters.
Source Code
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
internal Initializable.isConstructor keyboard_arrow_up
Parameters help
This function has no parameters.
Source Code
function isConstructor() private view returns (bool) {
// extcodesize checks the size of the code stored in an address, and
// address returns the current address. Since the code is still not
// deployed when running a constructor, any checks on its code size will
// yield zero, making it an effective way to detect if a contract is
// under construction or not.
address self = address(this);
uint256 cs;
assembly {
cs := extcodesize(self)
}
return cs == 0;
}