0

I have a simple Balancer swap contract:

pragma solidity ^0.8.0;

import "@balancer-labs/v2-vault/contracts/interfaces/IVault.sol";
import "@balancer-labs/v2-vault/contracts/interfaces/IFlashLoanRecipient.sol";
import "hardhat/console.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";



 contract balancerSwap is IVault {
    using SafeMath for uint;
    using SafeERC20 for IERC20;
    

    IVault public constant vault =
        IVault(0xBA12222222228d8Ba445958a75a0704d566BF2C8);


    SwapKind public swapKind;
    bytes32 pool_BAL_WETH =
        0x35c264f24f3a2fb0b9025905d3bbf10874b055aa0001000000000000000002c4;
   

    address sender0 = address(this);
    address payable addr0 = payable(address(this));
    IAsset tokenBal = IAsset(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599);
    IAsset tokenWeth = IAsset(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);

    SingleSwap public singleSwap;
    FundManagement public funds;


    uint256 deadline = block.timestamp;
    uint256 limit = 1;

    function Main(uint256 _amount) external {
        funds = FundManagement(sender0, false, addr0, false);
        singleSwap = SingleSwap(
            pool_BAL_WETH,
            SwapKind.GIVEN_IN,
            tokenBal,
            tokenWeth,
            _amount,
            "0x"
        );
        IERC20(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599).safeApprove(address(vault), _amount);
        uint256 result = vault.swap(singleSwap, funds, limit, deadline);
        console.log(result);
    }

    
    
}

It should work but Solidity tells me that this contract is Abstract. And it offers me to fix this problem by coping all the functions from IVault.sol. I don't use all this functions from IVault in my contract so is there any way to solve this problem without coping functions that I don't use?

1 Answer 1

0

There may some functions in interface that you imported should be implemented, but if you don't want to use all of the functions in IVault, you can delete some unused function in interface. You can write the interfaces by copy functions you want from IVault, instead of import completed IVault from Balancer.

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.