@paraswap/dex-lib 3.8.37 → 3.8.39-bebop
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/build/abi/USDM.json +807 -0
- package/build/abi/bebop/BebopSettlement.abi.json +2137 -0
- package/build/abi/cables/CablesMainnetRFQ.json +1073 -0
- package/build/abi/wUSDM.json +757 -0
- package/build/config.js +7 -0
- package/build/config.js.map +1 -1
- package/build/dex/bebop/bebop.d.ts +55 -0
- package/build/dex/bebop/bebop.js +524 -0
- package/build/dex/bebop/bebop.js.map +1 -0
- package/build/dex/bebop/config.d.ts +3 -0
- package/build/dex/bebop/config.js +38 -0
- package/build/dex/bebop/config.js.map +1 -0
- package/build/dex/bebop/constants.d.ts +9 -0
- package/build/dex/bebop/constants.js +13 -0
- package/build/dex/bebop/constants.js.map +1 -0
- package/build/dex/bebop/rate-fetcher.d.ts +22 -0
- package/build/dex/bebop/rate-fetcher.js +80 -0
- package/build/dex/bebop/rate-fetcher.js.map +1 -0
- package/build/dex/bebop/types.d.ts +76 -0
- package/build/dex/bebop/types.js +3 -0
- package/build/dex/bebop/types.js.map +1 -0
- package/build/dex/bebop/validators.d.ts +4 -0
- package/build/dex/bebop/validators.js +42 -0
- package/build/dex/bebop/validators.js.map +1 -0
- package/build/dex/bebop/websocket-fetcher.d.ts +35 -0
- package/build/dex/bebop/websocket-fetcher.js +87 -0
- package/build/dex/bebop/websocket-fetcher.js.map +1 -0
- package/build/dex/cables/cables.d.ts +64 -0
- package/build/dex/cables/cables.js +445 -0
- package/build/dex/cables/cables.js.map +1 -0
- package/build/dex/cables/config.d.ts +4 -0
- package/build/dex/cables/config.js +15 -0
- package/build/dex/cables/config.js.map +1 -0
- package/build/dex/cables/constants.d.ts +19 -0
- package/build/dex/cables/constants.js +26 -0
- package/build/dex/cables/constants.js.map +1 -0
- package/build/dex/cables/rate-fetcher.d.ts +34 -0
- package/build/dex/cables/rate-fetcher.js +117 -0
- package/build/dex/cables/rate-fetcher.js.map +1 -0
- package/build/dex/cables/types.d.ts +106 -0
- package/build/dex/cables/types.js +12 -0
- package/build/dex/cables/types.js.map +1 -0
- package/build/dex/cables/validators.d.ts +5 -0
- package/build/dex/cables/validators.js +49 -0
- package/build/dex/cables/validators.js.map +1 -0
- package/build/dex/index.js +2 -0
- package/build/dex/index.js.map +1 -1
- package/build/dex/spark/config.js +25 -0
- package/build/dex/spark/config.js.map +1 -1
- package/build/dex/spark/scripts/validate-state.js +1 -1
- package/build/dex/spark/scripts/validate-state.js.map +1 -1
- package/build/dex/spark/spark-sdai-pool.d.ts +7 -3
- package/build/dex/spark/spark-sdai-pool.js +24 -28
- package/build/dex/spark/spark-sdai-pool.js.map +1 -1
- package/build/dex/spark/spark.d.ts +10 -5
- package/build/dex/spark/spark.js +46 -31
- package/build/dex/spark/spark.js.map +1 -1
- package/build/dex/spark/types.d.ts +6 -0
- package/build/dex/spark/types.js.map +1 -1
- package/build/dex/spark/utils.d.ts +3 -1
- package/build/dex/spark/utils.js +43 -7
- package/build/dex/spark/utils.js.map +1 -1
- package/build/dex/woo-fi-v2/woo-fi-v2-pool.d.ts +2 -2
- package/build/dex/woo-fi-v2/woo-fi-v2-pool.js +30 -9
- package/build/dex/woo-fi-v2/woo-fi-v2-pool.js.map +1 -1
- package/build/dex/woo-fi-v2/woo-fi-v2.js +1 -1
- package/build/dex/woo-fi-v2/woo-fi-v2.js.map +1 -1
- package/build/dex/wusdm/config.d.ts +3 -0
- package/build/dex/wusdm/config.js +29 -0
- package/build/dex/wusdm/config.js.map +1 -0
- package/build/dex/wusdm/types.d.ts +10 -0
- package/build/dex/wusdm/types.js +3 -0
- package/build/dex/wusdm/types.js.map +1 -0
- package/build/dex/wusdm/wusdm.d.ts +39 -0
- package/build/dex/wusdm/wusdm.js +212 -0
- package/build/dex/wusdm/wusdm.js.map +1 -0
- package/build/lib/fetcher/wsFetcher.d.ts +35 -0
- package/build/lib/fetcher/wsFetcher.js +87 -0
- package/build/lib/fetcher/wsFetcher.js.map +1 -0
- package/build/types.d.ts +1 -0
- package/package.json +4 -2
- package/src/abi/bebop/BebopSettlement.abi.json +2137 -0
- package/src/abi/sdai/SavingsUSDS.abi.json +720 -0
- package/src/config.ts +8 -0
- package/src/dex/bebop/bebop-e2e.test.ts +195 -0
- package/src/dex/bebop/bebop-integration.test.ts +170 -0
- package/src/dex/bebop/bebop.ts +732 -0
- package/src/dex/bebop/config.ts +37 -0
- package/src/dex/bebop/constants.ts +9 -0
- package/src/dex/bebop/rate-fetcher.ts +138 -0
- package/src/dex/bebop/types.ts +81 -0
- package/src/dex/bebop/validators.ts +43 -0
- package/src/dex/index.ts +2 -0
- package/src/dex/spark/config.ts +24 -0
- package/src/dex/spark/scripts/validate-state.ts +1 -0
- package/src/dex/spark/spark-e2e.test.ts +25 -21
- package/src/dex/spark/spark-events.test.ts +77 -62
- package/src/dex/spark/spark-integration.test.ts +290 -7
- package/src/dex/spark/spark-sdai-pool.ts +22 -19
- package/src/dex/spark/spark.ts +62 -36
- package/src/dex/spark/types.ts +6 -0
- package/src/dex/spark/utils.ts +83 -19
- package/src/dex/woo-fi-v2/woo-fi-v2-pool.ts +58 -27
- package/src/dex/woo-fi-v2/woo-fi-v2.ts +1 -2
- package/src/lib/fetcher/wsFetcher.ts +126 -0
- package/src/types.ts +1 -0
- package/tests/constants-e2e.ts +5 -0
|
@@ -26,8 +26,7 @@ export class WooFiV2PollingPool extends StatefulRpcPoller<
|
|
|
26
26
|
poolIdentifier: string,
|
|
27
27
|
dexHelper: IDexHelper,
|
|
28
28
|
protected config: DexParams,
|
|
29
|
-
|
|
30
|
-
protected tokens: Token[],
|
|
29
|
+
protected baseTokens: Token[],
|
|
31
30
|
) {
|
|
32
31
|
const callbacks = pollingManagerCbExtractor(
|
|
33
32
|
StatePollingManager.getInstance(dexHelper),
|
|
@@ -50,37 +49,66 @@ export class WooFiV2PollingPool extends StatefulRpcPoller<
|
|
|
50
49
|
decodeFunction: uint256ToBigInt,
|
|
51
50
|
},
|
|
52
51
|
] as MultiCallParams<MulticallResultOutputs>[]
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
52
|
+
)
|
|
53
|
+
.concat([
|
|
54
|
+
{
|
|
55
|
+
target: this.config.wooPPV2Address,
|
|
56
|
+
callData: ifaces.PPV2.encodeFunctionData('tokenInfos', [
|
|
57
|
+
this.config.quoteToken.address,
|
|
58
|
+
]),
|
|
59
|
+
decodeFunction: tokenInfoDecoder,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
target: this.config.wooPPV2Address,
|
|
63
|
+
callData: ifaces.PPV2.encodeFunctionData('decimalInfo', [
|
|
64
|
+
this.config.quoteToken.address,
|
|
65
|
+
]),
|
|
66
|
+
decodeFunction: decimalInfoDecoder,
|
|
67
|
+
},
|
|
68
|
+
])
|
|
69
|
+
.concat(
|
|
70
|
+
this.baseTokens
|
|
71
|
+
.map(t => [
|
|
72
|
+
{
|
|
73
|
+
target: this.config.wooPPV2Address,
|
|
74
|
+
callData: ifaces.PPV2.encodeFunctionData('tokenInfos', [
|
|
75
|
+
t.address,
|
|
76
|
+
]),
|
|
77
|
+
decodeFunction: tokenInfoDecoder,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
target: this.config.wooPPV2Address,
|
|
81
|
+
callData: ifaces.PPV2.encodeFunctionData('decimalInfo', [
|
|
82
|
+
t.address,
|
|
83
|
+
]),
|
|
84
|
+
decodeFunction: decimalInfoDecoder,
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
target: this.config.wooOracleV2Address,
|
|
88
|
+
callData: ifaces.oracleV2.encodeFunctionData('state', [
|
|
89
|
+
t.address,
|
|
90
|
+
]),
|
|
91
|
+
decodeFunction: stateDecoder,
|
|
92
|
+
},
|
|
93
|
+
])
|
|
94
|
+
.flat(),
|
|
95
|
+
);
|
|
76
96
|
}
|
|
77
97
|
|
|
78
98
|
protected _parseStateFromMultiResults(
|
|
79
99
|
multiOutputs: MulticallResultOutputs[],
|
|
80
100
|
): PoolState {
|
|
81
|
-
const [
|
|
101
|
+
const [
|
|
102
|
+
isPaused,
|
|
103
|
+
oracleTimestamp,
|
|
104
|
+
quoteTokenInfo,
|
|
105
|
+
quoteTokenDecimals,
|
|
106
|
+
...remained
|
|
107
|
+
] = multiOutputs as [
|
|
82
108
|
boolean,
|
|
83
109
|
bigint,
|
|
110
|
+
TokenInfo,
|
|
111
|
+
DecimalInfo,
|
|
84
112
|
...MulticallResultOutputs[],
|
|
85
113
|
];
|
|
86
114
|
|
|
@@ -88,13 +116,16 @@ export class WooFiV2PollingPool extends StatefulRpcPoller<
|
|
|
88
116
|
const decimals: Record<string, DecimalInfo> = {};
|
|
89
117
|
const tokenStates: Record<string, TokenState> = {};
|
|
90
118
|
|
|
119
|
+
tokenInfos[this.config.quoteToken.address] = quoteTokenInfo;
|
|
120
|
+
decimals[this.config.quoteToken.address] = quoteTokenDecimals;
|
|
121
|
+
|
|
91
122
|
_.chunk(remained, 3).forEach((chunk, i) => {
|
|
92
123
|
const [tokenInfo, decimalInfo, tokenState] = chunk as [
|
|
93
124
|
TokenInfo,
|
|
94
125
|
DecimalInfo,
|
|
95
126
|
TokenState,
|
|
96
127
|
];
|
|
97
|
-
const token = this.
|
|
128
|
+
const token = this.baseTokens[i];
|
|
98
129
|
|
|
99
130
|
tokenInfos[token.address] = tokenInfo;
|
|
100
131
|
decimals[token.address] = decimalInfo;
|
|
@@ -27,7 +27,6 @@ import { ethers } from 'ethers';
|
|
|
27
27
|
import { addressDecode } from '../../lib/decoders';
|
|
28
28
|
import { ifaces } from './utils';
|
|
29
29
|
import { StatePollingManager } from '../../lib/stateful-rpc-poller/state-polling-manager';
|
|
30
|
-
import { solidityPack } from 'ethers/lib/utils';
|
|
31
30
|
import { extractReturnAmountPosition } from '../../executor/utils';
|
|
32
31
|
|
|
33
32
|
export class WooFiV2 extends SimpleExchange implements IDex<WooFiV2Data> {
|
|
@@ -521,7 +520,7 @@ export class WooFiV2 extends SimpleExchange implements IDex<WooFiV2Data> {
|
|
|
521
520
|
this.getIdentifier(),
|
|
522
521
|
this.dexHelper,
|
|
523
522
|
this.config,
|
|
524
|
-
|
|
523
|
+
this.baseTokens,
|
|
525
524
|
);
|
|
526
525
|
|
|
527
526
|
this.pollingManager.initializeAllPendingPools();
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { Logger } from 'log4js';
|
|
2
|
+
import { RequestConfig, Response } from '../../dex-helper/irequest-wrapper';
|
|
3
|
+
import {
|
|
4
|
+
connection as WebSocketConnection,
|
|
5
|
+
client as WebSocketClient,
|
|
6
|
+
} from 'websocket';
|
|
7
|
+
|
|
8
|
+
export class SkippingRequest {
|
|
9
|
+
constructor(public message = '') {}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type RequestInfo<T> = {
|
|
13
|
+
requestFunc?: (
|
|
14
|
+
options: RequestConfig,
|
|
15
|
+
) => Promise<Response<T> | SkippingRequest>;
|
|
16
|
+
requestOptions: RequestConfig;
|
|
17
|
+
caster: (data: unknown) => T;
|
|
18
|
+
authenticate?: (options: RequestConfig) => RequestConfig;
|
|
19
|
+
excludedFieldsCaching?: string[];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type RequestInfoWithHandler<T> = {
|
|
23
|
+
info: RequestInfo<T>;
|
|
24
|
+
handler: (data: T) => void;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export class WebSocketFetcher<T> {
|
|
28
|
+
private requests: RequestInfoWithHandler<T>;
|
|
29
|
+
public lastFetchSucceeded: boolean = false;
|
|
30
|
+
private stop: boolean = true;
|
|
31
|
+
private ws: WebSocketClient = new WebSocketClient();
|
|
32
|
+
private connection: WebSocketConnection | null = null;
|
|
33
|
+
|
|
34
|
+
constructor(requestsInfo: RequestInfoWithHandler<T>, private logger: Logger) {
|
|
35
|
+
this.requests = requestsInfo;
|
|
36
|
+
this.ws.on('connect', this.connected.bind(this));
|
|
37
|
+
this.ws.on('connectFailed', this.connectFailed.bind(this));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private connected(connection: WebSocketConnection) {
|
|
41
|
+
this.connection = connection;
|
|
42
|
+
this.logger.info(`Connected to ${this.requests.info.requestOptions.url}`);
|
|
43
|
+
this.connection.on('error', this.onError.bind(this));
|
|
44
|
+
this.connection.on('close', this.onClose.bind(this));
|
|
45
|
+
this.connection.on('message', this.onMessage.bind(this));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private connectFailed(error: any) {
|
|
49
|
+
this.logger.error(`Connect Error: ${error.toString()}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private onClose() {
|
|
53
|
+
this.logger.info(`Connection closed`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private onError(error: any) {
|
|
57
|
+
this.logger.error(`Connection Error: ${error.toString()}`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private onMessage(message: any) {
|
|
61
|
+
if (message.type === 'utf8') {
|
|
62
|
+
const response = JSON.parse(message.utf8Data) as Response<T>;
|
|
63
|
+
const reqInfo = this.requests;
|
|
64
|
+
const info = reqInfo.info;
|
|
65
|
+
const options = reqInfo.info.requestOptions;
|
|
66
|
+
this.logger.debug(`(${options.url}) received new data`);
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
const parsedData = info.caster(response);
|
|
70
|
+
reqInfo.handler(parsedData);
|
|
71
|
+
} catch (e) {
|
|
72
|
+
this.logger.info(e);
|
|
73
|
+
this.logger.info(
|
|
74
|
+
`(${options.url}) received incorrect data ${JSON.stringify(
|
|
75
|
+
response,
|
|
76
|
+
).replace(/(?:\r\n|\r|\n)/g, ' ')}`,
|
|
77
|
+
e,
|
|
78
|
+
);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private connect() {
|
|
85
|
+
const authorization =
|
|
86
|
+
this.requests.info.requestOptions.headers!.authorization;
|
|
87
|
+
const name = this.requests.info.requestOptions.headers!.name;
|
|
88
|
+
if (typeof authorization !== 'string') {
|
|
89
|
+
throw new Error('Authorization header is not a string');
|
|
90
|
+
}
|
|
91
|
+
if (typeof name !== 'string') {
|
|
92
|
+
throw new Error('Name header is not a string');
|
|
93
|
+
}
|
|
94
|
+
this.ws.connect(
|
|
95
|
+
this.requests.info.requestOptions.url!,
|
|
96
|
+
undefined,
|
|
97
|
+
undefined,
|
|
98
|
+
{
|
|
99
|
+
Authorization: authorization,
|
|
100
|
+
name: name,
|
|
101
|
+
},
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
startPolling(): void {
|
|
106
|
+
this.stop = false;
|
|
107
|
+
this.connect();
|
|
108
|
+
this.logger.info(
|
|
109
|
+
`Connection started for ${this.requests.info.requestOptions.url}`,
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
stopPolling() {
|
|
114
|
+
if (this.connection) {
|
|
115
|
+
this.connection.close();
|
|
116
|
+
}
|
|
117
|
+
this.stop = true;
|
|
118
|
+
this.logger.info(
|
|
119
|
+
`Connection stopped for ${this.requests.info.requestOptions.url}`,
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
isPolling(): boolean {
|
|
124
|
+
return !this.stop;
|
|
125
|
+
}
|
|
126
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -304,6 +304,7 @@ export type Config = {
|
|
|
304
304
|
uniswapV3EventLoggingSampleRate?: number;
|
|
305
305
|
swaapV2AuthToken?: string;
|
|
306
306
|
dexalotAuthToken?: string;
|
|
307
|
+
bebopAuthToken?: string;
|
|
307
308
|
idleDaoAuthToken?: string;
|
|
308
309
|
forceRpcFallbackDexs: string[];
|
|
309
310
|
apiKeyTheGraph: string;
|
package/tests/constants-e2e.ts
CHANGED
|
@@ -19,6 +19,10 @@ export const Tokens: {
|
|
|
19
19
|
[network: number]: { [symbol: string]: SmartTokenParams };
|
|
20
20
|
} = {
|
|
21
21
|
[Network.MAINNET]: {
|
|
22
|
+
sUSDS: {
|
|
23
|
+
address: '0xa3931d71877C0E7a3148CB7Eb4463524FEc27fbD',
|
|
24
|
+
decimals: 18,
|
|
25
|
+
},
|
|
22
26
|
USDS: {
|
|
23
27
|
address: '0xdC035D45d973E3EC169d2276DDab16f1e407384F',
|
|
24
28
|
decimals: 18,
|
|
@@ -1511,6 +1515,7 @@ export const Holders: {
|
|
|
1511
1515
|
} = {
|
|
1512
1516
|
[Network.MAINNET]: {
|
|
1513
1517
|
USDS: '0xB1796E8f1eEcF23027c1E3C00fE303629A189d10',
|
|
1518
|
+
sUSDS: '0xd564B3aE673CAa49D054Bf185bD72a6853763eE7',
|
|
1514
1519
|
SKY: '0x0ddda327A6614130CCb20bc0097313A282176A01',
|
|
1515
1520
|
MKR: '0xe9aAA7A9DDc0877626C1779AbC29993aD89A6c1f',
|
|
1516
1521
|
// Idle tokens
|