@venusprotocol/venus-protocol 7.1.0-dev.1 → 7.1.0-dev.2

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.
Files changed (77) hide show
  1. package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol/AccessControlledV8.dbg.json +1 -1
  2. package/artifacts/@venusprotocol/governance-contracts/contracts/Governance/IAccessControlManagerV8.sol/IAccessControlManagerV8.dbg.json +1 -1
  3. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/BoundValidatorInterface.dbg.json +1 -1
  4. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/OracleInterface.dbg.json +1 -1
  5. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/ResilientOracleInterface.dbg.json +1 -1
  6. package/artifacts/@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol/TwapInterface.dbg.json +1 -1
  7. package/artifacts/@venusprotocol/solidity-utilities/contracts/MaxLoopsLimitHelper.sol/MaxLoopsLimitHelper.dbg.json +1 -1
  8. package/artifacts/@venusprotocol/solidity-utilities/contracts/TimeManagerV8.sol/TimeManagerV8.dbg.json +1 -1
  9. package/artifacts/build-info/{5158b939f09b056403dc17322b3b5c7a.json → 23955c54eec3e914a4d10c9d990fdb4c.json} +1 -1
  10. package/artifacts/contracts/Admin/VBNBAdmin.sol/VBNBAdmin.dbg.json +1 -1
  11. package/artifacts/contracts/Admin/VBNBAdminStorage.sol/IProtocolShareReserve.dbg.json +1 -1
  12. package/artifacts/contracts/Admin/VBNBAdminStorage.sol/IWBNB.dbg.json +1 -1
  13. package/artifacts/contracts/Admin/VBNBAdminStorage.sol/VBNBAdminStorage.dbg.json +1 -1
  14. package/artifacts/contracts/Admin/VBNBAdminStorage.sol/VTokenInterface.dbg.json +1 -1
  15. package/artifacts/contracts/DelegateBorrowers/MoveDebtDelegate.sol/MoveDebtDelegate.dbg.json +1 -1
  16. package/artifacts/contracts/DelegateBorrowers/MoveDebtDelegate.sol/MoveDebtDelegate.json +115 -22
  17. package/artifacts/contracts/DelegateBorrowers/SwapDebtDelegate.sol/SwapDebtDelegate.dbg.json +1 -1
  18. package/artifacts/contracts/Governance/TokenRedeemer.sol/TokenRedeemer.dbg.json +1 -1
  19. package/artifacts/contracts/InterfacesV8.sol/IComptroller.dbg.json +1 -1
  20. package/artifacts/contracts/InterfacesV8.sol/ILiquidator.dbg.json +1 -1
  21. package/artifacts/contracts/InterfacesV8.sol/IVAIController.dbg.json +1 -1
  22. package/artifacts/contracts/InterfacesV8.sol/IVBNB.dbg.json +1 -1
  23. package/artifacts/contracts/InterfacesV8.sol/IVBep20.dbg.json +1 -1
  24. package/artifacts/contracts/InterfacesV8.sol/IVToken.dbg.json +1 -1
  25. package/artifacts/contracts/Liquidator/BUSDLiquidator.sol/BUSDLiquidator.dbg.json +1 -1
  26. package/artifacts/contracts/Liquidator/Liquidator.sol/Liquidator.dbg.json +1 -1
  27. package/artifacts/contracts/PegStability/IVAI.sol/IVAI.dbg.json +1 -1
  28. package/artifacts/contracts/PegStability/PegStability.sol/PegStability.dbg.json +1 -1
  29. package/artifacts/contracts/Swap/IRouterHelper.sol/IRouterHelper.dbg.json +1 -1
  30. package/artifacts/contracts/Swap/RouterHelper.sol/RouterHelper.dbg.json +1 -1
  31. package/artifacts/contracts/Swap/SwapRouter.sol/SwapRouter.dbg.json +1 -1
  32. package/artifacts/contracts/Swap/interfaces/IPancakePair.sol/IPancakePair.dbg.json +1 -1
  33. package/artifacts/contracts/Swap/interfaces/IPancakeSwapV2Factory.sol/IPancakeSwapV2Factory.dbg.json +1 -1
  34. package/artifacts/contracts/Swap/interfaces/IPancakeSwapV2Router.sol/IPancakeSwapV2Router.dbg.json +1 -1
  35. package/artifacts/contracts/Swap/interfaces/IVBNB.sol/IVBNB.dbg.json +1 -1
  36. package/artifacts/contracts/Swap/interfaces/IVtoken.sol/IVToken.dbg.json +1 -1
  37. package/artifacts/contracts/Swap/interfaces/IWBNB.sol/IWBNB.dbg.json +1 -1
  38. package/artifacts/contracts/Swap/interfaces/InterfaceComptroller.sol/InterfaceComptroller.dbg.json +1 -1
  39. package/artifacts/contracts/Swap/lib/PancakeLibrary.sol/PancakeLibrary.dbg.json +1 -1
  40. package/artifacts/contracts/Swap/lib/TransferHelper.sol/TransferHelper.dbg.json +1 -1
  41. package/artifacts/contracts/Tokens/Prime/Interfaces/IPoolRegistry.sol/PoolRegistryInterface.dbg.json +1 -1
  42. package/artifacts/contracts/Tokens/Prime/Interfaces/IPrime.sol/IPrime.dbg.json +1 -1
  43. package/artifacts/contracts/Tokens/Prime/Interfaces/IPrimeLiquidityProvider.sol/IPrimeLiquidityProvider.dbg.json +1 -1
  44. package/artifacts/contracts/Tokens/Prime/Interfaces/IVToken.sol/IVToken.dbg.json +1 -1
  45. package/artifacts/contracts/Tokens/Prime/Interfaces/IXVSVault.sol/IXVSVault.dbg.json +1 -1
  46. package/artifacts/contracts/Tokens/Prime/Interfaces/InterfaceComptroller.sol/InterfaceComptroller.dbg.json +1 -1
  47. package/artifacts/contracts/Tokens/Prime/Prime.sol/Prime.dbg.json +1 -1
  48. package/artifacts/contracts/Tokens/Prime/PrimeLiquidityProvider.sol/PrimeLiquidityProvider.dbg.json +1 -1
  49. package/artifacts/contracts/Tokens/Prime/PrimeLiquidityProviderStorage.sol/PrimeLiquidityProviderStorageV1.dbg.json +1 -1
  50. package/artifacts/contracts/Tokens/Prime/PrimeStorage.sol/PrimeStorageV1.dbg.json +1 -1
  51. package/artifacts/contracts/Tokens/Prime/libs/FixedMath.sol/FixedMath.dbg.json +1 -1
  52. package/artifacts/contracts/Tokens/Prime/libs/FixedMath0x.sol/FixedMath0x.dbg.json +1 -1
  53. package/artifacts/contracts/Tokens/Prime/libs/Scores.sol/Scores.dbg.json +1 -1
  54. package/artifacts/contracts/test/AccessControlManagerMock.sol/AccessControlManagerMock.dbg.json +1 -1
  55. package/artifacts/contracts/test/LiquidatorHarness.sol/LiquidatorHarness.dbg.json +1 -1
  56. package/artifacts/contracts/test/MockProtocolShareReserve.sol/IComptroller.dbg.json +1 -1
  57. package/artifacts/contracts/test/MockProtocolShareReserve.sol/IIncomeDestination.dbg.json +1 -1
  58. package/artifacts/contracts/test/MockProtocolShareReserve.sol/IMockProtocolShareReserve.dbg.json +1 -1
  59. package/artifacts/contracts/test/MockProtocolShareReserve.sol/IPoolRegistry.dbg.json +1 -1
  60. package/artifacts/contracts/test/MockProtocolShareReserve.sol/IPrime.dbg.json +1 -1
  61. package/artifacts/contracts/test/MockProtocolShareReserve.sol/IVToken.dbg.json +1 -1
  62. package/artifacts/contracts/test/MockProtocolShareReserve.sol/MaxLoopsLimitHelper.dbg.json +1 -1
  63. package/artifacts/contracts/test/MockProtocolShareReserve.sol/MockProtocolShareReserve.dbg.json +1 -1
  64. package/artifacts/contracts/test/PrimeScenario.sol/PrimeScenario.dbg.json +1 -1
  65. package/contracts/DelegateBorrowers/MoveDebtDelegate.sol +60 -17
  66. package/deployments/bscmainnet/MoveDebtDelegate.json +592 -0
  67. package/deployments/bscmainnet/MoveDebtDelegate_Implementation.json +766 -0
  68. package/deployments/bscmainnet/MoveDebtDelegate_Proxy.json +253 -0
  69. package/deployments/bscmainnet/solcInputs/03a6c42b57bcdc7c1b76c0f541accfdb.json +69 -0
  70. package/deployments/bscmainnet/solcInputs/1dff3b4c1e459128170e9af3e75c7e17.json +72 -0
  71. package/deployments/bscmainnet.json +1080 -0
  72. package/deployments/bscmainnet_addresses.json +3 -0
  73. package/dist/deployments/bscmainnet.json +1080 -0
  74. package/dist/typechain/contracts/DelegateBorrowers/MoveDebtDelegate.d.ts +64 -20
  75. package/dist/typechain/factories/contracts/DelegateBorrowers/MoveDebtDelegate__factory.d.ts +92 -20
  76. package/dist/typechain/factories/contracts/DelegateBorrowers/MoveDebtDelegate__factory.js +118 -25
  77. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../build-info/5158b939f09b056403dc17322b3b5c7a.json"
3
+ "buildInfo": "../../../../build-info/23955c54eec3e914a4d10c9d990fdb4c.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../../build-info/5158b939f09b056403dc17322b3b5c7a.json"
3
+ "buildInfo": "../../../../../build-info/23955c54eec3e914a4d10c9d990fdb4c.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../../build-info/5158b939f09b056403dc17322b3b5c7a.json"
3
+ "buildInfo": "../../../../../build-info/23955c54eec3e914a4d10c9d990fdb4c.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../../build-info/5158b939f09b056403dc17322b3b5c7a.json"
3
+ "buildInfo": "../../../../../build-info/23955c54eec3e914a4d10c9d990fdb4c.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5158b939f09b056403dc17322b3b5c7a.json"
3
+ "buildInfo": "../../../build-info/23955c54eec3e914a4d10c9d990fdb4c.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5158b939f09b056403dc17322b3b5c7a.json"
3
+ "buildInfo": "../../../build-info/23955c54eec3e914a4d10c9d990fdb4c.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5158b939f09b056403dc17322b3b5c7a.json"
3
+ "buildInfo": "../../../build-info/23955c54eec3e914a4d10c9d990fdb4c.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5158b939f09b056403dc17322b3b5c7a.json"
3
+ "buildInfo": "../../../build-info/23955c54eec3e914a4d10c9d990fdb4c.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5158b939f09b056403dc17322b3b5c7a.json"
3
+ "buildInfo": "../../../build-info/23955c54eec3e914a4d10c9d990fdb4c.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5158b939f09b056403dc17322b3b5c7a.json"
3
+ "buildInfo": "../../../build-info/23955c54eec3e914a4d10c9d990fdb4c.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5158b939f09b056403dc17322b3b5c7a.json"
3
+ "buildInfo": "../../../build-info/23955c54eec3e914a4d10c9d990fdb4c.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5158b939f09b056403dc17322b3b5c7a.json"
3
+ "buildInfo": "../../../build-info/23955c54eec3e914a4d10c9d990fdb4c.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5158b939f09b056403dc17322b3b5c7a.json"
3
+ "buildInfo": "../../../build-info/23955c54eec3e914a4d10c9d990fdb4c.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5158b939f09b056403dc17322b3b5c7a.json"
3
+ "buildInfo": "../../../build-info/23955c54eec3e914a4d10c9d990fdb4c.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5158b939f09b056403dc17322b3b5c7a.json"
3
+ "buildInfo": "../../../build-info/23955c54eec3e914a4d10c9d990fdb4c.json"
4
4
  }
