@paraswap/dex-lib 4.7.13 → 4.7.14-multi-route.1
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/pharaoh-v3/PharaohV3Factory.abi.json +39 -0
- package/build/abi/pharaoh-v3/PharaohV3Pool.abi.json +802 -0
- package/build/abi/pharaoh-v3/PharaohV3StateMulticall.abi.json +781 -0
- package/build/abi/uniswap-v4/hooks/arena/arena-fee-helper.abi.json +476 -0
- package/build/dex/idle-dao/idle-dao.d.ts +1 -0
- package/build/dex/idle-dao/idle-dao.js +23 -11
- package/build/dex/idle-dao/idle-dao.js.map +1 -1
- package/build/dex/{se-vlr/se-vlr-pool.d.ts → maker-psm/maker-psm-event-pool.d.ts} +15 -11
- package/build/dex/maker-psm/maker-psm-event-pool.js +132 -0
- package/build/dex/maker-psm/maker-psm-event-pool.js.map +1 -0
- package/build/dex/maker-psm/maker-psm.d.ts +4 -41
- package/build/dex/maker-psm/maker-psm.js +40 -143
- package/build/dex/maker-psm/maker-psm.js.map +1 -1
- package/build/dex/uniswap-v3/forks/pharaoh-v3/pharaoh-v3-factory.d.ts +7 -0
- package/build/dex/uniswap-v3/forks/pharaoh-v3/pharaoh-v3-factory.js +20 -0
- package/build/dex/uniswap-v3/forks/pharaoh-v3/pharaoh-v3-factory.js.map +1 -0
- package/build/dex/uniswap-v3/forks/pharaoh-v3/pharaoh-v3-pool.d.ts +12 -0
- package/build/dex/uniswap-v3/forks/pharaoh-v3/pharaoh-v3-pool.js +139 -0
- package/build/dex/uniswap-v3/forks/pharaoh-v3/pharaoh-v3-pool.js.map +1 -0
- package/build/dex/uniswap-v3/forks/pharaoh-v3/pharaoh-v3.d.ts +11 -0
- package/build/dex/uniswap-v3/forks/pharaoh-v3/pharaoh-v3.js +128 -0
- package/build/dex/uniswap-v3/forks/pharaoh-v3/pharaoh-v3.js.map +1 -0
- package/build/dex/uniswap-v3/forks/pharaoh-v3/utils.d.ts +4 -0
- package/build/dex/uniswap-v3/forks/pharaoh-v3/utils.js +56 -0
- package/build/dex/uniswap-v3/forks/pharaoh-v3/utils.js.map +1 -0
- package/build/dex/uniswap-v4/contract-math/Position.d.ts +6 -0
- package/build/dex/uniswap-v4/contract-math/Position.js +29 -0
- package/build/dex/uniswap-v4/contract-math/Position.js.map +1 -1
- package/build/dex/uniswap-v4/hooks/arena/arena-fee-helper.d.ts +36 -0
- package/build/dex/uniswap-v4/hooks/arena/arena-fee-helper.js +125 -0
- package/build/dex/uniswap-v4/hooks/arena/arena-fee-helper.js.map +1 -0
- package/build/dex/uniswap-v4/hooks/arena/arena-hook.d.ts +21 -0
- package/build/dex/uniswap-v4/hooks/arena/arena-hook.js +93 -0
- package/build/dex/uniswap-v4/hooks/arena/arena-hook.js.map +1 -0
- package/build/dex/uniswap-v4/hooks/arena/config.d.ts +3 -0
- package/build/dex/uniswap-v4/hooks/arena/config.js +11 -0
- package/build/dex/uniswap-v4/hooks/arena/config.js.map +1 -0
- package/build/dex/uniswap-v4/hooks/arena/types.d.ts +5 -0
- package/build/dex/uniswap-v4/hooks/arena/types.js.map +1 -0
- package/build/dex/uniswap-v4/hooks/types.d.ts +60 -0
- package/build/dex/uniswap-v4/hooks/types.js.map +1 -0
- package/build/executor/Executor01BytecodeBuilder.d.ts +5 -5
- package/build/executor/Executor01BytecodeBuilder.js +17 -14
- package/build/executor/Executor01BytecodeBuilder.js.map +1 -1
- package/build/executor/Executor02BytecodeBuilder.d.ts +11 -8
- package/build/executor/Executor02BytecodeBuilder.js +107 -103
- package/build/executor/Executor02BytecodeBuilder.js.map +1 -1
- package/build/executor/Executor03BytecodeBuilder.d.ts +5 -5
- package/build/executor/Executor03BytecodeBuilder.js +14 -11
- package/build/executor/Executor03BytecodeBuilder.js.map +1 -1
- package/build/executor/ExecutorBytecodeBuilder.d.ts +8 -8
- package/build/executor/ExecutorBytecodeBuilder.js +8 -8
- package/build/executor/ExecutorBytecodeBuilder.js.map +1 -1
- package/build/executor/WETHBytecodeBuilder.d.ts +2 -2
- package/build/executor/WETHBytecodeBuilder.js +1 -1
- package/build/executor/WETHBytecodeBuilder.js.map +1 -1
- package/build/executor/types.d.ts +21 -0
- package/build/executor/types.js.map +1 -1
- package/build/executor/utils.d.ts +20 -0
- package/build/executor/utils.js +129 -0
- package/build/executor/utils.js.map +1 -1
- package/build/generic-swap-transaction-builder.d.ts +4 -0
- package/build/generic-swap-transaction-builder.js +134 -52
- package/build/generic-swap-transaction-builder.js.map +1 -1
- package/package.json +12 -3
- package/build/abi/BProtocol.json +0 -1155
- package/build/abi/Jarvis.json +0 -1172
- package/build/abi/MStableAsset.json +0 -1545
- package/build/abi/OneInchLp.json +0 -1304
- package/build/abi/Onebit.json +0 -736
- package/build/abi/Shell.json +0 -1294
- package/build/abi/TraderJoeV2Router.json +0 -50
- package/build/abi/wUSDM.json +0 -757
- package/build/abi/zrx.v2.json +0 -1967
- package/build/abi/zrx.v3.json +0 -3454
- package/build/abi/zrx.v4.json +0 -2193
- package/build/dex/OneInchLp.d.ts +0 -24
- package/build/dex/OneInchLp.js +0 -43
- package/build/dex/OneInchLp.js.map +0 -1
- package/build/dex/bProtocol/bProtocol.d.ts +0 -15
- package/build/dex/bProtocol/bProtocol.js +0 -56
- package/build/dex/bProtocol/bProtocol.js.map +0 -1
- package/build/dex/bProtocol/types.d.ts +0 -11
- package/build/dex/bProtocol/types.js +0 -8
- package/build/dex/bProtocol/types.js.map +0 -1
- package/build/dex/jarvis.d.ts +0 -56
- package/build/dex/jarvis.js +0 -163
- package/build/dex/jarvis.js.map +0 -1
- package/build/dex/mStable.d.ts +0 -44
- package/build/dex/mStable.js +0 -75
- package/build/dex/mStable.js.map +0 -1
- package/build/dex/onebit/onebit.d.ts +0 -16
- package/build/dex/onebit/onebit.js +0 -61
- package/build/dex/onebit/onebit.js.map +0 -1
- package/build/dex/onebit/types.d.ts +0 -14
- package/build/dex/onebit/types.js +0 -8
- package/build/dex/onebit/types.js.map +0 -1
- package/build/dex/se-vlr/config.d.ts +0 -3
- package/build/dex/se-vlr/config.js +0 -24
- package/build/dex/se-vlr/config.js.map +0 -1
- package/build/dex/se-vlr/se-vlr-pool.js +0 -70
- package/build/dex/se-vlr/se-vlr-pool.js.map +0 -1
- package/build/dex/se-vlr/se-vlr.d.ts +0 -35
- package/build/dex/se-vlr/se-vlr.js +0 -131
- package/build/dex/se-vlr/se-vlr.js.map +0 -1
- package/build/dex/se-vlr/types.d.ts +0 -6
- package/build/dex/se-vlr/types.js.map +0 -1
- package/build/dex/shell.d.ts +0 -25
- package/build/dex/shell.js +0 -41
- package/build/dex/shell.js.map +0 -1
- package/build/dex/trader-joe-v2.d.ts +0 -40
- package/build/dex/trader-joe-v2.js +0 -74
- package/build/dex/trader-joe-v2.js.map +0 -1
- package/build/dex/uniswap-v3/uniswap-v3-new.d.ts +0 -94
- package/build/dex/uniswap-v3/uniswap-v3-new.js +0 -923
- package/build/dex/uniswap-v3/uniswap-v3-new.js.map +0 -1
- package/build/dex/usual-bond/config.d.ts +0 -3
- package/build/dex/usual-bond/config.js +0 -13
- package/build/dex/usual-bond/config.js.map +0 -1
- package/build/dex/usual-bond/types.d.ts +0 -7
- package/build/dex/usual-bond/types.js.map +0 -1
- package/build/dex/usual-bond/usual-bond.d.ts +0 -35
- package/build/dex/usual-bond/usual-bond.js +0 -176
- package/build/dex/usual-bond/usual-bond.js.map +0 -1
- package/build/dex/wusdm/config.d.ts +0 -3
- package/build/dex/wusdm/config.js +0 -43
- package/build/dex/wusdm/config.js.map +0 -1
- package/build/dex/wusdm/constants.d.ts +0 -2
- package/build/dex/wusdm/constants.js +0 -6
- package/build/dex/wusdm/constants.js.map +0 -1
- package/build/dex/wusdm/types.d.ts +0 -18
- package/build/dex/wusdm/types.js +0 -11
- package/build/dex/wusdm/types.js.map +0 -1
- package/build/dex/wusdm/wusdm-pool.d.ts +0 -21
- package/build/dex/wusdm/wusdm-pool.js +0 -74
- package/build/dex/wusdm/wusdm-pool.js.map +0 -1
- package/build/dex/wusdm/wusdm.d.ts +0 -46
- package/build/dex/wusdm/wusdm.js +0 -243
- package/build/dex/wusdm/wusdm.js.map +0 -1
- package/build/dex/zerox/config.d.ts +0 -2
- package/build/dex/zerox/config.js +0 -33
- package/build/dex/zerox/config.js.map +0 -1
- package/build/dex/zerox/index.d.ts +0 -22
- package/build/dex/zerox/index.js +0 -225
- package/build/dex/zerox/index.js.map +0 -1
- package/build/dex/zerox/order.d.ts +0 -88
- package/build/dex/zerox/order.js +0 -53
- package/build/dex/zerox/order.js.map +0 -1
- package/build/dex/zerox/types.d.ts +0 -73
- package/build/dex/zerox/types.js +0 -21
- package/build/dex/zerox/types.js.map +0 -1
- /package/build/dex/{se-vlr → uniswap-v4/hooks/arena}/types.js +0 -0
- /package/build/dex/{usual-bond → uniswap-v4/hooks}/types.js +0 -0
|
@@ -0,0 +1,139 @@
|
|
|
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.PharaohV3EventPool = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const velodrome_slipstream_pool_1 = require("../velodrome-slipstream/velodrome-slipstream-pool");
|
|
9
|
+
const decoders_1 = require("../../../../lib/decoders");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
const abi_1 = require("@ethersproject/abi");
|
|
12
|
+
const PharaohV3Pool_abi_json_1 = __importDefault(require("../../../../abi/pharaoh-v3/PharaohV3Pool.abi.json"));
|
|
13
|
+
const PharaohV3Factory_abi_json_1 = __importDefault(require("../../../../abi/pharaoh-v3/PharaohV3Factory.abi.json"));
|
|
14
|
+
const ts_essentials_1 = require("ts-essentials");
|
|
15
|
+
const utils_2 = require("../../contract-math/utils");
|
|
16
|
+
const TickBitMap_1 = require("../../contract-math/TickBitMap");
|
|
17
|
+
const utils_3 = require("../../../../utils");
|
|
18
|
+
const PHARAOH_V3_POOL_INIT_CODE_HASH = '0x892f127ed4b26ca352056c8fb54585a3268f76f97fdd84d5836ef4bda8d8c685';
|
|
19
|
+
class PharaohV3EventPool extends velodrome_slipstream_pool_1.VelodromeSlipstreamEventPool {
|
|
20
|
+
poolIface = new abi_1.Interface(PharaohV3Pool_abi_json_1.default);
|
|
21
|
+
factoryIface = new abi_1.Interface(PharaohV3Factory_abi_json_1.default);
|
|
22
|
+
async getCurrentFee(blockNumber) {
|
|
23
|
+
try {
|
|
24
|
+
const [result] = await this.dexHelper.multiWrapper.tryAggregate(false, [
|
|
25
|
+
{
|
|
26
|
+
target: this.poolAddress,
|
|
27
|
+
callData: this.poolIface.encodeFunctionData('fee', []),
|
|
28
|
+
decodeFunction: decoders_1.uint24ToBigInt,
|
|
29
|
+
},
|
|
30
|
+
], blockNumber);
|
|
31
|
+
if (result.success) {
|
|
32
|
+
return result.returnData;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
this.logger.error(`PharaohV3: Failed to fetch fee for pool ${this.poolAddress}:`, error);
|
|
37
|
+
}
|
|
38
|
+
return this.feeCode;
|
|
39
|
+
}
|
|
40
|
+
_getStateRequestCallData() {
|
|
41
|
+
if (!this._stateRequestCallData) {
|
|
42
|
+
const callData = [
|
|
43
|
+
{
|
|
44
|
+
target: this.token0,
|
|
45
|
+
callData: this.erc20Interface.encodeFunctionData('balanceOf', [
|
|
46
|
+
this.poolAddress,
|
|
47
|
+
]),
|
|
48
|
+
decodeFunction: decoders_1.uint256ToBigInt,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
target: this.token1,
|
|
52
|
+
callData: this.erc20Interface.encodeFunctionData('balanceOf', [
|
|
53
|
+
this.poolAddress,
|
|
54
|
+
]),
|
|
55
|
+
decodeFunction: decoders_1.uint256ToBigInt,
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
target: this.poolAddress,
|
|
59
|
+
callData: this.poolIface.encodeFunctionData('fee', []),
|
|
60
|
+
decodeFunction: decoders_1.uint24ToBigInt,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
target: this.stateMultiContract.options.address,
|
|
64
|
+
callData: this.stateMultiContract.methods
|
|
65
|
+
.getFullStateWithRelativeBitmaps(this.factoryAddress, this.token0, this.token1, this.tickSpacing, this.getBitmapRangeToRequest(), this.getBitmapRangeToRequest())
|
|
66
|
+
.encodeABI(),
|
|
67
|
+
decodeFunction: this.decodeStateMultiCallResultWithRelativeBitmaps !== undefined
|
|
68
|
+
? this.decodeStateMultiCallResultWithRelativeBitmaps
|
|
69
|
+
: utils_1.decodeStateMultiCallResultWithRelativeBitmaps,
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
this._stateRequestCallData = callData;
|
|
73
|
+
}
|
|
74
|
+
return this._stateRequestCallData;
|
|
75
|
+
}
|
|
76
|
+
async generateState(blockNumber) {
|
|
77
|
+
const callData = this._getStateRequestCallData();
|
|
78
|
+
const [resBalance0, resBalance1, resSwapFee, resState] = await this.dexHelper.multiWrapper.tryAggregate(false, callData, blockNumber, this.dexHelper.multiWrapper.defaultBatchSize, false);
|
|
79
|
+
(0, ts_essentials_1.assert)(resState.success, 'Pool does not exist');
|
|
80
|
+
const [balance0, balance1, fee, _state] = [
|
|
81
|
+
resBalance0.returnData,
|
|
82
|
+
resBalance1.returnData,
|
|
83
|
+
resSwapFee.returnData,
|
|
84
|
+
resState.returnData,
|
|
85
|
+
];
|
|
86
|
+
this._assertActivePool(_state);
|
|
87
|
+
const tickBitmap = {};
|
|
88
|
+
const ticks = {};
|
|
89
|
+
(0, utils_2._reduceTickBitmap)(tickBitmap, _state.tickBitmap);
|
|
90
|
+
(0, utils_2._reduceTicks)(ticks, _state.ticks);
|
|
91
|
+
const observations = {
|
|
92
|
+
[_state.slot0.observationIndex]: {
|
|
93
|
+
blockTimestamp: (0, utils_3.bigIntify)(_state.observation.blockTimestamp),
|
|
94
|
+
tickCumulative: (0, utils_3.bigIntify)(_state.observation.tickCumulative),
|
|
95
|
+
secondsPerLiquidityCumulativeX128: (0, utils_3.bigIntify)(_state.observation.secondsPerLiquidityCumulativeX128),
|
|
96
|
+
initialized: _state.observation.initialized,
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
const currentTick = (0, utils_3.bigIntify)(_state.slot0.tick);
|
|
100
|
+
const tickSpacing = (0, utils_3.bigIntify)(_state.tickSpacing);
|
|
101
|
+
const startTickBitmap = TickBitMap_1.TickBitMap.position(currentTick / tickSpacing)[0];
|
|
102
|
+
const requestedRange = this.getBitmapRangeToRequest();
|
|
103
|
+
return {
|
|
104
|
+
networkId: this.dexHelper.config.data.network,
|
|
105
|
+
pool: _state.pool,
|
|
106
|
+
fee,
|
|
107
|
+
blockTimestamp: (0, utils_3.bigIntify)(_state.blockTimestamp),
|
|
108
|
+
slot0: {
|
|
109
|
+
sqrtPriceX96: (0, utils_3.bigIntify)(_state.slot0.sqrtPriceX96),
|
|
110
|
+
tick: currentTick,
|
|
111
|
+
observationIndex: +_state.slot0.observationIndex,
|
|
112
|
+
observationCardinality: +_state.slot0.observationCardinality,
|
|
113
|
+
observationCardinalityNext: +_state.slot0.observationCardinalityNext,
|
|
114
|
+
feeProtocol: (0, utils_3.bigIntify)(_state.slot0.feeProtocol),
|
|
115
|
+
},
|
|
116
|
+
liquidity: (0, utils_3.bigIntify)(_state.liquidity),
|
|
117
|
+
tickSpacing,
|
|
118
|
+
maxLiquidityPerTick: (0, utils_3.bigIntify)(_state.maxLiquidityPerTick),
|
|
119
|
+
tickBitmap,
|
|
120
|
+
ticks,
|
|
121
|
+
observations,
|
|
122
|
+
isValid: true,
|
|
123
|
+
startTickBitmap,
|
|
124
|
+
lowestKnownTick: (BigInt.asIntN(24, startTickBitmap - requestedRange) << 8n) *
|
|
125
|
+
tickSpacing,
|
|
126
|
+
highestKnownTick: ((BigInt.asIntN(24, startTickBitmap + requestedRange) << 8n) +
|
|
127
|
+
BigInt.asIntN(24, 255n)) *
|
|
128
|
+
tickSpacing,
|
|
129
|
+
balance0,
|
|
130
|
+
balance1,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
predictDeterministicAddress(factory, implementation, salt) {
|
|
134
|
+
const address = ethers_1.ethers.utils.getCreate2Address(this.deployer ?? '', salt, PHARAOH_V3_POOL_INIT_CODE_HASH);
|
|
135
|
+
return address;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.PharaohV3EventPool = PharaohV3EventPool;
|
|
139
|
+
//# sourceMappingURL=pharaoh-v3-pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pharaoh-v3-pool.js","sourceRoot":"","sources":["../../../../../src/dex/uniswap-v3/forks/pharaoh-v3/pharaoh-v3-pool.ts"],"names":[],"mappings":";;;;;;AAAA,mCAAgC;AAChC,iGAAiG;AAOjG,uDAA2E;AAC3E,mCAAwE;AACxE,4CAA+C;AAC/C,+GAAiF;AACjF,qHAAuF;AACvF,iDAAuC;AACvC,qDAA4E;AAC5E,+DAA4D;AAC5D,6CAA8C;AAE9C,MAAM,8BAA8B,GAClC,oEAAoE,CAAC;AAEvE,MAAa,kBAAmB,SAAQ,wDAA4B;IAClD,SAAS,GAAG,IAAI,eAAS,CAAC,gCAAgB,CAAC,CAAC;IAC5C,YAAY,GAAG,IAAI,eAAS,CAAC,mCAAmB,CAAC,CAAC;IAExD,KAAK,CAAC,aAAa,CAAC,WAAmB;QAC/C,IAAI,CAAC;YACH,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,YAAY,CAC7D,KAAK,EACL;gBACE;oBACE,MAAM,EAAE,IAAI,CAAC,WAAW;oBACxB,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,KAAK,EAAE,EAAE,CAAC;oBACtD,cAAc,EAAE,yBAAc;iBAC/B;aACF,EACD,WAAW,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AAA,iBAAS,EAAC,MAAM,CAAC,mBAAmB,CAAC;YAC1D,UAAU;YACV,KAAK;YACL,YAAY;YACZ,OAAO,EAAE,IAAI;YACb,eAAe;YACf,eAAe,EACb,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,eAAe,GAAG,cAAc,CAAC,IAAI,EAAE,CAAC;gBAC3D,WAAW;YACb,gBAAgB,EACd,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,eAAe,GAAG,cAAc,CAAC,IAAI,EAAE,CAAC;gBAC1D,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;gBAC1B,WAAW;YACb,QAAQ;YACR,QAAQ;SACT,CAAC;IACJ,CAAC;IAES,2BAA2B,CACnC,OAAe,EACf,cAAsB,EACtB,IAAY;QAEZ,MAAM,OAAO,GAAG,eAAM,CAAC,KAAK,CAAC,iBAAiB,CAC5C,IAAI,CAAC,QAAQ,IAAI,EAAE,EACnB,IAAI,EACJ,8BAA8B,CACpB,CAAC;QAEb,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAjLD,gDAiLC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Network } from '../../../../constants';
|
|
2
|
+
import { VelodromeSlipstream } from '../velodrome-slipstream/velodrome-slipstream';
|
|
3
|
+
import { Address } from '@paraswap/core';
|
|
4
|
+
import { PoolLiquidity } from '../../../../types';
|
|
5
|
+
export declare class PharaohV3 extends VelodromeSlipstream {
|
|
6
|
+
static dexKeysWithNetwork: {
|
|
7
|
+
key: string;
|
|
8
|
+
networks: Network[];
|
|
9
|
+
}[];
|
|
10
|
+
getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
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.PharaohV3 = void 0;
|
|
7
|
+
const config_1 = require("../../config");
|
|
8
|
+
const utils_1 = require("../../../../utils");
|
|
9
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
10
|
+
const velodrome_slipstream_1 = require("../velodrome-slipstream/velodrome-slipstream");
|
|
11
|
+
const constants_1 = require("../../constants");
|
|
12
|
+
class PharaohV3 extends velodrome_slipstream_1.VelodromeSlipstream {
|
|
13
|
+
static dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(lodash_1.default.pick(config_1.UniswapV3Config, ['PharaohV3']));
|
|
14
|
+
async getTopPoolsForToken(tokenAddress, limit) {
|
|
15
|
+
if (!this.config.subgraphURL)
|
|
16
|
+
return [];
|
|
17
|
+
const _tokenAddress = tokenAddress.toLowerCase();
|
|
18
|
+
const res = await this._querySubgraph(`query ($token: Bytes!, $count: Int) {
|
|
19
|
+
pools0: clPools(
|
|
20
|
+
orderBy: totalValueLockedToken0
|
|
21
|
+
orderDirection: desc
|
|
22
|
+
first: $count
|
|
23
|
+
skip: 0
|
|
24
|
+
where: { token0: $token }
|
|
25
|
+
) {
|
|
26
|
+
id
|
|
27
|
+
token0 {
|
|
28
|
+
id
|
|
29
|
+
decimals
|
|
30
|
+
}
|
|
31
|
+
token1 {
|
|
32
|
+
id
|
|
33
|
+
decimals
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
pools1: clPools(
|
|
38
|
+
orderBy: totalValueLockedToken1
|
|
39
|
+
orderDirection: desc
|
|
40
|
+
first: $count
|
|
41
|
+
skip: 0
|
|
42
|
+
where: { token1: $token }
|
|
43
|
+
) {
|
|
44
|
+
id
|
|
45
|
+
token0 {
|
|
46
|
+
id
|
|
47
|
+
decimals
|
|
48
|
+
}
|
|
49
|
+
token1 {
|
|
50
|
+
id
|
|
51
|
+
decimals
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}`, {
|
|
55
|
+
token: _tokenAddress,
|
|
56
|
+
count: limit,
|
|
57
|
+
});
|
|
58
|
+
if (!(res && res.pools0 && res.pools1)) {
|
|
59
|
+
this.logger.error(`Error_${this.dexKey}_Subgraph: couldn't fetch pools from subgraph`);
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
const pools0 = res.pools0.map((pool) => ({
|
|
63
|
+
exchange: this.dexKey,
|
|
64
|
+
address: pool.id.toLowerCase(),
|
|
65
|
+
connectorTokens: [
|
|
66
|
+
{
|
|
67
|
+
address: pool.token1.id.toLowerCase(),
|
|
68
|
+
decimals: Number(pool.token1.decimals),
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
liquidityUSD: 0,
|
|
72
|
+
}));
|
|
73
|
+
const pools1 = res.pools1.map((pool) => ({
|
|
74
|
+
exchange: this.dexKey,
|
|
75
|
+
address: pool.id.toLowerCase(),
|
|
76
|
+
connectorTokens: [
|
|
77
|
+
{
|
|
78
|
+
address: pool.token0.id.toLowerCase(),
|
|
79
|
+
decimals: Number(pool.token0.decimals),
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
liquidityUSD: 0,
|
|
83
|
+
}));
|
|
84
|
+
const allPools = [...pools0, ...pools1];
|
|
85
|
+
if (allPools.length === 0)
|
|
86
|
+
return [];
|
|
87
|
+
const poolBalances = await this._getPoolBalances(allPools.map(p => [
|
|
88
|
+
p.address,
|
|
89
|
+
tokenAddress,
|
|
90
|
+
p.connectorTokens[0].address,
|
|
91
|
+
]));
|
|
92
|
+
const tokensAmounts = allPools
|
|
93
|
+
.map((p, i) => {
|
|
94
|
+
return [
|
|
95
|
+
[tokenAddress, poolBalances[i][0]],
|
|
96
|
+
[p.connectorTokens[0].address, poolBalances[i][1]],
|
|
97
|
+
];
|
|
98
|
+
})
|
|
99
|
+
.flat();
|
|
100
|
+
const poolUsdBalances = await this.dexHelper.getUsdTokenAmounts(tokensAmounts);
|
|
101
|
+
const pools = allPools.map((pool, i) => {
|
|
102
|
+
const tokenUsdBalance = poolUsdBalances[i * 2];
|
|
103
|
+
const connectorTokenUsdBalance = poolUsdBalances[i * 2 + 1];
|
|
104
|
+
const tokenUsdLiquidity = tokenUsdBalance
|
|
105
|
+
? tokenUsdBalance * constants_1.UNISWAPV3_EFFICIENCY_FACTOR
|
|
106
|
+
: null;
|
|
107
|
+
const connectorTokenUsdLiquidity = connectorTokenUsdBalance
|
|
108
|
+
? connectorTokenUsdBalance * constants_1.UNISWAPV3_EFFICIENCY_FACTOR
|
|
109
|
+
: null;
|
|
110
|
+
if (tokenUsdLiquidity) {
|
|
111
|
+
pool.connectorTokens[0] = {
|
|
112
|
+
...pool.connectorTokens[0],
|
|
113
|
+
liquidityUSD: tokenUsdLiquidity,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
const liquidityUSD = connectorTokenUsdLiquidity || tokenUsdLiquidity || 0;
|
|
117
|
+
return {
|
|
118
|
+
...pool,
|
|
119
|
+
liquidityUSD,
|
|
120
|
+
};
|
|
121
|
+
});
|
|
122
|
+
return pools
|
|
123
|
+
.sort((a, b) => b.liquidityUSD - a.liquidityUSD)
|
|
124
|
+
.slice(0, limit);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.PharaohV3 = PharaohV3;
|
|
128
|
+
//# sourceMappingURL=pharaoh-v3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pharaoh-v3.js","sourceRoot":"","sources":["../../../../../src/dex/uniswap-v3/forks/pharaoh-v3/pharaoh-v3.ts"],"names":[],"mappings":";;;;;;AACA,yCAA+C;AAC/C,6CAA0D;AAC1D,oDAAuB;AACvB,uFAAmF;AAGnF,+CAA8D;AAkB9D,MAAa,SAAU,SAAQ,0CAAmB;IACzC,MAAM,CAAC,kBAAkB,GAC9B,IAAA,6BAAqB,EAAC,gBAAC,CAAC,IAAI,CAAC,wBAAe,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAA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,eAAe,GAAG,uCAA2B;gBAC/C,CAAC,CAAC,IAAI,CAAC;YAET,MAAM,0BAA0B,GAAG,wBAAwB;gBACzD,CAAC,CAAC,wBAAwB,GAAG,uCAA2B;gBACxD,CAAC,CAAC,IAAI,CAAC;YAET,IAAI,iBAAiB,EAAE,CAAC;gBACtB,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG;oBACxB,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;oBAC1B,YAAY,EAAE,iBAAiB;iBAChC,CAAC;YACJ,CAAC;YAED,MAAM,YAAY,GAAG,0BAA0B,IAAI,iBAAiB,IAAI,CAAC,CAAC;YAE1E,OAAO;gBACL,GAAG,IAAI;gBACP,YAAY;aACb,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,KAAK;aACT,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,GAAG,CAAC,CAAC,YAAY,CAAC;aAC/C,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACrB,CAAC;;AA9IH,8BA+IC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { MultiResult } from '../../../../lib/multi-wrapper';
|
|
2
|
+
import { BytesLike } from 'ethers';
|
|
3
|
+
import { DecodedStateMultiCallResultWithRelativeBitmaps } from '../../types';
|
|
4
|
+
export declare function decodeStateMultiCallResultWithRelativeBitmaps(result: MultiResult<BytesLike> | BytesLike): DecodedStateMultiCallResultWithRelativeBitmaps;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decodeStateMultiCallResultWithRelativeBitmaps = decodeStateMultiCallResultWithRelativeBitmaps;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const decoders_1 = require("../../../../lib/decoders");
|
|
6
|
+
const ts_essentials_1 = require("ts-essentials");
|
|
7
|
+
function decodeStateMultiCallResultWithRelativeBitmaps(result) {
|
|
8
|
+
const [isSuccess, toDecode] = (0, decoders_1.extractSuccessAndValue)(result);
|
|
9
|
+
(0, ts_essentials_1.assert)(isSuccess && toDecode !== '0x', `decodeStateMultiCallResultWithRelativeBitmaps failed to get decodable result: ${result}`);
|
|
10
|
+
const decoded = ethers_1.ethers.utils.defaultAbiCoder.decode([
|
|
11
|
+
// I don't want to pass here any interface, so I just use it in ethers format
|
|
12
|
+
`
|
|
13
|
+
tuple(
|
|
14
|
+
address pool,
|
|
15
|
+
uint256 blockTimestamp,
|
|
16
|
+
tuple(
|
|
17
|
+
uint160 sqrtPriceX96,
|
|
18
|
+
int24 tick,
|
|
19
|
+
uint16 observationIndex,
|
|
20
|
+
uint16 observationCardinality,
|
|
21
|
+
uint16 observationCardinalityNext,
|
|
22
|
+
uint24 feeProtocol,
|
|
23
|
+
bool unlocked,
|
|
24
|
+
) slot0,
|
|
25
|
+
uint128 liquidity,
|
|
26
|
+
int24 tickSpacing,
|
|
27
|
+
uint128 maxLiquidityPerTick,
|
|
28
|
+
tuple(
|
|
29
|
+
uint32 blockTimestamp,
|
|
30
|
+
int56 tickCumulative,
|
|
31
|
+
uint160 secondsPerLiquidityCumulativeX128,
|
|
32
|
+
bool initialized,
|
|
33
|
+
) observation,
|
|
34
|
+
tuple(
|
|
35
|
+
int16 index,
|
|
36
|
+
uint256 value
|
|
37
|
+
)[] tickBitmap,
|
|
38
|
+
tuple(
|
|
39
|
+
int24 index,
|
|
40
|
+
tuple(
|
|
41
|
+
uint128 liquidityGross,
|
|
42
|
+
int128 liquidityNet,
|
|
43
|
+
int56 tickCumulativeOutside,
|
|
44
|
+
uint160 secondsPerLiquidityOutsideX128,
|
|
45
|
+
uint32 secondsOutside,
|
|
46
|
+
bool initialized,
|
|
47
|
+
) value,
|
|
48
|
+
)[] ticks
|
|
49
|
+
)
|
|
50
|
+
`,
|
|
51
|
+
], toDecode)[0];
|
|
52
|
+
// This conversion is not precise, because when we decode, we have more values
|
|
53
|
+
// But I typed only the ones that are used later
|
|
54
|
+
return decoded;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../src/dex/uniswap-v3/forks/pharaoh-v3/utils.ts"],"names":[],"mappings":";;AAMA,sGA2DC;AAhED,mCAA2C;AAE3C,uDAAkE;AAClE,iDAAuC;AAEvC,SAAgB,6CAA6C,CAC3D,MAA0C;IAE1C,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,IAAA,iCAAsB,EAAC,MAAM,CAAC,CAAC;IAE7D,IAAA,sBAAM,EACJ,SAAS,IAAI,QAAQ,KAAK,IAAI,EAC9B,iFAAiF,MAAM,EAAE,CAC1F,CAAC;IAEF,MAAM,OAAO,GAAG,eAAM,CAAC,KAAK,CAAC,eAAe,CAAC,MAAM,CACjD;QACE,6EAA6E;QAC7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsCD;KACA,EACD,QAAQ,CACT,CAAC,CAAC,CAAC,CAAC;IAEL,8EAA8E;IAC9E,gDAAgD;IAChD,OAAO,OAAyD,CAAC;AACnE,CAAC"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { PoolState, PositionState } from '../types';
|
|
1
2
|
export declare class Position {
|
|
2
3
|
static calculatePositionKey(owner: string, tickLower: bigint, tickUpper: bigint, salt: string): string;
|
|
4
|
+
static get(poolState: PoolState, owner: string, tickLower: bigint, tickUpper: bigint, salt: string): PositionState | undefined;
|
|
5
|
+
static update(poolState: PoolState, owner: string, tickLower: bigint, tickUpper: bigint, salt: string, liquidityDelta: bigint, feeGrowthInside0X128: bigint, feeGrowthInside1X128: bigint): {
|
|
6
|
+
feesOwed0: bigint;
|
|
7
|
+
feesOwed1: bigint;
|
|
8
|
+
};
|
|
3
9
|
}
|
|
@@ -1,10 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Position = void 0;
|
|
4
|
+
const utils_1 = require("../../../utils");
|
|
4
5
|
class Position {
|
|
5
6
|
static calculatePositionKey(owner, tickLower, tickUpper, salt) {
|
|
6
7
|
return `${owner}-${tickLower.toString()}-${tickUpper.toString()}-${salt}`;
|
|
7
8
|
}
|
|
9
|
+
static get(poolState, owner, tickLower, tickUpper, salt) {
|
|
10
|
+
const positionKey = Position.calculatePositionKey(owner, tickLower, tickUpper, salt);
|
|
11
|
+
return poolState.positions[positionKey];
|
|
12
|
+
}
|
|
13
|
+
static update(poolState, owner, tickLower, tickUpper, salt, liquidityDelta, feeGrowthInside0X128, feeGrowthInside1X128) {
|
|
14
|
+
const positionKey = Position.calculatePositionKey(owner, tickLower, tickUpper, salt);
|
|
15
|
+
let position = poolState.positions[positionKey];
|
|
16
|
+
(0, utils_1._require)(Boolean(position), 'Position does not exist', { position });
|
|
17
|
+
let { liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128 } = position;
|
|
18
|
+
if (liquidityDelta === 0n) {
|
|
19
|
+
(0, utils_1._require)(liquidity !== 0n, 'Cannot update empty position', {
|
|
20
|
+
liquidityDelta,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
liquidity += liquidityDelta;
|
|
25
|
+
}
|
|
26
|
+
const feesOwed0 = ((feeGrowthInside0X128 - feeGrowthInside0LastX128) * liquidity) /
|
|
27
|
+
BigInt(1 << 128);
|
|
28
|
+
const feesOwed1 = ((feeGrowthInside1X128 - feeGrowthInside1LastX128) * liquidity) /
|
|
29
|
+
BigInt(1 << 128);
|
|
30
|
+
poolState.positions[positionKey] = {
|
|
31
|
+
liquidity,
|
|
32
|
+
feeGrowthInside0LastX128: feeGrowthInside0X128,
|
|
33
|
+
feeGrowthInside1LastX128: feeGrowthInside1X128,
|
|
34
|
+
};
|
|
35
|
+
return { feesOwed0, feesOwed1 };
|
|
36
|
+
}
|
|
8
37
|
}
|
|
9
38
|
exports.Position = Position;
|
|
10
39
|
//# sourceMappingURL=Position.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Position.js","sourceRoot":"","sources":["../../../../src/dex/uniswap-v4/contract-math/Position.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Position.js","sourceRoot":"","sources":["../../../../src/dex/uniswap-v4/contract-math/Position.ts"],"names":[],"mappings":";;;AACA,0CAA0C;AAE1C,MAAa,QAAQ;IACZ,MAAM,CAAC,oBAAoB,CAChC,KAAa,EACb,SAAiB,EACjB,SAAiB,EACjB,IAAY;QAEZ,OAAO,GAAG,KAAK,IAAI,SAAS,CAAC,QAAQ,EAAE,IAAI,SAAS,CAAC,QAAQ,EAAE,IAAI,IAAI,EAAE,CAAC;IAC5E,CAAC;IAED,MAAM,CAAC,GAAG,CACR,SAAoB,EACpB,KAAa,EACb,SAAiB,EACjB,SAAiB,EACjB,IAAY;QAEZ,MAAM,WAAW,GAAG,QAAQ,CAAC,oBAAoB,CAC/C,KAAK,EACL,SAAS,EACT,SAAS,EACT,IAAI,CACL,CAAC;QAEF,OAAO,SAAS,CAAC,SAAU,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,CAAC,MAAM,CACX,SAAoB,EACpB,KAAa,EACb,SAAiB,EACjB,SAAiB,EACjB,IAAY,EACZ,cAAsB,EACtB,oBAA4B,EAC5B,oBAA4B;QAE5B,MAAM,WAAW,GAAG,QAAQ,CAAC,oBAAoB,CAC/C,KAAK,EACL,SAAS,EACT,SAAS,EACT,IAAI,CACL,CAAC;QACF,IAAI,QAAQ,GAAG,SAAS,CAAC,SAAU,CAAC,WAAW,CAAC,CAAC;QAEjD,IAAA,gBAAQ,EAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,yBAAyB,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;QAErE,IAAI,EAAE,SAAS,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,GACnE,QAAQ,CAAC;QAEX,IAAI,cAAc,KAAK,EAAE,EAAE,CAAC;YAC1B,IAAA,gBAAQ,EAAC,SAAS,KAAK,EAAE,EAAE,8BAA8B,EAAE;gBACzD,cAAc;aACf,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,SAAS,IAAI,cAAc,CAAC;QAC9B,CAAC;QAED,MAAM,SAAS,GACb,CAAC,CAAC,oBAAoB,GAAG,wBAAwB,CAAC,GAAG,SAAS,CAAC;YAC/D,MAAM,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;QACnB,MAAM,SAAS,GACb,CAAC,CAAC,oBAAoB,GAAG,wBAAwB,CAAC,GAAG,SAAS,CAAC;YAC/D,MAAM,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;QAEnB,SAAS,CAAC,SAAU,CAAC,WAAW,CAAC,GAAG;YAClC,SAAS;YACT,wBAAwB,EAAE,oBAAoB;YAC9C,wBAAwB,EAAE,oBAAoB;SAC/C,CAAC;QAEF,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;IAClC,CAAC;CACF;AAzED,4BAyEC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Interface } from 'ethers/lib/utils';
|
|
2
|
+
import { InitializeStateOptions, StatefulEventSubscriber } from '../../../../stateful-event-subscriber';
|
|
3
|
+
import { IDexHelper } from '../../../../dex-helper';
|
|
4
|
+
import { Logger, Log, Address } from '../../../../types';
|
|
5
|
+
import { DeepReadonly } from 'ts-essentials';
|
|
6
|
+
type ProtocolFeeSettings = {
|
|
7
|
+
recipient: Address;
|
|
8
|
+
protocolFeePpm: number;
|
|
9
|
+
referralFeePpm: number;
|
|
10
|
+
};
|
|
11
|
+
export type ArenaFeeHelperState = {
|
|
12
|
+
protocolFeePpm: ProtocolFeeSettings['protocolFeePpm'];
|
|
13
|
+
poolIdToTotalFeePpm: Record<string, bigint>;
|
|
14
|
+
};
|
|
15
|
+
export declare class ArenaFeeHelper extends StatefulEventSubscriber<ArenaFeeHelperState> {
|
|
16
|
+
readonly parentName: string;
|
|
17
|
+
protected network: number;
|
|
18
|
+
protected dexHelper: IDexHelper;
|
|
19
|
+
protected ArenaFeeHelperIface: Interface;
|
|
20
|
+
handlers: {
|
|
21
|
+
[event: string]: (event: any, state: DeepReadonly<ArenaFeeHelperState>, log: Readonly<Log>) => DeepReadonly<ArenaFeeHelperState> | null;
|
|
22
|
+
};
|
|
23
|
+
logDecoder: (log: Log) => any;
|
|
24
|
+
private readonly feeHelperAddress;
|
|
25
|
+
private readonly feeHelper;
|
|
26
|
+
protected poolIds: Set<string>;
|
|
27
|
+
constructor(parentName: string, network: number, dexHelper: IDexHelper, logger: Logger, ArenaFeeHelperIface?: Interface);
|
|
28
|
+
initialize(blockNumber: number, options?: InitializeStateOptions<ArenaFeeHelperState>): Promise<void>;
|
|
29
|
+
protected processLog(state: DeepReadonly<ArenaFeeHelperState>, log: Readonly<Log>): DeepReadonly<ArenaFeeHelperState> | null;
|
|
30
|
+
generateState(blockNumber?: number | 'latest'): Promise<DeepReadonly<ArenaFeeHelperState>>;
|
|
31
|
+
addPoolId(poolId: string): void;
|
|
32
|
+
getOrGenerateState(blockNumber: number): Promise<ArenaFeeHelperState>;
|
|
33
|
+
handleFeeArraySet(event: any, state: DeepReadonly<ArenaFeeHelperState>, log: Readonly<Log>): DeepReadonly<ArenaFeeHelperState> | null;
|
|
34
|
+
handleProtocolFeeSettingsSet(event: any, state: DeepReadonly<ArenaFeeHelperState>, log: Readonly<Log>): DeepReadonly<ArenaFeeHelperState> | null;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,125 @@
|
|
|
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.ArenaFeeHelper = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const utils_1 = require("ethers/lib/utils");
|
|
9
|
+
const stateful_event_subscriber_1 = require("../../../../stateful-event-subscriber");
|
|
10
|
+
const arena_fee_helper_abi_json_1 = __importDefault(require("../../../../abi/uniswap-v4/hooks/arena/arena-fee-helper.abi.json"));
|
|
11
|
+
const config_1 = require("./config");
|
|
12
|
+
const utils_2 = require("../../../../utils");
|
|
13
|
+
const decoders_1 = require("../../../../lib/decoders");
|
|
14
|
+
class ArenaFeeHelper extends stateful_event_subscriber_1.StatefulEventSubscriber {
|
|
15
|
+
parentName;
|
|
16
|
+
network;
|
|
17
|
+
dexHelper;
|
|
18
|
+
ArenaFeeHelperIface;
|
|
19
|
+
handlers = {};
|
|
20
|
+
logDecoder;
|
|
21
|
+
feeHelperAddress;
|
|
22
|
+
feeHelper;
|
|
23
|
+
poolIds = new Set();
|
|
24
|
+
constructor(parentName, network, dexHelper, logger, ArenaFeeHelperIface = new utils_1.Interface(arena_fee_helper_abi_json_1.default)) {
|
|
25
|
+
super(parentName, 'ArenaFeeHelper', dexHelper, logger, false);
|
|
26
|
+
this.parentName = parentName;
|
|
27
|
+
this.network = network;
|
|
28
|
+
this.dexHelper = dexHelper;
|
|
29
|
+
this.ArenaFeeHelperIface = ArenaFeeHelperIface;
|
|
30
|
+
this.feeHelperAddress =
|
|
31
|
+
config_1.ArenaHookConfig[this.network].feeHelperAddress.toLowerCase();
|
|
32
|
+
this.feeHelper = new ethers_1.Contract(this.feeHelperAddress, arena_fee_helper_abi_json_1.default, dexHelper.provider);
|
|
33
|
+
this.logDecoder = (log) => this.ArenaFeeHelperIface.parseLog(log);
|
|
34
|
+
this.addressesSubscribed = [this.feeHelperAddress];
|
|
35
|
+
this.handlers['FeeArraySet'] = this.handleFeeArraySet.bind(this);
|
|
36
|
+
this.handlers['ProtocolFeeSettingsSet'] =
|
|
37
|
+
this.handleProtocolFeeSettingsSet.bind(this);
|
|
38
|
+
}
|
|
39
|
+
async initialize(blockNumber, options) {
|
|
40
|
+
return super.initialize(blockNumber, options);
|
|
41
|
+
}
|
|
42
|
+
processLog(state, log) {
|
|
43
|
+
try {
|
|
44
|
+
const event = this.logDecoder(log);
|
|
45
|
+
if (event.name in this.handlers) {
|
|
46
|
+
return this.handlers[event.name](event, state, log);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
(0, utils_2.catchParseLogError)(e, this.logger);
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
async generateState(blockNumber) {
|
|
55
|
+
const protocolFeeSettings = await this.feeHelper.protocolFeeSettings();
|
|
56
|
+
const poolIdToTotalFeePpm = {};
|
|
57
|
+
const calls = [];
|
|
58
|
+
const poolIds = Array.from(this.poolIds);
|
|
59
|
+
for (const poolId of poolIds) {
|
|
60
|
+
calls.push({
|
|
61
|
+
target: this.feeHelperAddress,
|
|
62
|
+
callData: this.feeHelper.interface.encodeFunctionData('poolIdToTotalFeePpm', [poolId]),
|
|
63
|
+
decodeFunction: decoders_1.uint256ToBigInt,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const data = await this.dexHelper.multiWrapper.tryAggregate(false, calls);
|
|
67
|
+
data.forEach((result, index) => {
|
|
68
|
+
poolIdToTotalFeePpm[poolIds[index]] = result.success
|
|
69
|
+
? result.returnData
|
|
70
|
+
: 0n;
|
|
71
|
+
});
|
|
72
|
+
return {
|
|
73
|
+
protocolFeePpm: protocolFeeSettings.protocolFeePpm,
|
|
74
|
+
poolIdToTotalFeePpm,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
addPoolId(poolId) {
|
|
78
|
+
if (this.poolIds.has(poolId))
|
|
79
|
+
return;
|
|
80
|
+
this.poolIds.add(poolId);
|
|
81
|
+
const state = this.getStaleState();
|
|
82
|
+
if (state) {
|
|
83
|
+
const poolIdToTotalFeePpm = { ...state.poolIdToTotalFeePpm };
|
|
84
|
+
if (!(poolId in poolIdToTotalFeePpm)) {
|
|
85
|
+
poolIdToTotalFeePpm[poolId] = 0n;
|
|
86
|
+
}
|
|
87
|
+
this.setState({
|
|
88
|
+
...state,
|
|
89
|
+
poolIdToTotalFeePpm,
|
|
90
|
+
}, this.stateBlockNumber);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async getOrGenerateState(blockNumber) {
|
|
94
|
+
let state = this.getState(blockNumber);
|
|
95
|
+
if (!state) {
|
|
96
|
+
state = await this.generateState(blockNumber);
|
|
97
|
+
this.setState(state, blockNumber);
|
|
98
|
+
}
|
|
99
|
+
return state;
|
|
100
|
+
}
|
|
101
|
+
handleFeeArraySet(event, state, log) {
|
|
102
|
+
const poolId = event.args.poolId.toLowerCase();
|
|
103
|
+
const fees = event.args.fees;
|
|
104
|
+
let total = 0n;
|
|
105
|
+
for (const fee of fees) {
|
|
106
|
+
total += BigInt(fee.feePpm.toString());
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
protocolFeePpm: state.protocolFeePpm,
|
|
110
|
+
poolIdToTotalFeePpm: {
|
|
111
|
+
...state.poolIdToTotalFeePpm,
|
|
112
|
+
[poolId]: total,
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
handleProtocolFeeSettingsSet(event, state, log) {
|
|
117
|
+
const settings = event.args.settings;
|
|
118
|
+
return {
|
|
119
|
+
protocolFeePpm: Number(settings.protocolFeePpm),
|
|
120
|
+
poolIdToTotalFeePpm: { ...state.poolIdToTotalFeePpm },
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.ArenaFeeHelper = ArenaFeeHelper;
|
|
125
|
+
//# sourceMappingURL=arena-fee-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arena-fee-helper.js","sourceRoot":"","sources":["../../../../../src/dex/uniswap-v4/hooks/arena/arena-fee-helper.ts"],"names":[],"mappings":";;;;;;AAAA,mC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,OAAO,KAAK,CAAC;IACf,CAAC;IAED,iBAAiB,CACf,KAAU,EACV,KAAwC,EACxC,GAAkB;QAElB,MAAM,MAAM,GAAW,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QACvD,MAAM,IAAI,GAAU,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;QAEpC,IAAI,KAAK,GAAG,EAAE,CAAC;QACf,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,KAAK,IAAI,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;QACzC,CAAC;QAED,OAAO;YACL,cAAc,EAAE,KAAK,CAAC,cAAc;YACpC,mBAAmB,EAAE;gBACnB,GAAG,KAAK,CAAC,mBAAmB;gBAC5B,CAAC,MAAM,CAAC,EAAE,KAAK;aAChB;SACF,CAAC;IACJ,CAAC;IAED,4BAA4B,CAC1B,KAAU,EACV,KAAwC,EACxC,GAAkB;QAElB,MAAM,QAAQ,GAAwB,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;QAE1D,OAAO;YACL,cAAc,EAAE,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC;YAC/C,mBAAmB,EAAE,EAAE,GAAG,KAAK,CAAC,mBAAmB,EAAE;SACtD,CAAC;IACJ,CAAC;CACF;AApKD,wCAoKC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IDexHelper } from '../../../../dex-helper';
|
|
2
|
+
import { Network } from '../../../../constants';
|
|
3
|
+
import { Logger } from '../../../../types';
|
|
4
|
+
import { PoolKey } from '../../types';
|
|
5
|
+
import { SwapParams, BalanceDelta, HooksPermissions, IBaseHook } from '../types';
|
|
6
|
+
import { ArenaFeeHelper } from './arena-fee-helper';
|
|
7
|
+
export declare class ArenaHook implements IBaseHook {
|
|
8
|
+
readonly dexHelper: IDexHelper;
|
|
9
|
+
readonly network: Network;
|
|
10
|
+
readonly logger: Logger;
|
|
11
|
+
readonly feeHelperAddress: string;
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly address: string;
|
|
14
|
+
readonly arenaFeeHelper: ArenaFeeHelper;
|
|
15
|
+
constructor(dexHelper: IDexHelper, network: Network, logger: Logger, feeHelperAddress?: string);
|
|
16
|
+
registerPool(poolId: string, _poolKey: PoolKey): void;
|
|
17
|
+
initialize(blockNumber: number): Promise<void>;
|
|
18
|
+
getHookPermissions(): HooksPermissions;
|
|
19
|
+
afterSwap(_sender: string, key: PoolKey, params: SwapParams, delta: BalanceDelta, _hookData: string): bigint;
|
|
20
|
+
private getTotalFeePpm;
|
|
21
|
+
}
|