@paraswap/dex-lib 4.7.12 → 4.7.13-from-amount-pos.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 (215) hide show
  1. package/build/abi/PendleRouterStatic.json +19 -0
  2. package/build/abi/{MStableAsset.json → apex-defi/ApexDefiFactory.abi.json} +992 -788
  3. package/build/abi/{BProtocol.json → apex-defi/ApexDefiRouter.abi.json} +539 -574
  4. package/build/abi/apex-defi/ApexDefiToken.abi.json +229 -0
  5. package/build/abi/apex-defi/ApexDefiWrapper.abi.json +92 -0
  6. package/build/abi/{OneInchLp.json → apex-defi/ApexDefiWrapperFactory.abi.json} +577 -774
  7. package/build/abi/pangolin-v3/PangolinV3StateMulticall.abi.json +796 -0
  8. package/build/abi/pendle/pendle-deployer.abi.json +520 -0
  9. package/build/abi/pendle/pendle-oracle.abi.json +413 -0
  10. package/build/abi/ring-v2/few-wrapped-token.json +587 -0
  11. package/build/abi/ring-v2/ring-v2-factory.json +125 -0
  12. package/build/abi/ring-v2/ring-v2-pool.json +461 -0
  13. package/build/abi/ring-v2/ring-v2-router.json +332 -0
  14. package/build/abi/stabull/stabull-curve.json +738 -0
  15. package/build/abi/stabull/stabull-router.json +76 -0
  16. package/build/abi/uniswap-v4/hooks/SpotDynamicFeeManager.json +26 -0
  17. package/build/abi/uniswap-v4/hooks/SpotHook.json +54 -0
  18. package/build/abi/uniswap-v4/hooks/SpotPolicyManager.json +45 -0
  19. package/build/abi/uniswap-v4/hooks/cabalcoin-hook.abi.json +682 -0
  20. package/build/abi/uniswap-v4/hooks/fee-hook.abi.json +1335 -0
  21. package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying-factory.d.ts +29 -0
  22. package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying-factory.js +153 -0
  23. package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying-factory.js.map +1 -0
  24. package/build/dex/{usual-bond/usual-bond.d.ts → aave-pt-to-underlying/aave-pt-to-underlying.d.ts} +23 -18
  25. package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying.js +323 -0
  26. package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying.js.map +1 -0
  27. package/build/dex/aave-pt-to-underlying/config.d.ts +3 -0
  28. package/build/dex/aave-pt-to-underlying/config.js +24 -0
  29. package/build/dex/aave-pt-to-underlying/config.js.map +1 -0
  30. package/build/dex/aave-pt-to-underlying/constants.d.ts +2 -0
  31. package/build/dex/aave-pt-to-underlying/constants.js +6 -0
  32. package/build/dex/aave-pt-to-underlying/constants.js.map +1 -0
  33. package/build/dex/aave-pt-to-underlying/types.d.ts +24 -0
  34. package/build/dex/aave-pt-to-underlying/types.js.map +1 -0
  35. package/build/dex/aave-pt-to-usdc/aave-pt-to-usdc.d.ts +39 -0
  36. package/build/dex/aave-pt-to-usdc/aave-pt-to-usdc.js +244 -0
  37. package/build/dex/aave-pt-to-usdc/aave-pt-to-usdc.js.map +1 -0
  38. package/build/dex/aave-pt-to-usdc/config.d.ts +3 -0
  39. package/build/dex/aave-pt-to-usdc/config.js +47 -0
  40. package/build/dex/aave-pt-to-usdc/config.js.map +1 -0
  41. package/build/dex/aave-pt-to-usdc/constants.d.ts +2 -0
  42. package/build/dex/aave-pt-to-usdc/constants.js +6 -0
  43. package/build/dex/aave-pt-to-usdc/constants.js.map +1 -0
  44. package/build/dex/aave-pt-to-usdc/types.d.ts +22 -0
  45. package/build/dex/aave-pt-to-usdc/types.js.map +1 -0
  46. package/build/dex/apex-defi/apex-defi-factory.d.ts +26 -0
  47. package/build/dex/apex-defi/apex-defi-factory.js +53 -0
  48. package/build/dex/apex-defi/apex-defi-factory.js.map +1 -0
  49. package/build/dex/apex-defi/apex-defi-pool.d.ts +55 -0
  50. package/build/dex/apex-defi/apex-defi-pool.js +247 -0
  51. package/build/dex/apex-defi/apex-defi-pool.js.map +1 -0
  52. package/build/dex/apex-defi/apex-defi-wrapper-factory.d.ts +57 -0
  53. package/build/dex/apex-defi/apex-defi-wrapper-factory.js +250 -0
  54. package/build/dex/apex-defi/apex-defi-wrapper-factory.js.map +1 -0
  55. package/build/dex/apex-defi/apex-defi.d.ts +97 -0
  56. package/build/dex/apex-defi/apex-defi.js +1021 -0
  57. package/build/dex/apex-defi/apex-defi.js.map +1 -0
  58. package/build/dex/apex-defi/config.d.ts +4 -0
  59. package/build/dex/apex-defi/config.js +138 -0
  60. package/build/dex/apex-defi/config.js.map +1 -0
  61. package/build/dex/apex-defi/types.d.ts +32 -0
  62. package/build/dex/apex-defi/types.js +3 -0
  63. package/build/dex/{usual-bond → apex-defi}/types.js.map +1 -1
  64. package/build/dex/apex-defi/utils.d.ts +46 -0
  65. package/build/dex/apex-defi/utils.js +133 -0
  66. package/build/dex/apex-defi/utils.js.map +1 -0
  67. package/build/dex/maker-psm/maker-psm-event-pool.d.ts +43 -0
  68. package/build/dex/maker-psm/maker-psm-event-pool.js +132 -0
  69. package/build/dex/maker-psm/maker-psm-event-pool.js.map +1 -0
  70. package/build/dex/miro-migrator/miro-migrator-state.d.ts +27 -0
  71. package/build/dex/miro-migrator/miro-migrator-state.js +89 -0
  72. package/build/dex/miro-migrator/miro-migrator-state.js.map +1 -0
  73. package/build/dex/{usual-bond → stabull}/config.d.ts +1 -1
  74. package/build/dex/stabull/config.js +177 -0
  75. package/build/dex/stabull/config.js.map +1 -0
  76. package/build/dex/{se-vlr/se-vlr-pool.d.ts → stabull/stabull-pool.d.ts} +13 -6
  77. package/build/dex/stabull/stabull-pool.js +113 -0
  78. package/build/dex/stabull/stabull-pool.js.map +1 -0
  79. package/build/dex/stabull/stabull.d.ts +55 -0
  80. package/build/dex/stabull/stabull.js +286 -0
  81. package/build/dex/stabull/stabull.js.map +1 -0
  82. package/build/dex/stabull/types.d.ts +21 -0
  83. package/build/dex/stabull/types.js +3 -0
  84. package/build/dex/stabull/types.js.map +1 -0
  85. package/build/dex/uniswap-v3/forks/pangolin-v3/utils.d.ts +4 -0
  86. package/build/dex/uniswap-v3/forks/pangolin-v3/utils.js +56 -0
  87. package/build/dex/uniswap-v3/forks/pangolin-v3/utils.js.map +1 -0
  88. package/build/dex/uniswap-v4/contract-math/Position.d.ts +6 -0
  89. package/build/dex/uniswap-v4/contract-math/Position.js +29 -0
  90. package/build/dex/uniswap-v4/contract-math/Position.js.map +1 -1
  91. package/build/dex/uniswap-v4/hooks/cabalcoin-hook/cabalcoin-hook-pool.d.ts +7 -0
  92. package/build/dex/uniswap-v4/hooks/cabalcoin-hook/cabalcoin-hook-pool.js +28 -0
  93. package/build/dex/uniswap-v4/hooks/cabalcoin-hook/cabalcoin-hook-pool.js.map +1 -0
  94. package/build/dex/uniswap-v4/hooks/cabalcoin-hook/types.d.ts +0 -0
  95. package/build/dex/uniswap-v4/hooks/cabalcoin-hook/types.js +2 -0
  96. package/build/dex/uniswap-v4/hooks/cabalcoin-hook/types.js.map +1 -0
  97. package/build/dex/uniswap-v4/hooks/fee-hook/fee-hook-pool.d.ts +7 -0
  98. package/build/dex/uniswap-v4/hooks/fee-hook/fee-hook-pool.js +28 -0
  99. package/build/dex/uniswap-v4/hooks/fee-hook/fee-hook-pool.js.map +1 -0
  100. package/build/dex/uniswap-v4/hooks/fee-hook/types.d.ts +0 -0
  101. package/build/dex/uniswap-v4/hooks/fee-hook/types.js +2 -0
  102. package/build/dex/uniswap-v4/hooks/fee-hook/types.js.map +1 -0
  103. package/build/dex/uniswap-v4/hooks/index.d.ts +1 -0
  104. package/build/dex/uniswap-v4/hooks/index.js +9 -0
  105. package/build/dex/uniswap-v4/hooks/index.js.map +1 -0
  106. package/build/dex/uniswap-v4/hooks/spot.d.ts +15 -0
  107. package/build/dex/uniswap-v4/hooks/spot.js +109 -0
  108. package/build/dex/uniswap-v4/hooks/spot.js.map +1 -0
  109. package/build/dex/uniswap-v4/hooks/template.d.ts +150 -0
  110. package/build/dex/uniswap-v4/hooks/template.js +104 -0
  111. package/build/dex/uniswap-v4/hooks/template.js.map +1 -0
  112. package/build/dex/usdc-transmuter/usdc-transmuter-pool.d.ts +26 -0
  113. package/build/dex/usdc-transmuter/usdc-transmuter-pool.js +75 -0
  114. package/build/dex/usdc-transmuter/usdc-transmuter-pool.js.map +1 -0
  115. package/build/dex/usual/usual-usdc-usdc.d.ts +17 -0
  116. package/build/dex/usual/usual-usdc-usdc.js +59 -0
  117. package/build/dex/usual/usual-usdc-usdc.js.map +1 -0
  118. package/build/dex/{se-vlr → yo}/config.d.ts +1 -1
  119. package/build/dex/yo/config.js +21 -0
  120. package/build/dex/yo/config.js.map +1 -0
  121. package/build/dex/yo/types.d.ts +13 -0
  122. package/build/dex/yo/types.js +3 -0
  123. package/build/dex/{se-vlr → yo}/types.js.map +1 -1
  124. package/build/dex/yo/yo-pool.d.ts +13 -0
  125. package/build/dex/yo/yo-pool.js +26 -0
  126. package/build/dex/yo/yo-pool.js.map +1 -0
  127. package/build/dex/yo/yo.d.ts +39 -0
  128. package/build/dex/yo/yo.js +248 -0
  129. package/build/dex/yo/yo.js.map +1 -0
  130. package/build/executor/Executor01BytecodeBuilder.js +10 -4
  131. package/build/executor/Executor01BytecodeBuilder.js.map +1 -1
  132. package/build/implementations/api-paraswap-sdk.d.ts +25 -0
  133. package/build/implementations/api-paraswap-sdk.js +102 -0
  134. package/build/implementations/api-paraswap-sdk.js.map +1 -0
  135. package/package.json +1 -1
  136. package/build/abi/Jarvis.json +0 -1172
  137. package/build/abi/Onebit.json +0 -736
  138. package/build/abi/Shell.json +0 -1294
  139. package/build/abi/TraderJoeV2Router.json +0 -50
  140. package/build/abi/wUSDM.json +0 -757
  141. package/build/abi/zrx.v2.json +0 -1967
  142. package/build/abi/zrx.v3.json +0 -3454
  143. package/build/abi/zrx.v4.json +0 -2193
  144. package/build/dex/OneInchLp.d.ts +0 -24
  145. package/build/dex/OneInchLp.js +0 -43
  146. package/build/dex/OneInchLp.js.map +0 -1
  147. package/build/dex/bProtocol/bProtocol.d.ts +0 -15
  148. package/build/dex/bProtocol/bProtocol.js +0 -56
  149. package/build/dex/bProtocol/bProtocol.js.map +0 -1
  150. package/build/dex/bProtocol/types.d.ts +0 -11
  151. package/build/dex/bProtocol/types.js +0 -8
  152. package/build/dex/bProtocol/types.js.map +0 -1
  153. package/build/dex/jarvis.d.ts +0 -56
  154. package/build/dex/jarvis.js +0 -163
  155. package/build/dex/jarvis.js.map +0 -1
  156. package/build/dex/mStable.d.ts +0 -44
  157. package/build/dex/mStable.js +0 -75
  158. package/build/dex/mStable.js.map +0 -1
  159. package/build/dex/onebit/onebit.d.ts +0 -16
  160. package/build/dex/onebit/onebit.js +0 -61
  161. package/build/dex/onebit/onebit.js.map +0 -1
  162. package/build/dex/onebit/types.d.ts +0 -14
  163. package/build/dex/onebit/types.js +0 -8
  164. package/build/dex/onebit/types.js.map +0 -1
  165. package/build/dex/se-vlr/config.js +0 -24
  166. package/build/dex/se-vlr/config.js.map +0 -1
  167. package/build/dex/se-vlr/se-vlr-pool.js +0 -70
  168. package/build/dex/se-vlr/se-vlr-pool.js.map +0 -1
  169. package/build/dex/se-vlr/se-vlr.d.ts +0 -35
  170. package/build/dex/se-vlr/se-vlr.js +0 -131
  171. package/build/dex/se-vlr/se-vlr.js.map +0 -1
  172. package/build/dex/se-vlr/types.d.ts +0 -6
  173. package/build/dex/shell.d.ts +0 -25
  174. package/build/dex/shell.js +0 -41
  175. package/build/dex/shell.js.map +0 -1
  176. package/build/dex/trader-joe-v2.d.ts +0 -40
  177. package/build/dex/trader-joe-v2.js +0 -74
  178. package/build/dex/trader-joe-v2.js.map +0 -1
  179. package/build/dex/uniswap-v3/uniswap-v3-new.d.ts +0 -94
  180. package/build/dex/uniswap-v3/uniswap-v3-new.js +0 -923
  181. package/build/dex/uniswap-v3/uniswap-v3-new.js.map +0 -1
  182. package/build/dex/usual-bond/config.js +0 -13
  183. package/build/dex/usual-bond/config.js.map +0 -1
  184. package/build/dex/usual-bond/types.d.ts +0 -7
  185. package/build/dex/usual-bond/usual-bond.js +0 -176
  186. package/build/dex/usual-bond/usual-bond.js.map +0 -1
  187. package/build/dex/wusdm/config.d.ts +0 -3
  188. package/build/dex/wusdm/config.js +0 -43
  189. package/build/dex/wusdm/config.js.map +0 -1
  190. package/build/dex/wusdm/constants.d.ts +0 -2
  191. package/build/dex/wusdm/constants.js +0 -6
  192. package/build/dex/wusdm/constants.js.map +0 -1
  193. package/build/dex/wusdm/types.d.ts +0 -18
  194. package/build/dex/wusdm/types.js +0 -11
  195. package/build/dex/wusdm/types.js.map +0 -1
  196. package/build/dex/wusdm/wusdm-pool.d.ts +0 -21
  197. package/build/dex/wusdm/wusdm-pool.js +0 -74
  198. package/build/dex/wusdm/wusdm-pool.js.map +0 -1
  199. package/build/dex/wusdm/wusdm.d.ts +0 -46
  200. package/build/dex/wusdm/wusdm.js +0 -243
  201. package/build/dex/wusdm/wusdm.js.map +0 -1
  202. package/build/dex/zerox/config.d.ts +0 -2
  203. package/build/dex/zerox/config.js +0 -33
  204. package/build/dex/zerox/config.js.map +0 -1
  205. package/build/dex/zerox/index.d.ts +0 -22
  206. package/build/dex/zerox/index.js +0 -225
  207. package/build/dex/zerox/index.js.map +0 -1
  208. package/build/dex/zerox/order.d.ts +0 -88
  209. package/build/dex/zerox/order.js +0 -53
  210. package/build/dex/zerox/order.js.map +0 -1
  211. package/build/dex/zerox/types.d.ts +0 -73
  212. package/build/dex/zerox/types.js +0 -21
  213. package/build/dex/zerox/types.js.map +0 -1
  214. /package/build/dex/{se-vlr → aave-pt-to-underlying}/types.js +0 -0
  215. /package/build/dex/{usual-bond → aave-pt-to-usdc}/types.js +0 -0
