0

sometimes I am confused of how solidity works.

For example in this case:

function claimAssetsFromBridge(
    bytes calldata message,
    bytes calldata attestation
) public {
    IMessageTransmitter(circleTokenMessengerAddress).receiveMessage(
        message,
        attestation
    ); // returns bool
    _assetsAllocation();
}

function _assetsAllocation() internal {
    uint256 blanceUsdcNode = IERC20(tokenUSDC).balanceOf(address(this));
    address pool = _getPool();

    IERC20(tokenUSDC).approve(pool, blanceUsdcNode);
    IPool(pool).deposit(tokenUSDC, blanceUsdcNode, address(this), 0);
}

If initial balance of the contract is 0, and I call claimAssetsFromBridge, I dont really know if blanceUsdcNode will be the balance coming from the bridge or it will be 0??.

1 Answer 1

4

Here's a breakdown of what could have happened and why the final blanceUsdcNode might be 0:

claimAssetsFromBridge:

This function makes a call to IMessageTransmitter.receiveMessage which likely interacts with the bridge but doesn't directly transfer USDC tokens into the contract. The return value (bool) might indicate success or failure of the bridge interaction, but it doesn't guarantee USDC transfer. So in case, if it outcome is false it won't increase the balance.

Additionally, To understand definitively where the USDC comes from, you'd need to examine the implementation of IMessageTransmitter.receiveMessage and potentially other related functions.

1
  • Now i understad If I require (IMessageTransmitter) then blance is correct, if i dont then blance is 0, Thanks mate Apr 18 at 19:56

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.