@@ -18,13 +18,26 @@ async function withdrawFromFLC(
18
18
}
19
19
}
20
20
21
+ async function withdrawFromTranche (
22
+ hre : HardhatRuntimeEnvironment ,
23
+ trancheVaultContractAddr : string ,
24
+ redemptionRequester : SignerWithAddress ,
25
+ ) : Promise < void > {
26
+ const TrancheVault = await hre . ethers . getContractFactory ( "TrancheVault" ) ;
27
+ const trancheVaultContract = TrancheVault . attach ( trancheVaultContractAddr ) ;
28
+ const tx = await trancheVaultContract
29
+ . connect ( redemptionRequester )
30
+ . withdrawAfterPoolClosure ( ) ;
31
+ await tx . wait ( ) ;
32
+ }
33
+
21
34
task (
22
- "withdrawFLCAndClosePool " ,
35
+ "withdrawAndClosePool " ,
23
36
"Submit withdrawal and redemption requests and prepare pool for closing" ,
24
37
)
25
38
. addParam (
26
39
"poolConfigAddr" ,
27
- "The address of the Pool Config whose epoch you wish to advance to next " ,
40
+ "The PoolConfig contract address of the pool in question " ,
28
41
)
29
42
. setAction ( async ( taskArgs : { poolConfigAddr : string } , hre : HardhatRuntimeEnvironment ) => {
30
43
console . log ( "Preparing pool for closing" ) ;
34
47
poolOwnerTreasury,
35
48
evaluationAgent,
36
49
borrowerActive,
50
+ juniorLender,
51
+ seniorLender
37
52
} = await getAccountSigners ( hre . ethers ) ;
38
53
39
54
const PoolConfig = await hre . ethers . getContractFactory ( "PoolConfig" ) ;
46
61
const affiliateFirstLossCoverContract = FirstLossCover . attach (
47
62
flcContracts [ CONSTANTS . ADMIN_LOSS_COVER_INDEX ] ,
48
63
) ;
49
-
50
- await poolConfigContract . connect ( poolOwner ) . setPoolOwnerRewardsAndLiquidity ( 0 , 0 ) ;
51
- await poolConfigContract . connect ( poolOwner ) . setEARewardsAndLiquidity ( 0 , 0 ) ;
52
64
53
65
console . log ( "Closing pool" ) ;
54
66
const Pool = await hre . ethers . getContractFactory ( "Pool" ) ;
60
72
await withdrawFromFLC ( affiliateFirstLossCoverContract , evaluationAgent ) ;
61
73
await withdrawFromFLC ( affiliateFirstLossCoverContract , treasury ) ;
62
74
await withdrawFromFLC ( affiliateFirstLossCoverContract , poolOwnerTreasury ) ;
75
+
76
+ console . log ( "Withdrawing from pool tranches" ) ;
77
+ const juniorTranche = await poolConfigContract . juniorTranche ( ) ;
78
+ const seniorTranche = await poolConfigContract . seniorTranche ( ) ;
79
+
80
+ // Debug logs
81
+ // const TrancheVault = await hre.ethers.getContractFactory("TrancheVault");
82
+ // const juniorTrancheContract = TrancheVault.attach(juniorTranche);
83
+ // const seniorTrancheContract = TrancheVault.attach(seniorTranche);
84
+ // console.log(await juniorTrancheContract.withdrawableAssets(juniorLender.address));
85
+ // console.log(await juniorTrancheContract.withdrawableAssets(poolOwnerTreasury.address));
86
+ // console.log(await juniorTrancheContract.withdrawableAssets(evaluationAgent.address));
87
+ // console.log(await juniorTrancheContract.withdrawableAssets(seniorLender.address));
88
+ // console.log(await juniorTrancheContract.withdrawableAssets(treasury.address));
89
+ // console.log(await seniorTrancheContract.withdrawableAssets(juniorLender.address));
90
+ // console.log(await seniorTrancheContract.withdrawableAssets(poolOwnerTreasury.address));
91
+ // console.log(await seniorTrancheContract.withdrawableAssets(evaluationAgent.address));
92
+ // console.log(await seniorTrancheContract.withdrawableAssets(seniorLender.address));
93
+ // console.log(await seniorTrancheContract.withdrawableAssets(treasury.address));
94
+
95
+ // Redeem from tranches
96
+ await withdrawFromTranche ( hre , juniorTranche , juniorLender ) ;
97
+ await withdrawFromTranche ( hre , juniorTranche , poolOwnerTreasury ) ;
98
+ await withdrawFromTranche ( hre , juniorTranche , evaluationAgent ) ;
99
+ await withdrawFromTranche ( hre , seniorTranche , seniorLender ) ;
100
+ await withdrawFromTranche ( hre , seniorTranche , poolOwnerTreasury ) ;
63
101
} ) ;
0 commit comments