@alcorexchange/alcor-swap-sdk 1.0.396 → 1.0.397

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,7 +63,7 @@ function getBestSwapRoute(routeType, percentToQuotes, percents) {
63
63
  } = swapRouteConfig;
64
64
 
65
65
  // Проверяем наличие маршрута для 100% и инициализируем начальные данные
66
- if (!percentToSortedQuotes[100] || minSplits > 1) {
66
+ if (!percentToSortedQuotes[100] || percentToSortedQuotes[100].length === 0 || minSplits > 1) {
67
67
  console.log('Did not find a valid route without any splits. Continuing search anyway.');
68
68
  } else {
69
69
  bestQuote = percentToSortedQuotes[100][0].outputAmount;
@@ -83,7 +83,7 @@ function getBestSwapRoute(routeType, percentToQuotes, percents) {
83
83
  // Инициализируем очередь с топ-2 маршрутами для каждого процента
84
84
  for (let i = percents.length - 1; i >= 0; i--) {
85
85
  const percent = percents[i];
86
- if (!percentToSortedQuotes[percent]) continue;
86
+ if (!percentToSortedQuotes[percent] || percentToSortedQuotes[percent].length === 0) continue;
87
87
  const topRoutes = percentToSortedQuotes[percent].slice(0, 2);
88
88
  if (topRoutes[0]) {
89
89
  queue.enqueue({
@@ -126,7 +126,7 @@ function getBestSwapRoute(routeType, percentToQuotes, percents) {
126
126
  for (let i = percentIndex; i >= 0; i--) {
127
127
  const percentA = percents[i];
128
128
  if (percentA > remainingPercent) continue;
129
- if (!percentToSortedQuotes[percentA]) continue;
129
+ if (!percentToSortedQuotes[percentA] || percentToSortedQuotes[percentA].length === 0) continue;
130
130
  const candidateRoutesA = percentToSortedQuotes[percentA];
131
131
  const routeWithQuoteA = findFirstRouteNotUsingUsedPools(curRoutes, candidateRoutesA, routeToMask);
132
132
  if (!routeWithQuoteA) continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alcorexchange/alcor-swap-sdk",
3
- "version": "1.0.396",
3
+ "version": "1.0.397",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
@@ -74,7 +74,7 @@ export function getBestSwapRoute(
74
74
  const { minSplits, maxSplits } = swapRouteConfig;
75
75
 
76
76
  // Проверяем наличие маршрута для 100% и инициализируем начальные данные
77
- if (!percentToSortedQuotes[100] || minSplits > 1) {
77
+ if (!percentToSortedQuotes[100] || percentToSortedQuotes[100].length === 0 || minSplits > 1) {
78
78
  console.log('Did not find a valid route without any splits. Continuing search anyway.');
79
79
  } else {
80
80
  bestQuote = percentToSortedQuotes[100][0].outputAmount;
@@ -101,7 +101,7 @@ export function getBestSwapRoute(
101
101
  // Инициализируем очередь с топ-2 маршрутами для каждого процента
102
102
  for (let i = percents.length - 1; i >= 0; i--) {
103
103
  const percent = percents[i];
104
- if (!percentToSortedQuotes[percent]) continue;
104
+ if (!percentToSortedQuotes[percent] || percentToSortedQuotes[percent].length === 0) continue;
105
105
 
106
106
  const topRoutes = percentToSortedQuotes[percent].slice(0, 2);
107
107
  if (topRoutes[0]) {
@@ -147,7 +147,7 @@ export function getBestSwapRoute(
147
147
  for (let i = percentIndex; i >= 0; i--) {
148
148
  const percentA = percents[i];
149
149
  if (percentA > remainingPercent) continue;
150
- if (!percentToSortedQuotes[percentA]) continue;
150
+ if (!percentToSortedQuotes[percentA] || percentToSortedQuotes[percentA].length === 0) continue;
151
151
 
152
152
  const candidateRoutesA = percentToSortedQuotes[percentA];
153
153
  const routeWithQuoteA = findFirstRouteNotUsingUsedPools(curRoutes, candidateRoutesA, routeToMask);