What does this call to IERC20 actually do?

Trying to redo some code in Vyper & IERC20 use in Solidity is simple, but remaking the same functionality seems hard in Vyper. Which is stopping the whole thing from working.

 function depositERC20(
    IERC20 token, <---- What does this actually do?
    uint256 amount,
    address receiverAddress,
    uint256 targetChainId
  ) external payable;

Trying to use self, or even remaking the IER20 doesn't seem to work. Calling IERC20 seems to return the contract address?

    @external
    def depositERC20(token: self, amount: uint256, receiverAddress: address, targetChainId: uint256): payable

I just need to work out what does IERC20 do in this instance & how do I work out how to send the same thing in Vyper.

Also, please make Vyper interfaces :wink:

interface IERC20:
    @external
    def totalSupply() -> uint256: view
    @external
    def balanceOf(account: address) -> uint256: view 
    @external
    def transfer(to: address, amount: uint256) -> bool: payable
    @external 
    def allowance(owner: address, spender: address) -> uint256: view
    @external
    def approve(spender: address, amount: uint256) -> bool: view
    @external 
    def transferFrom(transferFrom: address, to: address, amount: uint256) -> bool: payable

I tried making IERC20 in Vyper & then doing this, but didn't work.

  @external
    def depositERC20(token: IERC20, amount: uint256, receiverAddress: address, targetChainId: uint256): payable

function abc(IERC20 t) external { /*...*/ } is just syntactic sugar for

function abc(address t) external {
    IERC20 _t = IERC20(t);
    /* ... */
}

When calling this function from a EOA, argument is an address. When calling it from another contract, solidity does type-checking but uses the address (calldata is formatted in the same way)

Don't really know Vyper but

@external
    def depositERC20(token: IERC20, amount: uint256, receiverAddress: address, targetChainId: uint256): payable

seems to be correct. Maybe Vyper doesn't allow you to pass interface types as arguments ?

1 Like

Thanks! turns out i found a bug.

1 Like