0

I wants to deposit & withdrawal DAI
(https://kovan.etherscan.io/address/0xc4375b7de8af5a38a93548eb8453a498222c4ff2)
to SOLO Margin(dydx) smart Contract at Kovan testnet (https://kovan.etherscan.io/address/0x4EC3570cADaAEE08Ae384779B0f3A45EF85289DE)
the whole code of solo margin can be seen on the mainnet at (https://etherscan.io/address/0x1e0447b19bb6ecfdae1e4ae1694b0c3659614e4e#code)
interacting it via the following contract which is deployed at (https://kovan.etherscan.io/address/0xc3d5d60630bc63eb1a07228cc5028cada1cc4c7b)

but while trying to deposit DAI with following parameters and after approval & allowance enter image description here
where the account is my account address with account id default to 0 amount is 1 dai in wei/wad ,market is the marketID which represents dai, isDeposit true means trying to deposit otherwise false for withdrawal but then also the following error persists enter image description here
at tranaction-: https://kovan.etherscan.io/tx/0x229c660fe0c3e851f8ca5d9956086650cfd5ee8df0fc70dc03b98021f45c9cc7

pragma solidity 0.5.8;
    pragma experimental ABIEncoderV2;


    library Account {
        struct Info {
            address owner;
            uint256 number;
        }
    }

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

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

        enum AssetReference {
            Delta, // the amount is given as a delta from the current value
            Target // the amount is given as an exact number to end up at
        }

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

    library Actions {
        enum ActionType {
            Deposit,   // supply tokens
            Withdraw  // borrow tokens TODO why comment is borrow?
        }

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

    contract SoloMargin {
        struct OperatorArg {
            address operator;
            bool trusted;
        }

        function operate(Account.Info[] memory accounts, Actions.ActionArgs[] memory actions) public;
        function getAccountWei(Account.Info memory account, uint256 marketId) public view returns (Types.Wei memory);
        function setOperators(OperatorArg[] memory args) public;

        function getMarketTokenAddress(
            uint256 marketId
        )
            public
            view
            returns (address);

        function getIsLocalOperator(
            address owner,
            address operator
        )
            public
            view
            returns (bool);
    }

    contract SoloTest
    {
        address sm; // SoloMargin contract address

        Account.Info[] accounts;
        Actions.ActionArgs[] actions;

        constructor(address soloMargin) public {
            sm = soloMargin;
        }

        function operate(Account.Info memory account, uint amount, uint market, bool isDeposit) public
        {
            bytes memory data;

            Actions.ActionArgs memory action = Actions.ActionArgs({
                actionType: isDeposit ? Actions.ActionType.Deposit : Actions.ActionType.Withdraw,
                amount: Types.AssetAmount({
                    sign: isDeposit,
                    denomination: Types.AssetDenomination.Wei,
                    ref: Types.AssetReference.Delta,
                    value: amount
                }),
                primaryMarketId: market,
                otherAddress: msg.sender,
                accountId: 0,
                secondaryMarketId: 0,
                otherAccountId: 0,
                data: data
            });

            if (accounts.length > 0) {
                accounts[0] = account;
                actions[0] = action;
            } else {
                accounts.push(account);
                actions.push(action);
            }

            SoloMargin(sm).operate(accounts, actions);
        }
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.