protocol-solidity icon indicating copy to clipboard operation
protocol-solidity copied to clipboard

Token Ownership/Approval/Minting Rights in the VAnchor

Open akileshtangella opened this issue 2 years ago • 0 comments

Flow for ERC20s

  1. Unwrapped ERC20 token is deposited via the wrapAndDepositERC20 function on the MultiAssetVAnchor.sol contract.
  2. The wrapAndDepositERC20 function takes in the fromTokenAddress which is the address of the unwrapped ERC20 contract and the toTokenAddress which is the address of the wrapped ERC20 contract.
  3. This calls the wrapForAndSendTo method on the TokenWrapper.sol contract. The unwrapped ERC20 tokens being deposited are transferred to the FungibleTokenWrapper and wrapped ERC20 tokens are minted to the MultiAssetVAnchor.

In the diagram below a -> b means a is owned by b. image

Security, etc.

  1. If minting right of ERC20PresetMinterPauser is not properly tranferred...the deployer of the FungibleTokenWrapper can mint infinite wrapped tokens to themselves. Solution: Need to transfer minting rights to the MultiAssetVAnchor.

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 the FungibleTokenWrapper. Rather each user must approve the FungibleTokenWrapper 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 deposits already wrapped tokens, the user needs to approve the VAnchor to spend wrapped tokens.

akileshtangella avatar Dec 02 '22 23:12 akileshtangella