@paraswap/dex-lib 4.3.5 → 4.3.6
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/algebra-integral/AlgebraFactory.abi.json +947 -0
- package/build/abi/algebra-integral/Quoter.abi.json +231 -0
- package/build/abi/algebra-integral/SwapRouter.abi.json +810 -0
- package/build/abi/ekubo/twamm-data-fetcher.json +216 -0
- package/build/abi/ekubo/twamm.json +720 -0
- package/build/abi/ring-v2/few-wrapped-token.json +587 -0
- package/build/abi/ring-v2/ring-v2-factory.json +125 -0
- package/build/abi/ring-v2/ring-v2-pool.json +461 -0
- package/build/abi/ring-v2/ring-v2-router.json +332 -0
- package/build/abi/uniswap-v2/ring-v2-router.json +332 -0
- package/build/dex/algebra-integral/algebra-integral-factory.d.ts +29 -0
- package/build/dex/algebra-integral/algebra-integral-factory.js +159 -0
- package/build/dex/algebra-integral/algebra-integral-factory.js.map +1 -0
- package/build/dex/algebra-integral/algebra-integral.d.ts +43 -0
- package/build/dex/algebra-integral/algebra-integral.js +425 -0
- package/build/dex/algebra-integral/algebra-integral.js.map +1 -0
- package/build/dex/algebra-integral/config.d.ts +3 -0
- package/build/dex/algebra-integral/config.js +17 -0
- package/build/dex/algebra-integral/config.js.map +1 -0
- package/build/dex/algebra-integral/types.d.ts +35 -0
- package/build/dex/algebra-integral/types.js +10 -0
- package/build/dex/algebra-integral/types.js.map +1 -0
- package/build/dex/balancer-v3/balancer-v3.js +13 -2
- package/build/dex/balancer-v3/balancer-v3.js.map +1 -1
- package/build/dex/balancer-v3/utils.d.ts +10 -0
- package/build/dex/balancer-v3/utils.js +32 -0
- package/build/dex/balancer-v3/utils.js.map +1 -1
- package/build/dex/ekubo/pools/base.d.ts +36 -0
- package/build/dex/ekubo/pools/base.js +289 -0
- package/build/dex/ekubo/pools/base.js.map +1 -0
- package/build/dex/ekubo/pools/full-range.d.ts +23 -0
- package/build/dex/ekubo/pools/full-range.js +99 -0
- package/build/dex/ekubo/pools/full-range.js.map +1 -0
- package/build/dex/ekubo/pools/iface.d.ts +46 -0
- package/build/dex/ekubo/pools/iface.js +75 -0
- package/build/dex/ekubo/pools/iface.js.map +1 -0
- package/build/dex/ekubo/pools/math/twamm/exp2.d.ts +1 -0
- package/build/dex/ekubo/pools/math/twamm/exp2.js +86 -0
- package/build/dex/ekubo/pools/math/twamm/exp2.js.map +1 -0
- package/build/dex/ekubo/pools/math/twamm/sqrt-ratio.d.ts +1 -0
- package/build/dex/ekubo/pools/math/twamm/sqrt-ratio.js +56 -0
- package/build/dex/ekubo/pools/math/twamm/sqrt-ratio.js.map +1 -0
- package/build/dex/ekubo/pools/oracle.d.ts +8 -0
- package/build/dex/ekubo/pools/oracle.js +19 -0
- package/build/dex/ekubo/pools/oracle.js.map +1 -0
- package/build/dex/ekubo/pools/twamm.d.ts +38 -0
- package/build/dex/ekubo/pools/twamm.js +253 -0
- package/build/dex/ekubo/pools/twamm.js.map +1 -0
- package/build/dex/ekubo/pools/utils.d.ts +28 -0
- package/build/dex/ekubo/pools/utils.js +80 -0
- package/build/dex/ekubo/pools/utils.js.map +1 -0
- package/build/dex/miro-migrator/constants.d.ts +1 -1
- package/build/dex/miro-migrator/constants.js +1 -1
- package/build/dex/miro-migrator/miro-migrator-pool.d.ts +5 -5
- package/build/dex/miro-migrator/miro-migrator-pool.js +13 -22
- package/build/dex/miro-migrator/miro-migrator-pool.js.map +1 -1
- package/build/dex/miro-migrator/miro-migrator-state.d.ts +27 -0
- package/build/dex/miro-migrator/miro-migrator-state.js +89 -0
- package/build/dex/miro-migrator/miro-migrator-state.js.map +1 -0
- package/build/dex/miro-migrator/miro-migrator.js +4 -2
- package/build/dex/miro-migrator/miro-migrator.js.map +1 -1
- package/build/dex/uniswap-v2/ring-v2.d.ts +35 -0
- package/build/dex/uniswap-v2/ring-v2.js +223 -0
- package/build/dex/uniswap-v2/ring-v2.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getUniqueHookNames = getUniqueHookNames;
|
|
4
|
+
exports.removeCircularStepPairs = removeCircularStepPairs;
|
|
4
5
|
function getUniqueHookNames(hooksConfigMap) {
|
|
5
6
|
// Use Object.values to get all HookConfig objects
|
|
6
7
|
// Then map to extract just the names
|
|
@@ -8,4 +9,35 @@ function getUniqueHookNames(hooksConfigMap) {
|
|
|
8
9
|
// Convert back to array and join with comma
|
|
9
10
|
return Array.from(new Set(Object.values(hooksConfigMap).map(hook => hook.apiName))).join(', ');
|
|
10
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Removes adjacent pairs of buffer steps that form circular swaps.
|
|
14
|
+
* Only removes pairs where both steps have isBuffer=true and
|
|
15
|
+
* first step's tokenIn equals second step's tokenOut.
|
|
16
|
+
*
|
|
17
|
+
* @param steps - Array of sequential swap steps
|
|
18
|
+
* @returns Filtered array with circular buffer pairs removed
|
|
19
|
+
*/
|
|
20
|
+
function removeCircularStepPairs(steps) {
|
|
21
|
+
const result = [];
|
|
22
|
+
let i = 0;
|
|
23
|
+
while (i < steps.length) {
|
|
24
|
+
const currentStep = steps[i];
|
|
25
|
+
const nextStep = steps[i + 1];
|
|
26
|
+
// Check if current step and next step form a circular pair AND both are buffer steps
|
|
27
|
+
const isCircularPair = nextStep !== undefined &&
|
|
28
|
+
currentStep.swapInput.tokenIn === nextStep.swapInput.tokenOut &&
|
|
29
|
+
currentStep.isBuffer &&
|
|
30
|
+
nextStep.isBuffer;
|
|
31
|
+
if (isCircularPair) {
|
|
32
|
+
// Skip both steps (they cancel each other out)
|
|
33
|
+
i += 2;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
// Keep this step
|
|
37
|
+
result.push(currentStep);
|
|
38
|
+
i += 1;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
11
43
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/dex/balancer-v3/utils.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/dex/balancer-v3/utils.ts"],"names":[],"mappings":";;AAGA,gDAQC;AAUD,0DA0BC;AA5CD,SAAgB,kBAAkB,CAAC,cAA8B;IAC/D,kDAAkD;IAClD,qCAAqC;IACrC,8BAA8B;IAC9B,4CAA4C;IAC5C,OAAO,KAAK,CAAC,IAAI,CACf,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CACjE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,uBAAuB,CAAC,KAAa;IACnD,MAAM,MAAM,GAAW,EAAE,CAAC;IAC1B,IAAI,CAAC,GAAG,CAAC,CAAC;IAEV,OAAO,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QACxB,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAC7B,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAE9B,qFAAqF;QACrF,MAAM,cAAc,GAClB,QAAQ,KAAK,SAAS;YACtB,WAAW,CAAC,SAAS,CAAC,OAAO,KAAK,QAAQ,CAAC,SAAS,CAAC,QAAQ;YAC7D,WAAW,CAAC,QAAQ;YACpB,QAAQ,CAAC,QAAQ,CAAC;QAEpB,IAAI,cAAc,EAAE,CAAC;YACnB,+CAA+C;YAC/C,CAAC,IAAI,CAAC,CAAC;QACT,CAAC;aAAM,CAAC;YACN,iBAAiB;YACjB,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACzB,CAAC,IAAI,CAAC,CAAC;QACT,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DeepReadonly } from 'ts-essentials';
|
|
2
|
+
import { IDexHelper } from '../../../dex-helper/idex-helper';
|
|
3
|
+
import { Logger } from '../../../types';
|
|
4
|
+
import { BasicQuoteData, EkuboContracts } from '../types';
|
|
5
|
+
import { EkuboPool } from './iface';
|
|
6
|
+
import { PoolKey, SwappedEvent } from './utils';
|
|
7
|
+
export declare class BasePool extends EkuboPool<BasePoolState.Object> {
|
|
8
|
+
private readonly dataFetcher;
|
|
9
|
+
constructor(parentName: string, dexHelper: IDexHelper, logger: Logger, contracts: EkuboContracts, key: PoolKey);
|
|
10
|
+
generateState(blockNumber: number): Promise<DeepReadonly<BasePoolState.Object>>;
|
|
11
|
+
}
|
|
12
|
+
export interface Tick {
|
|
13
|
+
readonly number: number;
|
|
14
|
+
liquidityDelta: bigint;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Returns the index in the sorted tick array that has the greatest value of tick that is not greater than the given tick
|
|
18
|
+
* @param sortedTicks the sorted list of ticks to search in
|
|
19
|
+
* @param tick the tick to search for
|
|
20
|
+
*/
|
|
21
|
+
export declare function findNearestInitializedTickIndex(sortedTicks: Tick[], tick: number): number | null;
|
|
22
|
+
export declare namespace BasePoolState {
|
|
23
|
+
type Object = {
|
|
24
|
+
sqrtRatio: bigint;
|
|
25
|
+
liquidity: bigint;
|
|
26
|
+
activeTick: number;
|
|
27
|
+
readonly sortedTicks: Tick[];
|
|
28
|
+
activeTickIndex: number | null;
|
|
29
|
+
readonly checkedTicksBounds: readonly [number, number];
|
|
30
|
+
};
|
|
31
|
+
function fromQuoter(data: BasicQuoteData): DeepReadonly<Object>;
|
|
32
|
+
function fromSwappedEvent(oldState: DeepReadonly<Object>, ev: SwappedEvent): Object;
|
|
33
|
+
function fromPositionUpdatedEvent(oldState: DeepReadonly<Object>, [lowTick, highTick]: [number, number], liquidityDelta: bigint): Object | null;
|
|
34
|
+
function addLiquidityCutoffs(state: BasePoolState.Object): void;
|
|
35
|
+
function updateTick(state: Object, updatedTickNumber: number, liquidityDelta: bigint, upper: boolean, forceInsert: boolean): void;
|
|
36
|
+
}
|
|
@@ -0,0 +1,289 @@
|
|
|
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.BasePoolState = exports.BasePool = void 0;
|
|
7
|
+
exports.findNearestInitializedTickIndex = findNearestInitializedTickIndex;
|
|
8
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
9
|
+
const iface_1 = require("./iface");
|
|
10
|
+
const price_1 = require("./math/price");
|
|
11
|
+
const swap_1 = require("./math/swap");
|
|
12
|
+
const tick_1 = require("./math/tick");
|
|
13
|
+
const utils_1 = require("./utils");
|
|
14
|
+
const GAS_COST_OF_ONE_CL_SWAP = 24_000;
|
|
15
|
+
const GAS_COST_OF_ONE_INITIALIZED_TICK_CROSSED = 9_400;
|
|
16
|
+
const GAS_COST_OF_ONE_TICK_SPACING_CROSSED = 4_000;
|
|
17
|
+
class BasePool extends iface_1.EkuboPool {
|
|
18
|
+
dataFetcher;
|
|
19
|
+
constructor(parentName, dexHelper, logger, contracts, key) {
|
|
20
|
+
const { contract: { address }, interface: iface, dataFetcher, } = contracts.core;
|
|
21
|
+
super(parentName, dexHelper, logger, key, {
|
|
22
|
+
[address]: new iface_1.NamedEventHandlers(iface, {
|
|
23
|
+
PositionUpdated: (args, oldState) => {
|
|
24
|
+
if (key.num_id !== BigInt(args.poolId)) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
const params = args.params;
|
|
28
|
+
return BasePoolState.fromPositionUpdatedEvent(oldState, [params.bounds.lower, params.bounds.upper], params.liquidityDelta.toBigInt());
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
}, {
|
|
32
|
+
[address]: (data, oldState) => {
|
|
33
|
+
const ev = (0, utils_1.parseSwappedEvent)(data);
|
|
34
|
+
if (key.num_id !== ev.poolId) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return BasePoolState.fromSwappedEvent(oldState, ev);
|
|
38
|
+
},
|
|
39
|
+
}, quote);
|
|
40
|
+
this.dataFetcher = dataFetcher;
|
|
41
|
+
}
|
|
42
|
+
async generateState(blockNumber) {
|
|
43
|
+
const data = await this.dataFetcher.getQuoteData([this.key.toAbi()], 10, {
|
|
44
|
+
blockTag: blockNumber,
|
|
45
|
+
});
|
|
46
|
+
return BasePoolState.fromQuoter(data[0]);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.BasePool = BasePool;
|
|
50
|
+
function quote(amount, isToken1, state) {
|
|
51
|
+
const isIncreasing = (0, swap_1.isPriceIncreasing)(amount, isToken1);
|
|
52
|
+
let { sqrtRatio, liquidity, activeTickIndex, sortedTicks } = state;
|
|
53
|
+
const sqrtRatioLimit = isIncreasing ? tick_1.MAX_SQRT_RATIO : tick_1.MIN_SQRT_RATIO;
|
|
54
|
+
let calculatedAmount = 0n;
|
|
55
|
+
let initializedTicksCrossed = 0;
|
|
56
|
+
let amountRemaining = amount;
|
|
57
|
+
const startingSqrtRatio = sqrtRatio;
|
|
58
|
+
while (amountRemaining !== 0n && sqrtRatio !== sqrtRatioLimit) {
|
|
59
|
+
const nextInitializedTick = (isIncreasing
|
|
60
|
+
? sortedTicks[activeTickIndex === null ? 0 : activeTickIndex + 1]
|
|
61
|
+
: activeTickIndex === null
|
|
62
|
+
? null
|
|
63
|
+
: sortedTicks[activeTickIndex]) ?? null;
|
|
64
|
+
const nextInitializedTickSqrtRatio = nextInitializedTick
|
|
65
|
+
? (0, tick_1.toSqrtRatio)(nextInitializedTick.number)
|
|
66
|
+
: null;
|
|
67
|
+
const stepSqrtRatioLimit = nextInitializedTickSqrtRatio === null
|
|
68
|
+
? sqrtRatioLimit
|
|
69
|
+
: nextInitializedTickSqrtRatio < sqrtRatioLimit === isIncreasing
|
|
70
|
+
? nextInitializedTickSqrtRatio
|
|
71
|
+
: sqrtRatioLimit;
|
|
72
|
+
const step = (0, swap_1.computeStep)({
|
|
73
|
+
fee: this.key.config.fee,
|
|
74
|
+
sqrtRatio,
|
|
75
|
+
liquidity,
|
|
76
|
+
isToken1,
|
|
77
|
+
sqrtRatioLimit: stepSqrtRatioLimit,
|
|
78
|
+
amount: amountRemaining,
|
|
79
|
+
});
|
|
80
|
+
amountRemaining -= step.consumedAmount;
|
|
81
|
+
calculatedAmount += step.calculatedAmount;
|
|
82
|
+
sqrtRatio = step.sqrtRatioNext;
|
|
83
|
+
// Cross the tick if the price moved all the way to the next initialized tick price
|
|
84
|
+
if (nextInitializedTick && sqrtRatio === nextInitializedTickSqrtRatio) {
|
|
85
|
+
activeTickIndex = isIncreasing
|
|
86
|
+
? activeTickIndex === null
|
|
87
|
+
? 0
|
|
88
|
+
: activeTickIndex + 1
|
|
89
|
+
: activeTickIndex
|
|
90
|
+
? activeTickIndex - 1
|
|
91
|
+
: null;
|
|
92
|
+
initializedTicksCrossed++;
|
|
93
|
+
liquidity += isIncreasing
|
|
94
|
+
? nextInitializedTick.liquidityDelta
|
|
95
|
+
: -nextInitializedTick.liquidityDelta;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const tickSpacingsCrossed = (0, tick_1.approximateNumberOfTickSpacingsCrossed)(startingSqrtRatio, sqrtRatio, this.key.config.tickSpacing);
|
|
99
|
+
return {
|
|
100
|
+
consumedAmount: amount - amountRemaining,
|
|
101
|
+
calculatedAmount,
|
|
102
|
+
gasConsumed: GAS_COST_OF_ONE_CL_SWAP +
|
|
103
|
+
initializedTicksCrossed * GAS_COST_OF_ONE_INITIALIZED_TICK_CROSSED +
|
|
104
|
+
tickSpacingsCrossed * GAS_COST_OF_ONE_TICK_SPACING_CROSSED,
|
|
105
|
+
skipAhead: initializedTicksCrossed === 0
|
|
106
|
+
? 0
|
|
107
|
+
: Math.floor(tickSpacingsCrossed / initializedTicksCrossed),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Returns the index in the sorted tick array that has the greatest value of tick that is not greater than the given tick
|
|
112
|
+
* @param sortedTicks the sorted list of ticks to search in
|
|
113
|
+
* @param tick the tick to search for
|
|
114
|
+
*/
|
|
115
|
+
function findNearestInitializedTickIndex(sortedTicks, tick) {
|
|
116
|
+
let l = 0, r = sortedTicks.length;
|
|
117
|
+
while (l < r) {
|
|
118
|
+
const mid = Math.floor((l + r) / 2);
|
|
119
|
+
const midTick = sortedTicks[mid].number;
|
|
120
|
+
if (midTick <= tick) {
|
|
121
|
+
// If it's the last index, or the next tick is greater, we've found our index
|
|
122
|
+
if (mid === sortedTicks.length - 1 ||
|
|
123
|
+
sortedTicks[mid + 1].number > tick) {
|
|
124
|
+
return mid;
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
// Otherwise our value is to the right of this one
|
|
128
|
+
l = mid;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
// The mid tick is greater than the one we want, so we know it's not mid
|
|
133
|
+
r = mid;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
var BasePoolState;
|
|
139
|
+
(function (BasePoolState) {
|
|
140
|
+
function fromQuoter(data) {
|
|
141
|
+
const sortedTicks = data.ticks.map(({ number, liquidityDelta }) => ({
|
|
142
|
+
number,
|
|
143
|
+
liquidityDelta: liquidityDelta.toBigInt(),
|
|
144
|
+
}));
|
|
145
|
+
const liquidity = data.liquidity.toBigInt();
|
|
146
|
+
const sqrtRatioFloat = data.sqrtRatio.toBigInt();
|
|
147
|
+
const state = {
|
|
148
|
+
sqrtRatio: (0, price_1.floatSqrtRatioToFixed)(sqrtRatioFloat),
|
|
149
|
+
liquidity,
|
|
150
|
+
activeTick: data.tick,
|
|
151
|
+
sortedTicks,
|
|
152
|
+
activeTickIndex: null, // This will be filled in
|
|
153
|
+
checkedTicksBounds: [data.minTick, data.maxTick],
|
|
154
|
+
};
|
|
155
|
+
addLiquidityCutoffs(state);
|
|
156
|
+
return state;
|
|
157
|
+
}
|
|
158
|
+
BasePoolState.fromQuoter = fromQuoter;
|
|
159
|
+
function fromSwappedEvent(oldState, ev) {
|
|
160
|
+
const sortedTicks = oldState.sortedTicks;
|
|
161
|
+
const clonedTicks = lodash_1.default.cloneDeep(sortedTicks);
|
|
162
|
+
return {
|
|
163
|
+
sqrtRatio: ev.sqrtRatioAfter,
|
|
164
|
+
liquidity: ev.liquidityAfter,
|
|
165
|
+
activeTick: ev.tickAfter,
|
|
166
|
+
sortedTicks: clonedTicks,
|
|
167
|
+
activeTickIndex: findNearestInitializedTickIndex(clonedTicks, ev.tickAfter),
|
|
168
|
+
checkedTicksBounds: oldState.checkedTicksBounds,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
BasePoolState.fromSwappedEvent = fromSwappedEvent;
|
|
172
|
+
function fromPositionUpdatedEvent(oldState, [lowTick, highTick], liquidityDelta) {
|
|
173
|
+
if (liquidityDelta === 0n) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
const clonedState = lodash_1.default.cloneDeep(oldState);
|
|
177
|
+
updateTick(clonedState, lowTick, liquidityDelta, false, false);
|
|
178
|
+
updateTick(clonedState, highTick, liquidityDelta, true, false);
|
|
179
|
+
if (clonedState.activeTick >= lowTick &&
|
|
180
|
+
clonedState.activeTick < highTick) {
|
|
181
|
+
clonedState.liquidity += liquidityDelta;
|
|
182
|
+
}
|
|
183
|
+
return clonedState;
|
|
184
|
+
}
|
|
185
|
+
BasePoolState.fromPositionUpdatedEvent = fromPositionUpdatedEvent;
|
|
186
|
+
function addLiquidityCutoffs(state) {
|
|
187
|
+
const { sortedTicks, liquidity, activeTick } = state;
|
|
188
|
+
let activeTickIndex = undefined;
|
|
189
|
+
let currentLiquidity = 0n;
|
|
190
|
+
// The liquidity added/removed by out-of-range initialized ticks (i.e. lower than minCheckedTickNumber)
|
|
191
|
+
let liquidityDeltaMin = 0n;
|
|
192
|
+
for (let i = 0; i < sortedTicks.length; i++) {
|
|
193
|
+
const tick = sortedTicks[i];
|
|
194
|
+
if (typeof activeTickIndex === 'undefined' && activeTick < tick.number) {
|
|
195
|
+
activeTickIndex = i === 0 ? null : i - 1;
|
|
196
|
+
liquidityDeltaMin = liquidity - currentLiquidity;
|
|
197
|
+
// We now need to switch to tracking the liquidity that needs to be cut off at maxCheckedTickNumber, therefore reset to the actual liquidity
|
|
198
|
+
currentLiquidity = liquidity;
|
|
199
|
+
}
|
|
200
|
+
currentLiquidity += tick.liquidityDelta;
|
|
201
|
+
}
|
|
202
|
+
if (typeof activeTickIndex === 'undefined') {
|
|
203
|
+
activeTickIndex = sortedTicks.length > 0 ? sortedTicks.length - 1 : null;
|
|
204
|
+
liquidityDeltaMin = liquidity - currentLiquidity;
|
|
205
|
+
currentLiquidity = liquidity;
|
|
206
|
+
}
|
|
207
|
+
state.activeTickIndex = activeTickIndex;
|
|
208
|
+
BasePoolState.updateTick(state, state.checkedTicksBounds[0], liquidityDeltaMin, false, true);
|
|
209
|
+
BasePoolState.updateTick(state, state.checkedTicksBounds[1], currentLiquidity, true, true);
|
|
210
|
+
}
|
|
211
|
+
BasePoolState.addLiquidityCutoffs = addLiquidityCutoffs;
|
|
212
|
+
function updateTick(state, updatedTickNumber, liquidityDelta, upper, forceInsert) {
|
|
213
|
+
const sortedTicks = state.sortedTicks;
|
|
214
|
+
if (upper) {
|
|
215
|
+
liquidityDelta = -liquidityDelta;
|
|
216
|
+
}
|
|
217
|
+
const nearestTickIndex = findNearestInitializedTickIndex(sortedTicks, updatedTickNumber);
|
|
218
|
+
const nearestTick = nearestTickIndex === null ? null : sortedTicks[nearestTickIndex];
|
|
219
|
+
const nearestTickNumber = nearestTick?.number;
|
|
220
|
+
const newTickReferenced = nearestTickNumber !== updatedTickNumber;
|
|
221
|
+
if (newTickReferenced) {
|
|
222
|
+
if (!forceInsert && nearestTickIndex === null) {
|
|
223
|
+
sortedTicks[0].liquidityDelta += liquidityDelta;
|
|
224
|
+
}
|
|
225
|
+
else if (!forceInsert && nearestTickIndex === sortedTicks.length - 1) {
|
|
226
|
+
sortedTicks[sortedTicks.length - 1].liquidityDelta += liquidityDelta;
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
sortedTicks.splice(nearestTickIndex === null ? 0 : nearestTickIndex + 1, 0, {
|
|
230
|
+
number: updatedTickNumber,
|
|
231
|
+
liquidityDelta,
|
|
232
|
+
});
|
|
233
|
+
if (state.activeTick >= updatedTickNumber) {
|
|
234
|
+
state.activeTickIndex =
|
|
235
|
+
state.activeTickIndex === null ? 0 : state.activeTickIndex + 1;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
const newDelta = nearestTick.liquidityDelta + liquidityDelta;
|
|
241
|
+
if (newDelta === 0n &&
|
|
242
|
+
!state.checkedTicksBounds.includes(nearestTickNumber)) {
|
|
243
|
+
sortedTicks.splice(nearestTickIndex, 1);
|
|
244
|
+
if (state.activeTick >= updatedTickNumber) {
|
|
245
|
+
state.activeTickIndex--;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
nearestTick.liquidityDelta = newDelta;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
BasePoolState.updateTick = updateTick;
|
|
254
|
+
/*export function computeTvl(state: DeepReadonly<Object>): [bigint, bigint] {
|
|
255
|
+
const stateSqrtRatio = state.sqrtRatio;
|
|
256
|
+
|
|
257
|
+
let [tvl0, tvl1] = [0n, 0n];
|
|
258
|
+
let liquidity = 0n;
|
|
259
|
+
let sqrtRatio = MIN_SQRT_RATIO;
|
|
260
|
+
|
|
261
|
+
for (const tick of state.sortedTicks) {
|
|
262
|
+
const tickSqrtRatio = toSqrtRatio(tick.number);
|
|
263
|
+
|
|
264
|
+
const minAmount1SqrtRatio =
|
|
265
|
+
stateSqrtRatio > tickSqrtRatio ? tickSqrtRatio : stateSqrtRatio;
|
|
266
|
+
const maxAmount0SqrtRatio =
|
|
267
|
+
stateSqrtRatio > sqrtRatio ? stateSqrtRatio : sqrtRatio;
|
|
268
|
+
|
|
269
|
+
if (sqrtRatio < minAmount1SqrtRatio) {
|
|
270
|
+
tvl1 += amount1Delta(sqrtRatio, minAmount1SqrtRatio, liquidity, false);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (maxAmount0SqrtRatio < tickSqrtRatio) {
|
|
274
|
+
tvl0 += amount0Delta(
|
|
275
|
+
maxAmount0SqrtRatio,
|
|
276
|
+
tickSqrtRatio,
|
|
277
|
+
liquidity,
|
|
278
|
+
false,
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
sqrtRatio = tickSqrtRatio;
|
|
283
|
+
liquidity += tick.liquidityDelta;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return [tvl0, tvl1];
|
|
287
|
+
}*/
|
|
288
|
+
})(BasePoolState || (exports.BasePoolState = BasePoolState = {}));
|
|
289
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../src/dex/ekubo/pools/base.ts"],"names":[],"mappings":";;;;;;AA8LA,0EA4BC;AA1ND,oDAAuB;AAKvB,mCAA0E;AAC1E,wCAAqD;AACrD,sCAA6D;AAC7D,sCAKqB;AACrB,mCAAmE;AAEnE,MAAM,uBAAuB,GAAG,MAAM,CAAC;AACvC,MAAM,wCAAwC,GAAG,KAAK,CAAC;AACvD,MAAM,oCAAoC,GAAG,KAAK,CAAC;AAEnD,MAAa,QAAS,SAAQ,iBAA+B;IAC1C,WAAW,CAAC;IAE7B,YACE,UAAkB,EAClB,SAAqB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c,IAAI,cAAc,CAAC;YACvE,CAAC;iBAAM,CAAC;gBACN,WAAW,CAAC,MAAM,CAChB,gBAAgB,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,GAAG,CAAC,EACpD,CAAC,EACD;oBACE,MAAM,EAAE,iBAAiB;oBACzB,cAAc;iBACf,CACF,CAAC;gBAEF,IAAI,KAAK,CAAC,UAAU,IAAI,iBAAiB,EAAE,CAAC;oBAC1C,KAAK,CAAC,eAAe;wBACnB,KAAK,CAAC,eAAe,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,eAAe,GAAG,CAAC,CAAC;gBACnE,CAAC;YACH,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,QAAQ,GAAG,WAAY,CAAC,cAAc,GAAG,cAAc,CAAC;YAE9D,IACE,QAAQ,KAAK,EAAE;gBACf,CAAC,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EACrD,CAAC;gBACD,WAAW,CAAC,MAAM,CAAC,gBAAiB,EAAE,CAAC,CAAC,CAAC;gBAEzC,IAAI,KAAK,CAAC,UAAU,IAAI,iBAAiB,EAAE,CAAC;oBAC1C,KAAK,CAAC,eAAgB,EAAE,CAAC;gBAC3B,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,WAAY,CAAC,cAAc,GAAG,QAAQ,CAAC;YACzC,CAAC;QACH,CAAC;IACH,CAAC;IA1De,wBAAU,aA0DzB,CAAA;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;AACL,CAAC,EA/NgB,aAAa,6BAAb,aAAa,QA+N7B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DeepReadonly } from 'ts-essentials';
|
|
2
|
+
import { IDexHelper } from '../../../dex-helper/idex-helper';
|
|
3
|
+
import { Logger } from '../../../types';
|
|
4
|
+
import { BasicQuoteData, EkuboContracts } from '../types';
|
|
5
|
+
import { EkuboPool, PoolKeyed, Quote, QuoteFn } from './iface';
|
|
6
|
+
import { PoolKey, SwappedEvent } from './utils';
|
|
7
|
+
export declare class FullRangePool extends EkuboPool<FullRangePoolState.Object> {
|
|
8
|
+
private readonly dataFetcher;
|
|
9
|
+
constructor(parentName: string, dexHelper: IDexHelper, logger: Logger, contracts: EkuboContracts, key: PoolKey, quoteFn?: QuoteFn<FullRangePoolState.Object>);
|
|
10
|
+
generateState(blockNumber?: number | 'latest'): Promise<DeepReadonly<FullRangePoolState.Object>>;
|
|
11
|
+
}
|
|
12
|
+
export declare namespace FullRangePoolState {
|
|
13
|
+
type Object = {
|
|
14
|
+
sqrtRatio: bigint;
|
|
15
|
+
liquidity: bigint;
|
|
16
|
+
};
|
|
17
|
+
function fromQuoter(data: BasicQuoteData): DeepReadonly<Object>;
|
|
18
|
+
function fromPositionUpdatedEvent(oldState: DeepReadonly<Object>, liquidityDelta: bigint): Object | null;
|
|
19
|
+
function fromSwappedEvent(ev: SwappedEvent): Object;
|
|
20
|
+
}
|
|
21
|
+
export declare function quote(this: PoolKeyed, amount: bigint, isToken1: boolean, state: DeepReadonly<FullRangePoolState.Object>, sqrtRatioLimit?: bigint): Quote & {
|
|
22
|
+
stateAfter: typeof state;
|
|
23
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
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.FullRangePoolState = exports.FullRangePool = void 0;
|
|
7
|
+
exports.quote = quote;
|
|
8
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
9
|
+
const iface_1 = require("./iface");
|
|
10
|
+
const price_1 = require("./math/price");
|
|
11
|
+
const swap_1 = require("./math/swap");
|
|
12
|
+
const tick_1 = require("./math/tick");
|
|
13
|
+
const utils_1 = require("./utils");
|
|
14
|
+
const GAS_COST_OF_ONE_FULL_RANGE_SWAP = 20_000;
|
|
15
|
+
class FullRangePool extends iface_1.EkuboPool {
|
|
16
|
+
dataFetcher;
|
|
17
|
+
constructor(parentName, dexHelper, logger, contracts, key, quoteFn) {
|
|
18
|
+
const { contract: { address }, interface: iface, dataFetcher, } = contracts.core;
|
|
19
|
+
super(parentName, dexHelper, logger, key, {
|
|
20
|
+
[address]: new iface_1.NamedEventHandlers(iface, {
|
|
21
|
+
PositionUpdated: (args, oldState) => {
|
|
22
|
+
if (key.num_id !== BigInt(args.poolId)) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return FullRangePoolState.fromPositionUpdatedEvent(oldState, args.params.liquidityDelta.toBigInt());
|
|
26
|
+
},
|
|
27
|
+
}),
|
|
28
|
+
}, {
|
|
29
|
+
[address]: data => {
|
|
30
|
+
const ev = (0, utils_1.parseSwappedEvent)(data);
|
|
31
|
+
if (key.num_id !== ev.poolId) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return FullRangePoolState.fromSwappedEvent(ev);
|
|
35
|
+
},
|
|
36
|
+
}, quoteFn ?? quote);
|
|
37
|
+
this.dataFetcher = dataFetcher;
|
|
38
|
+
}
|
|
39
|
+
async generateState(blockNumber) {
|
|
40
|
+
const data = await this.dataFetcher.getQuoteData([this.key.toAbi()], 0, {
|
|
41
|
+
blockTag: blockNumber,
|
|
42
|
+
});
|
|
43
|
+
return FullRangePoolState.fromQuoter(data[0]);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.FullRangePool = FullRangePool;
|
|
47
|
+
var FullRangePoolState;
|
|
48
|
+
(function (FullRangePoolState) {
|
|
49
|
+
function fromQuoter(data) {
|
|
50
|
+
const liquidity = data.liquidity.toBigInt();
|
|
51
|
+
const sqrtRatioFloat = data.sqrtRatio.toBigInt();
|
|
52
|
+
return {
|
|
53
|
+
sqrtRatio: (0, price_1.floatSqrtRatioToFixed)(sqrtRatioFloat),
|
|
54
|
+
liquidity,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
FullRangePoolState.fromQuoter = fromQuoter;
|
|
58
|
+
function fromPositionUpdatedEvent(oldState, liquidityDelta) {
|
|
59
|
+
if (liquidityDelta === 0n) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const clonedState = lodash_1.default.cloneDeep(oldState);
|
|
63
|
+
clonedState.liquidity += liquidityDelta;
|
|
64
|
+
return clonedState;
|
|
65
|
+
}
|
|
66
|
+
FullRangePoolState.fromPositionUpdatedEvent = fromPositionUpdatedEvent;
|
|
67
|
+
function fromSwappedEvent(ev) {
|
|
68
|
+
return {
|
|
69
|
+
liquidity: ev.liquidityAfter,
|
|
70
|
+
sqrtRatio: ev.sqrtRatioAfter,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
FullRangePoolState.fromSwappedEvent = fromSwappedEvent;
|
|
74
|
+
})(FullRangePoolState || (exports.FullRangePoolState = FullRangePoolState = {}));
|
|
75
|
+
function quote(amount, isToken1, state, sqrtRatioLimit) {
|
|
76
|
+
const isIncreasing = (0, swap_1.isPriceIncreasing)(amount, isToken1);
|
|
77
|
+
let sqrtRatio = state.sqrtRatio;
|
|
78
|
+
const liquidity = state.liquidity;
|
|
79
|
+
sqrtRatioLimit ??= isIncreasing ? tick_1.MAX_SQRT_RATIO : tick_1.MIN_SQRT_RATIO;
|
|
80
|
+
const step = (0, swap_1.computeStep)({
|
|
81
|
+
fee: this.key.config.fee,
|
|
82
|
+
sqrtRatio,
|
|
83
|
+
liquidity,
|
|
84
|
+
isToken1,
|
|
85
|
+
sqrtRatioLimit,
|
|
86
|
+
amount,
|
|
87
|
+
});
|
|
88
|
+
return {
|
|
89
|
+
consumedAmount: step.consumedAmount,
|
|
90
|
+
calculatedAmount: step.calculatedAmount,
|
|
91
|
+
gasConsumed: GAS_COST_OF_ONE_FULL_RANGE_SWAP,
|
|
92
|
+
skipAhead: 0,
|
|
93
|
+
stateAfter: {
|
|
94
|
+
sqrtRatio: step.sqrtRatioNext,
|
|
95
|
+
liquidity,
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=full-range.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"full-range.js","sourceRoot":"","sources":["../../../../src/dex/ekubo/pools/full-range.ts"],"names":[],"mappings":";;;;;;AA0HA,sBAiCC;AA3JD,oDAAuB;AAKvB,mCAMiB;AACjB,wCAAqD;AACrD,sCAA6D;AAC7D,sCAA6D;AAC7D,mCAAmE;AAEnE,MAAM,+BAA+B,GAAG,MAAM,CAAC;AAE/C,MAAa,aAAc,SAAQ,iBAAoC;IACpD,WAAW,CAAC;IAE7B,YACE,UAAkB,EAClB,SAAqB,EACrB,MAAc,EACd,SAAyB,EACzB,GAAY,EACZ,OAA4C;QAE5C,MAAM,EACJ,QAAQ,EAAE,EAAE,OAAO,EAAE,EACrB,SAAS,EAAE,KAAK,EAChB,WAAW,GACZ,GAAG,SAAS,CAAC,IAAI,CAAC;QAEnB,KAAK,CACH,UAAU,EACV,SAAS,EACT,MAAM,EACN,GAAG,EACH;YACE,CAAC,OAAO,CAAC,EAAE,IAAI,0BAAkB,CAAC,KAAK,EAAE;gBACvC,eAAe,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE;oBAClC,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;wBACvC,OAAO,IAAI,CAAC;oBACd,CAAC;oBAED,OAAO,kBAAkB,CAAC,wBAAwB,CAChD,QAAQ,EACR,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,CACtC,CAAC;gBACJ,CAAC;aACF,CAAC;SACH,EACD;YACE,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE;gBAChB,MAAM,EAAE,GAAG,IAAA,yBAAiB,EAAC,IAAI,CA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wB,2BAavC,CAAA;IAED,SAAgB,gBAAgB,CAAC,EAAgB;QAC/C,OAAO;YACL,SAAS,EAAE,EAAE,CAAC,cAAc;YAC5B,SAAS,EAAE,EAAE,CAAC,cAAc;SAC7B,CAAC;IACJ,CAAC;IALe,mCAAgB,mBAK/B,CAAA;AACH,CAAC,EAtCgB,kBAAkB,kCAAlB,kBAAkB,QAsClC;AAED,SAAgB,KAAK,CAEnB,MAAc,EACd,QAAiB,EACjB,KAA8C,EAC9C,cAAuB;IAEvB,MAAM,YAAY,GAAG,IAAA,wBAAiB,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAEzD,IAAI,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;IAChC,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;IAElC,cAAc,KAAK,YAAY,CAAC,CAAC,CAAC,qBAAc,CAAC,CAAC,CAAC,qBAAc,CAAC;IAElE,MAAM,IAAI,GAAG,IAAA,kBAAW,EAAC;QACvB,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG;QACxB,SAAS;QACT,SAAS;QACT,QAAQ;QACR,cAAc;QACd,MAAM;KACP,CAAC,CAAC;IAEH,OAAO;QACL,cAAc,EAAE,IAAI,CAAC,cAAc;QACnC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;QACvC,WAAW,EAAE,+BAA+B;QAC5C,SAAS,EAAE,CAAC;QACZ,UAAU,EAAE;YACV,SAAS,EAAE,IAAI,CAAC,aAAa;YAC7B,SAAS;SACV;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Interface, Result } from '@ethersproject/abi';
|
|
2
|
+
import { Logger } from 'log4js';
|
|
3
|
+
import { DeepReadonly } from 'ts-essentials';
|
|
4
|
+
import { IDexHelper } from '../../../dex-helper/idex-helper';
|
|
5
|
+
import { StatefulEventSubscriber } from '../../../stateful-event-subscriber';
|
|
6
|
+
import { BlockHeader, Log } from '../../../types';
|
|
7
|
+
import { PoolKey } from './utils';
|
|
8
|
+
export interface Quote {
|
|
9
|
+
consumedAmount: bigint;
|
|
10
|
+
calculatedAmount: bigint;
|
|
11
|
+
gasConsumed: number;
|
|
12
|
+
skipAhead: number;
|
|
13
|
+
}
|
|
14
|
+
export interface PoolKeyed {
|
|
15
|
+
key: PoolKey;
|
|
16
|
+
}
|
|
17
|
+
export interface IEkuboPool extends PoolKeyed {
|
|
18
|
+
quote(amount: bigint, token: bigint, blockNumber: number): Quote;
|
|
19
|
+
}
|
|
20
|
+
export type QuoteFn<State> = (amount: bigint, isToken1: boolean, state: DeepReadonly<State>) => Quote;
|
|
21
|
+
export type NamedEventHandler<State> = (args: Result, oldState: DeepReadonly<State>, blockHeader: Readonly<BlockHeader>) => DeepReadonly<State> | null;
|
|
22
|
+
export type AnonymousEventHandler<State> = (data: string, oldState: DeepReadonly<State>, blockHeader: Readonly<BlockHeader>) => DeepReadonly<State> | null;
|
|
23
|
+
export declare class NamedEventHandlers<State> {
|
|
24
|
+
private readonly iface;
|
|
25
|
+
private readonly handlers;
|
|
26
|
+
constructor(iface: Interface, handlers: Record<string, NamedEventHandler<State>>);
|
|
27
|
+
parseLog(log: Readonly<Log>, oldState: DeepReadonly<State>, blockHeader: Readonly<BlockHeader>): DeepReadonly<State> | null;
|
|
28
|
+
}
|
|
29
|
+
export declare abstract class EkuboPool<State> extends StatefulEventSubscriber<State> implements IEkuboPool {
|
|
30
|
+
readonly key: PoolKey;
|
|
31
|
+
private readonly namedEventHandlers;
|
|
32
|
+
private readonly anonymousEventHandlers;
|
|
33
|
+
private readonly quoteFn;
|
|
34
|
+
protected constructor(parentName: string, dexHelper: IDexHelper, logger: Logger, key: PoolKey, namedEventHandlers: Record<string, NamedEventHandlers<State>>, anonymousEventHandlers: Record<string, AnonymousEventHandler<State>>, quoteFn: QuoteFn<State>);
|
|
35
|
+
/**
|
|
36
|
+
* The function is called every time any of the subscribed
|
|
37
|
+
* addresses release log. The function accepts the current
|
|
38
|
+
* state, updates the state according to the log, and returns
|
|
39
|
+
* the updated state.
|
|
40
|
+
* @param state - Current state of event subscriber
|
|
41
|
+
* @param log - Log released by one of the subscribed addresses
|
|
42
|
+
* @returns Updates state of the event subscriber after the log
|
|
43
|
+
*/
|
|
44
|
+
protected processLog(state: DeepReadonly<State>, log: Readonly<Log>, blockHeader: Readonly<BlockHeader>): DeepReadonly<State> | null;
|
|
45
|
+
quote(amount: bigint, token: bigint, blockNumber: number): Quote;
|
|
46
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EkuboPool = exports.NamedEventHandlers = void 0;
|
|
4
|
+
const stateful_event_subscriber_1 = require("../../../stateful-event-subscriber");
|
|
5
|
+
class NamedEventHandlers {
|
|
6
|
+
iface;
|
|
7
|
+
handlers;
|
|
8
|
+
constructor(iface, handlers) {
|
|
9
|
+
this.iface = iface;
|
|
10
|
+
this.handlers = handlers;
|
|
11
|
+
}
|
|
12
|
+
parseLog(log, oldState, blockHeader) {
|
|
13
|
+
const event = this.iface.parseLog(log);
|
|
14
|
+
return this.handlers[event.name]?.(event.args, oldState, blockHeader);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.NamedEventHandlers = NamedEventHandlers;
|
|
18
|
+
const BASE_GAS_COST = 22_000;
|
|
19
|
+
class EkuboPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
|
|
20
|
+
key;
|
|
21
|
+
namedEventHandlers;
|
|
22
|
+
anonymousEventHandlers;
|
|
23
|
+
quoteFn;
|
|
24
|
+
constructor(parentName, dexHelper, logger, key, namedEventHandlers, anonymousEventHandlers, quoteFn) {
|
|
25
|
+
super(parentName, key.string_id, dexHelper, logger);
|
|
26
|
+
this.key = key;
|
|
27
|
+
this.namedEventHandlers = namedEventHandlers;
|
|
28
|
+
this.anonymousEventHandlers = anonymousEventHandlers;
|
|
29
|
+
this.quoteFn = quoteFn;
|
|
30
|
+
this.addressesSubscribed = [
|
|
31
|
+
...new Set(Object.keys(namedEventHandlers).concat(Object.keys(anonymousEventHandlers))),
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The function is called every time any of the subscribed
|
|
36
|
+
* addresses release log. The function accepts the current
|
|
37
|
+
* state, updates the state according to the log, and returns
|
|
38
|
+
* the updated state.
|
|
39
|
+
* @param state - Current state of event subscriber
|
|
40
|
+
* @param log - Log released by one of the subscribed addresses
|
|
41
|
+
* @returns Updates state of the event subscriber after the log
|
|
42
|
+
*/
|
|
43
|
+
processLog(state, log, blockHeader) {
|
|
44
|
+
const emitter = log.address;
|
|
45
|
+
if (log.topics.length === 0) {
|
|
46
|
+
return this.anonymousEventHandlers[emitter]?.(log.data, state, blockHeader);
|
|
47
|
+
}
|
|
48
|
+
return this.namedEventHandlers[emitter]?.parseLog(log, state, blockHeader);
|
|
49
|
+
}
|
|
50
|
+
quote(amount, token, blockNumber) {
|
|
51
|
+
const isToken1 = token === this.key.token1;
|
|
52
|
+
if (!isToken1 && this.key.token0 !== token) {
|
|
53
|
+
throw new Error('Invalid token');
|
|
54
|
+
}
|
|
55
|
+
if (amount === 0n) {
|
|
56
|
+
return {
|
|
57
|
+
consumedAmount: 0n,
|
|
58
|
+
calculatedAmount: 0n,
|
|
59
|
+
gasConsumed: 0,
|
|
60
|
+
skipAhead: 0,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const state = this.getState(blockNumber);
|
|
64
|
+
if (state === null) {
|
|
65
|
+
throw new Error(`Quote for block number ${blockNumber} requested but state is not recent enough`);
|
|
66
|
+
}
|
|
67
|
+
const quote = this.quoteFn(amount, isToken1, state);
|
|
68
|
+
if (quote.calculatedAmount !== 0n) {
|
|
69
|
+
quote.gasConsumed += BASE_GAS_COST;
|
|
70
|
+
}
|
|
71
|
+
return quote;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.EkuboPool = EkuboPool;
|
|
75
|
+
//# sourceMappingURL=iface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iface.js","sourceRoot":"","sources":["../../../../src/dex/ekubo/pools/iface.ts"],"names":[],"mappings":";;;AAIA,kFAA6E;AAoC7E,MAAa,kBAAkB;IAEV;IACA;IAFnB,YACmB,KAAgB,EAChB,QAAkD;QADlD,UAAK,GAAL,KAAK,CAAW;QAChB,aAAQ,GAAR,QAAQ,CAA0C;IAClE,CAAC;IAEG,QAAQ,CACb,GAAkB,EAClB,QAA6B,EAC7B,WAAkC;QAElC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACvC,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;IACxE,CAAC;CACF;AAdD,gDAcC;AAED,MAAM,aAAa,GAAG,MAAM,CAAC;AAE7B,MAAsB,SACpB,SAAQ,mDAA8B;IAOpB;IACC;IAIA;IAIA;IAbnB,YACE,UAAkB,EAClB,SAAqB,EACrB,MAAc,EACE,GAAY,EACX,kBAGhB,EACgB,sBAGhB,EACgB,OAAuB;QAExC,KAAK,CAAC,UAAU,EAAE,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QAXpC,QAAG,GAAH,GAAG,CAAS;QACX,uBAAkB,GAAlB,kBAAkB,CAGlC;QACgB,2BAAsB,GAAtB,sBAAsB,CAGtC;QACgB,YAAO,GAAP,OAAO,CAAgB;QAIxC,IAAI,CAAC,mBAAmB,GAAG;YACzB,GAAG,IAAI,GAAG,CACR,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,MAAM,CACpC,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CACpC,CACF;SACF,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG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