While working on integrating the Balancer Exchange protocol in my project, I noticed this interface defined in their exchange proxy:

interface TokenInterface {
    function balanceOf(address) external view returns (uint);
    function allowance(address, address) external view returns (uint);
    function approve(address, uint) external returns (bool);
    function transfer(address, uint) external returns (bool);
    function transferFrom(address, address, uint) external returns (bool);
    function deposit() external payable;
    function withdraw(uint) external;

This is almost an ERC-20 interface, but it has two custom functions, deposit and withdraw. The reason why these functions exist is out of scope for this question.

I want to call this function on the exchange proxy:

function smartSwapExactIn(
    TokenInterface tokenIn,
    TokenInterface tokenOut,
    uint256 totalAmountIn,
    uint256 minTotalAmountOut,
    uint256 nPools
) external payable returns (uint256 totalAmountOut);

But I would like to use a vanilla ERC-20 interface instead of this custom TokenInterface when writing my contract.

Here is the tricky part. Balancer has already deployed the exchange proxy at address 0x3E66B66Fd1d0b02fDa6C811Da9E0547970DB2f21. I will do the same thing with my own contract (deploy it at some point), and obviously the compiler won't complain because I used another interface instead of TokenInterface (it can't know what its eventual purpose is).

Will the the protocols "cross swords" when I attempt to call Balancer's smartSwapExactIn function via a contract that defines an interface that is slightly different to TokenInterface for the tokenIn and tokenOut arguments?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.