@paraswap/dex-lib 3.8.20-lite-psm → 3.8.20-lite-psm.2
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/lite-psm/dai.json +333 -0
- package/build/abi/lite-psm/usdc.json +814 -0
- package/build/dex/lite-psm/lite-psm-event-pool.js +13 -7
- package/build/dex/lite-psm/lite-psm-event-pool.js.map +1 -1
- package/build/dex/lite-psm/lite-psm.js +2 -1
- package/build/dex/lite-psm/lite-psm.js.map +1 -1
- package/build/dex-helper/dummy-dex-helper.js +1 -1
- package/build/dex-helper/dummy-dex-helper.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/lite-psm/dai.json +333 -0
- package/src/abi/lite-psm/usdc.json +814 -0
- package/src/dex/lite-psm/lite-psm-event-pool.ts +12 -9
- package/src/dex/lite-psm/lite-psm.ts +2 -4
- package/src/dex-helper/dummy-dex-helper.ts +1 -1
|
@@ -10,9 +10,13 @@ import { LitePsmConfig } from './config';
|
|
|
10
10
|
import PsmABI from '../../abi/maker-psm/psm.json';
|
|
11
11
|
import VatABI from '../../abi/maker-psm/vat.json';
|
|
12
12
|
import { erc20Iface } from '../../lib/tokens/utils';
|
|
13
|
+
import DaiABI from '../../abi/lite-psm/dai.json';
|
|
14
|
+
import UsdcABI from '../../abi/lite-psm/usdc.json';
|
|
13
15
|
|
|
14
16
|
const vatInterface = new Interface(VatABI);
|
|
15
17
|
const psmInterface = new Interface(PsmABI);
|
|
18
|
+
const daiInterface = new Interface(DaiABI);
|
|
19
|
+
const usdcInterface = new Interface(UsdcABI);
|
|
16
20
|
|
|
17
21
|
const bigIntify = (b: any) => BigInt(b.toString());
|
|
18
22
|
|
|
@@ -115,11 +119,10 @@ export class LitePsmEventPool extends StatefulEventSubscriber<PoolState> {
|
|
|
115
119
|
LitePsmConfig[this.parentName][this.network].dai.address.toLowerCase();
|
|
116
120
|
this.logDecoder = (log: Log) => {
|
|
117
121
|
const logAddress = log.address.toLowerCase();
|
|
118
|
-
if (
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return erc20Iface.parseLog(log);
|
|
122
|
+
if (logAddress === this.daiAddress) {
|
|
123
|
+
return daiInterface.parseLog(log);
|
|
124
|
+
} else if (logAddress === this.poolConfig.gem.address) {
|
|
125
|
+
return usdcInterface.parseLog(log);
|
|
123
126
|
} else {
|
|
124
127
|
return psmInterface.parseLog(log);
|
|
125
128
|
}
|
|
@@ -155,10 +158,10 @@ export class LitePsmEventPool extends StatefulEventSubscriber<PoolState> {
|
|
|
155
158
|
}
|
|
156
159
|
|
|
157
160
|
handleTransferDAI(event: any, pool: PoolState, log: Log): PoolState {
|
|
158
|
-
if (event.args?.
|
|
159
|
-
pool.daiBalance -= bigIntify(event.args.
|
|
160
|
-
} else if (event.args?.
|
|
161
|
-
pool.daiBalance += bigIntify(event.args.
|
|
161
|
+
if (event.args?.src?.toLowerCase() === this.poolConfig.psmAddress) {
|
|
162
|
+
pool.daiBalance -= bigIntify(event.args.wad);
|
|
163
|
+
} else if (event.args?.dst?.toLowerCase() === this.poolConfig.psmAddress) {
|
|
164
|
+
pool.daiBalance += bigIntify(event.args.wad);
|
|
162
165
|
}
|
|
163
166
|
return pool;
|
|
164
167
|
}
|
|
@@ -560,12 +560,10 @@ export class LitePsm
|
|
|
560
560
|
// this.vatAddress,
|
|
561
561
|
// 'latest',
|
|
562
562
|
// );
|
|
563
|
+
const blockNumber = this.dexHelper.blockManager.getLatestBlockNumber();
|
|
563
564
|
const poolStates = await Promise.all(
|
|
564
565
|
Object.values(this.eventPools).map(e =>
|
|
565
|
-
this.getPoolState(
|
|
566
|
-
e,
|
|
567
|
-
this.dexHelper.blockManager.getLatestBlockNumber(),
|
|
568
|
-
),
|
|
566
|
+
this.getPoolState(e, blockNumber),
|
|
569
567
|
),
|
|
570
568
|
);
|
|
571
569
|
return validPoolConfigs.map((p, i) => ({
|
|
@@ -261,7 +261,7 @@ export class DummyRequestWrapper implements IRequestWrapper {
|
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
class DummyBlockManager implements IBlockManager {
|
|
264
|
-
constructor(public _blockNumber: number =
|
|
264
|
+
constructor(public _blockNumber: number = 20569333) {}
|
|
265
265
|
|
|
266
266
|
subscribeToLogs(
|
|
267
267
|
subscriber: EventSubscriber,
|