@paraswap/dex-lib 4.6.21 → 4.6.22
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/PendleRouterStatic.json +19 -0
- package/build/abi/apex-defi/ApexDefiFactory.abi.json +1749 -0
- package/build/abi/apex-defi/ApexDefiRouter.abi.json +1120 -0
- package/build/abi/apex-defi/ApexDefiToken.abi.json +229 -0
- package/build/abi/apex-defi/ApexDefiWrapper.abi.json +92 -0
- package/build/abi/apex-defi/ApexDefiWrapperFactory.abi.json +1107 -0
- package/build/abi/ekubo/router.json +416 -398
- package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying.d.ts +2 -3
- package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying.js +53 -26
- package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying.js.map +1 -1
- package/build/dex/aave-pt-to-underlying/config.js +3 -0
- package/build/dex/aave-pt-to-underlying/config.js.map +1 -1
- package/build/dex/aave-pt-to-underlying/types.d.ts +1 -0
- package/build/dex/apex-defi/apex-defi-factory.d.ts +26 -0
- package/build/dex/apex-defi/apex-defi-factory.js +53 -0
- package/build/dex/apex-defi/apex-defi-factory.js.map +1 -0
- package/build/dex/apex-defi/apex-defi-pool.d.ts +55 -0
- package/build/dex/apex-defi/apex-defi-pool.js +247 -0
- package/build/dex/apex-defi/apex-defi-pool.js.map +1 -0
- package/build/dex/apex-defi/apex-defi-wrapper-factory.d.ts +57 -0
- package/build/dex/apex-defi/apex-defi-wrapper-factory.js +250 -0
- package/build/dex/apex-defi/apex-defi-wrapper-factory.js.map +1 -0
- package/build/dex/apex-defi/apex-defi.d.ts +97 -0
- package/build/dex/apex-defi/apex-defi.js +1021 -0
- package/build/dex/apex-defi/apex-defi.js.map +1 -0
- package/build/dex/apex-defi/config.d.ts +4 -0
- package/build/dex/apex-defi/config.js +138 -0
- package/build/dex/apex-defi/config.js.map +1 -0
- package/build/dex/apex-defi/types.d.ts +32 -0
- package/build/dex/apex-defi/types.js +3 -0
- package/build/dex/apex-defi/types.js.map +1 -0
- package/build/dex/apex-defi/utils.d.ts +46 -0
- package/build/dex/apex-defi/utils.js +133 -0
- package/build/dex/apex-defi/utils.js.map +1 -0
- package/build/dex/ekubo/config.d.ts +2 -1
- package/build/dex/ekubo/config.js +6 -4
- package/build/dex/ekubo/config.js.map +1 -1
- package/build/dex/ekubo/ekubo.d.ts +13 -12
- package/build/dex/ekubo/ekubo.js +282 -234
- package/build/dex/ekubo/ekubo.js.map +1 -1
- package/build/dex/ekubo/pools/base.d.ts +6 -2
- package/build/dex/ekubo/pools/base.js +120 -113
- package/build/dex/ekubo/pools/base.js.map +1 -1
- package/build/dex/ekubo/pools/full-range.d.ts +6 -5
- package/build/dex/ekubo/pools/full-range.js +50 -40
- package/build/dex/ekubo/pools/full-range.js.map +1 -1
- package/build/dex/ekubo/pools/math/swap.js +3 -3
- package/build/dex/ekubo/pools/math/swap.js.map +1 -1
- package/build/dex/ekubo/pools/math/tick.d.ts +1 -0
- package/build/dex/ekubo/pools/math/tick.js +9 -4
- package/build/dex/ekubo/pools/math/tick.js.map +1 -1
- package/build/dex/ekubo/pools/oracle.d.ts +5 -6
- package/build/dex/ekubo/pools/oracle.js +8 -10
- package/build/dex/ekubo/pools/oracle.js.map +1 -1
- package/build/dex/ekubo/pools/twamm.d.ts +5 -3
- package/build/dex/ekubo/pools/twamm.js +102 -94
- package/build/dex/ekubo/pools/twamm.js.map +1 -1
- package/build/dex/ekubo/pools/utils.d.ts +8 -7
- package/build/dex/ekubo/pools/utils.js +31 -18
- package/build/dex/ekubo/pools/utils.js.map +1 -1
- package/build/dex/ekubo/types.d.ts +1 -0
- package/build/dex/ekubo/utils.d.ts +0 -1
- package/build/dex/ekubo/utils.js +0 -4
- package/build/dex/ekubo/utils.js.map +1 -1
- package/build/dex/yo/config.d.ts +3 -0
- package/build/dex/yo/config.js +21 -0
- package/build/dex/yo/config.js.map +1 -0
- package/build/dex/yo/types.d.ts +13 -0
- package/build/dex/yo/types.js +3 -0
- package/build/dex/yo/types.js.map +1 -0
- package/build/dex/yo/yo-pool.d.ts +13 -0
- package/build/dex/yo/yo-pool.js +26 -0
- package/build/dex/yo/yo-pool.js.map +1 -0
- package/build/dex/yo/yo.d.ts +39 -0
- package/build/dex/yo/yo.js +248 -0
- package/build/dex/yo/yo.js.map +1 -0
- package/package.json +1 -1
|
@@ -13,7 +13,7 @@ export declare class AavePtToUnderlying extends SimpleExchange implements IDex<A
|
|
|
13
13
|
readonly needWrapNative = false;
|
|
14
14
|
readonly isFeeOnTransferSupported = false;
|
|
15
15
|
private config;
|
|
16
|
-
private
|
|
16
|
+
private routerStaticInterface;
|
|
17
17
|
private markets;
|
|
18
18
|
logger: Logger;
|
|
19
19
|
static dexKeysWithNetwork: {
|
|
@@ -30,8 +30,7 @@ export declare class AavePtToUnderlying extends SimpleExchange implements IDex<A
|
|
|
30
30
|
getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
|
|
31
31
|
private fetchActiveMarkets;
|
|
32
32
|
private getMarketByPtToken;
|
|
33
|
-
private
|
|
34
|
-
private calculatePriceFromOracle;
|
|
33
|
+
private calculatePricesFromRouterStatic;
|
|
35
34
|
getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<ExchangePrices<AavePtToUnderlyingData> | null>;
|
|
36
35
|
getCalldataGasCost(): number | number[];
|
|
37
36
|
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: AavePtToUnderlyingData, side: SwapSide): AdapterExchangeParam;
|
|
@@ -43,7 +43,7 @@ const utils_1 = require("../../utils");
|
|
|
43
43
|
const simple_exchange_1 = require("../simple-exchange");
|
|
44
44
|
const config_1 = require("./config");
|
|
45
45
|
const abi_1 = require("@ethersproject/abi");
|
|
46
|
-
const
|
|
46
|
+
const PendleRouterStatic_json_1 = __importDefault(require("../../abi/PendleRouterStatic.json"));
|
|
47
47
|
const constants_2 = require("./constants");
|
|
48
48
|
class AavePtToUnderlying extends simple_exchange_1.SimpleExchange {
|
|
49
49
|
network;
|
|
@@ -53,7 +53,7 @@ class AavePtToUnderlying extends simple_exchange_1.SimpleExchange {
|
|
|
53
53
|
needWrapNative = false;
|
|
54
54
|
isFeeOnTransferSupported = false;
|
|
55
55
|
config;
|
|
56
|
-
|
|
56
|
+
routerStaticInterface;
|
|
57
57
|
markets = new Map();
|
|
58
58
|
logger;
|
|
59
59
|
static dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.AavePtToUnderlyingConfig);
|
|
@@ -64,7 +64,7 @@ class AavePtToUnderlying extends simple_exchange_1.SimpleExchange {
|
|
|
64
64
|
this.dexHelper = dexHelper;
|
|
65
65
|
this.config = config_1.AavePtToUnderlyingConfig[dexKey][network];
|
|
66
66
|
this.logger = dexHelper.getLogger(dexKey);
|
|
67
|
-
this.
|
|
67
|
+
this.routerStaticInterface = new abi_1.Interface(PendleRouterStatic_json_1.default);
|
|
68
68
|
}
|
|
69
69
|
async initializePricing(blockNumber) {
|
|
70
70
|
await this.fetchActiveMarkets();
|
|
@@ -140,29 +140,52 @@ class AavePtToUnderlying extends simple_exchange_1.SimpleExchange {
|
|
|
140
140
|
}
|
|
141
141
|
return cachedMarket;
|
|
142
142
|
}
|
|
143
|
-
async
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const rate = await this.dexHelper.provider.call({
|
|
147
|
-
to: this.config.oracleAddress,
|
|
148
|
-
data: callData,
|
|
149
|
-
});
|
|
150
|
-
return BigInt(rate);
|
|
143
|
+
async calculatePricesFromRouterStatic(market, amounts, side, blockNumber) {
|
|
144
|
+
if (side === constants_1.SwapSide.BUY) {
|
|
145
|
+
return null;
|
|
151
146
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
147
|
+
const blockTag = blockNumber > 0 ? blockNumber : undefined;
|
|
148
|
+
const prices = new Array(amounts.length).fill(0n);
|
|
149
|
+
const calls = [];
|
|
150
|
+
const indices = [];
|
|
151
|
+
const decodeQuote = (raw) => {
|
|
152
|
+
const bytes = typeof raw === 'string'
|
|
153
|
+
? raw
|
|
154
|
+
: typeof raw?.returnData === 'string'
|
|
155
|
+
? raw.returnData
|
|
156
|
+
: raw;
|
|
157
|
+
const decoded = this.routerStaticInterface.decodeFunctionResult('swapExactPtForTokenStatic', bytes);
|
|
158
|
+
return BigInt(decoded[0].toString());
|
|
159
|
+
};
|
|
160
|
+
amounts.forEach((amount, idx) => {
|
|
161
|
+
if (amount === 0n) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
calls.push({
|
|
165
|
+
target: this.config.routerStaticAddress,
|
|
166
|
+
callData: this.routerStaticInterface.encodeFunctionData('swapExactPtForTokenStatic', [market.marketAddress, amount.toString(), market.underlyingAddress]),
|
|
167
|
+
decodeFunction: decodeQuote,
|
|
168
|
+
});
|
|
169
|
+
indices.push(idx);
|
|
170
|
+
});
|
|
171
|
+
if (calls.length === 0) {
|
|
172
|
+
return prices;
|
|
155
173
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
174
|
+
try {
|
|
175
|
+
const results = await this.dexHelper.multiWrapper.tryAggregate(true, calls, blockTag);
|
|
176
|
+
for (let i = 0; i < results.length; i += 1) {
|
|
177
|
+
const result = results[i];
|
|
178
|
+
if (!result.success) {
|
|
179
|
+
this.logger.error(`${this.dexKey}: router-static quote failed for ${amounts[indices[i]].toString()} PT on ${market.marketAddress}`);
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
prices[indices[i]] = result.returnData;
|
|
183
|
+
}
|
|
184
|
+
return prices;
|
|
163
185
|
}
|
|
164
|
-
|
|
165
|
-
|
|
186
|
+
catch (error) {
|
|
187
|
+
this.logger.error(`${this.dexKey}: router-static multicall failed for market ${market.marketAddress}: ${error}`);
|
|
188
|
+
return null;
|
|
166
189
|
}
|
|
167
190
|
}
|
|
168
191
|
async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
|
|
@@ -181,11 +204,15 @@ class AavePtToUnderlying extends simple_exchange_1.SimpleExchange {
|
|
|
181
204
|
return null;
|
|
182
205
|
}
|
|
183
206
|
}
|
|
184
|
-
|
|
207
|
+
if (side === constants_1.SwapSide.BUY) {
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
const unit = (0, utils_1.getBigIntPow)(srcToken.decimals);
|
|
185
211
|
const _amounts = [unit, ...amounts.slice(1)];
|
|
186
|
-
const prices = await this.
|
|
187
|
-
if (prices.length === 0)
|
|
212
|
+
const prices = await this.calculatePricesFromRouterStatic(market, _amounts, side, blockNumber);
|
|
213
|
+
if (!prices || prices.length === 0) {
|
|
188
214
|
return null;
|
|
215
|
+
}
|
|
189
216
|
return [
|
|
190
217
|
{
|
|
191
218
|
exchange: this.dexKey,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aave-pt-to-underlying.js","sourceRoot":"","sources":["../../../src/dex/aave-pt-to-underlying/aave-pt-to-underlying.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,+CAKyB;AACzB,2EAA6D;AAC7D,uCAAkE;
|
|
1
|
+
{"version":3,"file":"aave-pt-to-underlying.js","sourceRoot":"","sources":["../../../src/dex/aave-pt-to-underlying/aave-pt-to-underlying.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,+CAKyB;AACzB,2EAA6D;AAC7D,uCAAkE;AAUlE,wDAAoD;AACpD,qCAAoD;AACpD,4CAA+C;AAC/C,gGAAyE;AACzE,2CAA6E;AAG7E,MAAa,kBACX,SAAQ,gCAAc;IAiBX;IACA;IACA;IAhBF,4BAA4B,GAAG,KAAK,CAAC;IACrC,cAAc,GAAG,KAAK,CAAC;IACvB,wBAAwB,GAAG,KAAK,CAAC;IAEl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V4 Router https://etherscan.io/address/0x888888888889758f76e7103c6cbf23abbf58f946#code
|
|
6
6
|
const PENDLE_ROUTER_ADDRESS = '0x888888888889758f76e7103c6cbf23abbf58f946';
|
|
7
|
+
// Pendle Router Static https://etherscan.io/address/0x263833d47ea3fa4a30f269323aba6a107f9eb14c
|
|
8
|
+
const PENDLE_ROUTER_STATIC_ADDRESS = '0x263833d47eA3fA4a30f269323aba6a107f9eB14C';
|
|
7
9
|
// Pendle Oracle https://etherscan.io/address/0x9a9Fa8338dd5E5B2188006f1Cd2Ef26d921650C2
|
|
8
10
|
const ORACLE_ADDRESS = '0x9a9Fa8338dd5E5B2188006f1Cd2Ef26d921650C2';
|
|
9
11
|
exports.AavePtToUnderlyingConfig = {
|
|
10
12
|
AavePtToUnderlying: {
|
|
11
13
|
[constants_1.Network.MAINNET]: {
|
|
12
14
|
pendleRouterAddress: PENDLE_ROUTER_ADDRESS,
|
|
15
|
+
routerStaticAddress: PENDLE_ROUTER_STATIC_ADDRESS,
|
|
13
16
|
oracleAddress: ORACLE_ADDRESS,
|
|
14
17
|
underlyingAddresses: {
|
|
15
18
|
USDe: '0x4c9EDD5852cd905f086C759E8383e09bff1E68B3',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/aave-pt-to-underlying/config.ts"],"names":[],"mappings":";;;AAEA,+CAA0C;AAE1C,gGAAgG;AAChG,MAAM,qBAAqB,GAAG,4CAA4C,CAAC;AAC3E,wFAAwF;AACxF,MAAM,cAAc,GAAG,4CAA4C,CAAC;AAEvD,QAAA,wBAAwB,GAA4B;IAC/D,kBAAkB,EAAE;QAClB,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,mBAAmB,EAAE,qBAAqB;YAC1C,aAAa,EAAE,cAAc;YAC7B,mBAAmB,EAAE;gBACnB,IAAI,EAAE,4CAA4C;gBAClD,KAAK,EAAE,4CAA4C;aACpD;SACF;KACF;CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/aave-pt-to-underlying/config.ts"],"names":[],"mappings":";;;AAEA,+CAA0C;AAE1C,gGAAgG;AAChG,MAAM,qBAAqB,GAAG,4CAA4C,CAAC;AAC3E,+FAA+F;AAC/F,MAAM,4BAA4B,GAAG,4CAA4C,CAAC;AAClF,wFAAwF;AACxF,MAAM,cAAc,GAAG,4CAA4C,CAAC;AAEvD,QAAA,wBAAwB,GAA4B;IAC/D,kBAAkB,EAAE;QAClB,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,mBAAmB,EAAE,qBAAqB;YAC1C,mBAAmB,EAAE,4BAA4B;YACjD,aAAa,EAAE,cAAc;YAC7B,mBAAmB,EAAE;gBACnB,IAAI,EAAE,4CAA4C;gBAClD,KAAK,EAAE,4CAA4C;aACpD;SACF;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { DeepReadonly } from 'ts-essentials';
|
|
3
|
+
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
4
|
+
import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
|
|
5
|
+
import { Address, Log, Logger } from '../../types';
|
|
6
|
+
import { LogDescription } from 'ethers/lib/utils';
|
|
7
|
+
export type FactoryState = Record<string, never>;
|
|
8
|
+
export type OnPoolCreatedCallback = ({ pairAddress, blockNumber, }: {
|
|
9
|
+
pairAddress: string;
|
|
10
|
+
blockNumber: number;
|
|
11
|
+
}) => Promise<void>;
|
|
12
|
+
export declare class ApexDefiFactory extends StatefulEventSubscriber<FactoryState> {
|
|
13
|
+
readonly dexHelper: IDexHelper;
|
|
14
|
+
protected readonly factoryAddress: Address;
|
|
15
|
+
protected readonly onPoolCreated: OnPoolCreatedCallback;
|
|
16
|
+
handlers: {
|
|
17
|
+
[event: string]: (event: any, log: Readonly<Log>) => Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
logDecoder: (log: Log) => any;
|
|
20
|
+
readonly factoryIface: Interface;
|
|
21
|
+
constructor(dexHelper: IDexHelper, parentName: string, factoryAddress: Address, logger: Logger, onPoolCreated: OnPoolCreatedCallback);
|
|
22
|
+
generateState(): FactoryState;
|
|
23
|
+
protected processLog(_: DeepReadonly<FactoryState>, log: Readonly<Log>): Promise<FactoryState>;
|
|
24
|
+
handleTokenCreated(event: LogDescription, log: Readonly<Log>): Promise<void>;
|
|
25
|
+
releaseResources(): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ApexDefiFactory = void 0;
|
|
7
|
+
const abi_1 = require("@ethersproject/abi");
|
|
8
|
+
const ApexDefiFactory_abi_json_1 = __importDefault(require("../../abi/apex-defi/ApexDefiFactory.abi.json"));
|
|
9
|
+
const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
|
|
10
|
+
/*
|
|
11
|
+
* "Stateless" event subscriber in order to capture "PoolCreated" event on new pools created.
|
|
12
|
+
* State is present, but it's a placeholder to actually make the events reach handlers (if there's no previous state - `processBlockLogs` is not called)
|
|
13
|
+
*/
|
|
14
|
+
class ApexDefiFactory extends stateful_event_subscriber_1.StatefulEventSubscriber {
|
|
15
|
+
dexHelper;
|
|
16
|
+
factoryAddress;
|
|
17
|
+
onPoolCreated;
|
|
18
|
+
handlers = {};
|
|
19
|
+
logDecoder;
|
|
20
|
+
factoryIface = new abi_1.Interface(ApexDefiFactory_abi_json_1.default);
|
|
21
|
+
constructor(dexHelper, parentName, factoryAddress, logger, onPoolCreated) {
|
|
22
|
+
super(parentName, `${parentName} Factory`, dexHelper, logger);
|
|
23
|
+
this.dexHelper = dexHelper;
|
|
24
|
+
this.factoryAddress = factoryAddress;
|
|
25
|
+
this.onPoolCreated = onPoolCreated;
|
|
26
|
+
this.addressesSubscribed = [factoryAddress];
|
|
27
|
+
this.logDecoder = (log) => this.factoryIface.parseLog(log);
|
|
28
|
+
this.handlers['TokenCreated'] = this.handleTokenCreated.bind(this);
|
|
29
|
+
}
|
|
30
|
+
generateState() {
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
33
|
+
async processLog(_, log) {
|
|
34
|
+
const event = this.logDecoder(log);
|
|
35
|
+
if (event.name in this.handlers) {
|
|
36
|
+
await this.handlers[event.name](event, log);
|
|
37
|
+
}
|
|
38
|
+
return {};
|
|
39
|
+
}
|
|
40
|
+
async handleTokenCreated(event, log) {
|
|
41
|
+
const pairAddress = event.args.ammAddress.toLowerCase();
|
|
42
|
+
await this.onPoolCreated({ pairAddress, blockNumber: log.blockNumber });
|
|
43
|
+
}
|
|
44
|
+
// Add this method
|
|
45
|
+
releaseResources() {
|
|
46
|
+
// Clear handlers
|
|
47
|
+
this.handlers = {};
|
|
48
|
+
// Clear addresses subscribed
|
|
49
|
+
this.addressesSubscribed = [];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.ApexDefiFactory = ApexDefiFactory;
|
|
53
|
+
//# sourceMappingURL=apex-defi-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apex-defi-factory.js","sourceRoot":"","sources":["../../../src/dex/apex-defi/apex-defi-factory.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA+C;AAE/C,4GAA8E;AAE9E,+EAA0E;AAc1E;;;GAGG;AACH,MAAa,eAAgB,SAAQ,mDAAqC;IAU7D;IAEU;IAEA;IAbrB,QAAQ,GAEJ,EAAE,CAAC;IAEP,UAAU,CAAoB;IAEd,YAAY,GAAG,IAAI,eAAS,CAAC,kCAAkB,CAAC,CAAC;IAEjE,YACW,SAAqB,EAC9B,UAAkB,EACC,cAAuB,EAC1C,MAAc,EACK,aAAoC;QAEvD,KAAK,CAAC,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C;CACF;AAvDD,0CAuDC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { DeepReadonly } from 'ts-essentials';
|
|
3
|
+
import { Address, Log, Logger } from '../../types';
|
|
4
|
+
import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
|
|
5
|
+
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
6
|
+
import { ApexDefiPoolState } from './types';
|
|
7
|
+
import { AbiCoder } from '@ethersproject/abi';
|
|
8
|
+
export declare class ApexDefiEventPool extends StatefulEventSubscriber<ApexDefiPoolState> {
|
|
9
|
+
readonly parentName: string;
|
|
10
|
+
protected network: number;
|
|
11
|
+
protected dexHelper: IDexHelper;
|
|
12
|
+
protected apexDefiFactoryAddress: Address;
|
|
13
|
+
protected apexDefiFactoryIface: Interface;
|
|
14
|
+
protected apexDefiTokenIface: Interface;
|
|
15
|
+
handlers: {
|
|
16
|
+
[event: string]: (event: any, state: DeepReadonly<ApexDefiPoolState>, log: Readonly<Log>) => DeepReadonly<ApexDefiPoolState> | null;
|
|
17
|
+
};
|
|
18
|
+
logDecoder: (log: Log) => any;
|
|
19
|
+
coder: AbiCoder;
|
|
20
|
+
addressesSubscribed: string[];
|
|
21
|
+
readonly token0: Address;
|
|
22
|
+
readonly token1: Address;
|
|
23
|
+
private _poolAddress?;
|
|
24
|
+
constructor(parentName: string, network: number, dexHelper: IDexHelper, token0: Address, token1: Address, poolAddress: Address, logger: Logger, apexDefiFactoryAddress: Address, apexDefiFactoryIface?: Interface, apexDefiTokenIface?: Interface);
|
|
25
|
+
get poolAddress(): Address;
|
|
26
|
+
set poolAddress(address: Address);
|
|
27
|
+
/**
|
|
28
|
+
* The function is called every time any of the subscribed
|
|
29
|
+
* addresses release log. The function accepts the current
|
|
30
|
+
* state, updates the state according to the log, and returns
|
|
31
|
+
* the updated state.
|
|
32
|
+
* @param state - Current state of event subscriber
|
|
33
|
+
* @param log - Log released by one of the subscribed addresses
|
|
34
|
+
* @returns Updates state of the event subscriber after the log
|
|
35
|
+
*/
|
|
36
|
+
protected processLog(state: DeepReadonly<ApexDefiPoolState>, log: Readonly<Log>): DeepReadonly<ApexDefiPoolState> | null;
|
|
37
|
+
getStateOrGenerate(blockNumber: number): Promise<Readonly<ApexDefiPoolState>>;
|
|
38
|
+
/**
|
|
39
|
+
* The function generates state using on-chain calls. This
|
|
40
|
+
* function is called to regenerate state if the event based
|
|
41
|
+
* system fails to fetch events and the local state is no
|
|
42
|
+
* more correct.
|
|
43
|
+
* @param blockNumber - Blocknumber for which the state should
|
|
44
|
+
* should be generated
|
|
45
|
+
* @returns state of the event subscriber at blocknumber
|
|
46
|
+
*/
|
|
47
|
+
generateState(blockNumber: number): Promise<DeepReadonly<ApexDefiPoolState>>;
|
|
48
|
+
handleSwap(event: any, state: DeepReadonly<ApexDefiPoolState>, log: Readonly<Log>): DeepReadonly<ApexDefiPoolState> | null;
|
|
49
|
+
handleAddLiquidity(event: any, state: DeepReadonly<ApexDefiPoolState>, log: Readonly<Log>): DeepReadonly<ApexDefiPoolState> | null;
|
|
50
|
+
handleRemoveLiquidity(event: any, state: DeepReadonly<ApexDefiPoolState>, log: Readonly<Log>): DeepReadonly<ApexDefiPoolState> | null;
|
|
51
|
+
/**
|
|
52
|
+
* Release any resources held by this event pool
|
|
53
|
+
*/
|
|
54
|
+
releaseResources(): void;
|
|
55
|
+
}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ApexDefiEventPool = void 0;
|
|
7
|
+
const abi_1 = require("@ethersproject/abi");
|
|
8
|
+
const utils_1 = require("../../utils");
|
|
9
|
+
const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
|
|
10
|
+
const ApexDefiToken_abi_json_1 = __importDefault(require("../../abi/apex-defi/ApexDefiToken.abi.json"));
|
|
11
|
+
const ApexDefiFactory_abi_json_1 = __importDefault(require("../../abi/apex-defi/ApexDefiFactory.abi.json"));
|
|
12
|
+
const abi_2 = require("@ethersproject/abi");
|
|
13
|
+
const utils_2 = require("./utils");
|
|
14
|
+
const constants_1 = require("../../constants");
|
|
15
|
+
class ApexDefiEventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
|
|
16
|
+
parentName;
|
|
17
|
+
network;
|
|
18
|
+
dexHelper;
|
|
19
|
+
apexDefiFactoryAddress;
|
|
20
|
+
apexDefiFactoryIface;
|
|
21
|
+
apexDefiTokenIface;
|
|
22
|
+
handlers = {};
|
|
23
|
+
logDecoder;
|
|
24
|
+
coder = new abi_2.AbiCoder();
|
|
25
|
+
addressesSubscribed;
|
|
26
|
+
token0;
|
|
27
|
+
token1;
|
|
28
|
+
_poolAddress;
|
|
29
|
+
constructor(parentName, network, dexHelper, token0, token1, poolAddress, logger, apexDefiFactoryAddress, apexDefiFactoryIface = new abi_1.Interface(ApexDefiFactory_abi_json_1.default), apexDefiTokenIface = new abi_1.Interface(ApexDefiToken_abi_json_1.default)) {
|
|
30
|
+
super(parentName, poolAddress, dexHelper, logger);
|
|
31
|
+
this.parentName = parentName;
|
|
32
|
+
this.network = network;
|
|
33
|
+
this.dexHelper = dexHelper;
|
|
34
|
+
this.apexDefiFactoryAddress = apexDefiFactoryAddress;
|
|
35
|
+
this.apexDefiFactoryIface = apexDefiFactoryIface;
|
|
36
|
+
this.apexDefiTokenIface = apexDefiTokenIface;
|
|
37
|
+
this.token0 = token0.toLowerCase();
|
|
38
|
+
this.token1 = token1.toLowerCase();
|
|
39
|
+
this._poolAddress = poolAddress.toLowerCase();
|
|
40
|
+
this.logDecoder = (log) => this.apexDefiTokenIface.parseLog(log);
|
|
41
|
+
this.addressesSubscribed = new Array(1).fill(poolAddress);
|
|
42
|
+
// Add handlers
|
|
43
|
+
this.handlers['Swap'] = this.handleSwap.bind(this);
|
|
44
|
+
this.handlers['AddLiquidity'] = this.handleAddLiquidity.bind(this);
|
|
45
|
+
this.handlers['RemoveLiquidity'] = this.handleRemoveLiquidity.bind(this);
|
|
46
|
+
}
|
|
47
|
+
get poolAddress() {
|
|
48
|
+
// If the pool address is not set, compute it
|
|
49
|
+
// ApexDefi pools are always in the format of WETH/token
|
|
50
|
+
// If the token0 is WETH, then the pool address is the token1 address
|
|
51
|
+
// Otherwise, the pool address is the token0 address
|
|
52
|
+
if (this._poolAddress === undefined) {
|
|
53
|
+
if (this.token0.toLowerCase() === constants_1.ETHER_ADDRESS.toLowerCase()) {
|
|
54
|
+
this._poolAddress = this.token1;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this._poolAddress = this.token0;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return this._poolAddress;
|
|
61
|
+
}
|
|
62
|
+
set poolAddress(address) {
|
|
63
|
+
this._poolAddress = address.toLowerCase();
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The function is called every time any of the subscribed
|
|
67
|
+
* addresses release log. The function accepts the current
|
|
68
|
+
* state, updates the state according to the log, and returns
|
|
69
|
+
* the updated state.
|
|
70
|
+
* @param state - Current state of event subscriber
|
|
71
|
+
* @param log - Log released by one of the subscribed addresses
|
|
72
|
+
* @returns Updates state of the event subscriber after the log
|
|
73
|
+
*/
|
|
74
|
+
processLog(state, log) {
|
|
75
|
+
try {
|
|
76
|
+
const event = this.logDecoder(log);
|
|
77
|
+
if (event.name in this.handlers) {
|
|
78
|
+
return this.handlers[event.name](event, state, log);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
(0, utils_1.catchParseLogError)(e, this.logger);
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
async getStateOrGenerate(blockNumber) {
|
|
87
|
+
const eventState = this.getState(blockNumber);
|
|
88
|
+
if (eventState)
|
|
89
|
+
return eventState;
|
|
90
|
+
const onChainState = await this.generateState(blockNumber);
|
|
91
|
+
this.setState(onChainState, blockNumber);
|
|
92
|
+
return onChainState;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The function generates state using on-chain calls. This
|
|
96
|
+
* function is called to regenerate state if the event based
|
|
97
|
+
* system fails to fetch events and the local state is no
|
|
98
|
+
* more correct.
|
|
99
|
+
* @param blockNumber - Blocknumber for which the state should
|
|
100
|
+
* should be generated
|
|
101
|
+
* @returns state of the event subscriber at blocknumber
|
|
102
|
+
*/
|
|
103
|
+
async generateState(blockNumber) {
|
|
104
|
+
const poolData = await (0, utils_2.fetchApexDefiOnChainPoolData)(this.poolAddress, this.network, blockNumber, this.dexHelper, this.apexDefiTokenIface, this.apexDefiFactoryIface, this.logger);
|
|
105
|
+
if (!poolData) {
|
|
106
|
+
throw new Error('No pool data found');
|
|
107
|
+
}
|
|
108
|
+
const state = {
|
|
109
|
+
reserve0: (0, utils_2.toBigInt)(poolData.reserve0),
|
|
110
|
+
reserve1: (0, utils_2.toBigInt)(poolData.reserve1),
|
|
111
|
+
baseSwapRate: poolData.baseSwapRate,
|
|
112
|
+
protocolFee: poolData.protocolFee,
|
|
113
|
+
lpFee: poolData.lpFee,
|
|
114
|
+
tradingFee: poolData.tradingFee,
|
|
115
|
+
isLegacy: poolData.isLegacy,
|
|
116
|
+
tradingEnabled: poolData.tradingEnabled,
|
|
117
|
+
};
|
|
118
|
+
return state;
|
|
119
|
+
}
|
|
120
|
+
// Handle swap events to update pool state
|
|
121
|
+
handleSwap(event, state, log) {
|
|
122
|
+
try {
|
|
123
|
+
const { amountTokenIn, amountNativeIn, amountTokenOut, amountNativeOut } = event.args;
|
|
124
|
+
// Use bigIntify for safety
|
|
125
|
+
const tokenIn = (0, utils_1.bigIntify)(amountTokenIn);
|
|
126
|
+
const nativeIn = (0, utils_1.bigIntify)(amountNativeIn);
|
|
127
|
+
const tokenOut = (0, utils_1.bigIntify)(amountTokenOut);
|
|
128
|
+
const nativeOut = (0, utils_1.bigIntify)(amountNativeOut);
|
|
129
|
+
// Convert state reserves to BigInt
|
|
130
|
+
const currentReserve0 = (0, utils_2.toBigInt)(state.reserve0);
|
|
131
|
+
const currentReserve1 = (0, utils_2.toBigInt)(state.reserve1);
|
|
132
|
+
// Exact on-chain calculation trace
|
|
133
|
+
const inputAmount = tokenIn > 0n ? tokenIn : nativeIn;
|
|
134
|
+
// Step 1: Calculate trading fee (exactly like contract)
|
|
135
|
+
const tradingFees = (inputAmount * BigInt(state.tradingFee)) / 10000n;
|
|
136
|
+
// Step 2: Calculate factory fee (different for V1 vs V2)
|
|
137
|
+
let factoryFees;
|
|
138
|
+
if (state.isLegacy) {
|
|
139
|
+
// V1 token - calculate total fee and factory fee separately
|
|
140
|
+
// const totalFee = (inputAmount * BigInt(state.baseSwapRate)) / 10000n; // 30
|
|
141
|
+
factoryFees = (inputAmount * BigInt(state.protocolFee)) / 10000n; // 25
|
|
142
|
+
// const lpFees = totalFee - factoryFees; // 5
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
// V2 token - use protocol fee breakdown
|
|
146
|
+
const totalFactoryFee = (inputAmount * BigInt(state.baseSwapRate)) / 10000n;
|
|
147
|
+
const protocolFee = (totalFactoryFee * BigInt(state.protocolFee)) / 10000n;
|
|
148
|
+
// const lpFee = (totalFactoryFee * BigInt(state.lpFee)) / 10000n;
|
|
149
|
+
factoryFees = protocolFee;
|
|
150
|
+
}
|
|
151
|
+
// Step 3: Calculate total fees to set aside
|
|
152
|
+
const totalFeesToSetAside = tradingFees + factoryFees;
|
|
153
|
+
// Step 4: Calculate net amount for reserves
|
|
154
|
+
const netAmountForReserves = inputAmount - totalFeesToSetAside;
|
|
155
|
+
// Step 6: Update reserves (exactly like contract _swap function)
|
|
156
|
+
let newReserve0 = currentReserve0;
|
|
157
|
+
let newReserve1 = currentReserve1;
|
|
158
|
+
if (nativeIn > 0n) {
|
|
159
|
+
// Native to token swap
|
|
160
|
+
newReserve0 = currentReserve0 + netAmountForReserves;
|
|
161
|
+
newReserve1 = currentReserve1 - tokenOut;
|
|
162
|
+
}
|
|
163
|
+
else if (tokenIn > 0n) {
|
|
164
|
+
// Token to native swap
|
|
165
|
+
newReserve0 = currentReserve0 - nativeOut;
|
|
166
|
+
newReserve1 = currentReserve1 + netAmountForReserves;
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
...state,
|
|
170
|
+
tradingEnabled: true, // if we are here, the pool is trading
|
|
171
|
+
reserve0: newReserve0,
|
|
172
|
+
reserve1: newReserve1,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
this.logger.error('Error in handleSwap:', error);
|
|
177
|
+
this.logger.error('Error stack:', error.stack);
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// Handle AddLiquidity events to update pool state
|
|
182
|
+
handleAddLiquidity(event, state, log) {
|
|
183
|
+
try {
|
|
184
|
+
const { nativeAmount, tokenAmount } = event.args;
|
|
185
|
+
// Use bigIntify for safety
|
|
186
|
+
const nativeAdded = (0, utils_1.bigIntify)(nativeAmount);
|
|
187
|
+
const tokenAdded = (0, utils_1.bigIntify)(tokenAmount);
|
|
188
|
+
// Convert state reserves to BigInt
|
|
189
|
+
const currentReserve0 = (0, utils_2.toBigInt)(state.reserve0);
|
|
190
|
+
const currentReserve1 = (0, utils_2.toBigInt)(state.reserve1);
|
|
191
|
+
// Add liquidity to reserves
|
|
192
|
+
// Note: In ApexDefi, reserve0 is always native (AVAX) and reserve1 is always token
|
|
193
|
+
const newReserve0 = currentReserve0 + nativeAdded;
|
|
194
|
+
const newReserve1 = currentReserve1 + tokenAdded;
|
|
195
|
+
return {
|
|
196
|
+
...state,
|
|
197
|
+
reserve0: newReserve0,
|
|
198
|
+
reserve1: newReserve1,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
this.logger.error('Error in handleAddLiquidity:', error);
|
|
203
|
+
this.logger.error('Error stack:', error.stack);
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
// Handle RemoveLiquidity events to update pool state
|
|
208
|
+
handleRemoveLiquidity(event, state, log) {
|
|
209
|
+
try {
|
|
210
|
+
const { nativeAmount, tokenAmount } = event.args;
|
|
211
|
+
// Use bigIntify for safety
|
|
212
|
+
const nativeRemoved = (0, utils_1.bigIntify)(nativeAmount);
|
|
213
|
+
const tokenRemoved = (0, utils_1.bigIntify)(tokenAmount);
|
|
214
|
+
// Convert state reserves to BigInt
|
|
215
|
+
const currentReserve0 = (0, utils_2.toBigInt)(state.reserve0);
|
|
216
|
+
const currentReserve1 = (0, utils_2.toBigInt)(state.reserve1);
|
|
217
|
+
// Remove liquidity from reserves
|
|
218
|
+
// Note: In ApexDefi, reserve0 is always native (AVAX) and reserve1 is always token
|
|
219
|
+
const newReserve0 = currentReserve0 - nativeRemoved;
|
|
220
|
+
const newReserve1 = currentReserve1 - tokenRemoved;
|
|
221
|
+
// Ensure reserves don't go negative (safety check)
|
|
222
|
+
if (newReserve0 < 0n || newReserve1 < 0n) {
|
|
223
|
+
this.logger.warn('Reserves would go negative, keeping current state');
|
|
224
|
+
return state;
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
...state,
|
|
228
|
+
reserve0: newReserve0,
|
|
229
|
+
reserve1: newReserve1,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
catch (error) {
|
|
233
|
+
this.logger.error('Error in handleRemoveLiquidity:', error);
|
|
234
|
+
this.logger.error('Error stack:', error.stack);
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Release any resources held by this event pool
|
|
240
|
+
*/
|
|
241
|
+
releaseResources() {
|
|
242
|
+
// Clean up any subscriptions or timers if needed
|
|
243
|
+
this.addressesSubscribed = [];
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
exports.ApexDefiEventPool = ApexDefiEventPool;
|
|
247
|
+
//# sourceMappingURL=apex-defi-pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apex-defi-pool.js","sourceRoot":"","sources":["../../../src/dex/apex-defi/apex-defi-pool.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA+C;AAG/C,uCAA4D;AAC5D,+EAA0E;AAG1E,wGAA0E;AAC1E,4GAA8E;AAC9E,4CAA8C;AAC9C,mCAAiE;AACjE,+CAAgD;AAEhD,MAAa,iBAAkB,SAAQ,mDAA0C;IAqBpE;IACC;IACA;IAKA;IACA;IACA;IA7BZ,QAAQ,GAMJ,EAAE,CAAC;IAEP,UAAU,CAAoB;IAC9B,KAAK,GAAG,IAAI,cAAQ,EAAE,CAAC;IAEvB,mBAAmB,CAAW;IAErB,MAAM,CAAU;IAEhB,MAAM,CAAU;IAEjB,YAAY,CAAW;IAE/B,YACW,UAAkB,EACjB,OAAe,EACf,SAAqB,EAC/B,MAAe,EACf,MAAe,EACf,WAAoB,EACpB,MAAc,EACJ,sBAA+B,EAC/B,uBAAuB,IAAI,eAAS,CAAC,kCAAkB,CAAC,EACxD,qBAAqB,IAAI,eAAS,CAAC,gCAAgB,CAAC;QAE9D,KAAK,CAAC,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QAXzC,eAAU,GAAV,UAAU,CAAQ;QACjB,YAAO,GAAP,OAAO,CAAQ;QACf,cAAS,GAAT,SAAS,CAAY;QAKrB,2BAAsB,GAAtB,sBAAsB,CAAS;QAC/B,yBAAoB,GAApB,oBAAoB,CAAoC;QACxD,uBAAkB,GAAlB,kBAAkB,CAAkC;QAI9D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;QACnC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC,WAAW,E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