aftermath-ts-sdk 0.0.146 → 0.0.148
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.
- package/dist/general/api/objectsApiHelpers.d.ts +1 -0
- package/dist/general/api/objectsApiHelpers.d.ts.map +1 -1
- package/dist/general/api/objectsApiHelpers.js +20 -2
- package/dist/general/historicalData/historicalDataApi.d.ts +2 -1
- package/dist/general/historicalData/historicalDataApi.d.ts.map +1 -1
- package/dist/general/historicalData/historicalDataApiInterface.d.ts +10 -0
- package/dist/general/historicalData/historicalDataApiInterface.d.ts.map +1 -0
- package/dist/general/historicalData/historicalDataApiInterface.js +2 -0
- package/dist/general/historicalData/placeholderHistoricalDataApi.d.ts +10 -0
- package/dist/general/historicalData/placeholderHistoricalDataApi.d.ts.map +1 -0
- package/dist/general/historicalData/placeholderHistoricalDataApi.js +23 -0
- package/dist/general/prices/coingecko/coinGeckoApiHelpers.d.ts +1 -0
- package/dist/general/prices/coingecko/coinGeckoApiHelpers.d.ts.map +1 -1
- package/dist/general/prices/coingecko/coinGeckoApiHelpers.js +23 -4
- package/dist/general/prices/placeholder/placeholderPricesApi.d.ts +1 -2
- package/dist/general/prices/placeholder/placeholderPricesApi.d.ts.map +1 -1
- package/dist/general/prices/placeholder/placeholderPricesApi.js +1 -1
- package/dist/general/providers/aftermathApi.d.ts +6 -4
- package/dist/general/providers/aftermathApi.d.ts.map +1 -1
- package/dist/general/providers/aftermathApi.js +8 -3
- package/dist/general/utils/helpers.d.ts +1 -0
- package/dist/general/utils/helpers.d.ts.map +1 -1
- package/dist/general/utils/helpers.js +8 -0
- package/dist/packages/external/cetus/cetusApi.d.ts +11 -4
- package/dist/packages/external/cetus/cetusApi.d.ts.map +1 -1
- package/dist/packages/external/cetus/cetusApi.js +9 -6
- package/dist/packages/external/cetus/cetusApiHelpers.d.ts +54 -4
- package/dist/packages/external/cetus/cetusApiHelpers.d.ts.map +1 -1
- package/dist/packages/external/cetus/cetusApiHelpers.js +120 -50
- package/dist/packages/external/turbos/turbosApi.d.ts +11 -4
- package/dist/packages/external/turbos/turbosApi.d.ts.map +1 -1
- package/dist/packages/external/turbos/turbosApi.js +9 -6
- package/dist/packages/external/turbos/turbosApiHelpers.d.ts +14 -4
- package/dist/packages/external/turbos/turbosApiHelpers.d.ts.map +1 -1
- package/dist/packages/external/turbos/turbosApiHelpers.js +76 -20
- package/dist/packages/router/api/routerApi.d.ts +2 -4
- package/dist/packages/router/api/routerApi.d.ts.map +1 -1
- package/dist/packages/router/api/routerApi.js +5 -25
- package/dist/packages/router/api/routerApiHelpers.d.ts +41 -0
- package/dist/packages/router/api/routerApiHelpers.d.ts.map +1 -0
- package/dist/packages/router/api/routerApiHelpers.js +191 -0
- package/dist/packages/router/api/routerAsyncApiHelpers.d.ts +15 -4
- package/dist/packages/router/api/routerAsyncApiHelpers.d.ts.map +1 -1
- package/dist/packages/router/api/routerAsyncApiHelpers.js +42 -9
- package/dist/packages/router/api/routerSynchronousApiHelpers.d.ts +1 -10
- package/dist/packages/router/api/routerSynchronousApiHelpers.d.ts.map +1 -1
- package/dist/packages/router/api/routerSynchronousApiHelpers.js +5 -25
- package/dist/packages/router/routerTypes.d.ts.map +1 -1
- package/dist/packages/router/utils/async/routerAsyncApiInterface.d.ts +13 -6
- package/dist/packages/router/utils/async/routerAsyncApiInterface.d.ts.map +1 -1
- package/dist/packages/router/utils/async/routerAsyncGraph.d.ts +4 -2
- package/dist/packages/router/utils/async/routerAsyncGraph.d.ts.map +1 -1
- package/dist/packages/router/utils/async/routerAsyncGraph.js +34 -34
- package/dist/packages/router/utils/synchronous/routerGraph.d.ts +13 -11
- package/dist/packages/router/utils/synchronous/routerGraph.d.ts.map +1 -1
- package/dist/packages/router/utils/synchronous/routerGraph.js +109 -73
- package/package.json +1 -1
|
@@ -10,16 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.RouterApi = void 0;
|
|
13
|
-
const routerSynchronousApiHelpers_1 = require("./routerSynchronousApiHelpers");
|
|
14
13
|
const routerGraph_1 = require("../utils/synchronous/routerGraph");
|
|
15
|
-
const types_1 = require("../../../types");
|
|
16
14
|
const nojoAmmApi_1 = require("../../external/nojo/nojoAmmApi");
|
|
17
15
|
const deepBookApi_1 = require("../../external/deepBook/deepBookApi");
|
|
18
16
|
const poolsApi_1 = require("../../pools/api/poolsApi");
|
|
19
17
|
const cetusApi_1 = require("../../external/cetus/cetusApi");
|
|
20
|
-
const routerAsyncGraph_1 = require("../utils/async/routerAsyncGraph");
|
|
21
|
-
const routerAsyncApiHelpers_1 = require("./routerAsyncApiHelpers");
|
|
22
18
|
const turbosApi_1 = require("../../external/turbos/turbosApi");
|
|
19
|
+
const routerApiHelpers_1 = require("./routerApiHelpers");
|
|
23
20
|
class RouterApi {
|
|
24
21
|
/////////////////////////////////////////////////////////////////////
|
|
25
22
|
//// Constructor
|
|
@@ -42,10 +39,9 @@ class RouterApi {
|
|
|
42
39
|
//// Graph
|
|
43
40
|
/////////////////////////////////////////////////////////////////////
|
|
44
41
|
this.fetchSerializableGraph = () => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
|
|
42
|
+
return this.Helpers.fetchSerializableGraph({
|
|
46
43
|
protocols: this.protocols,
|
|
47
44
|
});
|
|
48
|
-
return routerGraph_1.RouterGraph.createGraph({ pools });
|
|
49
45
|
});
|
|
50
46
|
/////////////////////////////////////////////////////////////////////
|
|
51
47
|
//// Coin Paths
|
|
@@ -57,26 +53,10 @@ class RouterApi {
|
|
|
57
53
|
//// Routing
|
|
58
54
|
/////////////////////////////////////////////////////////////////////
|
|
59
55
|
this.fetchCompleteTradeRouteGivenAmountIn = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
|
|
61
|
-
throw new Error("no protocols set in constructor");
|
|
62
|
-
const { network, graph, coinInAmount } = inputs;
|
|
63
|
-
const coinInAmounts = routerSynchronousApiHelpers_1.RouterSynchronousApiHelpers.amountsInForRouterTrade({
|
|
64
|
-
coinInAmount,
|
|
65
|
-
});
|
|
66
|
-
const tradeResults = yield this.AsyncHelpers.fetchTradeResults(Object.assign(Object.assign({}, inputs), { protocols: this.protocols.filter(types_1.isRouterAsyncProtocolName), coinInAmounts }));
|
|
67
|
-
const routerGraph = new routerGraph_1.RouterGraph(network, graph);
|
|
68
|
-
if (tradeResults.results.length <= 0)
|
|
69
|
-
return routerGraph.getCompleteRouteGivenAmountIn(inputs);
|
|
70
|
-
const synchronousCompleteRoutes = routerGraph.getCompleteRoutesGivenAmountIns(Object.assign(Object.assign({}, inputs), { coinInAmounts }));
|
|
71
|
-
return routerAsyncGraph_1.RouterAsyncGraph.createFinalCompleteRoute({
|
|
72
|
-
tradeResults,
|
|
73
|
-
synchronousCompleteRoutes,
|
|
74
|
-
coinInAmounts,
|
|
75
|
-
});
|
|
56
|
+
return this.Helpers.fetchCompleteTradeRouteGivenAmountIn(Object.assign(Object.assign({}, inputs), { protocols: this.protocols }));
|
|
76
57
|
});
|
|
77
58
|
this.Provider = Provider;
|
|
78
|
-
this.Helpers = new
|
|
79
|
-
this.AsyncHelpers = new routerAsyncApiHelpers_1.RouterAsyncApiHelpers(Provider);
|
|
59
|
+
this.Helpers = new routerApiHelpers_1.RouterApiHelpers(Provider);
|
|
80
60
|
}
|
|
81
61
|
// public fetchCompleteTradeRouteGivenAmountOut = async (
|
|
82
62
|
// network: SuiNetwork | Url,
|
|
@@ -100,7 +80,7 @@ class RouterApi {
|
|
|
100
80
|
/////////////////////////////////////////////////////////////////////
|
|
101
81
|
fetchTransactionForCompleteTradeRoute(inputs) {
|
|
102
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
const tx = yield this.Helpers.
|
|
83
|
+
const tx = yield this.Helpers.fetchTransactionForCompleteTradeRoute(inputs);
|
|
104
84
|
return this.Provider.Transactions().fetchSetGasBudgetAndSerializeTransaction(tx);
|
|
105
85
|
});
|
|
106
86
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { SuiAddress, TransactionBlock } from "@mysten/sui.js";
|
|
2
|
+
import { AftermathApi } from "../../../general/providers/aftermathApi";
|
|
3
|
+
import { Balance, CoinType, RouterCompleteTradeRoute, RouterExternalFee, RouterProtocolName, RouterSerializableCompleteGraph, Slippage, SuiNetwork, Url } from "../../../types";
|
|
4
|
+
import { RouterAsyncApiHelpers } from "./routerAsyncApiHelpers";
|
|
5
|
+
import { RouterSynchronousApiHelpers } from "./routerSynchronousApiHelpers";
|
|
6
|
+
export declare class RouterApiHelpers {
|
|
7
|
+
private readonly Provider;
|
|
8
|
+
static readonly constants: {
|
|
9
|
+
defaults: {
|
|
10
|
+
tradePartitionCount: number;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
readonly SynchronousHelpers: RouterSynchronousApiHelpers;
|
|
14
|
+
readonly AsyncHelpers: RouterAsyncApiHelpers;
|
|
15
|
+
constructor(Provider: AftermathApi);
|
|
16
|
+
fetchSerializableGraph: (inputs: {
|
|
17
|
+
protocols: RouterProtocolName[];
|
|
18
|
+
}) => Promise<RouterSerializableCompleteGraph>;
|
|
19
|
+
fetchCompleteTradeRouteGivenAmountIn: (inputs: {
|
|
20
|
+
protocols: RouterProtocolName[];
|
|
21
|
+
network: SuiNetwork | Url;
|
|
22
|
+
graph: RouterSerializableCompleteGraph;
|
|
23
|
+
coinInType: CoinType;
|
|
24
|
+
coinInAmount: Balance;
|
|
25
|
+
coinOutType: CoinType;
|
|
26
|
+
referrer?: SuiAddress;
|
|
27
|
+
externalFee?: RouterExternalFee;
|
|
28
|
+
}) => Promise<RouterCompleteTradeRoute>;
|
|
29
|
+
private fetchCompleteTradeRoutesForLastRouteAsyncPool;
|
|
30
|
+
fetchTransactionForCompleteTradeRoute(inputs: {
|
|
31
|
+
walletAddress: SuiAddress;
|
|
32
|
+
completeRoute: RouterCompleteTradeRoute;
|
|
33
|
+
slippage: Slippage;
|
|
34
|
+
}): Promise<TransactionBlock>;
|
|
35
|
+
static amountsInForRouterTrade: (inputs: {
|
|
36
|
+
coinInAmount: Balance;
|
|
37
|
+
partitions?: number;
|
|
38
|
+
}) => Balance[];
|
|
39
|
+
private static addFinalRouterCompleteTradeRouteToRoute;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=routerApiHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routerApiHelpers.d.ts","sourceRoot":"","sources":["../../../../src/packages/router/api/routerApiHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EACN,OAAO,EACP,QAAQ,EAER,wBAAwB,EACxB,iBAAiB,EACjB,kBAAkB,EAClB,+BAA+B,EAC/B,QAAQ,EACR,UAAU,EACV,GAAG,EAEH,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAG5E,qBAAa,gBAAgB;IAsBhB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAjBrC,gBAAuB,SAAS;;;;MAI9B;IAMF,SAAgB,kBAAkB,8BAAC;IACnC,SAAgB,YAAY,wBAAC;gBAMA,QAAQ,EAAE,YAAY;IAe5C,sBAAsB,WAAkB;QAC9C,SAAS,EAAE,kBAAkB,EAAE,CAAC;KAChC,8CAGC;IAMK,oCAAoC,WAAkB;QAC5D,SAAS,EAAE,kBAAkB,EAAE,CAAC;QAChC,OAAO,EAAE,UAAU,GAAG,GAAG,CAAC;QAC1B,KAAK,EAAE,+BAA+B,CAAC;QACvC,UAAU,EAAE,QAAQ,CAAC;QACrB,YAAY,EAAE,OAAO,CAAC;QACtB,WAAW,EAAE,QAAQ,CAAC;QACtB,QAAQ,CAAC,EAAE,UAAU,CAAC;QACtB,WAAW,CAAC,EAAE,iBAAiB,CAAC;KAGhC,KAAG,QAAQ,wBAAwB,CAAC,CAgEnC;IAEF,OAAO,CAAC,6CAA6C,CAuDnD;IAmDW,qCAAqC,CAAC,MAAM,EAAE;QAC1D,aAAa,EAAE,UAAU,CAAC;QAC1B,aAAa,EAAE,wBAAwB,CAAC;QACxC,QAAQ,EAAE,QAAQ,CAAC;KACnB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAc7B,OAAc,uBAAuB,WAAY;QAChD,YAAY,EAAE,OAAO,CAAC;QACtB,UAAU,CAAC,EAAE,MAAM,CAAC;KACpB,KAAG,OAAO,EAAE,CAqBX;IAUF,OAAO,CAAC,MAAM,CAAC,uCAAuC,CAwCpD;CACF"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RouterApiHelpers = void 0;
|
|
13
|
+
const types_1 = require("../../../types");
|
|
14
|
+
const routerGraph_1 = require("../utils/synchronous/routerGraph");
|
|
15
|
+
const routerAsyncApiHelpers_1 = require("./routerAsyncApiHelpers");
|
|
16
|
+
const routerSynchronousApiHelpers_1 = require("./routerSynchronousApiHelpers");
|
|
17
|
+
const routerAsyncGraph_1 = require("../utils/async/routerAsyncGraph");
|
|
18
|
+
class RouterApiHelpers {
|
|
19
|
+
/////////////////////////////////////////////////////////////////////
|
|
20
|
+
//// Constructor
|
|
21
|
+
/////////////////////////////////////////////////////////////////////
|
|
22
|
+
constructor(Provider) {
|
|
23
|
+
this.Provider = Provider;
|
|
24
|
+
/////////////////////////////////////////////////////////////////////
|
|
25
|
+
//// Public Methods
|
|
26
|
+
/////////////////////////////////////////////////////////////////////
|
|
27
|
+
/////////////////////////////////////////////////////////////////////
|
|
28
|
+
//// Graph
|
|
29
|
+
/////////////////////////////////////////////////////////////////////
|
|
30
|
+
this.fetchSerializableGraph = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const pools = yield this.SynchronousHelpers.fetchAllPools(inputs);
|
|
32
|
+
return routerGraph_1.RouterGraph.createGraph({ pools });
|
|
33
|
+
});
|
|
34
|
+
/////////////////////////////////////////////////////////////////////
|
|
35
|
+
//// Routing
|
|
36
|
+
/////////////////////////////////////////////////////////////////////
|
|
37
|
+
this.fetchCompleteTradeRouteGivenAmountIn = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
if (inputs.protocols.length === 0)
|
|
39
|
+
throw new Error("no protocols set in constructor");
|
|
40
|
+
const { network, graph, coinInAmount } = inputs;
|
|
41
|
+
const coinInAmounts = RouterApiHelpers.amountsInForRouterTrade({
|
|
42
|
+
coinInAmount,
|
|
43
|
+
});
|
|
44
|
+
const asyncProtocols = inputs.protocols.filter(types_1.isRouterAsyncProtocolName);
|
|
45
|
+
const { exactMatchPools, partialMatchPools } = yield this.AsyncHelpers.fetchPossiblePools(Object.assign(Object.assign({}, inputs), { protocols: asyncProtocols }));
|
|
46
|
+
const routerGraph = new routerGraph_1.RouterGraph(network, graph);
|
|
47
|
+
if (exactMatchPools.length <= 0 && partialMatchPools.length <= 0)
|
|
48
|
+
return routerGraph.getCompleteRouteGivenAmountIn(inputs);
|
|
49
|
+
const [exactTradeResults, completeRoutesForLastPoolAsync] = yield Promise.all([
|
|
50
|
+
this.AsyncHelpers.fetchTradeResults(Object.assign(Object.assign({}, inputs), { pools: exactMatchPools, coinInAmounts })),
|
|
51
|
+
Promise.all(partialMatchPools.map((lastPool) => this.fetchCompleteTradeRoutesForLastRouteAsyncPool(Object.assign(Object.assign({}, inputs), { routerGraph,
|
|
52
|
+
coinInAmounts,
|
|
53
|
+
lastPool })))),
|
|
54
|
+
]);
|
|
55
|
+
const synchronousCompleteRoutes = routerGraph.getCompleteRoutesGivenAmountIns(Object.assign(Object.assign({}, inputs), { coinInAmounts }));
|
|
56
|
+
const allCompleteRoutes = [
|
|
57
|
+
...completeRoutesForLastPoolAsync,
|
|
58
|
+
synchronousCompleteRoutes,
|
|
59
|
+
];
|
|
60
|
+
const completeRoutes = allCompleteRoutes.filter((routes) => routes.length > 0);
|
|
61
|
+
return routerAsyncGraph_1.RouterAsyncGraph.createFinalCompleteRoute({
|
|
62
|
+
tradeResults: exactTradeResults,
|
|
63
|
+
completeRoutes: completeRoutes.length <= 0 ? undefined : completeRoutes,
|
|
64
|
+
coinInAmounts,
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
this.fetchCompleteTradeRoutesForLastRouteAsyncPool = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
const { routerGraph } = inputs;
|
|
69
|
+
const asyncApi = this.AsyncHelpers.protocolNamesToApi[this.AsyncHelpers.protocolNameFromPool({
|
|
70
|
+
pool: inputs.lastPool,
|
|
71
|
+
})]();
|
|
72
|
+
const lastPoolCoinInType = asyncApi.otherCoinInPool({
|
|
73
|
+
coinType: inputs.coinOutType,
|
|
74
|
+
pool: inputs.lastPool,
|
|
75
|
+
});
|
|
76
|
+
const synchronousCompleteRoutes = routerGraph.getCompleteRoutesGivenAmountIns(Object.assign(Object.assign({}, inputs), { coinOutType: lastPoolCoinInType }));
|
|
77
|
+
const lastPoolCoinInAmounts = synchronousCompleteRoutes.map((route) => route.coinOut.amount);
|
|
78
|
+
const tradeResults = yield this.AsyncHelpers.fetchTradeResults(Object.assign(Object.assign({}, inputs), { coinInType: lastPoolCoinInType, pools: [inputs.lastPool], coinInAmounts: lastPoolCoinInAmounts }));
|
|
79
|
+
const asyncCompleteRoutes = routerAsyncGraph_1.RouterAsyncGraph.completeRoutesFromTradeResults({
|
|
80
|
+
tradeResults,
|
|
81
|
+
})[0];
|
|
82
|
+
const finalCompleteRoutes = synchronousCompleteRoutes.map((syncRoute, index) => RouterApiHelpers.addFinalRouterCompleteTradeRouteToRoute({
|
|
83
|
+
startCompleteRoute: syncRoute,
|
|
84
|
+
endCompleteRoute: asyncCompleteRoutes[index],
|
|
85
|
+
}));
|
|
86
|
+
return finalCompleteRoutes.every((route) => route.routes.length === 0)
|
|
87
|
+
? []
|
|
88
|
+
: finalCompleteRoutes;
|
|
89
|
+
});
|
|
90
|
+
this.Provider = Provider;
|
|
91
|
+
this.SynchronousHelpers = new routerSynchronousApiHelpers_1.RouterSynchronousApiHelpers(Provider);
|
|
92
|
+
this.AsyncHelpers = new routerAsyncApiHelpers_1.RouterAsyncApiHelpers(Provider);
|
|
93
|
+
}
|
|
94
|
+
// public fetchCompleteTradeRouteGivenAmountIn = async (inputs: {
|
|
95
|
+
// protocols: RouterProtocolName[];
|
|
96
|
+
// network: SuiNetwork | Url;
|
|
97
|
+
// graph: RouterSerializableCompleteGraph;
|
|
98
|
+
// coinInType: CoinType;
|
|
99
|
+
// coinInAmount: Balance;
|
|
100
|
+
// coinOutType: CoinType;
|
|
101
|
+
// referrer?: SuiAddress;
|
|
102
|
+
// externalFee?: RouterExternalFee;
|
|
103
|
+
// // TODO: add options to set all these params ?
|
|
104
|
+
// // maxRouteLength?: number,
|
|
105
|
+
// }): Promise<RouterCompleteTradeRoute> => {
|
|
106
|
+
// if (inputs.protocols.length === 0)
|
|
107
|
+
// throw new Error("no protocols set in constructor");
|
|
108
|
+
// const { network, graph, coinInAmount } = inputs;
|
|
109
|
+
// const coinInAmounts = RouterApiHelpers.amountsInForRouterTrade({
|
|
110
|
+
// coinInAmount,
|
|
111
|
+
// });
|
|
112
|
+
// const tradeResults = await this.AsyncHelpers.fetchTradeResults({
|
|
113
|
+
// ...inputs,
|
|
114
|
+
// protocols: inputs.protocols.filter(isRouterAsyncProtocolName),
|
|
115
|
+
// coinInAmounts,
|
|
116
|
+
// });
|
|
117
|
+
// const routerGraph = new RouterGraph(network, graph);
|
|
118
|
+
// if (tradeResults.results.length <= 0)
|
|
119
|
+
// return routerGraph.getCompleteRouteGivenAmountIn(inputs);
|
|
120
|
+
// const synchronousCompleteRoutes =
|
|
121
|
+
// routerGraph.getCompleteRoutesGivenAmountIns({
|
|
122
|
+
// ...inputs,
|
|
123
|
+
// coinInAmounts,
|
|
124
|
+
// });
|
|
125
|
+
// return RouterAsyncGraph.createFinalCompleteRoute({
|
|
126
|
+
// tradeResults,
|
|
127
|
+
// synchronousCompleteRoutes,
|
|
128
|
+
// coinInAmounts,
|
|
129
|
+
// });
|
|
130
|
+
// };
|
|
131
|
+
/////////////////////////////////////////////////////////////////////
|
|
132
|
+
//// Transactions
|
|
133
|
+
/////////////////////////////////////////////////////////////////////
|
|
134
|
+
fetchTransactionForCompleteTradeRoute(inputs) {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
return this.SynchronousHelpers.fetchBuildTransactionForCompleteTradeRoute(inputs);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
exports.RouterApiHelpers = RouterApiHelpers;
|
|
141
|
+
/////////////////////////////////////////////////////////////////////
|
|
142
|
+
//// Constants
|
|
143
|
+
/////////////////////////////////////////////////////////////////////
|
|
144
|
+
RouterApiHelpers.constants = {
|
|
145
|
+
defaults: {
|
|
146
|
+
tradePartitionCount: 3,
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
/////////////////////////////////////////////////////////////////////
|
|
150
|
+
//// Public Static Methods
|
|
151
|
+
/////////////////////////////////////////////////////////////////////
|
|
152
|
+
/////////////////////////////////////////////////////////////////////
|
|
153
|
+
//// Helpers
|
|
154
|
+
/////////////////////////////////////////////////////////////////////
|
|
155
|
+
RouterApiHelpers.amountsInForRouterTrade = (inputs) => {
|
|
156
|
+
const { coinInAmount } = inputs;
|
|
157
|
+
const partitions = inputs.partitions ||
|
|
158
|
+
RouterApiHelpers.constants.defaults.tradePartitionCount;
|
|
159
|
+
const coinInPartitionAmount = coinInAmount / BigInt(Math.floor(partitions));
|
|
160
|
+
const coinInRemainderAmount = coinInAmount % BigInt(Math.floor(partitions));
|
|
161
|
+
const amountsIn = Array(partitions)
|
|
162
|
+
.fill(0)
|
|
163
|
+
.map((_, index) => index === 0
|
|
164
|
+
? coinInRemainderAmount + coinInPartitionAmount
|
|
165
|
+
: BigInt(1 + index) * coinInPartitionAmount);
|
|
166
|
+
return amountsIn;
|
|
167
|
+
};
|
|
168
|
+
/////////////////////////////////////////////////////////////////////
|
|
169
|
+
//// Private Methods
|
|
170
|
+
/////////////////////////////////////////////////////////////////////
|
|
171
|
+
/////////////////////////////////////////////////////////////////////
|
|
172
|
+
//// Helpers
|
|
173
|
+
/////////////////////////////////////////////////////////////////////
|
|
174
|
+
RouterApiHelpers.addFinalRouterCompleteTradeRouteToRoute = (inputs) => {
|
|
175
|
+
const { startCompleteRoute, endCompleteRoute } = inputs;
|
|
176
|
+
const totalEndRouteAmountIn = endCompleteRoute.coinIn.amount;
|
|
177
|
+
return Object.assign(Object.assign({}, startCompleteRoute), { routes: startCompleteRoute.routes.map((route) => {
|
|
178
|
+
const finalRoute = endCompleteRoute.routes[0];
|
|
179
|
+
const finalPath = finalRoute.paths[0];
|
|
180
|
+
// TODO: handle remainder amount
|
|
181
|
+
const finalCoinOutAmountForRoute = route.coinOut.amount / totalEndRouteAmountIn;
|
|
182
|
+
const spotPrice = Number(route.coinIn.amount) /
|
|
183
|
+
Number(finalCoinOutAmountForRoute);
|
|
184
|
+
return {
|
|
185
|
+
spotPrice,
|
|
186
|
+
coinIn: Object.assign({}, route.coinIn),
|
|
187
|
+
coinOut: Object.assign(Object.assign({}, finalRoute.coinOut), { amount: finalCoinOutAmountForRoute }),
|
|
188
|
+
paths: [...route.paths, finalPath],
|
|
189
|
+
};
|
|
190
|
+
}), coinOut: Object.assign({}, endCompleteRoute.coinOut), spotPrice: startCompleteRoute.spotPrice * endCompleteRoute.spotPrice });
|
|
191
|
+
};
|
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
import { AftermathApi } from "../../../general/providers/aftermathApi";
|
|
2
|
-
import { RouterAsyncProtocolName, RouterAsyncTradeResults } from "../routerTypes";
|
|
2
|
+
import { RouterAsyncProtocolName, RouterAsyncSerializablePool, RouterAsyncTradeResults } from "../routerTypes";
|
|
3
3
|
import { Balance, CoinType } from "../../../types";
|
|
4
|
+
import { RouterAsyncApiInterface } from "../utils/async/routerAsyncApiInterface";
|
|
4
5
|
export declare class RouterAsyncApiHelpers {
|
|
5
6
|
private readonly Provider;
|
|
6
|
-
|
|
7
|
+
readonly protocolNamesToApi: Record<RouterAsyncProtocolName, () => RouterAsyncApiInterface<any>>;
|
|
7
8
|
constructor(Provider: AftermathApi);
|
|
8
|
-
|
|
9
|
+
fetchPossiblePools: (inputs: {
|
|
9
10
|
protocols: RouterAsyncProtocolName[];
|
|
10
11
|
coinInType: CoinType;
|
|
11
12
|
coinOutType: CoinType;
|
|
13
|
+
}) => Promise<{
|
|
14
|
+
exactMatchPools: RouterAsyncSerializablePool[];
|
|
15
|
+
partialMatchPools: RouterAsyncSerializablePool[];
|
|
16
|
+
}>;
|
|
17
|
+
fetchTradeResults: (inputs: {
|
|
18
|
+
pools: RouterAsyncSerializablePool[];
|
|
19
|
+
coinInType: CoinType;
|
|
20
|
+
coinOutType: CoinType;
|
|
12
21
|
coinInAmounts: Balance[];
|
|
13
22
|
}) => Promise<RouterAsyncTradeResults>;
|
|
14
|
-
|
|
23
|
+
protocolNameFromPool: (inputs: {
|
|
24
|
+
pool: RouterAsyncSerializablePool;
|
|
25
|
+
}) => RouterAsyncProtocolName;
|
|
15
26
|
}
|
|
16
27
|
//# sourceMappingURL=routerAsyncApiHelpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routerAsyncApiHelpers.d.ts","sourceRoot":"","sources":["../../../../src/packages/router/api/routerAsyncApiHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EACN,uBAAuB,
|
|
1
|
+
{"version":3,"file":"routerAsyncApiHelpers.d.ts","sourceRoot":"","sources":["../../../../src/packages/router/api/routerAsyncApiHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EACN,uBAAuB,EACvB,2BAA2B,EAE3B,uBAAuB,EACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAOjF,qBAAa,qBAAqB;IAiBrB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAZrC,SAAgB,kBAAkB,EAAE,MAAM,CACzC,uBAAuB,EACvB,MAAM,uBAAuB,CAAC,GAAG,CAAC,CAClC,CAGC;gBAM2B,QAAQ,EAAE,YAAY;IAQ5C,kBAAkB,WAAkB;QAC1C,SAAS,EAAE,uBAAuB,EAAE,CAAC;QACrC,UAAU,EAAE,QAAQ,CAAC;QACrB,WAAW,EAAE,QAAQ,CAAC;KACtB,KAAG,QAAQ;QACX,eAAe,EAAE,2BAA2B,EAAE,CAAC;QAC/C,iBAAiB,EAAE,2BAA2B,EAAE,CAAC;KACjD,CAAC,CA8BA;IAEK,iBAAiB,WAAkB;QACzC,KAAK,EAAE,2BAA2B,EAAE,CAAC;QACrC,UAAU,EAAE,QAAQ,CAAC;QACrB,WAAW,EAAE,QAAQ,CAAC;QACtB,aAAa,EAAE,OAAO,EAAE,CAAC;KACzB,KAAG,QAAQ,uBAAuB,CAAC,CAwDlC;IA4CK,oBAAoB,WAAY;QACtC,IAAI,EAAE,2BAA2B,CAAC;KAClC,KAAG,uBAAuB,CAQzB;CACF"}
|
|
@@ -13,6 +13,7 @@ exports.RouterAsyncApiHelpers = void 0;
|
|
|
13
13
|
const cetusApi_1 = require("../../external/cetus/cetusApi");
|
|
14
14
|
const rpcApiHelpers_1 = require("../../../general/api/rpcApiHelpers");
|
|
15
15
|
const turbosApi_1 = require("../../external/turbos/turbosApi");
|
|
16
|
+
const turbosTypes_1 = require("../../external/turbos/turbosTypes");
|
|
16
17
|
class RouterAsyncApiHelpers {
|
|
17
18
|
/////////////////////////////////////////////////////////////////////
|
|
18
19
|
//// Constructor
|
|
@@ -29,18 +30,47 @@ class RouterAsyncApiHelpers {
|
|
|
29
30
|
/////////////////////////////////////////////////////////////////////
|
|
30
31
|
//// Objects
|
|
31
32
|
/////////////////////////////////////////////////////////////////////
|
|
33
|
+
this.fetchPossiblePools = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const apis = inputs.protocols.map((protocol) => this.protocolNamesToApi[protocol]());
|
|
35
|
+
const allPools = (yield Promise.all(apis.map((api) => api.fetchPoolsForTrade(inputs)))).reduce((acc, pools) => {
|
|
36
|
+
return {
|
|
37
|
+
exactMatchPools: [
|
|
38
|
+
...acc.exactMatchPools,
|
|
39
|
+
...pools.exactMatchPools,
|
|
40
|
+
],
|
|
41
|
+
partialMatchPools: [
|
|
42
|
+
...acc.partialMatchPools,
|
|
43
|
+
...pools.partialMatchPools,
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
}, {
|
|
47
|
+
partialMatchPools: [],
|
|
48
|
+
exactMatchPools: [],
|
|
49
|
+
});
|
|
50
|
+
return allPools;
|
|
51
|
+
});
|
|
32
52
|
this.fetchTradeResults = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
const { coinInAmounts
|
|
34
|
-
const
|
|
53
|
+
const { coinInAmounts } = inputs;
|
|
54
|
+
const protocols = inputs.pools.map((pool) => this.protocolNameFromPool({ pool }));
|
|
55
|
+
const apis = protocols.map((protocol) => this.protocolNamesToApi[protocol]());
|
|
35
56
|
const resultsOrUndefined = yield Promise.all(apis.map((api, index) => __awaiter(this, void 0, void 0, function* () {
|
|
36
57
|
try {
|
|
37
|
-
const pool =
|
|
38
|
-
const amountsOut = yield Promise.all(coinInAmounts.map((amountIn) =>
|
|
39
|
-
|
|
58
|
+
const pool = inputs.pools[index];
|
|
59
|
+
const amountsOut = yield Promise.all(coinInAmounts.map((amountIn) => __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
try {
|
|
61
|
+
return yield api.fetchTradeAmountOut(Object.assign(Object.assign({}, inputs), { pool, walletAddress: rpcApiHelpers_1.RpcApiHelpers.constants
|
|
62
|
+
.devInspectSigner, coinInAmount: amountIn }));
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
console.error(e);
|
|
66
|
+
return BigInt(0);
|
|
67
|
+
}
|
|
68
|
+
})));
|
|
69
|
+
const protocol = protocols[index];
|
|
40
70
|
return {
|
|
41
71
|
pool,
|
|
42
72
|
amountsOut,
|
|
43
|
-
protocol
|
|
73
|
+
protocol,
|
|
44
74
|
};
|
|
45
75
|
}
|
|
46
76
|
catch (e) {
|
|
@@ -84,9 +114,12 @@ class RouterAsyncApiHelpers {
|
|
|
84
114
|
/////////////////////////////////////////////////////////////////////
|
|
85
115
|
//// Helpers
|
|
86
116
|
/////////////////////////////////////////////////////////////////////
|
|
87
|
-
this.
|
|
88
|
-
const {
|
|
89
|
-
|
|
117
|
+
this.protocolNameFromPool = (inputs) => {
|
|
118
|
+
const { pool } = inputs;
|
|
119
|
+
const protocolName = (0, turbosTypes_1.isTurbosPoolObject)(pool)
|
|
120
|
+
? "Turbos"
|
|
121
|
+
: "Cetus";
|
|
122
|
+
return protocolName;
|
|
90
123
|
};
|
|
91
124
|
this.Provider = Provider;
|
|
92
125
|
}
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { SuiAddress, TransactionBlock } from "@mysten/sui.js";
|
|
2
2
|
import { AftermathApi } from "../../../general/providers/aftermathApi";
|
|
3
3
|
import { RouterCompleteTradeRoute, RouterProtocolName, RouterSerializablePool } from "../routerTypes";
|
|
4
|
-
import {
|
|
4
|
+
import { CoinType, Slippage } from "../../../types";
|
|
5
5
|
export declare class RouterSynchronousApiHelpers {
|
|
6
6
|
private readonly Provider;
|
|
7
7
|
private readonly protocolNamesToApi;
|
|
8
|
-
static readonly constants: {
|
|
9
|
-
defaults: {
|
|
10
|
-
tradePartitionCount: number;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
8
|
constructor(Provider: AftermathApi);
|
|
14
9
|
fetchAllPools: (inputs: {
|
|
15
10
|
protocols: RouterProtocolName[];
|
|
@@ -22,10 +17,6 @@ export declare class RouterSynchronousApiHelpers {
|
|
|
22
17
|
completeRoute: RouterCompleteTradeRoute;
|
|
23
18
|
slippage: Slippage;
|
|
24
19
|
}): Promise<TransactionBlock>;
|
|
25
|
-
static amountsInForRouterTrade: (inputs: {
|
|
26
|
-
coinInAmount: Balance;
|
|
27
|
-
partitions?: number;
|
|
28
|
-
}) => Balance[];
|
|
29
20
|
private protocolApisFromNames;
|
|
30
21
|
}
|
|
31
22
|
//# sourceMappingURL=routerSynchronousApiHelpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routerSynchronousApiHelpers.d.ts","sourceRoot":"","sources":["../../../../src/packages/router/api/routerSynchronousApiHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,UAAU,EAEV,gBAAgB,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EACN,wBAAwB,EACxB,kBAAkB,EAClB,sBAAsB,EACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,
|
|
1
|
+
{"version":3,"file":"routerSynchronousApiHelpers.d.ts","sourceRoot":"","sources":["../../../../src/packages/router/api/routerSynchronousApiHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,UAAU,EAEV,gBAAgB,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EACN,wBAAwB,EACxB,kBAAkB,EAClB,sBAAsB,EACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAW,QAAQ,EAAE,QAAQ,EAAmB,MAAM,gBAAgB,CAAC;AAW9E,qBAAa,2BAA2B;IAoB3B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAfrC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CASjC;gBAM2B,QAAQ,EAAE,YAAY;IAQ5C,aAAa,WAAkB;QACrC,SAAS,EAAE,kBAAkB,EAAE,CAAC;KAChC,KAAG,QAAQ,sBAAsB,EAAE,CAAC,CAanC;IAMK,mBAAmB,WAAkB;QAC3C,SAAS,EAAE,kBAAkB,EAAE,CAAC;KAChC,KAAG,QAAQ,QAAQ,EAAE,CAAC,CAgBrB;IAMW,0CAA0C,CAAC,MAAM,EAAE;QAC/D,aAAa,EAAE,UAAU,CAAC;QAC1B,aAAa,EAAE,wBAAwB,CAAC;QACxC,QAAQ,EAAE,QAAQ,CAAC;KACnB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAsH7B,OAAO,CAAC,qBAAqB,CAK3B;CACF"}
|
|
@@ -125,7 +125,11 @@ class RouterSynchronousApiHelpers {
|
|
|
125
125
|
slippage,
|
|
126
126
|
referrer,
|
|
127
127
|
});
|
|
128
|
-
coinIn =
|
|
128
|
+
coinIn =
|
|
129
|
+
poolForPath.noHopsAllowed &&
|
|
130
|
+
poolForPath.protocolName !== "Cetus"
|
|
131
|
+
? undefined
|
|
132
|
+
: newCoinIn;
|
|
129
133
|
}
|
|
130
134
|
if (coinIn)
|
|
131
135
|
coinsOut.push(coinIn);
|
|
@@ -152,27 +156,3 @@ class RouterSynchronousApiHelpers {
|
|
|
152
156
|
}
|
|
153
157
|
}
|
|
154
158
|
exports.RouterSynchronousApiHelpers = RouterSynchronousApiHelpers;
|
|
155
|
-
RouterSynchronousApiHelpers.constants = {
|
|
156
|
-
defaults: {
|
|
157
|
-
tradePartitionCount: 3,
|
|
158
|
-
},
|
|
159
|
-
};
|
|
160
|
-
/////////////////////////////////////////////////////////////////////
|
|
161
|
-
//// Public Static Methods
|
|
162
|
-
/////////////////////////////////////////////////////////////////////
|
|
163
|
-
/////////////////////////////////////////////////////////////////////
|
|
164
|
-
//// Helpers
|
|
165
|
-
/////////////////////////////////////////////////////////////////////
|
|
166
|
-
RouterSynchronousApiHelpers.amountsInForRouterTrade = (inputs) => {
|
|
167
|
-
const { coinInAmount } = inputs;
|
|
168
|
-
const partitions = inputs.partitions ||
|
|
169
|
-
RouterSynchronousApiHelpers.constants.defaults.tradePartitionCount;
|
|
170
|
-
const coinInPartitionAmount = coinInAmount / BigInt(Math.floor(partitions));
|
|
171
|
-
const coinInRemainderAmount = coinInAmount % BigInt(Math.floor(partitions));
|
|
172
|
-
const amountsIn = Array(partitions)
|
|
173
|
-
.fill(0)
|
|
174
|
-
.map((_, index) => index === 0
|
|
175
|
-
? coinInRemainderAmount + coinInPartitionAmount
|
|
176
|
-
: BigInt(1 + index) * coinInPartitionAmount);
|
|
177
|
-
return amountsIn;
|
|
178
|
-
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routerTypes.d.ts","sourceRoot":"","sources":["../../../src/packages/router/routerTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACN,OAAO,EACP,UAAU,EACV,QAAQ,EACR,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE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
1
1
|
import { SuiAddress } from "@mysten/sui.js";
|
|
2
2
|
import { CoinType } from "../../../coin/coinTypes";
|
|
3
|
-
import { Balance, SerializedTransaction } from "../../../../types";
|
|
4
|
-
export interface RouterAsyncApiInterface<PoolType> {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}) => Promise<
|
|
3
|
+
import { Balance, RouterAsyncSerializablePool, SerializedTransaction } from "../../../../types";
|
|
4
|
+
export interface RouterAsyncApiInterface<PoolType extends RouterAsyncSerializablePool> {
|
|
5
|
+
fetchPoolsForTrade: (inputs: {
|
|
6
|
+
coinInType: CoinType;
|
|
7
|
+
coinOutType: CoinType;
|
|
8
|
+
}) => Promise<{
|
|
9
|
+
partialMatchPools: PoolType[];
|
|
10
|
+
exactMatchPools: PoolType[];
|
|
11
|
+
}>;
|
|
9
12
|
fetchTradeAmountOut: (inputs: {
|
|
10
13
|
walletAddress: SuiAddress;
|
|
11
14
|
pool: PoolType;
|
|
@@ -13,6 +16,10 @@ export interface RouterAsyncApiInterface<PoolType> {
|
|
|
13
16
|
coinOutType: CoinType;
|
|
14
17
|
coinInAmount: Balance;
|
|
15
18
|
}) => Promise<Balance>;
|
|
19
|
+
otherCoinInPool: (inputs: {
|
|
20
|
+
coinType: CoinType;
|
|
21
|
+
pool: PoolType;
|
|
22
|
+
}) => CoinType;
|
|
16
23
|
fetchTradeTx: (inputs: {
|
|
17
24
|
walletAddress: SuiAddress;
|
|
18
25
|
pool: PoolType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routerAsyncApiInterface.d.ts","sourceRoot":"","sources":["../../../../../src/packages/router/utils/async/routerAsyncApiInterface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,
|
|
1
|
+
{"version":3,"file":"routerAsyncApiInterface.d.ts","sourceRoot":"","sources":["../../../../../src/packages/router/utils/async/routerAsyncApiInterface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EACN,OAAO,EACP,2BAA2B,EAC3B,qBAAqB,EACrB,MAAM,mBAAmB,CAAC;AAM3B,MAAM,WAAW,uBAAuB,CACvC,QAAQ,SAAS,2BAA2B;IAc5C,kBAAkB,EAAE,CAAC,MAAM,EAAE;QAC5B,UAAU,EAAE,QAAQ,CAAC;QACrB,WAAW,EAAE,QAAQ,CAAC;KACtB,KAAK,OAAO,CAAC;QACb,iBAAiB,EAAE,QAAQ,EAAE,CAAC;QAC9B,eAAe,EAAE,QAAQ,EAAE,CAAC;KAC5B,CAAC,CAAC;IAMH,mBAAmB,EAAE,CAAC,MAAM,EAAE;QAC7B,aAAa,EAAE,UAAU,CAAC;QAC1B,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,EAAE,QAAQ,CAAC;QACrB,WAAW,EAAE,QAAQ,CAAC;QACtB,YAAY,EAAE,OAAO,CAAC;KACtB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAUvB,eAAe,EAAE,CAAC,MAAM,EAAE;QACzB,QAAQ,EAAE,QAAQ,CAAC;QACnB,IAAI,EAAE,QAAQ,CAAC;KACf,KAAK,QAAQ,CAAC;IAMf,YAAY,EAAE,CAAC,MAAM,EAAE;QACtB,aAAa,EAAE,UAAU,CAAC;QAC1B,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,EAAE,QAAQ,CAAC;QACrB,WAAW,EAAE,QAAQ,CAAC;QACtB,YAAY,EAAE,OAAO,CAAC;KACtB,KAAK,OAAO,CAAC,qBAAqB,CAAC,CAAC;CACrC"}
|
|
@@ -3,10 +3,12 @@ export declare class RouterAsyncGraph {
|
|
|
3
3
|
static createFinalCompleteRoute(inputs: {
|
|
4
4
|
tradeResults: RouterAsyncTradeResults;
|
|
5
5
|
coinInAmounts: Balance[];
|
|
6
|
-
|
|
6
|
+
completeRoutes?: RouterCompleteTradeRoute[][];
|
|
7
7
|
}): RouterCompleteTradeRoute;
|
|
8
|
+
static completeRoutesFromTradeResults: (inputs: {
|
|
9
|
+
tradeResults: RouterAsyncTradeResults;
|
|
10
|
+
}) => RouterCompleteTradeRoute[][];
|
|
8
11
|
private static splitTradeBetweenRoutes;
|
|
9
12
|
private static singleCompleteRouteFromMany;
|
|
10
|
-
private static completeRoutesFromTradeResults;
|
|
11
13
|
}
|
|
12
14
|
//# sourceMappingURL=routerAsyncGraph.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routerAsyncGraph.d.ts","sourceRoot":"","sources":["../../../../../src/packages/router/utils/async/routerAsyncGraph.ts"],"names":[],"mappings":"AACA,OAAO,EACN,OAAO,EACP,uBAAuB,EACvB,wBAAwB,EAExB,MAAM,mBAAmB,CAAC;AAM3B,qBAAa,gBAAgB;WASd,wBAAwB,CAAC,MAAM,EAAE;QAC9C,YAAY,EAAE,uBAAuB,CAAC;QACtC,aAAa,EAAE,OAAO,EAAE,CAAC;QACzB,
|
|
1
|
+
{"version":3,"file":"routerAsyncGraph.d.ts","sourceRoot":"","sources":["../../../../../src/packages/router/utils/async/routerAsyncGraph.ts"],"names":[],"mappings":"AACA,OAAO,EACN,OAAO,EACP,uBAAuB,EACvB,wBAAwB,EAExB,MAAM,mBAAmB,CAAC;AAM3B,qBAAa,gBAAgB;WASd,wBAAwB,CAAC,MAAM,EAAE;QAC9C,YAAY,EAAE,uBAAuB,CAAC;QACtC,aAAa,EAAE,OAAO,EAAE,CAAC;QACzB,cAAc,CAAC,EAAE,wBAAwB,EAAE,EAAE,CAAC;KAC9C,GAAG,wBAAwB;IAqB5B,OAAc,8BAA8B,WAAY;QACvD,YAAY,EAAE,uBAAuB,CAAC;KACtC,KAAG,wBAAwB,EAAE,EAAE,CA+C9B;IAUF,OAAO,CAAC,MAAM,CAAC,uBAAuB,CA2CpC;IAEF,OAAO,CAAC,MAAM,CAAC,2BAA2B,CAqCxC;CACF"}
|