@paraswap/dex-lib 2.42.22 → 2.42.23
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/hashflow/HashflowRouter.abi.json +816 -246
- package/build/abi/kyberswap-elastic/IAntiSnipAttackPositionManager.json +1276 -0
- package/build/abi/kyberswap-elastic/IFactory.json +550 -0
- package/build/abi/kyberswap-elastic/IPool.json +1042 -0
- package/build/abi/kyberswap-elastic/IQuoterV2.json +226 -0
- package/build/abi/kyberswap-elastic/IRouter.json +239 -0
- package/build/abi/kyberswap-elastic/TicksFeesReader.json +142 -0
- package/build/abi/wombat/asset.json +769 -0
- package/build/abi/wombat/bmw.json +1247 -0
- package/build/abi/wombat/pool.json +1364 -0
- package/build/config.js +14 -14
- package/build/dex/baseswap-v3/baseswap-v3-factory.d.ts +26 -0
- package/build/dex/baseswap-v3/baseswap-v3-factory.js +44 -0
- package/build/dex/baseswap-v3/baseswap-v3-factory.js.map +1 -0
- package/build/dex/baseswap-v3/baseswap-v3-pool.d.ts +46 -0
- package/build/dex/baseswap-v3/baseswap-v3-pool.js +312 -0
- package/build/dex/baseswap-v3/baseswap-v3-pool.js.map +1 -0
- package/build/dex/baseswap-v3/baseswap-v3.d.ts +71 -0
- package/build/dex/baseswap-v3/baseswap-v3.js +752 -0
- package/build/dex/baseswap-v3/baseswap-v3.js.map +1 -0
- package/build/dex/baseswap-v3/config.d.ts +9 -0
- package/build/dex/baseswap-v3/config.js +48 -0
- package/build/dex/baseswap-v3/config.js.map +1 -0
- package/build/dex/baseswap-v3/constants.d.ts +28 -0
- package/build/dex/baseswap-v3/constants.js +35 -0
- package/build/dex/baseswap-v3/constants.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/BitMath.d.ts +4 -0
- package/build/dex/baseswap-v3/contract-math/BitMath.js +93 -0
- package/build/dex/baseswap-v3/contract-math/BitMath.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/FixedPoint128.d.ts +3 -0
- package/build/dex/baseswap-v3/contract-math/FixedPoint128.js +8 -0
- package/build/dex/baseswap-v3/contract-math/FixedPoint128.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/FixedPoint96.d.ts +4 -0
- package/build/dex/baseswap-v3/contract-math/FixedPoint96.js +9 -0
- package/build/dex/baseswap-v3/contract-math/FixedPoint96.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/FullMath.d.ts +4 -0
- package/build/dex/baseswap-v3/contract-math/FullMath.js +19 -0
- package/build/dex/baseswap-v3/contract-math/FullMath.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/LiquidityMath.d.ts +3 -0
- package/build/dex/baseswap-v3/contract-math/LiquidityMath.js +22 -0
- package/build/dex/baseswap-v3/contract-math/LiquidityMath.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/Oracle.d.ts +10 -0
- package/build/dex/baseswap-v3/contract-math/Oracle.js +133 -0
- package/build/dex/baseswap-v3/contract-math/Oracle.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/SqrtPriceMath.d.ts +10 -0
- package/build/dex/baseswap-v3/contract-math/SqrtPriceMath.js +91 -0
- package/build/dex/baseswap-v3/contract-math/SqrtPriceMath.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/SwapMath.d.ts +8 -0
- package/build/dex/baseswap-v3/contract-math/SwapMath.js +70 -0
- package/build/dex/baseswap-v3/contract-math/SwapMath.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/Tick.d.ts +7 -0
- package/build/dex/baseswap-v3/contract-math/Tick.js +45 -0
- package/build/dex/baseswap-v3/contract-math/Tick.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/TickBitMap.d.ts +7 -0
- package/build/dex/baseswap-v3/contract-math/TickBitMap.js +84 -0
- package/build/dex/baseswap-v3/contract-math/TickBitMap.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/TickMath.d.ts +8 -0
- package/build/dex/baseswap-v3/contract-math/TickMath.js +162 -0
- package/build/dex/baseswap-v3/contract-math/TickMath.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/UnsafeMath.d.ts +3 -0
- package/build/dex/baseswap-v3/contract-math/UnsafeMath.js +10 -0
- package/build/dex/baseswap-v3/contract-math/UnsafeMath.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/uniswap-v3-math.d.ts +37 -0
- package/build/dex/baseswap-v3/contract-math/uniswap-v3-math.js +393 -0
- package/build/dex/baseswap-v3/contract-math/uniswap-v3-math.js.map +1 -0
- package/build/dex/baseswap-v3/contract-math/utils.d.ts +7 -0
- package/build/dex/baseswap-v3/contract-math/utils.js +42 -0
- package/build/dex/baseswap-v3/contract-math/utils.js.map +1 -0
- package/build/dex/baseswap-v3/types.d.ts +164 -0
- package/build/dex/baseswap-v3/types.js +9 -0
- package/build/dex/baseswap-v3/types.js.map +1 -0
- package/build/dex/baseswap-v3/utils.d.ts +6 -0
- package/build/dex/baseswap-v3/utils.js +65 -0
- package/build/dex/baseswap-v3/utils.js.map +1 -0
- package/build/dex/hashflow/config.d.ts +1 -1
- package/build/dex/hashflow/config.js +6 -6
- package/build/dex/hashflow/config.js.map +1 -1
- package/build/dex/hashflow/hashflow.d.ts +7 -7
- package/build/dex/hashflow/hashflow.js +47 -54
- package/build/dex/hashflow/hashflow.js.map +1 -1
- package/build/dex/hashflow/rate-fetcher.d.ts +1 -1
- package/build/dex/hashflow/rate-fetcher.js +2 -4
- package/build/dex/hashflow/rate-fetcher.js.map +1 -1
- package/build/dex/hashflow/types.d.ts +5 -6
- package/build/dex/hashflow/types.js.map +1 -1
- package/build/dex/hashflow/validators.js +11 -4
- package/build/dex/hashflow/validators.js.map +1 -1
- package/build/dex/hello/config.d.ts +4 -0
- package/build/dex/hello/config.js +15 -0
- package/build/dex/hello/config.js.map +1 -0
- package/build/dex/hello/hello-pool.d.ts +39 -0
- package/build/dex/hello/hello-pool.js +64 -0
- package/build/dex/hello/hello-pool.js.map +1 -0
- package/build/dex/hello/hello.d.ts +37 -0
- package/build/dex/hello/hello.js +126 -0
- package/build/dex/hello/hello.js.map +1 -0
- package/build/dex/hello/types.d.ts +6 -0
- package/build/dex/hello/types.js +3 -0
- package/build/dex/hello/types.js.map +1 -0
- package/build/dex/kyberswap-elastic/config.d.ts +4 -0
- package/build/dex/kyberswap-elastic/config.js +80 -0
- package/build/dex/kyberswap-elastic/config.js.map +1 -0
- package/build/dex/kyberswap-elastic/constants.d.ts +17 -0
- package/build/dex/kyberswap-elastic/constants.js +42 -0
- package/build/dex/kyberswap-elastic/constants.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/FixedPoint96.d.ts +4 -0
- package/build/dex/kyberswap-elastic/contract-math/FixedPoint96.js +9 -0
- package/build/dex/kyberswap-elastic/contract-math/FixedPoint96.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/FullMath.d.ts +5 -0
- package/build/dex/kyberswap-elastic/contract-math/FullMath.js +22 -0
- package/build/dex/kyberswap-elastic/contract-math/FullMath.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/LiqDeltaMath.d.ts +3 -0
- package/build/dex/kyberswap-elastic/contract-math/LiqDeltaMath.js +12 -0
- package/build/dex/kyberswap-elastic/contract-math/LiqDeltaMath.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/LiquidityMath.d.ts +3 -0
- package/build/dex/kyberswap-elastic/contract-math/LiquidityMath.js +22 -0
- package/build/dex/kyberswap-elastic/contract-math/LiquidityMath.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/QtyDeltaMath.d.ts +5 -0
- package/build/dex/kyberswap-elastic/contract-math/QtyDeltaMath.js +25 -0
- package/build/dex/kyberswap-elastic/contract-math/QtyDeltaMath.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/QuadMath.d.ts +4 -0
- package/build/dex/kyberswap-elastic/contract-math/QuadMath.js +27 -0
- package/build/dex/kyberswap-elastic/contract-math/QuadMath.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/ReinvestmentMath.d.ts +3 -0
- package/build/dex/kyberswap-elastic/contract-math/ReinvestmentMath.js +14 -0
- package/build/dex/kyberswap-elastic/contract-math/ReinvestmentMath.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/SafeCast.d.ts +8 -0
- package/build/dex/kyberswap-elastic/contract-math/SafeCast.js +30 -0
- package/build/dex/kyberswap-elastic/contract-math/SafeCast.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/SqrtPriceMath.d.ts +10 -0
- package/build/dex/kyberswap-elastic/contract-math/SqrtPriceMath.js +91 -0
- package/build/dex/kyberswap-elastic/contract-math/SqrtPriceMath.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/SwapMath.d.ts +13 -0
- package/build/dex/kyberswap-elastic/contract-math/SwapMath.js +188 -0
- package/build/dex/kyberswap-elastic/contract-math/SwapMath.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/TickLinkedList.d.ts +6 -0
- package/build/dex/kyberswap-elastic/contract-math/TickLinkedList.js +41 -0
- package/build/dex/kyberswap-elastic/contract-math/TickLinkedList.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/TickMath.d.ts +9 -0
- package/build/dex/kyberswap-elastic/contract-math/TickMath.js +165 -0
- package/build/dex/kyberswap-elastic/contract-math/TickMath.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/UnsafeMath.d.ts +3 -0
- package/build/dex/kyberswap-elastic/contract-math/UnsafeMath.js +10 -0
- package/build/dex/kyberswap-elastic/contract-math/UnsafeMath.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/kyberswap-elastic-math.d.ts +28 -0
- package/build/dex/kyberswap-elastic/contract-math/kyberswap-elastic-math.js +502 -0
- package/build/dex/kyberswap-elastic/contract-math/kyberswap-elastic-math.js.map +1 -0
- package/build/dex/kyberswap-elastic/contract-math/utils.d.ts +3 -0
- package/build/dex/kyberswap-elastic/contract-math/utils.js +16 -0
- package/build/dex/kyberswap-elastic/contract-math/utils.js.map +1 -0
- package/build/dex/kyberswap-elastic/errors.d.ts +2 -0
- package/build/dex/kyberswap-elastic/errors.js +6 -0
- package/build/dex/kyberswap-elastic/errors.js.map +1 -0
- package/build/dex/kyberswap-elastic/kyberswap-elastic-pool.d.ts +80 -0
- package/build/dex/kyberswap-elastic/kyberswap-elastic-pool.js +458 -0
- package/build/dex/kyberswap-elastic/kyberswap-elastic-pool.js.map +1 -0
- package/build/dex/kyberswap-elastic/kyberswap-elastic.d.ts +53 -0
- package/build/dex/kyberswap-elastic/kyberswap-elastic.js +610 -0
- package/build/dex/kyberswap-elastic/kyberswap-elastic.js.map +1 -0
- package/build/dex/kyberswap-elastic/types.d.ts +134 -0
- package/build/dex/kyberswap-elastic/types.js +9 -0
- package/build/dex/kyberswap-elastic/types.js.map +1 -0
- package/build/dex/kyberswap-elastic/utils/decoders.d.ts +9 -0
- package/build/dex/kyberswap-elastic/utils/decoders.js +78 -0
- package/build/dex/kyberswap-elastic/utils/decoders.js.map +1 -0
- package/build/dex/morphex/config.d.ts +11 -0
- package/build/dex/morphex/config.js +43 -0
- package/build/dex/morphex/config.js.map +1 -0
- package/build/dex/morphex/morphex.d.ts +25 -0
- package/build/dex/morphex/morphex.js +19 -0
- package/build/dex/morphex/morphex.js.map +1 -0
- package/build/dex/my-test-dex/config.d.ts +4 -0
- package/build/dex/my-test-dex/config.js +15 -0
- package/build/dex/my-test-dex/config.js.map +1 -0
- package/build/dex/my-test-dex/my-test-dex-pool.d.ts +39 -0
- package/build/dex/my-test-dex/my-test-dex-pool.js +64 -0
- package/build/dex/my-test-dex/my-test-dex-pool.js.map +1 -0
- package/build/dex/my-test-dex/my-test-dex.d.ts +37 -0
- package/build/dex/my-test-dex/my-test-dex.js +126 -0
- package/build/dex/my-test-dex/my-test-dex.js.map +1 -0
- package/build/dex/my-test-dex/types.d.ts +6 -0
- package/build/dex/my-test-dex/types.js +3 -0
- package/build/dex/my-test-dex/types.js.map +1 -0
- package/build/dex/solidly/forks-override/fvm.d.ts +20 -0
- package/build/dex/solidly/forks-override/fvm.js +42 -0
- package/build/dex/solidly/forks-override/fvm.js.map +1 -0
- package/build/dex/wombat/config.d.ts +4 -0
- package/build/dex/wombat/config.js +99 -0
- package/build/dex/wombat/config.js.map +1 -0
- package/build/dex/wombat/types.d.ts +33 -0
- package/build/dex/wombat/types.js +3 -0
- package/build/dex/wombat/types.js.map +1 -0
- package/build/dex/wombat/utils.d.ts +9 -0
- package/build/dex/wombat/utils.js +66 -0
- package/build/dex/wombat/utils.js.map +1 -0
- package/build/dex/wombat/wombat-bmw.d.ts +40 -0
- package/build/dex/wombat/wombat-bmw.js +147 -0
- package/build/dex/wombat/wombat-bmw.js.map +1 -0
- package/build/dex/wombat/wombat-pool.d.ts +22 -0
- package/build/dex/wombat/wombat-pool.js +161 -0
- package/build/dex/wombat/wombat-pool.js.map +1 -0
- package/build/dex/wombat/wombat-quoter.d.ts +16 -0
- package/build/dex/wombat/wombat-quoter.js +176 -0
- package/build/dex/wombat/wombat-quoter.js.map +1 -0
- package/build/dex/wombat/wombat.d.ts +55 -0
- package/build/dex/wombat/wombat.js +290 -0
- package/build/dex/wombat/wombat.js.map +1 -0
- package/build/lib/fetcher/fetcher.d.ts +1 -1
- package/build/lib/fetcher/fetcher.js.map +1 -1
- package/package.json +2 -2
- package/src/abi/hashflow/HashflowRouter.abi.json +816 -246
- package/src/config.ts +14 -14
- package/src/dex/hashflow/config.ts +8 -8
- package/src/dex/hashflow/hashflow-e2e.test.ts +4 -4
- package/src/dex/hashflow/hashflow-integration.test.ts +9 -6
- package/src/dex/hashflow/hashflow.ts +70 -87
- package/src/dex/hashflow/rate-fetcher.ts +6 -8
- package/src/dex/hashflow/types.ts +5 -6
- package/src/dex/hashflow/validators.ts +11 -4
- package/src/lib/fetcher/fetcher.ts +2 -2
- package/tests/constants-e2e.ts +1 -1
- package/tests/tenderly-simulation.ts +5 -2
- package/.vscode/launch.json +0 -39
- package/.vscode/settings.json +0 -2
- package/.vscode/tasks.json +0 -15
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { DeepReadonly } from 'ts-essentials';
|
|
3
|
+
import { Log, Logger } from '../../types';
|
|
4
|
+
import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
|
|
5
|
+
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
6
|
+
import { PoolState } from './types';
|
|
7
|
+
export declare class HelloEventPool extends StatefulEventSubscriber<PoolState> {
|
|
8
|
+
readonly parentName: string;
|
|
9
|
+
protected network: number;
|
|
10
|
+
protected dexHelper: IDexHelper;
|
|
11
|
+
protected helloIface: Interface;
|
|
12
|
+
handlers: {
|
|
13
|
+
[event: string]: (event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>) => DeepReadonly<PoolState> | null;
|
|
14
|
+
};
|
|
15
|
+
logDecoder: (log: Log) => any;
|
|
16
|
+
addressesSubscribed: string[];
|
|
17
|
+
constructor(parentName: string, network: number, dexHelper: IDexHelper, logger: Logger, helloIface?: Interface);
|
|
18
|
+
/**
|
|
19
|
+
* The function is called every time any of the subscribed
|
|
20
|
+
* addresses release log. The function accepts the current
|
|
21
|
+
* state, updates the state according to the log, and returns
|
|
22
|
+
* the updated state.
|
|
23
|
+
* @param state - Current state of event subscriber
|
|
24
|
+
* @param log - Log released by one of the subscribed addresses
|
|
25
|
+
* @returns Updates state of the event subscriber after the log
|
|
26
|
+
*/
|
|
27
|
+
protected processLog(state: DeepReadonly<PoolState>, log: Readonly<Log>): DeepReadonly<PoolState> | null;
|
|
28
|
+
/**
|
|
29
|
+
* The function generates state using on-chain calls. This
|
|
30
|
+
* function is called to regenerate state if the event based
|
|
31
|
+
* system fails to fetch events and the local state is no
|
|
32
|
+
* more correct.
|
|
33
|
+
* @param blockNumber - Blocknumber for which the state should
|
|
34
|
+
* should be generated
|
|
35
|
+
* @returns state of the event subscriber at blocknumber
|
|
36
|
+
*/
|
|
37
|
+
generateState(blockNumber: number): Promise<DeepReadonly<PoolState>>;
|
|
38
|
+
handleMyEvent(event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>): DeepReadonly<PoolState> | null;
|
|
39
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HelloEventPool = void 0;
|
|
4
|
+
const abi_1 = require("@ethersproject/abi");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
|
|
7
|
+
class HelloEventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
|
|
8
|
+
constructor(parentName, network, dexHelper, logger, helloIface = new abi_1.Interface('' /* TODO: Import and put here Hello ABI */)) {
|
|
9
|
+
// TODO: Add pool name
|
|
10
|
+
super(parentName, 'POOL_NAME', dexHelper, logger);
|
|
11
|
+
this.parentName = parentName;
|
|
12
|
+
this.network = network;
|
|
13
|
+
this.dexHelper = dexHelper;
|
|
14
|
+
this.helloIface = helloIface;
|
|
15
|
+
this.handlers = {};
|
|
16
|
+
// TODO: make logDecoder decode logs that
|
|
17
|
+
this.logDecoder = (log) => this.helloIface.parseLog(log);
|
|
18
|
+
this.addressesSubscribed = [
|
|
19
|
+
/* subscribed addresses */
|
|
20
|
+
];
|
|
21
|
+
// Add handlers
|
|
22
|
+
this.handlers['myEvent'] = this.handleMyEvent.bind(this);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The function is called every time any of the subscribed
|
|
26
|
+
* addresses release log. The function accepts the current
|
|
27
|
+
* state, updates the state according to the log, and returns
|
|
28
|
+
* the updated state.
|
|
29
|
+
* @param state - Current state of event subscriber
|
|
30
|
+
* @param log - Log released by one of the subscribed addresses
|
|
31
|
+
* @returns Updates state of the event subscriber after the log
|
|
32
|
+
*/
|
|
33
|
+
processLog(state, log) {
|
|
34
|
+
try {
|
|
35
|
+
const event = this.logDecoder(log);
|
|
36
|
+
if (event.name in this.handlers) {
|
|
37
|
+
return this.handlers[event.name](event, state, log);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
(0, utils_1.catchParseLogError)(e, this.logger);
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The function generates state using on-chain calls. This
|
|
47
|
+
* function is called to regenerate state if the event based
|
|
48
|
+
* system fails to fetch events and the local state is no
|
|
49
|
+
* more correct.
|
|
50
|
+
* @param blockNumber - Blocknumber for which the state should
|
|
51
|
+
* should be generated
|
|
52
|
+
* @returns state of the event subscriber at blocknumber
|
|
53
|
+
*/
|
|
54
|
+
async generateState(blockNumber) {
|
|
55
|
+
// TODO: complete me!
|
|
56
|
+
return {};
|
|
57
|
+
}
|
|
58
|
+
// Its just a dummy example
|
|
59
|
+
handleMyEvent(event, state, log) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.HelloEventPool = HelloEventPool;
|
|
64
|
+
//# sourceMappingURL=hello-pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hello-pool.js","sourceRoot":"","sources":["../../../src/dex/hello/hello-pool.ts"],"names":[],"mappings":";;;AAAA,4CAA+C;AAG/C,uCAAiD;AACjD,+EAA0E;AAI1E,MAAa,cAAe,SAAQ,mDAAkC;IAapE,YACW,UAAkB,EACjB,OAAe,EACf,SAAqB,EAC/B,MAAc,EACJ,aAAa,IAAI,eAAS,CAClC,EAAE,CAAC,yCAAyC,CAC7C;QAED,sBAAsB;QACtB,KAAK,CAAC,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QATzC,eAAU,GAAV,UAAU,CAAQ;QACjB,YAAO,GAAP,OAAO,CAAQ;QACf,cAAS,GAAT,SAAS,CAAY;QAErB,eAAU,GAAV,UAAU,CAEnB;QAnBH,aAAQ,GAMJ,EAAE,CAAC;QAkBL,yCAAyC;QACzC,IAAI,CAAC,UAAU,GAAG,CAAC,GAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC9D,IAAI,CAAC,mBAAmB,GAAG;QACzB,0BAA0B;SAC3B,CAAC;QAEF,eAAe;QACf,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;;;;OAQG;IACO,UAAU,CAClB,KAA8B,EAC9B,GAAkB;QAElB,IAAI;YACF,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YACnC,IAAI,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE;gBAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;aACrD;SACF;QAAC,OAAO,CAAC,EAAE;YACV,IAAA,0BAAkB,EAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;SACpC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,aAAa,CAAC,WAAmB;QACrC,qBAAqB;QACrB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,2BAA2B;IAC3B,aAAa,CACX,KAAU,EACV,KAA8B,EAC9B,GAAkB;QAElB,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAlFD,wCAkFC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AsyncOrSync } from 'ts-essentials';
|
|
2
|
+
import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, SimpleExchangeParam, PoolLiquidity, Logger } from '../../types';
|
|
3
|
+
import { SwapSide, Network } from '../../constants';
|
|
4
|
+
import { IDex } from '../../dex/idex';
|
|
5
|
+
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
6
|
+
import { HelloData } from './types';
|
|
7
|
+
import { SimpleExchange } from '../simple-exchange';
|
|
8
|
+
import { HelloEventPool } from './hello-pool';
|
|
9
|
+
export declare class Hello extends SimpleExchange implements IDex<HelloData> {
|
|
10
|
+
readonly network: Network;
|
|
11
|
+
readonly dexKey: string;
|
|
12
|
+
readonly dexHelper: IDexHelper;
|
|
13
|
+
protected adapters: import("../../types").AdapterMappings;
|
|
14
|
+
protected eventPools: HelloEventPool;
|
|
15
|
+
readonly hasConstantPriceLargeAmounts = false;
|
|
16
|
+
readonly needWrapNative = true;
|
|
17
|
+
readonly isFeeOnTransferSupported = false;
|
|
18
|
+
static dexKeysWithNetwork: {
|
|
19
|
+
key: string;
|
|
20
|
+
networks: Network[];
|
|
21
|
+
}[];
|
|
22
|
+
logger: Logger;
|
|
23
|
+
constructor(network: Network, dexKey: string, dexHelper: IDexHelper, adapters?: import("../../types").AdapterMappings);
|
|
24
|
+
initializePricing(blockNumber: number): Promise<void>;
|
|
25
|
+
getAdapters(side: SwapSide): {
|
|
26
|
+
name: string;
|
|
27
|
+
index: number;
|
|
28
|
+
}[] | null;
|
|
29
|
+
getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
|
|
30
|
+
getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<HelloData>>;
|
|
31
|
+
getCalldataGasCost(poolPrices: PoolPrices<HelloData>): number | number[];
|
|
32
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: HelloData, side: SwapSide): AdapterExchangeParam;
|
|
33
|
+
getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: HelloData, side: SwapSide): Promise<SimpleExchangeParam>;
|
|
34
|
+
updatePoolState(): Promise<void>;
|
|
35
|
+
getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
|
|
36
|
+
releaseResources(): AsyncOrSync<void>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.Hello = void 0;
|
|
27
|
+
const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
|
|
28
|
+
const utils_1 = require("../../utils");
|
|
29
|
+
const simple_exchange_1 = require("../simple-exchange");
|
|
30
|
+
const config_1 = require("./config");
|
|
31
|
+
const hello_pool_1 = require("./hello-pool");
|
|
32
|
+
class Hello extends simple_exchange_1.SimpleExchange {
|
|
33
|
+
constructor(network, dexKey, dexHelper, adapters = config_1.Adapters[network] || {}) {
|
|
34
|
+
super(dexHelper, dexKey);
|
|
35
|
+
this.network = network;
|
|
36
|
+
this.dexKey = dexKey;
|
|
37
|
+
this.dexHelper = dexHelper;
|
|
38
|
+
this.adapters = adapters;
|
|
39
|
+
this.hasConstantPriceLargeAmounts = false;
|
|
40
|
+
// TODO: set true here if protocols works only with wrapped asset
|
|
41
|
+
this.needWrapNative = true;
|
|
42
|
+
this.isFeeOnTransferSupported = false;
|
|
43
|
+
this.logger = dexHelper.getLogger(dexKey);
|
|
44
|
+
this.eventPools = new hello_pool_1.HelloEventPool(dexKey, network, dexHelper, this.logger);
|
|
45
|
+
}
|
|
46
|
+
// Initialize pricing is called once in the start of
|
|
47
|
+
// pricing service. It is intended to setup the integration
|
|
48
|
+
// for pricing requests. It is optional for a DEX to
|
|
49
|
+
// implement this function
|
|
50
|
+
async initializePricing(blockNumber) {
|
|
51
|
+
// TODO: complete me!
|
|
52
|
+
}
|
|
53
|
+
// Returns the list of contract adapters (name and index)
|
|
54
|
+
// for a buy/sell. Return null if there are no adapters.
|
|
55
|
+
getAdapters(side) {
|
|
56
|
+
return this.adapters[side] ? this.adapters[side] : null;
|
|
57
|
+
}
|
|
58
|
+
// Returns list of pool identifiers that can be used
|
|
59
|
+
// for a given swap. poolIdentifiers must be unique
|
|
60
|
+
// across DEXes. It is recommended to use
|
|
61
|
+
// ${dexKey}_${poolAddress} as a poolIdentifier
|
|
62
|
+
async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
|
|
63
|
+
// TODO: complete me!
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
// Returns pool prices for amounts.
|
|
67
|
+
// If limitPools is defined only pools in limitPools
|
|
68
|
+
// should be used. If limitPools is undefined then
|
|
69
|
+
// any pools can be used.
|
|
70
|
+
async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
|
|
71
|
+
// TODO: complete me!
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
// Returns estimated gas cost of calldata for this DEX in multiSwap
|
|
75
|
+
getCalldataGasCost(poolPrices) {
|
|
76
|
+
// TODO: update if there is any payload in getAdapterParam
|
|
77
|
+
return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
|
|
78
|
+
}
|
|
79
|
+
// Encode params required by the exchange adapter
|
|
80
|
+
// Used for multiSwap, buy & megaSwap
|
|
81
|
+
// Hint: abiCoder.encodeParameter() could be useful
|
|
82
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
83
|
+
// TODO: complete me!
|
|
84
|
+
const { exchange } = data;
|
|
85
|
+
// Encode here the payload for adapter
|
|
86
|
+
const payload = '';
|
|
87
|
+
return {
|
|
88
|
+
targetExchange: exchange,
|
|
89
|
+
payload,
|
|
90
|
+
networkFee: '0',
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
// Encode call data used by simpleSwap like routers
|
|
94
|
+
// Used for simpleSwap & simpleBuy
|
|
95
|
+
// Hint: this.buildSimpleParamWithoutWETHConversion
|
|
96
|
+
// could be useful
|
|
97
|
+
async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
98
|
+
// TODO: complete me!
|
|
99
|
+
const { exchange } = data;
|
|
100
|
+
// Encode here the transaction arguments
|
|
101
|
+
const swapData = '';
|
|
102
|
+
return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, exchange);
|
|
103
|
+
}
|
|
104
|
+
// This is called once before getTopPoolsForToken is
|
|
105
|
+
// called for multiple tokens. This can be helpful to
|
|
106
|
+
// update common state required for calculating
|
|
107
|
+
// getTopPoolsForToken. It is optional for a DEX
|
|
108
|
+
// to implement this
|
|
109
|
+
async updatePoolState() {
|
|
110
|
+
// TODO: complete me!
|
|
111
|
+
}
|
|
112
|
+
// Returns list of top pools based on liquidity. Max
|
|
113
|
+
// limit number pools should be returned.
|
|
114
|
+
async getTopPoolsForToken(tokenAddress, limit) {
|
|
115
|
+
//TODO: complete me!
|
|
116
|
+
return [];
|
|
117
|
+
}
|
|
118
|
+
// This is optional function in case if your implementation has acquired any resources
|
|
119
|
+
// you need to release for graceful shutdown. For example, it may be any interval timer
|
|
120
|
+
releaseResources() {
|
|
121
|
+
// TODO: complete me!
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.Hello = Hello;
|
|
125
|
+
Hello.dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.HelloConfig);
|
|
126
|
+
//# sourceMappingURL=hello.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hello.js","sourceRoot":"","sources":["../../../src/dex/hello/hello.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/hello/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Adapters = exports.KyberswapElasticConfig = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
const constants_2 = require("./constants");
|
|
6
|
+
const SUBGRAPH_BASE_URL = 'https://api.thegraph.com/subgraphs/name/kybernetwork';
|
|
7
|
+
const KS_ELASTIC_CONFIG = {
|
|
8
|
+
factory: '0xC7a590291e07B9fe9E64b86c58fD8fC764308C4A',
|
|
9
|
+
router: '0xF9c2b5746c946EF883ab2660BbbB1f10A5bdeAb4',
|
|
10
|
+
positionManager: '0xe222fBE074A436145b255442D919E4E3A6c6a480',
|
|
11
|
+
quoter: '0x4d47fd5a29904Dae0Ef51b1c450C9750F15D7856',
|
|
12
|
+
ticksFeesReader: '0x8Fd8Cb948965d9305999D767A02bf79833EADbB3',
|
|
13
|
+
tokenPositionDescriptor: '0x98565FcAD2080C5c19C3136fa367cE371cD40bD6',
|
|
14
|
+
supportedFees: constants_2.KS_SUPPORTED_FEES,
|
|
15
|
+
poolInitHash: '0x00e263aaa3a2c06a89b53217a9e7aad7e15613490a72e0f95f303c4de2dc7045',
|
|
16
|
+
chunksCount: 10,
|
|
17
|
+
};
|
|
18
|
+
exports.KyberswapElasticConfig = {
|
|
19
|
+
KyberswapElastic: {
|
|
20
|
+
[constants_1.Network.MAINNET]: {
|
|
21
|
+
...KS_ELASTIC_CONFIG,
|
|
22
|
+
subgraphURL: `${SUBGRAPH_BASE_URL}/kyberswap-elastic-mainnet`,
|
|
23
|
+
},
|
|
24
|
+
[constants_1.Network.BSC]: {
|
|
25
|
+
...KS_ELASTIC_CONFIG,
|
|
26
|
+
subgraphURL: `${SUBGRAPH_BASE_URL}/kyberswap-elastic-bsc`,
|
|
27
|
+
},
|
|
28
|
+
[constants_1.Network.ARBITRUM]: {
|
|
29
|
+
...KS_ELASTIC_CONFIG,
|
|
30
|
+
subgraphURL: `${SUBGRAPH_BASE_URL}/kyberswap-elastic-arbitrum-one`,
|
|
31
|
+
},
|
|
32
|
+
[constants_1.Network.POLYGON]: {
|
|
33
|
+
...KS_ELASTIC_CONFIG,
|
|
34
|
+
subgraphURL: `${SUBGRAPH_BASE_URL}/kyberswap-elastic-matic`,
|
|
35
|
+
},
|
|
36
|
+
[constants_1.Network.OPTIMISM]: {
|
|
37
|
+
...KS_ELASTIC_CONFIG,
|
|
38
|
+
subgraphURL: `${SUBGRAPH_BASE_URL}/kyberswap-elastic-optimism`,
|
|
39
|
+
},
|
|
40
|
+
[constants_1.Network.FANTOM]: {
|
|
41
|
+
...KS_ELASTIC_CONFIG,
|
|
42
|
+
subgraphURL: `${SUBGRAPH_BASE_URL}/kyberswap-elastic-fantom`,
|
|
43
|
+
},
|
|
44
|
+
[constants_1.Network.AVALANCHE]: {
|
|
45
|
+
...KS_ELASTIC_CONFIG,
|
|
46
|
+
subgraphURL: `${SUBGRAPH_BASE_URL}/kyberswap-elastic-avalanche`,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
exports.Adapters = {
|
|
51
|
+
[constants_1.Network.MAINNET]: {
|
|
52
|
+
[constants_1.SwapSide.SELL]: [{ name: 'Adapter01', index: 6 }],
|
|
53
|
+
[constants_1.SwapSide.BUY]: [{ name: 'BuyAdapter', index: 2 }],
|
|
54
|
+
},
|
|
55
|
+
[constants_1.Network.BSC]: {
|
|
56
|
+
[constants_1.SwapSide.SELL]: [{ name: 'BscAdapter02', index: 4 }],
|
|
57
|
+
[constants_1.SwapSide.BUY]: [{ name: 'BscBuyAdapter', index: 5 }],
|
|
58
|
+
},
|
|
59
|
+
[constants_1.Network.ARBITRUM]: {
|
|
60
|
+
[constants_1.SwapSide.SELL]: [{ name: 'ArbitrumAdapter01', index: 3 }],
|
|
61
|
+
[constants_1.SwapSide.BUY]: [{ name: 'ArbitrumBuyAdapter', index: 2 }],
|
|
62
|
+
},
|
|
63
|
+
[constants_1.Network.POLYGON]: {
|
|
64
|
+
[constants_1.SwapSide.SELL]: [{ name: 'PolygonAdapter01', index: 13 }],
|
|
65
|
+
[constants_1.SwapSide.BUY]: [{ name: 'PolygonBuyAdapter', index: 2 }],
|
|
66
|
+
},
|
|
67
|
+
[constants_1.Network.OPTIMISM]: {
|
|
68
|
+
[constants_1.SwapSide.SELL]: [{ name: 'OptimismAdapter01', index: 3 }],
|
|
69
|
+
[constants_1.SwapSide.BUY]: [{ name: 'OptimismBuyAdapter', index: 2 }],
|
|
70
|
+
},
|
|
71
|
+
[constants_1.Network.FANTOM]: {
|
|
72
|
+
[constants_1.SwapSide.SELL]: [{ name: 'FantomAdapter01', index: 11 }],
|
|
73
|
+
[constants_1.SwapSide.BUY]: [{ name: 'FantomBuyAdapter', index: 3 }],
|
|
74
|
+
},
|
|
75
|
+
[constants_1.Network.AVALANCHE]: {
|
|
76
|
+
[constants_1.SwapSide.SELL]: [{ name: 'AvanlancheAdapter01', index: 12 }],
|
|
77
|
+
[constants_1.SwapSide.BUY]: [{ name: 'AvanlancheBuyAdapter', index: 7 }],
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/kyberswap-elastic/config.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { NumberAsString } from '../../types';
|
|
2
|
+
export declare const NEGATIVE_ONE = -1n;
|
|
3
|
+
export declare const ZERO = 0n;
|
|
4
|
+
export declare const ONE = 1n;
|
|
5
|
+
export declare const BI_MAX_UINT128: bigint;
|
|
6
|
+
export declare const MAX_TICK_DISTANCE = 480n;
|
|
7
|
+
export declare const MAX_TICK_TRAVEL = 10n;
|
|
8
|
+
export declare const FEE_UNITS = 100000n;
|
|
9
|
+
export declare const TWO_FEE_UNITS: bigint;
|
|
10
|
+
export declare const TWO_POW_96: bigint;
|
|
11
|
+
export declare const KS_ELASTIC_QUOTE_GASLIMIT = 200000;
|
|
12
|
+
export declare const KS_ELASTIC_EFFICIENCY_FACTOR = 5;
|
|
13
|
+
export declare const KS_ELASTIC_TICK_GAS_COST = 24000;
|
|
14
|
+
export declare const KS_ELASTIC_TICK_BASE_OVERHEAD = 75000;
|
|
15
|
+
export declare const KS_ELASTIC_POOL_SEARCH_OVERHEAD = 10000;
|
|
16
|
+
export declare const KS_SUPPORTED_FEES: bigint[];
|
|
17
|
+
export declare const KS_TICK_DISTANCE: Record<NumberAsString, bigint>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KS_TICK_DISTANCE = exports.KS_SUPPORTED_FEES = exports.KS_ELASTIC_POOL_SEARCH_OVERHEAD = exports.KS_ELASTIC_TICK_BASE_OVERHEAD = exports.KS_ELASTIC_TICK_GAS_COST = exports.KS_ELASTIC_EFFICIENCY_FACTOR = exports.KS_ELASTIC_QUOTE_GASLIMIT = exports.TWO_POW_96 = exports.TWO_FEE_UNITS = exports.FEE_UNITS = exports.MAX_TICK_TRAVEL = exports.MAX_TICK_DISTANCE = exports.BI_MAX_UINT128 = exports.ONE = exports.ZERO = exports.NEGATIVE_ONE = void 0;
|
|
4
|
+
exports.NEGATIVE_ONE = -1n;
|
|
5
|
+
exports.ZERO = 0n;
|
|
6
|
+
exports.ONE = 1n;
|
|
7
|
+
exports.BI_MAX_UINT128 = 2n ** 128n - 1n;
|
|
8
|
+
exports.MAX_TICK_DISTANCE = 480n;
|
|
9
|
+
exports.MAX_TICK_TRAVEL = 10n;
|
|
10
|
+
exports.FEE_UNITS = 100000n;
|
|
11
|
+
exports.TWO_FEE_UNITS = exports.FEE_UNITS + exports.FEE_UNITS;
|
|
12
|
+
exports.TWO_POW_96 = BigInt(2) ** BigInt(96);
|
|
13
|
+
exports.KS_ELASTIC_QUOTE_GASLIMIT = 200000;
|
|
14
|
+
exports.KS_ELASTIC_EFFICIENCY_FACTOR = 5;
|
|
15
|
+
exports.KS_ELASTIC_TICK_GAS_COST = 24000; // Ceiled
|
|
16
|
+
exports.KS_ELASTIC_TICK_BASE_OVERHEAD = 75000;
|
|
17
|
+
exports.KS_ELASTIC_POOL_SEARCH_OVERHEAD = 10000;
|
|
18
|
+
exports.KS_SUPPORTED_FEES = [
|
|
19
|
+
5000n,
|
|
20
|
+
2000n,
|
|
21
|
+
1000n,
|
|
22
|
+
300n,
|
|
23
|
+
250n,
|
|
24
|
+
100n,
|
|
25
|
+
40n,
|
|
26
|
+
20n,
|
|
27
|
+
10n,
|
|
28
|
+
8n,
|
|
29
|
+
];
|
|
30
|
+
exports.KS_TICK_DISTANCE = {
|
|
31
|
+
5000: 100n,
|
|
32
|
+
2000: 100n,
|
|
33
|
+
1000: 200n,
|
|
34
|
+
300: 60n,
|
|
35
|
+
250: 25n,
|
|
36
|
+
100: 10n,
|
|
37
|
+
40: 8n,
|
|
38
|
+
20: 2n,
|
|
39
|
+
10: 1n,
|
|
40
|
+
8: 1n,
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/dex/kyberswap-elastic/constants.ts"],"names":[],"mappings":";;;AAEa,QAAA,YAAY,GAAG,CAAC,EAAE,CAAC;AACnB,QAAA,IAAI,GAAG,EAAE,CAAC;AACV,QAAA,GAAG,GAAG,EAAE,CAAC;AAET,QAAA,cAAc,GAAG,EAAE,IAAI,IAAI,GAAG,EAAE,CAAC;AACjC,QAAA,iBAAiB,GAAG,IAAI,CAAC;AACzB,QAAA,eAAe,GAAG,GAAG,CAAC;AACtB,QAAA,SAAS,GAAG,OAAO,CAAC;AACpB,QAAA,aAAa,GAAG,iBAAS,GAAG,iBAAS,CAAC;AACtC,QAAA,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC;AAErC,QAAA,yBAAyB,GAAG,MAAO,CAAC;AACpC,QAAA,4BAA4B,GAAG,CAAC,CAAC;AACjC,QAAA,wBAAwB,GAAG,KAAM,CAAC,CAAC,SAAS;AAC5C,QAAA,6BAA6B,GAAG,KAAM,CAAC;AACvC,QAAA,+BAA+B,GAAG,KAAM,CAAC;AAEzC,QAAA,iBAAiB,GAAG;IAC/B,KAAK;IACL,KAAK;IACL,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,GAAG;IACH,GAAG;IACH,EAAE;CACH,CAAC;AAEW,QAAA,gBAAgB,GAAmC;IAC9D,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;IACR,EAAE,EAAE,EAAE;IACN,EAAE,EAAE,EAAE;IACN,EAAE,EAAE,EAAE;IACN,CAAC,EAAE,EAAE;CACN,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FixedPoint96 = void 0;
|
|
4
|
+
class FixedPoint96 {
|
|
5
|
+
}
|
|
6
|
+
exports.FixedPoint96 = FixedPoint96;
|
|
7
|
+
FixedPoint96.RESOLUTION = 96n;
|
|
8
|
+
FixedPoint96.Q96 = 0x1000000000000000000000000n;
|
|
9
|
+
//# sourceMappingURL=FixedPoint96.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FixedPoint96.js","sourceRoot":"","sources":["../../../../src/dex/kyberswap-elastic/contract-math/FixedPoint96.ts"],"names":[],"mappings":";;;AAAA,MAAa,YAAY;;AAAzB,oCAGC;AAFiB,uBAAU,GAAG,GAAG,CAAC;AACjB,gBAAG,GAAG,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FullMath = void 0;
|
|
4
|
+
const bigint_constants_1 = require("../../../bigint-constants");
|
|
5
|
+
const utils_1 = require("../../../utils");
|
|
6
|
+
class FullMath {
|
|
7
|
+
static mulDiv(a, b, denominator) {
|
|
8
|
+
const result = (a * b) / denominator;
|
|
9
|
+
(0, utils_1._require)(result <= bigint_constants_1.BI_MAX_UINT256, '', { result, BI_MAX_UINT: bigint_constants_1.BI_MAX_UINT256 }, 'result <= BI_MAX_UINT');
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
static mulDivFloor(a, b, denominator) {
|
|
13
|
+
return this.mulDiv(a, b, denominator);
|
|
14
|
+
}
|
|
15
|
+
static mulDivCeil(a, b, denominator) {
|
|
16
|
+
const result = (a * b + denominator - 1n) / denominator;
|
|
17
|
+
(0, utils_1._require)(result <= bigint_constants_1.BI_MAX_UINT256, '', { result, BI_MAX_UINT: bigint_constants_1.BI_MAX_UINT256 }, 'result <= BI_MAX_UINT');
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.FullMath = FullMath;
|
|
22
|
+
//# sourceMappingURL=FullMath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FullMath.js","sourceRoot":"","sources":["../../../../src/dex/kyberswap-elastic/contract-math/FullMath.ts"],"names":[],"mappings":";;;AAAA,gEAA2D;AAC3D,0CAA0C;AAE1C,MAAa,QAAQ;IACnB,MAAM,CAAC,MAAM,CAAC,CAAS,EAAE,CAAS,EAAE,WAAmB;QACrD,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC;QAErC,IAAA,gBAAQ,EACN,MAAM,IAAI,iCAAc,EACxB,EAAE,EACF,EAAE,MAAM,EAAE,WAAW,EAAE,iCAAc,EAAE,EACvC,uBAAuB,CACxB,CAAC;QAEF,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,CAAS,EAAE,CAAS,EAAE,WAAmB;QAC1D,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,CAAS,EAAE,CAAS,EAAE,WAAmB;QACzD,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,WAAW,GAAG,EAAE,CAAC,GAAG,WAAW,CAAC;QAExD,IAAA,gBAAQ,EACN,MAAM,IAAI,iCAAc,EACxB,EAAE,EACF,EAAE,MAAM,EAAE,WAAW,EAAE,iCAAc,EAAE,EACvC,uBAAuB,CACxB,CAAC;QAEF,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA9BD,4BA8BC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LiqDeltaMath = void 0;
|
|
4
|
+
class LiqDeltaMath {
|
|
5
|
+
static applyLiquidityDelta(liquidity, liquidityDelta, isAddLiquidity) {
|
|
6
|
+
return isAddLiquidity
|
|
7
|
+
? liquidity + liquidityDelta
|
|
8
|
+
: liquidity - liquidityDelta;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.LiqDeltaMath = LiqDeltaMath;
|
|
12
|
+
//# sourceMappingURL=LiqDeltaMath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LiqDeltaMath.js","sourceRoot":"","sources":["../../../../src/dex/kyberswap-elastic/contract-math/LiqDeltaMath.ts"],"names":[],"mappings":";;;AAAA,MAAa,YAAY;IACvB,MAAM,CAAC,mBAAmB,CACxB,SAAiB,EACjB,cAAsB,EACtB,cAAuB;QAEvB,OAAO,cAAc;YACnB,CAAC,CAAC,SAAS,GAAG,cAAc;YAC5B,CAAC,CAAC,SAAS,GAAG,cAAc,CAAC;IACjC,CAAC;CACF;AAVD,oCAUC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LiquidityMath = void 0;
|
|
4
|
+
const utils_1 = require("../../../utils");
|
|
5
|
+
class LiquidityMath {
|
|
6
|
+
static addDelta(x, y) {
|
|
7
|
+
let z;
|
|
8
|
+
if (y < 0) {
|
|
9
|
+
const _y = BigInt.asUintN(128, -y);
|
|
10
|
+
z = x - _y;
|
|
11
|
+
(0, utils_1._require)(z < x, 'LS', { z, x, y, _y }, 'z < x');
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
const _y = BigInt.asUintN(128, y);
|
|
15
|
+
z = x + _y;
|
|
16
|
+
(0, utils_1._require)(z >= x, 'LA', { z, x, y, _y }, 'z >= x');
|
|
17
|
+
}
|
|
18
|
+
return z;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.LiquidityMath = LiquidityMath;
|
|
22
|
+
//# sourceMappingURL=LiquidityMath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LiquidityMath.js","sourceRoot":"","sources":["../../../../src/dex/kyberswap-elastic/contract-math/LiquidityMath.ts"],"names":[],"mappings":";;;AAAA,0CAA0C;AAE1C,MAAa,aAAa;IACxB,MAAM,CAAC,QAAQ,CAAC,CAAS,EAAE,CAAS;QAClC,IAAI,CAAC,CAAC;QACN,IAAI,CAAC,GAAG,CAAC,EAAE;YACT,MAAM,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;YACnC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;YACX,IAAA,gBAAQ,EAAC,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;SACjD;aAAM;YACL,MAAM,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAClC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;YACX,IAAA,gBAAQ,EAAC,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC;SACnD;QACD,OAAO,CAAC,CAAC;IACX,CAAC;CACF;AAdD,sCAcC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare class QtyDeltaMath {
|
|
2
|
+
static calcRequiredQty0(lowerSqrtP: bigint, upperSqrtP: bigint, liquidity: bigint, isAdd: boolean): bigint;
|
|
3
|
+
static calcRequiredQty1(lowerSqrtP: bigint, upperSqrtP: bigint, liquidity: bigint, isAdd: boolean): bigint;
|
|
4
|
+
static divCeil(a: bigint, b: bigint): bigint;
|
|
5
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QtyDeltaMath = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const FullMath_1 = require("./FullMath");
|
|
6
|
+
const SafeCast_1 = require("./SafeCast");
|
|
7
|
+
class QtyDeltaMath {
|
|
8
|
+
static calcRequiredQty0(lowerSqrtP, upperSqrtP, liquidity, isAdd) {
|
|
9
|
+
let numerator1 = liquidity << 96n;
|
|
10
|
+
let numerator2 = upperSqrtP - lowerSqrtP;
|
|
11
|
+
return isAdd
|
|
12
|
+
? SafeCast_1.SafeCast.toInt256(this.divCeil(FullMath_1.FullMath.mulDivCeil(numerator1, numerator2, upperSqrtP), lowerSqrtP))
|
|
13
|
+
: SafeCast_1.SafeCast.revToInt256(FullMath_1.FullMath.mulDivFloor(numerator1, numerator2, upperSqrtP) / lowerSqrtP);
|
|
14
|
+
}
|
|
15
|
+
static calcRequiredQty1(lowerSqrtP, upperSqrtP, liquidity, isAdd) {
|
|
16
|
+
return isAdd
|
|
17
|
+
? SafeCast_1.SafeCast.toInt256(FullMath_1.FullMath.mulDivCeil(liquidity, upperSqrtP - lowerSqrtP, constants_1.TWO_POW_96))
|
|
18
|
+
: SafeCast_1.SafeCast.revToInt256(FullMath_1.FullMath.mulDivFloor(liquidity, upperSqrtP - lowerSqrtP, constants_1.TWO_POW_96));
|
|
19
|
+
}
|
|
20
|
+
static divCeil(a, b) {
|
|
21
|
+
return (a + b - 1n) / b;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.QtyDeltaMath = QtyDeltaMath;
|
|
25
|
+
//# sourceMappingURL=QtyDeltaMath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QtyDeltaMath.js","sourceRoot":"","sources":["../../../../src/dex/kyberswap-elastic/contract-math/QtyDeltaMath.ts"],"names":[],"mappings":";;;AAAA,4CAA0C;AAC1C,yCAAsC;AACtC,yCAAsC;AAEtC,MAAa,YAAY;IACvB,MAAM,CAAC,gBAAgB,CACrB,UAAkB,EAClB,UAAkB,EAClB,SAAiB,EACjB,KAAc;QAEd,IAAI,UAAU,GAAG,SAAS,IAAI,GAAG,CAAC;QAClC,IAAI,UAAU,GAAG,UAAU,GAAG,UAAU,CAAC;QAEzC,OAAO,KAAK;YACV,CAAC,CAAC,mBAAQ,CAAC,QAAQ,CACf,IAAI,CAAC,OAAO,CACV,mBAAQ,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,EACvD,UAAU,CACX,CACF;YACH,CAAC,CAAC,mBAAQ,CAAC,WAAW,CAClB,mBAAQ,CAAC,WAAW,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,GAAG,UAAU,CACtE,CAAC;IACR,CAAC;IAED,MAAM,CAAC,gBAAgB,CACrB,UAAkB,EAClB,UAAkB,EAClB,SAAiB,EACjB,KAAc;QAEd,OAAO,KAAK;YACV,CAAC,CAAC,mBAAQ,CAAC,QAAQ,CACf,mBAAQ,CAAC,UAAU,CAAC,SAAS,EAAE,UAAU,GAAG,UAAU,EAAE,sBAAU,CAAC,CACpE;YACH,CAAC,CAAC,mBAAQ,CAAC,WAAW,CAClB,mBAAQ,CAAC,WAAW,CAAC,SAAS,EAAE,UAAU,GAAG,UAAU,EAAE,sBAAU,CAAC,CACrE,CAAC;IACR,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,CAAS,EAAE,CAAS;QACjC,OAAO,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;CACF;AAxCD,oCAwCC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QuadMath = void 0;
|
|
4
|
+
class QuadMath {
|
|
5
|
+
static getSmallerRootOfQuadEqn(a, b, c) {
|
|
6
|
+
let smallerRoot = 0n;
|
|
7
|
+
smallerRoot = (b - this.sqrt(b * b - a * c)) / a;
|
|
8
|
+
return smallerRoot;
|
|
9
|
+
}
|
|
10
|
+
static sqrt(y) {
|
|
11
|
+
let z = 0n;
|
|
12
|
+
if (y > 3) {
|
|
13
|
+
z = y;
|
|
14
|
+
let x = y / 2n + 1n;
|
|
15
|
+
while (x < z) {
|
|
16
|
+
z = x;
|
|
17
|
+
x = (y / x + x) / 2n;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
else if (y != 0n) {
|
|
21
|
+
z = 1n;
|
|
22
|
+
}
|
|
23
|
+
return z;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.QuadMath = QuadMath;
|
|
27
|
+
//# sourceMappingURL=QuadMath.js.map
|