Skip to content

Conversation

cgewecke
Copy link
Contributor

@cgewecke cgewecke commented Oct 6, 2021

Especially on Polygon, CoinGecko price requests return an empty object for some (liquid) tokens, crashing the quote API

In the initial TradeQuoter review Alex suggested we set the price as 0 when this happens as a way of failing gracefully. (#61).

Would that work for set-ui, or is there a more convenient default value?

Example response with zero values:

{
  from: '0x1494ca1f11d487c2bbe4543e90080aeba4ba3c2b',
  fromTokenAddress: '0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2',
  toTokenAddress: '0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2',
  exchangeAdapterName: 'ZeroExApiAdapterV4',
  calldata: '0x415565b00000000000000000000000009f8f72aa9304c8b593d555f12ef6589cc3a579a2',
  gas: '315000',
  gasPrice: '61',
  slippagePercentage: '2.00%',
  fromTokenAmount: '1126868991563',
  toTokenAmount: '90314741816',
  display: {
    inputAmountRaw: '.5',
    inputAmount: '500000000000000000',
    quoteAmount: '499999999999793729',
    fromTokenDisplayAmount: '0.4999999999997937',
    toTokenDisplayAmount: '0.04131269116050703',
+    fromTokenPriceUsd: '$0.00', 
+    toTokenPriceUsd: '$0.00', 
+    gasCostsUsd: '$0.00', 
    gasCostsChainCurrency: '0.0192150 ETH',
    feePercentage: '1.00%',
+    slippage: '0.00%', 
  },
},

@cgewecke cgewecke requested a review from justinkchen October 6, 2021 15:50
@asoong
Copy link
Contributor

asoong commented Oct 6, 2021

This is fine for now, something to add as an issue:

  • We don't want this to block the quote generation, but we want to provide a signal that one or more of the dependencies may be inaccurate
  • We should be able to capture some kind of status on the API calls each time a dependency is down, adding a new field for each dependency so the consumer knows which data may be using defaults

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants