Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CrossChainBridgeBacker.sol _swapCanonicalForAny function #107

Closed
dannywitters opened this issue Nov 18, 2021 · 1 comment
Closed

CrossChainBridgeBacker.sol _swapCanonicalForAny function #107

dannywitters opened this issue Nov 18, 2021 · 1 comment

Comments

@dannywitters
Copy link

dannywitters commented Nov 18, 2021

line 379 - 398 in '/src/hardhat/contracts/Bridges/CrossChainBridgeBacker.sol'

    // Swap canToken for anyToken [GOVERNANCE CALLABLE]
    function swapCanonicalForAny(uint256 token_type, uint256 token_amount) external onlyByOwnGov {
        _swapCanonicalForAny(token_type, token_amount);
    }

    // Swap anyToken for canToken [INTERNAL]
    function _swapCanonicalForAny(uint256 token_type, uint256 token_amount) internal {
        if (token_type == 0) {
            // FRAX
            // Approve and swap
            canFRAX.approve(address(canFRAX), token_amount);
            canFRAX.exchangeCanonicalForOld(address(anyFRAX), token_amount);
        }
        else {
            // FXS
            // Approve and swap
            canFXS.approve(address(canFXS), token_amount);
            canFXS.exchangeCanonicalForOld(address(anyFXS), token_amount);
        }
    }

I think the commented code should be // swap canToken for anyToken [INTERNAL]. But more importantly, shouldn't it be anyFRAX.approve(address(canFRAX), token_amount); and anyFXS.approve(address(canFXS), token_amount);?

@FortisFortuna
Copy link
Contributor

Good catch. I will update the comment. As for the approvals, the function takes in canTokens and gives out anyTokens, so the canTokens are the ones that need to be pulled in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants