@paraswap/dex-lib 4.6.20 → 4.6.21

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.
@@ -0,0 +1,413 @@
1
+ [
2
+ {
3
+ "inputs": [],
4
+ "stateMutability": "nonpayable",
5
+ "type": "constructor"
6
+ },
7
+ {
8
+ "inputs": [
9
+ {
10
+ "internalType": "uint256",
11
+ "name": "blockCycleNumerator",
12
+ "type": "uint256"
13
+ }
14
+ ],
15
+ "name": "InvalidBlockRate",
16
+ "type": "error"
17
+ },
18
+ {
19
+ "inputs": [
20
+ {
21
+ "internalType": "int256",
22
+ "name": "exchangeRate",
23
+ "type": "int256"
24
+ }
25
+ ],
26
+ "name": "MarketExchangeRateBelowOne",
27
+ "type": "error"
28
+ },
29
+ {
30
+ "inputs": [],
31
+ "name": "MarketExpired",
32
+ "type": "error"
33
+ },
34
+ {
35
+ "inputs": [],
36
+ "name": "MarketProportionMustNotEqualOne",
37
+ "type": "error"
38
+ },
39
+ {
40
+ "inputs": [
41
+ {
42
+ "internalType": "int256",
43
+ "name": "rateScalar",
44
+ "type": "int256"
45
+ }
46
+ ],
47
+ "name": "MarketRateScalarBelowZero",
48
+ "type": "error"
49
+ },
50
+ {
51
+ "inputs": [
52
+ {
53
+ "internalType": "int256",
54
+ "name": "totalPt",
55
+ "type": "int256"
56
+ },
57
+ {
58
+ "internalType": "int256",
59
+ "name": "totalAsset",
60
+ "type": "int256"
61
+ }
62
+ ],
63
+ "name": "MarketZeroTotalPtOrTotalAsset",
64
+ "type": "error"
65
+ },
66
+ {
67
+ "inputs": [
68
+ {
69
+ "internalType": "uint32",
70
+ "name": "duration",
71
+ "type": "uint32"
72
+ },
73
+ {
74
+ "internalType": "uint32",
75
+ "name": "cardinalityRequired",
76
+ "type": "uint32"
77
+ }
78
+ ],
79
+ "name": "TwapDurationTooLarge",
80
+ "type": "error"
81
+ },
82
+ {
83
+ "anonymous": false,
84
+ "inputs": [
85
+ {
86
+ "indexed": false,
87
+ "internalType": "uint8",
88
+ "name": "version",
89
+ "type": "uint8"
90
+ }
91
+ ],
92
+ "name": "Initialized",
93
+ "type": "event"
94
+ },
95
+ {
96
+ "anonymous": false,
97
+ "inputs": [
98
+ {
99
+ "indexed": true,
100
+ "internalType": "address",
101
+ "name": "previousOwner",
102
+ "type": "address"
103
+ },
104
+ {
105
+ "indexed": true,
106
+ "internalType": "address",
107
+ "name": "newOwner",
108
+ "type": "address"
109
+ }
110
+ ],
111
+ "name": "OwnershipTransferred",
112
+ "type": "event"
113
+ },
114
+ {
115
+ "anonymous": false,
116
+ "inputs": [
117
+ {
118
+ "indexed": false,
119
+ "internalType": "uint16",
120
+ "name": "newBlockCycleNumerator",
121
+ "type": "uint16"
122
+ }
123
+ ],
124
+ "name": "SetBlockCycleNumerator",
125
+ "type": "event"
126
+ },
127
+ {
128
+ "inputs": [],
129
+ "name": "BLOCK_CYCLE_DENOMINATOR",
130
+ "outputs": [
131
+ {
132
+ "internalType": "uint16",
133
+ "name": "",
134
+ "type": "uint16"
135
+ }
136
+ ],
137
+ "stateMutability": "view",
138
+ "type": "function"
139
+ },
140
+ {
141
+ "inputs": [],
142
+ "name": "blockCycleNumerator",
143
+ "outputs": [
144
+ {
145
+ "internalType": "uint16",
146
+ "name": "",
147
+ "type": "uint16"
148
+ }
149
+ ],
150
+ "stateMutability": "view",
151
+ "type": "function"
152
+ },
153
+ {
154
+ "inputs": [],
155
+ "name": "claimOwnership",
156
+ "outputs": [],
157
+ "stateMutability": "nonpayable",
158
+ "type": "function"
159
+ },
160
+ {
161
+ "inputs": [
162
+ {
163
+ "internalType": "address",
164
+ "name": "market",
165
+ "type": "address"
166
+ },
167
+ {
168
+ "internalType": "uint32",
169
+ "name": "duration",
170
+ "type": "uint32"
171
+ }
172
+ ],
173
+ "name": "getLpToAssetRate",
174
+ "outputs": [
175
+ {
176
+ "internalType": "uint256",
177
+ "name": "",
178
+ "type": "uint256"
179
+ }
180
+ ],
181
+ "stateMutability": "view",
182
+ "type": "function"
183
+ },
184
+ {
185
+ "inputs": [
186
+ {
187
+ "internalType": "address",
188
+ "name": "market",
189
+ "type": "address"
190
+ },
191
+ {
192
+ "internalType": "uint32",
193
+ "name": "duration",
194
+ "type": "uint32"
195
+ }
196
+ ],
197
+ "name": "getLpToSyRate",
198
+ "outputs": [
199
+ {
200
+ "internalType": "uint256",
201
+ "name": "",
202
+ "type": "uint256"
203
+ }
204
+ ],
205
+ "stateMutability": "view",
206
+ "type": "function"
207
+ },
208
+ {
209
+ "inputs": [
210
+ {
211
+ "internalType": "address",
212
+ "name": "market",
213
+ "type": "address"
214
+ },
215
+ {
216
+ "internalType": "uint32",
217
+ "name": "duration",
218
+ "type": "uint32"
219
+ }
220
+ ],
221
+ "name": "getOracleState",
222
+ "outputs": [
223
+ {
224
+ "internalType": "bool",
225
+ "name": "increaseCardinalityRequired",
226
+ "type": "bool"
227
+ },
228
+ {
229
+ "internalType": "uint16",
230
+ "name": "cardinalityRequired",
231
+ "type": "uint16"
232
+ },
233
+ {
234
+ "internalType": "bool",
235
+ "name": "oldestObservationSatisfied",
236
+ "type": "bool"
237
+ }
238
+ ],
239
+ "stateMutability": "view",
240
+ "type": "function"
241
+ },
242
+ {
243
+ "inputs": [
244
+ {
245
+ "internalType": "address",
246
+ "name": "market",
247
+ "type": "address"
248
+ },
249
+ {
250
+ "internalType": "uint32",
251
+ "name": "duration",
252
+ "type": "uint32"
253
+ }
254
+ ],
255
+ "name": "getPtToAssetRate",
256
+ "outputs": [
257
+ {
258
+ "internalType": "uint256",
259
+ "name": "",
260
+ "type": "uint256"
261
+ }
262
+ ],
263
+ "stateMutability": "view",
264
+ "type": "function"
265
+ },
266
+ {
267
+ "inputs": [
268
+ {
269
+ "internalType": "address",
270
+ "name": "market",
271
+ "type": "address"
272
+ },
273
+ {
274
+ "internalType": "uint32",
275
+ "name": "duration",
276
+ "type": "uint32"
277
+ }
278
+ ],
279
+ "name": "getPtToSyRate",
280
+ "outputs": [
281
+ {
282
+ "internalType": "uint256",
283
+ "name": "",
284
+ "type": "uint256"
285
+ }
286
+ ],
287
+ "stateMutability": "view",
288
+ "type": "function"
289
+ },
290
+ {
291
+ "inputs": [
292
+ {
293
+ "internalType": "address",
294
+ "name": "market",
295
+ "type": "address"
296
+ },
297
+ {
298
+ "internalType": "uint32",
299
+ "name": "duration",
300
+ "type": "uint32"
301
+ }
302
+ ],
303
+ "name": "getYtToAssetRate",
304
+ "outputs": [
305
+ {
306
+ "internalType": "uint256",
307
+ "name": "",
308
+ "type": "uint256"
309
+ }
310
+ ],
311
+ "stateMutability": "view",
312
+ "type": "function"
313
+ },
314
+ {
315
+ "inputs": [
316
+ {
317
+ "internalType": "address",
318
+ "name": "market",
319
+ "type": "address"
320
+ },
321
+ {
322
+ "internalType": "uint32",
323
+ "name": "duration",
324
+ "type": "uint32"
325
+ }
326
+ ],
327
+ "name": "getYtToSyRate",
328
+ "outputs": [
329
+ {
330
+ "internalType": "uint256",
331
+ "name": "",
332
+ "type": "uint256"
333
+ }
334
+ ],
335
+ "stateMutability": "view",
336
+ "type": "function"
337
+ },
338
+ {
339
+ "inputs": [
340
+ {
341
+ "internalType": "uint16",
342
+ "name": "_blockCycleNumerator",
343
+ "type": "uint16"
344
+ }
345
+ ],
346
+ "name": "initialize",
347
+ "outputs": [],
348
+ "stateMutability": "nonpayable",
349
+ "type": "function"
350
+ },
351
+ {
352
+ "inputs": [],
353
+ "name": "owner",
354
+ "outputs": [
355
+ {
356
+ "internalType": "address",
357
+ "name": "",
358
+ "type": "address"
359
+ }
360
+ ],
361
+ "stateMutability": "view",
362
+ "type": "function"
363
+ },
364
+ {
365
+ "inputs": [],
366
+ "name": "pendingOwner",
367
+ "outputs": [
368
+ {
369
+ "internalType": "address",
370
+ "name": "",
371
+ "type": "address"
372
+ }
373
+ ],
374
+ "stateMutability": "view",
375
+ "type": "function"
376
+ },
377
+ {
378
+ "inputs": [
379
+ {
380
+ "internalType": "uint16",
381
+ "name": "newBlockCycleNumerator",
382
+ "type": "uint16"
383
+ }
384
+ ],
385
+ "name": "setBlockCycleNumerator",
386
+ "outputs": [],
387
+ "stateMutability": "nonpayable",
388
+ "type": "function"
389
+ },
390
+ {
391
+ "inputs": [
392
+ {
393
+ "internalType": "address",
394
+ "name": "newOwner",
395
+ "type": "address"
396
+ },
397
+ {
398
+ "internalType": "bool",
399
+ "name": "direct",
400
+ "type": "bool"
401
+ },
402
+ {
403
+ "internalType": "bool",
404
+ "name": "renounce",
405
+ "type": "bool"
406
+ }
407
+ ],
408
+ "name": "transferOwnership",
409
+ "outputs": [],
410
+ "stateMutability": "nonpayable",
411
+ "type": "function"
412
+ }
413
+ ]
@@ -8,35 +8,68 @@
8
8
  "stateMutability": "nonpayable",
