@gearbox-protocol/sdk 0.0.54 → 0.0.57
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/lib/core/contracts.d.ts +29 -17
- package/lib/core/contracts.js +43 -3
- package/lib/core/contractsRegister.js +24 -6
- package/lib/core/creditAccount.js +26 -20
- package/lib/core/events.d.ts +10 -10
- package/lib/core/events.js +22 -22
- package/lib/core/pathfinder.d.ts +35 -5
- package/lib/core/pathfinder.js +547 -67
- package/lib/core/priceFeeds.js +61 -0
- package/lib/core/token.d.ts +47 -15
- package/lib/core/token.js +204 -36
- package/lib/core/tradeTypes.d.ts +2 -0
- package/lib/core/transactions.d.ts +2 -2
- package/lib/core/transactions.js +10 -10
- package/lib/index.d.ts +2 -0
- package/lib/index.js +6 -1
- package/lib/pathfinder/connectorPathAsset.d.ts +7 -0
- package/lib/pathfinder/connectorPathAsset.js +144 -0
- package/lib/pathfinder/convexLPTokenPathAsset.d.ts +5 -0
- package/lib/pathfinder/convexLPTokenPathAsset.js +77 -0
- package/lib/pathfinder/curveLPPathAsset.d.ts +5 -0
- package/lib/pathfinder/curveLPPathAsset.js +72 -0
- package/lib/pathfinder/metaCurveLPPathAsset.d.ts +5 -0
- package/lib/pathfinder/metaCurveLPPathAsset.js +72 -0
- package/lib/pathfinder/normalTokenPathAsset.d.ts +5 -0
- package/lib/pathfinder/normalTokenPathAsset.js +136 -0
- package/lib/pathfinder/path.d.ts +41 -0
- package/lib/pathfinder/path.js +302 -0
- package/lib/pathfinder/pathfinder.d.ts +28 -0
- package/lib/pathfinder/pathfinder.js +519 -0
- package/lib/pathfinder/yearnVaultOfCurveLPPathAsset.d.ts +5 -0
- package/lib/pathfinder/yearnVaultOfCurveLPPathAsset.js +87 -0
- package/lib/pathfinder/yearnVaultOfMetaCurveLPPathAsset.d.ts +5 -0
- package/lib/pathfinder/yearnVaultOfMetaCurveLPPathAsset.js +87 -0
- package/lib/pathfinder/yearnVaultPathAsset.d.ts +5 -0
- package/lib/pathfinder/yearnVaultPathAsset.js +87 -0
- package/lib/utils/mappers.d.ts +6 -0
- package/lib/utils/mappers.js +33 -0
- package/lib/utils/types.d.ts +3 -0
- package/lib/utils/types.js +2 -0
- package/package.json +1 -1
- package/src/core/adapters.ts +14 -15
- package/src/core/contracts.ts +121 -43
- package/src/core/contractsRegister.ts +16 -8
- package/src/core/creditAccount.ts +33 -19
- package/src/core/events.ts +30 -22
- package/src/core/priceFeeds.ts +66 -0
- package/src/core/token.ts +645 -370
- package/src/core/tradeTypes.ts +2 -0
- package/src/core/transactions.ts +10 -10
- package/src/index.ts +2 -0
- package/src/pathfinder/connectorPathAsset.ts +69 -0
- package/src/pathfinder/convexLPTokenPathAsset.ts +33 -0
- package/src/pathfinder/curveLPPathAsset.ts +10 -0
- package/src/pathfinder/metaCurveLPPathAsset.ts +12 -0
- package/src/pathfinder/normalTokenPathAsset.ts +68 -0
- package/src/pathfinder/path.ts +259 -0
- package/src/pathfinder/yearnVaultOfCurveLPPathAsset.ts +22 -0
- package/src/pathfinder/yearnVaultOfMetaCurveLPPathAsset.ts +22 -0
- package/src/pathfinder/yearnVaultPathAsset.ts +27 -0
- package/src/utils/mappers.ts +23 -0
- package/src/utils/types.ts +3 -0
- 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,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;
|
package/package.json
CHANGED
package/src/core/adapters.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
export enum AdapterInterface {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
CURVE_V1_DEPOSIT, // 7 - 128
|
|
10
|
+
YEARN_V2, // 8 - 256
|
|
11
|
+
CONVEX_V1_BASE_REWARD_POOL, // 9 - 512
|
|
12
|
+
CONVEX_V1_BOOSTER, // 10 - 1024
|
|
13
|
+
CONVEX_V1_CLAIM_ZAP, // 11 - 2048
|
|
14
|
+
LIDO_V1 // 12 - 4096
|
|
15
|
+
}
|
package/src/core/contracts.ts
CHANGED
|
@@ -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 {
|
|
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,77 +126,110 @@ export const contractsByNetwork: Record<
|
|
|
119
126
|
|
|
120
127
|
export const UNISWAP_V3_QUOTER = "0xb27308f9f90d607463bb33ea1bebb41c27ce5ab6";
|
|
121
128
|
|
|
122
|
-
export interface
|
|
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";
|
|
127
|
-
}
|
|
159
|
+
} & BaseContractParams;
|
|
160
|
+
|
|
161
|
+
export type CurveDepositParams = {
|
|
162
|
+
protocol: Protocols.Curve;
|
|
163
|
+
type: AdapterInterface.CURVE_V1_DEPOSIT;
|
|
164
|
+
pool: Record<NetworkType, string>;
|
|
165
|
+
lpToken: CurveLPToken;
|
|
166
|
+
nCoins: number
|
|
167
|
+
} & BaseContractParams;
|
|
168
|
+
|
|
169
|
+
type YearnParams = {
|
|
170
|
+
protocol: Protocols.Yearn;
|
|
171
|
+
type: AdapterInterface.YEARN_V2;
|
|
172
|
+
} & BaseContractParams;
|
|
173
|
+
|
|
174
|
+
type ConvexParams = {
|
|
175
|
+
protocol: Protocols.Convex;
|
|
176
|
+
type:
|
|
177
|
+
| AdapterInterface.CONVEX_V1_BOOSTER
|
|
178
|
+
| AdapterInterface.CONVEX_V1_CLAIM_ZAP;
|
|
179
|
+
} & BaseContractParams;
|
|
128
180
|
|
|
129
|
-
|
|
181
|
+
type ConvexPoolParams = {
|
|
182
|
+
protocol: Protocols.Convex;
|
|
183
|
+
type: AdapterInterface.CONVEX_V1_BASE_REWARD_POOL;
|
|
184
|
+
stakedToken: ConvexStakedPhantomToken;
|
|
185
|
+
} & BaseContractParams;
|
|
186
|
+
|
|
187
|
+
export type LidoParams = {
|
|
130
188
|
protocol: Protocols.Lido;
|
|
131
189
|
type: AdapterInterface.LIDO_V1;
|
|
132
190
|
contract: Record<NetworkType, string>;
|
|
133
|
-
|
|
191
|
+
lpToken: "steCRV";
|
|
192
|
+
} & BaseContractParams;
|
|
134
193
|
|
|
135
194
|
export type ContractParams =
|
|
136
|
-
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
| {
|
|
141
|
-
protocol: Protocols.Uniswap;
|
|
142
|
-
type: AdapterInterface.UNISWAP_V3_ROUTER;
|
|
143
|
-
quoter: string;
|
|
144
|
-
}
|
|
145
|
-
| {
|
|
146
|
-
protocol: Protocols.Curve;
|
|
147
|
-
type:
|
|
148
|
-
| AdapterInterface.CURVE_V1_2ASSETS
|
|
149
|
-
| AdapterInterface.CURVE_V1_3ASSETS
|
|
150
|
-
| AdapterInterface.CURVE_V1_4ASSETS;
|
|
151
|
-
lpToken: CurveLPToken;
|
|
152
|
-
tokens: Array<NormalToken | CurveLPToken>;
|
|
153
|
-
}
|
|
195
|
+
| UniswapV2Params
|
|
196
|
+
| UniswapV3Params
|
|
197
|
+
| CurveParams
|
|
154
198
|
| CurveSteCRVPoolParams
|
|
155
|
-
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
| {
|
|
160
|
-
protocol: Protocols.Convex;
|
|
161
|
-
type:
|
|
162
|
-
| AdapterInterface.CONVEX_V1_BOOSTER
|
|
163
|
-
| AdapterInterface.CONVEX_V1_CLAIM_ZAP;
|
|
164
|
-
}
|
|
165
|
-
| {
|
|
166
|
-
protocol: Protocols.Convex;
|
|
167
|
-
type: AdapterInterface.CONVEX_V1_BASE_REWARD_POOL;
|
|
168
|
-
stakedToken: ConvexStakedPhantomToken;
|
|
169
|
-
}
|
|
199
|
+
| CurveDepositParams
|
|
200
|
+
| YearnParams
|
|
201
|
+
| ConvexParams
|
|
202
|
+
| ConvexPoolParams
|
|
170
203
|
| LidoParams;
|
|
171
204
|
|
|
172
205
|
export const contractParams: Record<SupportedContract, ContractParams> = {
|
|
173
206
|
UNISWAP_V2_ROUTER: {
|
|
207
|
+
name: "Uniswap V2",
|
|
174
208
|
protocol: Protocols.Uniswap,
|
|
175
209
|
type: AdapterInterface.UNISWAP_V2_ROUTER
|
|
176
210
|
},
|
|
177
211
|
UNISWAP_V3_ROUTER: {
|
|
212
|
+
name: "Uniswap V3",
|
|
178
213
|
protocol: Protocols.Uniswap,
|
|
179
214
|
quoter: UNISWAP_V3_QUOTER,
|
|
180
215
|
type: AdapterInterface.UNISWAP_V3_ROUTER
|
|
181
216
|
},
|
|
217
|
+
|
|
182
218
|
SUSHISWAP_ROUTER: {
|
|
219
|
+
name: "Sushiswap",
|
|
183
220
|
protocol: Protocols.Sushiswap,
|
|
184
221
|
type: AdapterInterface.UNISWAP_V2_ROUTER
|
|
185
222
|
},
|
|
223
|
+
|
|
186
224
|
CURVE_3CRV_POOL: {
|
|
225
|
+
name: "Curve 3Pool",
|
|
187
226
|
protocol: Protocols.Curve,
|
|
188
227
|
type: AdapterInterface.CURVE_V1_3ASSETS,
|
|
189
228
|
lpToken: "3Crv",
|
|
190
229
|
tokens: ["DAI", "USDC", "USDT"]
|
|
191
230
|
},
|
|
192
231
|
CURVE_STETH_GATEWAY: {
|
|
232
|
+
name: "Curve stETH",
|
|
193
233
|
protocol: Protocols.Curve,
|
|
194
234
|
type: AdapterInterface.CURVE_V1_STECRV_POOL,
|
|
195
235
|
pool: {
|
|
@@ -199,93 +239,131 @@ export const contractParams: Record<SupportedContract, ContractParams> = {
|
|
|
199
239
|
lpToken: "steCRV"
|
|
200
240
|
},
|
|
201
241
|
CURVE_FRAX_POOL: {
|
|
242
|
+
name: "Curve FRAX",
|
|
202
243
|
protocol: Protocols.Curve,
|
|
203
244
|
type: AdapterInterface.CURVE_V1_2ASSETS,
|
|
204
245
|
lpToken: "FRAX3CRV",
|
|
205
246
|
tokens: ["3Crv", "FRAX"]
|
|
206
247
|
},
|
|
207
248
|
CURVE_LUSD_POOL: {
|
|
249
|
+
name: "Curve LUSD",
|
|
208
250
|
protocol: Protocols.Curve,
|
|
209
251
|
type: AdapterInterface.CURVE_V1_2ASSETS,
|
|
210
252
|
lpToken: "LUSD3CRV",
|
|
211
253
|
tokens: ["3Crv", "LUSD"]
|
|
212
254
|
},
|
|
213
255
|
CURVE_SUSD_POOL: {
|
|
256
|
+
name: "Curve SUSD",
|
|
214
257
|
protocol: Protocols.Curve,
|
|
215
258
|
type: AdapterInterface.CURVE_V1_4ASSETS,
|
|
216
259
|
lpToken: "crvPlain3andSUSD",
|
|
217
260
|
tokens: ["DAI", "USDC", "USDT", "sUSD"]
|
|
218
261
|
},
|
|
262
|
+
CURVE_SUSD_DEPOSIT: {
|
|
263
|
+
name: "Curve SUSD Deposit",
|
|
264
|
+
protocol: Protocols.Curve,
|
|
265
|
+
type: AdapterInterface.CURVE_V1_DEPOSIT,
|
|
266
|
+
lpToken: "crvPlain3andSUSD",
|
|
267
|
+
pool: {
|
|
268
|
+
Mainnet: "0x22eE18aca7F3Ee920D01F25dA85840D12d98E8Ca",
|
|
269
|
+
Kovan: ""
|
|
270
|
+
},
|
|
271
|
+
nCoins: 4
|
|
272
|
+
},
|
|
219
273
|
CURVE_GUSD_POOL: {
|
|
274
|
+
name: "Curve GUSD",
|
|
220
275
|
protocol: Protocols.Curve,
|
|
221
276
|
type: AdapterInterface.CURVE_V1_2ASSETS,
|
|
222
277
|
lpToken: "gusd3CRV",
|
|
223
|
-
tokens: ["3Crv", "
|
|
278
|
+
tokens: ["3Crv", "GUSD"]
|
|
224
279
|
},
|
|
280
|
+
|
|
225
281
|
YEARN_DAI_VAULT: {
|
|
282
|
+
name: "Yearn DAI",
|
|
226
283
|
protocol: Protocols.Yearn,
|
|
227
284
|
type: AdapterInterface.YEARN_V2
|
|
228
285
|
},
|
|
229
|
-
|
|
230
286
|
YEARN_USDC_VAULT: {
|
|
287
|
+
name: "Yearn USDC",
|
|
231
288
|
protocol: Protocols.Yearn,
|
|
232
289
|
type: AdapterInterface.YEARN_V2
|
|
233
290
|
},
|
|
234
291
|
YEARN_WETH_VAULT: {
|
|
292
|
+
name: "Yearn WETH",
|
|
235
293
|
protocol: Protocols.Yearn,
|
|
236
294
|
type: AdapterInterface.YEARN_V2
|
|
237
295
|
},
|
|
238
296
|
YEARN_WBTC_VAULT: {
|
|
297
|
+
name: "Yearn WBTC",
|
|
239
298
|
protocol: Protocols.Yearn,
|
|
240
299
|
type: AdapterInterface.YEARN_V2
|
|
241
300
|
},
|
|
242
301
|
YEARN_CURVE_FRAX_VAULT: {
|
|
302
|
+
name: "Yearn Curve FRAX",
|
|
243
303
|
protocol: Protocols.Yearn,
|
|
244
304
|
type: AdapterInterface.YEARN_V2
|
|
245
305
|
},
|
|
246
306
|
YEARN_CURVE_STETH_VAULT: {
|
|
307
|
+
name: "Yearn Curve STETH",
|
|
247
308
|
protocol: Protocols.Yearn,
|
|
248
309
|
type: AdapterInterface.YEARN_V2
|
|
249
310
|
},
|
|
311
|
+
|
|
250
312
|
CONVEX_BOOSTER: {
|
|
313
|
+
name: "Convex BOOSTER",
|
|
251
314
|
protocol: Protocols.Convex,
|
|
252
315
|
type: AdapterInterface.CONVEX_V1_BOOSTER
|
|
253
316
|
},
|
|
254
317
|
CONVEX_3CRV_POOL: {
|
|
318
|
+
name: "Convex 3crv",
|
|
255
319
|
protocol: Protocols.Convex,
|
|
256
320
|
type: AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
|
|
257
321
|
stakedToken: "stkcvx3Crv"
|
|
258
322
|
},
|
|
259
323
|
CONVEX_GUSD_POOL: {
|
|
324
|
+
name: "Convex GUSD",
|
|
260
325
|
protocol: Protocols.Convex,
|
|
261
326
|
type: AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
|
|
262
327
|
stakedToken: "stkcvxgusd3CRV"
|
|
263
328
|
},
|
|
264
329
|
CONVEX_SUSD_POOL: {
|
|
330
|
+
name: "Convex SUSD",
|
|
265
331
|
protocol: Protocols.Convex,
|
|
266
332
|
type: AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
|
|
267
333
|
stakedToken: "stkcvxcrvPlain3andSUSD"
|
|
268
334
|
},
|
|
269
335
|
CONVEX_STECRV_POOL: {
|
|
336
|
+
name: "Convex STECRV",
|
|
270
337
|
protocol: Protocols.Convex,
|
|
271
338
|
type: AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
|
|
272
339
|
stakedToken: "stkcvxsteCRV"
|
|
273
340
|
},
|
|
274
341
|
CONVEX_FRAX3CRV_POOL: {
|
|
342
|
+
name: "Convex FRAX3CRV",
|
|
275
343
|
protocol: Protocols.Convex,
|
|
276
344
|
type: AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
|
|
277
345
|
stakedToken: "stkcvxFRAX3CRV"
|
|
278
346
|
},
|
|
279
347
|
CONVEX_CLAIM_ZAP: {
|
|
348
|
+
name: "Convex ZAP",
|
|
280
349
|
protocol: Protocols.Convex,
|
|
281
350
|
type: AdapterInterface.CONVEX_V1_CLAIM_ZAP
|
|
282
351
|
},
|
|
352
|
+
|
|
283
353
|
LIDO_STETH_GATEWAY: {
|
|
354
|
+
name: "Lido STETH",
|
|
284
355
|
protocol: Protocols.Lido,
|
|
285
356
|
type: AdapterInterface.LIDO_V1,
|
|
286
357
|
contract: {
|
|
287
358
|
Mainnet: "0xae7ab96520de3a18e5e111b5eaab095312d7fe84",
|
|
288
359
|
Kovan: ""
|
|
289
|
-
}
|
|
360
|
+
},
|
|
361
|
+
lpToken: "steCRV"
|
|
290
362
|
}
|
|
291
363
|
};
|
|
364
|
+
|
|
365
|
+
export const contractsByAddress = objectEntries(contractsByNetwork).reduce<
|
|
366
|
+
Record<string, SupportedContract>
|
|
367
|
+
>((sum, [_, contracts]) => {
|
|
368
|
+
return { ...sum, ...keyToLowercase(swapKeyValue(contracts)) };
|
|
369
|
+
}, {});
|
|
@@ -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
|
-
|
|
41
|
-
deployedContracts[addr.toLowerCase()] = name;
|
|
42
|
-
});
|
|
43
|
-
return deployedContracts[address.toLowerCase()] || address;
|
|
51
|
+
return contractsFullList[address.toLowerCase()] || address;
|
|
44
52
|
}
|