@across-protocol/sdk 4.1.43 → 4.1.45-beta.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/cjs/addressAggregator/adapters/abstract.d.ts +15 -0
- package/dist/cjs/addressAggregator/adapters/abstract.js +83 -0
- package/dist/cjs/addressAggregator/adapters/abstract.js.map +1 -0
- package/dist/cjs/addressAggregator/adapters/bybit.d.ts +5 -9
- package/dist/cjs/addressAggregator/adapters/bybit.js +11 -12
- package/dist/cjs/addressAggregator/adapters/bybit.js.map +1 -1
- package/dist/cjs/addressAggregator/adapters/env.d.ts +5 -7
- package/dist/cjs/addressAggregator/adapters/env.js +12 -11
- package/dist/cjs/addressAggregator/adapters/env.js.map +1 -1
- package/dist/cjs/addressAggregator/adapters/file.d.ts +5 -7
- package/dist/cjs/addressAggregator/adapters/file.js +13 -12
- package/dist/cjs/addressAggregator/adapters/file.js.map +1 -1
- package/dist/cjs/addressAggregator/adapters/risklabs.d.ts +5 -9
- package/dist/cjs/addressAggregator/adapters/risklabs.js +18 -14
- package/dist/cjs/addressAggregator/adapters/risklabs.js.map +1 -1
- package/dist/cjs/addressAggregator/index.js +2 -2
- package/dist/cjs/addressAggregator/index.js.map +1 -1
- package/dist/cjs/addressAggregator/types.d.ts +9 -1
- package/dist/cjs/addressAggregator/types.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +13 -6
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +9 -0
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.d.ts +7 -6
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +46 -35
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/cjs/clients/HubPoolClient.d.ts +2 -0
- package/dist/cjs/clients/HubPoolClient.js +27 -10
- package/dist/cjs/clients/HubPoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +1 -0
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +16 -3
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +2 -0
- package/dist/cjs/clients/mocks/MockHubPoolClient.js +18 -0
- package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/cjs/constants.d.ts +1 -0
- package/dist/cjs/constants.js +13 -1
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/svm/eventsClient.js +5 -12
- package/dist/cjs/svm/eventsClient.js.map +1 -1
- package/dist/cjs/svm/index.d.ts +2 -0
- package/dist/cjs/svm/index.js +3 -0
- package/dist/cjs/svm/index.js.map +1 -1
- package/dist/cjs/svm/utils/events.d.ts +6 -1
- package/dist/cjs/svm/utils/events.js +13 -4
- package/dist/cjs/svm/utils/events.js.map +1 -1
- package/dist/cjs/svm/utils/index.d.ts +1 -0
- package/dist/cjs/svm/utils/index.js +5 -0
- package/dist/cjs/svm/utils/index.js.map +1 -0
- package/dist/cjs/utils/DepositUtils.d.ts +1 -0
- package/dist/cjs/utils/DepositUtils.js +5 -1
- package/dist/cjs/utils/DepositUtils.js.map +1 -1
- package/dist/cjs/utils/TokenUtils.d.ts +1 -0
- package/dist/cjs/utils/TokenUtils.js +5 -1
- package/dist/cjs/utils/TokenUtils.js.map +1 -1
- package/dist/cjs/utils/common.d.ts +2 -0
- package/dist/cjs/utils/common.js +3 -1
- package/dist/cjs/utils/common.js.map +1 -1
- package/dist/esm/addressAggregator/adapters/abstract.d.ts +15 -0
- package/dist/esm/addressAggregator/adapters/abstract.js +80 -0
- package/dist/esm/addressAggregator/adapters/abstract.js.map +1 -0
- package/dist/esm/addressAggregator/adapters/bybit.d.ts +5 -9
- package/dist/esm/addressAggregator/adapters/bybit.js +12 -13
- package/dist/esm/addressAggregator/adapters/bybit.js.map +1 -1
- package/dist/esm/addressAggregator/adapters/env.d.ts +5 -7
- package/dist/esm/addressAggregator/adapters/env.js +12 -11
- package/dist/esm/addressAggregator/adapters/env.js.map +1 -1
- package/dist/esm/addressAggregator/adapters/file.d.ts +5 -7
- package/dist/esm/addressAggregator/adapters/file.js +14 -13
- package/dist/esm/addressAggregator/adapters/file.js.map +1 -1
- package/dist/esm/addressAggregator/adapters/risklabs.d.ts +5 -9
- package/dist/esm/addressAggregator/adapters/risklabs.js +19 -15
- package/dist/esm/addressAggregator/adapters/risklabs.js.map +1 -1
- package/dist/esm/addressAggregator/index.js +2 -2
- package/dist/esm/addressAggregator/index.js.map +1 -1
- package/dist/esm/addressAggregator/types.d.ts +9 -1
- package/dist/esm/addressAggregator/types.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +14 -7
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +15 -0
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.d.ts +28 -6
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +82 -49
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/esm/clients/HubPoolClient.d.ts +2 -0
- package/dist/esm/clients/HubPoolClient.js +31 -13
- package/dist/esm/clients/HubPoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +1 -0
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +24 -11
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +2 -0
- package/dist/esm/clients/mocks/MockHubPoolClient.js +18 -0
- package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/esm/constants.d.ts +1 -0
- package/dist/esm/constants.js +12 -0
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/svm/eventsClient.js +6 -13
- package/dist/esm/svm/eventsClient.js.map +1 -1
- package/dist/esm/svm/index.d.ts +2 -0
- package/dist/esm/svm/index.js +3 -0
- package/dist/esm/svm/index.js.map +1 -1
- package/dist/esm/svm/utils/events.d.ts +9 -1
- package/dist/esm/svm/utils/events.js +15 -3
- package/dist/esm/svm/utils/events.js.map +1 -1
- package/dist/esm/svm/utils/index.d.ts +1 -0
- package/dist/esm/svm/utils/index.js +2 -0
- package/dist/esm/svm/utils/index.js.map +1 -0
- package/dist/esm/utils/DepositUtils.d.ts +1 -0
- package/dist/esm/utils/DepositUtils.js +5 -1
- package/dist/esm/utils/DepositUtils.js.map +1 -1
- package/dist/esm/utils/TokenUtils.d.ts +1 -0
- package/dist/esm/utils/TokenUtils.js +3 -0
- package/dist/esm/utils/TokenUtils.js.map +1 -1
- package/dist/esm/utils/common.d.ts +2 -0
- package/dist/esm/utils/common.js +2 -0
- package/dist/esm/utils/common.js.map +1 -1
- package/dist/types/addressAggregator/adapters/abstract.d.ts +16 -0
- package/dist/types/addressAggregator/adapters/abstract.d.ts.map +1 -0
- package/dist/types/addressAggregator/adapters/bybit.d.ts +5 -9
- package/dist/types/addressAggregator/adapters/bybit.d.ts.map +1 -1
- package/dist/types/addressAggregator/adapters/env.d.ts +5 -7
- package/dist/types/addressAggregator/adapters/env.d.ts.map +1 -1
- package/dist/types/addressAggregator/adapters/file.d.ts +5 -7
- package/dist/types/addressAggregator/adapters/file.d.ts.map +1 -1
- package/dist/types/addressAggregator/adapters/risklabs.d.ts +5 -9
- package/dist/types/addressAggregator/adapters/risklabs.d.ts.map +1 -1
- package/dist/types/addressAggregator/types.d.ts +9 -1
- package/dist/types/addressAggregator/types.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/DataworkerUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts +28 -6
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -1
- package/dist/types/clients/HubPoolClient.d.ts +2 -0
- package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts +1 -0
- package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts +2 -0
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts.map +1 -1
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/svm/eventsClient.d.ts.map +1 -1
- package/dist/types/svm/index.d.ts +2 -0
- package/dist/types/svm/index.d.ts.map +1 -1
- package/dist/types/svm/utils/events.d.ts +9 -1
- package/dist/types/svm/utils/events.d.ts.map +1 -1
- package/dist/types/svm/utils/index.d.ts +2 -0
- package/dist/types/svm/utils/index.d.ts.map +1 -0
- package/dist/types/utils/DepositUtils.d.ts +1 -0
- package/dist/types/utils/DepositUtils.d.ts.map +1 -1
- package/dist/types/utils/TokenUtils.d.ts +1 -0
- package/dist/types/utils/TokenUtils.d.ts.map +1 -1
- package/dist/types/utils/common.d.ts +2 -0
- package/dist/types/utils/common.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/addressAggregator/adapters/abstract.ts +74 -0
- package/src/addressAggregator/adapters/bybit.ts +10 -11
- package/src/addressAggregator/adapters/env.ts +10 -10
- package/src/addressAggregator/adapters/file.ts +11 -12
- package/src/addressAggregator/adapters/risklabs.ts +14 -13
- package/src/addressAggregator/index.ts +2 -2
- package/src/addressAggregator/types.ts +10 -1
- package/src/clients/BundleDataClient/BundleDataClient.ts +28 -18
- package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +29 -0
- package/src/clients/BundleDataClient/utils/FillUtils.ts +128 -71
- package/src/clients/HubPoolClient.ts +38 -14
- package/src/clients/SpokePoolClient/SpokePoolClient.ts +40 -14
- package/src/clients/mocks/MockHubPoolClient.ts +16 -0
- package/src/constants.ts +13 -0
- package/src/svm/eventsClient.ts +6 -12
- package/src/svm/index.ts +2 -0
- package/src/svm/utils/events.ts +16 -4
- package/src/svm/utils/index.ts +1 -0
- package/src/utils/DepositUtils.ts +6 -1
- package/src/utils/TokenUtils.ts +6 -0
- package/src/utils/common.ts +2 -0
- package/dist/cjs/addressAggregator/adapters/util.d.ts +0 -4
- package/dist/cjs/addressAggregator/adapters/util.js +0 -66
- package/dist/cjs/addressAggregator/adapters/util.js.map +0 -1
- package/dist/esm/addressAggregator/adapters/util.d.ts +0 -4
- package/dist/esm/addressAggregator/adapters/util.js +0 -60
- package/dist/esm/addressAggregator/adapters/util.js.map +0 -1
- package/dist/types/addressAggregator/adapters/util.d.ts +0 -5
- package/dist/types/addressAggregator/adapters/util.d.ts.map +0 -1
- package/src/addressAggregator/adapters/util.ts +0 -47
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import Decimal from "decimal.js";
|
|
2
|
+
import bs58 from "bs58";
|
|
2
3
|
import { ethers } from "ethers";
|
|
3
4
|
import { BigNumber, BigNumberish, BN } from "./BigNumberUtils";
|
|
4
5
|
export type Decimalish = string | number | Decimal;
|
|
5
6
|
export declare const AddressZero = "0x0000000000000000000000000000000000000000";
|
|
6
7
|
export declare const MAX_BIG_INT: ethers.BigNumber;
|
|
7
8
|
export declare const keccak256: typeof ethers.utils.keccak256;
|
|
9
|
+
export { bs58 };
|
|
8
10
|
/**
|
|
9
11
|
* toBNWei.
|
|
10
12
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/utils/common.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,EAAiC,MAAM,kBAAkB,CAAC;AAG9F,M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AAgB,aAAa,WAE5B"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { AdapterOptions, AddressListAdapter } from "../types";
|
|
3
|
+
import { Logger } from "../../utils";
|
|
4
|
+
|
|
5
|
+
const { ACROSS_USER_AGENT = "across-protocol" } = process.env;
|
|
6
|
+
|
|
7
|
+
export abstract class AbstractAdapter implements AddressListAdapter {
|
|
8
|
+
readonly timeout: number;
|
|
9
|
+
readonly retries: number;
|
|
10
|
+
readonly throw: boolean;
|
|
11
|
+
readonly logger?: Logger;
|
|
12
|
+
|
|
13
|
+
constructor(
|
|
14
|
+
readonly name: string,
|
|
15
|
+
readonly path: string,
|
|
16
|
+
opts?: Omit<AdapterOptions, "name" | "path">
|
|
17
|
+
) {
|
|
18
|
+
this.timeout = opts?.timeout ?? 2000;
|
|
19
|
+
this.retries = opts?.retries ?? 1;
|
|
20
|
+
this.throw = opts?.throwOnError ?? true;
|
|
21
|
+
this.logger = opts?.logger;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
abstract update(logger?: Logger): Promise<string[]>;
|
|
25
|
+
|
|
26
|
+
protected sleep(ms: number): Promise<void> {
|
|
27
|
+
return new Promise((r) => setTimeout(r, ms));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
protected async fetch(name: string, url: string, timeout = 2000, retries = 1): Promise<unknown> {
|
|
31
|
+
const args = {
|
|
32
|
+
headers: { "User-Agent": ACROSS_USER_AGENT },
|
|
33
|
+
timeout,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const errs: string[] = [];
|
|
37
|
+
let tries = 0;
|
|
38
|
+
do {
|
|
39
|
+
try {
|
|
40
|
+
return (await axios(url, args)).data;
|
|
41
|
+
} catch (err) {
|
|
42
|
+
const errMsg = axios.isAxiosError(err) || err instanceof Error ? err.message : "unknown error";
|
|
43
|
+
errs.push(errMsg);
|
|
44
|
+
if (++tries <= retries) await this.sleep(Math.pow(1.5, tries) * 1000); // simple backoff
|
|
45
|
+
}
|
|
46
|
+
} while (tries <= retries);
|
|
47
|
+
|
|
48
|
+
throw new Error(`${name} retrieval failure (${errs.join(", ")})`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
protected error(error: unknown): Promise<string[]> {
|
|
52
|
+
if (this.throw) {
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let reason: string;
|
|
57
|
+
if (error instanceof Error) {
|
|
58
|
+
reason = error.message;
|
|
59
|
+
} else {
|
|
60
|
+
reason = typeof error === "string" ? error : "unknown error";
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const { name, path, timeout, retries } = this;
|
|
64
|
+
this.logger?.warn({
|
|
65
|
+
at: `${name}::update`,
|
|
66
|
+
message: `Failed to read addresses from ${name}.`,
|
|
67
|
+
reason,
|
|
68
|
+
path,
|
|
69
|
+
retries,
|
|
70
|
+
timeout,
|
|
71
|
+
});
|
|
72
|
+
return Promise.resolve([]);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { array, defaulted, string, type } from "superstruct";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { AdapterOptions } from "../types";
|
|
3
|
+
import { AbstractAdapter } from "./abstract";
|
|
4
4
|
|
|
5
|
+
const DEFAULT_NAME = "bybit";
|
|
5
6
|
const DEFAULT_URL = "https://hackscan.hackbounty.io/public/hack-address.json";
|
|
6
7
|
|
|
7
8
|
// This type is a bit message and unweildy. Additional fields representing new chains may be added without notification.
|
|
@@ -13,18 +14,16 @@ const bybitResponse = type({
|
|
|
13
14
|
}),
|
|
14
15
|
});
|
|
15
16
|
|
|
16
|
-
export class AddressList
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
constructor(readonly url = DEFAULT_URL) {}
|
|
17
|
+
export class AddressList extends AbstractAdapter {
|
|
18
|
+
constructor(opts?: AdapterOptions) {
|
|
19
|
+
super(opts?.name ?? DEFAULT_NAME, opts?.path ?? DEFAULT_URL, opts);
|
|
20
|
+
}
|
|
22
21
|
|
|
23
|
-
async update(
|
|
24
|
-
const response = await fetch(this.name, this.
|
|
22
|
+
async update(): Promise<string[]> {
|
|
23
|
+
const response = await this.fetch(this.name, this.path, this.timeout, this.retries);
|
|
25
24
|
if (!bybitResponse.is(response)) {
|
|
26
25
|
// nb. don't log the response because it might be very large.
|
|
27
|
-
return
|
|
26
|
+
return this.error("Failed to validate response");
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
return [...response["0221"].eth, ...response["0221"].bsc, ...response["0221"].arbi];
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { array, defaulted, string } from "superstruct";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { AdapterOptions } from "../types";
|
|
3
|
+
import { AbstractAdapter } from "./abstract";
|
|
4
4
|
|
|
5
5
|
const envConfig = defaulted(array(string()), []);
|
|
6
6
|
|
|
7
|
-
export class AddressList
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
export class AddressList extends AbstractAdapter {
|
|
8
|
+
constructor(opts?: AdapterOptions) {
|
|
9
|
+
super(opts?.name ?? "process.env", opts?.path ?? "ACROSS_IGNORED_ADDRESSES", opts);
|
|
10
|
+
}
|
|
11
11
|
|
|
12
|
-
update(
|
|
13
|
-
const config = process.env[this.
|
|
12
|
+
update(): Promise<string[]> {
|
|
13
|
+
const config = process.env[this.path];
|
|
14
14
|
if (!config) {
|
|
15
15
|
return Promise.resolve([]);
|
|
16
16
|
}
|
|
@@ -19,10 +19,10 @@ export class AddressList implements AddressListAdapter {
|
|
|
19
19
|
try {
|
|
20
20
|
addresses = JSON.parse(config);
|
|
21
21
|
if (!envConfig.is(addresses)) {
|
|
22
|
-
return
|
|
22
|
+
return this.error("Address format validation failure.");
|
|
23
23
|
}
|
|
24
24
|
} catch (err) {
|
|
25
|
-
return
|
|
25
|
+
return this.error(err);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
return Promise.resolve(addresses);
|
|
@@ -1,37 +1,36 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { array, defaulted, string } from "superstruct";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { AdapterOptions } from "../types";
|
|
4
|
+
import { AbstractAdapter } from "./abstract";
|
|
5
5
|
|
|
6
6
|
const fileConfig = defaulted(array(string()), []);
|
|
7
7
|
|
|
8
|
-
export class AddressList
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
this.name = `fs:${path}`;
|
|
8
|
+
export class AddressList extends AbstractAdapter {
|
|
9
|
+
constructor(opts?: AdapterOptions) {
|
|
10
|
+
const { path = "addresses.json" } = opts ?? {};
|
|
11
|
+
super(opts?.name ?? `fs:${path}`, path, opts);
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
async update(
|
|
14
|
+
async update(): Promise<string[]> {
|
|
16
15
|
let data: string;
|
|
17
16
|
try {
|
|
18
17
|
data = await readFile(this.path, { encoding: "utf8" });
|
|
19
18
|
} catch (err) {
|
|
20
|
-
return
|
|
19
|
+
return this.error(err);
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
if (!data) {
|
|
24
|
-
return
|
|
23
|
+
return this.error("No addresses found");
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
let addresses: unknown;
|
|
28
27
|
try {
|
|
29
28
|
addresses = JSON.parse(data);
|
|
30
29
|
if (!fileConfig.is(addresses)) {
|
|
31
|
-
return
|
|
30
|
+
return this.error("Address format validation failure.");
|
|
32
31
|
}
|
|
33
32
|
} catch (err) {
|
|
34
|
-
return
|
|
33
|
+
return this.error(err);
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
return Promise.resolve(addresses);
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { array, string } from "superstruct";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { AdapterOptions } from "../types";
|
|
3
|
+
import { AbstractAdapter } from "./abstract";
|
|
4
4
|
|
|
5
5
|
const RESPONSE_TYPE = array(string());
|
|
6
6
|
const DEFAULT_NAME = "Risk Labs";
|
|
7
7
|
const DEFAULT_URL = "https://blacklist.risklabs.foundation/api/blacklist";
|
|
8
8
|
|
|
9
|
-
export class AddressList
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
constructor(
|
|
14
|
-
readonly name = DEFAULT_NAME,
|
|
15
|
-
readonly url = DEFAULT_URL
|
|
16
|
-
) {}
|
|
9
|
+
export class AddressList extends AbstractAdapter {
|
|
10
|
+
constructor(opts?: AdapterOptions) {
|
|
11
|
+
super(opts?.name ?? DEFAULT_NAME, opts?.path ?? DEFAULT_URL, opts);
|
|
12
|
+
}
|
|
17
13
|
|
|
18
|
-
async update(
|
|
19
|
-
|
|
14
|
+
async update(): Promise<string[]> {
|
|
15
|
+
let response: unknown;
|
|
16
|
+
try {
|
|
17
|
+
response = await this.fetch(this.name, this.path, this.timeout, this.retries);
|
|
18
|
+
} catch (err) {
|
|
19
|
+
return this.error(err);
|
|
20
|
+
}
|
|
20
21
|
|
|
21
22
|
if (!RESPONSE_TYPE.is(response)) {
|
|
22
|
-
return
|
|
23
|
+
return this.error("Failed to validate response");
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
return response;
|
|
@@ -25,7 +25,7 @@ export class AddressAggregator {
|
|
|
25
25
|
|
|
26
26
|
const allAddresses = await mapAsync(this.adapters, async (adapter) => {
|
|
27
27
|
const invalidAddresses: string[] = [];
|
|
28
|
-
const addresses = (await adapter.update(
|
|
28
|
+
const addresses = (await adapter.update())
|
|
29
29
|
.map((address) => {
|
|
30
30
|
try {
|
|
31
31
|
return ethersUtils.getAddress(address.toLowerCase());
|
|
@@ -66,7 +66,7 @@ export class AddressAggregator {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
async function run(): Promise<number> {
|
|
69
|
-
const addressList = new AddressAggregator([new adapters.risklabs.AddressList()]);
|
|
69
|
+
const addressList = new AddressAggregator([new adapters.risklabs.AddressList({ throwOnError: true })]);
|
|
70
70
|
|
|
71
71
|
const addresses = await addressList.update();
|
|
72
72
|
console.log(`Retrieved ${addresses.size} addresses: ${JSON.stringify(Array.from(addresses), null, 2)}`);
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { Logger } from "../utils";
|
|
2
2
|
|
|
3
|
+
export type AdapterOptions = {
|
|
4
|
+
name?: string;
|
|
5
|
+
path?: string;
|
|
6
|
+
retries?: number;
|
|
7
|
+
timeout?: number;
|
|
8
|
+
throwOnError?: boolean;
|
|
9
|
+
logger?: Logger;
|
|
10
|
+
};
|
|
11
|
+
|
|
3
12
|
export interface AddressListAdapter {
|
|
4
13
|
readonly name: string;
|
|
5
|
-
update(
|
|
14
|
+
update(): Promise<string[]>;
|
|
6
15
|
}
|
|
7
16
|
|
|
8
17
|
export const INVALID_ADDRESS = "";
|
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
chainIsEvm,
|
|
43
43
|
isValidEvmAddress,
|
|
44
44
|
duplicateEvent,
|
|
45
|
+
invalidOutputToken,
|
|
45
46
|
} from "../../utils";
|
|
46
47
|
import winston from "winston";
|
|
47
48
|
import {
|
|
@@ -372,7 +373,8 @@ export class BundleDataClient {
|
|
|
372
373
|
if (
|
|
373
374
|
fill.blockNumber < blockRanges[chainIndex][0] ||
|
|
374
375
|
fill.blockNumber > blockRanges[chainIndex][1] ||
|
|
375
|
-
isZeroValueFillOrSlowFillRequest(fill)
|
|
376
|
+
isZeroValueFillOrSlowFillRequest(fill) ||
|
|
377
|
+
invalidOutputToken(fill)
|
|
376
378
|
) {
|
|
377
379
|
return false;
|
|
378
380
|
}
|
|
@@ -405,11 +407,12 @@ export class BundleDataClient {
|
|
|
405
407
|
return;
|
|
406
408
|
}
|
|
407
409
|
const { chainToSendRefundTo, repaymentToken } = getRefundInformationFromFill(
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
410
|
+
{
|
|
411
|
+
...fill,
|
|
412
|
+
fromLiteChain: matchingDeposit.fromLiteChain,
|
|
413
|
+
quoteBlockNumber: matchingDeposit.quoteBlockNumber,
|
|
414
|
+
},
|
|
415
|
+
this.clients.hubPoolClient
|
|
413
416
|
);
|
|
414
417
|
// Assume that lp fees are 0 for the sake of speed. In the future we could batch compute
|
|
415
418
|
// these or make hardcoded assumptions based on the origin-repayment chain direction. This might result
|
|
@@ -885,7 +888,10 @@ export class BundleDataClient {
|
|
|
885
888
|
// tokens to the filler. We can't remove non-empty message deposit here in case there is a slow fill
|
|
886
889
|
// request for the deposit, we'd want to see the fill took place.
|
|
887
890
|
.filter(
|
|
888
|
-
(fill) =>
|
|
891
|
+
(fill) =>
|
|
892
|
+
fill.blockNumber <= destinationChainBlockRange[1] &&
|
|
893
|
+
!isZeroValueFillOrSlowFillRequest(fill) &&
|
|
894
|
+
!invalidOutputToken(fill)
|
|
889
895
|
),
|
|
890
896
|
async (fill) => {
|
|
891
897
|
fillCounter++;
|
|
@@ -1054,7 +1060,9 @@ export class BundleDataClient {
|
|
|
1054
1060
|
.getSlowFillRequestsForOriginChain(originChainId)
|
|
1055
1061
|
.filter(
|
|
1056
1062
|
(request) =>
|
|
1057
|
-
request.blockNumber <= destinationChainBlockRange[1] &&
|
|
1063
|
+
request.blockNumber <= destinationChainBlockRange[1] &&
|
|
1064
|
+
!isZeroValueFillOrSlowFillRequest(request) &&
|
|
1065
|
+
!invalidOutputToken(request)
|
|
1058
1066
|
),
|
|
1059
1067
|
async (slowFillRequest: SlowFillRequestWithBlock) => {
|
|
1060
1068
|
const relayDataHash = getRelayEventKey(slowFillRequest);
|
|
@@ -1376,11 +1384,12 @@ export class BundleDataClient {
|
|
|
1376
1384
|
const matchedDeposit = deposits[0];
|
|
1377
1385
|
assert(isDefined(matchedDeposit), "Deposit should exist in relay hash dictionary.");
|
|
1378
1386
|
const { chainToSendRefundTo: paymentChainId } = getRefundInformationFromFill(
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1387
|
+
{
|
|
1388
|
+
...fill,
|
|
1389
|
+
fromLiteChain: matchedDeposit.fromLiteChain,
|
|
1390
|
+
quoteBlockNumber: matchedDeposit.quoteBlockNumber,
|
|
1391
|
+
},
|
|
1392
|
+
this.clients.hubPoolClient
|
|
1384
1393
|
);
|
|
1385
1394
|
return {
|
|
1386
1395
|
...fill,
|
|
@@ -1422,11 +1431,12 @@ export class BundleDataClient {
|
|
|
1422
1431
|
const associatedDeposit = deposits[0];
|
|
1423
1432
|
assert(isDefined(associatedDeposit), "Deposit should exist in relay hash dictionary.");
|
|
1424
1433
|
const { chainToSendRefundTo, repaymentToken } = getRefundInformationFromFill(
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1434
|
+
{
|
|
1435
|
+
...fill,
|
|
1436
|
+
fromLiteChain: associatedDeposit.fromLiteChain,
|
|
1437
|
+
quoteBlockNumber: associatedDeposit.quoteBlockNumber,
|
|
1438
|
+
},
|
|
1439
|
+
this.clients.hubPoolClient
|
|
1430
1440
|
);
|
|
1431
1441
|
updateBundleFillsV3(bundleFillsV3, fill, realizedLpFeePct, chainToSendRefundTo, repaymentToken, fill.relayer);
|
|
1432
1442
|
});
|
|
@@ -146,6 +146,13 @@ export function _buildPoolRebalanceRoot(
|
|
|
146
146
|
const repaymentChainId = Number(_repaymentChainId);
|
|
147
147
|
Object.entries(fillsForChain).forEach(
|
|
148
148
|
([l2TokenAddress, { realizedLpFees: totalRealizedLpFee, totalRefundAmount }]) => {
|
|
149
|
+
// If the repayment token and repayment chain ID do not map to a PoolRebalanceRoute graph, then
|
|
150
|
+
// there are no relevant L1 running balances.
|
|
151
|
+
if (
|
|
152
|
+
!clients.hubPoolClient.l2TokenHasPoolRebalanceRoute(l2TokenAddress, repaymentChainId, mainnetBundleEndBlock)
|
|
153
|
+
) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
149
156
|
const l1TokenCounterpart = clients.hubPoolClient.getL1TokenForL2TokenAtBlock(
|
|
150
157
|
l2TokenAddress,
|
|
151
158
|
repaymentChainId,
|
|
@@ -215,6 +222,17 @@ export function _buildPoolRebalanceRoot(
|
|
|
215
222
|
Object.entries(bundleV3Deposits).forEach(([, depositsForChain]) => {
|
|
216
223
|
Object.entries(depositsForChain).forEach(([, deposits]) => {
|
|
217
224
|
deposits.forEach((deposit) => {
|
|
225
|
+
// If the repayment token and repayment chain ID do not map to a PoolRebalanceRoute graph, then
|
|
226
|
+
// there are no relevant L1 running balances.
|
|
227
|
+
if (
|
|
228
|
+
!clients.hubPoolClient.l2TokenHasPoolRebalanceRoute(
|
|
229
|
+
deposit.inputToken,
|
|
230
|
+
deposit.originChainId,
|
|
231
|
+
mainnetBundleEndBlock
|
|
232
|
+
)
|
|
233
|
+
) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
218
236
|
updateRunningBalanceForDeposit(runningBalances, clients.hubPoolClient, deposit, deposit.inputAmount.mul(-1));
|
|
219
237
|
});
|
|
220
238
|
});
|
|
@@ -229,6 +247,17 @@ export function _buildPoolRebalanceRoot(
|
|
|
229
247
|
const originChainId = Number(_originChainId);
|
|
230
248
|
Object.entries(depositsForChain).forEach(([inputToken, deposits]) => {
|
|
231
249
|
deposits.forEach((deposit) => {
|
|
250
|
+
// If the repayment token and repayment chain ID do not map to a PoolRebalanceRoute graph, then
|
|
251
|
+
// there are no relevant L1 running balances.
|
|
252
|
+
if (
|
|
253
|
+
!clients.hubPoolClient.l2TokenHasPoolRebalanceRoute(
|
|
254
|
+
deposit.inputToken,
|
|
255
|
+
deposit.originChainId,
|
|
256
|
+
mainnetBundleEndBlock
|
|
257
|
+
)
|
|
258
|
+
) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
232
261
|
const l1TokenCounterpart = clients.hubPoolClient.getL1TokenForL2TokenAtBlock(
|
|
233
262
|
inputToken,
|
|
234
263
|
originChainId,
|