9
9
  "type": "constructor"
10
10
  },
11
+ {
12
+ "anonymous": false,
13
+ "inputs": [
14
+ {
15
+ "indexed": false,
16
+ "internalType": "uint256",
17
+ "name": "skyAmt",
18
+ "type": "uint256"
19
+ }
20
+ ],
21
+ "name": "Burn",
22
+ "type": "event"
23
+ },
11
24
  {
12
25
  "anonymous": false,
13
26
  "inputs": [
14
27
  {
15
28
  "indexed": true,
16
29
  "internalType": "address",
17
- "name": "caller",
30
+ "name": "to",
18
31
  "type": "address"
19
32
  },
33
+ {
34
+ "indexed": false,
35
+ "internalType": "uint256",
36
+ "name": "take",
37
+ "type": "uint256"
38
+ }
39
+ ],
40
+ "name": "Collect",
41
+ "type": "event"
42
+ },
43
+ {
44
+ "anonymous": false,
45
+ "inputs": [
20
46
  {
21
47
  "indexed": true,
22
48
  "internalType": "address",
23
49
  "name": "usr",
24
50
  "type": "address"
25
- },
51
+ }
52
+ ],
53
+ "name": "Deny",
54
+ "type": "event"
55
+ },
56
+ {
57
+ "anonymous": false,
58
+ "inputs": [
26
59
  {
27
- "indexed": false,
28
- "internalType": "uint256",
29
- "name": "mkrAmt",
30
- "type": "uint256"
60
+ "indexed": true,
61
+ "internalType": "bytes32",
62
+ "name": "what",
63
+ "type": "bytes32"
31
64
  },
32
65
  {
33
66
  "indexed": false,
34
67
  "internalType": "uint256",
35
- "name": "skyAmt",
68
+ "name": "data",
36
69
  "type": "uint256"
37
70
  }
38
71
  ],
39
- "name": "MkrToSky",
72
+ "name": "File",
40
73
  "type": "event"
41
74
  },
