-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDepositVault.sol
More file actions
811 lines (703 loc) · 22.9 KB
/
DepositVault.sol
File metadata and controls
811 lines (703 loc) · 22.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import {IERC20Upgradeable as IERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import {IERC20MetadataUpgradeable as IERC20Metadata} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol";
import {Counters} from "@openzeppelin/contracts/utils/Counters.sol";
import "./interfaces/IDepositVault.sol";
import "./interfaces/IDataFeed.sol";
import "./abstract/ManageableVault.sol";
/**
* @title DepositVault
* @notice Smart contract that handles mToken minting
* @author RedDuck Software
*/
contract DepositVault is ManageableVault, IDepositVault {
using Counters for Counters.Counter;
/**
* @notice return data of _calcAndValidateDeposit
* packed into a struct to avoid stack too deep errors
*/
struct CalcAndValidateDepositResult {
/// @notice tokenIn amount converted to USD
uint256 tokenAmountInUsd;
/// @notice fee amount in tokenIn
uint256 feeTokenAmount;
/// @notice tokenIn amount without fee
uint256 amountTokenWithoutFee;
/// @notice mToken amount for mint
uint256 mintAmount;
/// @notice tokenIn rate
uint256 tokenInRate;
/// @notice mToken rate
uint256 tokenOutRate;
/// @notice tokenIn decimals
uint256 tokenDecimals;
}
/**
* @dev default role that grants admin rights to the contract
*/
bytes32 private constant _DEFAULT_DEPOSIT_VAULT_ADMIN_ROLE =
keccak256("DEPOSIT_VAULT_ADMIN_ROLE");
/**
* @dev selector for deposit instant
*/
bytes4 private constant _DEPOSIT_INSTANT_SELECTOR =
bytes4(keccak256("depositInstant(address,uint256,uint256,bytes32)"));
/**
* @dev selector for deposit instant with custom recipient
*/
bytes4 private constant _DEPOSIT_INSTANT_WITH_CUSTOM_RECIPIENT_SELECTOR =
bytes4(
keccak256("depositInstant(address,uint256,uint256,bytes32,address)")
);
/**
* @dev selector for deposit request
*/
bytes4 private constant _DEPOSIT_REQUEST_SELECTOR =
bytes4(keccak256("depositRequest(address,uint256,bytes32)"));
/**
* @dev selector for deposit request with custom recipient
*/
bytes4 private constant _DEPOSIT_REQUEST_WITH_CUSTOM_RECIPIENT_SELECTOR =
bytes4(keccak256("depositRequest(address,uint256,bytes32,address)"));
/**
* @notice minimal USD amount for first user`s deposit
*/
uint256 public minMTokenAmountForFirstDeposit;
/**
* @notice mapping, requestId => request data
*/
mapping(uint256 => Request) public mintRequests;
/**
* @dev depositor address => amount minted
*/
mapping(address => uint256) public totalMinted;
/**
* @notice max supply cap value in mToken
* @dev if after the deposit, mToken.totalSupply() > maxSupplyCap,
* the tx will be reverted
*/
uint256 public maxSupplyCap;
/**
* @dev leaving a storage gap for futures updates
*
* used slots:
* 50 - `maxSupplyCap`
*/
uint256[49] private __gap;
/**
* @notice upgradeable pattern contract`s initializer
* @dev Calls all versioned initializers (V1, V2, ...) in chronological order.
* This ensures that every deployment, whether fresh or upgraded, ends up
* initialized to the latest contract state without breaking the
* initializer/reinitializer versioning rules.
* @param _ac address of MidasAccessControll contract
* @param _mTokenInitParams init params for mToken
* @param _receiversInitParams init params for receivers
* @param _instantInitParams init params for instant operations
* @param _sanctionsList address of sanctionsList contract
* @param _variationTolerance percent of prices diviation 1% = 100
* @param _minAmount basic min amount for operations in mToken
* @param _minMTokenAmountForFirstDeposit min amount for first deposit in mToken
* @param _maxSupplyCap max supply cap for mToken
*/
function initialize(
address _ac,
MTokenInitParams calldata _mTokenInitParams,
ReceiversInitParams calldata _receiversInitParams,
InstantInitParams calldata _instantInitParams,
address _sanctionsList,
uint256 _variationTolerance,
uint256 _minAmount,
uint256 _minMTokenAmountForFirstDeposit,
uint256 _maxSupplyCap
) public {
initializeV1(
_ac,
_mTokenInitParams,
_receiversInitParams,
_instantInitParams,
_sanctionsList,
_variationTolerance,
_minAmount,
_minMTokenAmountForFirstDeposit
);
initializeV2(_maxSupplyCap);
}
/**
* @notice v1 initializer
* @param _ac address of MidasAccessControll contract
* @param _mTokenInitParams init params for mToken
* @param _receiversInitParams init params for receivers
* @param _instantInitParams init params for instant operations
* @param _sanctionsList address of sanctionsList contract
* @param _variationTolerance percent of prices diviation 1% = 100
* @param _minAmount basic min amount for operations in mToken
* @param _minMTokenAmountForFirstDeposit min amount for first deposit in mToken
*/
function initializeV1(
address _ac,
MTokenInitParams calldata _mTokenInitParams,
ReceiversInitParams calldata _receiversInitParams,
InstantInitParams calldata _instantInitParams,
address _sanctionsList,
uint256 _variationTolerance,
uint256 _minAmount,
uint256 _minMTokenAmountForFirstDeposit
) public initializer {
__ManageableVault_init(
_ac,
_mTokenInitParams,
_receiversInitParams,
_instantInitParams,
_sanctionsList,
_variationTolerance,
_minAmount
);
minMTokenAmountForFirstDeposit = _minMTokenAmountForFirstDeposit;
}
/**
* @notice v2 initializer
* @param _maxSupplyCap max supply cap for mToken
*/
function initializeV2(uint256 _maxSupplyCap) public reinitializer(2) {
maxSupplyCap = _maxSupplyCap;
}
/**
* @inheritdoc IDepositVault
*/
function depositInstant(
address tokenIn,
uint256 amountToken,
uint256 minReceiveAmount,
bytes32 referrerId
) external whenFnNotPaused(_DEPOSIT_INSTANT_SELECTOR) {
_validateUserAccess(msg.sender);
CalcAndValidateDepositResult memory result = _depositInstant(
tokenIn,
amountToken,
minReceiveAmount,
msg.sender
);
emit DepositInstant(
msg.sender,
tokenIn,
result.tokenAmountInUsd,
amountToken,
result.feeTokenAmount,
result.mintAmount,
referrerId
);
}
/**
* @inheritdoc IDepositVault
*/
function depositInstant(
address tokenIn,
uint256 amountToken,
uint256 minReceiveAmount,
bytes32 referrerId,
address recipient
)
external
whenFnNotPaused(_DEPOSIT_INSTANT_WITH_CUSTOM_RECIPIENT_SELECTOR)
{
_validateUserAccess(msg.sender);
if (recipient != msg.sender) {
_validateUserAccess(recipient);
}
CalcAndValidateDepositResult memory result = _depositInstant(
tokenIn,
amountToken,
minReceiveAmount,
recipient
);
emit DepositInstantWithCustomRecipient(
msg.sender,
tokenIn,
recipient,
result.tokenAmountInUsd,
amountToken,
result.feeTokenAmount,
result.mintAmount,
referrerId
);
}
/**
* @inheritdoc IDepositVault
*/
function depositRequest(
address tokenIn,
uint256 amountToken,
bytes32 referrerId
)
external
whenFnNotPaused(_DEPOSIT_REQUEST_SELECTOR)
returns (
uint256 /*requestId*/
)
{
_validateUserAccess(msg.sender);
(
uint256 requestId,
CalcAndValidateDepositResult memory calcResult
) = _depositRequest(tokenIn, amountToken, msg.sender);
emit DepositRequest(
requestId,
msg.sender,
tokenIn,
amountToken,
calcResult.tokenAmountInUsd,
calcResult.feeTokenAmount,
calcResult.tokenOutRate,
referrerId
);
return requestId;
}
/**
* @inheritdoc IDepositVault
*/
function depositRequest(
address tokenIn,
uint256 amountToken,
bytes32 referrerId,
address recipient
)
external
whenFnNotPaused(_DEPOSIT_REQUEST_WITH_CUSTOM_RECIPIENT_SELECTOR)
returns (
uint256 /*requestId*/
)
{
_validateUserAccess(msg.sender);
if (recipient != msg.sender) {
_validateUserAccess(recipient);
}
(
uint256 requestId,
CalcAndValidateDepositResult memory calcResult
) = _depositRequest(tokenIn, amountToken, recipient);
bytes32 referrerIdCopy = referrerId;
emit DepositRequestWithCustomRecipient(
requestId,
msg.sender,
tokenIn,
recipient,
amountToken,
calcResult.tokenAmountInUsd,
calcResult.feeTokenAmount,
calcResult.tokenOutRate,
referrerIdCopy
);
return requestId;
}
/**
* @inheritdoc IDepositVault
*/
function safeBulkApproveRequestAtSavedRate(uint256[] calldata requestIds)
external
onlyVaultAdmin
{
for (uint256 i = 0; i < requestIds.length; i++) {
uint256 rate = mintRequests[requestIds[i]].tokenOutRate;
bool success = _approveRequest(requestIds[i], rate, true, false);
if (!success) {
continue;
}
emit SafeApproveRequest(requestIds[i], rate);
}
}
/**
* @inheritdoc IDepositVault
*/
function safeBulkApproveRequest(uint256[] calldata requestIds) external {
uint256 currentMTokenRate = _getMTokenRate();
safeBulkApproveRequest(requestIds, currentMTokenRate);
}
/**
* @inheritdoc IDepositVault
*/
function safeApproveRequest(uint256 requestId, uint256 newOutRate)
external
onlyVaultAdmin
{
_approveRequest(requestId, newOutRate, true, true);
emit SafeApproveRequest(requestId, newOutRate);
}
/**
* @inheritdoc IDepositVault
*/
function approveRequest(uint256 requestId, uint256 newOutRate)
external
onlyVaultAdmin
{
_approveRequest(requestId, newOutRate, false, true);
emit ApproveRequest(requestId, newOutRate);
}
/**
* @inheritdoc IDepositVault
*/
function rejectRequest(uint256 requestId) external onlyVaultAdmin {
Request memory request = mintRequests[requestId];
require(request.sender != address(0), "DV: request not exist");
require(
request.status == RequestStatus.Pending,
"DV: request not pending"
);
mintRequests[requestId].status = RequestStatus.Canceled;
emit RejectRequest(requestId, request.sender);
}
/**
* @inheritdoc IDepositVault
*/
function setMinMTokenAmountForFirstDeposit(uint256 newValue)
external
onlyVaultAdmin
{
minMTokenAmountForFirstDeposit = newValue;
emit SetMinMTokenAmountForFirstDeposit(msg.sender, newValue);
}
/**
* @inheritdoc IDepositVault
*/
function setMaxSupplyCap(uint256 newValue) external onlyVaultAdmin {
maxSupplyCap = newValue;
emit SetMaxSupplyCap(msg.sender, newValue);
}
/**
* @inheritdoc IDepositVault
*/
function safeBulkApproveRequest(
uint256[] calldata requestIds,
uint256 newOutRate
) public onlyVaultAdmin {
for (uint256 i = 0; i < requestIds.length; i++) {
bool success = _approveRequest(
requestIds[i],
newOutRate,
true,
false
);
if (!success) {
continue;
}
emit SafeApproveRequest(requestIds[i], newOutRate);
}
}
/**
* @inheritdoc ManageableVault
*/
function vaultRole() public pure virtual override returns (bytes32) {
return _DEFAULT_DEPOSIT_VAULT_ADMIN_ROLE;
}
/**
* @inheritdoc Greenlistable
*/
function greenlistTogglerRole()
public
view
virtual
override
returns (bytes32)
{
return vaultRole();
}
/**
* @dev internal deposit instant logic
* @param tokenIn tokenIn address
* @param amountToken amount of tokenIn (decimals 18)
* @param minReceiveAmount min amount of mToken to receive (decimals 18)
* @param recipient recipient address
*
* @return result calculated deposit result
*/
function _depositInstant(
address tokenIn,
uint256 amountToken,
uint256 minReceiveAmount,
address recipient
) internal virtual returns (CalcAndValidateDepositResult memory result) {
address user = msg.sender;
result = _calcAndValidateDeposit(user, tokenIn, amountToken, true);
require(
result.mintAmount >= minReceiveAmount,
"DV: minReceiveAmount > actual"
);
totalMinted[user] += result.mintAmount;
_requireAndUpdateLimit(result.mintAmount);
_instantTransferTokensToTokensReceiver(
tokenIn,
result.amountTokenWithoutFee,
result.tokenDecimals
);
if (result.feeTokenAmount > 0)
_tokenTransferFromUser(
tokenIn,
feeReceiver,
result.feeTokenAmount,
result.tokenDecimals
);
mToken.mint(recipient, result.mintAmount);
_validateMaxSupplyCap(true);
}
/**
* @dev internal deposit request logic
* @param tokenIn tokenIn address
* @param amountToken amount of tokenIn (decimals 18)
* @param recipient recipient address
*
* @return requestId request id
* @return calcResult calculated deposit result
*/
function _depositRequest(
address tokenIn,
uint256 amountToken,
address recipient
)
private
returns (
uint256 requestId,
CalcAndValidateDepositResult memory calcResult
)
{
address user = msg.sender;
requestId = currentRequestId.current();
currentRequestId.increment();
calcResult = _calcAndValidateDeposit(user, tokenIn, amountToken, false);
_requestTransferTokensToTokensReceiver(
tokenIn,
calcResult.amountTokenWithoutFee,
calcResult.tokenDecimals
);
if (calcResult.feeTokenAmount > 0)
_tokenTransferFromUser(
tokenIn,
feeReceiver,
calcResult.feeTokenAmount,
calcResult.tokenDecimals
);
mintRequests[requestId] = Request({
sender: recipient,
tokenIn: tokenIn,
status: RequestStatus.Pending,
depositedUsdAmount: calcResult.tokenAmountInUsd,
usdAmountWithoutFees: (calcResult.amountTokenWithoutFee *
calcResult.tokenInRate) / 10**18,
tokenOutRate: calcResult.tokenOutRate
});
}
/**
* @dev approving request
* Checks price diviation if safe
* Mints mTokens to user
* @param requestId request id
* @param newOutRate mToken rate
*/
function _approveRequest(
uint256 requestId,
uint256 newOutRate,
bool isSafe,
bool revertAboveSupplyCap
)
private
returns (
bool /* success */
)
{
Request memory request = mintRequests[requestId];
require(request.sender != address(0), "DV: request not exist");
require(
request.status == RequestStatus.Pending,
"DV: request not pending"
);
if (isSafe)
_requireVariationTolerance(request.tokenOutRate, newOutRate);
uint256 amountMToken = (request.usdAmountWithoutFees * (10**18)) /
newOutRate;
if (!_validateMaxSupplyCap(amountMToken, revertAboveSupplyCap)) {
return false;
}
mToken.mint(request.sender, amountMToken);
totalMinted[request.sender] += amountMToken;
request.status = RequestStatus.Processed;
request.tokenOutRate = newOutRate;
mintRequests[requestId] = request;
return true;
}
/**
* @dev internal transfer tokens to tokens receiver (instant deposits)
* @param tokenIn tokenIn address
* @param amountToken amount of tokenIn (decimals 18)
* @param tokensDecimals tokens decimals
*/
function _instantTransferTokensToTokensReceiver(
address tokenIn,
uint256 amountToken,
uint256 tokensDecimals
) internal virtual {
_tokenTransferFromUser(
tokenIn,
tokensReceiver,
amountToken,
tokensDecimals
);
}
/**
* @dev internal transfer tokens to tokens receiver (deposit requests)
* @param tokenIn tokenIn address
* @param amountToken amount of tokenIn (decimals 18)
* @param tokensDecimals tokens decimals
*/
function _requestTransferTokensToTokensReceiver(
address tokenIn,
uint256 amountToken,
uint256 tokensDecimals
) internal virtual {
_tokenTransferFromUser(
tokenIn,
tokensReceiver,
amountToken,
tokensDecimals
);
}
/**
* @dev validate deposit and calculate mint amount
* @param user user address
* @param tokenIn tokenIn address
* @param amountToken tokenIn amount (decimals 18)
* @param isInstant is instant operation
*
* @return result calculated deposit result
*/
function _calcAndValidateDeposit(
address user,
address tokenIn,
uint256 amountToken,
bool isInstant
) internal returns (CalcAndValidateDepositResult memory result) {
require(amountToken > 0, "DV: invalid amount");
result.tokenDecimals = _tokenDecimals(tokenIn);
_requireTokenExists(tokenIn);
(uint256 amountInUsd, uint256 tokenInUSDRate) = _convertTokenToUsd(
tokenIn,
amountToken
);
result.tokenAmountInUsd = amountInUsd;
result.tokenInRate = tokenInUSDRate;
address userCopy = user;
_requireAndUpdateAllowance(tokenIn, amountToken);
result.feeTokenAmount = _truncate(
_getFeeAmount(userCopy, tokenIn, amountToken, isInstant, 0),
result.tokenDecimals
);
result.amountTokenWithoutFee = amountToken - result.feeTokenAmount;
uint256 feeInUsd = (result.feeTokenAmount * result.tokenInRate) /
10**18;
(uint256 mTokenAmount, uint256 mTokenRate) = _convertUsdToMToken(
result.tokenAmountInUsd - feeInUsd
);
result.mintAmount = mTokenAmount;
result.tokenOutRate = mTokenRate;
if (!isFreeFromMinAmount[userCopy]) {
_validateMinAmount(userCopy, result.mintAmount);
}
require(result.mintAmount > 0, "DV: invalid mint amount");
}
/**
* @dev validates that inputted USD amount >= minAmountToDepositInUsd()
* and amount >= minAmount()
* @param user user address
* @param amountMTokenWithoutFee amount of mToken without fee (decimals 18)
*/
function _validateMinAmount(address user, uint256 amountMTokenWithoutFee)
internal
view
{
require(amountMTokenWithoutFee >= minAmount, "DV: mToken amount < min");
if (totalMinted[user] != 0) return;
require(
amountMTokenWithoutFee >= minMTokenAmountForFirstDeposit,
"DV: mint amount < min"
);
}
/**
* @dev validates that mToken.totalSupply() <= maxSupplyCap
*
* @param revertOnError if true, will revert if supply is exceeded
* if false, will return false if supply is exceeded without reverting
*
* @return true if supply is valid, false otherwise
*/
function _validateMaxSupplyCap(bool revertOnError)
internal
view
returns (bool)
{
return _validateMaxSupplyCap(0, revertOnError);
}
/**
* @dev validates that mToken.totalSupply() <= maxSupplyCap
*
* @param mintAmount amount of mToken to mint
* @param revertOnError if true, will revert if supply is exceeded
* if false, will return false if supply is exceeded without reverting
*
* @return true if supply is valid, false otherwise
*/
function _validateMaxSupplyCap(uint256 mintAmount, bool revertOnError)
internal
view
returns (bool)
{
bool isExceeded = mToken.totalSupply() + mintAmount > maxSupplyCap;
if (!revertOnError) {
return !isExceeded;
}
require(!isExceeded, "DV: max supply cap exceeded");
return true;
}
/**
* @dev calculates USD amount from tokenIn amount
* @param tokenIn tokenIn address
* @param amount amount of tokenIn (decimals 18)
*
* @return amountInUsd converted amount to USD
* @return rate conversion rate
*/
function _convertTokenToUsd(address tokenIn, uint256 amount)
internal
view
virtual
returns (uint256 amountInUsd, uint256 rate)
{
require(amount > 0, "DV: amount zero");
TokenConfig storage tokenConfig = tokensConfig[tokenIn];
rate = _getTokenRate(tokenConfig.dataFeed, tokenConfig.stable);
require(rate > 0, "DV: rate zero");
amountInUsd = (amount * rate) / (10**18);
}
/**
* @dev calculates mToken amount from USD amount
* @param amountUsd amount of USD (decimals 18)
*
* @return amountMToken converted USD to mToken
* @return mTokenRate conversion rate
*/
function _convertUsdToMToken(uint256 amountUsd)
internal
view
virtual
returns (uint256 amountMToken, uint256 mTokenRate)
{
mTokenRate = _getMTokenRate();
amountMToken = (amountUsd * (10**18)) / mTokenRate;
}
/**
* @dev gets and validates mToken rate
* @return mTokenRate mToken rate
*/
function _getMTokenRate() private view returns (uint256 mTokenRate) {
mTokenRate = _getTokenRate(address(mTokenDataFeed), false);
require(mTokenRate > 0, "DV: rate zero");
}
}