{
    "Function": "startBridgeTokensViaCBridge",
    "File": "src/Facets/CBridgeFacet.sol",
    "Parent Contracts": [
        "src/Facets/Swapper.sol",
        "src/Interfaces/ILiFi.sol"
    ],
    "High-Level Calls": [
        "LibAsset",
        "LibAsset",
        "LibAsset"
    ],
    "Internal Calls": [
        "require(bool,string)",
        "require(bool,string)",
        "_startBridge"
    ],
    "Library Calls": [
        "getOwnBalance",
        "transferFromERC20",
        "getOwnBalance"
    ],
    "Low-Level Calls": [],
    "Code": "function startBridgeTokensViaCBridge(LiFiData memory _lifiData, CBridgeData calldata _cBridgeData) public payable {\n        if (_cBridgeData.token != address(0)) {\n            uint256 _fromTokenBalance = LibAsset.getOwnBalance(_cBridgeData.token);\n\n            LibAsset.transferFromERC20(_cBridgeData.token, msg.sender, address(this), _cBridgeData.amount);\n\n            require(\n                LibAsset.getOwnBalance(_cBridgeData.token) - _fromTokenBalance == _cBridgeData.amount,\n                \"ERR_INVALID_AMOUNT\"\n            );\n        } else {\n            require(msg.value >= _cBridgeData.amount, \"ERR_INVALID_AMOUNT\");\n        }\n\n        _startBridge(_cBridgeData);\n\n        emit LiFiTransferStarted(\n            _lifiData.transactionId,\n            _lifiData.integrator,\n            _lifiData.referrer,\n            _lifiData.sendingAssetId,\n            _lifiData.receivingAssetId,\n            _lifiData.receiver,\n            _lifiData.amount,\n            _lifiData.destinationChainId,\n            block.timestamp\n        );\n    }"
}