This deposit function works perfectly. However, when I attempt to call this function from another contract (through an interface), it does all the right transactions, but then reverts at the end, with no message. No indications whatsoever.

Even the sub_calls() for each of the transactions are identical and it doesn't specify where or why it fails. It just reverts it.

Here is the deposit function in the first contract -->

    function deposit (
        address[] calldata depositTokens,
        uint256[] calldata depositAmounts,
        bytes[] calldata swapdata,
        address userAddress
        )  public payable {

        // This calls the lending pool and deposits the tokens for userAddress
        LendingPool(lendingPool).deposit(depositTokens, depositAmounts, userAddress, 0);


This is the second contract function calling the first deposit function -->

     // this is the function within the router that is calling the above deposit function. 
     // it passes msg.sender along so the first contract can send back to user (tx.origin)
     FirstContractInterface(firstContractAddress).deposit(depositTokens, depositTokenAmounts, 
          depositConnectorData, msg.sender);

All of the necessary approvals have been made.

Is there a reason in solidity why this would work being called directly but fail when called with another contract?

  • check LandingPool().deposit() code is there anything that cause it to revert?
    – Calvin
    Commented Mar 22, 2022 at 7:27
  • Have u give it enough gas ? external contract call might not give an accurate gas estimation.
    – Jiaming Li
    Commented Mar 23, 2022 at 7:52
  • 1
    I think it about msg.sender, you may check if it exist in function code. Cause that the thing different when call direct vs call by another contract
    – rived
    Commented Feb 27, 2023 at 3:29

1 Answer 1


it should be an external method to be called from outside.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.