@shapeshiftoss/swapper 15.3.2 → 15.3.3

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.
@@ -9,8 +9,19 @@ const chain_adapters_1 = require("@shapeshiftoss/chain-adapters");
9
9
  const axios_1 = __importDefault(require("axios"));
10
10
  const lodash_1 = require("lodash");
11
11
  const api_1 = require("../../../api");
12
+ const utils_1 = require("../../../utils");
12
13
  const bignumber_1 = require("../../utils/bignumber");
13
14
  const constants_1 = require("./constants");
15
+ // Create cached axios service for pools endpoint because it gets called a LOT
16
+ const cache = (0, utils_1.createCache)(3000, ['/osmosis/gamm/v1beta1/pools/']);
17
+ const osmoPoolsService = axios_1.default.create({
18
+ timeout: 10000,
19
+ headers: {
20
+ Accept: 'application/json',
21
+ 'Content-Type': 'application/json',
22
+ },
23
+ adapter: cache.adapter,
24
+ });
14
25
  exports.symbolDenomMapping = {
15
26
  OSMO: 'uosmo',
16
27
  ATOM: 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2',
@@ -102,10 +113,12 @@ exports.pollForAtomChannelBalance = pollForAtomChannelBalance;
102
113
  const findPool = async (sellAssetSymbol, buyAssetSymbol, osmoUrl) => {
103
114
  const sellAssetDenom = exports.symbolDenomMapping[sellAssetSymbol];
104
115
  const buyAssetDenom = exports.symbolDenomMapping[buyAssetSymbol];
105
- const poolsUrl = osmoUrl + '/osmosis/gamm/v1beta1/pools?pagination.limit=1000';
116
+ // pagination.limit can be small because we only care about the osmo/atom pool right now
117
+ // this will need to increase when adding new pools
118
+ const poolsUrl = osmoUrl + '/osmosis/gamm/v1beta1/pools?pagination.limit=10';
106
119
  const poolsResponse = await (async () => {
107
120
  try {
108
- return axios_1.default.get(poolsUrl);
121
+ return osmoPoolsService.get(poolsUrl);
109
122
  }
110
123
  catch (e) {
111
124
  throw new api_1.SwapError('failed to get pool', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshiftoss/swapper",
3
- "version": "15.3.2",
3
+ "version": "15.3.3",
4
4
  "description": "An interface and implementations to trade coins via various protocols",
5
5
  "repository": "https://github.com/shapeshift/lib",
6
6
  "license": "MIT",