@gearbox-protocol/sdk 0.0.36 → 0.0.39
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/pathfinder.d.ts +12 -6
- package/lib/core/pathfinder.js +116 -3
- package/lib/core/token.d.ts +5 -12
- package/lib/core/token.js +19 -11
- package/package.json +1 -1
- package/src/core/pathfinder.ts +94 -20
- package/src/core/token.ts +24 -14
package/lib/core/pathfinder.d.ts
CHANGED
|
@@ -2,12 +2,18 @@ import { BigNumber } from "ethers";
|
|
|
2
2
|
import { CreditManagerData } from "./creditManager";
|
|
3
3
|
import { MultiCall } from "./multicall";
|
|
4
4
|
import { SupportedTokens } from "./token";
|
|
5
|
-
export
|
|
6
|
-
calls: Array<MultiCall>;
|
|
7
|
-
balances: Record<SupportedTokens, BigNumber>;
|
|
8
|
-
|
|
9
|
-
pool: SupportedTokens;
|
|
10
|
-
creditManager: CreditManagerData;
|
|
5
|
+
export declare class Path {
|
|
6
|
+
readonly calls: Array<MultiCall>;
|
|
7
|
+
readonly balances: Record<SupportedTokens, BigNumber>;
|
|
8
|
+
protected _gasUsed: number;
|
|
9
|
+
readonly pool: SupportedTokens;
|
|
10
|
+
readonly creditManager: CreditManagerData;
|
|
11
|
+
constructor(opts: {
|
|
12
|
+
gasUsed: number;
|
|
13
|
+
balances: Record<SupportedTokens, BigNumber>;
|
|
14
|
+
pool: SupportedTokens;
|
|
15
|
+
creditManager: CreditManagerData;
|
|
16
|
+
});
|
|
11
17
|
getBestPath(): Promise<Path>;
|
|
12
18
|
}
|
|
13
19
|
export interface PathAsset {
|
package/lib/core/pathfinder.js
CHANGED
|
@@ -1,16 +1,129 @@
|
|
|
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
|
+
};
|
|
2
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConnectorPathAsset = void 0;
|
|
39
|
+
exports.ConnectorPathAsset = exports.Path = void 0;
|
|
40
|
+
// const path = new Path({gasUsed:0, balances: creditAccount.balances, })
|
|
41
|
+
// const closurePath = await path.getBestPath();
|
|
42
|
+
// closurePath.calls -> multicalls (!)
|
|
43
|
+
// closurePath.balances[path.pool] = (X)
|
|
44
|
+
// closurePath.balances[!path.pool] = 0 / 1;
|
|
45
|
+
//
|
|
46
|
+
// [0,0,0, 100]
|
|
47
|
+
// [ 12, 12, 12, 0]
|
|
48
|
+
var Path = /** @class */ (function () {
|
|
49
|
+
function Path(opts) {
|
|
50
|
+
this.calls = [];
|
|
51
|
+
this._gasUsed = opts.gasUsed;
|
|
52
|
+
this.balances = opts.balances;
|
|
53
|
+
this.pool = opts.pool;
|
|
54
|
+
this.creditManager = opts.creditManager;
|
|
55
|
+
}
|
|
56
|
+
Path.prototype.getBestPath = function () {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
58
|
+
return __generator(this, function (_a) {
|
|
59
|
+
// const nextToken = Object.entries(this.balances).filter(([token, balance]) => balance.gt(1) ) //.sort((a,b) => {})
|
|
60
|
+
// if (nextToken.length ===1 ) {
|
|
61
|
+
// }
|
|
62
|
+
// Get balances and keep non-zero only
|
|
63
|
+
// Find token with highest priority
|
|
64
|
+
// Get token type of this token
|
|
65
|
+
// switch (type) {
|
|
66
|
+
// case TokenType.YearnValut:
|
|
67
|
+
// const assetPathClass = new Path(tokenData);
|
|
68
|
+
// return assetPathClass.getBestPath(this);
|
|
69
|
+
// ...
|
|
70
|
+
//}
|
|
71
|
+
throw new Error("Not implmented");
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
return Path;
|
|
76
|
+
}());
|
|
77
|
+
exports.Path = Path;
|
|
4
78
|
var ConnectorPathAsset = /** @class */ (function () {
|
|
5
79
|
function ConnectorPathAsset() {
|
|
6
80
|
}
|
|
7
81
|
ConnectorPathAsset.prototype.getBestPath = function (p) {
|
|
8
82
|
console.log(p);
|
|
9
|
-
// How to unwrap
|
|
83
|
+
// How to unwrap
|
|
10
84
|
// set balance of current token to 0
|
|
11
|
-
// add balnace what we get
|
|
85
|
+
// add balnace what we get
|
|
12
86
|
// add call
|
|
13
87
|
// create new Paths
|
|
88
|
+
// 3CRV:
|
|
89
|
+
// coinst balance3crv = p.balance["3rcv"];
|
|
90
|
+
// const p.balance["3rcv"] = 0;
|
|
91
|
+
// DAI
|
|
92
|
+
// const daiPath = {...p};
|
|
93
|
+
// const daiPath["Dai"] = await curve.getAmount(t balance3crv);
|
|
94
|
+
// const pathDai = new Path(daiPath)
|
|
95
|
+
// ...
|
|
96
|
+
// const bestPath = pathDai.balance[0] > pathUSDC.balance(0) ? pathDai : pathUsdc;
|
|
97
|
+
// --- DAI
|
|
98
|
+
// --|
|
|
99
|
+
// --- USDC
|
|
100
|
+
//
|
|
101
|
+
// NORMAL TOKEN
|
|
102
|
+
// ============
|
|
103
|
+
//
|
|
104
|
+
// - NORMAL -> POOL (1 pair) => #1
|
|
105
|
+
// for(let conn of connectors) {
|
|
106
|
+
// const result = getAmount([NORMAL, conn, pool])
|
|
107
|
+
// }
|
|
108
|
+
// => best Path to get max Pool tokens
|
|
109
|
+
// const resultInConnector = getAmount([NORMAL, conn]);
|
|
110
|
+
// calls.push("Uniswap.swap(NORMAL, conn)");
|
|
111
|
+
// CRV => CRV -> USDC -> DAI
|
|
112
|
+
// LINK => LINK -> USDC -> DAI
|
|
113
|
+
//
|
|
114
|
+
// [UniV2.swap("CRV", "USDC"),
|
|
115
|
+
// UniV3.swap("LINK", "USDC"),
|
|
116
|
+
// Curve.exchange("USDC", "DAI")]
|
|
117
|
+
//
|
|
118
|
+
// Below is not optimal:
|
|
119
|
+
// [ UniV2.swap("CRV -> USDC -> DAI"),
|
|
120
|
+
// UniV2.swap("LINK -> USDC -> DAI")]
|
|
121
|
+
//
|
|
122
|
+
//
|
|
123
|
+
// [ UniV2.swap("CRV -> USDC")
|
|
124
|
+
// UniV2.swap("USDC -> DAI"),
|
|
125
|
+
// UniV2.swap("LINK -> USDC"),
|
|
126
|
+
// UniV2.swap("USDC -> DAI") ]
|
|
14
127
|
// return maxValuable(new Paths.getBestPath())
|
|
15
128
|
throw new Error("Method not implemented.");
|
|
16
129
|
};
|
package/lib/core/token.d.ts
CHANGED
|
@@ -7,18 +7,10 @@ declare enum TokenType {
|
|
|
7
7
|
YEARN_VAULT = 4,
|
|
8
8
|
YEARN_VAULT_OF_CURVE_LP = 5,
|
|
9
9
|
YEARN_VAULT_OF_META_CURVE_LP = 6,
|
|
10
|
-
|
|
10
|
+
CONVEX_LP_TOKEN = 7,
|
|
11
|
+
CONVEX_STAKED_PHANTOM_TOKEN = 8
|
|
11
12
|
}
|
|
12
|
-
export declare const priority:
|
|
13
|
-
0: number;
|
|
14
|
-
1: number;
|
|
15
|
-
2: number;
|
|
16
|
-
4: number;
|
|
17
|
-
3: number;
|
|
18
|
-
5: number;
|
|
19
|
-
7: number;
|
|
20
|
-
6: number;
|
|
21
|
-
};
|
|
13
|
+
export declare const priority: Record<TokenType, number>;
|
|
22
14
|
export declare type TokenDataI = {
|
|
23
15
|
type: TokenType.CONNECTOR;
|
|
24
16
|
} | {
|
|
@@ -27,12 +19,13 @@ export declare type TokenDataI = {
|
|
|
27
19
|
type: TokenType.CURVE_LP;
|
|
28
20
|
} | {
|
|
29
21
|
type: TokenType.YEARN_VAULT;
|
|
22
|
+
underlying: SupportedTokens;
|
|
30
23
|
} | {
|
|
31
24
|
type: TokenType.META_CURVE_LP;
|
|
32
25
|
} | {
|
|
33
26
|
type: TokenType.YEARN_VAULT_OF_CURVE_LP;
|
|
34
27
|
} | {
|
|
35
|
-
type: TokenType.
|
|
28
|
+
type: TokenType.CONVEX_LP_TOKEN;
|
|
36
29
|
} | {
|
|
37
30
|
type: TokenType.YEARN_VAULT_OF_META_CURVE_LP;
|
|
38
31
|
};
|
package/lib/core/token.js
CHANGED
|
@@ -11,7 +11,8 @@ var TokenType;
|
|
|
11
11
|
TokenType[TokenType["YEARN_VAULT"] = 4] = "YEARN_VAULT";
|
|
12
12
|
TokenType[TokenType["YEARN_VAULT_OF_CURVE_LP"] = 5] = "YEARN_VAULT_OF_CURVE_LP";
|
|
13
13
|
TokenType[TokenType["YEARN_VAULT_OF_META_CURVE_LP"] = 6] = "YEARN_VAULT_OF_META_CURVE_LP";
|
|
14
|
-
TokenType[TokenType["
|
|
14
|
+
TokenType[TokenType["CONVEX_LP_TOKEN"] = 7] = "CONVEX_LP_TOKEN";
|
|
15
|
+
TokenType[TokenType["CONVEX_STAKED_PHANTOM_TOKEN"] = 8] = "CONVEX_STAKED_PHANTOM_TOKEN";
|
|
15
16
|
})(TokenType || (TokenType = {}));
|
|
16
17
|
exports.priority = (_a = {},
|
|
17
18
|
_a[TokenType.CONNECTOR] = 1,
|
|
@@ -20,8 +21,9 @@ exports.priority = (_a = {},
|
|
|
20
21
|
_a[TokenType.YEARN_VAULT] = 3,
|
|
21
22
|
_a[TokenType.META_CURVE_LP] = 4,
|
|
22
23
|
_a[TokenType.YEARN_VAULT_OF_CURVE_LP] = 4,
|
|
23
|
-
_a[TokenType.
|
|
24
|
+
_a[TokenType.CONVEX_LP_TOKEN] = 5,
|
|
24
25
|
_a[TokenType.YEARN_VAULT_OF_META_CURVE_LP] = 5,
|
|
26
|
+
_a[TokenType.CONVEX_STAKED_PHANTOM_TOKEN] = 5,
|
|
25
27
|
_a);
|
|
26
28
|
exports.supportedTokens = {
|
|
27
29
|
"1INCH": {
|
|
@@ -111,16 +113,20 @@ exports.supportedTokens = {
|
|
|
111
113
|
},
|
|
112
114
|
// YEARN TOKENS
|
|
113
115
|
yvDAI: {
|
|
114
|
-
type: TokenType.YEARN_VAULT
|
|
116
|
+
type: TokenType.YEARN_VAULT,
|
|
117
|
+
underlying: "DAI",
|
|
115
118
|
},
|
|
116
119
|
yvUSDC: {
|
|
117
|
-
type: TokenType.YEARN_VAULT
|
|
120
|
+
type: TokenType.YEARN_VAULT,
|
|
121
|
+
underlying: "USDC"
|
|
118
122
|
},
|
|
119
123
|
yvWETH: {
|
|
120
|
-
type: TokenType.YEARN_VAULT
|
|
124
|
+
type: TokenType.YEARN_VAULT,
|
|
125
|
+
underlying: "WETH",
|
|
121
126
|
},
|
|
122
127
|
yvWBTC: {
|
|
123
|
-
type: TokenType.YEARN_VAULT
|
|
128
|
+
type: TokenType.YEARN_VAULT,
|
|
129
|
+
underlying: "WBTC"
|
|
124
130
|
},
|
|
125
131
|
// CURVE LP TOKENS
|
|
126
132
|
"3Crv": {
|
|
@@ -144,19 +150,19 @@ exports.supportedTokens = {
|
|
|
144
150
|
},
|
|
145
151
|
// CONVEX LP TOKENS
|
|
146
152
|
cvx3Crv: {
|
|
147
|
-
type: TokenType.
|
|
153
|
+
type: TokenType.CONVEX_LP_TOKEN
|
|
148
154
|
},
|
|
149
155
|
cvxsteCRV: {
|
|
150
|
-
type: TokenType.
|
|
156
|
+
type: TokenType.CONVEX_LP_TOKEN
|
|
151
157
|
},
|
|
152
158
|
cvxFRAX3CRV: {
|
|
153
|
-
type: TokenType.
|
|
159
|
+
type: TokenType.CONVEX_LP_TOKEN
|
|
154
160
|
},
|
|
155
161
|
cvxcrvPlain3andSUSD: {
|
|
156
|
-
type: TokenType.
|
|
162
|
+
type: TokenType.CONVEX_LP_TOKEN
|
|
157
163
|
},
|
|
158
164
|
cvxgusd3CRV: {
|
|
159
|
-
type: TokenType.
|
|
165
|
+
type: TokenType.CONVEX_LP_TOKEN
|
|
160
166
|
},
|
|
161
167
|
// YEARN- CURVE TOKENS
|
|
162
168
|
yvCurve_stETH: {
|
|
@@ -217,6 +223,8 @@ exports.tokenDataByNetwork = {
|
|
|
217
223
|
cvxFRAX3CRV: "0xbE0F6478E0E4894CFb14f32855603A083A57c7dA",
|
|
218
224
|
cvxcrvPlain3andSUSD: "0x11D200ef1409cecA8D6d23e6496550f707772F11",
|
|
219
225
|
cvxgusd3CRV: "0x15c2471ef46Fa721990730cfa526BcFb45574576",
|
|
226
|
+
// CONVEX PHANTOM TOKEN ADDRESSES
|
|
227
|
+
// <Provide them here>
|
|
220
228
|
// YEARN- CURVE TOKENS
|
|
221
229
|
yvCurve_stETH: "0xdCD90C7f6324cfa40d7169ef80b12031770B4325",
|
|
222
230
|
yvCurve_FRAX: "0xB4AdA607B9d6b2c9Ee07A275e9616B84AC560139"
|
package/package.json
CHANGED
package/src/core/pathfinder.ts
CHANGED
|
@@ -3,24 +3,54 @@ import { CreditManagerData } from "./creditManager";
|
|
|
3
3
|
import { MultiCall } from "./multicall";
|
|
4
4
|
import { SupportedTokens } from "./token";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
6
|
+
// const path = new Path({gasUsed:0, balances: creditAccount.balances, })
|
|
7
|
+
// const closurePath = await path.getBestPath();
|
|
8
|
+
// closurePath.calls -> multicalls (!)
|
|
9
|
+
// closurePath.balances[path.pool] = (X)
|
|
10
|
+
// closurePath.balances[!path.pool] = 0 / 1;
|
|
11
|
+
|
|
12
|
+
//
|
|
13
|
+
// [0,0,0, 100]
|
|
14
|
+
// [ 12, 12, 12, 0]
|
|
15
|
+
|
|
16
|
+
export class Path {
|
|
17
|
+
public readonly calls: Array<MultiCall> = [];
|
|
18
|
+
public readonly balances: Record<SupportedTokens, BigNumber>;
|
|
19
|
+
// usedTokens: Array<SupportedTokens>;
|
|
20
|
+
protected _gasUsed: number;
|
|
21
|
+
public readonly pool: SupportedTokens;
|
|
22
|
+
public readonly creditManager: CreditManagerData;
|
|
23
|
+
|
|
24
|
+
constructor(opts: {
|
|
25
|
+
gasUsed: number;
|
|
26
|
+
balances: Record<SupportedTokens, BigNumber>;
|
|
27
|
+
pool: SupportedTokens;
|
|
28
|
+
creditManager: CreditManagerData;
|
|
29
|
+
}) {
|
|
30
|
+
this._gasUsed = opts.gasUsed;
|
|
31
|
+
this.balances = opts.balances;
|
|
32
|
+
this.pool = opts.pool;
|
|
33
|
+
this.creditManager = opts.creditManager;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async getBestPath(): Promise<Path> {
|
|
37
|
+
// const nextToken = Object.entries(this.balances).filter(([token, balance]) => balance.gt(1) ) //.sort((a,b) => {})
|
|
38
|
+
// if (nextToken.length ===1 ) {
|
|
39
|
+
|
|
40
|
+
// }
|
|
41
|
+
|
|
42
|
+
// Get balances and keep non-zero only
|
|
43
|
+
// Find token with highest priority
|
|
44
|
+
// Get token type of this token
|
|
45
|
+
// switch (type) {
|
|
46
|
+
// case TokenType.YearnValut:
|
|
47
|
+
// const assetPathClass = new Path(tokenData);
|
|
48
|
+
// return assetPathClass.getBestPath(this);
|
|
49
|
+
// ...
|
|
50
|
+
|
|
51
|
+
//}
|
|
52
|
+
throw new Error("Not implmented");
|
|
53
|
+
}
|
|
24
54
|
}
|
|
25
55
|
|
|
26
56
|
export interface PathAsset {
|
|
@@ -30,11 +60,55 @@ export interface PathAsset {
|
|
|
30
60
|
export class ConnectorPathAsset implements PathAsset {
|
|
31
61
|
getBestPath(p: Path): Promise<Path> {
|
|
32
62
|
console.log(p);
|
|
33
|
-
// How to unwrap
|
|
63
|
+
// How to unwrap
|
|
34
64
|
// set balance of current token to 0
|
|
35
|
-
// add balnace what we get
|
|
65
|
+
// add balnace what we get
|
|
36
66
|
// add call
|
|
37
67
|
// create new Paths
|
|
68
|
+
|
|
69
|
+
// 3CRV:
|
|
70
|
+
// coinst balance3crv = p.balance["3rcv"];
|
|
71
|
+
// const p.balance["3rcv"] = 0;
|
|
72
|
+
// DAI
|
|
73
|
+
// const daiPath = {...p};
|
|
74
|
+
// const daiPath["Dai"] = await curve.getAmount(t balance3crv);
|
|
75
|
+
|
|
76
|
+
// const pathDai = new Path(daiPath)
|
|
77
|
+
// ...
|
|
78
|
+
// const bestPath = pathDai.balance[0] > pathUSDC.balance(0) ? pathDai : pathUsdc;
|
|
79
|
+
|
|
80
|
+
// --- DAI
|
|
81
|
+
// --|
|
|
82
|
+
// --- USDC
|
|
83
|
+
//
|
|
84
|
+
// NORMAL TOKEN
|
|
85
|
+
// ============
|
|
86
|
+
//
|
|
87
|
+
// - NORMAL -> POOL (1 pair) => #1
|
|
88
|
+
// for(let conn of connectors) {
|
|
89
|
+
// const result = getAmount([NORMAL, conn, pool])
|
|
90
|
+
// }
|
|
91
|
+
// => best Path to get max Pool tokens
|
|
92
|
+
// const resultInConnector = getAmount([NORMAL, conn]);
|
|
93
|
+
// calls.push("Uniswap.swap(NORMAL, conn)");
|
|
94
|
+
|
|
95
|
+
// CRV => CRV -> USDC -> DAI
|
|
96
|
+
// LINK => LINK -> USDC -> DAI
|
|
97
|
+
//
|
|
98
|
+
// [UniV2.swap("CRV", "USDC"),
|
|
99
|
+
// UniV3.swap("LINK", "USDC"),
|
|
100
|
+
// Curve.exchange("USDC", "DAI")]
|
|
101
|
+
//
|
|
102
|
+
// Below is not optimal:
|
|
103
|
+
// [ UniV2.swap("CRV -> USDC -> DAI"),
|
|
104
|
+
// UniV2.swap("LINK -> USDC -> DAI")]
|
|
105
|
+
//
|
|
106
|
+
//
|
|
107
|
+
// [ UniV2.swap("CRV -> USDC")
|
|
108
|
+
// UniV2.swap("USDC -> DAI"),
|
|
109
|
+
// UniV2.swap("LINK -> USDC"),
|
|
110
|
+
// UniV2.swap("USDC -> DAI") ]
|
|
111
|
+
|
|
38
112
|
// return maxValuable(new Paths.getBestPath())
|
|
39
113
|
throw new Error("Method not implemented.");
|
|
40
114
|
}
|
package/src/core/token.ts
CHANGED
|
@@ -8,18 +8,20 @@ enum TokenType {
|
|
|
8
8
|
YEARN_VAULT,
|
|
9
9
|
YEARN_VAULT_OF_CURVE_LP,
|
|
10
10
|
YEARN_VAULT_OF_META_CURVE_LP,
|
|
11
|
-
|
|
11
|
+
CONVEX_LP_TOKEN,
|
|
12
|
+
CONVEX_STAKED_PHANTOM_TOKEN,
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
export const priority = {
|
|
15
|
+
export const priority : Record<TokenType, number> = {
|
|
15
16
|
[TokenType.CONNECTOR]: 1,
|
|
16
17
|
[TokenType.NORMAL_TOKEN]: 2,
|
|
17
18
|
[TokenType.CURVE_LP]: 3,
|
|
18
19
|
[TokenType.YEARN_VAULT]: 3,
|
|
19
20
|
[TokenType.META_CURVE_LP]: 4,
|
|
20
21
|
[TokenType.YEARN_VAULT_OF_CURVE_LP]: 4,
|
|
21
|
-
[TokenType.
|
|
22
|
-
[TokenType.YEARN_VAULT_OF_META_CURVE_LP]: 5
|
|
22
|
+
[TokenType.CONVEX_LP_TOKEN]: 5,
|
|
23
|
+
[TokenType.YEARN_VAULT_OF_META_CURVE_LP]: 5,
|
|
24
|
+
[TokenType.CONVEX_STAKED_PHANTOM_TOKEN]: 5
|
|
23
25
|
};
|
|
24
26
|
|
|
25
27
|
export type TokenDataI =
|
|
@@ -34,6 +36,7 @@ export type TokenDataI =
|
|
|
34
36
|
}
|
|
35
37
|
| {
|
|
36
38
|
type: TokenType.YEARN_VAULT;
|
|
39
|
+
underlying: SupportedTokens,
|
|
37
40
|
}
|
|
38
41
|
| {
|
|
39
42
|
type: TokenType.META_CURVE_LP;
|
|
@@ -42,7 +45,7 @@ export type TokenDataI =
|
|
|
42
45
|
type: TokenType.YEARN_VAULT_OF_CURVE_LP;
|
|
43
46
|
}
|
|
44
47
|
| {
|
|
45
|
-
type: TokenType.
|
|
48
|
+
type: TokenType.CONVEX_LP_TOKEN;
|
|
46
49
|
}
|
|
47
50
|
| {
|
|
48
51
|
type: TokenType.YEARN_VAULT_OF_META_CURVE_LP;
|
|
@@ -220,19 +223,23 @@ export const supportedTokens: Record<SupportedTokens, TokenDataI> = {
|
|
|
220
223
|
|
|
221
224
|
// YEARN TOKENS
|
|
222
225
|
yvDAI: {
|
|
223
|
-
type: TokenType.YEARN_VAULT
|
|
226
|
+
type: TokenType.YEARN_VAULT,
|
|
227
|
+
underlying: "DAI",
|
|
224
228
|
},
|
|
225
229
|
|
|
226
230
|
yvUSDC: {
|
|
227
|
-
type: TokenType.YEARN_VAULT
|
|
231
|
+
type: TokenType.YEARN_VAULT,
|
|
232
|
+
underlying: "USDC"
|
|
228
233
|
},
|
|
229
234
|
|
|
230
235
|
yvWETH: {
|
|
231
|
-
type: TokenType.YEARN_VAULT
|
|
236
|
+
type: TokenType.YEARN_VAULT,
|
|
237
|
+
underlying: "WETH",
|
|
232
238
|
},
|
|
233
239
|
|
|
234
240
|
yvWBTC: {
|
|
235
|
-
type: TokenType.YEARN_VAULT
|
|
241
|
+
type: TokenType.YEARN_VAULT,
|
|
242
|
+
underlying: "WBTC"
|
|
236
243
|
},
|
|
237
244
|
|
|
238
245
|
// CURVE LP TOKENS
|
|
@@ -266,23 +273,23 @@ export const supportedTokens: Record<SupportedTokens, TokenDataI> = {
|
|
|
266
273
|
// CONVEX LP TOKENS
|
|
267
274
|
|
|
268
275
|
cvx3Crv: {
|
|
269
|
-
type: TokenType.
|
|
276
|
+
type: TokenType.CONVEX_LP_TOKEN
|
|
270
277
|
},
|
|
271
278
|
|
|
272
279
|
cvxsteCRV: {
|
|
273
|
-
type: TokenType.
|
|
280
|
+
type: TokenType.CONVEX_LP_TOKEN
|
|
274
281
|
},
|
|
275
282
|
|
|
276
283
|
cvxFRAX3CRV: {
|
|
277
|
-
type: TokenType.
|
|
284
|
+
type: TokenType.CONVEX_LP_TOKEN
|
|
278
285
|
},
|
|
279
286
|
|
|
280
287
|
cvxcrvPlain3andSUSD: {
|
|
281
|
-
type: TokenType.
|
|
288
|
+
type: TokenType.CONVEX_LP_TOKEN
|
|
282
289
|
},
|
|
283
290
|
|
|
284
291
|
cvxgusd3CRV: {
|
|
285
|
-
type: TokenType.
|
|
292
|
+
type: TokenType.CONVEX_LP_TOKEN
|
|
286
293
|
},
|
|
287
294
|
|
|
288
295
|
// YEARN- CURVE TOKENS
|
|
@@ -353,6 +360,9 @@ export const tokenDataByNetwork: Record<
|
|
|
353
360
|
cvxcrvPlain3andSUSD: "0x11D200ef1409cecA8D6d23e6496550f707772F11",
|
|
354
361
|
cvxgusd3CRV: "0x15c2471ef46Fa721990730cfa526BcFb45574576",
|
|
355
362
|
|
|
363
|
+
// CONVEX PHANTOM TOKEN ADDRESSES
|
|
364
|
+
// <Provide them here>
|
|
365
|
+
|
|
356
366
|
// YEARN- CURVE TOKENS
|
|
357
367
|
yvCurve_stETH: "0xdCD90C7f6324cfa40d7169ef80b12031770B4325",
|
|
358
368
|
yvCurve_FRAX: "0xB4AdA607B9d6b2c9Ee07A275e9616B84AC560139"
|