0

I am trying to run this API call: https://polygon.api.0x.org/swap/v1/quote?buyToken=0x2e1AD108fF1D8C782fcBbB89AAd783aC49586756&sellToken=0x580a84c73811e1839f75d86d75d88cca0c241ff4&sellAmount=10000000000000000000

This is the full returned value:

{
  "chainId": 137,
  "price": "0.816659249868949659",
  "guaranteedPrice": "0.808492657370260162",
  "estimatedPriceImpact": null,
  "to": "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
  "data": "0x415565b0000000000000000000000000580a84c73811e1839f75d86d75d88cca0c241ff40000000000000000000000002e1ad108ff1d8c782fcbbb89aad783ac495867560000000000000000000000000000000000000000000000008ac7230489e8000000000000000000000000000000000000000000000000000070336de20ca8db9b00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000006c000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000580a84c73811e1839f75d86d75d88cca0c241ff40000000000000000000000008f3cf7ad23cd3cadbd9735aff958023239c6a063000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000002a00000000000000000000000000000000000000000000000008ac7230489e8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000002517569636b53776170000000000000000000000000000000000000000000000000000000000000008ac7230489e800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000a5e0829caced8ffdd4de3c43696c57f7d7a678ff00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000580a84c73811e1839f75d86d75d88cca0c241ff40000000000000000000000008f3cf7ad23cd3cadbd9735aff958023239c6a063000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008f3cf7ad23cd3cadbd9735aff958023239c6a0630000000000000000000000002e1ad108ff1d8c782fcbbb89aad783ac495867560000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000002600000000000000000000000000000000000000000000000000000000000000240ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000001142616c616e6365725632000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000070336de20ca8db9b00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000040000000000000000000000000ba12222222228d8ba445958a75a0704d566bf2c80d34e5dd4d8f043557145598e4e2dc286b35fd4f000000000000000000000068000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000580a84c73811e1839f75d86d75d88cca0c241ff40000000000000000000000008f3cf7ad23cd3cadbd9735aff958023239c6a063000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000000869584cd00000000000000000000000010000000000000000000000000000000000000110000000000000000000000000000000000000000000000782b35e1ff621e96bb",
  "value": "0",
  "gas": "266000",
  "estimatedGas": "266000",
  "gasPrice": "40000000000",
  "protocolFee": "0",
  "minimumProtocolFee": "0",
  "buyTokenAddress": "0x2e1ad108ff1d8c782fcbbb89aad783ac49586756",
  "sellTokenAddress": "0x580a84c73811e1839f75d86d75d88cca0c241ff4",
  "buyAmount": "8166592498689496593",
  "sellAmount": "10000000000000000000",
  "sources": [
    {
      "name": "SushiSwap",
      "proportion": "0"
    },
    {
      "name": "QuickSwap",
      "proportion": "0"
    },
    {
      "name": "ComethSwap",
      "proportion": "0"
    },
    {
      "name": "Dfyn",
      "proportion": "0"
    },
    {
      "name": "mStable",
      "proportion": "0"
    },
    {
      "name": "Curve",
      "proportion": "0"
    },
    {
      "name": "DODO_V2",
      "proportion": "0"
    },
    {
      "name": "DODO",
      "proportion": "0"
    },
    {
      "name": "Curve_V2",
      "proportion": "0"
    },
    {
      "name": "WaultSwap",
      "proportion": "0"
    },
    {
      "name": "Polydex",
      "proportion": "0"
    },
    {
      "name": "ApeSwap",
      "proportion": "0"
    },
    {
      "name": "FirebirdOneSwap",
      "proportion": "0"
    },
    {
      "name": "Balancer_V2",
      "proportion": "0"
    },
    {
      "name": "KyberDMM",
      "proportion": "0"
    },
    {
      "name": "LiquidityProvider",
      "proportion": "0"
    },
    {
      "proportion": "1",
      "intermediateToken": "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",
      "hops": [
        "QuickSwap",
        "Balancer_V2"
      ],
      "name": "MultiHop"
    },
    {
      "name": "JetSwap",
      "proportion": "0"
    },
    {
      "name": "IronSwap",
      "proportion": "0"
    },
    {
      "name": "Aave_V2",
      "proportion": "0"
    },
    {
      "name": "Uniswap_V3",
      "proportion": "0"
    },
    {
      "name": "Synapse",
      "proportion": "0"
    }
  ],
  "orders": [
    {
      "makerToken": "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",
      "takerToken": "0x580a84c73811e1839f75d86d75d88cca0c241ff4",
      "makerAmount": "0",
      "takerAmount": "10000000000000000000",
      "fillData": {
        "tokenAddressPath": [
          "0x580a84c73811e1839f75d86d75d88cca0c241ff4",
          "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063"
        ],
        "router": "0xa5e0829caced8ffdd4de3c43696c57f7d7a678ff"
      },
      "source": "QuickSwap",
      "sourcePathId": "",
      "type": 0
    },
    {
      "makerToken": "0x2e1ad108ff1d8c782fcbbb89aad783ac49586756",
      "takerToken": "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",
      "makerAmount": "8166592498689496593",
      "takerAmount": "115792089237316195423570985008687907853269984665640564039457584007913129639935",
      "fillData": {
        "poolId": "0x0d34e5dd4d8f043557145598e4e2dc286b35fd4f000000000000000000000068",
        "vault": "0xba12222222228d8ba445958a75a0704d566bf2c8"
      },
      "source": "Balancer_V2",
      "sourcePathId": "",
      "type": 0
    }
  ],
  "allowanceTarget": "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
  "sellTokenToEthRate": "1.929673719382614526",
  "buyTokenToEthRate": "0"
}

The issue is for order 0, makerAmount is 0, and for order 1, takerAmount is an exceedingly large number: 115792089237316195423570985008687907853269984665640564039457584007913129639935

Any tips or fixes I can do on my side to avoid such behavior? (It seems only to happen when Multihop is turned on, but that is not a desirable fix for us)

1 Answer 1

1

The values under orders are just informational and legacy at this point. We will be completely removing them in the next major version of 0xAPI.

Everything required to execute the transaction is encoded in the data field.

You are correct that it occurs in MultiHop where the MAX_UINT represents "sell the entire balance" in the middle of a MultiHop trade.

How are you intending to use those values?

2
  • We are using orders to route our swaps at defibasket.org. I explored using the data field, but that would require us to know beforehand the exact buy or sell amounts, which is not always the case.
    – joaoavf
    Mar 2, 2022 at 13:32
  • Jacob, could you share any timelines on when orders will be deprecated? Happy to share my use case in more detail in order to understand if there is a way to keep working with 0x.
    – joaoavf
    Mar 7, 2022 at 20:54

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.