@gearbox-protocol/sdk 1.5.14 → 1.5.15

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.
@@ -1,8 +1,5 @@
1
- import { Signer } from "ethers";
2
1
  import { AdapterInterface } from "../contracts/adapters";
3
2
  import { SupportedContract } from "../contracts/contracts";
4
- import { EVMTx } from "./eventOrTx";
5
- import { TradePath } from "./trade";
6
3
  interface BaseAdapterProps {
7
4
  name: string;
8
5
  adapterInterface: AdapterInterface;
@@ -11,11 +8,6 @@ interface BaseAdapterProps {
11
8
  contractSymbol: SupportedContract;
12
9
  creditManager: string;
13
10
  }
14
- interface ExecuteProps {
15
- tradePath: TradePath;
16
- slippage: number;
17
- signer: Signer;
18
- }
19
11
  export declare class BaseAdapter {
20
12
  readonly name: string;
21
13
  readonly adapterInterface: AdapterInterface;
@@ -24,6 +16,5 @@ export declare class BaseAdapter {
24
16
  readonly contractSymbol: SupportedContract;
25
17
  readonly creditManager: string;
26
18
  constructor(props: BaseAdapterProps);
27
- execute(props: ExecuteProps): Promise<EVMTx>;
28
19
  }
29
20
  export {};
@@ -1,40 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
2
  Object.defineProperty(exports, "__esModule", { value: true });
39
3
  exports.BaseAdapter = void 0;
40
4
  var BaseAdapter = /** @class */ (function () {
@@ -46,14 +10,6 @@ var BaseAdapter = /** @class */ (function () {
46
10
  this.contractSymbol = props.contractSymbol;
47
11
  this.creditManager = props.creditManager;
48
12
  }
49
- BaseAdapter.prototype.execute = function (props) {
50
- return __awaiter(this, void 0, void 0, function () {
51
- return __generator(this, function (_a) {
52
- console.debug(props);
53
- return [2 /*return*/, {}];
54
- });
55
- });
56
- };
57
13
  return BaseAdapter;
58
14
  }());
59
15
  exports.BaseAdapter = BaseAdapter;
@@ -1,9 +1,9 @@
1
1
  import { BigNumber, ethers, Signer } from "ethers";
2
+ import { MultiCall } from "../pathfinder/core";
2
3
  import { CreditManagerDataPayload, CreditManagerStatPayload } from "../payload/creditManager";
3
4
  import { TokenData } from "../tokens/tokenData";
4
5
  import { ICreditManager } from "../types";
5
6
  import { Asset } from "./assets";
6
- import { MultiCall } from "./multicall";
7
7
  export declare class CreditManagerData {
8
8
  readonly id: string;
9
9
  readonly address: string;
@@ -1,32 +1,29 @@
1
1
  import { BigNumber } from "ethers";
2
2
  import { AdapterInterface } from "../contracts/adapters";
3
- import { SwapType } from "../pathfinder/tradeTypes";
3
+ import { PathFinderResult, SwapOperation } from "../pathfinder/core";
4
4
  import { ICreditFacade } from "../types";
5
- import { PathFinderResultStruct, PathFinderResultStructOutput } from "../types/contracts/pathfinder/interfaces/IPathFinder";
6
5
  import { BaseAdapter } from "./adapter";
7
6
  import { EVMTx } from "./eventOrTx";
8
7
  import { TXSwap } from "./transactions";
9
- export declare type TradePath = Pick<PathFinderResultStructOutput, keyof PathFinderResultStruct>;
10
- export interface BaseTradeInterface {
11
- swapType: SwapType;
8
+ interface BaseTradeInterface {
9
+ swapType: SwapOperation;
12
10
  sourceAmount: BigNumber;
13
11
  expectedAmount: BigNumber;
14
- rate: BigNumber;
15
12
  tokenFrom: string;
16
13
  tokenTo: string;
17
14
  operationName: TradeOperations;
18
15
  }
19
16
  export interface TradeProps extends BaseTradeInterface {
20
17
  adapter: BaseAdapter;
21
- tradePath: TradePath;
18
+ tradePath: PathFinderResult;
22
19
  creditFacade: ICreditFacade;
23
20
  }
24
21
  export declare type TradeOperations = "farmWithdraw" | "farmDeposit" | "swap" | "unknownOperation";
25
22
  export declare class Trade implements BaseTradeInterface {
26
23
  protected helper: BaseAdapter;
27
- protected tradePath: TradePath;
24
+ protected tradePath: PathFinderResult;
28
25
  protected creditFacade: ICreditFacade;
29
- readonly swapType: SwapType;
26
+ readonly swapType: SwapOperation;
30
27
  readonly sourceAmount: BigNumber;
31
28
  readonly expectedAmount: BigNumber;
32
29
  readonly rate: BigNumber;
@@ -45,3 +42,4 @@ export declare class Trade implements BaseTradeInterface {
45
42
  getToAmount(slippage: number): BigNumber;
46
43
  static getOperationName(tokenInAddress: string, tokenOutAddress: string): TradeOperations;
47
44
  }
45
+ export {};
package/lib/core/trade.js CHANGED
@@ -56,7 +56,7 @@ var Trade = /** @class */ (function () {
56
56
  this.swapType = props.swapType;
57
57
  this.sourceAmount = props.sourceAmount;
58
58
  this.expectedAmount = props.expectedAmount;
59
- this.rate = props.rate;
59
+ this.rate = constants_1.WAD.mul(props.expectedAmount).div(props.sourceAmount);
60
60
  this.tokenFrom = props.tokenFrom;
61
61
  this.tokenTo = props.tokenTo;
62
62
  this.operationName = props.operationName;
@@ -15,7 +15,7 @@ export interface TxInfo {
15
15
  amountTo?: BigNumber;
16
16
  functionFragment: FunctionFragment;
17
17
  }
18
- export declare class SwapOperation {
18
+ export declare class WcSwapOperation {
19
19
  readonly id: number;
20
20
  operation?: string;
21
21
  from?: string;
@@ -39,7 +39,7 @@ export declare class SwapOperation {
39
39
  amountFrom: BigNumber;
40
40
  amountTo: BigNumber;
41
41
  raw: RawTransaction;
42
- }): SwapOperation;
42
+ }): WcSwapOperation;
43
43
  static NewLPOperation(params: {
44
44
  adapter: string;
45
45
  operation: string;
@@ -48,7 +48,7 @@ export declare class SwapOperation {
48
48
  farm: string;
49
49
  type: LpOperationType;
50
50
  raw: RawTransaction;
51
- }): SwapOperation;
52
- static NewUnsupportedOperation(raw: RawTransaction): SwapOperation;
53
- static NewApproveOperation(creditManager: string, raw: RawTransaction, token: string): SwapOperation;
51
+ }): WcSwapOperation;
52
+ static NewUnsupportedOperation(raw: RawTransaction): WcSwapOperation;
53
+ static NewApproveOperation(creditManager: string, raw: RawTransaction, token: string): WcSwapOperation;
54
54
  }
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SwapOperation = void 0;
3
+ exports.WcSwapOperation = void 0;
4
4
  var types_1 = require("../types");
5
- var SwapOperation = /** @class */ (function () {
6
- function SwapOperation(raw, kind) {
5
+ var WcSwapOperation = /** @class */ (function () {
6
+ function WcSwapOperation(raw, kind) {
7
7
  this.id = raw.id;
8
8
  this.raw = raw;
9
9
  this.kind = kind;
10
10
  this.isPending = false;
11
11
  }
12
- SwapOperation.NewSwapOperation = function (params) {
12
+ WcSwapOperation.NewSwapOperation = function (params) {
13
13
  var _a, _b;
14
- var newOperation = new SwapOperation(params.raw, "swap");
14
+ var newOperation = new WcSwapOperation(params.raw, "swap");
15
15
  newOperation.operation = params.operation;
16
16
  newOperation.from = params.from;
17
17
  newOperation.to = params.to;
@@ -25,9 +25,9 @@ var SwapOperation = /** @class */ (function () {
25
25
  };
26
26
  return newOperation;
27
27
  };
28
- SwapOperation.NewLPOperation = function (params) {
28
+ WcSwapOperation.NewLPOperation = function (params) {
29
29
  var _a, _b;
30
- var newOperation = new SwapOperation(params.raw, "lp");
30
+ var newOperation = new WcSwapOperation(params.raw, "lp");
31
31
  newOperation.operation = params.operation;
32
32
  newOperation.from = params.from;
33
33
  newOperation.amountFrom = params.amountFrom;
@@ -41,12 +41,12 @@ var SwapOperation = /** @class */ (function () {
41
41
  newOperation.lpOperationType = params.type;
42
42
  return newOperation;
43
43
  };
44
- SwapOperation.NewUnsupportedOperation = function (raw) {
45
- return new SwapOperation(raw, "unsupported");
44
+ WcSwapOperation.NewUnsupportedOperation = function (raw) {
45
+ return new WcSwapOperation(raw, "unsupported");
46
46
  };
47
- SwapOperation.NewApproveOperation = function (creditManager, raw, token) {
47
+ WcSwapOperation.NewApproveOperation = function (creditManager, raw, token) {
48
48
  var _a, _b;
49
- var operation = new SwapOperation(raw, "approve");
49
+ var operation = new WcSwapOperation(raw, "approve");
50
50
  operation.to = token;
51
51
  operation.calldata = (_a = raw === null || raw === void 0 ? void 0 : raw.params[0]) === null || _a === void 0 ? void 0 : _a.data;
52
52
  var tokenI = types_1.IERC20__factory.createInterface();
@@ -67,10 +67,10 @@ var SwapOperation = /** @class */ (function () {
67
67
  }
68
68
  catch (e) {
69
69
  console.error(e);
70
- return SwapOperation.NewUnsupportedOperation(raw);
70
+ return WcSwapOperation.NewUnsupportedOperation(raw);
71
71
  }
72
72
  };
73
- SwapOperation.tokens = {};
74
- return SwapOperation;
73
+ WcSwapOperation.tokens = {};
74
+ return WcSwapOperation;
75
75
  }());
76
- exports.SwapOperation = SwapOperation;
76
+ exports.WcSwapOperation = WcSwapOperation;
package/lib/index.d.ts CHANGED
@@ -34,6 +34,8 @@ export { AdapterInterface } from "./contracts/adapters";
34
34
  export { getContractName } from "./contracts/contractsRegister";
35
35
  export * from "./core/history";
36
36
  export * from "./parsers/txParser";
37
+ export * from "./pathfinder/core";
38
+ export * from "./pathfinder/pathfinder";
37
39
  export * from "./pathfinder/tradeTypes";
38
40
  export * from "./strategies/convex";
39
41
  export * from "./strategies/creditFacade";
package/lib/index.js CHANGED
@@ -54,6 +54,8 @@ var contractsRegister_1 = require("./contracts/contractsRegister");
54
54
  Object.defineProperty(exports, "getContractName", { enumerable: true, get: function () { return contractsRegister_1.getContractName; } });
55
55
  __exportStar(require("./core/history"), exports);
56
56
  __exportStar(require("./parsers/txParser"), exports);
57
+ __exportStar(require("./pathfinder/core"), exports);
58
+ __exportStar(require("./pathfinder/pathfinder"), exports);
57
59
  __exportStar(require("./pathfinder/tradeTypes"), exports);
58
60
  __exportStar(require("./strategies/convex"), exports);
59
61
  __exportStar(require("./strategies/creditFacade"), exports);
@@ -77,7 +77,3 @@ export declare type TradeAction = {
77
77
  contract: ConvexPoolContract;
78
78
  tokenOut: CurveLPToken;
79
79
  };
80
- export declare enum SwapType {
81
- ExactInput = 1,
82
- ExactOutput = 2
83
- }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SwapType = exports.TradeType = void 0;
3
+ exports.TradeType = void 0;
4
4
  var TradeType;
5
5
  (function (TradeType) {
6
6
  TradeType[TradeType["UniswapV2Swap"] = 0] = "UniswapV2Swap";
@@ -19,8 +19,3 @@ var TradeType;
19
19
  TradeType[TradeType["ConvexWithdraw"] = 13] = "ConvexWithdraw";
20
20
  TradeType[TradeType["ConvexWithdrawAndUnwrap"] = 14] = "ConvexWithdrawAndUnwrap";
21
21
  })(TradeType = exports.TradeType || (exports.TradeType = {}));
22
- var SwapType;
23
- (function (SwapType) {
24
- SwapType[SwapType["ExactInput"] = 1] = "ExactInput";
25
- SwapType[SwapType["ExactOutput"] = 2] = "ExactOutput";
26
- })(SwapType = exports.SwapType || (exports.SwapType = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "1.5.14",
3
+ "version": "1.5.15",
4
4
  "description": "Gearbox SDK",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -1,5 +0,0 @@
1
- import { BytesLike } from "ethers";
2
- export interface MultiCall {
3
- target: string;
4
- callData: BytesLike;
5
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });