Skip to content

Conversation

1up1n
Copy link

@1up1n 1up1n commented Aug 8, 2025

No description provided.

@1up1n 1up1n force-pushed the pathfinding-algorithm branch from f778514 to 297be78 Compare August 8, 2025 04:25
}

scale := math.Pow10(int(decimals))
minUnits := int64(math.Ceil((minThresholdUsd / price) * scale))
Copy link
Member

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 {
Copy link
Member

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)
Copy link
Member

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,
Copy link
Member

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).

Copy link
Member

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.

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.

2 participants