@gearbox-protocol/sdk 0.0.52 → 0.0.55

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.
@@ -10,9 +10,12 @@ export declare enum TradeType {
10
10
  YearnDeposit = 6,
11
11
  YearnWithdraw = 7,
12
12
  LidoStake = 8,
13
- ConvexDeposit = 9,
13
+ ConvexDepositLP = 9,
14
14
  ConvexStake = 10,
15
- ConvexDepositAndStake = 11
15
+ ConvexDepositLPAndStake = 11,
16
+ ConvexWithdrawLP = 12,
17
+ ConvexWithdraw = 13,
18
+ ConvexWithdrawAndUnwrap = 14
16
19
  }
17
20
  export declare type TradeAction = {
18
21
  type: TradeType.UniswapV2Swap;
@@ -45,15 +48,27 @@ export declare type TradeAction = {
45
48
  contract: "LIDO_STETH_GATEWAY";
46
49
  tokenOut: NormalToken;
47
50
  } | {
48
- type: TradeType.ConvexDeposit;
49
- contract: ConvexPoolContract;
51
+ type: TradeType.ConvexDepositLP;
52
+ contract: "CONVEX_BOOSTER";
50
53
  tokenOut: ConvexLPToken;
51
54
  } | {
52
55
  type: TradeType.ConvexStake;
53
56
  contract: ConvexPoolContract;
54
57
  tokenOut: ConvexStakedPhantomToken;
55
58
  } | {
56
- type: TradeType.ConvexDepositAndStake;
57
- contract: ConvexPoolContract;
59
+ type: TradeType.ConvexDepositLPAndStake;
60
+ contract: "CONVEX_BOOSTER";
58
61
  tokenOut: ConvexStakedPhantomToken;
62
+ } | {
63
+ type: TradeType.ConvexWithdrawLP;
64
+ contract: "CONVEX_BOOSTER";
65
+ tokenOut: CurveLPToken;
66
+ } | {
67
+ type: TradeType.ConvexWithdraw;
68
+ contract: ConvexPoolContract;
69
+ tokenOut: ConvexLPToken;
70
+ } | {
71
+ type: TradeType.ConvexWithdrawAndUnwrap;
72
+ contract: ConvexPoolContract;
73
+ tokenOut: CurveLPToken;
59
74
  };
@@ -12,7 +12,10 @@ var TradeType;
12
12
  TradeType[TradeType["YearnDeposit"] = 6] = "YearnDeposit";
13
13
  TradeType[TradeType["YearnWithdraw"] = 7] = "YearnWithdraw";
14
14
  TradeType[TradeType["LidoStake"] = 8] = "LidoStake";
15
- TradeType[TradeType["ConvexDeposit"] = 9] = "ConvexDeposit";
15
+ TradeType[TradeType["ConvexDepositLP"] = 9] = "ConvexDepositLP";
16
16
  TradeType[TradeType["ConvexStake"] = 10] = "ConvexStake";
17
- TradeType[TradeType["ConvexDepositAndStake"] = 11] = "ConvexDepositAndStake";
17
+ TradeType[TradeType["ConvexDepositLPAndStake"] = 11] = "ConvexDepositLPAndStake";
18
+ TradeType[TradeType["ConvexWithdrawLP"] = 12] = "ConvexWithdrawLP";
19
+ TradeType[TradeType["ConvexWithdraw"] = 13] = "ConvexWithdraw";
20
+ TradeType[TradeType["ConvexWithdrawAndUnwrap"] = 14] = "ConvexWithdrawAndUnwrap";
18
21
  })(TradeType = exports.TradeType || (exports.TradeType = {}));
