-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Moved fee estimation and profitability calculation to /core
#82
Conversation
We have to move them to the And, as always, it's better to cache lower-level function that does the fetching ( |
The functions to calculate the fee etc are already in the core. The store only temporary saves them for auction injecting, but all of the needed functions are already in the core. https://github.com/sidestream-tech/unified-auctions-ui/blob/main/core/src/fees.ts Or am I mistaken here? |
Perfect, then let's add cache and get rid of the store? |
core/src/fees.ts
Outdated
export const getApproximateTransactionFees = memoizee(_getApproximateTransactionFees, { | ||
maxAge: TRANSACTION_FEE_CACHE, | ||
promise: true, | ||
length: 1, | ||
}); |
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.
-
As suggested above: can you please cache actual function that fetches gas price instead (and please use smaller cache, something like 10 seconds)?
-
getExchangeRateBySymbol
is already cached, as far as I remember, so you wouldn't need to cache cached output, otherwise it can pile up
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.
- As suggested above: can you please cache actual function that fetches gas price instead (and please use smaller cache, something like 10 seconds)?
- Cached the Gas price for 10 seconds
- Removed cache on parent function
core/src/gas.ts
Outdated
|
||
const API_URL = 'https://ethgasstation.info/json/ethgasAPI.json'; | ||
const TRANSACTION_SPEED = 'fast'; | ||
|
||
const getCurrentGasPrice = async function (): Promise<BigNumber> { | ||
const GAS_CACHE = 10 * 60 * 1000; |
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.
That is 10 minutes 😅
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.
Oh god.. Hahaha
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 set it to 10 seconds now!
closes #80
After some trying around I decided to only
memoizee
the functions. Moving them out of the store would require a larger rewrite of how they are imported and merged into the Auction Transaction.If this is not okay, then I can sit down and refractor them too!