aftermath-ts-sdk 1.1.30 → 1.1.31
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routerGraph.d.ts","sourceRoot":"","sources":["../../../../../src/packages/router/utils/synchronous/routerGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD,OAAO,EACN,OAAO,EACP,mBAAmB,EACnB,wBAAwB,EACxB,iBAAiB,EACjB,wBAAwB,EACxB,+BAA+B,EAE/B,eAAe,EAIf,UAAU,EACV,QAAQ,EAGR,sBAAsB,EACtB,UAAU,EAEV,kBAAkB,EAElB,MAAM,mBAAmB,CAAC;AAW3B,KAAK,kBAAkB,GAAG;IACzB,MAAM,EAAE,UAAU,EAAE,CAAC;CACrB,GAAG,SAAS,CAAC;AAEd,KAAK,UAAU,GAAG;IACjB,KAAK,EAAE,SAAS,EAAE,CAAC;CACnB,GAAG,SAAS,CAAC;AAEd,KAAK,SAAS,GAAG,SAAS,GAAG;IAC5B,OAAO,EAAE,QAAQ,CAAC;CAClB,CAAC;AAEF,KAAK,SAAS,GAAG,eAAe,GAAG;IAClC,gBAAgB,EAAE,OAAO,CAAC;CAC1B,CAAC;AAMF,qBAAa,WAAW;IAoBtB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC;IAZnC,SAAgB,KAAK,EAAE,mBAAmB,CAAC;IAE3C,OAAO,CAAC,WAAW,CAA+B;gBAOjD,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,+BAA+B,EAC9B,OAAO,EAAE,wBAAwB,EACxB,gBAAgB,CAAC,kCAAsB;IAclD,aAAa,CAAC,cAAc,EAAE,OAAO,CAAC,wBAAwB,CAAC;IAO/D,6BAA6B,CAAC,MAAM,EAAE;QAC5C,UAAU,EAAE,QAAQ,CAAC;QACrB,YAAY,EA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wCAAwC,CAiBrD;IAGF,OAAO,CAAC,MAAM,CAAC,gBAAgB,CACpB;IASX,OAAO,CAAC,MAAM,CAAC,eAAe,CAA6C;IAM3E,OAAO,CAAC,MAAM,CAAC,8CAA8C,CAsD3D;IAMF,OAAO,CAAC,MAAM,CAAC,SAAS,CAUtB;CACF"}
|
|
@@ -445,38 +445,40 @@ RouterGraph.createStartingRoutes = (pools, coinInPoolIds, coinIn, onlyNoHopPools
|
|
|
445
445
|
const pool = pools[poolUid];
|
|
446
446
|
if (onlyNoHopPools && !pool.noHopsAllowed)
|
|
447
447
|
continue;
|
|
448
|
-
const
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
coinOut: {
|
|
457
|
-
type: coinOut,
|
|
458
|
-
amount: BigInt(0),
|
|
459
|
-
tradeFee: BigInt(0),
|
|
460
|
-
},
|
|
461
|
-
spotPrice: 0,
|
|
462
|
-
paths: [
|
|
463
|
-
{
|
|
464
|
-
poolUid: pool.uid,
|
|
465
|
-
estimatedGasCost: pool.expectedGasCostPerHop,
|
|
466
|
-
coinIn: {
|
|
467
|
-
type: coinIn,
|
|
468
|
-
amount: BigInt(0),
|
|
469
|
-
tradeFee: BigInt(0),
|
|
470
|
-
},
|
|
471
|
-
coinOut: {
|
|
472
|
-
type: coinOut,
|
|
473
|
-
amount: BigInt(0),
|
|
474
|
-
tradeFee: BigInt(0),
|
|
475
|
-
},
|
|
476
|
-
spotPrice: 0,
|
|
448
|
+
const coinOuts = _a.otherCoin({ pool, coinType: coinIn });
|
|
449
|
+
for (const coinOut of coinOuts) {
|
|
450
|
+
routes.push({
|
|
451
|
+
estimatedGasCost: pool.expectedGasCostPerHop,
|
|
452
|
+
coinIn: {
|
|
453
|
+
type: coinIn,
|
|
454
|
+
amount: BigInt(0),
|
|
455
|
+
tradeFee: BigInt(0),
|
|
477
456
|
},
|
|
478
|
-
|
|
479
|
-
|
|
457
|
+
coinOut: {
|
|
458
|
+
type: coinOut,
|
|
459
|
+
amount: BigInt(0),
|
|
460
|
+
tradeFee: BigInt(0),
|
|
461
|
+
},
|
|
462
|
+
spotPrice: 0,
|
|
463
|
+
paths: [
|
|
464
|
+
{
|
|
465
|
+
poolUid: pool.uid,
|
|
466
|
+
estimatedGasCost: pool.expectedGasCostPerHop,
|
|
467
|
+
coinIn: {
|
|
468
|
+
type: coinIn,
|
|
469
|
+
amount: BigInt(0),
|
|
470
|
+
tradeFee: BigInt(0),
|
|
471
|
+
},
|
|
472
|
+
coinOut: {
|
|
473
|
+
type: coinOut,
|
|
474
|
+
amount: BigInt(0),
|
|
475
|
+
tradeFee: BigInt(0),
|
|
476
|
+
},
|
|
477
|
+
spotPrice: 0,
|
|
478
|
+
},
|
|
479
|
+
],
|
|
480
|
+
});
|
|
481
|
+
}
|
|
480
482
|
}
|
|
481
483
|
return routes;
|
|
482
484
|
// let routes: TradeRoute[] = [];
|
|
@@ -631,32 +633,34 @@ RouterGraph.findCompleteRoutes = (graph, routes, finalCoinOut, maxRouteLength, i
|
|
|
631
633
|
if (!(poolUid in graph.pools))
|
|
632
634
|
continue;
|
|
633
635
|
const pool = graph.pools[poolUid];
|
|
634
|
-
const
|
|
636
|
+
const coinOuts = _a.otherCoin({
|
|
635
637
|
pool,
|
|
636
638
|
coinType: lastPath.coinOut.type,
|
|
637
639
|
});
|
|
638
|
-
const
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
640
|
+
for (const coinOut of coinOuts) {
|
|
641
|
+
const newRoute = Object.assign(Object.assign({}, route), { paths: [
|
|
642
|
+
...route.paths,
|
|
643
|
+
{
|
|
644
|
+
poolUid: pool.uid,
|
|
645
|
+
estimatedGasCost: pool.expectedGasCostPerHop,
|
|
646
|
+
coinIn: lastPath.coinOut,
|
|
647
|
+
coinOut: {
|
|
648
|
+
type: coinOut,
|
|
649
|
+
amount: BigInt(0),
|
|
650
|
+
tradeFee: BigInt(0),
|
|
651
|
+
},
|
|
652
|
+
spotPrice: 0,
|
|
648
653
|
},
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
654
|
+
] });
|
|
655
|
+
if (coinOut === finalCoinOut) {
|
|
656
|
+
completeRoutes = [...completeRoutes, newRoute];
|
|
657
|
+
// break if too many routes to look at
|
|
658
|
+
if (completeRoutes.length >= maxRoutesToCheck)
|
|
659
|
+
break outerLoop;
|
|
660
|
+
continue;
|
|
661
|
+
}
|
|
662
|
+
newCurrentRoutes = [...newCurrentRoutes, newRoute];
|
|
658
663
|
}
|
|
659
|
-
newCurrentRoutes = [...newCurrentRoutes, newRoute];
|
|
660
664
|
}
|
|
661
665
|
}
|
|
662
666
|
currentRoutes = [...newCurrentRoutes];
|
|
@@ -669,8 +673,6 @@ RouterGraph.findCompleteRoutes = (graph, routes, finalCoinOut, maxRouteLength, i
|
|
|
669
673
|
return Object.assign(Object.assign({}, newRoute), { paths: newRoute.paths.reverse() });
|
|
670
674
|
})
|
|
671
675
|
: completeRoutes;
|
|
672
|
-
// console.log("completeRoutes", completeRoutes);
|
|
673
|
-
console.log("completeRoutes", completeRoutes.length);
|
|
674
676
|
return finalRoutes;
|
|
675
677
|
};
|
|
676
678
|
RouterGraph.completeRouteFromRoutes = (routes, coinIn, coinInAmount, coinOut) => {
|
|
@@ -763,8 +765,8 @@ RouterGraph.routerCompleteTradeRouteFromCompleteTradeRoute = (completeRoute, poo
|
|
|
763
765
|
// =========================================================================
|
|
764
766
|
RouterGraph.otherCoin = (inputs) => {
|
|
765
767
|
const { pool, coinType } = inputs;
|
|
766
|
-
const
|
|
767
|
-
if (!
|
|
768
|
+
const otherCoins = pool.coinTypes.filter((coin) => coin !== coinType);
|
|
769
|
+
if (!otherCoins)
|
|
768
770
|
throw new Error("no other coin found");
|
|
769
|
-
return
|
|
771
|
+
return otherCoins;
|
|
770
772
|
};
|