@gearbox-protocol/sdk 0.0.53 → 0.0.56

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 (63) hide show
  1. package/lib/core/contracts.d.ts +29 -16
  2. package/lib/core/contracts.js +45 -4
  3. package/lib/core/contractsRegister.js +24 -6
  4. package/lib/core/creditAccount.js +26 -20
  5. package/lib/core/events.d.ts +10 -10
  6. package/lib/core/events.js +22 -22
  7. package/lib/core/pathfinder.d.ts +35 -5
  8. package/lib/core/pathfinder.js +547 -67
  9. package/lib/core/priceFeeds.js +61 -0
  10. package/lib/core/token.d.ts +47 -15
  11. package/lib/core/token.js +204 -36
  12. package/lib/core/tradeTypes.d.ts +2 -0
  13. package/lib/core/transactions.d.ts +2 -2
  14. package/lib/core/transactions.js +10 -10
  15. package/lib/index.d.ts +2 -0
  16. package/lib/index.js +6 -1
  17. package/lib/pathfinder/connectorPathAsset.d.ts +7 -0
  18. package/lib/pathfinder/connectorPathAsset.js +144 -0
  19. package/lib/pathfinder/convexLPTokenPathAsset.d.ts +5 -0
  20. package/lib/pathfinder/convexLPTokenPathAsset.js +77 -0
  21. package/lib/pathfinder/curveLPPathAsset.d.ts +5 -0
  22. package/lib/pathfinder/curveLPPathAsset.js +72 -0
  23. package/lib/pathfinder/metaCurveLPPathAsset.d.ts +5 -0
  24. package/lib/pathfinder/metaCurveLPPathAsset.js +72 -0
  25. package/lib/pathfinder/normalTokenPathAsset.d.ts +5 -0
  26. package/lib/pathfinder/normalTokenPathAsset.js +136 -0
  27. package/lib/pathfinder/path.d.ts +41 -0
  28. package/lib/pathfinder/path.js +302 -0
  29. package/lib/pathfinder/pathfinder.d.ts +28 -0
  30. package/lib/pathfinder/pathfinder.js +519 -0
  31. package/lib/pathfinder/yearnVaultOfCurveLPPathAsset.d.ts +5 -0
  32. package/lib/pathfinder/yearnVaultOfCurveLPPathAsset.js +87 -0
  33. package/lib/pathfinder/yearnVaultOfMetaCurveLPPathAsset.d.ts +5 -0
  34. package/lib/pathfinder/yearnVaultOfMetaCurveLPPathAsset.js +87 -0
  35. package/lib/pathfinder/yearnVaultPathAsset.d.ts +5 -0
  36. package/lib/pathfinder/yearnVaultPathAsset.js +87 -0
  37. package/lib/utils/mappers.d.ts +6 -0
  38. package/lib/utils/mappers.js +33 -0
  39. package/lib/utils/types.d.ts +3 -0
  40. package/lib/utils/types.js +2 -0
  41. package/package.json +1 -1
  42. package/src/core/adapters.ts +13 -15
  43. package/src/core/contracts.ts +111 -44
  44. package/src/core/contractsRegister.ts +16 -8
  45. package/src/core/creditAccount.ts +33 -19
  46. package/src/core/events.ts +30 -22
  47. package/src/core/priceFeeds.ts +66 -0
  48. package/src/core/token.ts +645 -370
  49. package/src/core/tradeTypes.ts +2 -0
  50. package/src/core/transactions.ts +10 -10
  51. package/src/index.ts +2 -0
  52. package/src/pathfinder/connectorPathAsset.ts +69 -0
  53. package/src/pathfinder/convexLPTokenPathAsset.ts +33 -0
  54. package/src/pathfinder/curveLPPathAsset.ts +10 -0
  55. package/src/pathfinder/metaCurveLPPathAsset.ts +12 -0
  56. package/src/pathfinder/normalTokenPathAsset.ts +68 -0
  57. package/src/pathfinder/path.ts +259 -0
  58. package/src/pathfinder/yearnVaultOfCurveLPPathAsset.ts +22 -0
  59. package/src/pathfinder/yearnVaultOfMetaCurveLPPathAsset.ts +22 -0
  60. package/src/pathfinder/yearnVaultPathAsset.ts +27 -0
  61. package/src/utils/mappers.ts +23 -0
  62. package/src/utils/types.ts +3 -0
  63. package/src/core/pathfinder.ts +0 -115
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ 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;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.YearnVaultOfMetaCurveLPPathAsset = void 0;
55
+ var token_1 = require("../core/token");
56
+ var path_1 = require("./path");
57
+ var ethers_1 = require("ethers");
58
+ var YearnVaultOfMetaCurveLPPathAsset = /** @class */ (function (_super) {
59
+ __extends(YearnVaultOfMetaCurveLPPathAsset, _super);
60
+ function YearnVaultOfMetaCurveLPPathAsset() {
61
+ return _super !== null && _super.apply(this, arguments) || this;
62
+ }
63
+ YearnVaultOfMetaCurveLPPathAsset.prototype.getBestPath = function (currentToken, p) {
64
+ return __awaiter(this, void 0, void 0, function () {
65
+ var currentBalance, currentTokenData, outputToken, yearnActionData;
66
+ return __generator(this, function (_a) {
67
+ switch (_a.label) {
68
+ case 0:
69
+ currentBalance = p.balances[currentToken].sub(1);
70
+ currentTokenData = token_1.supportedTokens[currentToken];
71
+ outputToken = currentTokenData.lpActions[0].tokenOut;
72
+ return [4 /*yield*/, this.getYearnActionData(currentTokenData.lpActions[0], currentBalance, p)];
73
+ case 1:
74
+ yearnActionData = _a.sent();
75
+ p.balances[outputToken].add(yearnActionData.amountOut);
76
+ p.balances[currentToken] = ethers_1.BigNumber.from(1);
77
+ p.totalGasLimit.add(yearnActionData.gasLimit);
78
+ p.calls.push(yearnActionData.callData);
79
+ return [4 /*yield*/, p.getBestPath()];
80
+ case 2: return [2 /*return*/, _a.sent()];
81
+ }
82
+ });
83
+ });
84
+ };
85
+ return YearnVaultOfMetaCurveLPPathAsset;
86
+ }(path_1.PathAsset));
87
+ exports.YearnVaultOfMetaCurveLPPathAsset = YearnVaultOfMetaCurveLPPathAsset;
@@ -0,0 +1,5 @@
1
+ import { SupportedToken } from "../core/token";
2
+ import { Path, PathAsset } from "./path";
3
+ export declare class YearnVaultPathAsset extends PathAsset {
4
+ getBestPath(currentToken: SupportedToken, p: Path): Promise<Path>;
5
+ }
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ 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;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.YearnVaultPathAsset = void 0;
55
+ var ethers_1 = require("ethers");
56
+ var token_1 = require("../core/token");
57
+ var path_1 = require("./path");
58
+ var YearnVaultPathAsset = /** @class */ (function (_super) {
59
+ __extends(YearnVaultPathAsset, _super);
60
+ function YearnVaultPathAsset() {
61
+ return _super !== null && _super.apply(this, arguments) || this;
62
+ }
63
+ YearnVaultPathAsset.prototype.getBestPath = function (currentToken, p) {
64
+ return __awaiter(this, void 0, void 0, function () {
65
+ var currentBalance, currentTokenData, outputToken, yearnActionData;
66
+ return __generator(this, function (_a) {
67
+ switch (_a.label) {
68
+ case 0:
69
+ currentBalance = p.balances[currentToken].sub(1);
70
+ currentTokenData = token_1.supportedTokens[currentToken];
71
+ outputToken = currentTokenData.lpActions[0].tokenOut;
72
+ return [4 /*yield*/, this.getYearnActionData(currentTokenData.lpActions[0], currentBalance, p)];
73
+ case 1:
74
+ yearnActionData = _a.sent();
75
+ p.balances[outputToken].add(yearnActionData.amountOut);
76
+ p.balances[currentToken] = ethers_1.BigNumber.from(1);
77
+ p.totalGasLimit.add(yearnActionData.gasLimit);
78
+ p.calls.push(yearnActionData.callData);
79
+ return [4 /*yield*/, p.getBestPath()];
80
+ case 2: return [2 /*return*/, _a.sent()];
81
+ }
82
+ });
83
+ });
84
+ };
85
+ return YearnVaultPathAsset;
86
+ }(path_1.PathAsset));
87
+ exports.YearnVaultPathAsset = YearnVaultPathAsset;
@@ -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;
@@ -0,0 +1,3 @@
1
+ export declare type PartialRecord<K extends keyof any, T> = {
2
+ [P in K]?: T;
3
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "0.0.53",
3
+ "version": "0.0.56",
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,12 +3,16 @@
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
- import { CurveLPToken, NormalToken, ConvexStakedPhantomToken, tokenDataByNetwork } from "./token";
11
-
10
+ import {
11
+ CurveLPToken,
12
+ NormalToken,
13
+ ConvexStakedPhantomToken,
14
+ tokenDataByNetwork
15
+ } from "./token";
12
16
 
13
17
  export type UniswapV2Contract = "UNISWAP_V2_ROUTER" | "SUSHISWAP_ROUTER";
14
18
 
@@ -18,6 +22,7 @@ export type CurvePoolContract =
18
22
  | "CURVE_FRAX_POOL"
19
23
  | "CURVE_LUSD_POOL"
20
24
  | "CURVE_GUSD_POOL"
25
+ | "CURVE_SUSD_DEPOSIT"
21
26
  | "CURVE_SUSD_POOL";
22
27
 
23
28
  export type YearnVaultContract =
@@ -60,6 +65,7 @@ export const contractsByNetwork: Record<
60
65
  CURVE_FRAX_POOL: tokenDataByNetwork.Mainnet.FRAX3CRV,
61
66
  CURVE_LUSD_POOL: tokenDataByNetwork.Mainnet.LUSD3CRV,
62
67
  CURVE_SUSD_POOL: "0xA5407eAE9Ba41422680e2e00537571bcC53efBfD", // SEPARATE TOKEN
68
+ CURVE_SUSD_DEPOSIT: "0xFCBa3E75865d2d561BE8D220616520c171F12851",
63
69
  CURVE_GUSD_POOL: "0x4f062658EaAF2C1ccf8C8e36D6824CDf41167956", // SEPARATE TOKEN
64
70
 
65
71
  // YEARN
@@ -93,6 +99,7 @@ export const contractsByNetwork: Record<
93
99
  CURVE_FRAX_POOL: "",
94
100
  CURVE_LUSD_POOL: tokenDataByNetwork.Kovan.LUSD3CRV,
95
101
  CURVE_SUSD_POOL: "0x032f1cE00865F3499C0052ceBA5F2348842416DB", // SEPARATE TOKEN
102
+ CURVE_SUSD_DEPOSIT: "",
96
103
  CURVE_GUSD_POOL: "",
97
104
 
98
105
  // YEARN
@@ -119,171 +126,231 @@ export const contractsByNetwork: Record<
119
126
 
120
127
  export const UNISWAP_V3_QUOTER = "0xb27308f9f90d607463bb33ea1bebb41c27ce5ab6";
121
128
 
122
- export interface CurveSteCRVPoolParams {
129
+ export interface BaseContractParams {
130
+ name: string;
131
+ }
132
+
133
+ type UniswapV2Params = {
134
+ protocol: Protocols.Uniswap | Protocols.Sushiswap;
135
+ type: AdapterInterface.UNISWAP_V2_ROUTER;
136
+ } & BaseContractParams;
137
+
138
+ type UniswapV3Params = {
139
+ protocol: Protocols.Uniswap;
140
+ type: AdapterInterface.UNISWAP_V3_ROUTER;
141
+ quoter: string;
142
+ } & BaseContractParams;
143
+
144
+ type CurveParams = {
145
+ protocol: Protocols.Curve;
146
+ type:
147
+ | AdapterInterface.CURVE_V1_2ASSETS
148
+ | AdapterInterface.CURVE_V1_3ASSETS
149
+ | AdapterInterface.CURVE_V1_4ASSETS;
150
+ lpToken: CurveLPToken;
151
+ tokens: Array<NormalToken | CurveLPToken>;
152
+ } & BaseContractParams;
153
+
154
+ export type CurveSteCRVPoolParams = {
123
155
  protocol: Protocols.Curve;
124
156
  type: AdapterInterface.CURVE_V1_STECRV_POOL;
125
157
  pool: Record<NetworkType, string>;
126
- }
158
+ lpToken: "steCRV";
159
+ } & BaseContractParams;
160
+
161
+ type YearnParams = {
162
+ protocol: Protocols.Yearn;
163
+ type: AdapterInterface.YEARN_V2;
164
+ } & BaseContractParams;
165
+
166
+ type ConvexParams = {
167
+ protocol: Protocols.Convex;
168
+ type:
169
+ | AdapterInterface.CONVEX_V1_BOOSTER
170
+ | AdapterInterface.CONVEX_V1_CLAIM_ZAP;
171
+ } & BaseContractParams;
127
172
 
128
- export interface LidoParams {
173
+ type ConvexPoolParams = {
174
+ protocol: Protocols.Convex;
175
+ type: AdapterInterface.CONVEX_V1_BASE_REWARD_POOL;
176
+ stakedToken: ConvexStakedPhantomToken;
177
+ } & BaseContractParams;
178
+
179
+ export type LidoParams = {
129
180
  protocol: Protocols.Lido;
130
181
  type: AdapterInterface.LIDO_V1;
131
182
  contract: Record<NetworkType, string>;
132
- }
183
+ lpToken: "steCRV";
184
+ } & BaseContractParams;
133
185
 
134
186
  export type ContractParams =
135
- | {
136
- protocol: Protocols.Uniswap | Protocols.Sushiswap;
137
- type: AdapterInterface.UNISWAP_V2_ROUTER;
138
- }
139
- | {
140
- protocol: Protocols.Uniswap;
141
- type: AdapterInterface.UNISWAP_V3_ROUTER;
142
- quoter: string;
143
- }
144
- | {
145
- protocol: Protocols.Curve;
146
- type:
147
- | AdapterInterface.CURVE_V1_2ASSETS
148
- | AdapterInterface.CURVE_V1_3ASSETS
149
- | AdapterInterface.CURVE_V1_4ASSETS;
150
- lpToken: CurveLPToken;
151
- tokens: Array<NormalToken | CurveLPToken>;
152
- }
187
+ | UniswapV2Params
188
+ | UniswapV3Params
189
+ | CurveParams
153
190
  | CurveSteCRVPoolParams
154
- | {
155
- protocol: Protocols.Yearn;
156
- type: AdapterInterface.YEARN_V2;
157
- }
158
- | {
159
- protocol: Protocols.Convex;
160
- type:
161
- | AdapterInterface.CONVEX_V1_BOOSTER
162
- | AdapterInterface.CONVEX_V1_CLAIM_ZAP;
163
- }
164
- | {
165
- protocol: Protocols.Convex;
166
- type: AdapterInterface.CONVEX_V1_BASE_REWARD_POOL;
167
- stakedToken: ConvexStakedPhantomToken;
168
- }
191
+ | YearnParams
192
+ | ConvexParams
193
+ | ConvexPoolParams
169
194
  | LidoParams;
170
195
 
171
196
  export const contractParams: Record<SupportedContract, ContractParams> = {
172
197
  UNISWAP_V2_ROUTER: {
198
+ name: "Uniswap V2",
173
199
  protocol: Protocols.Uniswap,
174
200
  type: AdapterInterface.UNISWAP_V2_ROUTER
175
201
  },
176
202
  UNISWAP_V3_ROUTER: {
203
+ name: "Uniswap V3",
177
204
  protocol: Protocols.Uniswap,
178
205
  quoter: UNISWAP_V3_QUOTER,
179
206
  type: AdapterInterface.UNISWAP_V3_ROUTER
180
207
  },
208
+
181
209
  SUSHISWAP_ROUTER: {
210
+ name: "Sushiswap",
182
211
  protocol: Protocols.Sushiswap,
183
212
  type: AdapterInterface.UNISWAP_V2_ROUTER
184
213
  },
214
+
185
215
  CURVE_3CRV_POOL: {
216
+ name: "Curve 3Pool",
186
217
  protocol: Protocols.Curve,
187
218
  type: AdapterInterface.CURVE_V1_3ASSETS,
188
219
  lpToken: "3Crv",
189
220
  tokens: ["DAI", "USDC", "USDT"]
190
221
  },
191
222
  CURVE_STETH_GATEWAY: {
223
+ name: "Curve stETH",
192
224
  protocol: Protocols.Curve,
193
225
  type: AdapterInterface.CURVE_V1_STECRV_POOL,
194
226
  pool: {
195
227
  Mainnet: "0xDC24316b9AE028F1497c275EB9192a3Ea0f67022",
196
228
  Kovan: "0xF695d3aa358D5087A0C157DBb9449d4f0d8E534a"
197
- }
229
+ },
230
+ lpToken: "steCRV"
198
231
  },
199
232
  CURVE_FRAX_POOL: {
233
+ name: "Curve FRAX",
200
234
  protocol: Protocols.Curve,
201
235
  type: AdapterInterface.CURVE_V1_2ASSETS,
202
236
  lpToken: "FRAX3CRV",
203
237
  tokens: ["3Crv", "FRAX"]
204
238
  },
205
239
  CURVE_LUSD_POOL: {
240
+ name: "Curve LUSD",
206
241
  protocol: Protocols.Curve,
207
242
  type: AdapterInterface.CURVE_V1_2ASSETS,
208
243
  lpToken: "LUSD3CRV",
209
244
  tokens: ["3Crv", "LUSD"]
210
245
  },
211
246
  CURVE_SUSD_POOL: {
247
+ name: "Curve SUSD",
212
248
  protocol: Protocols.Curve,
213
249
  type: AdapterInterface.CURVE_V1_4ASSETS,
214
250
  lpToken: "crvPlain3andSUSD",
215
251
  tokens: ["DAI", "USDC", "USDT", "sUSD"]
216
252
  },
253
+ CURVE_SUSD_DEPOSIT: {
254
+ name: "Curve SUSD Deposit",
255
+ protocol: Protocols.Curve,
256
+ type: AdapterInterface.CURVE_V1_4ASSETS,
257
+ lpToken: "crvPlain3andSUSD",
258
+ tokens: ["DAI", "USDC", "USDT", "sUSD"]
259
+ },
217
260
  CURVE_GUSD_POOL: {
261
+ name: "Curve GUSD",
218
262
  protocol: Protocols.Curve,
219
263
  type: AdapterInterface.CURVE_V1_2ASSETS,
220
264
  lpToken: "gusd3CRV",
221
- tokens: ["3Crv", "FRAX"]
265
+ tokens: ["3Crv", "GUSD"]
222
266
  },
267
+
223
268
  YEARN_DAI_VAULT: {
269
+ name: "Yearn DAI",
224
270
  protocol: Protocols.Yearn,
225
271
  type: AdapterInterface.YEARN_V2
226
272
  },
227
-
228
273
  YEARN_USDC_VAULT: {
274
+ name: "Yearn USDC",
229
275
  protocol: Protocols.Yearn,
230
276
  type: AdapterInterface.YEARN_V2
231
277
  },
232
278
  YEARN_WETH_VAULT: {
279
+ name: "Yearn WETH",
233
280
  protocol: Protocols.Yearn,
234
281
  type: AdapterInterface.YEARN_V2
235
282
  },
236
283
  YEARN_WBTC_VAULT: {
284
+ name: "Yearn WBTC",
237
285
  protocol: Protocols.Yearn,
238
286
  type: AdapterInterface.YEARN_V2
239
287
  },
240
288
  YEARN_CURVE_FRAX_VAULT: {
289
+ name: "Yearn Curve FRAX",
241
290
  protocol: Protocols.Yearn,
242
291
  type: AdapterInterface.YEARN_V2
243
292
  },
244
293
  YEARN_CURVE_STETH_VAULT: {
294
+ name: "Yearn Curve STETH",
245
295
  protocol: Protocols.Yearn,
246
296
  type: AdapterInterface.YEARN_V2
247
297
  },
298
+
248
299
  CONVEX_BOOSTER: {
300
+ name: "Convex BOOSTER",
249
301
  protocol: Protocols.Convex,
250
302
  type: AdapterInterface.CONVEX_V1_BOOSTER
251
303
  },
252
304
  CONVEX_3CRV_POOL: {
305
+ name: "Convex 3crv",
253
306
  protocol: Protocols.Convex,
254
307
  type: AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
255
308
  stakedToken: "stkcvx3Crv"
256
309
  },
257
310
  CONVEX_GUSD_POOL: {
311
+ name: "Convex GUSD",
258
312
  protocol: Protocols.Convex,
259
313
  type: AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
260
314
  stakedToken: "stkcvxgusd3CRV"
261
315
  },
262
316
  CONVEX_SUSD_POOL: {
317
+ name: "Convex SUSD",
263
318
  protocol: Protocols.Convex,
264
319
  type: AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
265
320
  stakedToken: "stkcvxcrvPlain3andSUSD"
266
321
  },
267
322
  CONVEX_STECRV_POOL: {
323
+ name: "Convex STECRV",
268
324
  protocol: Protocols.Convex,
269
325
  type: AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
270
326
  stakedToken: "stkcvxsteCRV"
271
327
  },
272
328
  CONVEX_FRAX3CRV_POOL: {
329
+ name: "Convex FRAX3CRV",
273
330
  protocol: Protocols.Convex,
274
331
  type: AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
275
332
  stakedToken: "stkcvxFRAX3CRV"
276
333
  },
277
334
  CONVEX_CLAIM_ZAP: {
335
+ name: "Convex ZAP",
278
336
  protocol: Protocols.Convex,
279
337
  type: AdapterInterface.CONVEX_V1_CLAIM_ZAP
280
338
  },
339
+
281
340
  LIDO_STETH_GATEWAY: {
341
+ name: "Lido STETH",
282
342
  protocol: Protocols.Lido,
283
343
  type: AdapterInterface.LIDO_V1,
284
344
  contract: {
285
345
  Mainnet: "0xae7ab96520de3a18e5e111b5eaab095312d7fe84",
286
346
  Kovan: ""
287
- }
347
+ },
348
+ lpToken: "steCRV"
288
349
  }
289
350
  };
351
+
352
+ export const contractsByAddress = objectEntries(contractsByNetwork).reduce<
353
+ Record<string, SupportedContract>
354
+ >((sum, [_, contracts]) => {
355
+ return { ...sum, ...keyToLowercase(swapKeyValue(contracts)) };
356
+ }, {});
@@ -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
  }