API Issues
To help provide developers a smooth build experience, 0x API v2 will do as much validation as it can and report all issues it finds in the issues
object in the API reponse.
This object returns a list of potential validation issues detected with the quote. In rare cases where we are unable to validate the quote, we’ll return true
in issues.simulationIncomplete
. We strongly encourage using this object to provide the best experience for your users.
// Sample response from /swap/permit2/quote highlighting the issues object
...
"issues":{
"allowance":{
"actual":"0",
"spender":"0x000000000022d473030f116ddee9f6b43ac78ba3"
},
"balance":{
"token":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"actual":"0",
"expected":"100000000"
},
"simulationIncomplete":false,
"invalidSourcesPassed": [ ]
},
...
Issues Types​
Today, there are 4 types of issues that can be returned for /price
and /quote
in API v2
allowance
: When thetaker
does not have sufficient allowance to the target contract, this returns the details required for the swap to execute. Otherwise, it will be set asnull
.balance
: When thetaker
does not have sufficient balance of the sell token, this returns the details required for the swap to execute. Otherwise, it will be set asnull
.simulationIncomplete
: Set totrue
when 0x cannot validate the transaction. This happens when thetaker
has an insufficient balance of thesellToken
and 0x is unable to peform ehanced quote validation with the low balance. Note that this does not necessarily mean that the trade will revert.invalidSourcesPassed
: a list of invalid sources present inexcludedSources
- Valid list of source names will be available in
GET /sources
- Valid list of source names will be available in
Below is a screenshot summarizing the API issues. See the latest details in response sections of the API references:
Guidance on Using the Issues Object​
Note the following about the issues
object for Price and Quote:
Price
allowance
: If this field is notnull
, prompt the user to set the allowance.balance
: If this field is notnull
, do not proceed to get aquote
.simulationIncomplete
: This field can be ignored forprice
since when calling price means aren't close to submitting a transaction (versus calling quote). TypicallysimulationIncomplete: true
won't occur if thetaker
address is set and thetaker
has a sufficient balance of the sell token.
Quote
allowance
: This field should not appear if thequote
is sent after the token allowance is set.balance
: This field will not be returned if the taker has sufficient balance when thequote
request is sent.simulationIncomplete: true
: This field will not be returned if the taker has sufficient balance when thequote
request is sent.