1

i'm getting this error:

Contract "DyDxPool" should be marked as abstract

I have already seen others question like mine and they say that this error pops up because the contract that inherited the other contract didn't declare the functions that are in the inherited contract. The problem is there aren't any function in the contract that i'm inheriting so i'm really confused. If you have any suggestion please help me it would be very useful.

pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";


interface Structs {
    struct Val {
        uint256 value;
    }

    enum ActionType {
        Deposit, // supply tokens
        Withdraw, // borrow tokens
        Transfer, // transfer balance between accounts
        Buy, // buy an amount of some token (externally)
        Sell, // sell an amount of some token (externally)
        Trade, // trade tokens against another account
        Liquidate, // liquidate an undercollateralized or expiring account
        Vaporize, // use excess tokens to zero-out a completely negative account
        Call // send arbitrary data to an address
    }

    enum AssetDenomination {
        Wei // the amount is denominated in wei
    }

    enum AssetReference {
        Delta // the amount is given as a delta from the current value
    }

    struct AssetAmount {
        bool sign; // true if positive
        AssetDenomination denomination;
        AssetReference ref;
        uint256 value;
    }

    struct ActionArgs {
        ActionType actionType;
        uint256 accountId;
        AssetAmount amount;
        uint256 primaryMarketId;
        uint256 secondaryMarketId;
        address otherAddress;
        uint256 otherAccountId;
        bytes data;
    }

    struct Info {
        address owner; // The address that owns the account
        uint256 number; // A nonce that allows a single address to control many accounts
    }

    struct Wei {
        bool sign; // true if positive
        uint256 value;
    }
}

contract DyDxPool is Structs {
    function getAccountWei(Info memory account, uint256 marketId)
        virtual
        public
        view
        returns (Wei memory);

    function operate(Info[] memory, ActionArgs[] memory) virtual public;
}

1 Answer 1

0

The error message says that the DyDxPool contract should be marked as abstract.

An abstract contract is a contract that cannot be instantiated and must be inherited by other contracts.

So, in this case marking the "DyDxPool" contract as abstract should solve the error:

abstract contract DyDxPool is Structs {
    function getAccountWei(Info memory account, uint256 marketId)
        virtual
        public
        view
        returns (Wei memory);

    function operate(Info[] memory, ActionArgs[] memory) virtual public;
}

By marking the contract as abstract, you're telling the compiler that this contract is not meant to be instantiated and can only be used as a base contract to be inherited by other contracts.

Alternatively, you can implement functions with empty blocks that will be enough to solve this error:

abstract contract DyDxPool is Structs {
    function getAccountWei(Info memory account, uint256 marketId)
        virtual
        public
        view
        returns (Wei memory) {}

    function operate(Info[] memory, ActionArgs[] memory) virtual public {}
}

This will solve your problem.

1
  • Thank you very much, this fixed the bug and helped me a lot.
    – Shadq
    Commented Apr 1, 2023 at 18:37

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.