42
75
  {
@@ -54,6 +87,12 @@
54
87
  "name": "usr",
55
88
  "type": "address"
56
89
  },
90
+ {
91
+ "indexed": false,
92
+ "internalType": "uint256",
93
+ "name": "mkrAmt",
94
+ "type": "uint256"
95
+ },
57
96
  {
58
97
  "indexed": false,
59
98
  "internalType": "uint256",
@@ -63,13 +102,68 @@
63
102
  {
64
103
  "indexed": false,
65
104
  "internalType": "uint256",
66
- "name": "mkrAmt",
105
+ "name": "skyFee",
67
106
  "type": "uint256"
68
107
  }
69
108
  ],
70
- "name": "SkyToMkr",
109
+ "name": "MkrToSky",
110
+ "type": "event"
111
+ },
112
+ {
113
+ "anonymous": false,
114
+ "inputs": [
115
+ {
116
+ "indexed": true,
117
+ "internalType": "address",
118
+ "name": "usr",
119
+ "type": "address"
120
+ }
121
+ ],
122
+ "name": "Rely",
71
123
  "type": "event"
72
124
  },
125
+ {
126
+ "inputs": [
127
+ { "internalType": "uint256", "name": "skyAmt", "type": "uint256" }
128
+ ],
129
+ "name": "burn",
130
+ "outputs": [],
131
+ "stateMutability": "nonpayable",
132
+ "type": "function"
133
+ },
134
+ {
135
+ "inputs": [{ "internalType": "address", "name": "to", "type": "address" }],
136
+ "name": "collect",
137
+ "outputs": [
138
+ { "internalType": "uint256", "name": "take_", "type": "uint256" }
139
+ ],
140
+ "stateMutability": "nonpayable",
141
+ "type": "function"
142
+ },
143
+ {
144
+ "inputs": [{ "internalType": "address", "name": "usr", "type": "address" }],
145
+ "name": "deny",
146
+ "outputs": [],
147
+ "stateMutability": "nonpayable",
148
+ "type": "function"
149
+ },
150
+ {
151
+ "inputs": [],
152
+ "name": "fee",
153
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
154
+ "stateMutability": "view",
155
+ "type": "function"
156
+ },
157
+ {
158
+ "inputs": [
159
+ { "internalType": "bytes32", "name": "what", "type": "bytes32" },
160
+ { "internalType": "uint256", "name": "data", "type": "uint256" }
161
+ ],
162
+ "name": "file",
163
+ "outputs": [],
164
+ "stateMutability": "nonpayable",
165
+ "type": "function"
166
+ },
73
167
  {
74
168
  "inputs": [],
75
169
  "name": "mkr",
@@ -96,6 +190,13 @@
96
190
  "stateMutability": "view",
97
191
  "type": "function"
98
192
  },