@@ -0,0 +1,27 @@
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 { MiroMigratorState } from './types';
7
+ export declare class MiroMigratorEventState extends StatefulEventSubscriber<MiroMigratorState> {
8
+ readonly parentName: string;
9
+ protected network: number;
10
+ protected dexHelper: IDexHelper;
11
+ protected migratorAddress: string;
12
+ protected xyzAddress: string;
13
+ protected transferTopic: string;
14
+ protected migratorInterface: Interface;
15
+ protected xyzInterface: Interface;
16
+ handlers: {
17
+ [event: string]: (event: any, state: DeepReadonly<MiroMigratorState>, log: Readonly<Log>) => DeepReadonly<MiroMigratorState> | null;
18
+ };
19
+ logDecoder: (log: Log) => any;
20
+ addressesSubscribed: string[];
21
+ constructor(parentName: string, network: number, dexHelper: IDexHelper, logger: Logger, migratorAddress: string, xyzAddress: string, transferTopic: string, migratorInterface?: Interface, xyzInterface?: Interface);
22
+ protected processLog(state: DeepReadonly<MiroMigratorState>, log: Readonly<Log>): Promise<DeepReadonly<MiroMigratorState> | null>;
23
+ generateState(blockNumber?: number | 'latest'): Promise<DeepReadonly<MiroMigratorState>>;
24
+ getOrGenerateState(blockNumber: number): Promise<MiroMigratorState>;
25
+ handleTransferTo(event: any, state: DeepReadonly<MiroMigratorState>, log: Readonly<Log>): Promise<DeepReadonly<MiroMigratorState>>;
26
+ handleTransferFrom(event: any, state: DeepReadonly<MiroMigratorState>, log: Readonly<Log>): Promise<DeepReadonly<MiroMigratorState>>;
27
+ }
@@ -0,0 +1,89 @@
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.MiroMigratorEventState = void 0;
7
+ const abi_1 = require("@ethersproject/abi");
8
+ const utils_1 = require("../../utils");
9
+ const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
10
+ const decoders_1 = require("../../lib/decoders");
11
+ const MiroMigrator_abi_json_1 = __importDefault(require("../../abi/miro-migrator/MiroMigrator.abi.json"));
12
+ const erc20_json_1 = __importDefault(require("../../abi/erc20.json"));
13
+ class MiroMigratorEventState extends stateful_event_subscriber_1.StatefulEventSubscriber {
14
+ parentName;
15
+ network;
16
+ dexHelper;
17
+ migratorAddress;
18
+ xyzAddress;
19
+ transferTopic;
20
+ migratorInterface;
21
+ xyzInterface;
22
+ handlers = {};
23
+ logDecoder;
24
+ addressesSubscribed;
25
+ constructor(parentName, network, dexHelper, logger, migratorAddress, xyzAddress, transferTopic, migratorInterface = new abi_1.Interface(MiroMigrator_abi_json_1.default), xyzInterface = new abi_1.Interface(erc20_json_1.default)) {
26
+ super(parentName, 'state', dexHelper, logger);
27
+ this.parentName = parentName;
28
+ this.network = network;
29
+ this.dexHelper = dexHelper;
30
+ this.migratorAddress = migratorAddress;
31
+ this.xyzAddress = xyzAddress;
32
+ this.transferTopic = transferTopic;
33
+ this.migratorInterface = migratorInterface;
34
+ this.xyzInterface = xyzInterface;
35
+ this.logDecoder = (log) => this.migratorInterface.parseLog(log);
36
+ this.addressesSubscribed = [xyzAddress];
37
+ }
38
+ async processLog(state, log) {
39
+ try {
40
+ const event = this.logDecoder(log);
41
+ if (log.topics[0] === this.transferTopic &&
42
+ event.args.to.toLowerCase() === this.migratorAddress.toLowerCase()) {
43
+ return this.handleTransferTo(event, state, log);
44
+ }
45
+ if (log.topics[0] === this.transferTopic &&
46
+ event.args.from.toLowerCase() === this.migratorAddress.toLowerCase()) {
47
+ return this.handleTransferFrom(event, state, log);
48
+ }
49
+ return null;
50
+ }
51
+ catch (e) {
52
+ (0, utils_1.catchParseLogError)(e, this.logger);
53
+ return null;
54
+ }
55
+ }
56
+ async generateState(blockNumber = 'latest') {
57
+ const calls = [
58
+ {
59
+ target: this.xyzAddress,
60
+ callData: this.xyzInterface.encodeFunctionData('balanceOf', [
61
+ this.migratorAddress,
62
+ ]),
63
+ decodeFunction: decoders_1.uint256ToBigInt,
64
+ },
65
+ ];
66
+ const [balance] = await this.dexHelper.multiWrapper.tryAggregate(true, calls, blockNumber);
67
+ return { balance: balance.returnData };
68
+ }
69
+ async getOrGenerateState(blockNumber) {
70
+ let state = this.getState(blockNumber);
71
+ if (!state) {
72
+ state = await this.generateState(blockNumber);
73
+ this.setState(state, blockNumber);
74
+ }
75
+ return state;
76
+ }
77
+ async handleTransferTo(event, state, log) {
78
+ return {
79
+ balance: state.balance + BigInt(event.args.value),
80
+ };
81
+ }
82
+ async handleTransferFrom(event, state, log) {
83
+ return {
84
+ balance: state.balance - BigInt(event.args.value),
85
+ };
86
+ }
87
+ }
88
+ exports.MiroMigratorEventState = MiroMigratorEventState;
89
+ //# sourceMappingURL=miro-migrator-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"miro-migrator-state.js","sourceRoot":"","sources":["../../../src/dex/miro-migrator/miro-migrator-state.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA+C;AAG/C,uCAAiD;AACjD,+EAA0E;AAG1E,iDAAqD;AACrD,0GAA4E;AAC5E,sEAA4C;AAE5C,MAAa,sBAAuB,SAAQ,mDAA0C;IAczE;IACC;IACA;IAEA;IACA;IACA;IACA;IACA;IArBZ,QAAQ,GAMJ,EAAE,CAAC;IAEP,UAAU,CAAoB;IAE9B,mBAAmB,CAAW;IAE9B,YACW,UAAkB,EACjB,OAAe,EACf,SAAqB,EAC/B,MAAc,EACJ,eAAuB,EACvB,UAAkB,EAClB,aAAqB,EACrB,oBAA+B,IAAI,eAAS,CAAC,+BAAe,CAAC,EAC7D,eAA0B,IAAI,eAAS,CAAC,oBAAQ,CAAC;QAE3D,KAAK,CAAC,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QAVrC,eAAU,GAAV,UAAU,CAAQ;QACjB,YAAO,GAAP,OAAO,CAAQ;QACf,cAAS,GAAT,SAAS,CAAY;QAErB,oBAAe,GAAf,eAAe,CAAQ;QACvB,eAAU,GAAV,UAAU,CAAQ;QAClB,kBAAa,GAAb,aAAa,CAAQ;QACrB,sBAAiB,GAAjB,iBAAiB,CAA4C;QAC7D,iBAAY,GAAZ,YAAY,CAAqC;QAG3D,IAAI,CAAC,UAAU,GAAG,CAAC,GAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,iBA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AEF,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,YAAY,CAC9D,IAAI,EACJ,KAAK,EACL,WAAW,CACZ,CAAC;QAEF,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,WAAmB;QAC1C,IAAI,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACvC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,KAAK,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;YAC9C,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,CAAC,gBAAgB,CACpB,KAAU,EACV,KAAsC,EACtC,GAAkB;QAElB,OAAO;YACL,OAAO,EAAE,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;SAClD,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,kBAAkB,CACtB,KAAU,EACV,KAAsC,EACtC,GAAkB;QAElB,OAAO;YACL,OAAO,EAAE,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;SAClD,CAAC;IACJ,CAAC;CACF;AA3GD,wDA2GC"}
@@ -1,3 +1,3 @@
1
1
  import { DexParams } from './types';
