{
    "Function": "swapTo",
    "File": "contracts/Pool.sol",
    "Parent Contracts": [
        "contracts/interfaces/iBEP20.sol"
    ],
    "High-Level Calls": [
        "iBEP20"
    ],
    "Internal Calls": [
        "_getAddedBaseAmount",
        "_getAddedTokenAmount",
        "_swapBaseToToken",
        "require(bool,string)",
        "_swapTokenToBase"
    ],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "function swapTo(address token, address member) public payable returns (uint outputAmount, uint fee) {\n        require((token == BASE || token == TOKEN), \"!BASE||TOKEN\"); // Must be SPARTA or the pool's relevant TOKEN\n        address _fromToken; uint _amount;\n        if(token == BASE){\n            _fromToken = TOKEN; // If SPARTA is selected; swap from TOKEN\n            _amount = _getAddedTokenAmount(); // Get the received TOKEN amount\n            (outputAmount, fee) = _swapTokenToBase(_amount); // Calculate the SPARTA output from the swap\n        } else {\n            _fromToken = BASE; // If TOKEN is selected; swap from SPARTA\n            _amount = _getAddedBaseAmount(); // Get the received SPARTA amount\n            (outputAmount, fee) = _swapBaseToToken(_amount); // Calculate the TOKEN output from the swap\n        }\n        emit Swapped(_fromToken, token, member, _amount, outputAmount, fee);\n        iBEP20(token).transfer(member, outputAmount); // Transfer the swap output to the selected user\n        return (outputAmount, fee);\n    }"
}