@orbs-network/twap 1.8.2 → 1.8.3

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/dist/src/lib.d.ts CHANGED
@@ -2,6 +2,8 @@ import { Config, TokenData } from "./configs";
2
2
  import BN from "bignumber.js";
3
3
  import type { TWAP } from "../typechain-hardhat/contracts";
4
4
  import type { Lens } from "../typechain-hardhat/contracts/periphery";
5
+ import { Paraswap } from "./paraswap";
6
+ import ParaswapRoute = Paraswap.ParaswapRoute;
5
7
  export declare const twapAbi: any;
6
8
  export declare const lensAbi: any;
7
9
  export declare const takerAbi: any;
@@ -44,7 +46,14 @@ export declare class TWAPLib {
44
46
  dstToken: TokenData;
45
47
  srcNextChunkAmountIn: BN;
46
48
  dstNextChunkAmountOut: BN;
47
- raw: any;
49
+ raw: string[] | Paraswap.ParaswapRoute;
50
+ data: string;
51
+ }>;
52
+ convertRouteToSwapData(route: ParaswapRoute): Promise<{
53
+ raw: string[];
54
+ data: string;
55
+ } | {
56
+ raw: Paraswap.ParaswapRoute;
48
57
  data: string;
49
58
  }>;
50
59
  }
package/dist/src/lib.js CHANGED
@@ -220,23 +220,21 @@ class TWAPLib {
220
220
  ]);
221
221
  const route = yield paraswap_1.Paraswap.findRoute(this.config.chainId, srcToken, dstToken, srcNextChunkAmountIn, this.config.pathfinderKey);
222
222
  const dstNextChunkAmountOut = (0, bignumber_js_1.default)(route.destAmount);
223
+ const { raw, data } = yield this.convertRouteToSwapData(route);
224
+ return { srcToken, dstToken, srcNextChunkAmountIn, dstNextChunkAmountOut, raw, data };
225
+ });
226
+ }
227
+ convertRouteToSwapData(route) {
228
+ return __awaiter(this, void 0, void 0, function* () {
223
229
  switch (this.config.exchangeType) {
224
230
  case "UniswapV2Exchange":
225
231
  const path = paraswap_1.Paraswap.getDirectPath(route, this.config.pathfinderKey);
226
232
  return {
227
- srcToken,
228
- dstToken,
229
- srcNextChunkAmountIn,
230
- dstNextChunkAmountOut,
231
233
  raw: path,
232
234
  data: (0, web3_candies_1.web3)().eth.abi.encodeParameters(["bool", "address[]"], [true, path]),
233
235
  };
234
236
  case "ParaswapExchange":
235
237
  return {
236
- srcToken,
237
- dstToken,
238
- srcNextChunkAmountIn,
239
- dstNextChunkAmountOut,
240
238
  raw: route,
241
239
  data: yield paraswap_1.Paraswap.buildSwapData(route, this.config.twapAddress),
242
240
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbs-network/twap",
3
- "version": "1.8.2",
3
+ "version": "1.8.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/orbs-network/twap.git"