2
2
  import { DexConfigMap } from '../../types';
3
- export declare const UsualBondConfig: DexConfigMap<DexParams>;
3
+ export declare const StabullConfig: DexConfigMap<DexParams>;
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StabullConfig = void 0;
4
+ const constants_1 = require("../../constants");
5
+ exports.StabullConfig = {
6
+ Stabull: {
7
+ [constants_1.Network.MAINNET]: {
8
+ router: '0x871af97122d08890193e8d6465015f6d9e2889b2',
9
+ quoteCurrency: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
10
+ pools: {
11
+ '0xe37d763c7c4cdd9a8f085f7db70139a0843529f3': {
12
+ tokens: [
13
+ {
14
+ address: '0xda446fad08277b4d2591536f204e018f32b6831c',
15
+ decimals: 18,
16
+ }, // NZDS
17
+ {
18
+ address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
19
+ decimals: 6,
20
+ }, // USDC
21
+ ],
22
+ },
23
+ '0x865040f92ac6cca1b9683c03d843799d8e6d1282': {
24
+ tokens: [
25
+ {
26
+ address: '0xdb25f211ab05b1c97d595516f45794528a807ad8',
27
+ decimals: 2,
28
+ }, // EURS
29
+ {
30
+ address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
31
+ decimals: 6,
32
+ }, // USDC
33
+ ],
34
+ },
35
+ '0xc1a195fdb17da5771d470a232545550a7d264809': {
36
+ tokens: [
37
+ {
38
+ address: '0x2c537e5624e4af88a7ae4060c022609376c8d0eb',
39
+ decimals: 6,
40
+ }, // TRYB
41
+ {
42
+ address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
43
+ decimals: 6,
44
+ }, // USDC
45
+ ],
46
+ },
47
+ '0x402878106b88b41fad1200b47e998c8effd0d887': {
48
+ tokens: [
49
+ {
50
+ address: '0x86b4dbe5d203e634a12364c0e428fa242a3fba98',
51
+ decimals: 18,
52
+ }, // 1GBP
53
+ {
54
+ address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
55
+ decimals: 6,
56
+ }, // USDC
57
+ ],
58
+ },
59
+ '0x01e4013c478d7f02112c3cf178f2771c842edbd0': {
60
+ tokens: [
61
+ {
62
+ address: '0xc08512927d12348f6620a698105e1baac6ecd911',
63
+ decimals: 6,
64
+ }, // GYEN
65
+ {
66
+ address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
67
+ decimals: 6,
68
+ }, // USDC
69
+ ],
70
+ },
71
+ },
72
+ },
73
+ [constants_1.Network.POLYGON]: {
74
+ router: '0x0c1f53e7b5a770f4c0d4bef139f752eeb08de88d',
75
+ quoteCurrency: '0x3c499c542cef5e3811e1192ce70d8cc03d5c3359',
76
+ pools: {
77
+ '0xdcb7efaca996fe2985138bf31b647efcd1d0901a': {
78
+ tokens: [
79
+ {
80
+ address: '0xfbbe4b730e1e77d02dc40fedf9438e2802eab3b5',
81
+ decimals: 18,
82
+ }, // NZDS
83
+ {
84
+ address: '0x3c499c542cef5e3811e1192ce70d8cc03d5c3359',
85
+ decimals: 6,
86
+ }, // USDC
87
+ ],
88
+ },
89
+ '0xf80b3a8977d34a443a836a380b2fce69a1a4e819': {
90
+ tokens: [
91
+ {
92
+ address: '0xe111178a87a3bff0c8d18decba5798827539ae99',
93
+ decimals: 2,
94
+ }, // EURS
95
+ {
96
+ address: '0x3c499c542cef5e3811e1192ce70d8cc03d5c3359',
97
+ decimals: 6,
98
+ }, // USDC
99
+ ],
100
+ },
101
+ '0x55bdf7f0223e8b1d509141a8d852dd86b3553d59': {
102
+ tokens: [
103
+ {
104
+ address: '0x4fb71290ac171e1d144f7221d882becac7196eb5',
105
+ decimals: 6,
106
+ }, // TRYB
107
+ {
108
+ address: '0x3c499c542cef5e3811e1192ce70d8cc03d5c3359',
109
+ decimals: 6,
110
+ }, // USDC
111
+ ],
112
+ },
113
+ '0x509aacb7746166252ecb0d62bfba097cc9731e20': {
114
+ tokens: [
115
+ {
116
+ address: '0xdc3326e71d45186f113a2f448984ca0e8d201995',
117
+ decimals: 6,
118
+ }, // XSGD
119
+ {
120
+ address: '0x3c499c542cef5e3811e1192ce70d8cc03d5c3359',
121
+ decimals: 6,
122
+ }, // USDC
123
+ ],
124
+ },
125
+ '0xce0abd182d2cf5844f2a0cb52cfcc55d4ff4fcba': {
126
+ tokens: [
127
+ {
128
+ address: '0x4ed141110f6eeeaba9a1df36d8c26f684d2475dc',
129
+ decimals: 4,
130
+ }, // BRZ
131
+ {
132
+ address: '0x3c499c542cef5e3811e1192ce70d8cc03d5c3359',
133
+ decimals: 6,
134
+ }, // USDC
135
+ ],
136
+ },
137
+ '0x3d4436ba3ae7e0e6361c83ab940ea779cd598206': {
138
+ tokens: [
139
+ {
140
+ address: '0xc2132d05d31c914a87c6611c10748aeb04b58e8f',
141
+ decimals: 6,
142
+ }, // USDT
143
+ {
144
+ address: '0x3c499c542cef5e3811e1192ce70d8cc03d5c3359',
145
+ decimals: 6,
146
+ }, // USDC
147
+ ],
148
+ },
149
+ '0xa52508b1822ca9261b33213b233694f846abd0ed': {
150
+ tokens: [
151
+ {
152
+ address: '0x8f3cf7ad23cd3cadbd9735aff958023239c6a063',
153
+ decimals: 18,
154
+ }, // DAI
155
+ {
156
+ address: '0x3c499c542cef5e3811e1192ce70d8cc03d5c3359',
157
+ decimals: 6,
158
+ }, // USDC
159
+ ],
160
+ },
161
+ '0x1233003461f654cf1c0d7db19e753badef05a87f': {
162
+ tokens: [
163
+ {
164
+ address: '0x87a25dc121db52369f4a9971f664ae5e372cf69a',
165
+ decimals: 6,
166
+ }, // PHPC
167
+ {
168
+ address: '0x3c499c542cef5e3811e1192ce70d8cc03d5c3359',
169
+ decimals: 6,
170
+ }, // USDC
171
+ ],
172
+ },
173
+ },
174
+ },
175
+ },
176
+ };
177
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/stabull/config.ts"],"names":[],"mappings":";;;AAEA,+CAA0C;AAE7B,QAAA,aAAa,GAA4B;IACpD,OAAO,EAAE;QACP,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,MAAM,EAAE,4CAA4C;YACpD,aAAa,EAAE,4CAA4C;YAC3D,KAAK,EAAE;gBACL,4CAA4C,EAAE;oBAC5C,MAAM,EAAE;wBACN;4BACE,OAAO,EAAE,4CAA4C;4BACrD,QAAQ,EAAE,EAAE;yBACb,EAAE,OA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D,QAAQ,EAAE,CAAC;yBACZ,EAAE,OAAO;qBACX;iBACF;gBACD,4CAA4C,EAAE;oBAC5C,MAAM,EAAE;wBACN;4BACE,OAAO,EAAE,4CAA4C;4BACrD,QAAQ,EAAE,CAAC;yBACZ,EAAE,OAAO;wBACV;4BACE,OAAO,EAAE,4CAA4C;4BACrD,QAAQ,EAAE,CAAC;yBACZ,EAAE,OAAO;qBACX;iBACF;aACF;SACF;KACF;CACF,CAAC"}
@@ -1,20 +1,19 @@
1
- import { Interface } from '@ethersproject/abi';
2
1
  import { DeepReadonly } from 'ts-essentials';
