@paraswap/dex-lib 3.11.7 → 3.11.8-bebop-incr-timeout.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.
@@ -6,7 +6,7 @@ export declare const BEBOP_API_URL = "https://api.bebop.xyz";
6
6
  export declare const BEBOP_WS_API_URL = "wss://api.bebop.xyz";
7
7
  export declare const BEBOP_GAS_COST = 120000;
8
8
  export declare const BEBOP_AUTH_NAME = "paraswap";
9
- export declare const BEBOP_QUOTE_TIMEOUT_MS = 2000;
9
+ export declare const BEBOP_QUOTE_TIMEOUT_MS = 3000;
10
10
  export declare const BEBOP_ERRORS_CACHE_KEY = "errors";
11
11
  export declare const BEBOP_RESTRICTED_CACHE_KEY = "restricted";
12
12
  export declare const BEBOP_RESTRICT_TTL_S: number;
@@ -9,7 +9,7 @@ exports.BEBOP_API_URL = 'https://api.bebop.xyz';
9
9
  exports.BEBOP_WS_API_URL = 'wss://api.bebop.xyz';
10
10
  exports.BEBOP_GAS_COST = 120000;
11
11
  exports.BEBOP_AUTH_NAME = 'paraswap';
12
- exports.BEBOP_QUOTE_TIMEOUT_MS = 2000;
12
+ exports.BEBOP_QUOTE_TIMEOUT_MS = 3000;
13
13
  exports.BEBOP_ERRORS_CACHE_KEY = 'errors';
14
14
  exports.BEBOP_RESTRICTED_CACHE_KEY = 'restricted';
15
15
  // Restrict for BEBOP_RESTRICT_TTL_S if an error occured >= BEBOP_RESTRICT_COUNT_THRESHOLD times within BEBOP_RESTRICT_CHECK_INTERVAL_S interval
