-
Notifications
You must be signed in to change notification settings - Fork 201
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
Fix Beethoven X Cache Issue [TKR-486] #519
Conversation
public static createBeethovenXPoolCache(chainId: ChainId): BalancerV2PoolsCache | undefined { | ||
const subgraphUrl = BEETHOVEN_X_SUBGRAPH_URL_BY_CHAIN.get(chainId); | ||
if (subgraphUrl === undefined) { | ||
return undefined; |
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.
What are your thoughts on usage of undefined
versus a default identity like cache that implements PoolCache
but always returns empty results?
It would reduce the flow on effects of it being undefined throughout the rest of the code.
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 like the approach!
I might need to refactor PoolCache a bit more first.
will update the PR.
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.
Actually there are other related cache stuff that I want to modify as well.
Do you mind if I address undefined
vs no-op PoolCache
in a separate PR?
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.
* `BalancerV2PoolsCache` was created regardless of the chain id resulting in unecessary cache update. * Remove `BalancerV2PoolsCache` Balancer mainnet test since it's not used in prod.
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.
Nice, left some nits, looking good to me.
chainId, | ||
BEETHOVEN_X_SUBGRAPH_URL_BY_CHAIN[chainId], | ||
), | ||
[ERC20BridgeSource.Beethovenx]: BalancerV2PoolsCache.createBeethovenXPoolCache(chainId), |
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.
So only Beethovenx
uses BalancerV2PoolsCache
now? Since BalancerV2
uses the newer BalancerV2SwapInfoCache
? If that is the case I'd ultimately recommend a rename.
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.
Yes, that's the case!
I will rename in a follow up PR.
|
||
import { parsePoolData } from './balancer_sor_v2'; | ||
import { CacheValue, PoolsCache } from './pools_cache'; | ||
|
||
const BEETHOVEN_X_SUBGRAPH_URL_BY_CHAIN = new Map<ChainId, string>([ | ||
[ChainId.Fantom, 'https://api.thegraph.com/subgraphs/name/beethovenxfi/beethovenx'], |
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 on the fence about having the config/urls/addresses in files outside of packages/asset-swapper/src/utils/market_operation_utils/constants.ts
. Do you have a preference?
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.
For the constants that are only used in a single place, I prefer those constants to be defined in the same file as it's used and not export
ed.
Ideally, if it's for sampling of a liquidity source, all related constants and logic (router addresses, pool info, gas schedule) are located in a single file specific to that source (when a new source is added, it should be mainly adding a single file vs touching multiple parts of the code base).
Let's discuss more on Slack!
Description
Bug Fix:
Improvements:
BalancerV2PoolsCache
on unsupported chains.BalancerV2PoolsCache
test for Beethoven X.BalancerV2PoolsCache
test for Balancer V2 (no longer used in production).PoolsCacheMap
type.Testing instructions
Types of changes
Checklist:
[WIP]
if necessary.