3
2
  import { Log, Logger } from '../../types';
4
3
  import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
5
4
  import { IDexHelper } from '../../dex-helper/idex-helper';
6
5
  import { PoolState } from './types';
7
- export declare class SeVlrEventPool extends StatefulEventSubscriber<PoolState> {
6
+ export declare class StabullEventPool extends StatefulEventSubscriber<PoolState> {
8
7
  readonly parentName: string;
9
8
  protected network: number;
10
9
  protected dexHelper: IDexHelper;
11
- protected seVlrIface: Interface;
10
+ readonly poolAddress: string;
11
+ protected addressesSubscribed_: string[];
12
12
  handlers: {
13
13
  [event: string]: (event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>) => DeepReadonly<PoolState> | null;
14
14
  };
15
15
  logDecoder: (log: Log) => any;
16
- addressesSubscribed: string[];
17
- constructor(parentName: string, network: number, dexHelper: IDexHelper, logger: Logger, seVlrIface?: Interface);
16
+ constructor(parentName: string, network: number, dexHelper: IDexHelper, poolAddress: string, addressesSubscribed_: string[], logger: Logger);
18
17
  /**
19
18
  * The function is called every time any of the subscribed
20
19
  * addresses release log. The function accepts the current
@@ -35,5 +34,13 @@ export declare class SeVlrEventPool extends StatefulEventSubscriber<PoolState> {
35
34
  * @returns state of the event subscriber at blocknumber
36
35
  */
37
36
  generateState(blockNumber: number): Promise<DeepReadonly<PoolState>>;
38
- handleMyEvent(event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>): DeepReadonly<PoolState> | null;
37
+ /**
38
+ * Handles a transfer event and updates the pool state accordingly.
39
+ *
40
+ * @param event - The transfer event object containing details about the transfer.
41
+ * @param state - The current state of the pool.
42
+ * @param log - The log object containing additional information about the event.
43
+ * @returns The updated pool state if the transfer involves the pool, otherwise null.
44
+ */
45
+ handleTransfer(event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>): DeepReadonly<PoolState> | null;
39
46
  }
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StabullEventPool = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
6
+ const utils_2 = require("../../lib/tokens/utils");
7
+ const decoders_1 = require("../../lib/decoders");
8
+ class StabullEventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
9
+ parentName;
10
+ network;
11
+ dexHelper;
12
+ poolAddress;
13
+ addressesSubscribed_;
14
+ handlers = {};
15
+ logDecoder;
16
+ constructor(parentName, network, dexHelper, poolAddress, addressesSubscribed_, logger) {
17
+ super(parentName, poolAddress.toLowerCase(), dexHelper, logger);
18
+ this.parentName = parentName;
19
+ this.network = network;
20
+ this.dexHelper = dexHelper;
21
+ this.poolAddress = poolAddress;
22
+ this.addressesSubscribed_ = addressesSubscribed_;
23
+ this.logDecoder = (log) => utils_2.erc20Iface.parseLog(log);
24
+ this.addressesSubscribed = addressesSubscribed_;
25
+ this.poolAddress = poolAddress.toLowerCase();
26
+ }
27
+ /**
28
+ * The function is called every time any of the subscribed
29
+ * addresses release log. The function accepts the current
30
+ * state, updates the state according to the log, and returns
31
+ * the updated state.
32
+ * @param state - Current state of event subscriber
33
+ * @param log - Log released by one of the subscribed addresses
34
+ * @returns Updates state of the event subscriber after the log
35
+ */
36
+ processLog(state, log) {
37
+ try {
38
+ const event = this.logDecoder(log);
39
+ if (event.name in this.handlers) {
40
+ return this.handlers[event.name](event, state, log);
41
+ }
42
+ }
43
+ catch (e) {
44
+ (0, utils_1.catchParseLogError)(e, this.logger);
45
+ }
46
+ return null;
47
+ }
48
+ /**
49
+ * The function generates state using on-chain calls. This
50
+ * function is called to regenerate state if the event based
51
+ * system fails to fetch events and the local state is no
52
+ * more correct.
53
+ * @param blockNumber - Blocknumber for which the state should
54
+ * should be generated
55
+ * @returns state of the event subscriber at blocknumber
56
+ */
57
+ async generateState(blockNumber) {
58
+ let calldata = [
59
+ {
60
+ target: this.addressesSubscribed[0],
61
+ callData: utils_2.erc20Iface.encodeFunctionData('balanceOf', [
62
+ this.poolAddress,
63
+ ]),
64
+ decodeFunction: decoders_1.uint256ToBigInt,
65
+ },
66
+ {
67
+ target: this.addressesSubscribed[1],
68
+ callData: utils_2.erc20Iface.encodeFunctionData('balanceOf', [
69
+ this.poolAddress,
70
+ ]),
71
+ decodeFunction: decoders_1.uint256ToBigInt,
72
+ },
73
+ ];
74
+ const data = await this.dexHelper.multiWrapper.tryAggregate(true, calldata, blockNumber);
75
+ return {
76
+ reserves0: data[0].success ? data[0].returnData : 0n,
77
+ reserves1: data[1].success ? data[1].returnData : 0n,
78
+ };
79
+ }
80
+ /**
81
+ * Handles a transfer event and updates the pool state accordingly.
82
+ *
83
+ * @param event - The transfer event object containing details about the transfer.
84
+ * @param state - The current state of the pool.
85
+ * @param log - The log object containing additional information about the event.
86
+ * @returns The updated pool state if the transfer involves the pool, otherwise null.
87
+ */
88
+ handleTransfer(event, state, log) {
89
+ const from = event.args.from.toLowerCase();
90
+ const to = event.args.to.toLowerCase();
91
+ // Check if pool is involved in the transfer
92
+ if (from !== this.poolAddress && to !== this.poolAddress) {
93
+ return null;
94
+ }
95
+ // Determine which token this is
96
+ const eventTokenAddress = log.address.toLowerCase();
97
+ const isToken0 = eventTokenAddress === this.addressesSubscribed[0].toLowerCase();
98
+ const value = event.args.value.toBigInt();
99
+ const reserveKey = isToken0 ? 'reserves0' : 'reserves1';
100
+ const currentReserve = state[reserveKey];
101
+ // Pool is sending tokens (decrease) or receiving tokens (increase)
102
+ const isFromPool = from === this.poolAddress;
103
+ const newReserve = isFromPool
104
+ ? currentReserve - value
105
+ : currentReserve + value;
106
+ return {
107
+ ...state,
108
+ [reserveKey]: newReserve,
109
+ };
110
+ }
111
+ }
112
+ exports.StabullEventPool = StabullEventPool;
113
+ //# sourceMappingURL=stabull-pool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stabull-pool.js","sourceRoot":"","sources":["../../../src/dex/stabull/stabull-pool.ts"],"names":[],"mappings":";;;AAEA,uCAAiD;AACjD,+EAA0E;AAG1E,kDAAoD;AACpD,iDAAqD;AAErD,MAAa,gBAAiB,SAAQ,mDAAkC;IAY3D;IACC;IACA;IACD;IACC;IAfZ,QAAQ,GAMJ,EAAE,CAAC;IAEP,UAAU,CAAoB;IAE9B,YACW,UAAkB,EACjB,OAAe,EACf,SAAqB,EACtB,WAAmB,EAClB,oBAA8B,EACxC,MAAc;QAEd,KAAK,CAAC,UAAU,EAAE,WAAW,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QAPvD,eAAU,GAAV,UAAU,CAAQ;QACjB,YAAO,GAAP,OAAO,CAAQ;QACf,cAAS,GAAT,SAAS,CAAY;QACtB,gBAAW,GAAX,WAAW,CAAQ;QAClB,yBAAoB,GAApB,oBAAoB,CAAU;QAKxC,IAAI,CAAC,UAAU,GAAG,CAAC,GAAQ,EAAE,EAAE,CAAC,kBAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACzD,IAAI,CAAC,mBAAmB,GAAG,oBAAoB,CAAC;QAChD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;IAC/C,CAAC;IAED;;;;;;;;OAQG;IACO,UAAU,CAClB,KAA8B,EAC9B,GAAkB;QAElB,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YACnC,IAAI,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC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EACV,KAA8B,EAC9B,GAAkB;QAElB,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QAC3C,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC;QAEvC,4CAA4C;QAC5C,IAAI,IAAI,KAAK,IAAI,CAAC,WAAW,IAAI,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE,CAAC;YACzD,OAAO,IAAI,CAAC;QACd,CAAC;QAED,gCAAgC;QAChC,MAAM,iBAAiB,GAAG,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QACpD,MAAM,QAAQ,GACZ,iBAAiB,KAAK,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QAElE,MAAM,KAAK,GAAW,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAClD,MAAM,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC;QACxD,MAAM,cAAc,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;QAEzC,mEAAmE;QACnE,MAAM,UAAU,GAAG,IAAI,KAAK,IAAI,CAAC,WAAW,CAAC;QAC7C,MAAM,UAAU,GAAG,UAAU;YAC3B,CAAC,CAAC,cAAc,GAAG,KAAK;YACxB,CAAC,CAAC,cAAc,GAAG,KAAK,CAAC;QAE3B,OAAO;YACL,GAAG,KAAK;YACR,CAAC,UAAU,CAAC,EAAE,UAAU;SACzB,CAAC;IACJ,CAAC;CACF;AAnID,4CAmIC"}
@@ -0,0 +1,55 @@
1
+ import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, PoolLiquidity, Logger, DexExchangeParam } from '../../types';
2
+ import { SwapSide, Network } from '../../constants';
3
+ import { IDex } from '../../dex/idex';
4
+ import { IDexHelper } from '../../dex-helper/idex-helper';
5
+ import { StabullData } from './types';
6
+ import { SimpleExchange } from '../simple-exchange';
7
+ import { ethers } from 'ethers';
8
+ export declare class Stabull extends SimpleExchange implements IDex<StabullData> {
9
+ readonly network: Network;
10
+ readonly dexKey: string;
11
+ readonly dexHelper: IDexHelper;
12
+ protected poolIface: ethers.utils.Interface;
13
+ protected routerIface: ethers.utils.Interface;
14
+ protected routerAddress: string;
15
+ protected quoteCurrency: string;
16
+ private pools;
17
+ private poolsConfig;
18
+ readonly hasConstantPriceLargeAmounts = false;
19
+ readonly needWrapNative = true;
20
+ readonly isFeeOnTransferSupported = false;
21
+ static dexKeysWithNetwork: {
22
+ key: string;
23
+ networks: Network[];
24
+ }[];
25
+ logger: Logger;
26
+ constructor(network: Network, dexKey: string, dexHelper: IDexHelper, poolIface?: ethers.utils.Interface, routerIface?: ethers.utils.Interface, routerAddress?: string, quoteCurrency?: string);
27
+ getAdapters(side: SwapSide): {
28
+ name: string;
29
+ index: number;
30
+ }[] | null;
31
+ getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
32
+ getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<StabullData>>;
33
+ getCalldataGasCost(poolPrices: PoolPrices<StabullData>): number | number[];
34
+ getAdapterParam: (srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: StabullData, side: SwapSide) => AdapterExchangeParam;
35
+ updatePoolState(): Promise<void>;
36
+ getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
37
+ /**
38
+ * Retrieves the decentralized exchange (DEX) parameters for a swap operation.
39
+ *
40
+ * @param srcToken - The address of the source token.
41
+ * @param destToken - The address of the destination token.
42
+ * @param srcAmount - The amount of the source token to swap.
43
+ * @param destAmount - The desired amount of the destination token.
44
+ * @param recipient - The address of the recipient.
45
+ * @param data - Additional data required for the swap.
46
+ * @param side - The side of the swap (SELL or BUY).
47
+ * @param options - Options for global tokens.
48
+ * @param executorAddress - The address of the executor.
49
+ * @returns A promise that resolves to the DEX exchange parameters.
50
+ */
51
+ getDexParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, recipient: string, data: StabullData, side: SwapSide, options: {
52
+ isGlobalSrcToken: boolean;
53
+ isGlobalDestToken: boolean;
54
+ }, executorAddress: string): Promise<DexExchangeParam>;
55
+ }