-
Notifications
You must be signed in to change notification settings - Fork 54
[USD Price] Add coingecko api and hooks #1356
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm i can see it 🤔 not able to get the non-price impact. let me keep trying |
I see it now 🤷 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const fiatValueOutput = useUSDCValue(trade.outputAmountWithoutFee) | ||
// const fiatValueInput = useUSDCValue(trade.inputAmountWithoutFee) | ||
// const fiatValueOutput = useUSDCValue(trade.outputAmountWithoutFee) | ||
const fiatValueInput = useHigherUSDValue(trade.inputAmountWithoutFee) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
higher or highest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well technically "highest" would mean just that, the "highest" whereas "higher" implies of the choices given, which is "highest"
but yes it's very nitpicky here. happy to change it to whatever we like best @alfetopito @Anxo @nenadV91
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whatever
tokenAddress, | ||
}) | ||
.then(toPriceInformation) | ||
.then((response) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just curious, why do you expose the original data instead of just the, priceInformation directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This response
i think is to generic name. maybe priceInfo
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it was because in the other APIs it's done similarly ( i think ) - and for paraswap there are other useful props that could posisbly want to be used elsewhere before the priceInformation
schema mapping. In the case of coingecko there isn't any useful info so i could change the fn directly 👍
const coingeckoUsdPrice = useCoingeckoUSDValue({ | ||
tokenAddress: currencyAmount ? currencyId(currencyAmount.currency) : '', | ||
currencyAmount, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have any kind of timeout logic? probably not for this PR, also less important than other things, but maybe good to track it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm able to see price impact now.
BTW, there is an issue related to DAI token estimation #1363
I could the the price impact once I did a hard refresh. I came across this issue additionally to #1363 |
ca86e75
to
4e6b850
Compare
* coingecko api * coingecko usd hooks * use in swapmod * replace useUSDCValue with useHigherUSDValue * comment * mod computeFiatValue fn * made dumb comp * smarter container * naming * remove unnecessary mod * parse usd price from API as USDC * fix infiniLoop (TM) * remove trans from priceImpact * fix baseAmount
* coingecko api * coingecko usd hooks * use in swapmod * replace useUSDCValue with useHigherUSDValue * comment * mod computeFiatValue fn * made dumb comp * smarter container * naming * remove unnecessary mod * parse usd price from API as USDC * fix infiniLoop (TM) * remove trans from priceImpact * fix baseAmount
Summary
Adds Coingecko as a source for USD estimation on tokens to MAINNET and XDAI (no rinkeby or other test nets)
Currently it is part of a hook that get the GREATER of the 2 USD prices from USDC estimation vs Coingecko api resp. This can be discussed.
You can see in the logs the price found by coingecko:

To Test
Next potentially
i. paraswap blocks swap button if price impact is -15%
ii. if we get a returned USD price of -15% OR if we get no estimation and a bad A -> B -> A slippage then also block