@@ -0,0 +1,3 @@
1
+ import { DexParams } from './types';
2
+ import { DexConfigMap } from '../../types';
3
+ export declare const StaderConfig: DexConfigMap<DexParams>;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StaderConfig = void 0;
4
+ const constants_1 = require("../../constants");
5
+ exports.StaderConfig = {
6
+ Stader: {
7
+ [constants_1.Network.MAINNET]: {
8
+ ETHx: '0xA35b1B31Ce002FBF2058D22F30f95D405200A15b',
9
+ SSPM: '0xcf5EA1b38380f6aF39068375516Daf40Ed70D299',
10
+ StaderOracle: '0xF64bAe65f6f2a5277571143A24FaaFDFC0C2a737',
11
+ },
12
+ },
13
+ };
14
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/stader/config.ts"],"names":[],"mappings":";;;AAEA,+CAAoD;AAEvC,QAAA,YAAY,GAA4B;IACnD,MAAM,EAAE;QACN,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,IAAI,EAAE,4CAA4C;YAClD,IAAI,EAAE,4CAA4C;YAClD,YAAY,EAAE,4CAA4C;SAC3D;KACF;CACF,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { Interface } from '@ethersproject/abi';
2
+ import { IDexHelper } from '../../dex-helper/idex-helper';
3
+ import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
4
+ import { Address, Log, Logger } from '../../types';
5
+ import { DeepReadonly } from 'ts-essentials';
6
+ import { ETHxPoolState } from './types';
7
+ export declare class ETHxEventPool extends StatefulEventSubscriber<ETHxPoolState> {
8
+ protected dexHelper: IDexHelper;
9
+ private poolAddress;
10
+ private poolInterface;
11
+ decoder: (log: Log) => import("@ethersproject/abi").LogDescription;
12
+ DECIMALS: bigint;
13
+ addressesSubscribed: string[];
14
+ constructor(parentName: string, dexHelper: IDexHelper, poolAddress: Address, poolInterface: Interface, logger: Logger);
15
+ protected processLog(state: DeepReadonly<ETHxPoolState>, log: Readonly<Log>): DeepReadonly<ETHxPoolState> | null;
16
+ generateState(blockNumber: number): Promise<DeepReadonly<ETHxPoolState>>;
17
+ getPrice(blockNumber: number, ethAmount: bigint): bigint;
18
+ }
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ETHxEventPool = void 0;
4
+ const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
5
+ const utils_1 = require("../../utils");
6
+ const utils_2 = require("./utils");
7
+ class ETHxEventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
8
+ constructor(parentName, dexHelper, poolAddress, poolInterface, logger) {
9
+ super(parentName, 'ETHx', dexHelper, logger);
10
+ this.dexHelper = dexHelper;
11
+ this.poolAddress = poolAddress;
12
+ this.poolInterface = poolInterface;
13
+ this.decoder = (log) => this.poolInterface.parseLog(log);
14
+ this.DECIMALS = 1000000000000000000n;
15
+ this.addressesSubscribed = [poolAddress];
16
+ }
17
+ processLog(state, log) {
18
+ try {
19
+ const event = this.decoder(log);
20
+ if (event.name === 'ExchangeRateUpdated') {
21
+ const totalEth = BigInt(event.args.totalEth);
22
+ const ethxSupply = BigInt(event.args.ethxSupply);
23
+ return {
24
+ totalETHBalance: totalEth,
25
+ totalETHXSupply: ethxSupply,
26
+ };
27
+ }
28
+ }
29
+ catch (e) {
30
+ (0, utils_1.catchParseLogError)(e, this.logger);
31
+ }
32
+ return null;
33
+ }
34
+ async generateState(blockNumber) {
35
+ const state = await (0, utils_2.getOnChainStateETHx)(this.dexHelper.multiContract, this.poolAddress, this.poolInterface, blockNumber);
36
+ return state;
37
+ }
38
+ getPrice(blockNumber, ethAmount) {
39
+ const state = this.getState(blockNumber);
40
+ if (!state)
41
+ throw new Error('Cannot compute price');
42
+ const { totalETHBalance, totalETHXSupply } = state;
43
+ return (ethAmount * totalETHXSupply) / totalETHBalance;
44
+ }
45
+ }
46
+ exports.ETHxEventPool = ETHxEventPool;
47
+ //# sourceMappingURL=stader-pool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stader-pool.js","sourceRoot":"","sources":["../../../src/dex/stader/stader-pool.ts"],"names":[],"mappings":";;;AAEA,+EAA0E;AAG1E,uCAAiD;AAEjD,mCAA8C;AAG9C,MAAa,aAAc,SAAQ,mDAAsC;IAKvE,YACE,UAAkB,EACR,SAAqB,EACvB,WAAoB,EACpB,aAAwB,EAChC,M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,CAAC,WAAW,CAAC,CAAC;QACzC,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QACpD,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,GAAG,KAAK,CAAC;QAEnD,OAAO,CAAC,SAAS,GAAG,eAAe,CAAC,GAAG,eAAe,CAAC;IACzD,CAAC;CACF;AAzDD,sCAyDC"}
@@ -0,0 +1,42 @@
1
+ import { Interface } from '@ethersproject/abi';
2
+ import { NumberAsString, SwapSide } from '@paraswap/core';
3
+ import { AdapterExchangeParam, Address, DexExchangeParam, ExchangePrices, Logger, PoolLiquidity, PoolPrices, Token, TransferFeeParams } from '../../types';
4
+ import { IDexTxBuilder } from '../idex';
5
+ import { Network } from '../../constants';
6
+ import { IDexHelper } from '../../dex-helper';
7
+ import { SimpleExchange } from '../simple-exchange';
8
+ import { AsyncOrSync } from 'ts-essentials';
9
+ import { ETHxEventPool } from './stader-pool';
10
+ import { StaderData } from './types';
11
+ export declare class Stader extends SimpleExchange implements IDexTxBuilder<StaderData, any> {
12
+ protected network: Network;
13
+ protected config: import("./types").DexParams;
14
+ static dexKeys: string[];
15
+ ETHxAddress: string;
16
+ SSPM_Address: string;
17
+ SSPMInterface: Interface;
18
+ StaderOracleAddress: string;
19
+ StaderOracleInterface: Interface;
20
+ erc20Interface: Interface;
21
+ needWrapNative: boolean;
22
+ ethxPool: ETHxEventPool;
23
+ logger: Logger;
24
+ hasConstantPriceLargeAmounts: boolean;
25
+ static dexKeysWithNetwork: {
26
+ key: string;
27
+ networks: Network[];
28
+ }[];
29
+ constructor(network: Network, dexKey: string, dexHelper: IDexHelper, config?: import("./types").DexParams);
30
+ getAdapterParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, data: StaderData, side: SwapSide): AdapterExchangeParam;
31
+ initializePricing(blockNumber: number): Promise<void>;
32
+ getPricesVolume(srcToken: Token, destToken: Token, amountsIn: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[] | undefined, transferFees?: TransferFeeParams | undefined, isFirstSwap?: boolean | undefined): Promise<ExchangePrices<StaderData> | null>;
33
+ isEligibleSwap(srcToken: Token | string, destToken: Token | string, side: SwapSide): boolean;
34
+ getDexParam(srcToken: Address, _destToken: Address, srcAmount: NumberAsString, _destAmount: NumberAsString, _recipient: Address, _data: StaderData, _side: SwapSide): DexExchangeParam;
35
+ getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
36
+ getCalldataGasCost(poolPrices: PoolPrices<StaderData>): number | number[];
37
+ getAdapters(side: SwapSide): {
38
+ name: string;
39
+ index: number;
40
+ }[] | null;
41
+ getTopPoolsForToken(tokenAddress: string, limit: number): AsyncOrSync<PoolLiquidity[]>;
42
+ }
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.Stader = void 0;
30
+ const abi_1 = require("@ethersproject/abi");
31
+ const core_1 = require("@paraswap/core");
32
+ const SSPM_json_1 = __importDefault(require("../../abi/SSPM.json"));
33
+ const StaderOracle_json_1 = __importDefault(require("../../abi/StaderOracle.json"));
34
+ const constants_1 = require("../../constants");
35
+ const simple_exchange_1 = require("../simple-exchange");
36
+ const bigint_constants_1 = require("../../bigint-constants");
37
+ const stader_pool_1 = require("./stader-pool");
38
+ const types_1 = require("./types");
39
+ const config_1 = require("./config");
40
+ const types_2 = require("../weth/types");
41
+ const erc20_json_1 = __importDefault(require("../../abi/erc20.json"));
42
+ const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
43
+ const lodash_1 = __importDefault(require("lodash"));
44
+ const utils_1 = require("../../executor/utils");
45
+ const utils_2 = require("../../utils");
46
+ class Stader extends simple_exchange_1.SimpleExchange {
47
+ constructor(network, dexKey, dexHelper, config = config_1.StaderConfig[dexKey][network]) {
48
+ super(dexHelper, 'Stader');
49
+ this.network = network;
50
+ this.config = config;
51
+ this.needWrapNative = false;
52
+ this.hasConstantPriceLargeAmounts = true;
53
+ this.network = dexHelper.config.data.network;
54
+ this.ETHxAddress = this.config.ETHx.toLowerCase();
55
+ this.SSPM_Address = this.config.SSPM.toLowerCase();
56
+ this.SSPMInterface = new abi_1.Interface(SSPM_json_1.default);
57
+ this.StaderOracleAddress = this.config.StaderOracle.toLowerCase();
58
+ this.StaderOracleInterface = new abi_1.Interface(StaderOracle_json_1.default);
59
+ this.erc20Interface = new abi_1.Interface(erc20_json_1.default);
60
+ this.logger = dexHelper.getLogger(this.dexKey);
61
+ this.ethxPool = new stader_pool_1.ETHxEventPool(this.dexKey, dexHelper, this.StaderOracleAddress, this.StaderOracleInterface, this.logger);
62
+ }
63
+ getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
64
+ return {
65
+ targetExchange: constants_1.NULL_ADDRESS,
66
+ payload: '0x',
67
+ networkFee: '0',
68
+ };
69
+ }
70
+ async initializePricing(blockNumber) {
71
+ await this.ethxPool.initialize(blockNumber);
72
+ }
73
+ async getPricesVolume(srcToken, destToken, amountsIn, side, blockNumber, limitPools, transferFees, isFirstSwap) {
74
+ const pool = this.ethxPool;
75
+ if (!pool.getState(blockNumber))
76
+ return null;
77
+ const unitIn = bigint_constants_1.BI_POWS[18];
78
+ const unitOut = pool.getPrice(blockNumber, unitIn);
79
+ const amountsOut = amountsIn.map(amountIn => pool.getPrice(blockNumber, amountIn));
80
+ return [
81
+ {
82
+ prices: amountsOut,
83
+ unit: unitOut,
84
+ data: {},
85
+ exchange: this.dexKey,
86
+ poolIdentifier: `${constants_1.ETHER_ADDRESS}_${destToken.address}`.toLowerCase(),
87
+ gasCost: 120000,
88
+ poolAddresses: [destToken.address],
89
+ },
90
+ ];
91
+ }
92
+ isEligibleSwap(srcToken, destToken, side) {
93
+ if (side === core_1.SwapSide.BUY)
94
+ return false;
95
+ const srcTokenAddress = (typeof srcToken === 'string' ? srcToken : srcToken.address).toLowerCase();
96
+ const destTokenAddress = (typeof destToken === 'string' ? destToken : destToken.address).toLowerCase();
97
+ return (((0, utils_2.isETHAddress)(srcTokenAddress) || this.isWETH(srcTokenAddress)) &&
98
+ destTokenAddress === this.ETHxAddress);
99
+ }
100
+ getDexParam(srcToken, _destToken, srcAmount, _destAmount, _recipient, _data, _side) {
101
+ const swapData = this.SSPMInterface.encodeFunctionData(types_1.SSPMFunctions.deposit, [_recipient]);
102
+ return {
103
+ needWrapNative: this.needWrapNative,
104
+ dexFuncHasRecipient: true,
105
+ exchangeData: swapData,
106
+ targetExchange: this.config.SSPM.toLowerCase(),
107
+ preSwapUnwrapCalldata: this.isWETH(srcToken)
108
+ ? this.erc20Interface.encodeFunctionData(types_2.WethFunctions.withdraw, [
109
+ srcAmount,
110
+ ])
111
+ : undefined,
112
+ returnAmountPos: _side === core_1.SwapSide.SELL
113
+ ? (0, utils_1.extractReturnAmountPosition)(this.SSPMInterface, types_1.SSPMFunctions.deposit)
114
+ : undefined,
115
+ };
116
+ }
117
+ async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
118
+ if (!this.isEligibleSwap(srcToken, destToken, side))
119
+ return [];
120
+ return [`${constants_1.ETHER_ADDRESS}_${destToken.address}`.toLowerCase()];
121
+ }
122
+ getCalldataGasCost(poolPrices) {
123
+ return CALLDATA_GAS_COST.DEX_OVERHEAD + CALLDATA_GAS_COST.LENGTH_SMALL;
124
+ }
125
+ getAdapters(side) {
126
+ return null;
127
+ }
128
+ getTopPoolsForToken(tokenAddress, limit) {
129
+ if (!((0, utils_2.isETHAddress)(tokenAddress) || this.isWETH(tokenAddress.toLowerCase())))
130
+ return [];
131
+ return [
132
+ {
133
+ exchange: this.dexKey,
134
+ address: this.config.ETHx,
135
+ connectorTokens: [
136
+ {
137
+ decimals: 18,
138
+ address: this.config.ETHx,
139
+ },
140
+ ],
141
+ liquidityUSD: 1000000000, // Just returning a big number so this DEX will be preferred
142
+ },
143
+ ];
144
+ }
145
+ }
146
+ exports.Stader = Stader;
147
+ Stader.dexKeys = ['Stader'];
148
+ Stader.dexKeysWithNetwork = (0, utils_2.getDexKeysWithNetwork)(lodash_1.default.pick(config_1.StaderConfig, ['Stader']));
149
+ //# sourceMappingURL=stader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stader.js","sourceRoot":"","sources":["../../../src/dex/stader/stader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA6D;AAC7D,yCAA0D;AAc1D,oEAA0C;AAC1C,oFAAyD;AACzD,+CAAuE;AAEvE,wDAAoD;AACpD,6DAAiD;AAEjD,+CAA8C;AAC9C,mCAAoD;AACpD,qCAAwC;AACxC,yCAA8C;AAC9C,sEAA4C;AAC5C,2EAA6D;AAC7D,oDAAuB;AACvB,gDAAmE;AACnE,uCAAkE;AAGlE,MAAa,MACX,SAAQ,gCAAc;IAkBtB,YACY,O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AAC,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC;YAAE,OAAO,EAAE,CAAC;QAE/D,OAAO,CAAC,GAAG,yBAAa,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;IACjE,CAAC;IAED,kBAAkB,CAAC,UAAkC;QACnD,OAAO,iBAAiB,CAAC,YAAY,GAAG,iBAAiB,CAAC,YAAY,CAAC;IACzE,CAAC;IAED,WAAW,CAAC,IAAc;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,mBAAmB,CACjB,YAAoB,EACpB,KAAa;QAEb,IACE,CAAC,CAAC,IAAA,oBAAY,EAAC,YAAY,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC;YAExE,OAAO,EAAE,CAAC;QAEZ,OAAO;YACL;gBACE,QAAQ,EAAE,IAAI,CAAC,MAAM;gBACrB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;gBACzB,eAAe,EAAE;oBACf;wBACE,QAAQ,EAAE,EAAE;wBACZ,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;qBAC1B;iBACF;gBACD,YAAY,EAAE,UAAU,EAAE,4DAA4D;aACvF;SACF,CAAC;IACJ,CAAC;;AA/LH,wBAgMC;AA5LQ,cAAO,GAAG,CAAC,QAAQ,CAAC,CAAC;AAYd,yBAAkB,GAC9B,IAAA,6BAAqB,EAAC,gBAAC,CAAC,IAAI,CAAC,qBAAY,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ export declare type ETHxPoolState = {
2
+ totalETHBalance: bigint;
3
+ totalETHXSupply: bigint;
4
+ };
5
+ export declare type StaderData = {};
6
+ export declare type DexParams = {
7
+ ETHx: string;
8
+ SSPM: string;
9
+ StaderOracle: string;
10
+ };
11
+ export declare enum SSPMFunctions {
12
+ deposit = "deposit"
13
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SSPMFunctions = void 0;
4
+ var SSPMFunctions;
5
+ (function (SSPMFunctions) {
6
+ SSPMFunctions["deposit"] = "deposit";
7
+ })(SSPMFunctions = exports.SSPMFunctions || (exports.SSPMFunctions = {}));
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/stader/types.ts"],"names":[],"mappings":";;;AAaA,IAAY,aAEX;AAFD,WAAY,aAAa;IACvB,oCAAmB,CAAA;AACrB,CAAC,EAFW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAExB"}
@@ -0,0 +1,4 @@
1
+ import { Contract } from 'web3-eth-contract';
2
+ import { ETHxPoolState } from './types';
3
+ import { Interface } from '@ethersproject/abi';
4
+ export declare function getOnChainStateETHx(multiContract: Contract, poolAddress: string, poolInterface: Interface, blockNumber: number | 'latest'): Promise<ETHxPoolState>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getOnChainStateETHx = void 0;
4
+ const abi_1 = require("@ethersproject/abi");
5
+ async function getOnChainStateETHx(multiContract, poolAddress, poolInterface, blockNumber) {
6
+ const coder = new abi_1.AbiCoder();
7
+ const data = await multiContract.methods
8
+ .aggregate([
9
+ {
10
+ target: poolAddress,
11
+ callData: poolInterface.encodeFunctionData('getExchangeRate', []),
12
+ },
13
+ ])
14
+ .call({}, blockNumber);
15
+ const decodedData = coder.decode(['uint256', 'uint256', 'uint256'], data.returnData[0]);
16
+ const totalETHBalance = BigInt(decodedData[1].toString());
17
+ const totalETHXSupply = BigInt(decodedData[2].toString());
18
+ return {
19
+ totalETHBalance,
20
+ totalETHXSupply,
21
+ };
22
+ }
23
+ exports.getOnChainStateETHx = getOnChainStateETHx;
24
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/dex/stader/utils.ts"],"names":[],"mappings":";;;AAEA,4CAAyD;AAGlD,KAAK,UAAU,mBAAmB,CACvC,aAAuB,EACvB,WAAmB,EACnB,aAAwB,EACxB,WAA8B;IAE9B,MAAM,KAAK,GAAG,IAAI,cAAQ,EAAE,CAAC;IAC7B,MAAM,IAAI,GAA0B,MAAM,aAAa,CAAC,OAAO;SAC5D,SAAS,CAAC;QACT;YACE,MAAM,EAAE,WAAW;YACnB,QAAQ,EAAE,aAAa,CAAC,kBAAkB,CAAC,iBAAiB,EAAE,EAAE,CAAC;SAClE;KACF,CAAC;SACD,IAAI,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;IAEzB,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAC9B,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,EACjC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CACnB,CAAC;IAEF,MAAM,eAAe,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC1D,MAAM,eAAe,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IAE1D,OAAO;QACL,eAAe;QACf,eAAe;KAChB,CAAC;AACJ,CAAC;AA5BD,kDA4BC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraswap/dex-lib",
3
- "version": "3.11.7",
3
+ "version": "3.11.8-bebop-incr-timeout.0",
4
4
  "main": "build/index.js",
5
5
  "types": "build/index.d.ts",
6
6
  "repository": "https://github.com/paraswap/paraswap-dex-lib",
@@ -6,7 +6,7 @@ export const BEBOP_API_URL = 'https://api.bebop.xyz';
6
6
  export const BEBOP_WS_API_URL = 'wss://api.bebop.xyz';
7
7
  export const BEBOP_GAS_COST = 120_000;
8
8
  export const BEBOP_AUTH_NAME = 'paraswap';
9
- export const BEBOP_QUOTE_TIMEOUT_MS = 2000;
9
+ export const BEBOP_QUOTE_TIMEOUT_MS = 3000;
10
10
  export const BEBOP_ERRORS_CACHE_KEY = 'errors';
11
11
  export const BEBOP_RESTRICTED_CACHE_KEY = 'restricted';
12
12
  // Restrict for BEBOP_RESTRICT_TTL_S if an error occured >= BEBOP_RESTRICT_COUNT_THRESHOLD times within BEBOP_RESTRICT_CHECK_INTERVAL_S interval