@@ -84,14 +84,16 @@ abstract contract ALEBaseSDolaLPDynYearnV2Test is MarketForkTest {
84
84
assertEq (vault.balanceOf (userPkEscrow), sharesAmount + sharesAdded);
85
85
}
86
86
87
- function test_leveragePosition_buyDBR () public {
87
+ function test_leveragePosition_buyDBR (uint256 amount ) public {
88
+ vm.assume (amount > 0.0001 ether);
89
+ vm.assume (amount < 10000000 ether);
88
90
vm.prank (gov);
89
- DOLA.mint (userPk, 10000 ether );
91
+ DOLA.mint (userPk, amount );
90
92
91
93
vm.startPrank (userPk, userPk);
92
- DOLA.approve (address (helper), 10000 ether );
94
+ DOLA.approve (address (helper), amount );
93
95
helper.transformToCollateralAndDeposit (
94
- 10000 ether ,
96
+ amount ,
95
97
userPk,
96
98
abi.encode (address (market), 0 )
97
99
);
@@ -103,7 +105,7 @@ abstract contract ALEBaseSDolaLPDynYearnV2Test is MarketForkTest {
103
105
104
106
// Calculate the amount of DOLA needed to borrow to buy the DBR needed to cover for the borrowing period
105
107
(uint256 dolaForDBR , uint256 dbrAmount ) = ale
106
- .approximateDolaAndDbrNeeded (maxBorrowAmount, 365 days, 8 );
108
+ .approximateDolaAndDbrNeeded (maxBorrowAmount, 15 days, 8 );
107
109
108
110
// Sign Message for borrow on behalf
109
111
bytes32 hash = keccak256 (
@@ -132,7 +134,7 @@ abstract contract ALEBaseSDolaLPDynYearnV2Test is MarketForkTest {
132
134
133
135
ALE.DBRHelper memory dbrData = ALE.DBRHelper (
134
136
dolaForDBR,
135
- (dbrAmount * 98 ) / 100 ,
137
+ (dbrAmount * 90 ) / 100 ,
136
138
0
137
139
);
138
140
@@ -155,18 +157,20 @@ abstract contract ALEBaseSDolaLPDynYearnV2Test is MarketForkTest {
155
157
156
158
assertEq (DOLA.balanceOf (userPk), 0 );
157
159
assertEq (vault.balanceOf (userPkEscrow), sharesAmount + sharesAdded);
158
- assertGt (dbr.balanceOf (userPk), (dbrAmount * 98 ) / 100 );
160
+ assertGt (dbr.balanceOf (userPk), (dbrAmount * 90 ) / 100 );
159
161
}
160
162
161
- function test_depositAndLeveragePosition_DOLA () public {
163
+ function test_depositAndLeveragePosition_DOLA (uint256 amount ) public {
164
+ vm.assume (amount > 0.0001 ether);
165
+ vm.assume (amount < 10000000 ether);
162
166
vm.prank (gov);
163
- DOLA.mint (userPk, 11000 ether );
164
- uint256 initialDolaDeposit = 1000 ether ;
167
+ DOLA.mint (userPk, amount );
168
+ uint256 initialDolaDeposit = amount / 10 ;
165
169
166
170
vm.startPrank (userPk, userPk);
167
- DOLA.approve (address (helper), 10000 ether );
171
+ DOLA.approve (address (helper), amount - initialDolaDeposit );
168
172
helper.transformToCollateralAndDeposit (
169
- 10000 ether ,
173
+ amount - initialDolaDeposit ,
170
174
userPk,
171
175
abi.encode (address (market), 0 )
172
176
);
@@ -231,18 +235,20 @@ abstract contract ALEBaseSDolaLPDynYearnV2Test is MarketForkTest {
231
235
assertEq (vault.balanceOf (userPkEscrow), sharesAmount + sharesAdded);
232
236
}
233
237
234
- function test_depositAndLeveragePosition_LP () public {
238
+ function test_depositAndLeveragePosition_LP (uint256 amount ) public {
239
+ vm.assume (amount > 0.0001 ether);
240
+ vm.assume (amount < 10000000 ether);
235
241
vm.prank (gov);
236
- DOLA.mint (userPk, 11000 ether );
237
-
242
+ DOLA.mint (userPk, amount );
243
+ uint256 initialDolaForShares = amount / 10 ;
238
244
vm.startPrank (userPk, userPk);
239
- DOLA.approve (address (helper), 11000 ether );
245
+ DOLA.approve (address (helper), amount );
240
246
uint256 initialSharesAmount = helper.transformToCollateral (
241
- 1000 ether ,
247
+ initialDolaForShares ,
242
248
abi.encode (address (market), 0 )
243
249
);
244
250
helper.transformToCollateralAndDeposit (
245
- 10000 ether ,
251
+ amount - initialDolaForShares ,
246
252
userPk,
247
253
abi.encode (address (market), 0 )
248
254
);
@@ -357,7 +363,6 @@ abstract contract ALEBaseSDolaLPDynYearnV2Test is MarketForkTest {
357
363
abi.encode (address (market), uint (0 )),
358
364
dbrData
359
365
);
360
-
361
366
assertEq (
362
367
vault.balanceOf (userPkEscrow),
363
368
totalSharesAmount - amountToWithdraw
@@ -449,10 +454,11 @@ abstract contract ALEBaseSDolaLPDynYearnV2Test is MarketForkTest {
449
454
uint256 sharesAmount = vault.balanceOf (userPkEscrow);
450
455
uint256 amountToWithdraw = sharesAmount / 2 ;
451
456
452
- uint256 dolaRedeemed = curvePool.calc_withdraw_one_coin (
457
+ uint256 sDolaRedeemed = curvePool.calc_withdraw_one_coin (
453
458
YearnVaultV2Helper.collateralToAsset (vault, amountToWithdraw),
454
- 0
459
+ 1
455
460
);
461
+ uint256 dolaRedeemed = sDOLA.convertToAssets (sDolaRedeemed);
456
462
uint256 debt = market.debts (address (userPk));
457
463
458
464
assertGt (debt, 0 );
0 commit comments