Skip to content

Commit 9be3d1b

Browse files
author
Sachin
authored
fix(SlippageIssuanceModule): Fix issuance & redemption flows to not update position units (#254)
* Reapply all fixes by Brain; Skip package.json changes * Fix SIM * Fix PerpV2LeverageModule<>SIM integration tests * Fix BTM <> SIM integration tests * Add tests to ensure base token position unit does not update on issuance and redemption * Bump package to 0.10.3-basis.0 and publish * Override issue and redeem; Add tests * Reset package version to 0.10.3
1 parent c04e399 commit 9be3d1b

File tree

4 files changed

+289
-151
lines changed

4 files changed

+289
-151
lines changed

contracts/protocol/modules/v1/SlippageIssuanceModule.sol

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,20 @@ contract SlippageIssuanceModule is DebtIssuanceModule {
4242

4343
/* ============ External Functions ============ */
4444

45+
/**
46+
* @dev Reverts upon calling. Call `issueWithSlippage` instead.
47+
*/
48+
function issue(ISetToken /*_setToken*/, uint256 /*_quantity*/, address /*_to*/) external override(DebtIssuanceModule) {
49+
revert("Call issueWithSlippage instead");
50+
}
51+
52+
/**
53+
* @dev Reverts upon calling. Call `redeemWithSlippage` instead.
54+
*/
55+
function redeem(ISetToken /*_setToken*/, uint256 /*_quantity*/, address /*_to*/) external override(DebtIssuanceModule) {
56+
revert("Call redeemWithSlippage instead");
57+
}
58+
4559
/**
4660
* Deposits components to the SetToken, replicates any external module component positions and mints
4761
* the SetToken. If the token has a debt position all collateral will be transferred in first then debt
@@ -76,8 +90,6 @@ contract SlippageIssuanceModule is DebtIssuanceModule {
7690

7791
address hookContract = _callManagerPreIssueHooks(_setToken, _setQuantity, msg.sender, _to);
7892

79-
_callModulePreIssueHooks(_setToken, _setQuantity);
80-
8193
bool isIssue = true;
8294

8395
(
@@ -86,6 +98,8 @@ contract SlippageIssuanceModule is DebtIssuanceModule {
8698
uint256 protocolFee
8799
) = calculateTotalFees(_setToken, _setQuantity, isIssue);
88100

101+
_callModulePreIssueHooks(_setToken, quantityWithFees);
102+
89103
// Scoping logic to avoid stack too deep errors
90104
{
91105
(
@@ -148,11 +162,6 @@ contract SlippageIssuanceModule is DebtIssuanceModule {
148162
{
149163
_validateInputs(_setQuantity, _checkedComponents, _minTokenAmountsOut);
150164

151-
_callModulePreRedeemHooks(_setToken, _setQuantity);
152-
153-
// Place burn after pre-redeem hooks because burning tokens may lead to false accounting of synced positions
154-
_setToken.burn(msg.sender, _setQuantity);
155-
156165
bool isIssue = false;
157166

158167
(
@@ -161,6 +170,11 @@ contract SlippageIssuanceModule is DebtIssuanceModule {
161170
uint256 protocolFee
162171
) = calculateTotalFees(_setToken, _setQuantity, isIssue);
163172

173+
_callModulePreRedeemHooks(_setToken, quantityNetFees);
174+
175+
// Place burn after pre-redeem hooks because burning tokens may lead to false accounting of synced positions
176+
_setToken.burn(msg.sender, _setQuantity);
177+
164178
(
165179
address[] memory components,
166180
uint256[] memory equityUnits,

0 commit comments

Comments
 (0)