@@ -103,7 +103,7 @@ interface RepayAccountProps extends EVMTxProps {
103
103
  export declare class TxRepayAccount extends EVMTx {
104
104
  readonly creditManager: string;
105
105
  constructor(opts: RepayAccountProps);
106
- toString(_tokenData: Record<string, TokenData>): string;
106
+ toString(_: Record<string, TokenData>): string;
107
107
  serialize(): TxSerialized;
108
108
  }
109
109
  interface CloseAccountProps extends EVMTxProps {
@@ -112,7 +112,7 @@ interface CloseAccountProps extends EVMTxProps {
112
112
  export declare class TxCloseAccount extends EVMTx {
113
113
  readonly creditManager: string;
114
114
  constructor(opts: CloseAccountProps);
115
- toString(_tokenData: Record<string, TokenData>): string;
115
+ toString(_: Record<string, TokenData>): string;
116
116
  serialize(): TxSerialized;
117
117
  }
118
118
  interface ApproveProps extends EVMTxProps {
@@ -72,7 +72,7 @@ var TxAddLiquidity = /** @class */ (function (_super) {
72
72
  return _this;
73
73
  }
74
74
  TxAddLiquidity.prototype.toString = function (tokenData) {
75
- var token = tokenData[this.underlyingToken];
75
+ var token = tokenData[this.underlyingToken.toLowerCase()];
76
76
  return "".concat((0, contractsRegister_1.getContractName)(this.pool), ": Deposit ").concat((0, formatter_1.formatBN)(this.amount, (token === null || token === void 0 ? void 0 : token.decimals) || 18), " ").concat((token === null || token === void 0 ? void 0 : token.symbol) || "");
77
77
  };
78
78
  TxAddLiquidity.prototype.serialize = function () {
@@ -99,7 +99,7 @@ var TxRemoveLiquidity = /** @class */ (function (_super) {
99
99
  return _this;
100
100
  }
101
101
  TxRemoveLiquidity.prototype.toString = function (tokenData) {
102
- var dtoken = tokenData[this.dieselToken];
102
+ var dtoken = tokenData[this.dieselToken.toLowerCase()];
103
103
  return "".concat((0, contractsRegister_1.getContractName)(this.pool), ": Withdraw ").concat((0, formatter_1.formatBN)(this.amount, (dtoken === null || dtoken === void 0 ? void 0 : dtoken.decimals) || 18), " ").concat((dtoken === null || dtoken === void 0 ? void 0 : dtoken.symbol) || "");
104
104
  };
105
105
  TxRemoveLiquidity.prototype.serialize = function () {
@@ -130,10 +130,10 @@ var TXSwap = /** @class */ (function (_super) {
130
130
  return _this;
131
131
  }
132
132
  TXSwap.prototype.toString = function (tokenData) {
133
- var tokenFrom = tokenData[this.tokenFrom];
133
+ var tokenFrom = tokenData[this.tokenFrom.toLowerCase()];
134
134
  var toPart = "";
135
135
  if (this.tokenTo && this.amountTo) {
136
- var tokenTo = tokenData[this.tokenTo];
136
+ var tokenTo = tokenData[this.tokenTo.toLowerCase()];
137
137
  toPart = " \u21D2 ".concat((0, formatter_1.formatBN)(this.amountTo, (tokenTo === null || tokenTo === void 0 ? void 0 : tokenTo.decimals) || 18), " ").concat((tokenTo === null || tokenTo === void 0 ? void 0 : tokenTo.symbol) || "");
138
138
  }
139
139
  return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": ").concat(this.operation, " ").concat((0, formatter_1.formatBN)(this.amountFrom, (tokenFrom === null || tokenFrom === void 0 ? void 0 : tokenFrom.decimals) || 18), " ").concat((tokenFrom === null || tokenFrom === void 0 ? void 0 : tokenFrom.symbol) || "", " ").concat(toPart, " on ").concat((0, contractsRegister_1.getContractName)(this.protocol));
@@ -162,7 +162,7 @@ var TxAddCollateral = /** @class */ (function (_super) {
162
162
  return _this;
163
163
  }
164
164
  TxAddCollateral.prototype.toString = function (tokenData) {
165
- var addedToken = tokenData[this.addedToken];
165
+ var addedToken = tokenData[this.addedToken.toLowerCase()];
166
166
  return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": Added ").concat((0, formatter_1.formatBN)(this.amount, addedToken.decimals), " ").concat(addedToken.symbol, " as collateral");
167
167
  };
168
168
  TxAddCollateral.prototype.serialize = function () {
@@ -189,7 +189,7 @@ var TxIncreaseBorrowAmount = /** @class */ (function (_super) {
189
189
  return _this;
190
190
  }
191
191
  TxIncreaseBorrowAmount.prototype.toString = function (tokenData) {
192
- var token = tokenData[this.underlyingToken];
192
+ var token = tokenData[this.underlyingToken.toLowerCase()];
193
193
  return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": Borrowed amount was increased for ").concat((0, formatter_1.formatBN)(this.amount, (token === null || token === void 0 ? void 0 : token.decimals) || 18), " ").concat(token === null || token === void 0 ? void 0 : token.symbol);
194
194
  };
195
195
  TxIncreaseBorrowAmount.prototype.serialize = function () {
@@ -217,7 +217,7 @@ var TxOpenAccount = /** @class */ (function (_super) {
217
217
  return _this;
218
218
  }
219
219
  TxOpenAccount.prototype.toString = function (tokenData) {
220
- var token = tokenData[this.underlyingToken];
220
+ var token = tokenData[this.underlyingToken.toLowerCase()];
221
221
  return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": opening ").concat((0, formatter_1.formatBN)(this.amount, (token === null || token === void 0 ? void 0 : token.decimals) || 18), " ").concat(token === null || token === void 0 ? void 0 : token.symbol, " x ").concat(this.leverage.toFixed(2), " \u21D2 \n ").concat((0, formatter_1.formatBN)(this.amount
222
222
  .mul(Math.floor(this.leverage * constants_1.LEVERAGE_DECIMALS))
223
223
  .div(constants_1.LEVERAGE_DECIMALS), (token === null || token === void 0 ? void 0 : token.decimals) || 18), " ").concat(token === null || token === void 0 ? void 0 : token.symbol);
@@ -243,7 +243,7 @@ var TxRepayAccount = /** @class */ (function (_super) {
243
243
  _this.creditManager = opts.creditManager;
244
244
  return _this;
245
245
  }
246
- TxRepayAccount.prototype.toString = function (_tokenData) {
246
+ TxRepayAccount.prototype.toString = function (_) {
247
247
  return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": Repaying account");
248
248
  };
249
249
  TxRepayAccount.prototype.serialize = function () {
@@ -267,7 +267,7 @@ var TxCloseAccount = /** @class */ (function (_super) {
267
267
  _this.creditManager = opts.creditManager;
268
268
  return _this;
269
269
  }
270
- TxCloseAccount.prototype.toString = function (_tokenData) {
270
+ TxCloseAccount.prototype.toString = function (_) {
271
271
  return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": Closing account");
272
272
  };
273
273
  TxCloseAccount.prototype.serialize = function () {
@@ -292,7 +292,7 @@ var TxApprove = /** @class */ (function (_super) {
292
292
  return _this;
293
293
  }
294
294
  TxApprove.prototype.toString = function (tokenData) {
295
- var token = tokenData[this.token];
295
+ var token = tokenData[this.token.toLowerCase()];
296
296
  return "Approve ".concat(token === null || token === void 0 ? void 0 : token.symbol);
297
297
  };
298
298
  TxApprove.prototype.serialize = function () {
package/lib/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export * from "./core/contracts";
6
6
  export * from "./core/events";
7
7
  export * from "./core/errors";
8
8
  export * from "./core/pool";
9
+ export * from "./core/protocols";
9
10
  export * from "./core/priceFeeds";
10
11
  export * from "./core/operations";
11
12
  export * from "./core/oracles";
@@ -34,3 +35,4 @@ export { MultiCallContract } from "./utils/multicall";
34
35
  export { callRepeater } from "./utils/repeater";
35
36
  export { getContractName } from "./core/contractsRegister";
36
37
  export { AdapterInterface } from "./core/adapters";
38
+ export { objectEntries, swapKeyValue, keyToLowercase } from "./utils/mappers";
package/lib/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.AdapterInterface = exports.getContractName = exports.callRepeater = exports.MultiCallContract = void 0;
17
+ exports.keyToLowercase = exports.swapKeyValue = exports.objectEntries = exports.AdapterInterface = exports.getContractName = exports.callRepeater = exports.MultiCallContract = void 0;
18
18
  __exportStar(require("./core/constants"), exports);
19
19
  __exportStar(require("./core/creditAccount"), exports);
20
20
  __exportStar(require("./core/creditManager"), exports);
@@ -23,6 +23,7 @@ __exportStar(require("./core/contracts"), exports);
23
23
  __exportStar(require("./core/events"), exports);
24
24
  __exportStar(require("./core/errors"), exports);
25
25
  __exportStar(require("./core/pool"), exports);
26
+ __exportStar(require("./core/protocols"), exports);
26
27
  __exportStar(require("./core/priceFeeds"), exports);
27
28
  __exportStar(require("./core/operations"), exports);
28
29
  __exportStar(require("./core/oracles"), exports);
@@ -54,3 +55,7 @@ var contractsRegister_1 = require("./core/contractsRegister");
54
55
  Object.defineProperty(exports, "getContractName", { enumerable: true, get: function () { return contractsRegister_1.getContractName; } });
55
56
  var adapters_1 = require("./core/adapters");
56
57
  Object.defineProperty(exports, "AdapterInterface", { enumerable: true, get: function () { return adapters_1.AdapterInterface; } });
58
+ var mappers_1 = require("./utils/mappers");
59
+ Object.defineProperty(exports, "objectEntries", { enumerable: true, get: function () { return mappers_1.objectEntries; } });
60
+ Object.defineProperty(exports, "swapKeyValue", { enumerable: true, get: function () { return mappers_1.swapKeyValue; } });
61
+ Object.defineProperty(exports, "keyToLowercase", { enumerable: true, get: function () { return mappers_1.keyToLowercase; } });
@@ -0,0 +1,6 @@
1
+ declare type SupportedValue = string | number;
2
+ declare const objectEntries: <K extends SupportedValue, T>(o: Record<K, T>) => [K, T][];
3
+ declare const swapKeyValue: <K extends SupportedValue, T extends SupportedValue>(o: Record<K, T>) => Record<T, K>;
4
+ declare const keyToLowercase: <K extends SupportedValue, T extends SupportedValue>(o: Record<K, T>) => Record<K, T>;
5
+ export type { SupportedValue };
6
+ export { objectEntries, swapKeyValue, keyToLowercase };
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.keyToLowercase = exports.swapKeyValue = exports.objectEntries = void 0;
15
+ var objectEntries = function (o) { return Object.entries(o); };
16
+ exports.objectEntries = objectEntries;
17
+ var swapKeyValue = function (o) {
18
+ return objectEntries(o).reduce(function (sum, _a) {
19
+ var _b;
20
+ var key = _a[0], value = _a[1];
21
+ return __assign(__assign({}, sum), (_b = {}, _b[value] = key, _b));
22
+ }, {});
23
+ };
24
+ exports.swapKeyValue = swapKeyValue;
25
+ var keyToLowercase = function (o) {
26
+ return objectEntries(o).reduce(function (sum, _a) {
27
+ var _b;
28
+ var key = _a[0], value = _a[1];
29
+ var keyTransformed = typeof key === "string" ? key.toLowerCase() : key;
30
+ return __assign(__assign({}, sum), (_b = {}, _b[keyTransformed] = value, _b));
31
+ }, {});
32
+ };
33
+ exports.keyToLowercase = keyToLowercase;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "0.0.52",
3
+ "version": "0.0.55",
4
4
  "description": "Gearbox SDK",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -1,16 +1,14 @@
1
1
  export enum AdapterInterface {
2
- NO_SWAP, // 0 - 1
3
- UNISWAP_V2_ROUTER, // 1 - 2
4
- UNISWAP_V3_ROUTER, // 2 - 4
5
- CURVE_V1_2ASSETS, // 3 - 8
6
- CURVE_V1_3ASSETS, // 4 - 16
7
- CURVE_V1_4ASSETS, // 5 - 32
8
- CURVE_V1_STECRV_POOL, // 6 - 64
9
- YEARN_V2, // 7 - 128
10
- CONVEX_V1_BASE_REWARD_POOL, // 8 - 256
11
- CONVEX_V1_BOOSTER, // 9 - 512
12
- CONVEX_V1_CLAIM_ZAP, // 10 - 1024
13
- LIDO_V1 // 11 - 2048
14
- }
15
-
16
-
2
+ NO_SWAP, // 0 - 1
3
+ UNISWAP_V2_ROUTER, // 1 - 2
4
+ UNISWAP_V3_ROUTER, // 2 - 4
5
+ CURVE_V1_2ASSETS, // 3 - 8
6
+ CURVE_V1_3ASSETS, // 4 - 16
7
+ CURVE_V1_4ASSETS, // 5 - 32
8
+ CURVE_V1_STECRV_POOL, // 6 - 64
9
+ YEARN_V2, // 7 - 128
10
+ CONVEX_V1_BASE_REWARD_POOL, // 8 - 256
11
+ CONVEX_V1_BOOSTER, // 9 - 512
12
+ CONVEX_V1_CLAIM_ZAP, // 10 - 1024
13
+ LIDO_V1 // 11 - 2048
14
+ }
@@ -3,14 +3,14 @@
3
3
  * Gearbox. Generalized leverage protocol, which allows to take leverage and then use it across other DeFi protocols and platforms in a composable way.
4
4
  * (c) Gearbox.fi, 2021
5
5
  */
6
-
6
+ import { objectEntries, keyToLowercase, swapKeyValue } from "../utils/mappers";
7
7
  import { AdapterInterface } from "./adapters";
8
8
  import { NetworkType } from "./constants";
9
9
  import { Protocols } from "./protocols";
10
10
  import {
11
- ConvexStakedPhantomToken,
12
11
  CurveLPToken,
13
12
  NormalToken,
13
+ ConvexStakedPhantomToken,
14
14
  tokenDataByNetwork
15
15
  } from "./token";
16
16
 
@@ -123,171 +123,224 @@ export const contractsByNetwork: Record<
123
123
 
124
124
  export const UNISWAP_V3_QUOTER = "0xb27308f9f90d607463bb33ea1bebb41c27ce5ab6";
125
125
 
126
- export interface CurveSteCRVPoolParams {
126
+ export interface BaseContractParams {
127
+ name: string;
128
+ }
129
+
130
+ type UniswapV2Params = {
131
+ protocol: Protocols.Uniswap | Protocols.Sushiswap;
132
+ type: AdapterInterface.UNISWAP_V2_ROUTER;
133
+ } & BaseContractParams;
134
+
135
+ type UniswapV3Params = {
136
+ protocol: Protocols.Uniswap;
137
+ type: AdapterInterface.UNISWAP_V3_ROUTER;
138
+ quoter: string;
139
+ } & BaseContractParams;
140
+
141
+ type CurveParams = {
142
+ protocol: Protocols.Curve;
143
+ type:
144
+ | AdapterInterface.CURVE_V1_2ASSETS
145
+ | AdapterInterface.CURVE_V1_3ASSETS
146
+ | AdapterInterface.CURVE_V1_4ASSETS;
147
+ lpToken: CurveLPToken;
148
+ tokens: Array<NormalToken | CurveLPToken>;
149
+ } & BaseContractParams;
150
+
151
+ export type CurveSteCRVPoolParams = {
127
152
  protocol: Protocols.Curve;
128
153
  type: AdapterInterface.CURVE_V1_STECRV_POOL;
129
154
  pool: Record<NetworkType, string>;
130
- }
155
+ lpToken: "steCRV";
156
+ } & BaseContractParams;
157
+
158
+ type YearnParams = {
159
+ protocol: Protocols.Yearn;
160
+ type: AdapterInterface.YEARN_V2;
161
+ } & BaseContractParams;
162
+
163
+ type ConvexParams = {
164
+ protocol: Protocols.Convex;
165
+ type:
166
+ | AdapterInterface.CONVEX_V1_BOOSTER
167
+ | AdapterInterface.CONVEX_V1_CLAIM_ZAP;
168
+ } & BaseContractParams;
131
169
 
132
- export interface LidoParams {
170
+ type ConvexPoolParams = {
171
+ protocol: Protocols.Convex;
172
+ type: AdapterInterface.CONVEX_V1_BASE_REWARD_POOL;
173
+ stakedToken: ConvexStakedPhantomToken;
174
+ } & BaseContractParams;
175
+
176
+ export type LidoParams = {
133
177
  protocol: Protocols.Lido;
134
178
  type: AdapterInterface.LIDO_V1;
135
179
  contract: Record<NetworkType, string>;
136
- }
180
+ lpToken: "steCRV";
181
+ } & BaseContractParams;
137
182
 
138
183
  export type ContractParams =
139
- | {
140
- protocol: Protocols.Uniswap | Protocols.Sushiswap;
141
- type: AdapterInterface.UNISWAP_V2_ROUTER;
142
- }
143
- | {
144
- protocol: Protocols.Uniswap;
145
- type: AdapterInterface.UNISWAP_V3_ROUTER;
146
- quoter: string;
147
- }
148
- | {
149
- protocol: Protocols.Curve;
150
- type:
151
- | AdapterInterface.CURVE_V1_2ASSETS
152
- | AdapterInterface.CURVE_V1_3ASSETS
153
- | AdapterInterface.CURVE_V1_4ASSETS;
154
- lpToken: CurveLPToken;
155
- tokens: Array<NormalToken | CurveLPToken>;
156
- }
184
+ | UniswapV2Params
185
+ | UniswapV3Params
186
+ | CurveParams
157
187
  | CurveSteCRVPoolParams
158
- | {
159
- protocol: Protocols.Yearn;
160
- type: AdapterInterface.YEARN_V2;
161
- }
162
- | {
163
- protocol: Protocols.Convex;
164
- type:
165
- | AdapterInterface.CONVEX_V1_BOOSTER
166
- | AdapterInterface.CONVEX_V1_CLAIM_ZAP;
167
- }
168
- | {
169
- protocol: Protocols.Convex;
170
- type: AdapterInterface.CONVEX_V1_BASE_REWARD_POOL;
171
- stakedToken: ConvexStakedPhantomToken;
172
- }
188
+ | YearnParams
189
+ | ConvexParams
190
+ | ConvexPoolParams
173
191
  | LidoParams;
174
192
 
175
193
  export const contractParams: Record<SupportedContract, ContractParams> = {
176
194
  UNISWAP_V2_ROUTER: {
195
+ name: "Uniswap V2",
177
196
  protocol: Protocols.Uniswap,
178
197
  type: AdapterInterface.UNISWAP_V2_ROUTER
179
198
  },
180
199
  UNISWAP_V3_ROUTER: {
200
+ name: "Uniswap V3",
181
201
  protocol: Protocols.Uniswap,
182
202
  quoter: UNISWAP_V3_QUOTER,
183
203
  type: AdapterInterface.UNISWAP_V3_ROUTER
184
204
  },
205
+
185
206
  SUSHISWAP_ROUTER: {
207
+ name: "Sushiswap",
186
208
  protocol: Protocols.Sushiswap,
187
209
  type: AdapterInterface.UNISWAP_V2_ROUTER
188
210
  },
211
+
189
212
  CURVE_3CRV_POOL: {
213
+ name: "Curve 3Pool",
190
214
  protocol: Protocols.Curve,
191
215
  type: AdapterInterface.CURVE_V1_3ASSETS,
192
216
  lpToken: "3Crv",
193
217
  tokens: ["DAI", "USDC", "USDT"]
194
218
  },
195
219
  CURVE_STETH_GATEWAY: {
220
+ name: "Curve stETH",
196
221
  protocol: Protocols.Curve,
197
222
  type: AdapterInterface.CURVE_V1_STECRV_POOL,
198
223
  pool: {
199
224
  Mainnet: "0xDC24316b9AE028F1497c275EB9192a3Ea0f67022",
200
225
  Kovan: "0xF695d3aa358D5087A0C157DBb9449d4f0d8E534a"
201
- }
226
+ },
227
+ lpToken: "steCRV"
202
228
  },
203
229
  CURVE_FRAX_POOL: {
230
+ name: "Curve FRAX",
204
231
  protocol: Protocols.Curve,
205
232
  type: AdapterInterface.CURVE_V1_2ASSETS,
206
233
  lpToken: "FRAX3CRV",
207
234
  tokens: ["3Crv", "FRAX"]
208
235
  },
209
236
  CURVE_LUSD_POOL: {
237
+ name: "Curve LUSD",
210
238
  protocol: Protocols.Curve,
211
239
  type: AdapterInterface.CURVE_V1_2ASSETS,
212
240
  lpToken: "LUSD3CRV",
213
- tokens: ["3Crv", "FRAX"]
241
+ tokens: ["3Crv", "LUSD"]
214
242
  },
215
243
  CURVE_SUSD_POOL: {
244
+ name: "Curve SUSD",
216
245
  protocol: Protocols.Curve,
217
- type: AdapterInterface.CURVE_V1_2ASSETS,
246
+ type: AdapterInterface.CURVE_V1_4ASSETS,
218
247
  lpToken: "crvPlain3andSUSD",
219
- tokens: ["3Crv", "FRAX"]
248
+ tokens: ["DAI", "USDC", "USDT", "sUSD"]
220
249
  },
221
250
  CURVE_GUSD_POOL: {
251
+ name: "Curve GUSD",
222
252
  protocol: Protocols.Curve,
223
253
  type: AdapterInterface.CURVE_V1_2ASSETS,
224
254
  lpToken: "gusd3CRV",
225
255
  tokens: ["3Crv", "FRAX"]
226
256
  },
257
+
227
258
  YEARN_DAI_VAULT: {
259
+ name: "Yearn DAI",
228
260
  protocol: Protocols.Yearn,
229
261
  type: AdapterInterface.YEARN_V2
230
262
  },
231
-
232
263
  YEARN_USDC_VAULT: {
264
+ name: "Yearn USDC",
233
265
  protocol: Protocols.Yearn,
234
266
  type: AdapterInterface.YEARN_V2
235
267
  },
236
268
  YEARN_WETH_VAULT: {
269
+ name: "Yearn WETH",
237
270
  protocol: Protocols.Yearn,
238
271
  type: AdapterInterface.YEARN_V2
239
272
  },
240
273
  YEARN_WBTC_VAULT: {
274
+ name: "Yearn WBTC",
241
275
  protocol: Protocols.Yearn,
242
276
  type: AdapterInterface.YEARN_V2
243
277
  },
244
278
  YEARN_CURVE_FRAX_VAULT: {
279
+ name: "Yearn Curve FRAX",
245
280
  protocol: Protocols.Yearn,
246
281
  type: AdapterInterface.YEARN_V2
247
282
  },
248
283
  YEARN_CURVE_STETH_VAULT: {
284
+ name: "Yearn Curve STETH",
249
285
  protocol: Protocols.Yearn,
250
286
  type: AdapterInterface.YEARN_V2
251
287
  },
288
+
252
289
  CONVEX_BOOSTER: {
290
+ name: "Convex BOOSTER",
253
291
  protocol: Protocols.Convex,
254
292
  type: AdapterInterface.CONVEX_V1_BOOSTER
255
293
  },
256
294
  CONVEX_3CRV_POOL: {
295
+ name: "Convex 3crv",
257
296
  protocol: Protocols.Convex,
258
297
  type: AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
259
298
  stakedToken: "stkcvx3Crv"
260
299
  },
261
300
  CONVEX_GUSD_POOL: {
301
+ name: "Convex GUSD",
262
302
  protocol: Protocols.Convex,
263
303
  type: AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
264
304
  stakedToken: "stkcvxgusd3CRV"
265
305
  },
266
306
  CONVEX_SUSD_POOL: {
307
+ name: "Convex SUSD",
267
308
  protocol: Protocols.Convex,
268
309
  type: AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
269
310
  stakedToken: "stkcvxcrvPlain3andSUSD"
270
311
  },
271
312
  CONVEX_STECRV_POOL: {
313
+ name: "Convex STECRV",
272
314
  protocol: Protocols.Convex,
273
315
  type: AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
274
316
  stakedToken: "stkcvxsteCRV"
275
317
  },
276
318
  CONVEX_FRAX3CRV_POOL: {
319
+ name: "Convex FRAX3CRV",
277
320
  protocol: Protocols.Convex,
278
321
  type: AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
279
322
  stakedToken: "stkcvxFRAX3CRV"
280
323
  },
281
324
  CONVEX_CLAIM_ZAP: {
325
+ name: "Convex ZAP",
282
326
  protocol: Protocols.Convex,
283
327
  type: AdapterInterface.CONVEX_V1_CLAIM_ZAP
284
328
  },
329
+
285
330
  LIDO_STETH_GATEWAY: {
331
+ name: "Lido STETH",
286
332
  protocol: Protocols.Lido,
287
333
  type: AdapterInterface.LIDO_V1,
288
334
  contract: {
289
335
  Mainnet: "0xae7ab96520de3a18e5e111b5eaab095312d7fe84",
290
336
  Kovan: ""
291
- }
337
+ },
338
+ lpToken: "steCRV"
292
339
  }
293
340
  };
341
+
342
+ export const contractsByAddress = objectEntries(contractsByNetwork).reduce<
343
+ Record<string, SupportedContract>
344
+ >((sum, [_, contracts]) => {
345
+ return { ...sum, ...keyToLowercase(swapKeyValue(contracts)) };
346
+ }, {});
@@ -1,4 +1,5 @@
1
-
1
+ import { keyToLowercase } from "../utils/mappers";
2
+ import { contractsByAddress, contractParams } from "./contracts";
2
3
 
3
4
  export const deployedContracts: Record<string, string> = {
4
5
  // MAINNET
@@ -11,8 +12,6 @@ export const deployedContracts: Record<string, string> = {
11
12
  "0xB2A015c71c17bCAC6af36645DEad8c572bA08A08": "WBTC",
12
13
  "0xC38478B0A4bAFE964C3526EEFF534d70E1E09017": "WBTC",
13
14
 
14
-
15
-
16
15
  // [UNISWAP_V2_ROUTER]: "Uniswap V2",
17
16
  // [UNISWAP_V3_ROUTER]: "Uniswap V3",
18
17
  // [CURVE_3CRV_POOL_ADDRESS]: "Curve 3Pool",
@@ -28,17 +27,26 @@ export const deployedContracts: Record<string, string> = {
28
27
  "0xe04b4db67127d1930D36f16B51653120C4285708": "WBTC",
29
28
  "0x600073357c29d169aAF3E543A4519749830553F1": "WETH",
30
29
  "0xdBAd1361d9A03B81Be8D3a54Ef0dc9e39a1bA5b3": "USDC",
31
- "0x50d1fA47b0D88BA0D108148B8481b4A762eFB99e": "DAI",
30
+ "0x50d1fA47b0D88BA0D108148B8481b4A762eFB99e": "DAI"
32
31
  // [YEARN_DAI_VAULT_KOVAN_MOCK]: "Yearn DAI",
33
32
  // [YEARN_USDC_VAULT_KOVAN_MOCK]: "Yearn USDC",
34
33
  // [SUSHISWAP_KOVAN]: "Sushiswap"
35
34
  };
36
35
 
36
+ const contractNames = Object.entries(contractsByAddress).reduce<
37
+ Record<string, string>
38
+ >((sum, [addr, cSymbol]) => {
39
+ const params = contractParams[cSymbol];
40
+ if (!params) return sum;
37
41
 
42
+ return { ...sum, [addr]: params.name };
43
+ }, {});
44
+
45
+ const contractsFullList = {
46
+ ...keyToLowercase(deployedContracts),
47
+ ...contractNames
48
+ };
38
49
 
39
50
  export function getContractName(address: string): string {
40
- Object.entries(deployedContracts).forEach(([addr, name]) => {
41
- deployedContracts[addr.toLowerCase()] = name;
42
- });
43
- return deployedContracts[address.toLowerCase()] || address;
51
+ return contractsFullList[address.toLowerCase()] || address;
44
52
  }