Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross-chain Tokenized Threshold BTC: Generic L2 ERC20 implementation #543

Closed
pdyraga opened this issue Feb 17, 2023 · 0 comments · Fixed by #550
Closed

Cross-chain Tokenized Threshold BTC: Generic L2 ERC20 implementation #543

pdyraga opened this issue Feb 17, 2023 · 0 comments · Fixed by #550
Assignees
Labels
⛓️ solidity Solidity contracts

Comments

@pdyraga
Copy link
Member

pdyraga commented Feb 17, 2023

See #542

The L2/sidechain token will be upgradeable, owned by Threshold Council, will delegate the minting authority to multiple parties, and have a pause functionality for mints and burns. A generic implementation of the token will be provided in the solidity smart contracts directory.

@pdyraga pdyraga added the ⛓️ solidity Solidity contracts label Feb 17, 2023
@pdyraga pdyraga self-assigned this Feb 18, 2023
dimpar added a commit that referenced this issue Feb 27, 2023
…550)

Closes #543 

# The contract

`L2TBTC` is a canonical L2/sidechain token implementation. tBTC token is
minted on L1 and locked there to be moved to L2/sidechain. By deploying
a canonical token on each L2/sidechain, we can ensure the supply of tBTC
remains sacrosanct, while enabling quick, interoperable cross-chain
bridges and localizing ecosystem risk.

This contract is flexible enough to:
- Delegate minting authority to a native bridge on the chain, if
present.
- Delegate minting authority to a short list of ecosystem bridges.
- Have mints and burns paused by any one of n guardians, allowing
avoidance of contagion in case of a chain- or bridge-specific incident.
- Be governed and upgradeable.

The token is burnable by the token holder and supports EIP2612 permits.
Token holder can authorize a transfer of their token with a signature
conforming EIP712 standard instead of 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 governance can recover ERC20
and ERC721 tokens sent mistakenly to `L2TBTC` token contract.

# Testing

All functions defined in `L2TBTC` contract are fully covered with tests.
`L2TBTC` contract inherits from OpenZeppelin contracts and we do not
want to test the framework. At the same time, we need to make sure all
the declared functionalities are exposed by the contract and that they
work. The tests must fail if the contract initialization gets broken or
if one of the OpenZeppelin extensions is dropped from the inheritance.
To make it happen, the tests cover really basic scenarios for the code
implemented in OpenZeppelin ERC20 and extensions.

The tests use `helpers.upgrades.deployProxy` to deploy `L2TBTC` and to
test it as a contract deployed behind a proxy. There is a [small
complication](https://github.com/keep-network/tbtc-v2/pull/550/files/7ae7122334a75cbbcd3a2b117082ad4e5ddde3d3#diff-35dc35185324e88cdeb94aa85d52542cd9bf3fb6b3bddddb2e2fcbf7a42c4ebd)
with this approach that led to opening an issue in our hardhat plugins
repo: keep-network/hardhat-helpers#38.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⛓️ solidity Solidity contracts
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant