-
Notifications
You must be signed in to change notification settings - Fork 9
feat: build pathfinding lib #159
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
base: main
Are you sure you want to change the base?
Conversation
f778514
to
297be78
Compare
} | ||
|
||
scale := math.Pow10(int(decimals)) | ||
minUnits := int64(math.Ceil((minThresholdUsd / price) * scale)) |
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 can be very big (can greater than max int64). I think should use the normal way to split amount.
- Convert input amount into usd
- Calculate number of splits by divide input amount in usd to minThresholdUSD
- Pick the smaller amount between input numSplits and calculated numSplits.
numSplits uint64, | ||
minThresholdUSD float64, | ||
) *entity.Hop { | ||
if len(pools) == 0 || amountIn.Sign() <= 0 || numSplits == 0 { |
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.
Should return error
continue | ||
} | ||
|
||
isolatedPools := isolated.NewIsolatedPools(pools) |
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.
Why need to create new isolatedPools each time generate new path?
func (f *Finder) FindBestPathsOptimized( | ||
params *entity.FinderParams, | ||
minHops map[string]uint64, | ||
edges map[string]map[string][]dexlibPool.IPoolSimulator, |
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.
We need to maintains pools' state across multiple find paths run, so can use technique like pathfinder-lib
currently use (SimulationBucket).
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.
Also, need to take care for swap limits.
No description provided.