@@ -125,28 +125,29 @@ contract TroveBridge is ERC20, Ownable, IDefiBridge {
125
125
* the method. If this is not the case, the function will revert.
126
126
*
127
127
* Borrowing Repaying Redeeming
128
- * @param inputAssetA - ETH TB TB
129
- * @param inputAssetB - None LUSD None
130
- * @param outputAssetA - TB ETH ETH
131
- * @param outputAssetB - LUSD None None
132
- * @param inputValue - amount of ETH amount of TB and LUSD amount of TB
133
- * @param interactionNonce - nonce nonce nonce
134
- * @param auxData - max borrower fee 0 0
128
+ * @param _inputAssetA - ETH TB TB
129
+ * @param _inputAssetB - None LUSD None
130
+ * @param _outputAssetA - TB ETH ETH
131
+ * @param _outputAssetB - LUSD None None
132
+ * @param _inputValue - amount of ETH amount of TB and LUSD amount of TB
133
+ * @param _interactionNonce - nonce nonce nonce
134
+ * @param _auxData - max borrower fee 0 0
135
135
* @return outputValueA - amount of TB amount of ETH amount of ETH
136
136
* @return outputValueB - amount of LUSD 0 0
137
137
*/
138
138
function convert (
139
- AztecTypes.AztecAsset calldata inputAssetA ,
140
- AztecTypes.AztecAsset calldata inputAssetB ,
141
- AztecTypes.AztecAsset calldata outputAssetA ,
142
- AztecTypes.AztecAsset calldata outputAssetB ,
143
- uint256 inputValue ,
144
- uint256 interactionNonce ,
145
- uint64 auxData ,
139
+ AztecTypes.AztecAsset calldata _inputAssetA ,
140
+ AztecTypes.AztecAsset calldata _inputAssetB ,
141
+ AztecTypes.AztecAsset calldata _outputAssetA ,
142
+ AztecTypes.AztecAsset calldata _outputAssetB ,
143
+ uint256 _inputValue ,
144
+ uint256 _interactionNonce ,
145
+ uint64 _auxData ,
146
146
address
147
147
)
148
148
external
149
149
payable
150
+ override (IDefiBridge)
150
151
returns (
151
152
uint256 outputValueA ,
152
153
uint256 outputValueB ,
@@ -160,36 +161,36 @@ contract TroveBridge is ERC20, Ownable, IDefiBridge {
160
161
address lowerHint = SORTED_TROVES.getNext (address (this ));
161
162
162
163
if (
163
- inputAssetA .assetType == AztecTypes.AztecAssetType.ETH &&
164
- outputAssetA .erc20Address == address (this ) &&
165
- outputAssetB .erc20Address == LUSD
164
+ _inputAssetA .assetType == AztecTypes.AztecAssetType.ETH &&
165
+ _outputAssetA .erc20Address == address (this ) &&
166
+ _outputAssetB .erc20Address == LUSD
166
167
) {
167
168
// Borrowing
168
169
if (troveStatus != Status.active) revert IncorrectStatus (Status.active, troveStatus);
169
170
// outputValueA = by how much debt will increase and how much TB to mint
170
- outputValueB = computeAmtToBorrow (inputValue ); // LUSD amount to borrow
171
+ outputValueB = computeAmtToBorrow (_inputValue ); // LUSD amount to borrow
171
172
172
173
(uint256 debtBefore , , , ) = TROVE_MANAGER.getEntireDebtAndColl (address (this ));
173
- BORROWER_OPERATIONS.adjustTrove {value: inputValue}(auxData , 0 , outputValueB, true , upperHint, lowerHint);
174
+ BORROWER_OPERATIONS.adjustTrove {value: _inputValue}(_auxData , 0 , outputValueB, true , upperHint, lowerHint);
174
175
(uint256 debtAfter , , , ) = TROVE_MANAGER.getEntireDebtAndColl (address (this ));
175
176
176
177
// outputValueA = debt increase = amount of TB to mint
177
178
outputValueA = debtAfter - debtBefore;
178
179
_mint (address (this ), outputValueA);
179
180
} else if (
180
- inputAssetA .erc20Address == address (this ) &&
181
- inputAssetB .erc20Address == LUSD &&
182
- outputAssetA .assetType == AztecTypes.AztecAssetType.ETH
181
+ _inputAssetA .erc20Address == address (this ) &&
182
+ _inputAssetB .erc20Address == LUSD &&
183
+ _outputAssetA .assetType == AztecTypes.AztecAssetType.ETH
183
184
) {
184
185
// Repaying
185
186
if (troveStatus != Status.active) revert IncorrectStatus (Status.active, troveStatus);
186
187
(, uint256 coll , , ) = TROVE_MANAGER.getEntireDebtAndColl (address (this ));
187
- outputValueA = (coll * inputValue ) / this .totalSupply (); // Amount of collateral to withdraw
188
- BORROWER_OPERATIONS.adjustTrove (0 , outputValueA, inputValue , false , upperHint, lowerHint);
189
- _burn (address (this ), inputValue );
190
- IRollupProcessor (ROLLUP_PROCESSOR).receiveEthFromBridge {value: outputValueA}(interactionNonce );
188
+ outputValueA = (coll * _inputValue ) / this .totalSupply (); // Amount of collateral to withdraw
189
+ BORROWER_OPERATIONS.adjustTrove (0 , outputValueA, _inputValue , false , upperHint, lowerHint);
190
+ _burn (address (this ), _inputValue );
191
+ IRollupProcessor (ROLLUP_PROCESSOR).receiveEthFromBridge {value: outputValueA}(_interactionNonce );
191
192
} else if (
192
- inputAssetA .erc20Address == address (this ) && outputAssetA .assetType == AztecTypes.AztecAssetType.ETH
193
+ _inputAssetA .erc20Address == address (this ) && _outputAssetA .assetType == AztecTypes.AztecAssetType.ETH
193
194
) {
194
195
// Redeeming
195
196
if (troveStatus != Status.closedByRedemption)
@@ -198,9 +199,9 @@ contract TroveBridge is ERC20, Ownable, IDefiBridge {
198
199
BORROWER_OPERATIONS.claimCollateral ();
199
200
collateralClaimed = true ;
200
201
}
201
- outputValueA = (address (this ).balance * inputValue ) / this .totalSupply ();
202
- _burn (address (this ), inputValue );
203
- IRollupProcessor (ROLLUP_PROCESSOR).receiveEthFromBridge {value: outputValueA}(interactionNonce );
202
+ outputValueA = (address (this ).balance * _inputValue ) / this .totalSupply ();
203
+ _burn (address (this ), _inputValue );
204
+ IRollupProcessor (ROLLUP_PROCESSOR).receiveEthFromBridge {value: outputValueA}(_interactionNonce );
204
205
} else {
205
206
revert IncorrectInput ();
206
207
}
@@ -245,6 +246,7 @@ contract TroveBridge is ERC20, Ownable, IDefiBridge {
245
246
)
246
247
external
247
248
payable
249
+ override (IDefiBridge)
248
250
returns (
249
251
uint256 ,
250
252
uint256 ,
@@ -257,7 +259,7 @@ contract TroveBridge is ERC20, Ownable, IDefiBridge {
257
259
/**
258
260
* @notice Compute how much LUSD to borrow against collateral in order to keep ICR constant and by how much total
259
261
* trove debt will increase.
260
- * @param collateral Amount of ETH denominated in Wei
262
+ * @param _collateral Amount of ETH denominated in Wei
261
263
* @return amtToBorrow Amount of LUSD to borrow to keep ICR constant.
262
264
* + borrowing fee)
263
265
* @dev I don't use view modifier here because the function updates PriceFeed state.
@@ -273,13 +275,13 @@ contract TroveBridge is ERC20, Ownable, IDefiBridge {
273
275
* Note2: Step 4 is necessary to avoid loss of precision. BORROWING_RATE / DECIMAL_PRECISION was rounded to 0.
274
276
* Note3: The borrowing fee computation is on this line in Liquity code: https://github.com/liquity/dev/blob/cb583ddf5e7de6010e196cfe706bd0ca816ea40e/packages/contracts/contracts/TroveManager.sol#L1433
275
277
*/
276
- function computeAmtToBorrow (uint256 collateral ) public returns (uint256 amtToBorrow ) {
278
+ function computeAmtToBorrow (uint256 _collateral ) public returns (uint256 amtToBorrow ) {
277
279
uint256 price = TROVE_MANAGER.priceFeed ().fetchPrice ();
278
280
bool isRecoveryMode = TROVE_MANAGER.checkRecoveryMode (price);
279
281
if (TROVE_MANAGER.getTroveStatus (address (this )) == 1 ) {
280
282
// Trove is active - use current ICR and not the initial one
281
283
uint256 icr = TROVE_MANAGER.getCurrentICR (address (this ), price);
282
- amtToBorrow = (collateral * price) / icr;
284
+ amtToBorrow = (_collateral * price) / icr;
283
285
if (! isRecoveryMode) {
284
286
// Liquity is not in recovery mode so borrowing fee applies
285
287
uint256 borrowingRate = TROVE_MANAGER.getBorrowingRateWithDecay ();
@@ -288,7 +290,7 @@ contract TroveBridge is ERC20, Ownable, IDefiBridge {
288
290
} else {
289
291
// Trove is inactive - I will use initial ICR to compute debt
290
292
// 200e18 - 200 LUSD gas compensation to liquidators
291
- amtToBorrow = (collateral * price) / INITIAL_ICR - 200e18 ;
293
+ amtToBorrow = (_collateral * price) / INITIAL_ICR - 200e18 ;
292
294
if (! isRecoveryMode) {
293
295
// Liquity is not in recovery mode so borrowing fee applies
294
296
uint256 borrowingRate = TROVE_MANAGER.getBorrowingRateWithDecay ();
@@ -300,7 +302,7 @@ contract TroveBridge is ERC20, Ownable, IDefiBridge {
300
302
/**
301
303
* @dev See {IERC20-totalSupply}.
302
304
*/
303
- function totalSupply () public view override returns (uint256 ) {
305
+ function totalSupply () public view override ( ERC20 ) returns (uint256 ) {
304
306
return super .totalSupply () - DUST;
305
307
}
306
308
}
0 commit comments