@gearbox-protocol/sdk 0.0.103 → 0.0.104
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/.eslintignore +1 -0
- package/lib/contracts/contracts.d.ts +6 -3
- package/lib/contracts/contracts.js +17 -16
- package/lib/index.d.ts +7 -0
- package/lib/index.js +7 -0
- package/lib/strategies/convex.d.ts +12 -0
- package/lib/strategies/convex.js +74 -1
- package/lib/strategies/creditFacade.d.ts +1 -0
- package/lib/strategies/creditFacade.js +3 -0
- package/lib/strategies/curve.d.ts +9 -0
- package/lib/strategies/curve.js +68 -1
- package/lib/strategies/lido.d.ts +6 -0
- package/lib/strategies/lido.js +23 -1
- package/lib/strategies/uniswapV2.d.ts +1 -0
- package/lib/strategies/uniswapV2.js +3 -0
- package/lib/strategies/uniswapV3.d.ts +1 -0
- package/lib/strategies/uniswapV3.js +3 -0
- package/lib/strategies/yearn.d.ts +8 -0
- package/lib/strategies/yearn.js +77 -1
- package/lib/tokens/curveLP.d.ts +5 -0
- package/lib/tokens/curveLP.js +7 -0
- package/lib/tokens/yearn.d.ts +5 -1
- package/lib/tokens/yearn.js +6 -0
- package/package.json +2 -3
- package/src/contracts/contracts.ts +23 -14
- package/src/index.ts +9 -0
- package/src/strategies/convex.ts +167 -0
- package/src/strategies/creditFacade.ts +4 -0
- package/src/strategies/curve.ts +142 -0
- package/src/strategies/lido.ts +42 -0
- package/src/strategies/uniswapV2.ts +4 -0
- package/src/strategies/uniswapV3.ts +4 -0
- package/src/strategies/yearn.ts +131 -0
- package/src/tokens/curveLP.ts +12 -6
- package/src/tokens/yearn.ts +11 -7
package/.eslintignore
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import type { YearnLPToken } from "src/tokens/yearn";
|
|
1
2
|
import { AdapterInterface } from "./adapters";
|
|
2
3
|
import { NetworkType } from "../core/constants";
|
|
3
4
|
import { Protocols } from "./protocols";
|
|
4
|
-
import
|
|
5
|
+
import { ConvexStakedPhantomToken } from "../tokens/convex";
|
|
5
6
|
import type { CurveLPToken } from "../tokens/curveLP";
|
|
6
|
-
import
|
|
7
|
+
import { NormalToken } from "../tokens/normal";
|
|
7
8
|
export declare type UniswapV2Contract = "UNISWAP_V2_ROUTER" | "SUSHISWAP_ROUTER";
|
|
8
9
|
export declare type CurvePoolContract = "CURVE_3CRV_POOL" | "CURVE_STETH_GATEWAY" | "CURVE_FRAX_POOL" | "CURVE_LUSD_POOL" | "CURVE_GUSD_POOL" | "CURVE_SUSD_POOL" | "CURVE_SUSD_DEPOSIT";
|
|
9
10
|
export declare type YearnVaultContract = "YEARN_DAI_VAULT" | "YEARN_USDC_VAULT" | "YEARN_WETH_VAULT" | "YEARN_WBTC_VAULT" | "YEARN_CURVE_FRAX_VAULT" | "YEARN_CURVE_STETH_VAULT";
|
|
@@ -34,11 +35,13 @@ export declare type CurveSteCRVPoolParams = {
|
|
|
34
35
|
protocol: Protocols.Curve;
|
|
35
36
|
type: AdapterInterface.CURVE_V1_STECRV_POOL;
|
|
36
37
|
pool: Record<NetworkType, string>;
|
|
38
|
+
tokens: ["WETH", "STETH"];
|
|
37
39
|
lpToken: "steCRV";
|
|
38
40
|
} & BaseContractParams;
|
|
39
|
-
declare type YearnParams = {
|
|
41
|
+
export declare type YearnParams = {
|
|
40
42
|
protocol: Protocols.Yearn;
|
|
41
43
|
type: AdapterInterface.YEARN_V2;
|
|
44
|
+
shareToken: YearnLPToken;
|
|
42
45
|
} & BaseContractParams;
|
|
43
46
|
declare type ConvexParams = {
|
|
44
47
|
protocol: Protocols.Convex;
|
|
@@ -12,11 +12,6 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.contractsByAddress = exports.contractParams = exports.UNISWAP_V3_QUOTER = exports.contractsByNetwork = void 0;
|
|
15
|
-
/*
|
|
16
|
-
* SPDX-License-Identifier: BSL-1.1
|
|
17
|
-
* Gearbox. Generalized leverage protocol, which allows to take leverage and then use it across other DeFi protocols and platforms in a composable way.
|
|
18
|
-
* (c) Gearbox.fi, 2021
|
|
19
|
-
*/
|
|
20
15
|
var mappers_1 = require("../utils/mappers");
|
|
21
16
|
var adapters_1 = require("./adapters");
|
|
22
17
|
var protocols_1 = require("./protocols");
|
|
@@ -123,6 +118,7 @@ exports.contractParams = {
|
|
|
123
118
|
Mainnet: "0xDC24316b9AE028F1497c275EB9192a3Ea0f67022",
|
|
124
119
|
Kovan: "0xF5C73b58B70709e89aA1D322d48b0D0C71123cB4"
|
|
125
120
|
},
|
|
121
|
+
tokens: ["WETH", "STETH"],
|
|
126
122
|
lpToken: "steCRV"
|
|
127
123
|
},
|
|
128
124
|
CURVE_FRAX_POOL: {
|
|
@@ -130,14 +126,14 @@ exports.contractParams = {
|
|
|
130
126
|
protocol: protocols_1.Protocols.Curve,
|
|
131
127
|
type: adapters_1.AdapterInterface.CURVE_V1_2ASSETS,
|
|
132
128
|
lpToken: "FRAX3CRV",
|
|
133
|
-
tokens: ["
|
|
129
|
+
tokens: ["FRAX", "3Crv"]
|
|
134
130
|
},
|
|
135
131
|
CURVE_LUSD_POOL: {
|
|
136
132
|
name: "Curve LUSD",
|
|
137
133
|
protocol: protocols_1.Protocols.Curve,
|
|
138
134
|
type: adapters_1.AdapterInterface.CURVE_V1_2ASSETS,
|
|
139
135
|
lpToken: "LUSD3CRV",
|
|
140
|
-
tokens: ["
|
|
136
|
+
tokens: ["LUSD", "3Crv"]
|
|
141
137
|
},
|
|
142
138
|
CURVE_SUSD_POOL: {
|
|
143
139
|
name: "Curve SUSD",
|
|
@@ -152,45 +148,50 @@ exports.contractParams = {
|
|
|
152
148
|
protocol: protocols_1.Protocols.Curve,
|
|
153
149
|
type: adapters_1.AdapterInterface.CURVE_V1_WRAPPER,
|
|
154
150
|
lpToken: "crvPlain3andSUSD",
|
|
155
|
-
tokens: ["DAI", "USDC", "USDT", "sUSD"]
|
|
156
|
-
wrapper: "CURVE_SUSD_DEPOSIT"
|
|
151
|
+
tokens: ["DAI", "USDC", "USDT", "sUSD"]
|
|
157
152
|
},
|
|
158
153
|
CURVE_GUSD_POOL: {
|
|
159
154
|
name: "Curve GUSD",
|
|
160
155
|
protocol: protocols_1.Protocols.Curve,
|
|
161
156
|
type: adapters_1.AdapterInterface.CURVE_V1_2ASSETS,
|
|
162
157
|
lpToken: "gusd3CRV",
|
|
163
|
-
tokens: ["
|
|
158
|
+
tokens: ["GUSD", "3Crv"]
|
|
164
159
|
},
|
|
165
160
|
YEARN_DAI_VAULT: {
|
|
166
161
|
name: "Yearn DAI",
|
|
167
162
|
protocol: protocols_1.Protocols.Yearn,
|
|
168
|
-
type: adapters_1.AdapterInterface.YEARN_V2
|
|
163
|
+
type: adapters_1.AdapterInterface.YEARN_V2,
|
|
164
|
+
shareToken: "yvDAI"
|
|
169
165
|
},
|
|
170
166
|
YEARN_USDC_VAULT: {
|
|
171
167
|
name: "Yearn USDC",
|
|
172
168
|
protocol: protocols_1.Protocols.Yearn,
|
|
173
|
-
type: adapters_1.AdapterInterface.YEARN_V2
|
|
169
|
+
type: adapters_1.AdapterInterface.YEARN_V2,
|
|
170
|
+
shareToken: "yvUSDC"
|
|
174
171
|
},
|
|
175
172
|
YEARN_WETH_VAULT: {
|
|
176
173
|
name: "Yearn WETH",
|
|
177
174
|
protocol: protocols_1.Protocols.Yearn,
|
|
178
|
-
type: adapters_1.AdapterInterface.YEARN_V2
|
|
175
|
+
type: adapters_1.AdapterInterface.YEARN_V2,
|
|
176
|
+
shareToken: "yvWETH"
|
|
179
177
|
},
|
|
180
178
|
YEARN_WBTC_VAULT: {
|
|
181
179
|
name: "Yearn WBTC",
|
|
182
180
|
protocol: protocols_1.Protocols.Yearn,
|
|
183
|
-
type: adapters_1.AdapterInterface.YEARN_V2
|
|
181
|
+
type: adapters_1.AdapterInterface.YEARN_V2,
|
|
182
|
+
shareToken: "yvWBTC"
|
|
184
183
|
},
|
|
185
184
|
YEARN_CURVE_FRAX_VAULT: {
|
|
186
185
|
name: "Yearn Curve FRAX",
|
|
187
186
|
protocol: protocols_1.Protocols.Yearn,
|
|
188
|
-
type: adapters_1.AdapterInterface.YEARN_V2
|
|
187
|
+
type: adapters_1.AdapterInterface.YEARN_V2,
|
|
188
|
+
shareToken: "yvCurve_FRAX"
|
|
189
189
|
},
|
|
190
190
|
YEARN_CURVE_STETH_VAULT: {
|
|
191
191
|
name: "Yearn Curve STETH",
|
|
192
192
|
protocol: protocols_1.Protocols.Yearn,
|
|
193
|
-
type: adapters_1.AdapterInterface.YEARN_V2
|
|
193
|
+
type: adapters_1.AdapterInterface.YEARN_V2,
|
|
194
|
+
shareToken: "yvCurve_stETH"
|
|
194
195
|
},
|
|
195
196
|
CONVEX_BOOSTER: {
|
|
196
197
|
name: "Convex BOOSTER",
|
package/lib/index.d.ts
CHANGED
|
@@ -42,6 +42,13 @@ export * from "./core/history";
|
|
|
42
42
|
export * from "./utils/multicall";
|
|
43
43
|
export * from "./utils/types";
|
|
44
44
|
export * from "./utils/errors";
|
|
45
|
+
export * from "./strategies/convex";
|
|
46
|
+
export * from "./strategies/creditFacade";
|
|
47
|
+
export * from "./strategies/curve";
|
|
48
|
+
export * from "./strategies/lido";
|
|
49
|
+
export * from "./strategies/uniswapV2";
|
|
50
|
+
export * from "./strategies/uniswapV3";
|
|
51
|
+
export * from "./strategies/yearn";
|
|
45
52
|
export { callRepeater } from "./utils/repeater";
|
|
46
53
|
export { getContractName } from "./contracts/contractsRegister";
|
|
47
54
|
export { AdapterInterface } from "./contracts/adapters";
|
package/lib/index.js
CHANGED
|
@@ -61,6 +61,13 @@ __exportStar(require("./core/history"), exports);
|
|
|
61
61
|
__exportStar(require("./utils/multicall"), exports);
|
|
62
62
|
__exportStar(require("./utils/types"), exports);
|
|
63
63
|
__exportStar(require("./utils/errors"), exports);
|
|
64
|
+
__exportStar(require("./strategies/convex"), exports);
|
|
65
|
+
__exportStar(require("./strategies/creditFacade"), exports);
|
|
66
|
+
__exportStar(require("./strategies/curve"), exports);
|
|
67
|
+
__exportStar(require("./strategies/lido"), exports);
|
|
68
|
+
__exportStar(require("./strategies/uniswapV2"), exports);
|
|
69
|
+
__exportStar(require("./strategies/uniswapV3"), exports);
|
|
70
|
+
__exportStar(require("./strategies/yearn"), exports);
|
|
64
71
|
var repeater_1 = require("./utils/repeater");
|
|
65
72
|
Object.defineProperty(exports, "callRepeater", { enumerable: true, get: function () { return repeater_1.callRepeater; } });
|
|
66
73
|
var contractsRegister_1 = require("./contracts/contractsRegister");
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { BigNumberish } from "ethers";
|
|
2
|
+
import { ConvexPoolContract } from "src/contracts/contracts";
|
|
3
|
+
import { NetworkType } from "src/core/constants";
|
|
4
|
+
import { CreditManagerData } from "src/core/creditManager";
|
|
2
5
|
import { MultiCallStruct } from "../types/contracts/interfaces/ICreditFacade.sol/ICreditFacade";
|
|
3
6
|
export declare class ConvexBoosterCalls {
|
|
4
7
|
static deposit(pid: BigNumberish, amount: BigNumberish, stake: boolean): string;
|
|
@@ -20,6 +23,7 @@ export declare class ConvexClaimZapCalls {
|
|
|
20
23
|
export declare class ConvexBoosterMulticaller {
|
|
21
24
|
private readonly _address;
|
|
22
25
|
constructor(address: string);
|
|
26
|
+
static connect(address: string): ConvexBoosterMulticaller;
|
|
23
27
|
deposit(pid: BigNumberish, amount: BigNumberish, stake: boolean): MultiCallStruct;
|
|
24
28
|
depositAll(pid: BigNumberish, stake: boolean): MultiCallStruct;
|
|
25
29
|
withdraw(pid: BigNumberish, amount: BigNumberish): MultiCallStruct;
|
|
@@ -28,6 +32,7 @@ export declare class ConvexBoosterMulticaller {
|
|
|
28
32
|
export declare class ConvexPoolMulticaller {
|
|
29
33
|
private readonly _address;
|
|
30
34
|
constructor(address: string);
|
|
35
|
+
static connect(address: string): ConvexPoolMulticaller;
|
|
31
36
|
stake(amount: BigNumberish): MultiCallStruct;
|
|
32
37
|
stakeAll(): MultiCallStruct;
|
|
33
38
|
withdraw(amount: BigNumberish, claim: boolean): MultiCallStruct;
|
|
@@ -41,5 +46,12 @@ export declare class ConvexPoolMulticaller {
|
|
|
41
46
|
export declare class ConvexClaimZapMulticaller {
|
|
42
47
|
private readonly _address;
|
|
43
48
|
constructor(address: string);
|
|
49
|
+
static connect(address: string): ConvexClaimZapMulticaller;
|
|
44
50
|
claimRewards(rewardContracts: Array<string>, extraRewardContracts: Array<string>, tokenRewardContracts: Array<string>, tokenRewardTokens: Array<string>, depositCrvMaxAmount: BigNumberish, minAmountOut: BigNumberish, depositCvxMaxAmount: BigNumberish, spendCvxAmount: BigNumberish, options: BigNumberish): MultiCallStruct;
|
|
45
51
|
}
|
|
52
|
+
export declare class ConvexStrategies {
|
|
53
|
+
static underlyingToStakedConvex(data: CreditManagerData, network: NetworkType, convexPool: ConvexPoolContract, underlyingAmount: BigNumberish): MultiCallStruct[];
|
|
54
|
+
static stakedConvexToUnderlying(data: CreditManagerData, network: NetworkType, convexPool: ConvexPoolContract, convexLpAmount: BigNumberish, sellRewards: boolean): MultiCallStruct[];
|
|
55
|
+
static allStakedConvexToUnderlying(data: CreditManagerData, network: NetworkType, convexPool: ConvexPoolContract, sellRewards: boolean): MultiCallStruct[];
|
|
56
|
+
static sellRewards(data: CreditManagerData, network: NetworkType, convexPool: ConvexPoolContract): MultiCallStruct[];
|
|
57
|
+
}
|
package/lib/strategies/convex.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConvexClaimZapMulticaller = exports.ConvexPoolMulticaller = exports.ConvexBoosterMulticaller = exports.ConvexClaimZapCalls = exports.ConvexPoolCalls = exports.ConvexBoosterCalls = void 0;
|
|
3
|
+
exports.ConvexStrategies = exports.ConvexClaimZapMulticaller = exports.ConvexPoolMulticaller = exports.ConvexBoosterMulticaller = exports.ConvexClaimZapCalls = exports.ConvexPoolCalls = exports.ConvexBoosterCalls = void 0;
|
|
4
|
+
var contracts_1 = require("src/contracts/contracts");
|
|
5
|
+
var token_1 = require("src/tokens/token");
|
|
4
6
|
var types_1 = require("../types");
|
|
7
|
+
var curve_1 = require("./curve");
|
|
8
|
+
var uniswapV2_1 = require("./uniswapV2");
|
|
5
9
|
var ConvexBoosterCalls = /** @class */ (function () {
|
|
6
10
|
function ConvexBoosterCalls() {
|
|
7
11
|
}
|
|
@@ -67,6 +71,9 @@ var ConvexBoosterMulticaller = /** @class */ (function () {
|
|
|
67
71
|
function ConvexBoosterMulticaller(address) {
|
|
68
72
|
this._address = address;
|
|
69
73
|
}
|
|
74
|
+
ConvexBoosterMulticaller.connect = function (address) {
|
|
75
|
+
return new ConvexBoosterMulticaller(address);
|
|
76
|
+
};
|
|
70
77
|
ConvexBoosterMulticaller.prototype.deposit = function (pid, amount, stake) {
|
|
71
78
|
return {
|
|
72
79
|
target: this._address,
|
|
@@ -98,6 +105,9 @@ var ConvexPoolMulticaller = /** @class */ (function () {
|
|
|
98
105
|
function ConvexPoolMulticaller(address) {
|
|
99
106
|
this._address = address;
|
|
100
107
|
}
|
|
108
|
+
ConvexPoolMulticaller.connect = function (address) {
|
|
109
|
+
return new ConvexPoolMulticaller(address);
|
|
110
|
+
};
|
|
101
111
|
ConvexPoolMulticaller.prototype.stake = function (amount) {
|
|
102
112
|
return {
|
|
103
113
|
target: this._address,
|
|
@@ -141,6 +151,9 @@ var ConvexClaimZapMulticaller = /** @class */ (function () {
|
|
|
141
151
|
function ConvexClaimZapMulticaller(address) {
|
|
142
152
|
this._address = address;
|
|
143
153
|
}
|
|
154
|
+
ConvexClaimZapMulticaller.connect = function (address) {
|
|
155
|
+
return new ConvexClaimZapMulticaller(address);
|
|
156
|
+
};
|
|
144
157
|
ConvexClaimZapMulticaller.prototype.claimRewards = function (rewardContracts, extraRewardContracts, tokenRewardContracts, tokenRewardTokens, depositCrvMaxAmount, minAmountOut, depositCvxMaxAmount, spendCvxAmount, options) {
|
|
145
158
|
return {
|
|
146
159
|
target: this._address,
|
|
@@ -150,3 +163,63 @@ var ConvexClaimZapMulticaller = /** @class */ (function () {
|
|
|
150
163
|
return ConvexClaimZapMulticaller;
|
|
151
164
|
}());
|
|
152
165
|
exports.ConvexClaimZapMulticaller = ConvexClaimZapMulticaller;
|
|
166
|
+
var ConvexStrategies = /** @class */ (function () {
|
|
167
|
+
function ConvexStrategies() {
|
|
168
|
+
}
|
|
169
|
+
ConvexStrategies.underlyingToStakedConvex = function (data, network, convexPool, underlyingAmount) {
|
|
170
|
+
var calls = [];
|
|
171
|
+
var convexParams = contracts_1.contractParams[convexPool];
|
|
172
|
+
var stakedToken = convexParams.stakedToken;
|
|
173
|
+
var stakedTokenParams = token_1.supportedTokens[stakedToken];
|
|
174
|
+
var curveLpToken = stakedTokenParams.underlying;
|
|
175
|
+
var curveLpTokenData = token_1.supportedTokens[curveLpToken];
|
|
176
|
+
var curvePool = curveLpTokenData.pool;
|
|
177
|
+
calls = curve_1.CurveStrategies.underlyingToCurveLP(data, network, curvePool, underlyingAmount);
|
|
178
|
+
calls.push(ConvexBoosterMulticaller.connect(data.adapters[contracts_1.contractsByNetwork[network].CONVEX_BOOSTER]).depositAll(stakedTokenParams.pid, true));
|
|
179
|
+
return calls;
|
|
180
|
+
};
|
|
181
|
+
ConvexStrategies.stakedConvexToUnderlying = function (data, network, convexPool, convexLpAmount, sellRewards) {
|
|
182
|
+
var calls = [];
|
|
183
|
+
var convexParams = contracts_1.contractParams[convexPool];
|
|
184
|
+
var stakedToken = convexParams.stakedToken;
|
|
185
|
+
var stakedTokenParams = token_1.supportedTokens[stakedToken];
|
|
186
|
+
var curveLpToken = stakedTokenParams.underlying;
|
|
187
|
+
var curveLpTokenData = token_1.supportedTokens[curveLpToken];
|
|
188
|
+
var curvePool = curveLpTokenData.pool;
|
|
189
|
+
calls.push(ConvexPoolMulticaller.connect(data.adapters[contracts_1.contractsByNetwork[network][convexPool]]).withdrawAndUnwrap(convexLpAmount, true));
|
|
190
|
+
calls.push.apply(calls, curve_1.CurveStrategies.allCurveLPToUnderlying(data, network, curvePool));
|
|
191
|
+
if (sellRewards) {
|
|
192
|
+
calls.push.apply(calls, ConvexStrategies.sellRewards(data, network, convexPool));
|
|
193
|
+
}
|
|
194
|
+
return calls;
|
|
195
|
+
};
|
|
196
|
+
ConvexStrategies.allStakedConvexToUnderlying = function (data, network, convexPool, sellRewards) {
|
|
197
|
+
var calls = [];
|
|
198
|
+
var convexParams = contracts_1.contractParams[convexPool];
|
|
199
|
+
var stakedToken = convexParams.stakedToken;
|
|
200
|
+
var stakedTokenParams = token_1.supportedTokens[stakedToken];
|
|
201
|
+
var curveLpToken = stakedTokenParams.underlying;
|
|
202
|
+
var curveLpTokenData = token_1.supportedTokens[curveLpToken];
|
|
203
|
+
var curvePool = curveLpTokenData.pool;
|
|
204
|
+
calls.push(ConvexPoolMulticaller.connect(data.adapters[contracts_1.contractsByNetwork[network][convexPool]]).withdrawAllAndUnwrap(true));
|
|
205
|
+
calls.push.apply(calls, curve_1.CurveStrategies.allCurveLPToUnderlying(data, network, curvePool));
|
|
206
|
+
if (sellRewards) {
|
|
207
|
+
calls.push.apply(calls, ConvexStrategies.sellRewards(data, network, convexPool));
|
|
208
|
+
}
|
|
209
|
+
return calls;
|
|
210
|
+
};
|
|
211
|
+
ConvexStrategies.sellRewards = function (data, network, convexPool) {
|
|
212
|
+
var calls = [];
|
|
213
|
+
var convexParams = contracts_1.contractParams[convexPool];
|
|
214
|
+
calls.push(uniswapV2_1.UniswapV2Multicaller.connect(data.adapters[contracts_1.contractsByNetwork[network].UNISWAP_V2_ROUTER]).swapAllTokensForTokens(0, [token_1.tokenDataByNetwork[network].CRV, data.underlyingToken], Math.floor(new Date().getTime() / 1000) + 3600), uniswapV2_1.UniswapV2Multicaller.connect(data.adapters[contracts_1.contractsByNetwork[network].UNISWAP_V2_ROUTER]).swapAllTokensForTokens(0, [token_1.tokenDataByNetwork[network].CVX, data.underlyingToken], Math.floor(new Date().getTime() / 1000) + 3600));
|
|
215
|
+
convexParams.extraRewards.forEach(function (extraReward) {
|
|
216
|
+
uniswapV2_1.UniswapV2Multicaller.connect(data.adapters[contracts_1.contractsByNetwork[network].UNISWAP_V2_ROUTER]).swapAllTokensForTokens(0, [
|
|
217
|
+
token_1.tokenDataByNetwork[network][extraReward.rewardToken],
|
|
218
|
+
data.underlyingToken
|
|
219
|
+
], Math.floor(new Date().getTime() / 1000) + 3600);
|
|
220
|
+
});
|
|
221
|
+
return calls;
|
|
222
|
+
};
|
|
223
|
+
return ConvexStrategies;
|
|
224
|
+
}());
|
|
225
|
+
exports.ConvexStrategies = ConvexStrategies;
|
|
@@ -9,6 +9,7 @@ export declare class CreditFacadeCalls {
|
|
|
9
9
|
export declare class CreditFacadeMulticaller {
|
|
10
10
|
private readonly _address;
|
|
11
11
|
constructor(address: string);
|
|
12
|
+
static connect(address: string): CreditFacadeMulticaller;
|
|
12
13
|
addCollateral(onBehalfOf: string, token: string, amount: BigNumberish): MultiCallStruct;
|
|
13
14
|
increaseDebt(amount: BigNumberish): MultiCallStruct;
|
|
14
15
|
decreaseDebt(amount: BigNumberish): MultiCallStruct;
|
|
@@ -24,6 +24,9 @@ var CreditFacadeMulticaller = /** @class */ (function () {
|
|
|
24
24
|
function CreditFacadeMulticaller(address) {
|
|
25
25
|
this._address = address;
|
|
26
26
|
}
|
|
27
|
+
CreditFacadeMulticaller.connect = function (address) {
|
|
28
|
+
return new CreditFacadeMulticaller(address);
|
|
29
|
+
};
|
|
27
30
|
CreditFacadeMulticaller.prototype.addCollateral = function (onBehalfOf, token, amount) {
|
|
28
31
|
return {
|
|
29
32
|
target: this._address,
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { BigNumberish } from "ethers";
|
|
2
|
+
import { CurvePoolContract } from "src/contracts/contracts";
|
|
3
|
+
import { NetworkType } from "src/core/constants";
|
|
4
|
+
import { CreditManagerData } from "src/core/creditManager";
|
|
2
5
|
import { MultiCallStruct } from "../types/contracts/interfaces/ICreditFacade.sol/ICreditFacade";
|
|
3
6
|
export declare class CurveCalls {
|
|
4
7
|
static exchange(i: BigNumberish, j: BigNumberish, dx: BigNumberish, min_dy: BigNumberish): string;
|
|
@@ -15,6 +18,7 @@ export declare class CurveCalls {
|
|
|
15
18
|
export declare class CurveMulticaller {
|
|
16
19
|
private readonly _address;
|
|
17
20
|
constructor(address: string);
|
|
21
|
+
static connect(address: string): CurveMulticaller;
|
|
18
22
|
exchange(i: BigNumberish, j: BigNumberish, dx: BigNumberish, min_dy: BigNumberish): MultiCallStruct;
|
|
19
23
|
exchange_all(i: BigNumberish, j: BigNumberish, rateMinRAY: BigNumberish): MultiCallStruct;
|
|
20
24
|
exchange_underlying(i: BigNumberish, j: BigNumberish, dx: BigNumberish, min_dy: BigNumberish): MultiCallStruct;
|
|
@@ -32,3 +36,8 @@ export declare class CurveMulticaller {
|
|
|
32
36
|
remove_liquidity(amount: BigNumberish, min_amounts: [BigNumberish, BigNumberish] | [BigNumberish, BigNumberish, BigNumberish] | [BigNumberish, BigNumberish, BigNumberish, BigNumberish]): MultiCallStruct;
|
|
33
37
|
remove_liquidity_imbalance(amounts: [BigNumberish, BigNumberish] | [BigNumberish, BigNumberish, BigNumberish] | [BigNumberish, BigNumberish, BigNumberish, BigNumberish], max_burn_amount: BigNumberish): MultiCallStruct;
|
|
34
38
|
}
|
|
39
|
+
export declare class CurveStrategies {
|
|
40
|
+
static underlyingToCurveLP(data: CreditManagerData, network: NetworkType, curvePool: CurvePoolContract, underlyingAmount: BigNumberish): MultiCallStruct[];
|
|
41
|
+
static curveLPToUnderlying(data: CreditManagerData, network: NetworkType, curvePool: CurvePoolContract, curveLPAmount: BigNumberish): MultiCallStruct[];
|
|
42
|
+
static allCurveLPToUnderlying(data: CreditManagerData, network: NetworkType, curvePool: CurvePoolContract): MultiCallStruct[];
|
|
43
|
+
}
|
package/lib/strategies/curve.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CurveMulticaller = exports.CurveCalls = void 0;
|
|
3
|
+
exports.CurveStrategies = exports.CurveMulticaller = exports.CurveCalls = void 0;
|
|
4
|
+
var contracts_1 = require("src/contracts/contracts");
|
|
5
|
+
var constants_1 = require("src/core/constants");
|
|
6
|
+
var token_1 = require("src/tokens/token");
|
|
4
7
|
var types_1 = require("../types");
|
|
8
|
+
var uniswapV2_1 = require("./uniswapV2");
|
|
5
9
|
var CurveCalls = /** @class */ (function () {
|
|
6
10
|
function CurveCalls() {
|
|
7
11
|
}
|
|
@@ -69,6 +73,9 @@ var CurveMulticaller = /** @class */ (function () {
|
|
|
69
73
|
function CurveMulticaller(address) {
|
|
70
74
|
this._address = address;
|
|
71
75
|
}
|
|
76
|
+
CurveMulticaller.connect = function (address) {
|
|
77
|
+
return new CurveMulticaller(address);
|
|
78
|
+
};
|
|
72
79
|
CurveMulticaller.prototype.exchange = function (i, j, dx, min_dy) {
|
|
73
80
|
return {
|
|
74
81
|
target: this._address,
|
|
@@ -132,3 +139,63 @@ var CurveMulticaller = /** @class */ (function () {
|
|
|
132
139
|
return CurveMulticaller;
|
|
133
140
|
}());
|
|
134
141
|
exports.CurveMulticaller = CurveMulticaller;
|
|
142
|
+
var CurveStrategies = /** @class */ (function () {
|
|
143
|
+
function CurveStrategies() {
|
|
144
|
+
}
|
|
145
|
+
CurveStrategies.underlyingToCurveLP = function (data, network, curvePool, underlyingAmount) {
|
|
146
|
+
var calls = [];
|
|
147
|
+
var curveParams = contracts_1.contractParams[curvePool];
|
|
148
|
+
var tokenToDeposit = curveParams.tokens[0];
|
|
149
|
+
if (data.underlyingToken !== token_1.tokenDataByNetwork[network][tokenToDeposit]) {
|
|
150
|
+
calls.push(uniswapV2_1.UniswapV2Multicaller.connect(data.adapters[contracts_1.contractsByNetwork[network].UNISWAP_V2_ROUTER]).swapExactTokensForTokens(underlyingAmount, 0, [data.underlyingToken, token_1.tokenDataByNetwork[network][tokenToDeposit]], constants_1.ADDRESS_0X0, Math.floor(new Date().getTime() / 1000) + 3600));
|
|
151
|
+
}
|
|
152
|
+
calls.push(CurveMulticaller.connect(data.adapters[contracts_1.contractsByNetwork[network][curvePool]]).add_all_liquidity_one_coin(0, 0));
|
|
153
|
+
return calls;
|
|
154
|
+
};
|
|
155
|
+
CurveStrategies.curveLPToUnderlying = function (data, network, curvePool, curveLPAmount) {
|
|
156
|
+
var calls = [];
|
|
157
|
+
var curveParams = contracts_1.contractParams[curvePool];
|
|
158
|
+
var curveContractAddress;
|
|
159
|
+
if (curveParams.wrapper) {
|
|
160
|
+
curveContractAddress =
|
|
161
|
+
data.adapters[contracts_1.contractsByNetwork[network][curveParams.wrapper]];
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
curveContractAddress =
|
|
165
|
+
data.adapters[contracts_1.contractsByNetwork[network][curvePool]];
|
|
166
|
+
}
|
|
167
|
+
calls.push(CurveMulticaller.connect(curveContractAddress).remove_liquidity_one_coin(curveLPAmount, 0, 0));
|
|
168
|
+
if (token_1.tokenDataByNetwork[network][curveParams.tokens[0]] !==
|
|
169
|
+
data.underlyingToken) {
|
|
170
|
+
calls.push(uniswapV2_1.UniswapV2Multicaller.connect(data.adapters[contracts_1.contractsByNetwork[network].UNISWAP_V2_ROUTER]).swapAllTokensForTokens(0, [
|
|
171
|
+
token_1.tokenDataByNetwork[network][curveParams.tokens[0]],
|
|
172
|
+
data.underlyingToken
|
|
173
|
+
], Math.floor(new Date().getTime() / 1000) + 3600));
|
|
174
|
+
}
|
|
175
|
+
return calls;
|
|
176
|
+
};
|
|
177
|
+
CurveStrategies.allCurveLPToUnderlying = function (data, network, curvePool) {
|
|
178
|
+
var calls = [];
|
|
179
|
+
var curveParams = contracts_1.contractParams[curvePool];
|
|
180
|
+
var curveContractAddress;
|
|
181
|
+
if (curveParams.wrapper) {
|
|
182
|
+
curveContractAddress =
|
|
183
|
+
data.adapters[contracts_1.contractsByNetwork[network][curveParams.wrapper]];
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
curveContractAddress =
|
|
187
|
+
data.adapters[contracts_1.contractsByNetwork[network][curvePool]];
|
|
188
|
+
}
|
|
189
|
+
calls.push(CurveMulticaller.connect(curveContractAddress).remove_all_liquidity_one_coin(0, 0));
|
|
190
|
+
if (token_1.tokenDataByNetwork[network][curveParams.tokens[0]] !==
|
|
191
|
+
data.underlyingToken) {
|
|
192
|
+
calls.push(uniswapV2_1.UniswapV2Multicaller.connect(data.adapters[contracts_1.contractsByNetwork[network].UNISWAP_V2_ROUTER]).swapAllTokensForTokens(0, [
|
|
193
|
+
token_1.tokenDataByNetwork[network][curveParams.tokens[0]],
|
|
194
|
+
data.underlyingToken
|
|
195
|
+
], Math.floor(new Date().getTime() / 1000) + 3600));
|
|
196
|
+
}
|
|
197
|
+
return calls;
|
|
198
|
+
};
|
|
199
|
+
return CurveStrategies;
|
|
200
|
+
}());
|
|
201
|
+
exports.CurveStrategies = CurveStrategies;
|
package/lib/strategies/lido.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { BigNumberish } from "ethers";
|
|
2
|
+
import { CreditManagerData } from "src/core/creditManager";
|
|
3
|
+
import { NetworkType } from "src/core/constants";
|
|
2
4
|
import { MultiCallStruct } from "../types/contracts/interfaces/ICreditFacade.sol/ICreditFacade";
|
|
3
5
|
export declare class LidoCalls {
|
|
4
6
|
static submit(amount: BigNumberish): string;
|
|
@@ -7,6 +9,10 @@ export declare class LidoCalls {
|
|
|
7
9
|
export declare class LidoMulticaller {
|
|
8
10
|
private readonly _address;
|
|
9
11
|
constructor(address: string);
|
|
12
|
+
static connect(address: string): LidoMulticaller;
|
|
10
13
|
submit(amount: BigNumberish): MultiCallStruct;
|
|
11
14
|
submitAll(): MultiCallStruct;
|
|
12
15
|
}
|
|
16
|
+
export declare class LidoStrategies {
|
|
17
|
+
static mintSteth(data: CreditManagerData, network: NetworkType, underlyingAmount: BigNumberish): MultiCallStruct[];
|
|
18
|
+
}
|
package/lib/strategies/lido.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LidoMulticaller = exports.LidoCalls = void 0;
|
|
3
|
+
exports.LidoStrategies = exports.LidoMulticaller = exports.LidoCalls = void 0;
|
|
4
|
+
var constants_1 = require("src/core/constants");
|
|
5
|
+
var contracts_1 = require("src/contracts/contracts");
|
|
6
|
+
var token_1 = require("src/tokens/token");
|
|
4
7
|
var types_1 = require("../types");
|
|
8
|
+
var uniswapV2_1 = require("./uniswapV2");
|
|
5
9
|
var LidoCalls = /** @class */ (function () {
|
|
6
10
|
function LidoCalls() {
|
|
7
11
|
}
|
|
@@ -18,6 +22,9 @@ var LidoMulticaller = /** @class */ (function () {
|
|
|
18
22
|
function LidoMulticaller(address) {
|
|
19
23
|
this._address = address;
|
|
20
24
|
}
|
|
25
|
+
LidoMulticaller.connect = function (address) {
|
|
26
|
+
return new LidoMulticaller(address);
|
|
27
|
+
};
|
|
21
28
|
LidoMulticaller.prototype.submit = function (amount) {
|
|
22
29
|
return {
|
|
23
30
|
target: this._address,
|
|
@@ -33,3 +40,18 @@ var LidoMulticaller = /** @class */ (function () {
|
|
|
33
40
|
return LidoMulticaller;
|
|
34
41
|
}());
|
|
35
42
|
exports.LidoMulticaller = LidoMulticaller;
|
|
43
|
+
var LidoStrategies = /** @class */ (function () {
|
|
44
|
+
function LidoStrategies() {
|
|
45
|
+
}
|
|
46
|
+
LidoStrategies.mintSteth = function (data, network, underlyingAmount) {
|
|
47
|
+
var calls = [];
|
|
48
|
+
// This should be a pathfinder call
|
|
49
|
+
if (!data.isWETH) {
|
|
50
|
+
calls.push(uniswapV2_1.UniswapV2Multicaller.connect(data.adapters[contracts_1.contractsByNetwork[network].UNISWAP_V2_ROUTER]).swapExactTokensForTokens(underlyingAmount, 0, [data.underlyingToken, token_1.tokenDataByNetwork[network].WETH], constants_1.ADDRESS_0X0, Math.floor(new Date().getTime() / 1000) + 3600));
|
|
51
|
+
}
|
|
52
|
+
calls.push(LidoMulticaller.connect(data.adapters[contracts_1.contractsByNetwork[network].LIDO_STETH_GATEWAY]).submitAll());
|
|
53
|
+
return calls;
|
|
54
|
+
};
|
|
55
|
+
return LidoStrategies;
|
|
56
|
+
}());
|
|
57
|
+
exports.LidoStrategies = LidoStrategies;
|
|
@@ -8,6 +8,7 @@ export declare class UniswapV2Calls {
|
|
|
8
8
|
export declare class UniswapV2Multicaller {
|
|
9
9
|
private readonly _address;
|
|
10
10
|
constructor(address: string);
|
|
11
|
+
static connect(address: string): UniswapV2Multicaller;
|
|
11
12
|
swapExactTokensForTokens(amountIn: BigNumberish, amountOutMin: BigNumberish, path: Array<string>, to: string, deadline: BigNumberish): MultiCallStruct;
|
|
12
13
|
swapTokensForExactTokens(amountOut: BigNumberish, amountInMax: BigNumberish, path: Array<string>, to: string, deadline: BigNumberish): MultiCallStruct;
|
|
13
14
|
swapAllTokensForTokens(rateMinRAY: BigNumberish, path: Array<string>, deadline: BigNumberish): MultiCallStruct;
|
|
@@ -21,6 +21,9 @@ var UniswapV2Multicaller = /** @class */ (function () {
|
|
|
21
21
|
function UniswapV2Multicaller(address) {
|
|
22
22
|
this._address = address;
|
|
23
23
|
}
|
|
24
|
+
UniswapV2Multicaller.connect = function (address) {
|
|
25
|
+
return new UniswapV2Multicaller(address);
|
|
26
|
+
};
|
|
24
27
|
UniswapV2Multicaller.prototype.swapExactTokensForTokens = function (amountIn, amountOutMin, path, to, deadline) {
|
|
25
28
|
return {
|
|
26
29
|
target: this._address,
|
|
@@ -11,6 +11,7 @@ export declare class UniswapV3Calls {
|
|
|
11
11
|
export declare class UniswapV3Multicaller {
|
|
12
12
|
private readonly _address;
|
|
13
13
|
constructor(address: string);
|
|
14
|
+
static connect(address: string): UniswapV3Multicaller;
|
|
14
15
|
exactInputSingle(params: ISwapRouter.ExactInputSingleParamsStructOutput): MultiCallStruct;
|
|
15
16
|
exactAllInputSingle(params: IUniswapV3Adapter.ExactAllInputSingleParamsStructOutput): MultiCallStruct;
|
|
16
17
|
exactInput(params: ISwapRouter.ExactInputParamsStructOutput): MultiCallStruct;
|
|
@@ -31,6 +31,9 @@ var UniswapV3Multicaller = /** @class */ (function () {
|
|
|
31
31
|
function UniswapV3Multicaller(address) {
|
|
32
32
|
this._address = address;
|
|
33
33
|
}
|
|
34
|
+
UniswapV3Multicaller.connect = function (address) {
|
|
35
|
+
return new UniswapV3Multicaller(address);
|
|
36
|
+
};
|
|
34
37
|
UniswapV3Multicaller.prototype.exactInputSingle = function (params) {
|
|
35
38
|
return {
|
|
36
39
|
target: this._address,
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { BigNumberish } from "ethers";
|
|
2
|
+
import { YearnVaultContract } from "src/contracts/contracts";
|
|
3
|
+
import { NetworkType } from "src/core/constants";
|
|
4
|
+
import { CreditManagerData } from "src/core/creditManager";
|
|
2
5
|
import { MultiCallStruct } from "../types/contracts/interfaces/ICreditFacade.sol/ICreditFacade";
|
|
3
6
|
export declare class YearnV2Calls {
|
|
4
7
|
static deposit(amount?: BigNumberish, recipient?: string): string;
|
|
@@ -7,6 +10,11 @@ export declare class YearnV2Calls {
|
|
|
7
10
|
export declare class YearnV2Multicaller {
|
|
8
11
|
private readonly _address;
|
|
9
12
|
constructor(address: string);
|
|
13
|
+
static connect(address: string): YearnV2Multicaller;
|
|
10
14
|
deposit(amount?: BigNumberish, recipient?: string): MultiCallStruct;
|
|
11
15
|
withdraw(maxShares?: BigNumberish, recipient?: string, maxLoss?: BigNumberish): MultiCallStruct;
|
|
12
16
|
}
|
|
17
|
+
export declare class YearnV2Strategies {
|
|
18
|
+
static underlyingToYearn(data: CreditManagerData, network: NetworkType, yearnVault: YearnVaultContract, underlyingAmount: BigNumberish): void;
|
|
19
|
+
static yearnToUnderlying(data: CreditManagerData, network: NetworkType, yearnVault: YearnVaultContract, yearnSharesAmount: BigNumberish): void;
|
|
20
|
+
}
|
package/lib/strategies/yearn.js
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.YearnV2Multicaller = exports.YearnV2Calls = void 0;
|
|
12
|
+
exports.YearnV2Strategies = exports.YearnV2Multicaller = exports.YearnV2Calls = void 0;
|
|
13
|
+
var contracts_1 = require("src/contracts/contracts");
|
|
14
|
+
var constants_1 = require("src/core/constants");
|
|
15
|
+
var token_1 = require("src/tokens/token");
|
|
16
|
+
var tokenType_1 = require("src/tokens/tokenType");
|
|
4
17
|
var types_1 = require("../types");
|
|
18
|
+
var curve_1 = require("./curve");
|
|
19
|
+
var uniswapV2_1 = require("./uniswapV2");
|
|
5
20
|
var YearnV2Calls = /** @class */ (function () {
|
|
6
21
|
function YearnV2Calls() {
|
|
7
22
|
}
|
|
@@ -43,6 +58,9 @@ var YearnV2Multicaller = /** @class */ (function () {
|
|
|
43
58
|
function YearnV2Multicaller(address) {
|
|
44
59
|
this._address = address;
|
|
45
60
|
}
|
|
61
|
+
YearnV2Multicaller.connect = function (address) {
|
|
62
|
+
return new YearnV2Multicaller(address);
|
|
63
|
+
};
|
|
46
64
|
YearnV2Multicaller.prototype.deposit = function (amount, recipient) {
|
|
47
65
|
return {
|
|
48
66
|
target: this._address,
|
|
@@ -58,3 +76,61 @@ var YearnV2Multicaller = /** @class */ (function () {
|
|
|
58
76
|
return YearnV2Multicaller;
|
|
59
77
|
}());
|
|
60
78
|
exports.YearnV2Multicaller = YearnV2Multicaller;
|
|
79
|
+
var YearnV2Strategies = /** @class */ (function () {
|
|
80
|
+
function YearnV2Strategies() {
|
|
81
|
+
}
|
|
82
|
+
YearnV2Strategies.underlyingToYearn = function (data, network, yearnVault, underlyingAmount) {
|
|
83
|
+
var calls = [];
|
|
84
|
+
var vaultParams = contracts_1.contractParams[yearnVault];
|
|
85
|
+
var yearnToken = vaultParams.shareToken;
|
|
86
|
+
var yearnParams = token_1.supportedTokens[yearnToken];
|
|
87
|
+
if (yearnParams.type === tokenType_1.TokenType.YEARN_VAULT) {
|
|
88
|
+
if (data.underlyingToken !==
|
|
89
|
+
token_1.tokenDataByNetwork[network][yearnParams.underlying]) {
|
|
90
|
+
// This should be a pathfinder call
|
|
91
|
+
calls.push(uniswapV2_1.UniswapV2Multicaller.connect(data.adapters[contracts_1.contractsByNetwork[network].UNISWAP_V2_ROUTER]).swapExactTokensForTokens(underlyingAmount, 0, [
|
|
92
|
+
data.underlyingToken,
|
|
93
|
+
token_1.tokenDataByNetwork[network][yearnParams.underlying]
|
|
94
|
+
], constants_1.ADDRESS_0X0, Math.floor(new Date().getTime() / 1000) + 3600));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else if (yearnParams.type === tokenType_1.TokenType.YEARN_VAULT_OF_CURVE_LP ||
|
|
98
|
+
yearnParams.type === tokenType_1.TokenType.YEARN_VAULT_OF_META_CURVE_LP) {
|
|
99
|
+
var curveTokenParams = token_1.supportedTokens[yearnParams.underlying];
|
|
100
|
+
var curvePool = curveTokenParams.pool;
|
|
101
|
+
calls = curve_1.CurveStrategies.underlyingToCurveLP(data, network, curvePool, underlyingAmount);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
throw new Error("Yearn vault type unknown");
|
|
105
|
+
}
|
|
106
|
+
calls.push(YearnV2Multicaller.connect(data.adapters[contracts_1.contractsByNetwork[network][yearnVault]]).deposit());
|
|
107
|
+
};
|
|
108
|
+
YearnV2Strategies.yearnToUnderlying = function (data, network, yearnVault, yearnSharesAmount) {
|
|
109
|
+
var calls = [];
|
|
110
|
+
var vaultParams = contracts_1.contractParams[yearnVault];
|
|
111
|
+
var yearnToken = vaultParams.shareToken;
|
|
112
|
+
var yearnParams = token_1.supportedTokens[yearnToken];
|
|
113
|
+
calls.push(YearnV2Multicaller.connect(data.adapters[contracts_1.contractsByNetwork[network][yearnVault]]).withdraw(yearnSharesAmount));
|
|
114
|
+
if (yearnParams.type === tokenType_1.TokenType.YEARN_VAULT) {
|
|
115
|
+
if (data.underlyingToken !==
|
|
116
|
+
token_1.tokenDataByNetwork[network][yearnParams.underlying]) {
|
|
117
|
+
// This should be a pathfinder call
|
|
118
|
+
calls.push(uniswapV2_1.UniswapV2Multicaller.connect(data.adapters[contracts_1.contractsByNetwork[network].UNISWAP_V2_ROUTER]).swapAllTokensForTokens(0, [
|
|
119
|
+
token_1.tokenDataByNetwork[network][yearnParams.underlying],
|
|
120
|
+
data.underlyingToken
|
|
121
|
+
], Math.floor(new Date().getTime() / 1000) + 3600));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else if (yearnParams.type === tokenType_1.TokenType.YEARN_VAULT_OF_CURVE_LP ||
|
|
125
|
+
yearnParams.type === tokenType_1.TokenType.YEARN_VAULT_OF_META_CURVE_LP) {
|
|
126
|
+
var curveTokenParams = token_1.supportedTokens[yearnParams.underlying];
|
|
127
|
+
var curvePool = curveTokenParams.pool;
|
|
128
|
+
calls = __spreadArray(__spreadArray([], calls, true), curve_1.CurveStrategies.allCurveLPToUnderlying(data, network, curvePool), true);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
throw new Error("Yearn vault type unknown");
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
return YearnV2Strategies;
|
|
135
|
+
}());
|
|
136
|
+
exports.YearnV2Strategies = YearnV2Strategies;
|