@@ -4,6 +4,7 @@ import { BigNumber as BN } from "ethers";
4
4
import { ethers } from "hardhat" ;
5
5
import moment from "moment" ;
6
6
7
+ import { getAccountSigners } from "../tasks/utils" ;
7
8
import {
8
9
CreditContractName ,
9
10
CreditManagerContractName ,
@@ -14,60 +15,15 @@ import {
14
15
import { CONSTANTS , LocalPoolName } from "../test/constants" ;
15
16
import { overrideFirstLossCoverConfig , toToken } from "../test/TestUtils" ;
16
17
import {
17
- Calendar ,
18
- CreditDueManager ,
19
18
CreditLine ,
20
19
CreditLineManager ,
21
- EpochManager ,
22
20
FirstLossCover ,
23
- HumaConfig ,
24
21
MockToken ,
25
- Pool ,
26
- PoolConfig ,
27
- PoolFeeManager ,
28
- PoolSafe ,
29
- Receivable ,
30
22
ReceivableBackedCreditLine ,
31
- RiskAdjustedTranchesPolicy ,
32
- TrancheVault ,
23
+ ReceivableBackedCreditLineManager ,
33
24
} from "../typechain-types" ;
34
25
import { advanceChainTime } from "./utils" ;
35
26
36
- let defaultDeployer : SignerWithAddress ,
37
- protocolOwner : SignerWithAddress ,
38
- treasury : SignerWithAddress ,
39
- sentinelServiceAccount : SignerWithAddress ;
40
- let poolOwner : SignerWithAddress ,
41
- poolOwnerTreasury : SignerWithAddress ,
42
- evaluationAgent : SignerWithAddress ,
43
- poolOperator : SignerWithAddress ;
44
- let juniorLender : SignerWithAddress ,
45
- seniorLender : SignerWithAddress ,
46
- lenderRedemptionActive : SignerWithAddress ,
47
- borrowerActive : SignerWithAddress ,
48
- borrowerApproved : SignerWithAddress ,
49
- borrowerNoAutopay : SignerWithAddress ,
50
- borrowerAutopayReady : SignerWithAddress ,
51
- borrowerLate : SignerWithAddress ,
52
- borrowerDefault : SignerWithAddress ;
53
-
54
- let humaConfigContract : HumaConfig , mockTokenContract : MockToken ;
55
- let poolConfigContract : PoolConfig ,
56
- poolFeeManagerContract : PoolFeeManager ,
57
- poolSafeContract : PoolSafe ,
58
- calendarContract : Calendar ,
59
- borrowerFirstLossCoverContract : FirstLossCover ,
60
- adminFirstLossCoverContract : FirstLossCover ,
61
- tranchesPolicyContract : RiskAdjustedTranchesPolicy ,
62
- poolContract : Pool ,
63
- epochManagerContract : EpochManager ,
64
- seniorTrancheVaultContract : TrancheVault ,
65
- juniorTrancheVaultContract : TrancheVault ,
66
- creditContract : CreditLine | ReceivableBackedCreditLine ,
67
- creditDueManagerContract : CreditDueManager ,
68
- creditManagerContract : CreditLineManager ,
69
- receivableContract : Receivable ;
70
-
71
27
const poolsToDeploy : {
72
28
creditContract : CreditContractName ;
73
29
manager : CreditManagerContractName ;
@@ -86,7 +42,12 @@ const poolsToDeploy: {
86
42
// Add more pools as needed
87
43
] ;
88
44
89
- async function depositFirstLossCover ( coverContract : FirstLossCover , account : SignerWithAddress ) {
45
+ async function depositFirstLossCover (
46
+ coverContract : FirstLossCover ,
47
+ mockTokenContract : MockToken ,
48
+ poolOwner : SignerWithAddress ,
49
+ account : SignerWithAddress ,
50
+ ) {
90
51
await coverContract . connect ( poolOwner ) . addCoverProvider ( account . address ) ;
91
52
await mockTokenContract
92
53
. connect ( account )
@@ -110,7 +71,7 @@ async function deployPool(
110
71
console . log ( `Pool name: ${ poolName } ` ) ;
111
72
}
112
73
console . log ( `Starting block timestamp: ${ await time . latest ( ) } ` ) ;
113
- [
74
+ const {
114
75
defaultDeployer,
115
76
protocolOwner,
116
77
treasury,
@@ -123,22 +84,17 @@ async function deployPool(
123
84
seniorLender,
124
85
lenderRedemptionActive,
125
86
borrowerActive,
126
- borrowerApproved ,
127
- borrowerNoAutopay ,
128
- borrowerAutopayReady ,
129
- borrowerLate ,
130
- borrowerDefault ,
131
- ] = await ethers . getSigners ( ) ;
87
+ } = await getAccountSigners ( ethers ) ;
132
88
133
89
console . log ( "Deploying and setting up protocol contracts" ) ;
134
- [ humaConfigContract , mockTokenContract ] = await deployProtocolContracts (
90
+ const [ humaConfigContract , mockTokenContract ] = await deployProtocolContracts (
135
91
protocolOwner ,
136
92
treasury ,
137
93
sentinelServiceAccount ,
138
94
poolOwner ,
139
95
) ;
140
96
141
- [
97
+ const [
142
98
poolConfigContract ,
143
99
poolFeeManagerContract ,
144
100
poolSafeContract ,
@@ -150,9 +106,9 @@ async function deployPool(
150
106
epochManagerContract ,
151
107
seniorTrancheVaultContract ,
152
108
juniorTrancheVaultContract ,
153
- creditContract as unknown ,
109
+ creditContract ,
154
110
creditDueManagerContract ,
155
- creditManagerContract as unknown ,
111
+ creditManagerContract ,
156
112
receivableContract ,
157
113
] = await deployAndSetupPoolContracts (
158
114
humaConfigContract ,
@@ -170,7 +126,12 @@ async function deployPool(
170
126
) ;
171
127
172
128
// Deposit first loss cover
173
- await depositFirstLossCover ( borrowerFirstLossCoverContract , borrowerActive ) ;
129
+ await depositFirstLossCover (
130
+ borrowerFirstLossCoverContract ,
131
+ mockTokenContract ,
132
+ poolOwner ,
133
+ borrowerActive ,
134
+ ) ;
174
135
175
136
// Set first loss cover liquidity cap
176
137
const totalAssetsBorrowerFLC = await borrowerFirstLossCoverContract . totalAssets ( ) ;
@@ -208,15 +169,17 @@ async function deployPool(
208
169
209
170
if ( poolName === LocalPoolName . CreditLine ) {
210
171
console . log ( "Drawing down from CreditLine" ) ;
211
- await creditManagerContract . connect ( evaluationAgent ) . approveBorrower (
212
- borrowerActive . address ,
213
- toToken ( 100_000 ) ,
214
- 5 , // numOfPeriods
215
- 1217 , // yieldInBps
216
- toToken ( 0 ) ,
217
- 0 ,
218
- true ,
219
- ) ;
172
+ await ( creditManagerContract as CreditLineManager )
173
+ . connect ( evaluationAgent )
174
+ . approveBorrower (
175
+ borrowerActive . address ,
176
+ toToken ( 100_000 ) ,
177
+ 5 , // numOfPeriods
178
+ 1217 , // yieldInBps
179
+ toToken ( 0 ) ,
180
+ 0 ,
181
+ true ,
182
+ ) ;
220
183
const borrowAmount = toToken ( 100_000 ) ;
221
184
222
185
// Drawing down credit line
@@ -244,16 +207,18 @@ async function deployPool(
244
207
lateFeeBps,
245
208
} ) ;
246
209
247
- console . log ( "Drawing down from CreditLine" ) ;
248
- await creditManagerContract . connect ( evaluationAgent ) . approveBorrower (
249
- borrowerActive . address ,
250
- toToken ( 100_000 ) ,
251
- 5 , // numOfPeriods
252
- 1217 , // yieldInBps
253
- toToken ( 0 ) ,
254
- 0 ,
255
- true ,
256
- ) ;
210
+ console . log ( "Drawing down from ReceivableBackedCreditLine" ) ;
211
+ await ( creditManagerContract as ReceivableBackedCreditLineManager )
212
+ . connect ( evaluationAgent )
213
+ . approveBorrower (
214
+ borrowerActive . address ,
215
+ toToken ( 100_000 ) ,
216
+ 5 , // numOfPeriods
217
+ 1217 , // yieldInBps
218
+ toToken ( 0 ) ,
219
+ 0 ,
220
+ true ,
221
+ ) ;
257
222
const borrowAmount = toToken ( 100_000 ) ;
258
223
259
224
const currentBlockTimestamp = await time . latest ( ) ;
@@ -285,8 +250,8 @@ async function deployPool(
285
250
console . log ( `Borrower: ${ borrowerActive . address } ` ) ;
286
251
console . log ( `Sentinel Service: ${ sentinelServiceAccount . address } ` ) ;
287
252
console . log ( `Pool owner: ${ poolOwner . address } ` ) ;
288
-
289
253
console . log ( "-------------------------------------" ) ;
254
+
290
255
console . log ( "Addresses:" ) ;
291
256
console . log ( `Pool: ${ poolContract . address } ` ) ;
292
257
console . log ( `Epoch manager: ${ epochManagerContract . address } ` ) ;
@@ -303,7 +268,6 @@ async function deployPool(
303
268
if ( poolName === LocalPoolName . ReceivableBackedCreditLine ) {
304
269
console . log ( `Receivable: ${ receivableContract . address } ` ) ;
305
270
}
306
-
307
271
console . log ( "=====================================" ) ;
308
272
}
309
273
0 commit comments