@paraswap/dex-lib 2.42.9 → 2.42.10-cache-cleaning-bug.0

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.
Files changed (205) hide show
  1. package/.vscode/launch.json +38 -0
  2. package/.vscode/settings.json +2 -0
  3. package/.vscode/tasks.json +15 -0
  4. package/build/dex/algebra/algebra.js +9 -4
  5. package/build/dex/algebra/algebra.js.map +1 -1
  6. package/build/dex/pancakeswap-v3/pancakeswap-v3.js +9 -4
  7. package/build/dex/pancakeswap-v3/pancakeswap-v3.js.map +1 -1
  8. package/build/dex/uniswap-v3/uniswap-v3.js +9 -4
  9. package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
  10. package/package.json +1 -1
  11. package/src/dex/algebra/algebra.ts +14 -4
  12. package/src/dex/pancakeswap-v3/pancakeswap-v3.ts +14 -4
  13. package/src/dex/uniswap-v3/uniswap-v3.ts +14 -4
  14. package/build/abi/kyberswap-elastic/IAntiSnipAttackPositionManager.json +0 -1276
  15. package/build/abi/kyberswap-elastic/IFactory.json +0 -550
  16. package/build/abi/kyberswap-elastic/IPool.json +0 -1042
  17. package/build/abi/kyberswap-elastic/IQuoterV2.json +0 -226
  18. package/build/abi/kyberswap-elastic/IRouter.json +0 -239
  19. package/build/abi/kyberswap-elastic/TicksFeesReader.json +0 -142
  20. package/build/abi/wombat/asset.json +0 -769
  21. package/build/abi/wombat/bmw.json +0 -1247
  22. package/build/abi/wombat/pool.json +0 -1364
  23. package/build/dex/baseswap-v3/baseswap-v3-factory.d.ts +0 -26
  24. package/build/dex/baseswap-v3/baseswap-v3-factory.js +0 -44
  25. package/build/dex/baseswap-v3/baseswap-v3-factory.js.map +0 -1
  26. package/build/dex/baseswap-v3/baseswap-v3-pool.d.ts +0 -46
  27. package/build/dex/baseswap-v3/baseswap-v3-pool.js +0 -312
  28. package/build/dex/baseswap-v3/baseswap-v3-pool.js.map +0 -1
  29. package/build/dex/baseswap-v3/baseswap-v3.d.ts +0 -71
  30. package/build/dex/baseswap-v3/baseswap-v3.js +0 -752
  31. package/build/dex/baseswap-v3/baseswap-v3.js.map +0 -1
  32. package/build/dex/baseswap-v3/config.d.ts +0 -9
  33. package/build/dex/baseswap-v3/config.js +0 -48
  34. package/build/dex/baseswap-v3/config.js.map +0 -1
  35. package/build/dex/baseswap-v3/constants.d.ts +0 -28
  36. package/build/dex/baseswap-v3/constants.js +0 -35
  37. package/build/dex/baseswap-v3/constants.js.map +0 -1
  38. package/build/dex/baseswap-v3/contract-math/BitMath.d.ts +0 -4
  39. package/build/dex/baseswap-v3/contract-math/BitMath.js +0 -93
  40. package/build/dex/baseswap-v3/contract-math/BitMath.js.map +0 -1
  41. package/build/dex/baseswap-v3/contract-math/FixedPoint128.d.ts +0 -3
  42. package/build/dex/baseswap-v3/contract-math/FixedPoint128.js +0 -8
  43. package/build/dex/baseswap-v3/contract-math/FixedPoint128.js.map +0 -1
  44. package/build/dex/baseswap-v3/contract-math/FixedPoint96.d.ts +0 -4
  45. package/build/dex/baseswap-v3/contract-math/FixedPoint96.js +0 -9
  46. package/build/dex/baseswap-v3/contract-math/FixedPoint96.js.map +0 -1
  47. package/build/dex/baseswap-v3/contract-math/FullMath.d.ts +0 -4
  48. package/build/dex/baseswap-v3/contract-math/FullMath.js +0 -19
  49. package/build/dex/baseswap-v3/contract-math/FullMath.js.map +0 -1
  50. package/build/dex/baseswap-v3/contract-math/LiquidityMath.d.ts +0 -3
  51. package/build/dex/baseswap-v3/contract-math/LiquidityMath.js +0 -22
  52. package/build/dex/baseswap-v3/contract-math/LiquidityMath.js.map +0 -1
  53. package/build/dex/baseswap-v3/contract-math/Oracle.d.ts +0 -10
  54. package/build/dex/baseswap-v3/contract-math/Oracle.js +0 -133
  55. package/build/dex/baseswap-v3/contract-math/Oracle.js.map +0 -1
  56. package/build/dex/baseswap-v3/contract-math/SqrtPriceMath.d.ts +0 -10
  57. package/build/dex/baseswap-v3/contract-math/SqrtPriceMath.js +0 -91
  58. package/build/dex/baseswap-v3/contract-math/SqrtPriceMath.js.map +0 -1
  59. package/build/dex/baseswap-v3/contract-math/SwapMath.d.ts +0 -8
  60. package/build/dex/baseswap-v3/contract-math/SwapMath.js +0 -70
  61. package/build/dex/baseswap-v3/contract-math/SwapMath.js.map +0 -1
  62. package/build/dex/baseswap-v3/contract-math/Tick.d.ts +0 -7
  63. package/build/dex/baseswap-v3/contract-math/Tick.js +0 -45
  64. package/build/dex/baseswap-v3/contract-math/Tick.js.map +0 -1
  65. package/build/dex/baseswap-v3/contract-math/TickBitMap.d.ts +0 -7
  66. package/build/dex/baseswap-v3/contract-math/TickBitMap.js +0 -84
  67. package/build/dex/baseswap-v3/contract-math/TickBitMap.js.map +0 -1
  68. package/build/dex/baseswap-v3/contract-math/TickMath.d.ts +0 -8
  69. package/build/dex/baseswap-v3/contract-math/TickMath.js +0 -162
  70. package/build/dex/baseswap-v3/contract-math/TickMath.js.map +0 -1
  71. package/build/dex/baseswap-v3/contract-math/UnsafeMath.d.ts +0 -3
  72. package/build/dex/baseswap-v3/contract-math/UnsafeMath.js +0 -10
  73. package/build/dex/baseswap-v3/contract-math/UnsafeMath.js.map +0 -1
  74. package/build/dex/baseswap-v3/contract-math/uniswap-v3-math.d.ts +0 -37
  75. package/build/dex/baseswap-v3/contract-math/uniswap-v3-math.js +0 -393
  76. package/build/dex/baseswap-v3/contract-math/uniswap-v3-math.js.map +0 -1
  77. package/build/dex/baseswap-v3/contract-math/utils.d.ts +0 -7
  78. package/build/dex/baseswap-v3/contract-math/utils.js +0 -42
  79. package/build/dex/baseswap-v3/contract-math/utils.js.map +0 -1
  80. package/build/dex/baseswap-v3/types.d.ts +0 -164
  81. package/build/dex/baseswap-v3/types.js +0 -9
  82. package/build/dex/baseswap-v3/types.js.map +0 -1
  83. package/build/dex/baseswap-v3/utils.d.ts +0 -6
  84. package/build/dex/baseswap-v3/utils.js +0 -65
  85. package/build/dex/baseswap-v3/utils.js.map +0 -1
  86. package/build/dex/hello/config.d.ts +0 -4
  87. package/build/dex/hello/config.js +0 -15
  88. package/build/dex/hello/config.js.map +0 -1
  89. package/build/dex/hello/hello-pool.d.ts +0 -39
  90. package/build/dex/hello/hello-pool.js +0 -64
  91. package/build/dex/hello/hello-pool.js.map +0 -1
  92. package/build/dex/hello/hello.d.ts +0 -37
  93. package/build/dex/hello/hello.js +0 -126
  94. package/build/dex/hello/hello.js.map +0 -1
  95. package/build/dex/hello/types.d.ts +0 -6
  96. package/build/dex/hello/types.js +0 -3
  97. package/build/dex/hello/types.js.map +0 -1
  98. package/build/dex/kyberswap-elastic/config.d.ts +0 -4
  99. package/build/dex/kyberswap-elastic/config.js +0 -80
  100. package/build/dex/kyberswap-elastic/config.js.map +0 -1
  101. package/build/dex/kyberswap-elastic/constants.d.ts +0 -17
  102. package/build/dex/kyberswap-elastic/constants.js +0 -42
  103. package/build/dex/kyberswap-elastic/constants.js.map +0 -1
  104. package/build/dex/kyberswap-elastic/contract-math/FixedPoint96.d.ts +0 -4
  105. package/build/dex/kyberswap-elastic/contract-math/FixedPoint96.js +0 -9
  106. package/build/dex/kyberswap-elastic/contract-math/FixedPoint96.js.map +0 -1
  107. package/build/dex/kyberswap-elastic/contract-math/FullMath.d.ts +0 -5
  108. package/build/dex/kyberswap-elastic/contract-math/FullMath.js +0 -22
  109. package/build/dex/kyberswap-elastic/contract-math/FullMath.js.map +0 -1
  110. package/build/dex/kyberswap-elastic/contract-math/LiqDeltaMath.d.ts +0 -3
  111. package/build/dex/kyberswap-elastic/contract-math/LiqDeltaMath.js +0 -12
  112. package/build/dex/kyberswap-elastic/contract-math/LiqDeltaMath.js.map +0 -1
  113. package/build/dex/kyberswap-elastic/contract-math/LiquidityMath.d.ts +0 -3
  114. package/build/dex/kyberswap-elastic/contract-math/LiquidityMath.js +0 -22
  115. package/build/dex/kyberswap-elastic/contract-math/LiquidityMath.js.map +0 -1
  116. package/build/dex/kyberswap-elastic/contract-math/QtyDeltaMath.d.ts +0 -5
  117. package/build/dex/kyberswap-elastic/contract-math/QtyDeltaMath.js +0 -25
  118. package/build/dex/kyberswap-elastic/contract-math/QtyDeltaMath.js.map +0 -1
  119. package/build/dex/kyberswap-elastic/contract-math/QuadMath.d.ts +0 -4
  120. package/build/dex/kyberswap-elastic/contract-math/QuadMath.js +0 -27
  121. package/build/dex/kyberswap-elastic/contract-math/QuadMath.js.map +0 -1
  122. package/build/dex/kyberswap-elastic/contract-math/ReinvestmentMath.d.ts +0 -3
  123. package/build/dex/kyberswap-elastic/contract-math/ReinvestmentMath.js +0 -14
  124. package/build/dex/kyberswap-elastic/contract-math/ReinvestmentMath.js.map +0 -1
  125. package/build/dex/kyberswap-elastic/contract-math/SafeCast.d.ts +0 -8
  126. package/build/dex/kyberswap-elastic/contract-math/SafeCast.js +0 -30
  127. package/build/dex/kyberswap-elastic/contract-math/SafeCast.js.map +0 -1
  128. package/build/dex/kyberswap-elastic/contract-math/SqrtPriceMath.d.ts +0 -10
  129. package/build/dex/kyberswap-elastic/contract-math/SqrtPriceMath.js +0 -91
  130. package/build/dex/kyberswap-elastic/contract-math/SqrtPriceMath.js.map +0 -1
  131. package/build/dex/kyberswap-elastic/contract-math/SwapMath.d.ts +0 -13
  132. package/build/dex/kyberswap-elastic/contract-math/SwapMath.js +0 -188
  133. package/build/dex/kyberswap-elastic/contract-math/SwapMath.js.map +0 -1
  134. package/build/dex/kyberswap-elastic/contract-math/TickLinkedList.d.ts +0 -6
  135. package/build/dex/kyberswap-elastic/contract-math/TickLinkedList.js +0 -41
  136. package/build/dex/kyberswap-elastic/contract-math/TickLinkedList.js.map +0 -1
  137. package/build/dex/kyberswap-elastic/contract-math/TickMath.d.ts +0 -9
  138. package/build/dex/kyberswap-elastic/contract-math/TickMath.js +0 -165
  139. package/build/dex/kyberswap-elastic/contract-math/TickMath.js.map +0 -1
  140. package/build/dex/kyberswap-elastic/contract-math/UnsafeMath.d.ts +0 -3
  141. package/build/dex/kyberswap-elastic/contract-math/UnsafeMath.js +0 -10
  142. package/build/dex/kyberswap-elastic/contract-math/UnsafeMath.js.map +0 -1
  143. package/build/dex/kyberswap-elastic/contract-math/kyberswap-elastic-math.d.ts +0 -28
  144. package/build/dex/kyberswap-elastic/contract-math/kyberswap-elastic-math.js +0 -502
  145. package/build/dex/kyberswap-elastic/contract-math/kyberswap-elastic-math.js.map +0 -1
  146. package/build/dex/kyberswap-elastic/contract-math/utils.d.ts +0 -3
  147. package/build/dex/kyberswap-elastic/contract-math/utils.js +0 -16
  148. package/build/dex/kyberswap-elastic/contract-math/utils.js.map +0 -1
  149. package/build/dex/kyberswap-elastic/errors.d.ts +0 -2
  150. package/build/dex/kyberswap-elastic/errors.js +0 -6
  151. package/build/dex/kyberswap-elastic/errors.js.map +0 -1
  152. package/build/dex/kyberswap-elastic/kyberswap-elastic-pool.d.ts +0 -80
  153. package/build/dex/kyberswap-elastic/kyberswap-elastic-pool.js +0 -458
  154. package/build/dex/kyberswap-elastic/kyberswap-elastic-pool.js.map +0 -1
  155. package/build/dex/kyberswap-elastic/kyberswap-elastic.d.ts +0 -53
  156. package/build/dex/kyberswap-elastic/kyberswap-elastic.js +0 -610
  157. package/build/dex/kyberswap-elastic/kyberswap-elastic.js.map +0 -1
  158. package/build/dex/kyberswap-elastic/types.d.ts +0 -134
  159. package/build/dex/kyberswap-elastic/types.js +0 -9
  160. package/build/dex/kyberswap-elastic/types.js.map +0 -1
  161. package/build/dex/kyberswap-elastic/utils/decoders.d.ts +0 -9
  162. package/build/dex/kyberswap-elastic/utils/decoders.js +0 -78
  163. package/build/dex/kyberswap-elastic/utils/decoders.js.map +0 -1
  164. package/build/dex/morphex/config.d.ts +0 -11
  165. package/build/dex/morphex/config.js +0 -43
  166. package/build/dex/morphex/config.js.map +0 -1
  167. package/build/dex/morphex/morphex.d.ts +0 -25
  168. package/build/dex/morphex/morphex.js +0 -19
  169. package/build/dex/morphex/morphex.js.map +0 -1
  170. package/build/dex/my-test-dex/config.d.ts +0 -4
  171. package/build/dex/my-test-dex/config.js +0 -15
  172. package/build/dex/my-test-dex/config.js.map +0 -1
  173. package/build/dex/my-test-dex/my-test-dex-pool.d.ts +0 -39
  174. package/build/dex/my-test-dex/my-test-dex-pool.js +0 -64
  175. package/build/dex/my-test-dex/my-test-dex-pool.js.map +0 -1
  176. package/build/dex/my-test-dex/my-test-dex.d.ts +0 -37
  177. package/build/dex/my-test-dex/my-test-dex.js +0 -126
  178. package/build/dex/my-test-dex/my-test-dex.js.map +0 -1
  179. package/build/dex/my-test-dex/types.d.ts +0 -6
  180. package/build/dex/my-test-dex/types.js +0 -3
  181. package/build/dex/my-test-dex/types.js.map +0 -1
  182. package/build/dex/solidly/forks-override/fvm.d.ts +0 -20
  183. package/build/dex/solidly/forks-override/fvm.js +0 -42
  184. package/build/dex/solidly/forks-override/fvm.js.map +0 -1
  185. package/build/dex/wombat/config.d.ts +0 -5
  186. package/build/dex/wombat/config.js +0 -50
  187. package/build/dex/wombat/config.js.map +0 -1
  188. package/build/dex/wombat/types.d.ts +0 -33
  189. package/build/dex/wombat/types.js +0 -3
  190. package/build/dex/wombat/types.js.map +0 -1
  191. package/build/dex/wombat/utils.d.ts +0 -9
  192. package/build/dex/wombat/utils.js +0 -66
  193. package/build/dex/wombat/utils.js.map +0 -1
  194. package/build/dex/wombat/wombat-bmw.d.ts +0 -40
  195. package/build/dex/wombat/wombat-bmw.js +0 -145
  196. package/build/dex/wombat/wombat-bmw.js.map +0 -1
  197. package/build/dex/wombat/wombat-pool.d.ts +0 -22
  198. package/build/dex/wombat/wombat-pool.js +0 -161
  199. package/build/dex/wombat/wombat-pool.js.map +0 -1
  200. package/build/dex/wombat/wombat-quoter.d.ts +0 -16
  201. package/build/dex/wombat/wombat-quoter.js +0 -176
  202. package/build/dex/wombat/wombat-quoter.js.map +0 -1
  203. package/build/dex/wombat/wombat.d.ts +0 -55
  204. package/build/dex/wombat/wombat.js +0 -292
  205. package/build/dex/wombat/wombat.js.map +0 -1
