@@ -43,7 +43,7 @@ forkOnlyDescribe("ForkTest: Morpho Compound Strategy", function () {
4343
4444 describe ( "Redeem" , function ( ) {
4545 it ( "Should redeem from Morpho" , async ( ) => {
46- const { vault, ousd, usdt, usdc, dai, anna } = fixture ;
46+ const { vault, ousd, usdt, usdc, dai, domen } = fixture ;
4747
4848 const supplyBeforeMint = await ousd . totalSupply ( ) ;
4949
@@ -52,21 +52,21 @@ forkOnlyDescribe("ForkTest: Morpho Compound Strategy", function () {
5252 // Mint with all three assets
5353 for ( const asset of [ usdt , usdc , dai ] ) {
5454 await vault
55- . connect ( anna )
55+ . connect ( domen )
5656 . mint ( asset . address , await units ( amount , asset ) , 0 ) ;
5757 }
5858
5959 const currentSupply = await ousd . totalSupply ( ) ;
6060 const supplyAdded = currentSupply . sub ( supplyBeforeMint ) ;
6161 expect ( supplyAdded ) . to . approxEqualTolerance ( ousdUnits ( "30000" ) , 1 ) ;
6262
63- const currentBalance = await ousd . connect ( anna ) . balanceOf ( anna . address ) ;
63+ const currentBalance = await ousd . connect ( domen ) . balanceOf ( domen . address ) ;
6464
6565 // Now try to redeem 30k
66- await vault . connect ( anna ) . redeem ( ousdUnits ( "30000" ) , 0 ) ;
66+ await vault . connect ( domen ) . redeem ( ousdUnits ( "30000" ) , 0 ) ;
6767
6868 // User balance should be down by 30k
69- const newBalance = await ousd . connect ( anna ) . balanceOf ( anna . address ) ;
69+ const newBalance = await ousd . connect ( domen ) . balanceOf ( domen . address ) ;
7070 expect ( newBalance ) . to . approxEqualTolerance (
7171 currentBalance . sub ( ousdUnits ( "30000" ) ) ,
7272 1
@@ -79,96 +79,100 @@ forkOnlyDescribe("ForkTest: Morpho Compound Strategy", function () {
7979 } ) ;
8080 } ) ;
8181
82- it ( "Should be able to harvest rewards" , async function ( ) {
83- const {
84- harvester,
85- daniel,
86- anna,
87- usdc,
88- cusdc,
89- usdt,
90- morphoLens,
91- morphoCompoundStrategy,
92- dripper,
93- } = fixture ;
94- await mintTest ( fixture , anna , usdc , "110000" ) ;
95-
96- // harvester always exchanges for USDT and parks the funds in the dripper
97- const usdtBalanceDiff = await differenceInErc20TokenBalance (
98- dripper . address ,
99- usdt ,
100- async ( ) => {
101- // advance time so that some rewards accrue
102- await advanceTime ( 3600 * 24 * 100 ) ;
103- await advanceBlocks ( 10000 ) ;
104- // check that rewards are there
105- await expect (
106- await morphoLens . getUserUnclaimedRewards (
107- [ cusdc . address ] ,
108- morphoCompoundStrategy . address
109- )
110- ) . to . be . gte ( 0 ) ;
111- // prettier-ignore
112- await harvester
113- . connect ( daniel ) [ "harvestAndSwap(address)" ] ( morphoCompoundStrategy . address ) ;
114- }
115- ) ;
82+ describe ( "Rewards" , function ( ) {
83+ it ( "Should be able to harvest rewards" , async function ( ) {
84+ const {
85+ harvester,
86+ daniel,
87+ anna,
88+ usdc,
89+ cusdc,
90+ usdt,
91+ morphoLens,
92+ morphoCompoundStrategy,
93+ dripper,
94+ } = fixture ;
95+ await mintTest ( fixture , anna , usdc , "110000" ) ;
96+
97+ // harvester always exchanges for USDT and parks the funds in the dripper
98+ const usdtBalanceDiff = await differenceInErc20TokenBalance (
99+ dripper . address ,
100+ usdt ,
101+ async ( ) => {
102+ // advance time so that some rewards accrue
103+ await advanceTime ( 3600 * 24 * 100 ) ;
104+ await advanceBlocks ( 10000 ) ;
105+ // check that rewards are there
106+ await expect (
107+ await morphoLens . getUserUnclaimedRewards (
108+ [ cusdc . address ] ,
109+ morphoCompoundStrategy . address
110+ )
111+ ) . to . be . gte ( 0 ) ;
112+ // prettier-ignore
113+ await harvester
114+ . connect ( daniel ) [ "harvestAndSwap(address)" ] ( morphoCompoundStrategy . address ) ;
115+ }
116+ ) ;
116117
117- await expect ( usdtBalanceDiff ) . to . be . gte ( 0 ) ;
118+ await expect ( usdtBalanceDiff ) . to . be . gte ( 0 ) ;
119+ } ) ;
118120 } ) ;
119121
120- it ( "Should be able to withdraw from strategy" , async function ( ) {
121- const { matt, usdc, vault, morphoCompoundStrategy } = fixture ;
122- const amount = "110000" ;
123- await mintTest ( fixture , matt , usdc , amount ) ;
122+ describe ( "Withdraw" , function ( ) {
123+ it ( "Should be able to withdraw from strategy" , async function ( ) {
124+ const { matt, usdc, vault, morphoCompoundStrategy } = fixture ;
125+ const amount = "110000" ;
126+ await mintTest ( fixture , matt , usdc , amount ) ;
124127
125- const usdcUnits = await units ( amount , usdc ) ;
126- const vaultUsdcBefore = await usdc . balanceOf ( vault . address ) ;
127- const vaultSigner = await impersonateAndFundContract ( vault . address ) ;
128+ const usdcUnits = await units ( amount , usdc ) ;
129+ const vaultUsdcBefore = await usdc . balanceOf ( vault . address ) ;
130+ const vaultSigner = await impersonateAndFundContract ( vault . address ) ;
128131
129- await morphoCompoundStrategy
130- . connect ( vaultSigner )
131- . withdraw ( vault . address , usdc . address , usdcUnits ) ;
132- const vaultUsdcDiff =
133- ( await usdc . balanceOf ( vault . address ) ) - vaultUsdcBefore ;
132+ await morphoCompoundStrategy
133+ . connect ( vaultSigner )
134+ . withdraw ( vault . address , usdc . address , usdcUnits ) ;
135+ const vaultUsdcDiff =
136+ ( await usdc . balanceOf ( vault . address ) ) - vaultUsdcBefore ;
134137
135- expect ( vaultUsdcDiff ) . to . approxEqualTolerance ( usdcUnits , 1 ) ;
136- } ) ;
138+ expect ( vaultUsdcDiff ) . to . approxEqualTolerance ( usdcUnits , 1 ) ;
139+ } ) ;
137140
138- it ( "Should be able to withdrawAll from strategy" , async function ( ) {
139- const { matt, usdc, vault, usdt, morphoCompoundStrategy } = fixture ;
140- const vaultSigner = await impersonateAndFundContract ( vault . address ) ;
141- const amount = "110000" ;
141+ it ( "Should be able to withdrawAll from strategy" , async function ( ) {
142+ const { matt, usdc, vault, usdt, morphoCompoundStrategy } = fixture ;
143+ const vaultSigner = await impersonateAndFundContract ( vault . address ) ;
144+ const amount = "110000" ;
142145
143- const removeFundsFromVault = async ( ) => {
144- await usdc
145- . connect ( vaultSigner )
146- . transfer ( matt . address , usdc . balanceOf ( vault . address ) ) ;
147- await usdt
148- . connect ( vaultSigner )
149- . transfer ( matt . address , usdt . balanceOf ( vault . address ) ) ;
150- } ;
146+ const removeFundsFromVault = async ( ) => {
147+ await usdc
148+ . connect ( vaultSigner )
149+ . transfer ( matt . address , usdc . balanceOf ( vault . address ) ) ;
150+ await usdt
151+ . connect ( vaultSigner )
152+ . transfer ( matt . address , usdt . balanceOf ( vault . address ) ) ;
153+ } ;
151154
152- // remove funds so no residual funds get allocated
153- await removeFundsFromVault ( ) ;
155+ // remove funds so no residual funds get allocated
156+ await removeFundsFromVault ( ) ;
154157
155- await mintTest ( fixture , matt , usdc , amount ) ;
156- await mintTest ( fixture , matt , usdt , amount ) ;
158+ await mintTest ( fixture , matt , usdc , amount ) ;
159+ await mintTest ( fixture , matt , usdt , amount ) ;
157160
158- const usdcUnits = await units ( amount , usdc ) ;
159- const usdtUnits = await units ( amount , usdt ) ;
160- const vaultUsdtBefore = await usdt . balanceOf ( vault . address ) ;
161- const vaultUsdcBefore = await usdc . balanceOf ( vault . address ) ;
161+ const usdcUnits = await units ( amount , usdc ) ;
162+ const usdtUnits = await units ( amount , usdt ) ;
163+ const vaultUsdtBefore = await usdt . balanceOf ( vault . address ) ;
164+ const vaultUsdcBefore = await usdc . balanceOf ( vault . address ) ;
162165
163- await morphoCompoundStrategy . connect ( vaultSigner ) . withdrawAll ( ) ;
166+ await morphoCompoundStrategy . connect ( vaultSigner ) . withdrawAll ( ) ;
164167
165- const vaultUsdtDiff =
166- ( await usdt . balanceOf ( vault . address ) ) - vaultUsdtBefore ;
167- const vaultUsdcDiff =
168- ( await usdc . balanceOf ( vault . address ) ) - vaultUsdcBefore ;
168+ const vaultUsdtDiff =
169+ ( await usdt . balanceOf ( vault . address ) ) - vaultUsdtBefore ;
170+ const vaultUsdcDiff =
171+ ( await usdc . balanceOf ( vault . address ) ) - vaultUsdcBefore ;
169172
170- expect ( vaultUsdcDiff ) . to . approxEqualTolerance ( usdcUnits , 1 ) ;
171- expect ( vaultUsdtDiff ) . to . approxEqualTolerance ( usdtUnits , 1 ) ;
173+ expect ( vaultUsdcDiff ) . to . approxEqualTolerance ( usdcUnits , 1 ) ;
174+ expect ( vaultUsdtDiff ) . to . approxEqualTolerance ( usdtUnits , 1 ) ;
175+ } ) ;
172176 } ) ;
173177} ) ;
174178
0 commit comments