protocol-solidity
protocol-solidity copied to clipboard
Token Ownership/Approval/Minting Rights in the VAnchor
Flow for ERC20s
- Unwrapped ERC20 token is deposited via the
wrapAndDepositERC20
function on theMultiAssetVAnchor.sol
contract. - The
wrapAndDepositERC20
function takes in thefromTokenAddress
which is the address of the unwrapped ERC20 contract and thetoTokenAddress
which is the address of the wrapped ERC20 contract. - This calls the
wrapForAndSendTo
method on theTokenWrapper.sol
contract. The unwrapped ERC20 tokens being deposited are transferred to theFungibleTokenWrapper
and wrapped ERC20 tokens are minted to theMultiAssetVAnchor
.
In the diagram below a -> b
means a
is owned by b
.
Security, etc.
- If minting right of
ERC20PresetMinterPauser
is not properly tranferred...the deployer of theFungibleTokenWrapper
can mint infinite wrapped tokens to themselves. Solution: Need to transfer minting rights to theMultiAssetVAnchor
.
Approvals
It is possible for an ERC20 token owner, Alice, to approve a spender, Bob, to spend a certain number of tokens (known as the allowance) on her behalf. In the Webb private asset transfer system, this pattern is used in the following places:
- When a user deposits unwrapped ERC20 tokens, they don't directly
transfer
the tokens to theFungibleTokenWrapper
. Rather each user mustapprove
theFungibleTokenWrapper
to be able to spend the unwrapped ERC20 tokens on their behalf. So something like this is not quite right. - In the scenario, in which the user
deposit
s already wrapped tokens, the user needs toapprove
theVAnchor
to spend wrapped tokens.