Compare commits

...

3 Commits

Author SHA1 Message Date
Github Actions
f7cb7a0f51 Publish
- @0x/asset-swapper@16.63.1
2022-07-12 21:26:51 +00:00
Github Actions
9fcb28f5d8 Updated CHANGELOGS & MD docs 2022-07-12 21:26:48 +00:00
Kyu
982173471c Wrap balancer fetch top pools with try and catch [TKR-481] (#515)
* Wrap balancer fetch top pool with try and catch

* Update CHANGELOG.json
2022-07-12 13:50:07 -07:00
5 changed files with 34 additions and 3 deletions

View File

@@ -1,4 +1,14 @@
[
{
"version": "16.63.1",
"changes": [
{
"note": "Better error handling for balancer cache",
"pr": 515
}
],
"timestamp": 1657661207
},
{
"version": "16.63.0",
"changes": [

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v16.63.1 - _July 12, 2022_
* Better error handling for balancer cache (#515)
## v16.63.0 - _June 29, 2022_
* Remove JS router (#480)

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/asset-swapper",
"version": "16.63.0",
"version": "16.63.1",
"engines": {
"node": ">=6.12"
},

View File

@@ -2,6 +2,8 @@ import { getPoolsWithTokens, parsePoolData } from 'balancer-labs-sor-v1';
import { Pool } from 'balancer-labs-sor-v1/dist/types';
import { gql, request } from 'graphql-request';
import { DEFAULT_WARNING_LOGGER } from '../../../constants';
import { LogFunction } from '../../../types';
import { BALANCER_MAX_POOLS_FETCHED, BALANCER_SUBGRAPH_URL, BALANCER_TOP_POOLS_FETCHED } from '../constants';
import { CacheValue, PoolsCache } from './pools_cache';
@@ -24,6 +26,7 @@ export class BalancerPoolsCache extends PoolsCache {
cache: { [key: string]: CacheValue } = {},
private readonly maxPoolsFetched: number = BALANCER_MAX_POOLS_FETCHED,
private readonly _topPoolsFetched: number = BALANCER_TOP_POOLS_FETCHED,
private readonly _warningLogger: LogFunction = DEFAULT_WARNING_LOGGER,
) {
super(cache);
void this._loadTopPoolsAsync();
@@ -49,7 +52,14 @@ export class BalancerPoolsCache extends PoolsCache {
[from: string]: { [to: string]: Pool[] };
} = {};
const pools = await this._fetchTopPoolsAsync();
let pools: BalancerPoolResponse[];
try {
pools = await this._fetchTopPoolsAsync();
} catch (err) {
this._warningLogger(err, 'Failed to fetch top pools for Balancer V1');
return;
}
for (const pool of pools) {
const { tokensList } = pool;
for (const from of tokensList) {

View File

@@ -114,7 +114,14 @@ export class BalancerV2PoolsCache extends PoolsCache {
[from: string]: { [to: string]: Pool[] };
} = {};
const pools = await this._fetchTopPoolsAsync();
let pools: BalancerPoolResponse[];
try {
pools = await this._fetchTopPoolsAsync();
} catch (err) {
this._warningLogger(err, 'Failed to fetch top pools for Balancer V2');
return;
}
for (const pool of pools) {
const { tokensList } = pool;
for (const from of tokensList) {