@@ -1,161 +0,0 @@
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.WombatPool = void 0;
7
- const abi_1 = require("@ethersproject/abi");
8
- const lodash_1 = __importDefault(require("lodash"));
9
- const stateful_rpc_poller_1 = require("../../lib/stateful-rpc-poller/stateful-rpc-poller");
10
- const state_polling_manager_1 = require("../../lib/stateful-rpc-poller/state-polling-manager");
11
- const utils_1 = require("../../lib/stateful-rpc-poller/utils");
12
- const decoders_1 = require("../../lib/decoders");
13
- const pool_json_1 = __importDefault(require("../../abi/wombat/pool.json"));
14
- const asset_json_1 = __importDefault(require("../../abi/wombat/asset.json"));
15
- const utils_2 = require("./utils");
16
- class WombatPool extends stateful_rpc_poller_1.StatefulRpcPoller {
17
- constructor(dexKey, poolIdentifier, dexHelper, poolAddress, asset2TokenMap) {
18
- const callbacks = (0, utils_1.pollingManagerCbExtractor)(state_polling_manager_1.StatePollingManager.getInstance(dexHelper));
19
- super(dexKey, poolIdentifier, dexHelper, 0, 0, false, callbacks);
20
- this.poolAddress = poolAddress;
21
- this.asset2TokenMap = asset2TokenMap;
22
- }
23
- _getFetchStateMultiCalls() {
24
- const params = [];
25
- params.push({
26
- target: this.poolAddress,
27
- callData: WombatPool.poolInterface.encodeFunctionData('paused'),
28
- decodeFunction: decoders_1.booleanDecode,
29
- });
30
- params.push({
31
- target: this.poolAddress,
32
- callData: WombatPool.poolInterface.encodeFunctionData('ampFactor'),
33
- decodeFunction: decoders_1.uint256ToBigInt,
34
- });
35
- params.push({
36
- target: this.poolAddress,
37
- callData: WombatPool.poolInterface.encodeFunctionData('haircutRate'),
38
- decodeFunction: decoders_1.uint256ToBigInt,
39
- });
40
- params.push({
41
- target: this.poolAddress,
42
- callData: WombatPool.poolInterface.encodeFunctionData('startCovRatio'),
43
- decodeFunction: decoders_1.uint256ToBigInt,
44
- });
45
- params.push({
46
- target: this.poolAddress,
47
- callData: WombatPool.poolInterface.encodeFunctionData('endCovRatio'),
48
- decodeFunction: decoders_1.uint256ToBigInt,
49
- });
50
- params.push({
51
- target: this.poolAddress,
52
- callData: WombatPool.poolInterface.encodeFunctionData('getTokens'),
53
- decodeFunction: decoders_1.addressArrayDecode,
54
- });
55
- this.asset2TokenMap.forEach((token, asset) => {
56
- params.push({
57
- target: this.poolAddress,
58
- callData: WombatPool.poolInterface.encodeFunctionData('isPaused', [
59
- token,
60
- ]),
61
- decodeFunction: decoders_1.booleanDecode,
62
- });
63
- params.push({
64
- target: asset,
65
- callData: WombatPool.assetInterface.encodeFunctionData('cash'),
66
- decodeFunction: utils_2.uint120ToBigInt,
67
- });
68
- params.push({
69
- target: asset,
70
- callData: WombatPool.assetInterface.encodeFunctionData('liability'),
71
- decodeFunction: utils_2.uint120ToBigInt,
72
- });
73
- params.push({
74
- target: asset,
75
- callData: WombatPool.assetInterface.encodeFunctionData('underlyingTokenDecimals'),
76
- decodeFunction: decoders_1.uint8ToNumber,
77
- });
78
- params.push({
79
- target: asset,
80
- callData: WombatPool.assetInterface.encodeFunctionData('getRelativePrice'),
81
- decodeFunction: decoders_1.uint256ToBigInt,
82
- });
83
- });
84
- return params;
85
- }
86
- _parseStateFromMultiResults(multiOutputs) {
87
- const [paused, ampFactor, haircutRate, startCovRatio, endCovRatio, tokens, ...remained] = multiOutputs;
88
- const assetTokenArray = Array.from(this.asset2TokenMap.entries());
89
- const token2AssetStates = new Map();
90
- lodash_1.default.chunk(remained, 5).forEach((chunk, i) => {
91
- const [paused, cash, liability, underlyingTokenDecimals, relativePrice] = chunk;
92
- const [asset, token] = assetTokenArray[i];
93
- token2AssetStates.set(token, {
94
- address: asset,
95
- paused,
96
- cash,
97
- liability,
98
- underlyingTokenDecimals,
99
- relativePrice,
100
- });
101
- });
102
- const poolState = {
103
- params: {
104
- paused,
105
- ampFactor,
106
- haircutRate,
107
- startCovRatio,
108
- endCovRatio,
109
- },
110
- underlyingAddresses: tokens,
111
- asset: {},
112
- };
113
- const isMainPool = Array.from(token2AssetStates.values()).filter(assetState => assetState.relativePrice === undefined).length > 0;
114
- for (const token of poolState.underlyingAddresses) {
115
- if (!token2AssetStates.has(token)) {
116
- // this happens when asset has been added to pool but is not added to BMW yet
117
- continue;
118
- }
119
- poolState.asset[token] = token2AssetStates.get(token);
120
- if (isMainPool) {
121
- poolState.asset[token].relativePrice = undefined;
122
- }
123
- }
124
- return poolState;
125
- }
126
- async fetchLatestStateFromRpc() {
127
- const multiCalls = this.getFetchStateWithBlockInfoMultiCalls();
128
- try {
129
- const lastUpdatedAtMs = Date.now();
130
- const aggregatedResults = (await this.dexHelper.multiWrapper.tryAggregate(false, multiCalls));
131
- return this.parseStateFromMultiResultsWithBlockInfo(aggregatedResults, lastUpdatedAtMs);
132
- }
133
- catch (e) {
134
- this._logMessageWithSuppression('ERROR_FETCHING_STATE_FROM_RPC', e);
135
- }
136
- return null;
137
- }
138
- parseStateFromMultiResultsWithBlockInfo(multiOutputs, lastUpdatedAtMs) {
139
- const [blockNumber, ...outputsForAbstract] = multiOutputs.map((m, i) => {
140
- return m.returnData;
141
- });
142
- return {
143
- value: this._parseStateFromMultiResults(outputsForAbstract),
144
- blockNumber,
145
- lastUpdatedAtMs,
146
- };
147
- }
148
- addAssets(asset2TokenMap) {
149
- for (const [asset, token] of asset2TokenMap) {
150
- if (this.asset2TokenMap.has(asset)) {
151
- continue;
152
- }
153
- this.asset2TokenMap.set(asset, token);
154
- this._cachedMultiCallData = undefined;
155
- }
156
- }
157
- }
158
- exports.WombatPool = WombatPool;
159
- WombatPool.poolInterface = new abi_1.Interface(pool_json_1.default);
160
- WombatPool.assetInterface = new abi_1.Interface(asset_json_1.default);
161
- //# sourceMappingURL=wombat-pool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wombat-pool.js","sourceRoot":"","sources":["../../../src/dex/wombat/wombat-pool.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA+C;AAE/C,oDAAuB;AAIvB,2FAAsF;AACtF,+F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AC;IAEM,SAAS,CAAC,cAAqC;QACpD,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,cAAc,EAAE;YAC3C,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;gBAClC,SAAS;aACV;YAED,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YACtC,IAAI,CAAC,oBAAoB,GAAG,SAAS,CAAC;SACvC;IACH,CAAC;;AAhNH,gCAiNC;AA7MiB,wBAAa,GAAG,IAAI,eAAS,CAAC,mBAAO,CAAC,CAAC;AACvC,yBAAc,GAAG,IAAI,eAAS,CAAC,oBAAQ,CAAC,CAAC"}
@@ -1,16 +0,0 @@
1
- import { AssetState, PoolParams } from './types';
2
- export declare class WombatQuoter {
3
- private readonly ampFactor;
4
- private readonly haircutRate;
5
- private readonly startCovRatio;
6
- private readonly endCovRatio;
7
- constructor(poolParams: PoolParams);
8
- getQuote(fromAsset: AssetState, toAsset: AssetState, fromAmount: bigint): bigint;
9
- private _highCovRatioPoolQuoteFrom;
10
- private _highCovRatioFee;
11
- private _quoteFrom;
12
- private _findUpperBound;
13
- private _quoteFactor;
14
- static solveQuad(b: bigint, c: bigint): bigint;
15
- static swapQuoteFunc(aX: bigint, aY: bigint, lX: bigint, lY: bigint, dX: bigint, a: bigint): bigint;
16
- }
@@ -1,176 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WombatQuoter = void 0;
4
- const utils_1 = require("./utils");
5
- class WombatQuoter {
6
- constructor(poolParams) {
7
- this.ampFactor = poolParams.ampFactor;
8
- this.haircutRate = poolParams.haircutRate;
9
- this.startCovRatio = poolParams.startCovRatio;
10
- this.endCovRatio = poolParams.endCovRatio;
11
- }
12
- getQuote(fromAsset, toAsset, fromAmount) {
13
- if (fromAmount === 0n || fromAsset.paused) {
14
- return 0n;
15
- }
16
- fromAmount = (0, utils_1.toWad)(fromAmount, BigInt(fromAsset.underlyingTokenDecimals));
17
- try {
18
- const { actualToAmount, haircut } = this._highCovRatioPoolQuoteFrom(fromAsset, toAsset, fromAmount);
19
- const toCash = toAsset.cash - actualToAmount - haircut;
20
- if ((0, utils_1.wdiv)(toCash, toAsset.liability) < utils_1.WAD / 100n) {
21
- return 0n;
22
- }
23
- return (0, utils_1.fromWad)(actualToAmount, BigInt(toAsset.underlyingTokenDecimals));
24
- }
25
- catch (e) {
26
- return 0n;
27
- }
28
- }
29
- _highCovRatioPoolQuoteFrom(fromAsset, toAsset, fromAmount) {
30
- let { actualToAmount, haircut } = this._quoteFrom(fromAsset, toAsset, fromAmount);
31
- if (fromAmount > 0n) {
32
- const fromCash = fromAsset.cash;
33
- const fromLiability = fromAsset.liability;
34
- const finalFromAssetCovRatio = (0, utils_1.wdiv)(fromCash + fromAmount, fromLiability);
35
- if (finalFromAssetCovRatio > this.startCovRatio) {
36
- // charge high cov ratio fee
37
- const highCovRatioFee = (0, utils_1.wmul)(this._highCovRatioFee((0, utils_1.wdiv)(fromCash, fromLiability), finalFromAssetCovRatio), actualToAmount);
38
- actualToAmount -= highCovRatioFee;
39
- haircut += highCovRatioFee;
40
- }
41
- }
42
- else {
43
- // reverse quote
44
- const toCash = toAsset.cash;
45
- const toLiability = toAsset.liability;
46
- const finalToAssetCovRatio = (0, utils_1.wdiv)(toCash + actualToAmount, toLiability);
47
- if (finalToAssetCovRatio <= this.startCovRatio) {
48
- // happy path: no high cov ratio fee is charged
49
- return { actualToAmount, haircut };
50
- }
51
- else if ((0, utils_1.wdiv)(toCash, toLiability) >= this.endCovRatio) {
52
- // the to-asset exceeds it's cov ratio limit, further swap to increase cov ratio is impossible
53
- throw new Error('WOMBAT_COV_RATIO_LIMIT_EXCEEDED');
54
- }
55
- // reverse quote: cov ratio of the to-asset exceed endCovRatio. direct reverse quote is not supported
56
- // we binary search for a upper bound
57
- actualToAmount = this._findUpperBound(toAsset, fromAsset, -fromAmount);
58
- const result = this._highCovRatioPoolQuoteFrom(toAsset, fromAsset, actualToAmount);
59
- haircut = result.haircut;
60
- }
61
- return { actualToAmount, haircut };
62
- }
63
- _highCovRatioFee(initCovRatio, finalCovRatio) {
64
- const startCovRatio = this.startCovRatio;
65
- const endCovRatio = this.endCovRatio;
66
- if (finalCovRatio > endCovRatio) {
67
- // invalid swap
68
- throw new Error('WOMBAT_COV_RATIO_LIMIT_EXCEEDED');
69
- }
70
- else if (finalCovRatio <= startCovRatio ||
71
- finalCovRatio <= initCovRatio) {
72
- return 0n;
73
- }
74
- // 1. Calculate the area of fee(r) = (r - startCovRatio) / (endCovRatio - startCovRatio)
75
- // when r increase from initCovRatio to finalCovRatio
76
- // 2. Then multiply it by (endCovRatio - startCovRatio) / (finalCovRatio - initCovRatio)
77
- // to get the average fee over the range
78
- const a = initCovRatio <= startCovRatio
79
- ? 0n
80
- : (initCovRatio - startCovRatio) * (initCovRatio - startCovRatio);
81
- const b = (finalCovRatio - startCovRatio) * (finalCovRatio - startCovRatio);
82
- return (0, utils_1.wdiv)((b - a) / (finalCovRatio - initCovRatio) / BigInt(2), endCovRatio - startCovRatio);
83
- }
84
- _quoteFrom(fromAsset, toAsset, fromAmount) {
85
- if (fromAmount < 0n) {
86
- fromAmount = (0, utils_1.wdiv)(fromAmount, utils_1.WAD - this.haircutRate);
87
- }
88
- let fromCash = fromAsset.cash;
89
- const toCash = toAsset.cash;
90
- let fromLiability = fromAsset.liability;
91
- const toLiability = toAsset.liability;
92
- const scaleFactor = this._quoteFactor(fromAsset, toAsset);
93
- if (scaleFactor !== utils_1.WAD) {
94
- fromCash = (fromCash * scaleFactor) / utils_1.WAD;
95
- fromLiability = (fromLiability * scaleFactor) / utils_1.WAD;
96
- fromAmount = (fromAmount * scaleFactor) / utils_1.WAD;
97
- }
98
- const idealToAmount = WombatQuoter.swapQuoteFunc(fromCash, toCash, fromLiability, toLiability, fromAmount, this.ampFactor);
99
- if ((fromAmount > 0n && toCash < idealToAmount) ||
100
- (fromAmount < 0n && fromCash < -fromAmount)) {
101
- throw new Error('WOMBAT_CASH_NOT_ENOUGH');
102
- }
103
- let actualToAmount, haircut;
104
- if (fromAmount > 0) {
105
- haircut = (0, utils_1.wmul)(idealToAmount, this.haircutRate);
106
- actualToAmount = idealToAmount - haircut;
107
- }
108
- else {
109
- actualToAmount = idealToAmount;
110
- haircut = (0, utils_1.wmul)(-fromAmount, this.haircutRate);
111
- }
112
- return { actualToAmount, haircut };
113
- }
114
- _findUpperBound(fromAsset, toAsset, toAmount) {
115
- const decimals = BigInt(fromAsset.underlyingTokenDecimals);
116
- const toWadFactor = (0, utils_1.toWad)(1n, decimals);
117
- // the search value uses the same number of digits as the token
118
- let high = (0, utils_1.fromWad)((0, utils_1.wmul)(fromAsset.liability, this.endCovRatio) - fromAsset.cash, decimals);
119
- let low = 1n;
120
- // verify `high` is a valid upper bound
121
- const { actualToAmount: quote } = this._highCovRatioPoolQuoteFrom(fromAsset, toAsset, high * toWadFactor);
122
- if (quote < toAmount) {
123
- throw new Error('WOMBAT_COV_RATIO_LIMIT_EXCEEDED');
124
- }
125
- // Note: we might limit the maximum number of rounds if the request is always rejected by the RPC server
126
- while (low < high) {
127
- const mid = (low + high) / BigInt(2);
128
- const { actualToAmount: quote } = this._highCovRatioPoolQuoteFrom(fromAsset, toAsset, mid * toWadFactor);
129
- if (quote >= toAmount) {
130
- high = mid;
131
- }
132
- else {
133
- low = mid + 1n;
134
- }
135
- }
136
- return high * toWadFactor;
137
- }
138
- _quoteFactor(fromAsset, toAsset) {
139
- if (!fromAsset.relativePrice || !toAsset.relativePrice) {
140
- return utils_1.WAD;
141
- }
142
- return (utils_1.WAD * fromAsset.relativePrice) / toAsset.relativePrice;
143
- }
144
- static solveQuad(b, c) {
145
- return ((0, utils_1.sqrt)(b * b + c * 4n * utils_1.WAD, b) - b) / 2n;
146
- }
147
- static swapQuoteFunc(aX, aY, lX, lY, dX, a) {
148
- if (lX == 0n || lY == 0n) {
149
- // in case div of 0, CORE_UNDERFLOW
150
- return 0n;
151
- }
152
- // int256 D = Ax + Ay - A.wmul((Lx * Lx) / Ax + (Ly * Ly) / Ay); // flattened _invariantFunc
153
- const d = aX + aY - (0, utils_1.wmul)(a, (lX * lX) / aX + (lY * lY) / aY);
154
- // int256 rx_ = (Ax + Dx).wdiv(Lx);
155
- const rX = (0, utils_1.wdiv)(aX + dX, lX);
156
- // int256 b = (Lx * (rx_ - A.wdiv(rx_))) / Ly - D.wdiv(Ly); // flattened _coefficientFunc
157
- const b = (lX * (rX - (0, utils_1.wdiv)(a, rX))) / lY - (0, utils_1.wdiv)(d, lY);
158
- // int256 ry_ = _solveQuad(b, A);
159
- const rY = WombatQuoter.solveQuad(b, a);
160
- // int256 Dy = Ly.wmul(ry_) - Ay;
161
- const dY = (0, utils_1.wmul)(lY, rY) - aY;
162
- // if (Dy < 0) {
163
- // quote = uint256(-Dy);
164
- // } else {
165
- // quote = uint256(Dy);
166
- // }
167
- if (dY < 0n) {
168
- return -dY;
169
- }
170
- else {
171
- return dY;
172
- }
173
- }
174
- }
175
- exports.WombatQuoter = WombatQuoter;
176
- //# sourceMappingURL=wombat-quoter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wombat-quoter.js","sourceRoot":"","sources":["../../../src/dex/wombat/wombat-quoter.ts"],"names":[],"mappings":";;;AACA,mCAAgE;AAEhE,MAAa,YAAY;IAMvB,YAAY,UAAsB;QAChC,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC;QAC1C,IAAI,CAAC,aAAa,GAAG,UAAU,CAAC,aAAa,CAAC;QAC9C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC;IAC5C,CAAC;IAEM,QAAQ,CACb,SAAqB,EACrB,OAAmB,EACnB,UAAkB;QAElB,IAAI,UAAU,KAAK,EAAE,IAAI,SAAS,CAAC,MAAM,EAAE;YACzC,OAAO,EAAE,CAAC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,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;QAC7D,mCAAmC;QACnC,MAAM,EAAE,GAAG,IAAA,YAAI,EAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;QAC7B,yFAAyF;QACzF,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,IAAA,YAAI,EAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,IAAA,YAAI,EAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACvD,iCAAiC;QACjC,MAAM,EAAE,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACxC,iCAAiC;QACjC,MAAM,EAAE,GAAG,IAAA,YAAI,EAAC,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC;QAE7B,gBAAgB;QAChB,4BAA4B;QAC5B,WAAW;QACX,2BAA2B;QAC3B,IAAI;QACJ,IAAI,EAAE,GAAG,EAAE,EAAE;YACX,OAAO,CAAC,EAAE,CAAC;SACZ;aAAM;YACL,OAAO,EAAE,CAAC;SACX;IACH,CAAC;CACF;AAzQD,oCAyQC"}
@@ -1,55 +0,0 @@
1
- import { AsyncOrSync, DeepReadonly } from 'ts-essentials';
2
- import { Interface } from '@ethersproject/abi';
3
- import { SwapSide } from '@paraswap/core';
4
- import { AdapterExchangeParam, Address, ExchangePrices, Logger, PoolLiquidity, PoolPrices, SimpleExchangeParam, Token } from '../../types';
5
- import { Network } from '../../constants';
6
- import { IDex } from '../idex';
7
- import { IDexHelper } from '../../dex-helper';
8
- import { DexParams, PoolState, WombatData } from './types';
9
- import { SimpleExchange } from '../simple-exchange';
10
- import { WombatBmw } from './wombat-bmw';
11
- import { WombatPool } from './wombat-pool';
12
- export declare class Wombat extends SimpleExchange implements IDex<WombatData> {
13
- readonly network: Network;
14
- readonly dexKey: string;
15
- readonly dexHelper: IDexHelper;
16
- protected adapters: import("../../types").AdapterMappings;
17
- static readonly erc20Interface: Interface;
18
- static readonly poolInterface: Interface;
19
- static readonly assetInterface: Interface;
20
- protected config: DexParams;
21
- protected poolLiquidityUSD?: {
22
- [poolAddress: string]: number;
23
- };
24
- bmw: WombatBmw;
25
- pools: {
26
- [poolAddress: string]: WombatPool;
27
- };
28
- readonly hasConstantPriceLargeAmounts = false;
29
- readonly needWrapNative = true;
30
- readonly isFeeOnTransferSupported = false;
31
- static dexKeysWithNetwork: {
32
- key: string;
33
- networks: Network[];
34
- }[];
35
- logger: Logger;
36
- constructor(network: Network, dexKey: string, dexHelper: IDexHelper, adapters?: import("../../types").AdapterMappings);
37
- init(blockNumber: number): Promise<void>;
38
- initializePricing(blockNumber: number): Promise<void>;
39
- onAssetAdded: (pool: Address, asset2TokenMap: Map<Address, Address>, blockNumber: number) => void;
40
- getAdapters(side: SwapSide): {
41
- name: string;
42
- index: number;
43
- }[] | null;
44
- getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
45
- protected getPoolIdentifier(poolAddress: Address): string;
46
- getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<WombatData>>;
47
- protected computePrices(srcTokenAddress: Address, destTokenAddress: Address, amounts: bigint[], side: SwapSide, state: DeepReadonly<PoolState>): bigint[];
48
- protected findPools(srcTokenAddress: Address, destTokenAddress: Address, blockNumber: number, liquidityThresholdInUSD?: number): Promise<Address[]>;
49
- getCalldataGasCost(poolPrices: PoolPrices<WombatData>): number | number[];
50
- getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: WombatData, side: SwapSide): AdapterExchangeParam;
51
- getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: WombatData, side: SwapSide): Promise<SimpleExchangeParam>;
52
- updatePoolState(): Promise<void>;
53
- getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
54
- releaseResources(): AsyncOrSync<void>;
55
- }