@gearbox-protocol/sdk 0.0.102 → 0.0.105
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 +5 -0
- package/.eslintrc.js +52 -0
- package/.husky/pre-push +4 -0
- package/lib/apy/convexAPY.js +3 -5
- package/lib/apy/lidoAPY.js +8 -9
- package/lib/contracts/contracts.d.ts +5 -2
- package/lib/contracts/contracts.js +19 -18
- package/lib/core/constants.d.ts +1 -1
- package/lib/core/constants.js +2 -2
- package/lib/core/creditAccount.js +7 -5
- package/lib/core/creditManager.d.ts +1 -1
- package/lib/core/creditManager.js +1 -7
- package/lib/core/creditSession.js +14 -3
- package/lib/core/eventOrTx.d.ts +1 -1
- package/lib/core/events.d.ts +19 -19
- package/lib/core/events.js +23 -21
- package/lib/core/pool.d.ts +1 -1
- package/lib/core/pool.js +1 -7
- package/lib/core/price.js +6 -1
- package/lib/core/strategy.d.ts +1 -3
- package/lib/core/strategy.js +14 -13
- package/lib/core/tokenDistributor.js +1 -1
- package/lib/core/transactions.d.ts +18 -3
- package/lib/core/transactions.js +39 -3
- package/lib/index.d.ts +8 -2
- package/lib/index.js +8 -1
- package/lib/oracles/priceFeeds.js +1 -1
- package/lib/pathfinder/convexLP.d.ts +1 -1
- package/lib/pathfinder/convexLP.js +26 -29
- package/lib/pathfinder/curveLP.d.ts +1 -1
- package/lib/pathfinder/curveLP.js +5 -7
- package/lib/pathfinder/path.d.ts +1 -1
- package/lib/pathfinder/path.js +38 -42
- package/lib/pathfinder/trade.d.ts +1 -2
- package/lib/pathfinder/tradeTypes.d.ts +5 -5
- package/lib/pathfinder/yVault.d.ts +2 -2
- package/lib/pathfinder/yVault.js +18 -15
- 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 +15 -60
- package/lib/strategies/curve.js +74 -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 +6 -19
- package/lib/strategies/uniswapV3.d.ts +1 -0
- package/lib/strategies/uniswapV3.js +4 -1
- package/lib/strategies/yearn.d.ts +8 -0
- package/lib/strategies/yearn.js +92 -12
- package/lib/tokens/convex.d.ts +3 -3
- package/lib/tokens/curveLP.d.ts +7 -2
- package/lib/tokens/curveLP.js +8 -1
- package/lib/tokens/gear.d.ts +2 -2
- package/lib/tokens/gear.js +1 -1
- package/lib/tokens/normal.d.ts +1 -1
- package/lib/tokens/token.js +4 -4
- package/lib/tokens/tokenData.d.ts +3 -1
- package/lib/tokens/tokenData.js +10 -8
- package/lib/tokens/yearn.d.ts +6 -2
- package/lib/tokens/yearn.js +6 -0
- package/lib/utils/errors.d.ts +6 -0
- package/lib/utils/errors.js +13 -0
- package/lib/utils/formatter.d.ts +1 -1
- package/lib/utils/formatter.js +17 -14
- package/lib/utils/loading.d.ts +2 -1
- package/lib/utils/loading.js +9 -13
- package/lib/utils/mappers.js +2 -2
- package/lib/utils/network.js +2 -2
- package/lib/utils/repeater.js +12 -24
- package/lib/utils/validate.js +1 -1
- package/package.json +24 -7
- package/src/apy/convexAPY.ts +6 -6
- package/src/apy/lidoAPY.ts +12 -11
- package/src/contracts/contracts.ts +27 -17
- package/src/core/constants.ts +1 -1
- package/src/core/creditAccount.ts +28 -5
- package/src/core/creditManager.ts +29 -4
- package/src/core/creditOperation.ts +7 -7
- package/src/core/creditSession.ts +25 -5
- package/src/core/errors.ts +1 -0
- package/src/core/eventOrTx.ts +8 -5
- package/src/core/events.ts +85 -24
- package/src/core/history.ts +46 -46
- package/src/core/operations.ts +6 -0
- package/src/core/pool.ts +16 -4
- package/src/core/price.ts +7 -3
- package/src/core/strategy.ts +27 -23
- package/src/core/tokenDistributor.ts +2 -2
- package/src/core/transactions.ts +427 -350
- package/src/index.ts +10 -3
- package/src/oracles/priceFeeds.ts +523 -523
- package/src/pathfinder/contracts.ts +15 -13
- package/src/pathfinder/convexLP.ts +29 -25
- package/src/pathfinder/curveLP.ts +57 -53
- package/src/pathfinder/path.ts +17 -9
- package/src/pathfinder/priority.ts +11 -11
- package/src/pathfinder/trade.ts +84 -77
- package/src/pathfinder/tradeTypes.ts +98 -94
- package/src/pathfinder/yVault.ts +26 -11
- package/src/payload/token.ts +3 -3
- package/src/strategies/convex.ts +361 -186
- package/src/strategies/creditFacade.ts +74 -53
- package/src/strategies/curve.ts +400 -189
- package/src/strategies/lido.ts +70 -32
- package/src/strategies/uniswapV2.ts +93 -111
- package/src/strategies/uniswapV3.ts +118 -91
- package/src/strategies/yearn.ts +187 -60
- package/src/tokens/connectors.ts +6 -6
- package/src/tokens/convex.ts +297 -296
- package/src/tokens/curveLP.ts +176 -165
- package/src/tokens/gear.ts +47 -45
- package/src/tokens/normal.ts +801 -802
- package/src/tokens/token.ts +9 -5
- package/src/tokens/tokenData.ts +19 -9
- package/src/tokens/tokenType.ts +11 -11
- package/src/tokens/yearn.ts +130 -124
- package/src/utils/errors.ts +11 -0
- package/src/utils/formatter.ts +22 -18
- package/src/utils/loading.ts +14 -6
- package/src/utils/mappers.ts +8 -6
- package/src/utils/multicall.ts +2 -0
- package/src/utils/network.ts +21 -21
- package/src/utils/repeater.ts +2 -2
- package/src/utils/validate.ts +1 -1
- package/lib/utils/events.d.ts +0 -2
- package/lib/utils/events.js +0 -13
- package/src/utils/events.ts +0 -10
package/src/strategies/convex.ts
CHANGED
|
@@ -1,233 +1,408 @@
|
|
|
1
1
|
import { BigNumberish } from "ethers";
|
|
2
|
+
import {
|
|
3
|
+
contractParams,
|
|
4
|
+
contractsByNetwork,
|
|
5
|
+
ConvexPoolContract,
|
|
6
|
+
ConvexPoolParams
|
|
7
|
+
} from "../contracts/contracts";
|
|
8
|
+
import { NetworkType } from "../core/constants";
|
|
9
|
+
import { CreditManagerData } from "../core/creditManager";
|
|
10
|
+
import { ConvexPhantomTokenData } from "../tokens/convex";
|
|
11
|
+
|
|
12
|
+
import { supportedTokens, tokenDataByNetwork } from "../tokens/token";
|
|
13
|
+
import { CurveLPTokenData } from "../tokens/curveLP";
|
|
2
14
|
|
|
3
15
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from "../types"
|
|
16
|
+
ConvexV1BoosterAdapter__factory,
|
|
17
|
+
ConvexV1BaseRewardPoolAdapter__factory,
|
|
18
|
+
ConvexV1ClaimZapAdapter__factory
|
|
19
|
+
} from "../types";
|
|
8
20
|
|
|
9
21
|
import { MultiCallStruct } from "../types/contracts/interfaces/ICreditFacade.sol/ICreditFacade";
|
|
22
|
+
import { CurveStrategies } from "./curve";
|
|
23
|
+
import { UniswapV2Multicaller } from "./uniswapV2";
|
|
10
24
|
|
|
11
25
|
export class ConvexBoosterCalls {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
26
|
+
public static deposit(
|
|
27
|
+
pid: BigNumberish,
|
|
28
|
+
amount: BigNumberish,
|
|
29
|
+
stake: boolean
|
|
30
|
+
) {
|
|
31
|
+
return ConvexV1BoosterAdapter__factory.createInterface().encodeFunctionData(
|
|
32
|
+
"deposit",
|
|
33
|
+
[pid, amount, stake]
|
|
34
|
+
);
|
|
35
|
+
}
|
|
18
36
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
37
|
+
public static depositAll(pid: BigNumberish, stake: boolean) {
|
|
38
|
+
return ConvexV1BoosterAdapter__factory.createInterface().encodeFunctionData(
|
|
39
|
+
"depositAll",
|
|
40
|
+
[pid, stake]
|
|
41
|
+
);
|
|
42
|
+
}
|
|
25
43
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
44
|
+
public static withdraw(pid: BigNumberish, amount: BigNumberish) {
|
|
45
|
+
return ConvexV1BoosterAdapter__factory.createInterface().encodeFunctionData(
|
|
46
|
+
"withdraw",
|
|
47
|
+
[pid, amount]
|
|
48
|
+
);
|
|
49
|
+
}
|
|
32
50
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
51
|
+
public static withdrawAll(pid: BigNumberish) {
|
|
52
|
+
return ConvexV1BoosterAdapter__factory.createInterface().encodeFunctionData(
|
|
53
|
+
"withdrawAll",
|
|
54
|
+
[pid]
|
|
55
|
+
);
|
|
56
|
+
}
|
|
39
57
|
}
|
|
40
58
|
|
|
41
59
|
export class ConvexPoolCalls {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
60
|
+
public static stake(amount: BigNumberish) {
|
|
61
|
+
return ConvexV1BaseRewardPoolAdapter__factory.createInterface().encodeFunctionData(
|
|
62
|
+
"stake",
|
|
63
|
+
[amount]
|
|
64
|
+
);
|
|
65
|
+
}
|
|
48
66
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
67
|
+
public static stakeAll() {
|
|
68
|
+
return ConvexV1BaseRewardPoolAdapter__factory.createInterface().encodeFunctionData(
|
|
69
|
+
"stakeAll"
|
|
70
|
+
);
|
|
71
|
+
}
|
|
54
72
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
73
|
+
public static withdraw(amount: BigNumberish, claim: boolean) {
|
|
74
|
+
return ConvexV1BaseRewardPoolAdapter__factory.createInterface().encodeFunctionData(
|
|
75
|
+
"withdraw",
|
|
76
|
+
[amount, claim]
|
|
77
|
+
);
|
|
78
|
+
}
|
|
61
79
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
80
|
+
public static withdrawAll(claim: boolean) {
|
|
81
|
+
return ConvexV1BaseRewardPoolAdapter__factory.createInterface().encodeFunctionData(
|
|
82
|
+
"withdrawAll",
|
|
83
|
+
[claim]
|
|
84
|
+
);
|
|
85
|
+
}
|
|
68
86
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
87
|
+
public static withdrawAndUnwrap(amount: BigNumberish, claim: boolean) {
|
|
88
|
+
return ConvexV1BaseRewardPoolAdapter__factory.createInterface().encodeFunctionData(
|
|
89
|
+
"withdrawAndUnwrap",
|
|
90
|
+
[amount, claim]
|
|
91
|
+
);
|
|
92
|
+
}
|
|
75
93
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
94
|
+
public static withdrawAllAndUnwrap(claim: boolean) {
|
|
95
|
+
return ConvexV1BaseRewardPoolAdapter__factory.createInterface().encodeFunctionData(
|
|
96
|
+
"withdrawAllAndUnwrap",
|
|
97
|
+
[claim]
|
|
98
|
+
);
|
|
99
|
+
}
|
|
82
100
|
}
|
|
83
101
|
|
|
84
|
-
|
|
85
102
|
export class ConvexClaimZapCalls {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
103
|
+
public static claimRewards(
|
|
104
|
+
rewardContracts: Array<string>,
|
|
105
|
+
extraRewardContracts: Array<string>,
|
|
106
|
+
tokenRewardContracts: Array<string>,
|
|
107
|
+
tokenRewardTokens: Array<string>,
|
|
108
|
+
depositCrvMaxAmount: BigNumberish,
|
|
109
|
+
minAmountOut: BigNumberish,
|
|
110
|
+
depositCvxMaxAmount: BigNumberish,
|
|
111
|
+
spendCvxAmount: BigNumberish,
|
|
112
|
+
options: BigNumberish
|
|
113
|
+
) {
|
|
114
|
+
return ConvexV1ClaimZapAdapter__factory.createInterface().encodeFunctionData(
|
|
115
|
+
"claimRewards",
|
|
116
|
+
[
|
|
117
|
+
rewardContracts,
|
|
118
|
+
extraRewardContracts,
|
|
119
|
+
tokenRewardContracts,
|
|
120
|
+
tokenRewardTokens,
|
|
121
|
+
depositCrvMaxAmount,
|
|
122
|
+
minAmountOut,
|
|
123
|
+
depositCvxMaxAmount,
|
|
124
|
+
spendCvxAmount,
|
|
125
|
+
options
|
|
126
|
+
]
|
|
127
|
+
);
|
|
128
|
+
}
|
|
112
129
|
}
|
|
113
130
|
|
|
114
131
|
export class ConvexBoosterMulticaller {
|
|
115
|
-
|
|
132
|
+
private readonly _address: string;
|
|
116
133
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
134
|
+
constructor(address: string) {
|
|
135
|
+
this._address = address;
|
|
136
|
+
}
|
|
120
137
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
callData: ConvexBoosterCalls.deposit(pid, amount, stake)
|
|
125
|
-
}
|
|
126
|
-
}
|
|
138
|
+
static connect(address: string) {
|
|
139
|
+
return new ConvexBoosterMulticaller(address);
|
|
140
|
+
}
|
|
127
141
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
142
|
+
deposit(
|
|
143
|
+
pid: BigNumberish,
|
|
144
|
+
amount: BigNumberish,
|
|
145
|
+
stake: boolean
|
|
146
|
+
): MultiCallStruct {
|
|
147
|
+
return {
|
|
148
|
+
target: this._address,
|
|
149
|
+
callData: ConvexBoosterCalls.deposit(pid, amount, stake)
|
|
150
|
+
};
|
|
151
|
+
}
|
|
134
152
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
153
|
+
depositAll(pid: BigNumberish, stake: boolean): MultiCallStruct {
|
|
154
|
+
return {
|
|
155
|
+
target: this._address,
|
|
156
|
+
callData: ConvexBoosterCalls.depositAll(pid, stake)
|
|
157
|
+
};
|
|
158
|
+
}
|
|
141
159
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
160
|
+
withdraw(pid: BigNumberish, amount: BigNumberish): MultiCallStruct {
|
|
161
|
+
return {
|
|
162
|
+
target: this._address,
|
|
163
|
+
callData: ConvexBoosterCalls.withdraw(pid, amount)
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
withdrawAll(pid: BigNumberish): MultiCallStruct {
|
|
168
|
+
return {
|
|
169
|
+
target: this._address,
|
|
170
|
+
callData: ConvexBoosterCalls.withdrawAll(pid)
|
|
171
|
+
};
|
|
172
|
+
}
|
|
148
173
|
}
|
|
149
174
|
|
|
150
175
|
export class ConvexPoolMulticaller {
|
|
151
|
-
|
|
176
|
+
private readonly _address: string;
|
|
152
177
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
178
|
+
constructor(address: string) {
|
|
179
|
+
this._address = address;
|
|
180
|
+
}
|
|
156
181
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
callData: ConvexPoolCalls.stake(amount)
|
|
161
|
-
}
|
|
162
|
-
}
|
|
182
|
+
static connect(address: string) {
|
|
183
|
+
return new ConvexPoolMulticaller(address);
|
|
184
|
+
}
|
|
163
185
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
186
|
+
stake(amount: BigNumberish): MultiCallStruct {
|
|
187
|
+
return {
|
|
188
|
+
target: this._address,
|
|
189
|
+
callData: ConvexPoolCalls.stake(amount)
|
|
190
|
+
};
|
|
191
|
+
}
|
|
170
192
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
193
|
+
stakeAll(): MultiCallStruct {
|
|
194
|
+
return {
|
|
195
|
+
target: this._address,
|
|
196
|
+
callData: ConvexPoolCalls.stakeAll()
|
|
197
|
+
};
|
|
198
|
+
}
|
|
177
199
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
200
|
+
withdraw(amount: BigNumberish, claim: boolean): MultiCallStruct {
|
|
201
|
+
return {
|
|
202
|
+
target: this._address,
|
|
203
|
+
callData: ConvexPoolCalls.withdraw(amount, claim)
|
|
204
|
+
};
|
|
205
|
+
}
|
|
184
206
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
207
|
+
withdrawAll(claim: boolean): MultiCallStruct {
|
|
208
|
+
return {
|
|
209
|
+
target: this._address,
|
|
210
|
+
callData: ConvexPoolCalls.withdrawAll(claim)
|
|
211
|
+
};
|
|
212
|
+
}
|
|
191
213
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
214
|
+
withdrawAndUnwrap(amount: BigNumberish, claim: boolean): MultiCallStruct {
|
|
215
|
+
return {
|
|
216
|
+
target: this._address,
|
|
217
|
+
callData: ConvexPoolCalls.withdrawAndUnwrap(amount, claim)
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
withdrawAllAndUnwrap(claim: boolean) {
|
|
222
|
+
return {
|
|
223
|
+
target: this._address,
|
|
224
|
+
callData: ConvexPoolCalls.withdrawAllAndUnwrap(claim)
|
|
225
|
+
};
|
|
226
|
+
}
|
|
198
227
|
}
|
|
199
228
|
|
|
200
229
|
export class ConvexClaimZapMulticaller {
|
|
201
|
-
|
|
230
|
+
private readonly _address: string;
|
|
231
|
+
|
|
232
|
+
constructor(address: string) {
|
|
233
|
+
this._address = address;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
static connect(address: string) {
|
|
237
|
+
return new ConvexClaimZapMulticaller(address);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
claimRewards(
|
|
241
|
+
rewardContracts: Array<string>,
|
|
242
|
+
extraRewardContracts: Array<string>,
|
|
243
|
+
tokenRewardContracts: Array<string>,
|
|
244
|
+
tokenRewardTokens: Array<string>,
|
|
245
|
+
depositCrvMaxAmount: BigNumberish,
|
|
246
|
+
minAmountOut: BigNumberish,
|
|
247
|
+
depositCvxMaxAmount: BigNumberish,
|
|
248
|
+
spendCvxAmount: BigNumberish,
|
|
249
|
+
options: BigNumberish
|
|
250
|
+
): MultiCallStruct {
|
|
251
|
+
return {
|
|
252
|
+
target: this._address,
|
|
253
|
+
callData: ConvexClaimZapCalls.claimRewards(
|
|
254
|
+
rewardContracts,
|
|
255
|
+
extraRewardContracts,
|
|
256
|
+
tokenRewardContracts,
|
|
257
|
+
tokenRewardTokens,
|
|
258
|
+
depositCrvMaxAmount,
|
|
259
|
+
minAmountOut,
|
|
260
|
+
depositCvxMaxAmount,
|
|
261
|
+
spendCvxAmount,
|
|
262
|
+
options
|
|
263
|
+
)
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export class ConvexStrategies {
|
|
269
|
+
static underlyingToStakedConvex(
|
|
270
|
+
data: CreditManagerData,
|
|
271
|
+
network: NetworkType,
|
|
272
|
+
convexPool: ConvexPoolContract,
|
|
273
|
+
underlyingAmount: BigNumberish
|
|
274
|
+
) {
|
|
275
|
+
let calls: Array<MultiCallStruct> = [];
|
|
276
|
+
const convexParams = contractParams[convexPool] as ConvexPoolParams;
|
|
277
|
+
const { stakedToken } = convexParams;
|
|
278
|
+
const stakedTokenParams = supportedTokens[
|
|
279
|
+
stakedToken
|
|
280
|
+
] as ConvexPhantomTokenData;
|
|
281
|
+
const curveLpToken = stakedTokenParams.underlying;
|
|
282
|
+
const curveLpTokenData = supportedTokens[curveLpToken] as CurveLPTokenData;
|
|
283
|
+
const curvePool = curveLpTokenData.pool;
|
|
284
|
+
|
|
285
|
+
calls = CurveStrategies.underlyingToCurveLP(
|
|
286
|
+
data,
|
|
287
|
+
network,
|
|
288
|
+
curvePool,
|
|
289
|
+
underlyingAmount
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
calls.push(
|
|
293
|
+
ConvexBoosterMulticaller.connect(
|
|
294
|
+
data.adapters[contractsByNetwork[network].CONVEX_BOOSTER]
|
|
295
|
+
).depositAll(stakedTokenParams.pid, true)
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
return calls;
|
|
299
|
+
}
|
|
202
300
|
|
|
203
|
-
|
|
204
|
-
|
|
301
|
+
static stakedConvexToUnderlying(
|
|
302
|
+
data: CreditManagerData,
|
|
303
|
+
network: NetworkType,
|
|
304
|
+
convexPool: ConvexPoolContract,
|
|
305
|
+
convexLpAmount: BigNumberish,
|
|
306
|
+
sellRewards: boolean
|
|
307
|
+
) {
|
|
308
|
+
const calls: Array<MultiCallStruct> = [];
|
|
309
|
+
const convexParams = contractParams[convexPool] as ConvexPoolParams;
|
|
310
|
+
const { stakedToken } = convexParams;
|
|
311
|
+
const stakedTokenParams = supportedTokens[
|
|
312
|
+
stakedToken
|
|
313
|
+
] as ConvexPhantomTokenData;
|
|
314
|
+
const curveLpToken = stakedTokenParams.underlying;
|
|
315
|
+
const curveLpTokenData = supportedTokens[curveLpToken] as CurveLPTokenData;
|
|
316
|
+
const curvePool = curveLpTokenData.pool;
|
|
317
|
+
|
|
318
|
+
calls.push(
|
|
319
|
+
ConvexPoolMulticaller.connect(
|
|
320
|
+
data.adapters[contractsByNetwork[network][convexPool]]
|
|
321
|
+
).withdrawAndUnwrap(convexLpAmount, true)
|
|
322
|
+
);
|
|
323
|
+
|
|
324
|
+
calls.push(
|
|
325
|
+
...CurveStrategies.allCurveLPToUnderlying(data, network, curvePool)
|
|
326
|
+
);
|
|
327
|
+
|
|
328
|
+
if (sellRewards) {
|
|
329
|
+
calls.push(...ConvexStrategies.sellRewards(data, network, convexPool));
|
|
205
330
|
}
|
|
206
331
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
332
|
+
return calls;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
static allStakedConvexToUnderlying(
|
|
336
|
+
data: CreditManagerData,
|
|
337
|
+
network: NetworkType,
|
|
338
|
+
convexPool: ConvexPoolContract,
|
|
339
|
+
sellRewards: boolean
|
|
340
|
+
) {
|
|
341
|
+
const calls: Array<MultiCallStruct> = [];
|
|
342
|
+
const convexParams = contractParams[convexPool] as ConvexPoolParams;
|
|
343
|
+
const { stakedToken } = convexParams;
|
|
344
|
+
const stakedTokenParams = supportedTokens[
|
|
345
|
+
stakedToken
|
|
346
|
+
] as ConvexPhantomTokenData;
|
|
347
|
+
const curveLpToken = stakedTokenParams.underlying;
|
|
348
|
+
const curveLpTokenData = supportedTokens[curveLpToken] as CurveLPTokenData;
|
|
349
|
+
const curvePool = curveLpTokenData.pool;
|
|
350
|
+
|
|
351
|
+
calls.push(
|
|
352
|
+
ConvexPoolMulticaller.connect(
|
|
353
|
+
data.adapters[contractsByNetwork[network][convexPool]]
|
|
354
|
+
).withdrawAllAndUnwrap(true)
|
|
355
|
+
);
|
|
356
|
+
|
|
357
|
+
calls.push(
|
|
358
|
+
...CurveStrategies.allCurveLPToUnderlying(data, network, curvePool)
|
|
359
|
+
);
|
|
360
|
+
|
|
361
|
+
if (sellRewards) {
|
|
362
|
+
calls.push(...ConvexStrategies.sellRewards(data, network, convexPool));
|
|
232
363
|
}
|
|
364
|
+
|
|
365
|
+
return calls;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
static sellRewards(
|
|
369
|
+
data: CreditManagerData,
|
|
370
|
+
network: NetworkType,
|
|
371
|
+
convexPool: ConvexPoolContract
|
|
372
|
+
) {
|
|
373
|
+
const calls: Array<MultiCallStruct> = [];
|
|
374
|
+
const convexParams = contractParams[convexPool] as ConvexPoolParams;
|
|
375
|
+
|
|
376
|
+
calls.push(
|
|
377
|
+
UniswapV2Multicaller.connect(
|
|
378
|
+
data.adapters[contractsByNetwork[network].UNISWAP_V2_ROUTER]
|
|
379
|
+
).swapAllTokensForTokens(
|
|
380
|
+
0,
|
|
381
|
+
[tokenDataByNetwork[network].CRV, data.underlyingToken],
|
|
382
|
+
Math.floor(new Date().getTime() / 1000) + 3600
|
|
383
|
+
),
|
|
384
|
+
UniswapV2Multicaller.connect(
|
|
385
|
+
data.adapters[contractsByNetwork[network].UNISWAP_V2_ROUTER]
|
|
386
|
+
).swapAllTokensForTokens(
|
|
387
|
+
0,
|
|
388
|
+
[tokenDataByNetwork[network].CVX, data.underlyingToken],
|
|
389
|
+
Math.floor(new Date().getTime() / 1000) + 3600
|
|
390
|
+
)
|
|
391
|
+
);
|
|
392
|
+
|
|
393
|
+
convexParams.extraRewards.forEach(extraReward => {
|
|
394
|
+
UniswapV2Multicaller.connect(
|
|
395
|
+
data.adapters[contractsByNetwork[network].UNISWAP_V2_ROUTER]
|
|
396
|
+
).swapAllTokensForTokens(
|
|
397
|
+
0,
|
|
398
|
+
[
|
|
399
|
+
tokenDataByNetwork[network][extraReward.rewardToken],
|
|
400
|
+
data.underlyingToken
|
|
401
|
+
],
|
|
402
|
+
Math.floor(new Date().getTime() / 1000) + 3600
|
|
403
|
+
);
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
return calls;
|
|
407
|
+
}
|
|
233
408
|
}
|