@orbs-network/twap 1.20.0 → 1.21.0
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/src/lib.d.ts +1 -0
- package/dist/src/lib.js +13 -24
- package/package.json +1 -1
package/dist/src/lib.d.ts
CHANGED
package/dist/src/lib.js
CHANGED
|
@@ -244,37 +244,26 @@ class TWAPLib {
|
|
|
244
244
|
priceUsd(token) {
|
|
245
245
|
return __awaiter(this, void 0, void 0, function* () {
|
|
246
246
|
token = (0, web3_candies_1.isNativeAddress)(token.address) ? this.config.wToken : token;
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
return r.srcUsd.toNumber();
|
|
250
|
-
}
|
|
251
|
-
catch (e) {
|
|
252
|
-
try {
|
|
253
|
-
const r = yield odos_1.Odos.findRoute(this.config.chainId, token, this.config.nativeToken, (0, bignumber_js_1.default)(10).pow(token.decimals));
|
|
254
|
-
return r.srcUsd.toNumber();
|
|
255
|
-
}
|
|
256
|
-
catch (e) {
|
|
257
|
-
const r = yield openocean_1.OpenOcean.findRoute(this.config.chainId, token, this.config.nativeToken, (0, bignumber_js_1.default)(10).pow(token.decimals));
|
|
258
|
-
return r.srcUsd.toNumber();
|
|
259
|
-
}
|
|
260
|
-
}
|
|
247
|
+
const r = yield this.solverRoute(token, this.config.nativeToken, (0, bignumber_js_1.default)(10).pow(token.decimals));
|
|
248
|
+
return r.srcUsd.toNumber();
|
|
261
249
|
});
|
|
262
250
|
}
|
|
263
251
|
findRoute(srcToken, dstToken, srcAmount) {
|
|
264
252
|
return __awaiter(this, void 0, void 0, function* () {
|
|
265
|
-
|
|
266
|
-
if (this.config.exchangeType === "OdosExchange") {
|
|
267
|
-
route = yield odos_1.Odos.findRoute(this.config.chainId, srcToken, dstToken, srcAmount, this.config.exchangeAddress, this.config.pathfinderKey, this.config.partner);
|
|
268
|
-
}
|
|
269
|
-
else if (this.config.exchangeType === "OpenOceanExchange") {
|
|
270
|
-
route = yield openocean_1.OpenOcean.findRoute(this.config.chainId, srcToken, dstToken, srcAmount, this.config.exchangeAddress, this.config.pathfinderKey, this.config.partner);
|
|
271
|
-
}
|
|
272
|
-
else {
|
|
273
|
-
route = yield paraswap_1.Paraswap.findRoute(this.config.chainId, srcToken, dstToken, srcAmount, this.config.exchangeAddress, this.config.pathfinderKey, this.config.partner);
|
|
274
|
-
}
|
|
253
|
+
const route = yield this.solverRoute(srcToken, dstToken, srcAmount);
|
|
275
254
|
return Object.assign(Object.assign({}, route), { data: this.encodeBidData(route), srcToken, dstToken, srcAmount });
|
|
276
255
|
});
|
|
277
256
|
}
|
|
257
|
+
solverRoute(srcToken, dstToken, srcAmount) {
|
|
258
|
+
switch (this.config.exchangeType) {
|
|
259
|
+
case "OdosExchange":
|
|
260
|
+
return odos_1.Odos.findRoute(this.config.chainId, srcToken, dstToken, srcAmount, this.config.exchangeAddress, this.config.pathfinderKey, this.config.partner);
|
|
261
|
+
case "OpenOceanExchange":
|
|
262
|
+
return openocean_1.OpenOcean.findRoute(this.config.chainId, srcToken, dstToken, srcAmount, this.config.exchangeAddress, this.config.pathfinderKey, this.config.partner);
|
|
263
|
+
default:
|
|
264
|
+
return paraswap_1.Paraswap.findRoute(this.config.chainId, srcToken, dstToken, srcAmount, this.config.exchangeAddress, this.config.pathfinderKey, this.config.partner);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
278
267
|
findRouteForNextBid(order) {
|
|
279
268
|
return __awaiter(this, void 0, void 0, function* () {
|
|
280
269
|
if (order.ask.exchange !== web3_candies_1.zeroAddress && !(0, web3_candies_1.eqIgnoreCase)(order.ask.exchange, this.config.exchangeAddress))
|