@@ -7,6 +7,7 @@ import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/
7
7
  import { SafeERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
8
8
  import { IERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
9
9
  import { ResilientOracleInterface } from "@venusprotocol/oracle/contracts/interfaces/OracleInterface.sol";
10
+ import { ensureNonzeroAddress } from "@venusprotocol/solidity-utilities/contracts/validators.sol";
10
11
 
11
12
  import { approveOrRevert } from "../lib/approveOrRevert.sol";
12
13
  import { IVBep20, IComptroller } from "../InterfacesV8.sol";
@@ -15,9 +16,8 @@ contract MoveDebtDelegate is Ownable2StepUpgradeable, ReentrancyGuardUpgradeable
15
16
  /// @dev VToken return value signalling about successful execution
16
17
  uint256 internal constant NO_ERROR = 0;
17
18
 
18
- /// @notice VToken to repay the debt to
19
- /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
20
- IVBep20 public immutable vTokenToRepay;
19
+ /// @notice A wildcard indicating that repayment is allowed for _any_ user in the market
20
+ address public constant ANY_USER = address(1);
21
21
 
22
22
  /// @notice User to borrow on behalf of
23
23
  /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
@@ -26,15 +26,22 @@ contract MoveDebtDelegate is Ownable2StepUpgradeable, ReentrancyGuardUpgradeable
26
26
  /// @notice Whether to allow borrowing from the corresponding vToken
27
27
  mapping(address => bool) public borrowAllowed;
28
28
 
29
+ /// @notice Whether to allow repaying to the corresponding vToken on behalf of
30
+ /// a certain user. Use ANY_USER to check if repayment is allowed for any user.
31
+ mapping(address => mapping(address => bool)) public repaymentAllowed;
32
+
33
+ /// @notice Emitted when vToken is allowed or denied to be borrowed from
34
+ event BorrowAllowedSet(address indexed vTokenToBorrow, bool allowed);
35
+
29
36
  /// @notice Emitted when vToken is allowed or denied to be borrowed from
30
- event BorrowAllowedSet(address indexed vToken, bool allowed);
37
+ event RepaymentAllowedSet(address indexed vTokenToRepay, address indexed originalBorrower, bool allowed);
31
38
 
32
39
  /// @notice Emitted if debt is swapped successfully
33
40
  event DebtMoved(
34
41
  address indexed originalBorrower,
35
- address vTokenRepaid,
42
+ address indexed vTokenRepaid,
36
43
  uint256 repaidAmount,
37
- address indexed newBorrower,
44
+ address newBorrower,
38
45
  address indexed vTokenBorrowed,
39
46
  uint256 borrowedAmount
40
47
  );
@@ -55,14 +62,15 @@ contract MoveDebtDelegate is Ownable2StepUpgradeable, ReentrancyGuardUpgradeable
55
62
  /// @notice Thrown if borrowing from the corresponding vToken is not allowed
56
63
  error BorrowNotAllowed(address vToken);
57
64
 
65
+ /// @notice Thrown if repaying the debts of the borrower to the corresponding vToken is not allowed
66
+ error RepaymentNotAllowed(address vToken, address borrower);
67
+
58
68
  using SafeERC20Upgradeable for IERC20Upgradeable;
59
69
 
60
70
  /// @notice Constructor for the implementation contract. Sets immutable variables.
61
- /// @param vTokenToRepay_ VToken to repay the debt to
62
71
  /// @param newBorrower_ User to borrow on behalf of
63
72
  /// @custom:oz-upgrades-unsafe-allow constructor
64
- constructor(IVBep20 vTokenToRepay_, address newBorrower_) {
65
- vTokenToRepay = vTokenToRepay_;
73
+ constructor(address newBorrower_) {
66
74
  newBorrower = newBorrower_;
67
75
  _disableInitializers();
68
76
  }
@@ -74,16 +82,29 @@ contract MoveDebtDelegate is Ownable2StepUpgradeable, ReentrancyGuardUpgradeable
74
82
 
75
83
  /**
76
84
  * @notice Repays originalBorrower's borrow in vTokenToRepay.underlying() and borrows
77
- * vTokenToBorrow.underlying() on behalf of newBorrower
85
+ * vTokenToBorrow.underlying() on behalf of newBorrower.
86
+ *
78
87
  * @param originalBorrower The address of the borrower, whose debt to repay
88
+ * @param vTokenToRepay VToken to repay to on behalf of originalBorrower
79
89
  * @param repayAmount The amount to repay in terms of vTokenToRepay.underlying()
80
90
  * @param vTokenToBorrow VToken to borrow from
81
91
  */
82
- function moveDebt(address originalBorrower, uint256 repayAmount, IVBep20 vTokenToBorrow) external nonReentrant {
92
+ function moveDebt(
93
+ IVBep20 vTokenToRepay,
94
+ address originalBorrower,
95
+ uint256 repayAmount,
96
+ IVBep20 vTokenToBorrow
97
+ ) external nonReentrant {
83
98
  if (!borrowAllowed[address(vTokenToBorrow)]) {
84
99
  revert BorrowNotAllowed(address(vTokenToBorrow));
85
100
  }
86
- uint256 actualRepaymentAmount = _repay(originalBorrower, repayAmount);
101
+
102
+ mapping(address => bool) storage repaymentAllowedFor = repaymentAllowed[address(vTokenToRepay)];
103
+ if (!repaymentAllowedFor[ANY_USER] && !repaymentAllowedFor[originalBorrower]) {
104
+ revert RepaymentNotAllowed(address(vTokenToRepay), originalBorrower);
105
+ }
106
+
107
+ uint256 actualRepaymentAmount = _repay(vTokenToRepay, originalBorrower, repayAmount);
87
108
  uint256 amountToBorrow = _convert(vTokenToRepay, vTokenToBorrow, actualRepaymentAmount);
88
109
  _borrow(vTokenToBorrow, amountToBorrow);
89
110
  emit DebtMoved(
@@ -102,12 +123,29 @@ contract MoveDebtDelegate is Ownable2StepUpgradeable, ReentrancyGuardUpgradeable
102
123
  * @param allow Whether to allow borrowing from the corresponding vToken
103
124
  */
104
125
  function setBorrowAllowed(address vTokenToBorrow, bool allow) external onlyOwner {
126
+ ensureNonzeroAddress(vTokenToBorrow);
105
127
  if (borrowAllowed[vTokenToBorrow] != allow) {
106
128
  borrowAllowed[vTokenToBorrow] = allow;
107
129
  emit BorrowAllowedSet(vTokenToBorrow, allow);
108
130
  }
109
131
  }
110
132
 
133
+ /**
134
+ * @notice Allows or denies repaying the debts of originalBorrower to the corresponding vToken
135
+ * @param vTokenToRepay VToken to repay to
136
+ * @param originalBorrower The address of the borrower, whose debt to repay (or ANY_USER to allow
137
+ * repayments for all users in the market, e.g. if the market is going to be deprecated soon)
138
+ * @param allow Whether to allow repaying to the corresponding vToken on behalf of originalBorrower
139
+ */
140
+ function setRepaymentAllowed(address vTokenToRepay, address originalBorrower, bool allow) external onlyOwner {
141
+ ensureNonzeroAddress(vTokenToRepay);
142
+ ensureNonzeroAddress(originalBorrower);
143
+ if (repaymentAllowed[vTokenToRepay][originalBorrower] != allow) {
144
+ repaymentAllowed[vTokenToRepay][originalBorrower] = allow;
145
+ emit RepaymentAllowedSet(vTokenToRepay, originalBorrower, allow);
146
+ }
147
+ }
148
+
111
149
  /**
112
150
  * @notice Transfers tokens, accidentially sent to this contract, to the owner
113
151
  * @param token ERC-20 token to sweep
@@ -120,10 +158,15 @@ contract MoveDebtDelegate is Ownable2StepUpgradeable, ReentrancyGuardUpgradeable
120
158
 
121
159
  /**
122
160
  * @dev Transfers the funds from the sender and repays a borrow in vToken on behalf of the borrower
161
+ * @param vTokenToRepay VToken to repay to
123
162
  * @param borrower The address of the borrower, whose debt to repay
124
163
  * @param repayAmount The amount to repay in terms of underlying
125
164
  */
126
- function _repay(address borrower, uint256 repayAmount) internal returns (uint256 actualRepaymentAmount) {
165
+ function _repay(
166
+ IVBep20 vTokenToRepay,
167
+ address borrower,
168
+ uint256 repayAmount
169
+ ) internal returns (uint256 actualRepaymentAmount) {
127
170
  IERC20Upgradeable underlying = IERC20Upgradeable(vTokenToRepay.underlying());
128
171
  uint256 balanceBefore = underlying.balanceOf(address(this));
129
172
  underlying.safeTransferFrom(msg.sender, address(this), repayAmount);
@@ -143,13 +186,13 @@ contract MoveDebtDelegate is Ownable2StepUpgradeable, ReentrancyGuardUpgradeable
143
186
 
144
187
  /**
145
188
  * @dev Borrows in vToken on behalf of the borrower and transfers the funds to the sender
146
- * @param vToken VToken to borrow from
189
+ * @param vTokenToBorrow VToken to borrow from
147
190
  * @param borrowAmount The amount to borrow in terms of underlying
148
191
  */
149
- function _borrow(IVBep20 vToken, uint256 borrowAmount) internal {
150
- IERC20Upgradeable underlying = IERC20Upgradeable(vToken.underlying());
192
+ function _borrow(IVBep20 vTokenToBorrow, uint256 borrowAmount) internal {
193
+ IERC20Upgradeable underlying = IERC20Upgradeable(vTokenToBorrow.underlying());
151
194
  uint256 balanceBefore = underlying.balanceOf(address(this));
152
- uint256 err = vToken.borrowBehalf(newBorrower, borrowAmount);
195
+ uint256 err = vTokenToBorrow.borrowBehalf(newBorrower, borrowAmount);
153
196
  if (err != NO_ERROR) {
154
197
  revert BorrowFailed(err);
155
198
  }