@paraswap/dex-lib 4.7.14-multi-route.0 → 4.7.14-multi-route.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/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/simple-exchange.js +7 -1
- package/build/dex/simple-exchange.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/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 +3 -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 +3 -0
- package/build/dex/uniswap-v4/hooks/types.js.map +1 -0
- package/build/executor/types.d.ts +3 -3
- package/build/generic-swap-transaction-builder.d.ts +3 -2
- package/build/generic-swap-transaction-builder.js +61 -50
- package/build/generic-swap-transaction-builder.js.map +1 -1
- package/package.json +1 -1
|
@@ -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,EAA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C,MAAM,CAAC,SAAS,CAAC;YACtC,WAAW;YACX,mBAAmB,EAAE,IAAA,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,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,CAAC;YAE5D,MAAM,iBAAiB,GAAG,eAAe;gBACvC,CAAC,CAAC,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"}
|
|
@@ -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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IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;YAC9C,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QACpC,CAAC;QACD,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
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArenaHook = void 0;
|
|
4
|
+
const config_1 = require("./config");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
const utils_2 = require("../../../../utils");
|
|
7
|
+
const arena_fee_helper_1 = require("./arena-fee-helper");
|
|
8
|
+
const MAX_HOOK_FEE = 1000000n; // 100%
|
|
9
|
+
const UINT128_MAX = (1n << 128n) - 1n;
|
|
10
|
+
const INT128_MAX = (1n << 127n) - 1n;
|
|
11
|
+
class ArenaHook {
|
|
12
|
+
dexHelper;
|
|
13
|
+
network;
|
|
14
|
+
logger;
|
|
15
|
+
feeHelperAddress;
|
|
16
|
+
name = this.constructor.name;
|
|
17
|
+
address;
|
|
18
|
+
arenaFeeHelper;
|
|
19
|
+
constructor(dexHelper, network, logger, feeHelperAddress = config_1.ArenaHookConfig[network].feeHelperAddress.toLowerCase()) {
|
|
20
|
+
this.dexHelper = dexHelper;
|
|
21
|
+
this.network = network;
|
|
22
|
+
this.logger = logger;
|
|
23
|
+
this.feeHelperAddress = feeHelperAddress;
|
|
24
|
+
this.address = config_1.ArenaHookConfig[network].hookAddress.toLowerCase();
|
|
25
|
+
this.arenaFeeHelper = new arena_fee_helper_1.ArenaFeeHelper(this.name, network, dexHelper, logger);
|
|
26
|
+
}
|
|
27
|
+
registerPool(poolId, _poolKey) {
|
|
28
|
+
this.arenaFeeHelper.addPoolId(poolId.toLowerCase());
|
|
29
|
+
}
|
|
30
|
+
async initialize(blockNumber) {
|
|
31
|
+
if (!this.arenaFeeHelper.isInitialized) {
|
|
32
|
+
await this.arenaFeeHelper.initialize(blockNumber);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
getHookPermissions() {
|
|
36
|
+
return {
|
|
37
|
+
beforeInitialize: true,
|
|
38
|
+
afterInitialize: false,
|
|
39
|
+
beforeAddLiquidity: false,
|
|
40
|
+
afterAddLiquidity: false,
|
|
41
|
+
beforeRemoveLiquidity: false,
|
|
42
|
+
afterRemoveLiquidity: false,
|
|
43
|
+
beforeSwap: false,
|
|
44
|
+
afterSwap: true,
|
|
45
|
+
beforeDonate: false,
|
|
46
|
+
afterDonate: false,
|
|
47
|
+
beforeSwapReturnDelta: false,
|
|
48
|
+
afterSwapReturnDelta: true,
|
|
49
|
+
afterAddLiquidityReturnDelta: false,
|
|
50
|
+
afterRemoveLiquidityReturnDelta: false,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
afterSwap(_sender, key, params, delta, _hookData) {
|
|
54
|
+
const { amountSpecified, zeroForOne } = params;
|
|
55
|
+
const isExactInput = BigInt(amountSpecified) < 0n;
|
|
56
|
+
// Determine the unspecified (output) delta based on swap direction and type:
|
|
57
|
+
// - ExactInput + zeroForOne: input is token0, output is token1 (amount1)
|
|
58
|
+
// - ExactInput + oneForZero: input is token1, output is token0 (amount0)
|
|
59
|
+
// - ExactOutput + zeroForOne: output is token1, input is token0 (amount0 is unspecified)
|
|
60
|
+
// - ExactOutput + oneForZero: output is token0, input is token1 (amount1 is unspecified)
|
|
61
|
+
const outputIsToken1 = isExactInput === zeroForOne;
|
|
62
|
+
const unspecifiedDelta = outputIsToken1 ? delta.amount1 : delta.amount0;
|
|
63
|
+
if (unspecifiedDelta === 0n) {
|
|
64
|
+
return 0n;
|
|
65
|
+
}
|
|
66
|
+
const output = unspecifiedDelta < 0n ? -unspecifiedDelta : unspecifiedDelta;
|
|
67
|
+
(0, utils_2._require)(output <= UINT128_MAX, 'Unspecified output exceeds uint128', { output }, 'output <= UINT128_MAX');
|
|
68
|
+
const totalFeePpm = this.getTotalFeePpm((0, utils_1.toId)(key));
|
|
69
|
+
if (totalFeePpm === 0n) {
|
|
70
|
+
return output;
|
|
71
|
+
}
|
|
72
|
+
(0, utils_2._require)(totalFeePpm <= MAX_HOOK_FEE, 'Hook fee too large', { totalFeePpm }, 'totalFeePpm <= MAX_HOOK_FEE');
|
|
73
|
+
const feeAmount = (output * totalFeePpm) / MAX_HOOK_FEE;
|
|
74
|
+
(0, utils_2._require)(feeAmount <= INT128_MAX, 'Hook fee exceeds int128', { feeAmount }, 'feeAmount <= INT128_MAX');
|
|
75
|
+
// For exact input: user receives output minus fee
|
|
76
|
+
// For exact output: user must provide more input to cover fee
|
|
77
|
+
const netOutput = isExactInput ? output - feeAmount : output + feeAmount;
|
|
78
|
+
return netOutput;
|
|
79
|
+
}
|
|
80
|
+
getTotalFeePpm(poolId) {
|
|
81
|
+
if (!this.arenaFeeHelper?.isInitialized) {
|
|
82
|
+
return 0n;
|
|
83
|
+
}
|
|
84
|
+
const state = this.arenaFeeHelper.getStaleState();
|
|
85
|
+
if (!state) {
|
|
86
|
+
return 0n;
|
|
87
|
+
}
|
|
88
|
+
const poolFee = state.poolIdToTotalFeePpm[poolId] ?? 0n;
|
|
89
|
+
return poolFee + BigInt(state.protocolFeePpm);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.ArenaHook = ArenaHook;
|
|
93
|
+
//# sourceMappingURL=arena-hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arena-hook.js","sourceRoot":"","sources":["../../../../../src/dex/uniswap-v4/hooks/arena/arena-hook.ts"],"names":[],"mappings":";;;AACA,qCAA2C;AAU3C,uCAAmC;AACnC,6CAA6C;AAC7C,yDAAoD;AAEpD,MAAM,YAAY,GAAG,QAAU,CAAC,CAAC,OAAO;AACxC,MAAM,WAAW,GAAG,CAAC,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;AACtC,MAAM,UAAU,GAAG,CAAC,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;AAErC,MAAa,SAAS;IAMT;IACA;IACA;IACA;IARF,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IAC7B,OAAO,CAAS;IAChB,cAAc,CAAiB;IAExC,YACW,SAAqB,EACrB,OAAgB,EAChB,MAAc,EACd,mBAAmB,wBAAe,CACzC,OAAO,CACR,CAAC,gBAAgB,CAAC,WAAW,EAAE;QALvB,cAAS,GAAT,SAAS,CAAY;QACrB,YAAO,GAAP,OAAO,CAAS;QAChB,WAAM,GAAN,MAAM,CAAQ;QACd,qBAAgB,GAAhB,gBAAgB,CAEO;QAEhC,IAAI,CAAC,OAAO,GAAG,wBAAe,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC;QAElE,IAAI,CAAC,cAAc,GAAG,IAAI,iCAAc,CACtC,IAAI,CAAC,IAAI,EACT,OAAO,EACP,SAAS,EACT,MAAM,CACP,CAAC;IACJ,CAAC;IAED,YAAY,CAAC,MAAc,EAAE,QAAiB;QAC5C,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,WAAmB;QAClC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC;YACvC,MAAM,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QACpD,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