0

Im trying to exchange ETH to DAI, but Im getting an error : https://ropsten.etherscan.io/tx/0x19d2c3e8cd6bb1d4fa2da99f0a47de1c616b4d091f37d15f0a705ac784edb65e What am I doing wrong ? I tried to compare it to a working transaction

Request:

buyToken: 0xc715abcd34c8ed9ebbf95990e0c43401fbbc122d
sellToken: 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
sellAmount: 10000000000000000
takeAddress: 0xf5a64ea4fb8dff2b40450cd2016372c89e5e2ded
slippagePercentage: 0.027000000000000003
skipValidation: true

Response:

{
    "chainId": 3,
    "price": "4241.8966555520202953",
    "guaranteedPrice": "4127.3654458521157473",
    "estimatedPriceImpact": "0",
    "to": "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
    "data": "0x415565b0000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000c715abcd34c8ed9ebbf95990e0c43401fbbc122d000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000023cc97a0d865eff6100000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000460000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c778417e063141139fce010982780140aa0cd5ab000000000000000000000000c715abcd34c8ed9ebbf95990e0c43401fbbc122d000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000012556e6973776170563300000000000000000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000023cc97a0d865eff61000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000e592427a0aece92de3edee1f18e0157c058615640000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002bc778417e063141139fce010982780140aa0cd5ab000bb8c715abcd34c8ed9ebbf95990e0c43401fbbc122d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c778417e063141139fce010982780140aa0cd5ab000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000000869584cd000000000000000000000000100000000000000000000000000000000000001100000000000000000000000000000000000000000000006aa766f2eb623a0341",
    "value": "10000000000000000",
    "gas": "149965",
    "estimatedGas": "149965",
    "gasPrice": "4000000000",
    "protocolFee": "0",
    "minimumProtocolFee": "0",
    "buyTokenAddress": "0xc715abcd34c8ed9ebbf95990e0c43401fbbc122d",
    "sellTokenAddress": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
    "buyAmount": "42418966555520202953",
    "sellAmount": "10000000000000000",
    "sources": [{
        "name": "Kyber",
        "proportion": "0"
    }, {
        "name": "0x",
        "proportion": "0"
    }, {
        "name": "SushiSwap",
        "proportion": "0"
    }, {
        "name": "Uniswap",
        "proportion": "0"
    }, {
        "name": "Uniswap_V2",
        "proportion": "0"
    }, {
        "name": "Uniswap_V3",
        "proportion": "1"
    }, {
        "name": "Curve",
        "proportion": "0"
    }, {
        "name": "Mooniswap",
        "proportion": "0"
    }],
    "orders": [{
        "makerToken": "0xc715abcd34c8ed9ebbf95990e0c43401fbbc122d",
        "takerToken": "0xc778417e063141139fce010982780140aa0cd5ab",
        "makerAmount": "42418966555520202953",
        "takerAmount": "10000000000000000",
        "fillData": {
            "router": "0xe592427a0aece92de3edee1f18e0157c05861564",
            "tokenAddressPath": ["0xc778417e063141139fce010982780140aa0cd5ab", "0xc715abcd34c8ed9ebbf95990e0c43401fbbc122d"],
            "uniswapPath": "0xc778417e063141139fce010982780140aa0cd5ab000bb8c715abcd34c8ed9ebbf95990e0c43401fbbc122d",
            "gasUsed": 64965
        },
        "source": "Uniswap_V3",
        "sourcePathId": "0xac8bbf4304525b617983fe7fd5a01469908809116bac0ef721423c1d662c4137",
        "type": 0
    }],
    "allowanceTarget": "0x0000000000000000000000000000000000000000",
    "sellTokenToEthRate": "1",
    "buyTokenToEthRate": "235.752005730940250098"
}

UPDATE: Gas limit was too low (it is directly fetched from the 0x api). As you can see in the response its "gas": "149965", but it should be higher (300K wei approx). Even without setting the skipValidation to true, it still gives the same result.

https://ropsten.api.0x.org/swap/v1/quote?sellToken=ETH&buyToken=0xad6d458402f60fd3bd25163575031acdce07538d&sellAmount=100000000000000000&takerAddress=0xf5a64ea4fb8dff2b40450cd2016372c89e5e2ded

vs

https://ropsten.api.0x.org/swap/v1/quote?buyToken=0xad6d458402f60fd3bd25163575031acdce07538d&sellToken=ETH&sellAmount=100000000000000000&takeAddress=0xf5a64ea4fb8dff2b40450cd2016372c89e5e2ded

does order matter?

UPDATE: takerAddress was miswritten (takeAddress)

1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Mar 22, 2022 at 18:28

1 Answer 1

0

takerAddress was miswritten (takeAddress)

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.