@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,134 @@
|
|
|
1
|
+
import { Address } from '../../types';
|
|
2
|
+
import { NumberAsString } from '../../types';
|
|
3
|
+
export declare type PoolPairsInfo = {
|
|
4
|
+
token0: Address;
|
|
5
|
+
token1: Address;
|
|
6
|
+
swapFeeUnits: string;
|
|
7
|
+
};
|
|
8
|
+
export declare type PoolState = {
|
|
9
|
+
pool: string;
|
|
10
|
+
tickDistance: bigint;
|
|
11
|
+
poolOracle?: ObservationData;
|
|
12
|
+
poolObservation?: Record<NumberAsString, OracleObservation>;
|
|
13
|
+
maxTickLiquidity: bigint;
|
|
14
|
+
swapFeeUnits: bigint;
|
|
15
|
+
governmentFeeTo: string;
|
|
16
|
+
governmentFeeUnits: bigint;
|
|
17
|
+
poolData: PoolData;
|
|
18
|
+
ticks: Record<NumberAsString, TickInfo>;
|
|
19
|
+
initializedTicks: Record<NumberAsString, LinkedlistData>;
|
|
20
|
+
reinvestLiquidity: bigint;
|
|
21
|
+
currentTick: bigint;
|
|
22
|
+
balance0: bigint;
|
|
23
|
+
balance1: bigint;
|
|
24
|
+
isValid: boolean;
|
|
25
|
+
blockTimestamp: bigint;
|
|
26
|
+
};
|
|
27
|
+
export declare type PoolData = {
|
|
28
|
+
sqrtP: bigint;
|
|
29
|
+
nearestCurrentTick: bigint;
|
|
30
|
+
currentTick: bigint;
|
|
31
|
+
baseL: bigint;
|
|
32
|
+
reinvestL: bigint;
|
|
33
|
+
reinvestLLast: bigint;
|
|
34
|
+
feeGrowthGlobal: bigint;
|
|
35
|
+
secondsPerLiquidityGlobal: bigint;
|
|
36
|
+
secondsPerLiquidityUpdateTime: bigint;
|
|
37
|
+
rTokenSupply: bigint;
|
|
38
|
+
locked: boolean;
|
|
39
|
+
};
|
|
40
|
+
export declare type TickInfo = {
|
|
41
|
+
liquidityGross: bigint;
|
|
42
|
+
liquidityNet: bigint;
|
|
43
|
+
feeGrowthOutside: bigint;
|
|
44
|
+
secondsPerLiquidityOutside: bigint;
|
|
45
|
+
};
|
|
46
|
+
export declare type LinkedlistData = {
|
|
47
|
+
previous: bigint;
|
|
48
|
+
next: bigint;
|
|
49
|
+
};
|
|
50
|
+
export declare type ObservationData = {
|
|
51
|
+
initialized: boolean;
|
|
52
|
+
index: bigint;
|
|
53
|
+
cardinality: bigint;
|
|
54
|
+
cardinalityNext: bigint;
|
|
55
|
+
};
|
|
56
|
+
export declare type OracleObservation = {
|
|
57
|
+
blockTimestamp: bigint;
|
|
58
|
+
tickCumulative: bigint;
|
|
59
|
+
initialized: boolean;
|
|
60
|
+
};
|
|
61
|
+
export declare type KyberswapElasticData = {
|
|
62
|
+
path: {
|
|
63
|
+
tokenIn: Address;
|
|
64
|
+
tokenOut: Address;
|
|
65
|
+
swapFeeUnits: NumberAsString;
|
|
66
|
+
}[];
|
|
67
|
+
isApproved?: boolean;
|
|
68
|
+
};
|
|
69
|
+
export declare type DexParams = {
|
|
70
|
+
factory: Address;
|
|
71
|
+
router: Address;
|
|
72
|
+
positionManager: Address;
|
|
73
|
+
quoter: Address;
|
|
74
|
+
ticksFeesReader: Address;
|
|
75
|
+
tokenPositionDescriptor: Address;
|
|
76
|
+
supportedFees: bigint[];
|
|
77
|
+
poolInitHash: string;
|
|
78
|
+
chunksCount: number;
|
|
79
|
+
subgraphURL?: string;
|
|
80
|
+
};
|
|
81
|
+
export declare type KyberElasticSellParam = {
|
|
82
|
+
path: string;
|
|
83
|
+
recipient: Address;
|
|
84
|
+
deadline: string;
|
|
85
|
+
amountIn: NumberAsString;
|
|
86
|
+
amountOutMinimum: NumberAsString;
|
|
87
|
+
};
|
|
88
|
+
export declare type KyberElasticBuyParam = {
|
|
89
|
+
path: string;
|
|
90
|
+
recipient: Address;
|
|
91
|
+
deadline: string;
|
|
92
|
+
amountOut: NumberAsString;
|
|
93
|
+
amountInMaximum: NumberAsString;
|
|
94
|
+
};
|
|
95
|
+
export declare type KyberElasticParam = KyberElasticSellParam | KyberElasticBuyParam;
|
|
96
|
+
export declare enum KyberElasticFunctions {
|
|
97
|
+
quoteExactInputSingle = "quoteExactInputSingle",
|
|
98
|
+
quoteExactOutputSingle = "quoteExactOutputSingle"
|
|
99
|
+
}
|
|
100
|
+
export declare type PoolStateResponse = {
|
|
101
|
+
sqrtP: bigint;
|
|
102
|
+
currentTick: bigint;
|
|
103
|
+
nearestCurrentTick: bigint;
|
|
104
|
+
locked: boolean;
|
|
105
|
+
};
|
|
106
|
+
export declare type LiquidityStateResponse = {
|
|
107
|
+
baseL: bigint;
|
|
108
|
+
reinvestL: bigint;
|
|
109
|
+
reinvestLLast: bigint;
|
|
110
|
+
};
|
|
111
|
+
export declare type FeeGrowthGlobalResponse = bigint;
|
|
112
|
+
export declare type SecondsPerLiquidityResponse = {
|
|
113
|
+
secondsPerLiquidityGlobal: bigint;
|
|
114
|
+
lastUpdateTime: bigint;
|
|
115
|
+
};
|
|
116
|
+
export declare type FeeConfigurationResponse = {
|
|
117
|
+
_feeTo: Address;
|
|
118
|
+
_governmentFeeUnits: bigint;
|
|
119
|
+
};
|
|
120
|
+
export declare type InitializedTicksResponse = {
|
|
121
|
+
previous: bigint;
|
|
122
|
+
next: bigint;
|
|
123
|
+
};
|
|
124
|
+
export declare type TicksResponse = {
|
|
125
|
+
liquidityGross: bigint;
|
|
126
|
+
liquidityNet: bigint;
|
|
127
|
+
feeGrowthOutside: bigint;
|
|
128
|
+
secondsPerLiquidityOutside: bigint;
|
|
129
|
+
};
|
|
130
|
+
export declare type KyberElasticStateResponses = bigint | PoolStateResponse | LiquidityStateResponse | FeeGrowthGlobalResponse | SecondsPerLiquidityResponse | FeeConfigurationResponse | InitializedTicksResponse | TicksResponse;
|
|
131
|
+
export declare type OutputResult = {
|
|
132
|
+
outputs: bigint[];
|
|
133
|
+
tickCounts: number[];
|
|
134
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KyberElasticFunctions = void 0;
|
|
4
|
+
var KyberElasticFunctions;
|
|
5
|
+
(function (KyberElasticFunctions) {
|
|
6
|
+
KyberElasticFunctions["quoteExactInputSingle"] = "quoteExactInputSingle";
|
|
7
|
+
KyberElasticFunctions["quoteExactOutputSingle"] = "quoteExactOutputSingle";
|
|
8
|
+
})(KyberElasticFunctions = exports.KyberElasticFunctions || (exports.KyberElasticFunctions = {}));
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/kyberswap-elastic/types.ts"],"names":[],"mappings":";;;AA4GA,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAC/B,wEAA+C,CAAA;IAC/C,0EAAiD,CAAA;AACnD,CAAC,EAHW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAGhC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BytesLike } from 'ethers';
|
|
2
|
+
import { MultiResult } from '../../../lib/multi-wrapper';
|
|
3
|
+
import { KyberElasticStateResponses } from '../types';
|
|
4
|
+
export declare function decodePoolState(result: MultiResult<BytesLike> | BytesLike): KyberElasticStateResponses;
|
|
5
|
+
export declare function decodeLiquidityState(result: MultiResult<BytesLike> | BytesLike): KyberElasticStateResponses;
|
|
6
|
+
export declare function decodeSecondsPerLiquidity(result: MultiResult<BytesLike> | BytesLike): KyberElasticStateResponses;
|
|
7
|
+
export declare function decodeFeeConfiguration(result: MultiResult<BytesLike> | BytesLike): KyberElasticStateResponses;
|
|
8
|
+
export declare function decodeInitializedTicks(result: MultiResult<BytesLike> | BytesLike): KyberElasticStateResponses;
|
|
9
|
+
export declare function decodeTicks(result: MultiResult<BytesLike> | BytesLike): KyberElasticStateResponses;
|
|
@@ -0,0 +1,78 @@
|
|
|
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.decodeTicks = exports.decodeInitializedTicks = exports.decodeFeeConfiguration = exports.decodeSecondsPerLiquidity = exports.decodeLiquidityState = exports.decodePoolState = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const ts_essentials_1 = require("ts-essentials");
|
|
9
|
+
const decoders_1 = require("../../../lib/decoders");
|
|
10
|
+
const IFactory_json_1 = __importDefault(require("../../../abi/kyberswap-elastic/IFactory.json"));
|
|
11
|
+
const IPool_json_1 = __importDefault(require("../../../abi/kyberswap-elastic/IPool.json"));
|
|
12
|
+
const errors_1 = require("../errors");
|
|
13
|
+
function decodePoolState(result) {
|
|
14
|
+
const [isSuccess, toDecode] = (0, decoders_1.extractSuccessAndValue)(result);
|
|
15
|
+
(0, ts_essentials_1.assert)(isSuccess && toDecode !== '0x', `${errors_1.ERR_DECODE}: ${result}`);
|
|
16
|
+
const callResults = new ethers_1.ethers.utils.Interface(IPool_json_1.default).decodeFunctionResult('getPoolState', toDecode);
|
|
17
|
+
return {
|
|
18
|
+
sqrtP: callResults.sqrtP,
|
|
19
|
+
currentTick: callResults.currentTick,
|
|
20
|
+
nearestCurrentTick: callResults.nearestCurrentTick,
|
|
21
|
+
locked: callResults.locked,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
exports.decodePoolState = decodePoolState;
|
|
25
|
+
function decodeLiquidityState(result) {
|
|
26
|
+
const [isSuccess, toDecode] = (0, decoders_1.extractSuccessAndValue)(result);
|
|
27
|
+
(0, ts_essentials_1.assert)(isSuccess && toDecode !== '0x', `${errors_1.ERR_DECODE}: ${result}`);
|
|
28
|
+
const callResults = new ethers_1.ethers.utils.Interface(IPool_json_1.default).decodeFunctionResult('getLiquidityState', toDecode);
|
|
29
|
+
return {
|
|
30
|
+
baseL: callResults.baseL,
|
|
31
|
+
reinvestL: callResults.reinvestL,
|
|
32
|
+
reinvestLLast: callResults.reinvestLLast,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
exports.decodeLiquidityState = decodeLiquidityState;
|
|
36
|
+
function decodeSecondsPerLiquidity(result) {
|
|
37
|
+
const [isSuccess, toDecode] = (0, decoders_1.extractSuccessAndValue)(result);
|
|
38
|
+
(0, ts_essentials_1.assert)(isSuccess && toDecode !== '0x', `${errors_1.ERR_DECODE}: ${result}`);
|
|
39
|
+
const callResults = new ethers_1.ethers.utils.Interface(IPool_json_1.default).decodeFunctionResult('getSecondsPerLiquidityData', toDecode);
|
|
40
|
+
return {
|
|
41
|
+
secondsPerLiquidityGlobal: callResults.secondsPerLiquidityGlobal,
|
|
42
|
+
lastUpdateTime: callResults.lastUpdateTime,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
exports.decodeSecondsPerLiquidity = decodeSecondsPerLiquidity;
|
|
46
|
+
function decodeFeeConfiguration(result) {
|
|
47
|
+
const [isSuccess, toDecode] = (0, decoders_1.extractSuccessAndValue)(result);
|
|
48
|
+
(0, ts_essentials_1.assert)(isSuccess && toDecode !== '0x', `${errors_1.ERR_DECODE}: ${result}`);
|
|
49
|
+
const callResults = new ethers_1.ethers.utils.Interface(IFactory_json_1.default).decodeFunctionResult('feeConfiguration', toDecode);
|
|
50
|
+
return {
|
|
51
|
+
_feeTo: callResults._feeTo,
|
|
52
|
+
_governmentFeeUnits: callResults._governmentFeeUnits,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
exports.decodeFeeConfiguration = decodeFeeConfiguration;
|
|
56
|
+
function decodeInitializedTicks(result) {
|
|
57
|
+
const [isSuccess, toDecode] = (0, decoders_1.extractSuccessAndValue)(result);
|
|
58
|
+
(0, ts_essentials_1.assert)(isSuccess && toDecode !== '0x', `${errors_1.ERR_DECODE}: ${result}`);
|
|
59
|
+
const callResults = new ethers_1.ethers.utils.Interface(IPool_json_1.default).decodeFunctionResult('initializedTicks', toDecode);
|
|
60
|
+
return {
|
|
61
|
+
previous: callResults.previous,
|
|
62
|
+
next: callResults.next,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
exports.decodeInitializedTicks = decodeInitializedTicks;
|
|
66
|
+
function decodeTicks(result) {
|
|
67
|
+
const [isSuccess, toDecode] = (0, decoders_1.extractSuccessAndValue)(result);
|
|
68
|
+
(0, ts_essentials_1.assert)(isSuccess && toDecode !== '0x', `${errors_1.ERR_DECODE}: ${result}`);
|
|
69
|
+
const callResults = new ethers_1.ethers.utils.Interface(IPool_json_1.default).decodeFunctionResult('ticks', toDecode);
|
|
70
|
+
return {
|
|
71
|
+
liquidityGross: callResults.liquidityGross,
|
|
72
|
+
liquidityNet: callResults.liquidityNet,
|
|
73
|
+
feeGrowthOutside: callResults.feeGrowthOutside,
|
|
74
|
+
secondsPerLiquidityOutside: callResults.secondsPerLiquidityOutside,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
exports.decodeTicks = decodeTicks;
|
|
78
|
+
//# sourceMappingURL=decoders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decoders.js","sourceRoot":"","sources":["../../../../src/dex/kyberswap-elastic/utils/decoders.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DexParams } from '../gmx/types';
|
|
2
|
+
import { DexConfigMap } from '../../types';
|
|
3
|
+
export declare const MorphexConfig: DexConfigMap<DexParams>;
|
|
4
|
+
export declare const Adapters: {
|
|
5
|
+
[chainId: number]: {
|
|
6
|
+
[side: string]: {
|
|
7
|
+
name: string;
|
|
8
|
+
index: number;
|
|
9
|
+
}[] | null;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Adapters = exports.MorphexConfig = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
exports.MorphexConfig = {
|
|
6
|
+
Morphex: {
|
|
7
|
+
[constants_1.Network.FANTOM]: {
|
|
8
|
+
vault: '0x245cD6d33578de9aF75a3C0c636c726b1A8cbdAa',
|
|
9
|
+
reader: '0xcA47b9b612a152ece991F31d8D3547D73BaF2Ecc',
|
|
10
|
+
priceFeed: '0x7a451DE877CbB6551AACa671d0458B6f9dF1e29A',
|
|
11
|
+
fastPriceFeed: '0x7f54C35A38D89fcf5Fe516206E6628745ed38CC7',
|
|
12
|
+
fastPriceEvents: '0xDc7C389be5da32e326A261dC0126feCa7AE04d79',
|
|
13
|
+
usdg: '0xe135c7BFfda932b5B862Da442cF4CbC4d43DC3Ad',
|
|
14
|
+
},
|
|
15
|
+
[constants_1.Network.BSC]: {
|
|
16
|
+
vault: '0x46940Dc651bFe3F2CC3E04cf9dC5579B50Cf0765',
|
|
17
|
+
reader: '0x49A97680938B4F1f73816d1B70C3Ab801FAd124B',
|
|
18
|
+
priceFeed: '0x0144b19D1B9338fC7C286d6767bd9b29F0347f27',
|
|
19
|
+
fastPriceFeed: '0x55e6e6A968e485abEC1e1d957f408586e45a4f99',
|
|
20
|
+
fastPriceEvents: '0x491Df61db853761d42C4F38BeD220E9D807143dE',
|
|
21
|
+
usdg: '0x548f93779fBC992010C07467cBaf329DD5F059B7',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
exports.Adapters = {
|
|
26
|
+
[constants_1.Network.FANTOM]: {
|
|
27
|
+
[constants_1.SwapSide.SELL]: [
|
|
28
|
+
{
|
|
29
|
+
name: 'FantomAdapter01',
|
|
30
|
+
index: 6, // TODO: there is no Morphex adapter
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
[constants_1.Network.BSC]: {
|
|
35
|
+
[constants_1.SwapSide.SELL]: [
|
|
36
|
+
{
|
|
37
|
+
name: 'BscAdapter01',
|
|
38
|
+
index: 6, // TODO: there is no Morphex adapter
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/morphex/config.ts"],"names":[],"mappings":";;;AAEA,+CAAoD;AAEvC,QAAA,aAAa,GAA4B;IACpD,OAAO,EAAE;QACP,CAAC,mBAAO,CAAC,MAAM,CAAC,EAAE;YAChB,KAAK,EAAE,4CAA4C;YACnD,MAAM,EAAE,4CAA4C;YACpD,SAAS,EAAE,4CAA4C;YACvD,aAAa,EAAE,4CAA4C;YAC3D,eAAe,EAAE,4CAA4C;YAC7D,IAAI,EAAE,4CAA4C;SACnD;QACD,CAAC,mBAAO,CAAC,GAAG,CAAC,EAAE;YACb,KAAK,EAAE,4CAA4C;YACnD,MAAM,EAAE,4CAA4C;YACpD,SAAS,EAAE,4CAA4C;YACvD,aAAa,EAAE,4CAA4C;YAC3D,eAAe,EAAE,4CAA4C;YAC7D,IAAI,EAAE,4CAA4C;SACnD;KACF;CACF,CAAC;AAEW,QAAA,QAAQ,GAIjB;IACF,CAAC,mBAAO,CAAC,MAAM,CAAC,EAAE;QAChB,CAAC,oBAAQ,CAAC,IAAI,CAAC,EAAE;YACf;gBACE,IAAI,EAAE,iBAAiB;gBACvB,KAAK,EAAE,CAAC,EAAE,oCAAoC;aAC/C;SACF;KACF;IACD,CAAC,mBAAO,CAAC,GAAG,CAAC,EAAE;QACb,CAAC,oBAAQ,CAAC,IAAI,CAAC,EAAE;YACf;gBACE,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,CAAC,EAAE,oCAAoC;aAC/C;SACF;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Network } from '../../constants';
|
|
2
|
+
import { IDexHelper } from '../../dex-helper';
|
|
3
|
+
import { DexParams } from '../gmx/types';
|
|
4
|
+
import { GMX } from '../gmx/gmx';
|
|
5
|
+
export declare class Morphex extends GMX {
|
|
6
|
+
protected network: Network;
|
|
7
|
+
protected dexHelper: IDexHelper;
|
|
8
|
+
protected adapters: {
|
|
9
|
+
[side: string]: {
|
|
10
|
+
name: string;
|
|
11
|
+
index: number;
|
|
12
|
+
}[] | null;
|
|
13
|
+
};
|
|
14
|
+
protected params: DexParams;
|
|
15
|
+
static dexKeysWithNetwork: {
|
|
16
|
+
key: string;
|
|
17
|
+
networks: Network[];
|
|
18
|
+
}[];
|
|
19
|
+
constructor(network: Network, dexKey: string, dexHelper: IDexHelper, adapters?: {
|
|
20
|
+
[side: string]: {
|
|
21
|
+
name: string;
|
|
22
|
+
index: number;
|
|
23
|
+
}[] | null;
|
|
24
|
+
}, params?: DexParams);
|
|
25
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Morphex = void 0;
|
|
4
|
+
const config_1 = require("./config");
|
|
5
|
+
const gmx_1 = require("../gmx/gmx");
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
class Morphex extends gmx_1.GMX {
|
|
8
|
+
constructor(network, dexKey, dexHelper, adapters = config_1.Adapters[network], params = config_1.MorphexConfig[dexKey][network]) {
|
|
9
|
+
super(network, dexKey, dexHelper, adapters, params);
|
|
10
|
+
this.network = network;
|
|
11
|
+
this.dexHelper = dexHelper;
|
|
12
|
+
this.adapters = adapters;
|
|
13
|
+
this.params = params;
|
|
14
|
+
this.logger = dexHelper.getLogger(dexKey);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.Morphex = Morphex;
|
|
18
|
+
Morphex.dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.MorphexConfig);
|
|
19
|
+
//# sourceMappingURL=morphex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"morphex.js","sourceRoot":"","sources":["../../../src/dex/morphex/morphex.ts"],"names":[],"mappings":";;;AAGA,qCAAmD;AACnD,oCAAiC;AACjC,uCAAoD;AAEpD,MAAa,OAAQ,SAAQ,SAAG;IAI9B,YACY,OAAgB,EAC1B,MAAc,EACJ,SAAqB,EACrB,WAAW,iBAAQ,CAAC,OAAO,CAAC,EAC5B,SAAoB,sBAAa,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;QAE5D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAN1C,YAAO,GAAP,OAAO,CAAS;QAEhB,cAAS,GAAT,SAAS,CAAY;QACrB,aAAQ,GAAR,QAAQ,CAAoB;QAC5B,WAAM,GAAN,MAAM,CAA4C;QAG5D,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;;AAbH,0BAcC;AAbe,0BAAkB,GAC9B,IAAA,6BAAqB,EAAC,sBAAa,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Adapters = exports.MyTestDexConfig = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
exports.MyTestDexConfig = {
|
|
6
|
+
MyTestDex: {
|
|
7
|
+
// TODO: complete me!
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
exports.Adapters = {
|
|
11
|
+
// TODO: add adapters for each chain
|
|
12
|
+
// This is an example to copy
|
|
13
|
+
[constants_1.Network.MAINNET]: { [constants_1.SwapSide.SELL]: [{ name: '', index: 0 }] },
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/my-test-dex/config.ts"],"names":[],"mappings":";;;AAEA,+CAAoD;AAEvC,QAAA,eAAe,GAA4B;IACtD,SAAS,EAAE;IACT,qBAAqB;KACtB;CACF,CAAC;AAEW,QAAA,QAAQ,GAAoC;IACvD,oCAAoC;IACpC,6BAA6B;IAC7B,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,oBAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE;CACjE,CAAC"}
|
|
@@ -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 MyTestDexEventPool extends StatefulEventSubscriber<PoolState> {
|
|
8
|
+
readonly parentName: string;
|
|
9
|
+
protected network: number;
|
|
10
|
+
protected dexHelper: IDexHelper;
|
|
11
|
+
protected myTestDexIface: 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, myTestDexIface?: 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.MyTestDexEventPool = 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 MyTestDexEventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
|
|
8
|
+
constructor(parentName, network, dexHelper, logger, myTestDexIface = new abi_1.Interface('' /* TODO: Import and put here MyTestDex 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.myTestDexIface = myTestDexIface;
|
|
15
|
+
this.handlers = {};
|
|
16
|
+
// TODO: make logDecoder decode logs that
|
|
17
|
+
this.logDecoder = (log) => this.myTestDexIface.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.MyTestDexEventPool = MyTestDexEventPool;
|
|
64
|
+
//# sourceMappingURL=my-test-dex-pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"my-test-dex-pool.js","sourceRoot":"","sources":["../../../src/dex/my-test-dex/my-test-dex-pool.ts"],"names":[],"mappings":";;;AAAA,4CAA+C;AAG/C,uCAAiD;AACjD,+EAA0E;AAI1E,MAAa,kBAAmB,SAAQ,mDAAkC;IAaxE,YACW,UAAkB,EACjB,OAAe,EACf,SAAqB,EAC/B,MAAc,EACJ,iBAAiB,IAAI,eAAS,CACtC,EAAE,CAAC,6CAA6C,CACjD;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,mBAAc,GAAd,cAAc,CAEvB;QAnBH,aAAQ,GAMJ,EAAE,CAAC;QAkBL,yCAAyC;QACzC,IAAI,CAAC,UAAU,GAAG,CAAC,GAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAClE,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,gDAkFC"}
|
|
@@ -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 { MyTestDexData } from './types';
|
|
7
|
+
import { SimpleExchange } from '../simple-exchange';
|
|
8
|
+
import { MyTestDexEventPool } from './my-test-dex-pool';
|
|
9
|
+
export declare class MyTestDex extends SimpleExchange implements IDex<MyTestDexData> {
|
|
10
|
+
readonly network: Network;
|
|
11
|
+
readonly dexKey: string;
|
|
12
|
+
readonly dexHelper: IDexHelper;
|
|
13
|
+
protected adapters: import("../../types").AdapterMappings;
|
|
14
|
+
protected eventPools: MyTestDexEventPool;
|
|
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<MyTestDexData>>;
|
|
31
|
+
getCalldataGasCost(poolPrices: PoolPrices<MyTestDexData>): number | number[];
|
|
32
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: MyTestDexData, side: SwapSide): AdapterExchangeParam;
|
|
33
|
+
getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: MyTestDexData, 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.MyTestDex = 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 my_test_dex_pool_1 = require("./my-test-dex-pool");
|
|
32
|
+
class MyTestDex 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 my_test_dex_pool_1.MyTestDexEventPool(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.MyTestDex = MyTestDex;
|
|
125
|
+
MyTestDex.dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.MyTestDexConfig);
|
|
126
|
+
//# sourceMappingURL=my-test-dex.js.map
|