@pioneer-platform/pioneer-router 8.12.0 → 8.12.1
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/CHANGELOG.md +14 -0
- package/lib/index.d.ts +4 -32
- package/lib/index.js +118 -94
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @pioneer-platform/pioneer-router
|
|
2
2
|
|
|
3
|
+
## 8.12.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: add static file serving for /coins/ directory
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @pioneer-platform/chainflip-client@0.8.1
|
|
10
|
+
- @pioneer-platform/changelly-client@8.11.1
|
|
11
|
+
- @pioneer-platform/mayachain-client@0.8.1
|
|
12
|
+
- @pioneer-platform/osmosis-client@0.8.1
|
|
13
|
+
- @pioneer-platform/rango-client@8.11.1
|
|
14
|
+
- @pioneer-platform/thorchain-client@0.8.1
|
|
15
|
+
- @pioneer-platform/uniswap-client@0.8.1
|
|
16
|
+
|
|
3
17
|
## 8.12.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/lib/index.d.ts
CHANGED
|
@@ -8,45 +8,17 @@ declare let changelly: any;
|
|
|
8
8
|
declare let osmosis: any;
|
|
9
9
|
declare let thorchain: any;
|
|
10
10
|
declare let mayachain: any;
|
|
11
|
-
declare let uniswap: any;
|
|
12
|
-
declare let chainflip: any;
|
|
13
11
|
declare let MEMOLESS_SUPPORT: any;
|
|
14
12
|
interface Swap {
|
|
15
13
|
memoless?: boolean;
|
|
16
|
-
sellAsset: {
|
|
17
|
-
context: string;
|
|
14
|
+
sellAsset: string | {
|
|
18
15
|
caip: string;
|
|
19
|
-
|
|
20
|
-
address: string;
|
|
21
|
-
symbol: string;
|
|
22
|
-
chain: string;
|
|
23
|
-
ticker: string;
|
|
24
|
-
type: string;
|
|
25
|
-
balance: string;
|
|
26
|
-
priceUsd: number;
|
|
27
|
-
rank: number;
|
|
28
|
-
name: string;
|
|
29
|
-
source: string;
|
|
30
|
-
alias: number;
|
|
31
|
-
valueUsd: string;
|
|
16
|
+
[key: string]: any;
|
|
32
17
|
};
|
|
33
18
|
sellAmount: string;
|
|
34
|
-
buyAsset: {
|
|
35
|
-
context: string;
|
|
19
|
+
buyAsset: string | {
|
|
36
20
|
caip: string;
|
|
37
|
-
|
|
38
|
-
address: string;
|
|
39
|
-
symbol: string;
|
|
40
|
-
chain: string;
|
|
41
|
-
ticker: string;
|
|
42
|
-
type: string;
|
|
43
|
-
balance: string;
|
|
44
|
-
priceUsd: number;
|
|
45
|
-
rank: number;
|
|
46
|
-
name: string;
|
|
47
|
-
source: string;
|
|
48
|
-
alias: number;
|
|
49
|
-
valueUsd: string;
|
|
21
|
+
[key: string]: any;
|
|
50
22
|
};
|
|
51
23
|
senderAddress: string;
|
|
52
24
|
recipientAddress: string;
|
package/lib/index.js
CHANGED
|
@@ -89,10 +89,12 @@ var osmosis = require("@pioneer-platform/osmosis-client");
|
|
|
89
89
|
var thorchain = require("@pioneer-platform/thorchain-client");
|
|
90
90
|
//osmosis
|
|
91
91
|
var mayachain = require("@pioneer-platform/mayachain-client");
|
|
92
|
-
//uniswap
|
|
93
|
-
var uniswap = require("@pioneer-platform/uniswap-client");
|
|
94
92
|
//
|
|
95
|
-
|
|
93
|
+
// TEMPORARILY DISABLED - Focusing on Thorchain-only routing
|
|
94
|
+
// let uniswap = require("@pioneer-platform/uniswap-client")
|
|
95
|
+
//
|
|
96
|
+
// TEMPORARILY DISABLED - web3@4.x compatibility issue
|
|
97
|
+
// let chainflip = require("@pioneer-platform/chainflip-client")
|
|
96
98
|
//1inch/0x
|
|
97
99
|
// //bridge
|
|
98
100
|
// let across = require("@pioneer-platform/across-client")
|
|
@@ -105,43 +107,51 @@ var AssetsByIntegration = {};
|
|
|
105
107
|
module.exports = {
|
|
106
108
|
init: function () {
|
|
107
109
|
return __awaiter(this, void 0, void 0, function () {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
var _a, _b, _c, _d;
|
|
111
|
+
return __generator(this, function (_e) {
|
|
112
|
+
switch (_e.label) {
|
|
110
113
|
case 0: return [4 /*yield*/, rango.init()];
|
|
111
114
|
case 1:
|
|
112
|
-
|
|
115
|
+
_e.sent();
|
|
113
116
|
return [4 /*yield*/, changelly.init()];
|
|
114
117
|
case 2:
|
|
115
|
-
|
|
118
|
+
_e.sent();
|
|
116
119
|
return [4 /*yield*/, osmosis.init()];
|
|
117
120
|
case 3:
|
|
118
|
-
|
|
119
|
-
return [4 /*yield*/, mayachain.init()
|
|
121
|
+
_e.sent();
|
|
122
|
+
return [4 /*yield*/, mayachain.init()
|
|
123
|
+
// TEMP DISABLED: await uniswap.init()
|
|
124
|
+
];
|
|
120
125
|
case 4:
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
case 5:
|
|
124
|
-
_a.sent();
|
|
126
|
+
_e.sent();
|
|
127
|
+
// TEMP DISABLED: await uniswap.init()
|
|
125
128
|
return [4 /*yield*/, thorchain.init({})];
|
|
126
|
-
case
|
|
127
|
-
|
|
129
|
+
case 5:
|
|
130
|
+
// TEMP DISABLED: await uniswap.init()
|
|
131
|
+
_e.sent();
|
|
128
132
|
NetworksByIntegration['mayachain'] = mayachain.networkSupport();
|
|
129
133
|
NetworksByIntegration['changelly'] = changelly.networkSupport();
|
|
130
134
|
NetworksByIntegration['rango'] = rango.networkSupport();
|
|
131
135
|
NetworksByIntegration['osmosis'] = osmosis.networkSupport();
|
|
132
|
-
NetworksByIntegration['uniswap'] = uniswap.networkSupport()
|
|
136
|
+
// TEMP DISABLED: NetworksByIntegration['uniswap'] = uniswap.networkSupport()
|
|
133
137
|
// NetworksByIntegration['across'] = across.networkSupport()
|
|
134
|
-
NetworksByIntegration['chainflip'] = chainflip.networkSupport()
|
|
138
|
+
// TEMP DISABLED: NetworksByIntegration['chainflip'] = chainflip.networkSupport()
|
|
135
139
|
NetworksByIntegration['thorchain'] = thorchain.networkSupport();
|
|
136
140
|
//get assets
|
|
137
141
|
AssetsByIntegration['mayachain'] = mayachain.assetSupport();
|
|
138
142
|
AssetsByIntegration['changelly'] = changelly.assetSupport();
|
|
139
143
|
AssetsByIntegration['rango'] = rango.assetSupport();
|
|
140
144
|
AssetsByIntegration['osmosis'] = osmosis.assetSupport();
|
|
141
|
-
AssetsByIntegration['uniswap'] = uniswap.assetSupport()
|
|
145
|
+
// TEMP DISABLED: AssetsByIntegration['uniswap'] = uniswap.assetSupport()
|
|
142
146
|
AssetsByIntegration['thorchain'] = thorchain.assetSupport();
|
|
143
147
|
// AssetsByIntegration['across'] = across.assetSupport()
|
|
144
|
-
AssetsByIntegration['chainflip'] = chainflip.assetSupport()
|
|
148
|
+
// TEMP DISABLED: AssetsByIntegration['chainflip'] = chainflip.assetSupport()
|
|
149
|
+
// DEBUG: Log Thorchain assets to console
|
|
150
|
+
console.log("\n🔍 THORCHAIN ASSETS DEBUG:");
|
|
151
|
+
console.log("Total assets:", ((_a = AssetsByIntegration['thorchain']) === null || _a === void 0 ? void 0 : _a.length) || 0);
|
|
152
|
+
console.log("Contains BTC:", (_b = AssetsByIntegration['thorchain']) === null || _b === void 0 ? void 0 : _b.includes('bip122:000000000019d6689c085ae165831e93/slip44:0'));
|
|
153
|
+
console.log("Contains ETH.USDC:", (_c = AssetsByIntegration['thorchain']) === null || _c === void 0 ? void 0 : _c.includes('eip155:1/erc20:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'));
|
|
154
|
+
console.log("First 10 assets:", (_d = AssetsByIntegration['thorchain']) === null || _d === void 0 ? void 0 : _d.slice(0, 10));
|
|
145
155
|
return [2 /*return*/, true];
|
|
146
156
|
}
|
|
147
157
|
});
|
|
@@ -166,7 +176,7 @@ module.exports = {
|
|
|
166
176
|
};
|
|
167
177
|
function get_quote_from_integration(integration, quote) {
|
|
168
178
|
return __awaiter(this, void 0, void 0, function () {
|
|
169
|
-
var tag, _a, thorchainNameSellAsset, thorchainBuyAsset, payloadThorchain, quoteThorchain, rangoNameSellAsset, rangoNameBuyAsset, payloadRango, quoteRango, payloadOsmosis, quoteOsmosis, from, to, address, amount, quoteChangelly,
|
|
179
|
+
var tag, sellAssetCaip, buyAssetCaip, extractSymbolFromCaip, _a, thorchainNameSellAsset, thorchainBuyAsset, payloadThorchain, quoteThorchain, rangoNameSellAsset, rangoNameBuyAsset, payloadRango, quoteRango, payloadOsmosis, quoteOsmosis, from, to, address, amount, quoteChangelly, mayaSellAsset, mayaBuyAsset, payloadMayachain, quoteMayachain, e_1;
|
|
170
180
|
var _b;
|
|
171
181
|
return __generator(this, function (_c) {
|
|
172
182
|
switch (_c.label) {
|
|
@@ -174,7 +184,19 @@ function get_quote_from_integration(integration, quote) {
|
|
|
174
184
|
tag = TAG + " | get_quote_from_integration | ";
|
|
175
185
|
_c.label = 1;
|
|
176
186
|
case 1:
|
|
177
|
-
_c.trys.push([1,
|
|
187
|
+
_c.trys.push([1, 14, , 15]);
|
|
188
|
+
sellAssetCaip = typeof quote.sellAsset === 'string' ? quote.sellAsset : quote.sellAsset.caip;
|
|
189
|
+
buyAssetCaip = typeof quote.buyAsset === 'string' ? quote.buyAsset : quote.buyAsset.caip;
|
|
190
|
+
extractSymbolFromCaip = function (caip) {
|
|
191
|
+
// This is a simple extraction - you may want to use a proper CAIP parser
|
|
192
|
+
var parts = caip.split('/');
|
|
193
|
+
if (parts.length > 1) {
|
|
194
|
+
// For now, return the chain identifier
|
|
195
|
+
// You might need a proper CAIP-to-symbol mapping
|
|
196
|
+
return parts[0].split(':')[0].toUpperCase();
|
|
197
|
+
}
|
|
198
|
+
return '';
|
|
199
|
+
};
|
|
178
200
|
_a = integration;
|
|
179
201
|
switch (_a) {
|
|
180
202
|
case "thorchain": return [3 /*break*/, 2];
|
|
@@ -182,24 +204,18 @@ function get_quote_from_integration(integration, quote) {
|
|
|
182
204
|
case "osmosis": return [3 /*break*/, 6];
|
|
183
205
|
case "changelly": return [3 /*break*/, 8];
|
|
184
206
|
case "mayachain": return [3 /*break*/, 10];
|
|
185
|
-
case "uniswap": return [3 /*break*/, 12];
|
|
186
|
-
case "chainflip": return [3 /*break*/, 14];
|
|
187
207
|
}
|
|
188
|
-
return [3 /*break*/,
|
|
208
|
+
return [3 /*break*/, 12];
|
|
189
209
|
case 2:
|
|
190
210
|
log.info(tag, "thorchain quote: ", quote);
|
|
191
211
|
if (!quote.senderAddress)
|
|
192
212
|
throw Error('invalid quote! missing senderAddress');
|
|
193
213
|
if (!quote.recipientAddress)
|
|
194
214
|
throw Error('invalid quote! missing recipientAddress');
|
|
195
|
-
thorchainNameSellAsset =
|
|
196
|
-
thorchainBuyAsset =
|
|
215
|
+
thorchainNameSellAsset = thorchain.caipToAssetName(sellAssetCaip);
|
|
216
|
+
thorchainBuyAsset = thorchain.caipToAssetName(buyAssetCaip);
|
|
197
217
|
log.info(tag, "thorchainBuyAsset: ", thorchainBuyAsset);
|
|
198
218
|
log.info(tag, "thorchainNameSellAsset: ", thorchainNameSellAsset);
|
|
199
|
-
if (thorchainBuyAsset === 'THOR.THOR')
|
|
200
|
-
thorchainBuyAsset = 'THOR.RUNE';
|
|
201
|
-
if (thorchainNameSellAsset === 'THOR.THOR')
|
|
202
|
-
thorchainNameSellAsset = 'THOR.RUNE';
|
|
203
219
|
if (!thorchainNameSellAsset)
|
|
204
220
|
throw Error('invalid thorchainNameSellAsset');
|
|
205
221
|
if (!thorchainBuyAsset)
|
|
@@ -218,8 +234,8 @@ function get_quote_from_integration(integration, quote) {
|
|
|
218
234
|
quoteThorchain = _c.sent();
|
|
219
235
|
return [2 /*return*/, [quoteThorchain]];
|
|
220
236
|
case 4:
|
|
221
|
-
rangoNameSellAsset = caipToRango(
|
|
222
|
-
rangoNameBuyAsset = caipToRango(
|
|
237
|
+
rangoNameSellAsset = caipToRango(sellAssetCaip, null, null);
|
|
238
|
+
rangoNameBuyAsset = caipToRango(buyAssetCaip, null, null);
|
|
223
239
|
payloadRango = {
|
|
224
240
|
"from": rangoNameSellAsset,
|
|
225
241
|
"to": rangoNameBuyAsset,
|
|
@@ -228,19 +244,19 @@ function get_quote_from_integration(integration, quote) {
|
|
|
228
244
|
{
|
|
229
245
|
"blockchain": rangoNameSellAsset.blockchain,
|
|
230
246
|
"addresses": [
|
|
231
|
-
quote.
|
|
247
|
+
quote.senderAddress
|
|
232
248
|
]
|
|
233
249
|
},
|
|
234
250
|
{
|
|
235
251
|
"blockchain": rangoNameBuyAsset.blockchain,
|
|
236
252
|
"addresses": [
|
|
237
|
-
quote.
|
|
253
|
+
quote.recipientAddress
|
|
238
254
|
]
|
|
239
255
|
}
|
|
240
256
|
],
|
|
241
257
|
"selectedWallets": (_b = {},
|
|
242
|
-
_b[rangoNameBuyAsset.blockchain] = quote.
|
|
243
|
-
_b[rangoNameSellAsset.blockchain] = quote.
|
|
258
|
+
_b[rangoNameBuyAsset.blockchain] = quote.recipientAddress,
|
|
259
|
+
_b[rangoNameSellAsset.blockchain] = quote.senderAddress,
|
|
244
260
|
_b),
|
|
245
261
|
"checkPrerequisites": false,
|
|
246
262
|
"affiliateRef": null
|
|
@@ -252,8 +268,8 @@ function get_quote_from_integration(integration, quote) {
|
|
|
252
268
|
return [2 /*return*/, [quoteRango]];
|
|
253
269
|
case 6:
|
|
254
270
|
payloadOsmosis = {
|
|
255
|
-
sellAsset:
|
|
256
|
-
buyAsset:
|
|
271
|
+
sellAsset: sellAssetCaip,
|
|
272
|
+
buyAsset: buyAssetCaip,
|
|
257
273
|
sellAmount: quote.sellAmount,
|
|
258
274
|
senderAddress: quote.senderAddress,
|
|
259
275
|
recipientAddress: quote.recipientAddress,
|
|
@@ -264,9 +280,9 @@ function get_quote_from_integration(integration, quote) {
|
|
|
264
280
|
quoteOsmosis = _c.sent();
|
|
265
281
|
return [2 /*return*/, [quoteOsmosis]];
|
|
266
282
|
case 8:
|
|
267
|
-
from =
|
|
268
|
-
to =
|
|
269
|
-
address = quote.
|
|
283
|
+
from = extractSymbolFromCaip(sellAssetCaip);
|
|
284
|
+
to = extractSymbolFromCaip(buyAssetCaip);
|
|
285
|
+
address = quote.recipientAddress;
|
|
270
286
|
amount = quote.sellAmount;
|
|
271
287
|
log.info({
|
|
272
288
|
from: from,
|
|
@@ -279,9 +295,15 @@ function get_quote_from_integration(integration, quote) {
|
|
|
279
295
|
quoteChangelly = _c.sent();
|
|
280
296
|
return [2 /*return*/, [quoteChangelly]];
|
|
281
297
|
case 10:
|
|
298
|
+
mayaSellAsset = caipToThorchain(sellAssetCaip, null, null);
|
|
299
|
+
mayaBuyAsset = caipToThorchain(buyAssetCaip, null, null);
|
|
300
|
+
if (!mayaSellAsset)
|
|
301
|
+
throw Error('invalid mayaSellAsset');
|
|
302
|
+
if (!mayaBuyAsset)
|
|
303
|
+
throw Error('invalid mayaBuyAsset');
|
|
282
304
|
payloadMayachain = {
|
|
283
|
-
sellAsset:
|
|
284
|
-
buyAsset:
|
|
305
|
+
sellAsset: mayaSellAsset,
|
|
306
|
+
buyAsset: mayaBuyAsset,
|
|
285
307
|
sellAmount: quote.sellAmount,
|
|
286
308
|
senderAddress: quote.senderAddress,
|
|
287
309
|
recipientAddress: quote.recipientAddress,
|
|
@@ -291,35 +313,33 @@ function get_quote_from_integration(integration, quote) {
|
|
|
291
313
|
return [4 /*yield*/, mayachain.getQuote(payloadMayachain)];
|
|
292
314
|
case 11:
|
|
293
315
|
quoteMayachain = _c.sent();
|
|
294
|
-
return [2 /*return*/, [quoteMayachain]
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
sellAsset: quote.sellAsset.caip,
|
|
313
|
-
buyAsset: quote.buyAsset.caip,
|
|
314
|
-
sellAmount: quote.sellAmount,
|
|
315
|
-
recipientAddress: quote.recipientAddress,
|
|
316
|
-
slippage: quote.slippage
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
quoteChainflip = _c.sent();
|
|
322
|
-
return [2 /*return*/, [quoteChainflip]
|
|
316
|
+
return [2 /*return*/, [quoteMayachain]
|
|
317
|
+
// TEMP DISABLED - Focusing on Thorchain-only routing
|
|
318
|
+
// case "uniswap":
|
|
319
|
+
// let payloadUniswap = {
|
|
320
|
+
// sellAsset: quote.sellAsset,
|
|
321
|
+
// buyAsset: quote.buyAsset,
|
|
322
|
+
// sellAmount: quote.sellAmount,
|
|
323
|
+
// senderAddress: quote.senderAddress,
|
|
324
|
+
// recipientAddress: quote.recipientAddress,
|
|
325
|
+
// slippage: quote.slippage
|
|
326
|
+
// }
|
|
327
|
+
// log.info(tag,"payloadUniswap: ",payloadUniswap)
|
|
328
|
+
// let quoteUniswap = await uniswap.getQuote(payloadUniswap)
|
|
329
|
+
// log.info(tag,"quoteUniswap: ",quoteUniswap)
|
|
330
|
+
// return [quoteUniswap]
|
|
331
|
+
// TEMP DISABLED - web3 compatibility issue
|
|
332
|
+
// case "chainflip":
|
|
333
|
+
// let payloadChainflip = {
|
|
334
|
+
// sellAsset: quote.sellAsset.caip,
|
|
335
|
+
// buyAsset: quote.buyAsset.caip,
|
|
336
|
+
// sellAmount: quote.sellAmount,
|
|
337
|
+
// recipientAddress: quote.recipientAddress,
|
|
338
|
+
// slippage: quote.slippage
|
|
339
|
+
// }
|
|
340
|
+
// log.info(tag,"payloadChainflip: ",payloadChainflip)
|
|
341
|
+
// let quoteChainflip = await chainflip.getQuote(payloadChainflip)
|
|
342
|
+
// return [quoteChainflip]
|
|
323
343
|
// case "across":
|
|
324
344
|
// let payloadAcross = {
|
|
325
345
|
// sellAsset: quote.sellAsset.caip,
|
|
@@ -333,13 +353,13 @@ function get_quote_from_integration(integration, quote) {
|
|
|
333
353
|
// let quotedAcross = await accross.getQuote(payloadAcross)
|
|
334
354
|
// return [quotedAcross]
|
|
335
355
|
];
|
|
336
|
-
case
|
|
337
|
-
case
|
|
338
|
-
case
|
|
356
|
+
case 12: throw new Error("Intergration not found");
|
|
357
|
+
case 13: return [3 /*break*/, 15];
|
|
358
|
+
case 14:
|
|
339
359
|
e_1 = _c.sent();
|
|
340
360
|
log.error(tag, "Error: ", e_1);
|
|
341
361
|
return [2 /*return*/, null];
|
|
342
|
-
case
|
|
362
|
+
case 15: return [2 /*return*/];
|
|
343
363
|
}
|
|
344
364
|
});
|
|
345
365
|
});
|
|
@@ -375,7 +395,7 @@ var get_pro_rate_usd = function () {
|
|
|
375
395
|
};
|
|
376
396
|
function get_quote(quote) {
|
|
377
397
|
return __awaiter(this, void 0, void 0, function () {
|
|
378
|
-
var tag, sellChain, buyChain, integrations, quotes, supportsInput, supportsOutput, supportsBoth, _i, integrations_1, integration, supportedAssets, supportsInputOnly, supportsOutputOnly, supportsBothAssets, integrationQuotes, i, integrationQuote,
|
|
398
|
+
var tag, sellAssetCaip, buyAssetCaip, sellChain, buyChain, integrations, quotes, supportsInput, supportsOutput, supportsBoth, _i, integrations_1, integration, supportedAssets, supportsInputOnly, supportsOutputOnly, supportsBothAssets, integrationQuotes, i, integrationQuote, err_1;
|
|
379
399
|
return __generator(this, function (_a) {
|
|
380
400
|
switch (_a.label) {
|
|
381
401
|
case 0:
|
|
@@ -383,12 +403,21 @@ function get_quote(quote) {
|
|
|
383
403
|
_a.label = 1;
|
|
384
404
|
case 1:
|
|
385
405
|
_a.trys.push([1, 6, , 7]);
|
|
386
|
-
|
|
387
|
-
|
|
406
|
+
log.info(tag, "========== QUOTE DEBUG START ==========");
|
|
407
|
+
log.info(tag, "Requested swap:");
|
|
408
|
+
log.info(tag, " sellAsset:", quote.sellAsset);
|
|
409
|
+
log.info(tag, " buyAsset:", quote.buyAsset);
|
|
410
|
+
log.info(tag, " sellAmount:", quote.sellAmount);
|
|
411
|
+
sellAssetCaip = typeof quote.sellAsset === 'string' ? quote.sellAsset : quote.sellAsset.caip;
|
|
412
|
+
buyAssetCaip = typeof quote.buyAsset === 'string' ? quote.buyAsset : quote.buyAsset.caip;
|
|
413
|
+
sellChain = caipToNetworkId(sellAssetCaip);
|
|
414
|
+
buyChain = caipToNetworkId(buyAssetCaip);
|
|
388
415
|
integrations = Object.keys(NetworksByIntegration);
|
|
389
416
|
quotes = [];
|
|
390
417
|
log.info("sellChain: ", sellChain);
|
|
391
418
|
log.info("buyChain: ", buyChain);
|
|
419
|
+
// Log all integration assets for debugging
|
|
420
|
+
log.info(tag, "AssetsByIntegration:", JSON.stringify(AssetsByIntegration, null, 2));
|
|
392
421
|
// Filter integrations for memoless support if applicable
|
|
393
422
|
if (quote.memoless) {
|
|
394
423
|
integrations = integrations.filter(function (integration) { return MEMOLESS_SUPPORT[integration]; });
|
|
@@ -403,20 +432,20 @@ function get_quote(quote) {
|
|
|
403
432
|
integration = integrations_1[_i];
|
|
404
433
|
supportedAssets = AssetsByIntegration[integration];
|
|
405
434
|
log.info(tag, integration + " supportedAssets: ", supportedAssets);
|
|
406
|
-
supportsInputOnly = supportedAssets.includes(
|
|
407
|
-
supportsOutputOnly = !supportedAssets.includes(
|
|
408
|
-
supportsBothAssets = supportedAssets.includes(
|
|
435
|
+
supportsInputOnly = supportedAssets.includes(sellAssetCaip);
|
|
436
|
+
supportsOutputOnly = !supportedAssets.includes(sellAssetCaip) && supportedAssets.includes(buyAssetCaip);
|
|
437
|
+
supportsBothAssets = supportedAssets.includes(sellAssetCaip) && supportedAssets.includes(buyAssetCaip);
|
|
409
438
|
if (supportsInputOnly) {
|
|
410
439
|
supportsInput.push(integration);
|
|
411
|
-
log.info(tag, integration + " supports input asset: ",
|
|
440
|
+
log.info(tag, integration + " supports input asset: ", sellAssetCaip);
|
|
412
441
|
}
|
|
413
442
|
if (supportsOutputOnly) {
|
|
414
443
|
supportsOutput.push(integration);
|
|
415
|
-
log.info(tag, integration + " supports output asset: ",
|
|
444
|
+
log.info(tag, integration + " supports output asset: ", buyAssetCaip);
|
|
416
445
|
}
|
|
417
446
|
if (supportsBothAssets) {
|
|
418
447
|
supportsBoth.push(integration);
|
|
419
|
-
log.info(tag, integration + " supports both assets: ",
|
|
448
|
+
log.info(tag, integration + " supports both assets: ", sellAssetCaip, buyAssetCaip);
|
|
420
449
|
}
|
|
421
450
|
if (!supportsBothAssets) return [3 /*break*/, 4];
|
|
422
451
|
log.info(tag, "Found supported integration for both assets:", integration);
|
|
@@ -426,19 +455,14 @@ function get_quote(quote) {
|
|
|
426
455
|
if (integrationQuotes) {
|
|
427
456
|
for (i = 0; i < integrationQuotes.length; i++) {
|
|
428
457
|
integrationQuote = integrationQuotes[i];
|
|
429
|
-
integrationQuote.sellAsset =
|
|
458
|
+
integrationQuote.sellAsset = sellAssetCaip;
|
|
430
459
|
integrationQuote.sellAmount = quote.sellAmount;
|
|
431
|
-
integrationQuote.buyAsset =
|
|
460
|
+
integrationQuote.buyAsset = buyAssetCaip;
|
|
432
461
|
integrationQuote.buyAmount = integrationQuote.amountOut;
|
|
433
462
|
if (integrationQuote.amountOut > 0) {
|
|
434
463
|
log.info("integrationQuote.amountOut: ", integrationQuote.amountOut);
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
//let proTokenEarned = sellAssetValueUsd * 0.1; // For every 1 USD, they earn 0.01 PRO token
|
|
438
|
-
//integrationQuote.proTokenEarned = proTokenEarned;
|
|
439
|
-
//integrationQuote.proTokenEarnedUsd = proTokenEarned * await get_pro_rate_usd(); //TODO get dynamic price
|
|
440
|
-
integrationQuote.sellAssetValueUsd = sellAssetValueUsd;
|
|
441
|
-
integrationQuote.buyAssetValueUsd = buyAssetValueUsd;
|
|
464
|
+
// Note: priceUsd calculation removed - not needed for quote comparison
|
|
465
|
+
// Integrations already provide amountOut which is sufficient
|
|
442
466
|
quotes.push({ integration: integration, quote: integrationQuote });
|
|
443
467
|
}
|
|
444
468
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/pioneer-router",
|
|
3
|
-
"version": "8.12.
|
|
3
|
+
"version": "8.12.1",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -21,19 +21,19 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@coinmasters/types": "^4.10.2",
|
|
24
|
-
"@pioneer-platform/chainflip-client": "^0.8.
|
|
25
|
-
"@pioneer-platform/changelly-client": "^8.11.
|
|
24
|
+
"@pioneer-platform/chainflip-client": "^0.8.1",
|
|
25
|
+
"@pioneer-platform/changelly-client": "^8.11.1",
|
|
26
26
|
"@pioneer-platform/loggerdog": "^8.11.0",
|
|
27
|
-
"@pioneer-platform/mayachain-client": "^0.8.
|
|
28
|
-
"@pioneer-platform/osmosis-client": "^0.8.
|
|
27
|
+
"@pioneer-platform/mayachain-client": "^0.8.1",
|
|
28
|
+
"@pioneer-platform/osmosis-client": "^0.8.1",
|
|
29
29
|
"@pioneer-platform/pioneer-caip": "^9.10.0",
|
|
30
30
|
"@pioneer-platform/pro-token": "^0.8.0",
|
|
31
|
-
"@pioneer-platform/rango-client": "^8.11.
|
|
32
|
-
"@pioneer-platform/thorchain-client": "^0.8.
|
|
33
|
-
"@pioneer-platform/uniswap-client": "^0.8.
|
|
31
|
+
"@pioneer-platform/rango-client": "^8.11.1",
|
|
32
|
+
"@pioneer-platform/thorchain-client": "^0.8.1",
|
|
33
|
+
"@pioneer-platform/uniswap-client": "^0.8.1",
|
|
34
34
|
"@uniswap/sdk-core": "^4.2.0",
|
|
35
35
|
"@uniswap/universal-router-sdk": "^1.9.0",
|
|
36
|
-
"dotenv": "^
|
|
36
|
+
"dotenv": "^17.2.3",
|
|
37
37
|
"short-uuid": "^4.2.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|