@ensuro/core 2.8.1 → 2.8.3
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/build/contracts/AccessManager.sol/AccessManager.json +618 -0
- package/build/contracts/ERC4626AssetManager.sol/ERC4626AssetManager.json +238 -0
- package/build/contracts/ERC4626PlusVaultAssetManager.sol/ERC4626PlusVaultAssetManager.json +269 -0
- package/build/contracts/EToken.sol/EToken.json +1287 -0
- package/build/contracts/LPManualWhitelist.sol/LPManualWhitelist.json +657 -0
- package/build/contracts/LiquidityThresholdAssetManager.sol/LiquidityThresholdAssetManager.json +222 -0
- package/build/contracts/Policy.sol/Policy.json +10 -0
- package/build/contracts/PolicyPool.sol/PolicyPool.json +1775 -0
- package/build/contracts/PolicyPoolComponent.sol/PolicyPoolComponent.json +342 -0
- package/build/contracts/PremiumsAccount.sol/PremiumsAccount.json +1142 -0
- package/build/contracts/Reserve.sol/Reserve.json +413 -0
- package/build/contracts/RiskModule.sol/RiskModule.json +589 -0
- package/build/contracts/SignedBucketRiskModule.sol/SignedBucketRiskModule.json +1251 -0
- package/build/contracts/SignedQuoteRiskModule.sol/SignedQuoteRiskModule.json +1145 -0
- package/build/contracts/TimeScaled.sol/TimeScaled.json +10 -0
- package/build/contracts/TrustfulRiskModule.sol/TrustfulRiskModule.json +1143 -0
- package/build/contracts/dependencies/WadRayMath.sol/WadRayMath.json +10 -0
- package/build/contracts/interfaces/IAccessManager.sol/IAccessManager.json +343 -0
- package/build/contracts/interfaces/IAssetManager.sol/IAssetManager.json +128 -0
- package/build/contracts/interfaces/IEToken.sol/IEToken.json +460 -0
- package/build/contracts/interfaces/ILPWhitelist.sol/ILPWhitelist.json +103 -0
- package/build/contracts/interfaces/IPolicyHolder.sol/IPolicyHolder.json +108 -0
- package/build/contracts/interfaces/IPolicyHolderV2.sol/IPolicyHolderV2.json +142 -0
- package/build/contracts/interfaces/IPolicyPool.sol/IPolicyPool.json +820 -0
- package/build/contracts/interfaces/IPolicyPoolComponent.sol/IPolicyPoolComponent.json +43 -0
- package/build/contracts/interfaces/IPremiumsAccount.sol/IPremiumsAccount.json +477 -0
- package/build/contracts/interfaces/IRiskModule.sol/IRiskModule.json +165 -0
- package/build/contracts/migration/LPManualWhitelistV20.sol/LPManualWhitelistV20.json +491 -0
- package/build/contracts/migration/LPManualWhitelistV20Upgraded.sol/LPManualWhitelistV20Upgraded.json +502 -0
- package/build/contracts/mocks/FixedRateVault.sol/FixedRateVault.json +736 -0
- package/build/contracts/mocks/ForwardProxy.sol/ForwardProxy.json +43 -0
- package/build/contracts/mocks/IMintableERC20.sol/IMintableERC20.json +47 -0
- package/build/contracts/mocks/InterfaceIdCalculator.sol/InterfaceIdCalculator.json +193 -0
- package/build/contracts/mocks/PolicyHolderMock.sol/PolicyHolderMock.json +457 -0
- package/build/contracts/mocks/PolicyPoolComponentMock.sol/PolicyPoolComponentMock.json +54 -0
- package/build/contracts/mocks/PolicyPoolMock.sol/PolicyPoolMock.json +929 -0
- package/build/contracts/mocks/PolicyPoolMock.sol/PolicyPoolMockForward.json +92 -0
- package/build/contracts/mocks/RiskModuleMock.sol/RiskModuleMock.json +1316 -0
- package/build/contracts/mocks/TestCurrency.sol/TestCurrency.json +343 -0
- package/build/contracts/mocks/TestNFT.sol/TestNFT.json +388 -0
- package/contracts/ERC4626AssetManager.sol +6 -5
- package/contracts/ERC4626PlusVaultAssetManager.sol +105 -0
- package/js/deploy.js +6 -25
- package/package.json +3 -5
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_format": "hh-sol-artifact-1",
|
|
3
|
+
"contractName": "TestNFT",
|
|
4
|
+
"sourceName": "contracts/mocks/TestNFT.sol",
|
|
5
|
+
"abi": [
|
|
6
|
+
{
|
|
7
|
+
"inputs": [
|
|
8
|
+
{
|
|
9
|
+
"internalType": "string",
|
|
10
|
+
"name": "name_",
|
|
11
|
+
"type": "string"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"internalType": "string",
|
|
15
|
+
"name": "symbol_",
|
|
16
|
+
"type": "string"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"stateMutability": "nonpayable",
|
|
20
|
+
"type": "constructor"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"anonymous": false,
|
|
24
|
+
"inputs": [
|
|
25
|
+
{
|
|
26
|
+
"indexed": true,
|
|
27
|
+
"internalType": "address",
|
|
28
|
+
"name": "owner",
|
|
29
|
+
"type": "address"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"indexed": true,
|
|
33
|
+
"internalType": "address",
|
|
34
|
+
"name": "approved",
|
|
35
|
+
"type": "address"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"indexed": true,
|
|
39
|
+
"internalType": "uint256",
|
|
40
|
+
"name": "tokenId",
|
|
41
|
+
"type": "uint256"
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"name": "Approval",
|
|
45
|
+
"type": "event"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"anonymous": false,
|
|
49
|
+
"inputs": [
|
|
50
|
+
{
|
|
51
|
+
"indexed": true,
|
|
52
|
+
"internalType": "address",
|
|
53
|
+
"name": "owner",
|
|
54
|
+
"type": "address"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"indexed": true,
|
|
58
|
+
"internalType": "address",
|
|
59
|
+
"name": "operator",
|
|
60
|
+
"type": "address"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"indexed": false,
|
|
64
|
+
"internalType": "bool",
|
|
65
|
+
"name": "approved",
|
|
66
|
+
"type": "bool"
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"name": "ApprovalForAll",
|
|
70
|
+
"type": "event"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"anonymous": false,
|
|
74
|
+
"inputs": [
|
|
75
|
+
{
|
|
76
|
+
"indexed": true,
|
|
77
|
+
"internalType": "address",
|
|
78
|
+
"name": "from",
|
|
79
|
+
"type": "address"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"indexed": true,
|
|
83
|
+
"internalType": "address",
|
|
84
|
+
"name": "to",
|
|
85
|
+
"type": "address"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"indexed": true,
|
|
89
|
+
"internalType": "uint256",
|
|
90
|
+
"name": "tokenId",
|
|
91
|
+
"type": "uint256"
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
"name": "Transfer",
|
|
95
|
+
"type": "event"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"inputs": [
|
|
99
|
+
{
|
|
100
|
+
"internalType": "address",
|
|
101
|
+
"name": "to",
|
|
102
|
+
"type": "address"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"internalType": "uint256",
|
|
106
|
+
"name": "tokenId",
|
|
107
|
+
"type": "uint256"
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
"name": "approve",
|
|
111
|
+
"outputs": [],
|
|
112
|
+
"stateMutability": "nonpayable",
|
|
113
|
+
"type": "function"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"inputs": [
|
|
117
|
+
{
|
|
118
|
+
"internalType": "address",
|
|
119
|
+
"name": "owner",
|
|
120
|
+
"type": "address"
|
|
121
|
+
}
|
|
122
|
+
],
|
|
123
|
+
"name": "balanceOf",
|
|
124
|
+
"outputs": [
|
|
125
|
+
{
|
|
126
|
+
"internalType": "uint256",
|
|
127
|
+
"name": "",
|
|
128
|
+
"type": "uint256"
|
|
129
|
+
}
|
|
130
|
+
],
|
|
131
|
+
"stateMutability": "view",
|
|
132
|
+
"type": "function"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"inputs": [
|
|
136
|
+
{
|
|
137
|
+
"internalType": "uint256",
|
|
138
|
+
"name": "tokenId",
|
|
139
|
+
"type": "uint256"
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
"name": "burn",
|
|
143
|
+
"outputs": [],
|
|
144
|
+
"stateMutability": "nonpayable",
|
|
145
|
+
"type": "function"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"inputs": [
|
|
149
|
+
{
|
|
150
|
+
"internalType": "uint256",
|
|
151
|
+
"name": "tokenId",
|
|
152
|
+
"type": "uint256"
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
"name": "getApproved",
|
|
156
|
+
"outputs": [
|
|
157
|
+
{
|
|
158
|
+
"internalType": "address",
|
|
159
|
+
"name": "",
|
|
160
|
+
"type": "address"
|
|
161
|
+
}
|
|
162
|
+
],
|
|
163
|
+
"stateMutability": "view",
|
|
164
|
+
"type": "function"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"inputs": [
|
|
168
|
+
{
|
|
169
|
+
"internalType": "address",
|
|
170
|
+
"name": "owner",
|
|
171
|
+
"type": "address"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"internalType": "address",
|
|
175
|
+
"name": "operator",
|
|
176
|
+
"type": "address"
|
|
177
|
+
}
|
|
178
|
+
],
|
|
179
|
+
"name": "isApprovedForAll",
|
|
180
|
+
"outputs": [
|
|
181
|
+
{
|
|
182
|
+
"internalType": "bool",
|
|
183
|
+
"name": "",
|
|
184
|
+
"type": "bool"
|
|
185
|
+
}
|
|
186
|
+
],
|
|
187
|
+
"stateMutability": "view",
|
|
188
|
+
"type": "function"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"inputs": [
|
|
192
|
+
{
|
|
193
|
+
"internalType": "address",
|
|
194
|
+
"name": "recipient",
|
|
195
|
+
"type": "address"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"internalType": "uint256",
|
|
199
|
+
"name": "tokenId",
|
|
200
|
+
"type": "uint256"
|
|
201
|
+
}
|
|
202
|
+
],
|
|
203
|
+
"name": "mint",
|
|
204
|
+
"outputs": [],
|
|
205
|
+
"stateMutability": "nonpayable",
|
|
206
|
+
"type": "function"
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"inputs": [],
|
|
210
|
+
"name": "name",
|
|
211
|
+
"outputs": [
|
|
212
|
+
{
|
|
213
|
+
"internalType": "string",
|
|
214
|
+
"name": "",
|
|
215
|
+
"type": "string"
|
|
216
|
+
}
|
|
217
|
+
],
|
|
218
|
+
"stateMutability": "view",
|
|
219
|
+
"type": "function"
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"inputs": [
|
|
223
|
+
{
|
|
224
|
+
"internalType": "uint256",
|
|
225
|
+
"name": "tokenId",
|
|
226
|
+
"type": "uint256"
|
|
227
|
+
}
|
|
228
|
+
],
|
|
229
|
+
"name": "ownerOf",
|
|
230
|
+
"outputs": [
|
|
231
|
+
{
|
|
232
|
+
"internalType": "address",
|
|
233
|
+
"name": "",
|
|
234
|
+
"type": "address"
|
|
235
|
+
}
|
|
236
|
+
],
|
|
237
|
+
"stateMutability": "view",
|
|
238
|
+
"type": "function"
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"inputs": [
|
|
242
|
+
{
|
|
243
|
+
"internalType": "address",
|
|
244
|
+
"name": "from",
|
|
245
|
+
"type": "address"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"internalType": "address",
|
|
249
|
+
"name": "to",
|
|
250
|
+
"type": "address"
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
"internalType": "uint256",
|
|
254
|
+
"name": "tokenId",
|
|
255
|
+
"type": "uint256"
|
|
256
|
+
}
|
|
257
|
+
],
|
|
258
|
+
"name": "safeTransferFrom",
|
|
259
|
+
"outputs": [],
|
|
260
|
+
"stateMutability": "nonpayable",
|
|
261
|
+
"type": "function"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"inputs": [
|
|
265
|
+
{
|
|
266
|
+
"internalType": "address",
|
|
267
|
+
"name": "from",
|
|
268
|
+
"type": "address"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
"internalType": "address",
|
|
272
|
+
"name": "to",
|
|
273
|
+
"type": "address"
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
"internalType": "uint256",
|
|
277
|
+
"name": "tokenId",
|
|
278
|
+
"type": "uint256"
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
"internalType": "bytes",
|
|
282
|
+
"name": "data",
|
|
283
|
+
"type": "bytes"
|
|
284
|
+
}
|
|
285
|
+
],
|
|
286
|
+
"name": "safeTransferFrom",
|
|
287
|
+
"outputs": [],
|
|
288
|
+
"stateMutability": "nonpayable",
|
|
289
|
+
"type": "function"
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
"inputs": [
|
|
293
|
+
{
|
|
294
|
+
"internalType": "address",
|
|
295
|
+
"name": "operator",
|
|
296
|
+
"type": "address"
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
"internalType": "bool",
|
|
300
|
+
"name": "approved",
|
|
301
|
+
"type": "bool"
|
|
302
|
+
}
|
|
303
|
+
],
|
|
304
|
+
"name": "setApprovalForAll",
|
|
305
|
+
"outputs": [],
|
|
306
|
+
"stateMutability": "nonpayable",
|
|
307
|
+
"type": "function"
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
"inputs": [
|
|
311
|
+
{
|
|
312
|
+
"internalType": "bytes4",
|
|
313
|
+
"name": "interfaceId",
|
|
314
|
+
"type": "bytes4"
|
|
315
|
+
}
|
|
316
|
+
],
|
|
317
|
+
"name": "supportsInterface",
|
|
318
|
+
"outputs": [
|
|
319
|
+
{
|
|
320
|
+
"internalType": "bool",
|
|
321
|
+
"name": "",
|
|
322
|
+
"type": "bool"
|
|
323
|
+
}
|
|
324
|
+
],
|
|
325
|
+
"stateMutability": "view",
|
|
326
|
+
"type": "function"
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
"inputs": [],
|
|
330
|
+
"name": "symbol",
|
|
331
|
+
"outputs": [
|
|
332
|
+
{
|
|
333
|
+
"internalType": "string",
|
|
334
|
+
"name": "",
|
|
335
|
+
"type": "string"
|
|
336
|
+
}
|
|
337
|
+
],
|
|
338
|
+
"stateMutability": "view",
|
|
339
|
+
"type": "function"
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
"inputs": [
|
|
343
|
+
{
|
|
344
|
+
"internalType": "uint256",
|
|
345
|
+
"name": "tokenId",
|
|
346
|
+
"type": "uint256"
|
|
347
|
+
}
|
|
348
|
+
],
|
|
349
|
+
"name": "tokenURI",
|
|
350
|
+
"outputs": [
|
|
351
|
+
{
|
|
352
|
+
"internalType": "string",
|
|
353
|
+
"name": "",
|
|
354
|
+
"type": "string"
|
|
355
|
+
}
|
|
356
|
+
],
|
|
357
|
+
"stateMutability": "view",
|
|
358
|
+
"type": "function"
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
"inputs": [
|
|
362
|
+
{
|
|
363
|
+
"internalType": "address",
|
|
364
|
+
"name": "from",
|
|
365
|
+
"type": "address"
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
"internalType": "address",
|
|
369
|
+
"name": "to",
|
|
370
|
+
"type": "address"
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
"internalType": "uint256",
|
|
374
|
+
"name": "tokenId",
|
|
375
|
+
"type": "uint256"
|
|
376
|
+
}
|
|
377
|
+
],
|
|
378
|
+
"name": "transferFrom",
|
|
379
|
+
"outputs": [],
|
|
380
|
+
"stateMutability": "nonpayable",
|
|
381
|
+
"type": "function"
|
|
382
|
+
}
|
|
383
|
+
],
|
|
384
|
+
"bytecode": "0x60806040523480156200001157600080fd5b50604051620016eb380380620016eb833981016040819052620000349162000136565b818160006200004483826200022f565b5060016200005382826200022f565b5050600680546001600160a01b0319163317905550620002fb915050565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200009957600080fd5b81516001600160401b0380821115620000b657620000b662000071565b604051601f8301601f19908116603f01168101908282118183101715620000e157620000e162000071565b81604052838152602092508683858801011115620000fe57600080fd5b600091505b8382101562000122578582018301518183018401529082019062000103565b600093810190920192909252949350505050565b600080604083850312156200014a57600080fd5b82516001600160401b03808211156200016257600080fd5b620001708683870162000087565b935060208501519150808211156200018757600080fd5b50620001968582860162000087565b9150509250929050565b600181811c90821680620001b557607f821691505b602082108103620001d657634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200022a57600081815260208120601f850160051c81016020861015620002055750805b601f850160051c820191505b81811015620002265782815560010162000211565b5050505b505050565b81516001600160401b038111156200024b576200024b62000071565b62000263816200025c8454620001a0565b84620001dc565b602080601f8311600181146200029b5760008415620002825750858301515b600019600386901b1c1916600185901b17855562000226565b600085815260208120601f198616915b82811015620002cc57888601518255948401946001909101908401620002ab565b5085821015620002eb5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6113e0806200030b6000396000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c806342966c6811610097578063a22cb46511610066578063a22cb465146101ff578063b88d4fde14610212578063c87b56dd14610225578063e985e9c51461023857600080fd5b806342966c68146101b05780636352211e146101c357806370a08231146101d657806395d89b41146101f757600080fd5b8063095ea7b3116100d3578063095ea7b31461016257806323b872dd1461017757806340c10f191461018a57806342842e0e1461019d57600080fd5b806301ffc9a7146100fa57806306fdde0314610122578063081812fc14610137575b600080fd5b61010d610108366004610f6c565b610274565b60405190151581526020015b60405180910390f35b61012a6102c6565b6040516101199190610fd9565b61014a610145366004610fec565b610358565b6040516001600160a01b039091168152602001610119565b610175610170366004611021565b61037f565b005b61017561018536600461104b565b610499565b610175610198366004611021565b6104ca565b6101756101ab36600461104b565b6104d8565b6101756101be366004610fec565b6104f3565b61014a6101d1366004610fec565b61056d565b6101e96101e4366004611087565b6105cd565b604051908152602001610119565b61012a610653565b61017561020d3660046110a2565b610662565b6101756102203660046110f4565b61066d565b61012a610233366004610fec565b6106a5565b61010d6102463660046111d0565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b60006001600160e01b031982166380ac58cd60e01b14806102a557506001600160e01b03198216635b5e139f60e01b145b806102c057506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600080546102d590611203565b80601f016020809104026020016040519081016040528092919081815260200182805461030190611203565b801561034e5780601f106103235761010080835404028352916020019161034e565b820191906000526020600020905b81548152906001019060200180831161033157829003601f168201915b5050505050905090565b600061036382610719565b506000908152600460205260409020546001600160a01b031690565b600061038a8261056d565b9050806001600160a01b0316836001600160a01b0316036103fc5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b038216148061041857506104188133610246565b61048a5760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c00000060648201526084016103f3565b6104948383610778565b505050565b6104a333826107e6565b6104bf5760405162461bcd60e51b81526004016103f39061123d565b610494838383610865565b6104d482826109c9565b5050565b6104948383836040518060200160405280600081525061066d565b336104fd8261056d565b6001600160a01b0316146105615760405162461bcd60e51b815260206004820152602560248201527f4552433732313a206275726e206f6620746f6b656e2074686174206973206e6f6044820152643a1037bbb760d91b60648201526084016103f3565b61056a81610b54565b50565b6000818152600260205260408120546001600160a01b0316806102c05760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b60448201526064016103f3565b60006001600160a01b0382166106375760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b60648201526084016103f3565b506001600160a01b031660009081526003602052604090205490565b6060600180546102d590611203565b6104d4338383610be9565b61067733836107e6565b6106935760405162461bcd60e51b81526004016103f39061123d565b61069f84848484610cb7565b50505050565b60606106b082610719565b60006106c760408051602081019091526000815290565b905060008151116106e75760405180602001604052806000815250610712565b806106f184610cea565b60405160200161070292919061128a565b6040516020818303038152906040525b9392505050565b6000818152600260205260409020546001600160a01b031661056a5760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b60448201526064016103f3565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906107ad8261056d565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000806107f28361056d565b9050806001600160a01b0316846001600160a01b0316148061083957506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b8061085d5750836001600160a01b031661085284610358565b6001600160a01b0316145b949350505050565b826001600160a01b03166108788261056d565b6001600160a01b03161461089e5760405162461bcd60e51b81526004016103f3906112b9565b6001600160a01b0382166109005760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016103f3565b826001600160a01b03166109138261056d565b6001600160a01b0316146109395760405162461bcd60e51b81526004016103f3906112b9565b600081815260046020908152604080832080546001600160a01b03199081169091556001600160a01b0387811680865260038552838620805460001901905590871680865283862080546001019055868652600290945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6001600160a01b038216610a1f5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016103f3565b6000818152600260205260409020546001600160a01b031615610a845760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016103f3565b6000818152600260205260409020546001600160a01b031615610ae95760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016103f3565b6001600160a01b038216600081815260036020908152604080832080546001019055848352600290915280822080546001600160a01b0319168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6000610b5f8261056d565b9050610b6a8261056d565b600083815260046020908152604080832080546001600160a01b03199081169091556001600160a01b0385168085526003845282852080546000190190558785526002909352818420805490911690555192935084927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b816001600160a01b0316836001600160a01b031603610c4a5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016103f3565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b610cc2848484610865565b610cce84848484610d7d565b61069f5760405162461bcd60e51b81526004016103f3906112fe565b60606000610cf783610e7e565b600101905060008167ffffffffffffffff811115610d1757610d176110de565b6040519080825280601f01601f191660200182016040528015610d41576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084610d4b57509392505050565b60006001600160a01b0384163b15610e7357604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290610dc1903390899088908890600401611350565b6020604051808303816000875af1925050508015610dfc575060408051601f3d908101601f19168201909252610df99181019061138d565b60015b610e59573d808015610e2a576040519150601f19603f3d011682016040523d82523d6000602084013e610e2f565b606091505b508051600003610e515760405162461bcd60e51b81526004016103f3906112fe565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061085d565b506001949350505050565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310610ebd5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310610ee9576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310610f0757662386f26fc10000830492506010015b6305f5e1008310610f1f576305f5e100830492506008015b6127108310610f3357612710830492506004015b60648310610f45576064830492506002015b600a83106102c05760010192915050565b6001600160e01b03198116811461056a57600080fd5b600060208284031215610f7e57600080fd5b813561071281610f56565b60005b83811015610fa4578181015183820152602001610f8c565b50506000910152565b60008151808452610fc5816020860160208601610f89565b601f01601f19169290920160200192915050565b6020815260006107126020830184610fad565b600060208284031215610ffe57600080fd5b5035919050565b80356001600160a01b038116811461101c57600080fd5b919050565b6000806040838503121561103457600080fd5b61103d83611005565b946020939093013593505050565b60008060006060848603121561106057600080fd5b61106984611005565b925061107760208501611005565b9150604084013590509250925092565b60006020828403121561109957600080fd5b61071282611005565b600080604083850312156110b557600080fd5b6110be83611005565b9150602083013580151581146110d357600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b6000806000806080858703121561110a57600080fd5b61111385611005565b935061112160208601611005565b925060408501359150606085013567ffffffffffffffff8082111561114557600080fd5b818701915087601f83011261115957600080fd5b81358181111561116b5761116b6110de565b604051601f8201601f19908116603f01168101908382118183101715611193576111936110de565b816040528281528a60208487010111156111ac57600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b600080604083850312156111e357600080fd5b6111ec83611005565b91506111fa60208401611005565b90509250929050565b600181811c9082168061121757607f821691505b60208210810361123757634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b6000835161129c818460208801610f89565b8351908301906112b0818360208801610f89565b01949350505050565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061138390830184610fad565b9695505050505050565b60006020828403121561139f57600080fd5b815161071281610f5656fea264697066735822122032e948b2b08ed23fad1436490d9de8e4837b9f460507f13c2e7e469d771dd0f264736f6c63430008100033",
|
|
385
|
+
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806342966c6811610097578063a22cb46511610066578063a22cb465146101ff578063b88d4fde14610212578063c87b56dd14610225578063e985e9c51461023857600080fd5b806342966c68146101b05780636352211e146101c357806370a08231146101d657806395d89b41146101f757600080fd5b8063095ea7b3116100d3578063095ea7b31461016257806323b872dd1461017757806340c10f191461018a57806342842e0e1461019d57600080fd5b806301ffc9a7146100fa57806306fdde0314610122578063081812fc14610137575b600080fd5b61010d610108366004610f6c565b610274565b60405190151581526020015b60405180910390f35b61012a6102c6565b6040516101199190610fd9565b61014a610145366004610fec565b610358565b6040516001600160a01b039091168152602001610119565b610175610170366004611021565b61037f565b005b61017561018536600461104b565b610499565b610175610198366004611021565b6104ca565b6101756101ab36600461104b565b6104d8565b6101756101be366004610fec565b6104f3565b61014a6101d1366004610fec565b61056d565b6101e96101e4366004611087565b6105cd565b604051908152602001610119565b61012a610653565b61017561020d3660046110a2565b610662565b6101756102203660046110f4565b61066d565b61012a610233366004610fec565b6106a5565b61010d6102463660046111d0565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b60006001600160e01b031982166380ac58cd60e01b14806102a557506001600160e01b03198216635b5e139f60e01b145b806102c057506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600080546102d590611203565b80601f016020809104026020016040519081016040528092919081815260200182805461030190611203565b801561034e5780601f106103235761010080835404028352916020019161034e565b820191906000526020600020905b81548152906001019060200180831161033157829003601f168201915b5050505050905090565b600061036382610719565b506000908152600460205260409020546001600160a01b031690565b600061038a8261056d565b9050806001600160a01b0316836001600160a01b0316036103fc5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b038216148061041857506104188133610246565b61048a5760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c00000060648201526084016103f3565b6104948383610778565b505050565b6104a333826107e6565b6104bf5760405162461bcd60e51b81526004016103f39061123d565b610494838383610865565b6104d482826109c9565b5050565b6104948383836040518060200160405280600081525061066d565b336104fd8261056d565b6001600160a01b0316146105615760405162461bcd60e51b815260206004820152602560248201527f4552433732313a206275726e206f6620746f6b656e2074686174206973206e6f6044820152643a1037bbb760d91b60648201526084016103f3565b61056a81610b54565b50565b6000818152600260205260408120546001600160a01b0316806102c05760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b60448201526064016103f3565b60006001600160a01b0382166106375760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b60648201526084016103f3565b506001600160a01b031660009081526003602052604090205490565b6060600180546102d590611203565b6104d4338383610be9565b61067733836107e6565b6106935760405162461bcd60e51b81526004016103f39061123d565b61069f84848484610cb7565b50505050565b60606106b082610719565b60006106c760408051602081019091526000815290565b905060008151116106e75760405180602001604052806000815250610712565b806106f184610cea565b60405160200161070292919061128a565b6040516020818303038152906040525b9392505050565b6000818152600260205260409020546001600160a01b031661056a5760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b60448201526064016103f3565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906107ad8261056d565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000806107f28361056d565b9050806001600160a01b0316846001600160a01b0316148061083957506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b8061085d5750836001600160a01b031661085284610358565b6001600160a01b0316145b949350505050565b826001600160a01b03166108788261056d565b6001600160a01b03161461089e5760405162461bcd60e51b81526004016103f3906112b9565b6001600160a01b0382166109005760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016103f3565b826001600160a01b03166109138261056d565b6001600160a01b0316146109395760405162461bcd60e51b81526004016103f3906112b9565b600081815260046020908152604080832080546001600160a01b03199081169091556001600160a01b0387811680865260038552838620805460001901905590871680865283862080546001019055868652600290945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6001600160a01b038216610a1f5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016103f3565b6000818152600260205260409020546001600160a01b031615610a845760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016103f3565b6000818152600260205260409020546001600160a01b031615610ae95760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016103f3565b6001600160a01b038216600081815260036020908152604080832080546001019055848352600290915280822080546001600160a01b0319168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6000610b5f8261056d565b9050610b6a8261056d565b600083815260046020908152604080832080546001600160a01b03199081169091556001600160a01b0385168085526003845282852080546000190190558785526002909352818420805490911690555192935084927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b816001600160a01b0316836001600160a01b031603610c4a5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016103f3565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b610cc2848484610865565b610cce84848484610d7d565b61069f5760405162461bcd60e51b81526004016103f3906112fe565b60606000610cf783610e7e565b600101905060008167ffffffffffffffff811115610d1757610d176110de565b6040519080825280601f01601f191660200182016040528015610d41576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084610d4b57509392505050565b60006001600160a01b0384163b15610e7357604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290610dc1903390899088908890600401611350565b6020604051808303816000875af1925050508015610dfc575060408051601f3d908101601f19168201909252610df99181019061138d565b60015b610e59573d808015610e2a576040519150601f19603f3d011682016040523d82523d6000602084013e610e2f565b606091505b508051600003610e515760405162461bcd60e51b81526004016103f3906112fe565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061085d565b506001949350505050565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310610ebd5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310610ee9576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310610f0757662386f26fc10000830492506010015b6305f5e1008310610f1f576305f5e100830492506008015b6127108310610f3357612710830492506004015b60648310610f45576064830492506002015b600a83106102c05760010192915050565b6001600160e01b03198116811461056a57600080fd5b600060208284031215610f7e57600080fd5b813561071281610f56565b60005b83811015610fa4578181015183820152602001610f8c565b50506000910152565b60008151808452610fc5816020860160208601610f89565b601f01601f19169290920160200192915050565b6020815260006107126020830184610fad565b600060208284031215610ffe57600080fd5b5035919050565b80356001600160a01b038116811461101c57600080fd5b919050565b6000806040838503121561103457600080fd5b61103d83611005565b946020939093013593505050565b60008060006060848603121561106057600080fd5b61106984611005565b925061107760208501611005565b9150604084013590509250925092565b60006020828403121561109957600080fd5b61071282611005565b600080604083850312156110b557600080fd5b6110be83611005565b9150602083013580151581146110d357600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b6000806000806080858703121561110a57600080fd5b61111385611005565b935061112160208601611005565b925060408501359150606085013567ffffffffffffffff8082111561114557600080fd5b818701915087601f83011261115957600080fd5b81358181111561116b5761116b6110de565b604051601f8201601f19908116603f01168101908382118183101715611193576111936110de565b816040528281528a60208487010111156111ac57600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b600080604083850312156111e357600080fd5b6111ec83611005565b91506111fa60208401611005565b90509250929050565b600181811c9082168061121757607f821691505b60208210810361123757634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b6000835161129c818460208801610f89565b8351908301906112b0818360208801610f89565b01949350505050565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061138390830184610fad565b9695505050505050565b60006020828403121561139f57600080fd5b815161071281610f5656fea264697066735822122032e948b2b08ed23fad1436490d9de8e4837b9f460507f13c2e7e469d771dd0f264736f6c63430008100033",
|
|
386
|
+
"linkReferences": {},
|
|
387
|
+
"deployedLinkReferences": {}
|
|
388
|
+
}
|
|
@@ -21,25 +21,26 @@ contract ERC4626AssetManager is LiquidityThresholdAssetManager {
|
|
|
21
21
|
|
|
22
22
|
constructor(IERC20Metadata asset_, IERC4626 vault_) LiquidityThresholdAssetManager(asset_) {
|
|
23
23
|
require(address(vault_) != address(0), "ERC4626AssetManager: vault cannot be zero address");
|
|
24
|
+
require(address(asset_) == vault_.asset(), "ERC4626AssetManager: vault must have the same asset");
|
|
24
25
|
_vault = vault_;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
function connect() public override {
|
|
28
|
+
function connect() public virtual override {
|
|
28
29
|
super.connect();
|
|
29
30
|
_asset.approve(address(_vault), type(uint256).max); // infinite approval to the vault
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
function _invest(uint256 amount) internal override {
|
|
33
|
+
function _invest(uint256 amount) internal virtual override {
|
|
33
34
|
super._invest(amount);
|
|
34
35
|
_vault.deposit(amount, address(this));
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
function _deinvest(uint256 amount) internal override {
|
|
38
|
+
function _deinvest(uint256 amount) internal virtual override {
|
|
38
39
|
super._deinvest(amount);
|
|
39
40
|
_vault.withdraw(amount, address(this), address(this));
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
function deinvestAll() external override returns (int256 earnings) {
|
|
43
|
+
function deinvestAll() external virtual override returns (int256 earnings) {
|
|
43
44
|
DiamondStorage storage ds = diamondStorage();
|
|
44
45
|
uint256 assets = _vault.redeem(_vault.balanceOf(address(this)), address(this), address(this));
|
|
45
46
|
earnings = int256(assets) - int256(uint256(ds.lastInvestmentValue));
|
|
@@ -49,7 +50,7 @@ contract ERC4626AssetManager is LiquidityThresholdAssetManager {
|
|
|
49
50
|
return earnings;
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
function getInvestmentValue() public view override returns (uint256) {
|
|
53
|
+
function getInvestmentValue() public view virtual override returns (uint256) {
|
|
53
54
|
return _vault.convertToAssets(_vault.balanceOf(address(this)));
|
|
54
55
|
}
|
|
55
56
|
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
|
|
5
|
+
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
|
6
|
+
import {IERC4626} from "@openzeppelin/contracts/interfaces/IERC4626.sol";
|
|
7
|
+
import {ERC4626AssetManager} from "./ERC4626AssetManager.sol";
|
|
8
|
+
import {LiquidityThresholdAssetManager} from "./LiquidityThresholdAssetManager.sol";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @title Asset Manager that deploys the funds into a given ERC4626 but also, at request, can deploy the funds in
|
|
12
|
+
* another vault, the discretionary vault.
|
|
13
|
+
* @dev Using liquidity thresholds defined in {LiquidityThresholdAssetManager}, deploys the funds into _vault.
|
|
14
|
+
* By request of the administrator it can also deploy the funds in _discretionaryVault. When deinvesting, if
|
|
15
|
+
* funds in _vault are not enough, it tries to withdraw from _discretionaryVault.
|
|
16
|
+
* @custom:security-contact security@ensuro.co
|
|
17
|
+
* @author Ensuro
|
|
18
|
+
*/
|
|
19
|
+
contract ERC4626PlusVaultAssetManager is ERC4626AssetManager {
|
|
20
|
+
IERC4626 internal immutable _discretionaryVault;
|
|
21
|
+
|
|
22
|
+
constructor(
|
|
23
|
+
IERC20Metadata asset_,
|
|
24
|
+
IERC4626 vault_,
|
|
25
|
+
IERC4626 discretionaryVault_
|
|
26
|
+
) ERC4626AssetManager(asset_, vault_) {
|
|
27
|
+
require(address(discretionaryVault_) != address(0), "ERC4626PlusVaultAssetManager: vault cannot be zero address");
|
|
28
|
+
require(
|
|
29
|
+
address(asset_) == discretionaryVault_.asset(),
|
|
30
|
+
"ERC4626PlusVaultAssetManager: vault must have the same asset"
|
|
31
|
+
);
|
|
32
|
+
require(vault_ != discretionaryVault_, "ERC4626PlusVaultAssetManager: vaults must be different");
|
|
33
|
+
_discretionaryVault = discretionaryVault_;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function _deinvest(uint256 amount) internal virtual override {
|
|
37
|
+
LiquidityThresholdAssetManager._deinvest(amount);
|
|
38
|
+
uint256 vaultAmount = Math.min(amount, _vault.maxWithdraw(address(this)));
|
|
39
|
+
if (vaultAmount != 0) _vault.withdraw(vaultAmount, address(this), address(this));
|
|
40
|
+
if (amount - vaultAmount != 0) _discretionaryVault.withdraw(amount - vaultAmount, address(this), address(this));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function connect() public override {
|
|
44
|
+
super.connect();
|
|
45
|
+
_asset.approve(address(_discretionaryVault), type(uint256).max); // infinite approval to the vault
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function deinvestAll() external virtual override returns (int256 earnings) {
|
|
49
|
+
DiamondStorage storage ds = diamondStorage();
|
|
50
|
+
uint256 fromVault = _vault.redeem(_vault.balanceOf(address(this)), address(this), address(this));
|
|
51
|
+
/**
|
|
52
|
+
* WARNING: this was implemented withdrawing as much as possible from the vault WITHOUT failing.
|
|
53
|
+
* This implementation might leave some assets (those that aren't withdrawable) in the vault and those will
|
|
54
|
+
* be reported as losses.
|
|
55
|
+
*/
|
|
56
|
+
uint256 redeemable = _discretionaryVault.maxRedeem(address(this));
|
|
57
|
+
uint256 fromDiscVault = redeemable != 0 ? _discretionaryVault.redeem(redeemable, address(this), address(this)) : 0;
|
|
58
|
+
earnings = int256(fromVault + fromDiscVault) - int256(uint256(ds.lastInvestmentValue));
|
|
59
|
+
ds.lastInvestmentValue = 0;
|
|
60
|
+
emit MoneyDeinvested(fromDiscVault + fromVault);
|
|
61
|
+
emit EarningsRecorded(earnings);
|
|
62
|
+
return earnings;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function _erc4626Assets(IERC4626 vault) internal view returns (uint256) {
|
|
66
|
+
return vault.convertToAssets(vault.balanceOf(address(this)));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function getInvestmentValue() public view virtual override returns (uint256) {
|
|
70
|
+
return _erc4626Assets(_vault) + _erc4626Assets(_discretionaryVault);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @dev Transfers the given amount from _vault to the _discretionaryVault
|
|
75
|
+
*
|
|
76
|
+
* @param amount The amount to transfer. If that amount isn't available in _vault it reverts.
|
|
77
|
+
* If amount = type(uint256).max it withdraws all the withdrawable funds from _vault.
|
|
78
|
+
*/
|
|
79
|
+
function vaultToDiscretionary(uint256 amount) external {
|
|
80
|
+
if (amount == type(uint256).max) amount = _vault.maxWithdraw(address(this));
|
|
81
|
+
_vault.withdraw(amount, address(this), address(this));
|
|
82
|
+
_discretionaryVault.deposit(amount, address(this));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @dev Transfers the given amount from the _discretionaryVault to _vault
|
|
87
|
+
*
|
|
88
|
+
* @param amount The amount to transfer. If that amount isn't available in the _discretionaryVault it reverts.
|
|
89
|
+
* If amount = type(uint256).max it withdraws all the funds withdrawable in the _discretionaryVault
|
|
90
|
+
*/
|
|
91
|
+
function discretionaryToVault(uint256 amount) external {
|
|
92
|
+
uint256 withdrawn;
|
|
93
|
+
if (amount == type(uint256).max) {
|
|
94
|
+
withdrawn = _discretionaryVault.redeem(
|
|
95
|
+
_discretionaryVault.maxRedeem(address(this)),
|
|
96
|
+
address(this),
|
|
97
|
+
address(this)
|
|
98
|
+
);
|
|
99
|
+
} else {
|
|
100
|
+
_discretionaryVault.withdraw(amount, address(this), address(this));
|
|
101
|
+
withdrawn = amount;
|
|
102
|
+
}
|
|
103
|
+
_vault.deposit(withdrawn, address(this));
|
|
104
|
+
}
|
|
105
|
+
}
|
package/js/deploy.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const upgrades_core = require("@openzeppelin/upgrades-core");
|
|
2
1
|
const helpers = require("@nomicfoundation/hardhat-network-helpers");
|
|
3
2
|
const fs = require("fs");
|
|
4
3
|
const ethers = require("ethers");
|
|
@@ -75,16 +74,12 @@ async function logContractCreated(hre, contractName, address) {
|
|
|
75
74
|
}
|
|
76
75
|
|
|
77
76
|
async function verifyContract(hre, contract, isProxy, constructorArguments) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const contractAddr = await ethers.resolveAddress(contract);
|
|
81
|
-
const address = isProxy
|
|
82
|
-
? await upgrades_core.getImplementationAddress(hre.network.provider, contractAddr)
|
|
83
|
-
: contractAddr;
|
|
77
|
+
constructorArguments = constructorArguments || [];
|
|
78
|
+
const address = await ethers.resolveAddress(contract);
|
|
84
79
|
try {
|
|
85
80
|
await hre.run("verify:verify", {
|
|
86
|
-
address
|
|
87
|
-
constructorArguments
|
|
81
|
+
address,
|
|
82
|
+
constructorArguments,
|
|
88
83
|
});
|
|
89
84
|
} catch (error) {
|
|
90
85
|
console.log("Error verifying contract implementation: ", error);
|
|
@@ -95,18 +90,6 @@ async function verifyContract(hre, contract, isProxy, constructorArguments) {
|
|
|
95
90
|
.join(" ")}`
|
|
96
91
|
);
|
|
97
92
|
}
|
|
98
|
-
try {
|
|
99
|
-
if (isProxy) {
|
|
100
|
-
await hre.run("verify:verify", {
|
|
101
|
-
address: contractAddr,
|
|
102
|
-
constructorArguments: constructorArguments,
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
} catch (error) {
|
|
106
|
-
console.log("Error verifying contract proxy: ", error);
|
|
107
|
-
const endpoints = await hre.run("verify:get-etherscan-endpoint");
|
|
108
|
-
console.log(`You should do it manually at ${endpoints.urls.browserURL}/proxyContractChecker?a=${contractAddr}`);
|
|
109
|
-
}
|
|
110
93
|
}
|
|
111
94
|
|
|
112
95
|
async function deployContract({ saveAddr, verify, contractClass, constructorArgs }, hre) {
|
|
@@ -114,8 +97,7 @@ async function deployContract({ saveAddr, verify, contractClass, constructorArgs
|
|
|
114
97
|
const contract = await ContractFactory.deploy(...constructorArgs, txOverrides());
|
|
115
98
|
const contractAddr = await ethers.resolveAddress(contract);
|
|
116
99
|
if (verify) {
|
|
117
|
-
|
|
118
|
-
await contract.deployTransaction.wait(6);
|
|
100
|
+
await contract.deploymentTransaction().wait(6);
|
|
119
101
|
} else {
|
|
120
102
|
await contract.waitForDeployment();
|
|
121
103
|
}
|
|
@@ -138,8 +120,7 @@ async function deployProxyContract(
|
|
|
138
120
|
});
|
|
139
121
|
const contractAddr = await ethers.resolveAddress(contract);
|
|
140
122
|
if (verify) {
|
|
141
|
-
|
|
142
|
-
await contract.deployTransaction.wait(6);
|
|
123
|
+
await contract.deploymentTransaction().wait(6);
|
|
143
124
|
} else {
|
|
144
125
|
await contract.waitForDeployment();
|
|
145
126
|
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ensuro/core",
|
|
3
3
|
"description": "Ensuro - Decentralized insurance protocol",
|
|
4
|
-
"version": "2.8.
|
|
4
|
+
"version": "2.8.3",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.sol",
|
|
7
|
-
"/build
|
|
8
|
-
"/build/interfaces/*.json",
|
|
7
|
+
"/build",
|
|
9
8
|
"/js/*.js",
|
|
10
|
-
"/scripts
|
|
11
|
-
"/scripts/*.js"
|
|
9
|
+
"/scripts"
|
|
12
10
|
],
|
|
13
11
|
"repository": {
|
|
14
12
|
"type": "git",
|