@@ -34,7 +34,7 @@ import { Position } from "../lib/Position.sol";
34
34
* @title SlippageIssuanceModule
35
35
* @author Set Protocol
36
36
*
37
- * The SlippageIssuanceModule is a module that enables users to issue and redeem SetTokens that requires a transaction that incurs slippage.
37
+ * The SlippageIssuanceModule is a module that enables users to issue and redeem SetTokens that requires a transaction that incurs slippage
38
38
* in order to replicate the Set. Like the DebtIssuanceModule, module hooks are added to allow for syncing of positions, and component
39
39
* level hooks are added to ensure positions are replicated correctly. The manager can define arbitrary issuance logic in the manager hook,
40
40
* as well as specify issue and redeem fees. The getRequiredComponentIssuanceUnits and it's redemption counterpart now also include any
@@ -190,6 +190,8 @@ contract SlippageIssuanceModule is DebtIssuanceModule {
190
190
);
191
191
}
192
192
193
+ /* ============ External View Functions ============ */
194
+
193
195
/**
194
196
* Calculates the amount of each component needed to collateralize passed issue quantity plus fees of Sets as well as amount of debt
195
197
* that will be returned to caller. Overrides inherited function to take into account position updates from pre action module hooks.
@@ -271,6 +273,8 @@ contract SlippageIssuanceModule is DebtIssuanceModule {
271
273
);
272
274
}
273
275
276
+ /* ============ Internal Functions ============ */
277
+
274
278
/**
275
279
* Similar to _calculateRequiredComponentIssuanceUnits but adjustments for positions that will be updated DURING the issue
276
280
* or redeem process are added in. Adjustments can be either positive or negative, a negative debt adjustment means there
@@ -306,7 +310,7 @@ contract SlippageIssuanceModule is DebtIssuanceModule {
306
310
uint256 [] memory totalEquityUnits = new uint256 [](components.length );
307
311
uint256 [] memory totalDebtUnits = new uint256 [](components.length );
308
312
for (uint256 i = 0 ; i < components.length ; i++ ) {
309
- // NOTE: If equityAdjustment is negative and exceeds debtUnits in absolute value this will revert
313
+ // NOTE: If equityAdjustment is negative and exceeds equityUnits in absolute value this will revert
310
314
uint256 adjustedEquityUnits = equityUnits[i].toInt256 ().add (_equityAdjustments[i]).toUint256 ();
311
315
312
316
// Use preciseMulCeil to round up to ensure overcollateration when small issue quantities are provided
@@ -316,7 +320,7 @@ contract SlippageIssuanceModule is DebtIssuanceModule {
316
320
adjustedEquityUnits.preciseMul (_quantity);
317
321
318
322
// NOTE: If debtAdjustment is negative and exceeds debtUnits in absolute value this will revert
319
- uint256 adjustedDebtUnits = debtUnits[i].toInt256 ().add (_debtAdjustments[i]).toUint256 ();
323
+ uint256 adjustedDebtUnits = debtUnits[i].toInt256 ().sub (_debtAdjustments[i]).toUint256 ();
320
324
321
325
// Use preciseMulCeil to round up to ensure overcollateration when small redeem quantities are provided
322
326
// and preciseMul to round down to ensure overcollateration when small issue quantities are provided
0 commit comments