@orbs-network/twap 1.10.8 → 1.10.10
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/configs.d.ts +1 -2
- package/dist/src/configs.js +4 -9
- package/dist/src/paraswap.js +10 -4
- package/package.json +1 -1
package/dist/src/configs.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Paraswap } from "./paraswap";
|
|
2
2
|
import { Odos } from "./odos";
|
|
3
|
+
export { isNativeAddress, nativeTokenAddresses } from "@defi.org/web3-candies";
|
|
3
4
|
export interface TokenData {
|
|
4
5
|
address: string;
|
|
5
6
|
decimals: number;
|
|
@@ -1109,8 +1110,6 @@ export declare const Configs: {
|
|
|
1109
1110
|
QuickSwap: Config;
|
|
1110
1111
|
Chronos: Config;
|
|
1111
1112
|
};
|
|
1112
|
-
export declare const nativeTokenAddresses: string[];
|
|
1113
|
-
export declare const isNativeAddress: (address: string) => boolean;
|
|
1114
1113
|
export declare const chainConfig: (chainId: number) => {
|
|
1115
1114
|
twapAbi: ({
|
|
1116
1115
|
inputs: {
|
package/dist/src/configs.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.chainConfig = exports.
|
|
6
|
+
exports.chainConfig = exports.Configs = exports.ChainConfigs = exports.nativeTokenAddresses = exports.isNativeAddress = void 0;
|
|
7
7
|
const web3_candies_1 = require("@defi.org/web3-candies");
|
|
8
8
|
const lodash_1 = __importDefault(require("lodash"));
|
|
9
9
|
const paraswap_1 = require("./paraswap");
|
|
@@ -12,6 +12,9 @@ const Lens_json_1 = __importDefault(require("../artifacts/contracts/periphery/Le
|
|
|
12
12
|
const Taker_json_1 = __importDefault(require("../artifacts/contracts/periphery/Taker.sol/Taker.json"));
|
|
13
13
|
const legacy_abi_1 = require("./legacy-abi");
|
|
14
14
|
const odos_1 = require("./odos");
|
|
15
|
+
var web3_candies_2 = require("@defi.org/web3-candies");
|
|
16
|
+
Object.defineProperty(exports, "isNativeAddress", { enumerable: true, get: function () { return web3_candies_2.isNativeAddress; } });
|
|
17
|
+
Object.defineProperty(exports, "nativeTokenAddresses", { enumerable: true, get: function () { return web3_candies_2.nativeTokenAddresses; } });
|
|
15
18
|
const defaultAbis = {
|
|
16
19
|
twapAbi: TWAP_json_1.default.abi,
|
|
17
20
|
lensAbi: Lens_json_1.default.abi,
|
|
@@ -95,13 +98,5 @@ exports.Configs = {
|
|
|
95
98
|
QuickSwap: Object.assign(Object.assign({}, exports.ChainConfigs.poly), { partner: "QuickSwap", exchangeAddress: "0x26D0ec4Be402BCE03AAa8aAf0CF67e9428ba54eF", exchangeType: "ParaswapExchange", pathfinderKey: paraswap_1.Paraswap.OnlyDex.QuickSwap }),
|
|
96
99
|
Chronos: Object.assign(Object.assign({}, exports.ChainConfigs.arb), { partner: "Chronos", exchangeAddress: "0xA0b07F9a11dFb01388149abBdbc5B4f2196600AB", exchangeType: "OdosExchange", pathfinderKey: odos_1.Odos.OnlyDex.Chronos }),
|
|
97
100
|
};
|
|
98
|
-
exports.nativeTokenAddresses = [
|
|
99
|
-
web3_candies_1.zeroAddress,
|
|
100
|
-
"0x0000000000000000000000000000000000001010",
|
|
101
|
-
"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
|
102
|
-
"0x000000000000000000000000000000000000dEaD",
|
|
103
|
-
];
|
|
104
|
-
const isNativeAddress = (address) => !!lodash_1.default.find(exports.nativeTokenAddresses, (a) => (0, web3_candies_1.eqIgnoreCase)(a, address));
|
|
105
|
-
exports.isNativeAddress = isNativeAddress;
|
|
106
101
|
const chainConfig = (chainId) => lodash_1.default.find(exports.ChainConfigs, (c) => c.chainId === chainId);
|
|
107
102
|
exports.chainConfig = chainConfig;
|
package/dist/src/paraswap.js
CHANGED
|
@@ -58,7 +58,15 @@ var Paraswap;
|
|
|
58
58
|
throw new Error(`${response.statusText}`);
|
|
59
59
|
const route = (yield response.json()).priceRoute;
|
|
60
60
|
const path = getDirectPath(route, onlyDex);
|
|
61
|
-
|
|
61
|
+
let data = "";
|
|
62
|
+
try {
|
|
63
|
+
if (exchangeAdapter !== web3_candies_1.zeroAddress) {
|
|
64
|
+
data = yield buildSwapData(route, exchangeAdapter);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
console.error(e);
|
|
69
|
+
}
|
|
62
70
|
return { dstAmount: (0, bignumber_js_1.default)(route.destAmount), srcUsd: (0, bignumber_js_1.default)(route.srcUSD), dstUsd: (0, bignumber_js_1.default)(route.destUSD), data, path };
|
|
63
71
|
});
|
|
64
72
|
}
|
|
@@ -84,9 +92,7 @@ var Paraswap;
|
|
|
84
92
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
93
|
const response = yield fetch(`${URL}/transactions/${paraswapRoute.network}?ignoreChecks=true`, {
|
|
86
94
|
method: "POST",
|
|
87
|
-
headers: {
|
|
88
|
-
"Content-Type": "application/json",
|
|
89
|
-
},
|
|
95
|
+
headers: { "Content-Type": "application/json" },
|
|
90
96
|
body: JSON.stringify({
|
|
91
97
|
priceRoute: paraswapRoute,
|
|
92
98
|
srcToken: paraswapRoute.srcToken,
|