193
+ {
194
+ "inputs": [{ "internalType": "address", "name": "usr", "type": "address" }],
195
+ "name": "rely",
196
+ "outputs": [],
197
+ "stateMutability": "nonpayable",
198
+ "type": "function"
199
+ },
99
200
  {
100
201
  "inputs": [],
101
202
  "name": "sky",
@@ -106,13 +207,17 @@
106
207
  "type": "function"
107
208
  },
108
209
  {
109
- "inputs": [
110
- { "internalType": "address", "name": "usr", "type": "address" },
111
- { "internalType": "uint256", "name": "skyAmt", "type": "uint256" }
112
- ],
113
- "name": "skyToMkr",
114
- "outputs": [],
115
- "stateMutability": "nonpayable",
210
+ "inputs": [],
211
+ "name": "take",
212
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
213
+ "stateMutability": "view",
214
+ "type": "function"
215
+ },
216
+ {
217
+ "inputs": [{ "internalType": "address", "name": "", "type": "address" }],
218
+ "name": "wards",
219
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
220
+ "stateMutability": "view",
116
221
  "type": "function"
117
222
  }
118
223
  ]
@@ -0,0 +1,29 @@
1
+ import { Interface } from '@ethersproject/abi';
2
+ import { DeepReadonly } from 'ts-essentials';
3
+ import { Log, Logger, Address } from '../../types';
4
+ import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
5
+ import { IDexHelper } from '../../dex-helper/idex-helper';
6
+ import { Network } from '../../constants';
7
+ import { SupportedPt } from './types';
8
+ export type FactoryState = {
9
+ markets: SupportedPt[];
10
+ lastFetchTimestamp: number;
11
+ };
12
+ export declare class AavePtToUnderlyingFactory extends StatefulEventSubscriber<FactoryState> {
13
+ readonly parentName: string;
14
+ protected network: Network;
15
+ protected dexHelper: IDexHelper;
16
+ handlers: {
17
+ [event: string]: (event: any, state: DeepReadonly<FactoryState>, log: Readonly<Log>) => Promise<DeepReadonly<FactoryState> | null>;
18
+ };
19
+ logDecoder: (log: Log) => any;
20
+ addressesSubscribed: Address[];
21
+ protected deployerIface: Interface;
22
+ private readonly CACHE_TTL_MS;
23
+ constructor(parentName: string, network: Network, dexHelper: IDexHelper, logger: Logger);
24
+ handleMarketDeployment(event: any, _state: DeepReadonly<FactoryState>, _log: Readonly<Log>): Promise<DeepReadonly<FactoryState> | null>;
25
+ processLog(state: DeepReadonly<FactoryState>, log: Readonly<Log>): Promise<DeepReadonly<FactoryState> | null>;
26
+ getStateOrGenerate(blockNumber: number, readonly?: boolean): Promise<DeepReadonly<FactoryState>>;
27
+ generateState(_blockNumber: number): Promise<DeepReadonly<FactoryState>>;
28
+ private fetchMarketsFromAPI;
29
+ }