Skip to content

Commit d43df0c

Browse files
authored
feat(reorg): Re-org modules into v1 and v2 directories (#230)
1 parent 355c030 commit d43df0c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+348
-348
lines changed

contracts/protocol-viewers/StreamingFeeModuleViewer.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pragma experimental "ABIEncoderV2";
2121

2222
import { ISetToken } from "../interfaces/ISetToken.sol";
2323
import { IStreamingFeeModule } from "../interfaces/IStreamingFeeModule.sol";
24-
import { StreamingFeeModule } from "../protocol/modules/StreamingFeeModule.sol";
24+
import { StreamingFeeModule } from "../protocol/modules/v1/StreamingFeeModule.sol";
2525

2626

2727
/**

contracts/protocol/modules/AaveLeverageModule.sol renamed to contracts/protocol/modules/v1/AaveLeverageModule.sol

Lines changed: 89 additions & 89 deletions
Large diffs are not rendered by default.

contracts/protocol/modules/AirdropModule.sol renamed to contracts/protocol/modules/v1/AirdropModule.sol

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.s
2424
import { SafeCast } from "@openzeppelin/contracts/utils/SafeCast.sol";
2525
import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";
2626

27-
import { AddressArrayUtils } from "../../lib/AddressArrayUtils.sol";
28-
import { IController } from "../../interfaces/IController.sol";
29-
import { ISetToken } from "../../interfaces/ISetToken.sol";
30-
import { Invoke } from "../lib/Invoke.sol";
31-
import { ModuleBase } from "../lib/ModuleBase.sol";
32-
import { Position } from "../lib/Position.sol";
33-
import { PreciseUnitMath } from "../../lib/PreciseUnitMath.sol";
27+
import { AddressArrayUtils } from "../../../lib/AddressArrayUtils.sol";
28+
import { IController } from "../../../interfaces/IController.sol";
29+
import { ISetToken } from "../../../interfaces/ISetToken.sol";
30+
import { Invoke } from "../../lib/Invoke.sol";
31+
import { ModuleBase } from "../../lib/ModuleBase.sol";
32+
import { Position } from "../../lib/Position.sol";
33+
import { PreciseUnitMath } from "../../../lib/PreciseUnitMath.sol";
3434

3535

3636
/**
@@ -51,7 +51,7 @@ contract AirdropModule is ModuleBase, ReentrancyGuard {
5151
using Position for ISetToken;
5252

5353
/* ============ Structs ============ */
54-
54+
5555
struct AirdropSettings {
5656
address[] airdrops; // Array of tokens manager is allowing to be absorbed
5757
address feeRecipient; // Address airdrop fees are sent to
@@ -150,7 +150,7 @@ contract AirdropModule is ModuleBase, ReentrancyGuard {
150150
* SET MANAGER ONLY. Removes tokens from list to be absorbed.
151151
*
152152
* @param _setToken Address of SetToken
153-
* @param _airdrop Component to remove from airdrop list
153+
* @param _airdrop Component to remove from airdrop list
154154
*/
155155
function removeAirdrop(ISetToken _setToken, IERC20 _airdrop) external onlyManagerAndValidSet(_setToken) {
156156
require(isAirdropToken(_setToken, _airdrop), "Token not added.");
@@ -307,7 +307,7 @@ contract AirdropModule is ModuleBase, ReentrancyGuard {
307307

308308
if (amountAirdropped > 0) {
309309
(uint256 managerTake, uint256 protocolTake, uint256 totalFees) = _handleFees(_setToken, _token, amountAirdropped);
310-
310+
311311
uint256 newUnit = _getPostAirdropUnit(_setToken, preFeeTokenBalance, totalFees);
312312

313313
_setToken.editDefaultPosition(address(_token), newUnit);
@@ -338,12 +338,12 @@ contract AirdropModule is ModuleBase, ReentrancyGuard {
338338

339339
if (airdropFee > 0) {
340340
totalFees = _amountAirdropped.preciseMul(airdropFee);
341-
341+
342342
protocolTake = getModuleFee(AIRDROP_MODULE_PROTOCOL_FEE_INDEX, totalFees);
343343
netManagerTake = totalFees.sub(protocolTake);
344344

345345
_setToken.strictInvokeTransfer(address(_component), airdropSettings[_setToken].feeRecipient, netManagerTake);
346-
346+
347347
payProtocolFeeFromSetToken(_setToken, address(_component), protocolTake);
348348

349349
return (netManagerTake, protocolTake, totalFees);
@@ -354,7 +354,7 @@ contract AirdropModule is ModuleBase, ReentrancyGuard {
354354

355355
/**
356356
* Retrieve new unit, which is the current balance less fees paid divided by total supply
357-
*/
357+
*/
358358
function _getPostAirdropUnit(
359359
ISetToken _setToken,
360360
uint256 _totalComponentBalance,
@@ -370,8 +370,8 @@ contract AirdropModule is ModuleBase, ReentrancyGuard {
370370

371371
/**
372372
* If absorption is confined to the manager, manager must be caller
373-
*/
373+
*/
374374
function _isValidCaller(ISetToken _setToken) internal view returns(bool) {
375-
return airdropSettings[_setToken].anyoneAbsorb || isSetManager(_setToken, msg.sender);
375+
return airdropSettings[_setToken].anyoneAbsorb || isSetManager(_setToken, msg.sender);
376376
}
377377
}

contracts/protocol/modules/AmmModule.sol renamed to contracts/protocol/modules/v1/AmmModule.sol

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,22 @@ import { SafeCast } from "@openzeppelin/contracts/utils/SafeCast.sol";
2525
import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";
2626
import { SignedSafeMath } from "@openzeppelin/contracts/math/SignedSafeMath.sol";
2727

28-
import { IController } from "../../interfaces/IController.sol";
29-
import { IIntegrationRegistry } from "../../interfaces/IIntegrationRegistry.sol";
30-
import { Invoke } from "../lib/Invoke.sol";
31-
import { ISetToken } from "../../interfaces/ISetToken.sol";
32-
import { IAmmAdapter } from "../../interfaces/IAmmAdapter.sol";
33-
import { ModuleBase } from "../lib/ModuleBase.sol";
34-
import { Position } from "../lib/Position.sol";
35-
import { PreciseUnitMath } from "../../lib/PreciseUnitMath.sol";
28+
import { IController } from "../../../interfaces/IController.sol";
29+
import { IIntegrationRegistry } from "../../../interfaces/IIntegrationRegistry.sol";
30+
import { Invoke } from "../../lib/Invoke.sol";
31+
import { ISetToken } from "../../../interfaces/ISetToken.sol";
32+
import { IAmmAdapter } from "../../../interfaces/IAmmAdapter.sol";
33+
import { ModuleBase } from "../../lib/ModuleBase.sol";
34+
import { Position } from "../../lib/Position.sol";
35+
import { PreciseUnitMath } from "../../../lib/PreciseUnitMath.sol";
3636

3737

3838
/**
3939
* @title AmmModule
4040
* @author Set Protocol
4141
*
4242
* A smart contract module that enables joining and exiting of AMM Pools using multiple or a single ERC20s.
43-
* Examples of intended protocols include Curve, Uniswap, and Balancer.
43+
* Examples of intended protocols include Curve, Uniswap, and Balancer.
4444
*/
4545
contract AmmModule is ModuleBase, ReentrancyGuard {
4646
using SafeCast for int256;
@@ -61,7 +61,7 @@ contract AmmModule is ModuleBase, ReentrancyGuard {
6161
address[] _components,
6262
int256[] _componentBalancesDelta // Change in SetToken component token balances
6363
);
64-
64+
6565
event LiquidityRemoved(
6666
ISetToken indexed _setToken,
6767
address indexed _ammPool,
@@ -80,11 +80,11 @@ contract AmmModule is ModuleBase, ReentrancyGuard {
8080
address liquidityToken; // Address of the AMM pool token
8181
uint256 preActionLiquidityTokenBalance; // Balance of liquidity token before add/remove liquidity action
8282
uint256[] preActionComponentBalances; // Balance of components before add/remove liquidity action
83-
uint256 liquidityQuantity; // When adding liquidity, minimum quantity of liquidity required.
83+
uint256 liquidityQuantity; // When adding liquidity, minimum quantity of liquidity required.
8484
// When removing liquidity, quantity to dispose of
8585
uint256[] totalNotionalComponents; // When adding liquidity, maximum components provided
8686
// When removing liquidity, minimum components to receive
87-
uint256[] componentUnits; // List of inputted component real units
87+
uint256[] componentUnits; // List of inputted component real units
8888
address[] components; // List of component addresses for providing/removing liquidity
8989
}
9090

@@ -138,11 +138,11 @@ contract AmmModule is ModuleBase, ReentrancyGuard {
138138

139139
emit LiquidityAdded(_setToken, _ammPool, liquidityTokenDelta, _components, componentsDelta);
140140
}
141-
141+
142142
/**
143-
* SET MANAGER ONLY. Adds liquidity to an AMM pool for a specified AMM using a single asset if supported.
143+
* SET MANAGER ONLY. Adds liquidity to an AMM pool for a specified AMM using a single asset if supported.
144144
* Differs from addLiquidity as it will opt to use the AMMs single asset liquidity function if it exists
145-
* User specifies what component and component quantity to contribute and the minimum number of
145+
* User specifies what component and component quantity to contribute and the minimum number of
146146
* liquidity pool tokens to receive.
147147
*
148148
* @param _setToken Address of SetToken
@@ -193,7 +193,7 @@ contract AmmModule is ModuleBase, ReentrancyGuard {
193193
}
194194

195195
/**
196-
* SET MANAGER ONLY. Removes liquidity from an AMM pool for a specified AMM. User specifies the exact number of
196+
* SET MANAGER ONLY. Removes liquidity from an AMM pool for a specified AMM. User specifies the exact number of
197197
* liquidity pool tokens to provide and the components and minimum quantity of component units to receive
198198
*
199199
* @param _setToken Address of SetToken
@@ -240,7 +240,7 @@ contract AmmModule is ModuleBase, ReentrancyGuard {
240240
liquidityTokenDelta,
241241
_components,
242242
componentsDelta
243-
);
243+
);
244244
}
245245

246246
/**
@@ -262,7 +262,7 @@ contract AmmModule is ModuleBase, ReentrancyGuard {
262262
uint256 _poolTokenPositionUnits,
263263
address _component,
264264
uint256 _minComponentUnitsReceived
265-
)
265+
)
266266
external
267267
nonReentrant
268268
onlyManagerAndValidSet(_setToken)
@@ -339,14 +339,14 @@ contract AmmModule is ModuleBase, ReentrancyGuard {
339339
actionInfo.preActionComponentBalances = _getTokenBalances(address(_setToken), _components);
340340

341341
actionInfo.liquidityQuantity = actionInfo.totalSupply.getDefaultTotalNotional(_poolTokenInPositionUnit);
342-
342+
343343
actionInfo.totalNotionalComponents = _getTotalNotionalComponents(_setToken, _componentUnits);
344344

345345
actionInfo.componentUnits = _componentUnits;
346-
347-
actionInfo.components = _components;
348346

349-
return actionInfo;
347+
actionInfo.components = _components;
348+
349+
return actionInfo;
350350
}
351351

352352
function _getActionInfoSingleAsset(
@@ -426,7 +426,7 @@ contract AmmModule is ModuleBase, ReentrancyGuard {
426426
);
427427
}
428428
}
429-
429+
430430
function _executeAddLiquidity(ActionInfo memory _actionInfo) internal {
431431
(
432432
address targetAmm, uint256 callValue, bytes memory methodData
@@ -456,9 +456,9 @@ contract AmmModule is ModuleBase, ReentrancyGuard {
456456

457457
_executeComponentApprovals(_actionInfo);
458458

459-
_actionInfo.setToken.invoke(targetAmm, callValue, methodData);
459+
_actionInfo.setToken.invoke(targetAmm, callValue, methodData);
460460
}
461-
461+
462462
function _executeRemoveLiquidity(ActionInfo memory _actionInfo) internal {
463463
(
464464
address targetAmm, uint256 callValue, bytes memory methodData
@@ -476,7 +476,7 @@ contract AmmModule is ModuleBase, ReentrancyGuard {
476476
_actionInfo.liquidityQuantity
477477
);
478478

479-
_actionInfo.setToken.invoke(targetAmm, callValue, methodData);
479+
_actionInfo.setToken.invoke(targetAmm, callValue, methodData);
480480
}
481481

482482
function _executeRemoveLiquiditySingleAsset(ActionInfo memory _actionInfo) internal {
@@ -496,9 +496,9 @@ contract AmmModule is ModuleBase, ReentrancyGuard {
496496
_actionInfo.liquidityQuantity
497497
);
498498

499-
_actionInfo.setToken.invoke(targetAmm, callValue, methodData);
499+
_actionInfo.setToken.invoke(targetAmm, callValue, methodData);
500500
}
501-
501+
502502
function _validateMinimumLiquidityReceived(ActionInfo memory _actionInfo) internal view {
503503
uint256 liquidityTokenBalance = IERC20(_actionInfo.liquidityToken).balanceOf(address(_actionInfo.setToken));
504504

contracts/protocol/modules/BasicIssuanceModule.sol renamed to contracts/protocol/modules/v1/BasicIssuanceModule.sol

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.s
2020
import { SafeCast } from "@openzeppelin/contracts/utils/SafeCast.sol";
2121
import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";
2222

23-
import { IController } from "../../interfaces/IController.sol";
24-
import { IManagerIssuanceHook } from "../../interfaces/IManagerIssuanceHook.sol";
25-
import { Invoke } from "../lib/Invoke.sol";
26-
import { ISetToken } from "../../interfaces/ISetToken.sol";
27-
import { ModuleBase } from "../lib/ModuleBase.sol";
28-
import { Position } from "../lib/Position.sol";
29-
import { PreciseUnitMath } from "../../lib/PreciseUnitMath.sol";
23+
import { IController } from "../../../interfaces/IController.sol";
24+
import { IManagerIssuanceHook } from "../../../interfaces/IManagerIssuanceHook.sol";
25+
import { Invoke } from "../../lib/Invoke.sol";
26+
import { ISetToken } from "../../../interfaces/ISetToken.sol";
27+
import { ModuleBase } from "../../lib/ModuleBase.sol";
28+
import { Position } from "../../lib/Position.sol";
29+
import { PreciseUnitMath } from "../../../lib/PreciseUnitMath.sol";
3030

3131
/**
3232
* @title BasicIssuanceModule
@@ -87,7 +87,7 @@ contract BasicIssuanceModule is ModuleBase, ReentrancyGuard {
8787
ISetToken _setToken,
8888
uint256 _quantity,
8989
address _to
90-
)
90+
)
9191
external
9292
nonReentrant
9393
onlyValidAndInitializedSet(_setToken)

contracts/protocol/modules/ClaimModule.sol renamed to contracts/protocol/modules/v1/ClaimModule.sol

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,25 @@ pragma experimental "ABIEncoderV2";
1717

1818
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
1919

20-
import { AddressArrayUtils } from "../../lib/AddressArrayUtils.sol";
21-
import { IClaimAdapter } from "../../interfaces/IClaimAdapter.sol";
22-
import { IController } from "../../interfaces/IController.sol";
23-
import { ISetToken } from "../../interfaces/ISetToken.sol";
24-
import { ModuleBase } from "../lib/ModuleBase.sol";
20+
import { AddressArrayUtils } from "../../../lib/AddressArrayUtils.sol";
21+
import { IClaimAdapter } from "../../../interfaces/IClaimAdapter.sol";
22+
import { IController } from "../../../interfaces/IController.sol";
23+
import { ISetToken } from "../../../interfaces/ISetToken.sol";
24+
import { ModuleBase } from "../../lib/ModuleBase.sol";
2525

2626

2727
/**
2828
* @title ClaimModule
2929
* @author Set Protocol
3030
*
3131
* Module that enables managers to claim tokens from external protocols given to the Set as part of participating in
32-
* incentivized activities of other protocols. The ClaimModule works in conjunction with ClaimAdapters, in which the
32+
* incentivized activities of other protocols. The ClaimModule works in conjunction with ClaimAdapters, in which the
3333
* claimAdapterID / integrationNames are stored on the integration registry.
34-
*
34+
*
3535
* Design:
3636
* The ecosystem is coalescing around a few standards of how reward programs are created, using forks of popular
3737
* contracts such as Synthetix's Mintr. Thus, the Claim architecture reflects a more functional vs external-protocol
38-
* approach where an adapter with common functionality can be used across protocols.
38+
* approach where an adapter with common functionality can be used across protocols.
3939
*
4040
* Definitions:
4141
* Reward Pool: A reward pool is a contract associated with an external protocol's reward. Examples of reward pools
@@ -232,7 +232,7 @@ contract ClaimModule is ModuleBase {
232232
_removeClaim(_setToken, _rewardPools[i], _integrationNames[i]);
233233
}
234234
}
235-
235+
236236
/**
237237
* SET MANAGER ONLY. Initializes this module to the SetToken.
238238
*
@@ -278,11 +278,11 @@ contract ClaimModule is ModuleBase {
278278
}
279279
delete claimSettings[ISetToken(msg.sender)][setTokenPoolList[i]];
280280
}
281-
281+
282282
for (uint256 i = 0; i < rewardPoolList[ISetToken(msg.sender)].length; i++) {
283283
address toRemove = rewardPoolList[ISetToken(msg.sender)][i];
284284
rewardPoolStatus[ISetToken(msg.sender)][toRemove] = false;
285-
285+
286286
delete rewardPoolList[ISetToken(msg.sender)][i];
287287
}
288288
delete rewardPoolList[ISetToken(msg.sender)];
@@ -439,7 +439,7 @@ contract ClaimModule is ModuleBase {
439439
}
440440

441441
/**
442-
* Internal version. Adds a new rewardPool to the list to perform claims for the SetToken indicating the list of claim
442+
* Internal version. Adds a new rewardPool to the list to perform claims for the SetToken indicating the list of claim
443443
* integrations. Each claim integration is associated to an adapter that provides the functionality to claim the rewards
444444
* for a specific token.
445445
*
@@ -464,7 +464,7 @@ contract ClaimModule is ModuleBase {
464464

465465
/**
466466
* Validates and stores the adapter address used to claim rewards for the passed rewardPool. If no adapters
467-
* left after removal then remove rewardPool from rewardPoolList and delete entry in claimSettings.
467+
* left after removal then remove rewardPool from rewardPoolList and delete entry in claimSettings.
468468
*
469469
* @param _setToken Address of SetToken
470470
* @param _rewardPool Address of the rewardPool that identifies the contract governing claims
@@ -484,7 +484,7 @@ contract ClaimModule is ModuleBase {
484484
}
485485

486486
/**
487-
* For batch functions validate arrays are of equal length and not empty. Return length of array for iteration.
487+
* For batch functions validate arrays are of equal length and not empty. Return length of array for iteration.
488488
*
489489
* @param _rewardPools Addresses of the rewardPool that identifies the contract governing claims
490490
* @param _integrationNames IDs of claim module integration (mapping on integration registry)

contracts/protocol/modules/CompoundLeverageModule.sol renamed to contracts/protocol/modules/v1/CompoundLeverageModule.sol

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
2323
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
2424
import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
2525

26-
import { Compound } from "../integration/lib/Compound.sol";
27-
import { ICErc20 } from "../../interfaces/external/ICErc20.sol";
28-
import { IComptroller } from "../../interfaces/external/IComptroller.sol";
29-
import { IController } from "../../interfaces/IController.sol";
30-
import { IDebtIssuanceModule } from "../../interfaces/IDebtIssuanceModule.sol";
31-
import { IExchangeAdapter } from "../../interfaces/IExchangeAdapter.sol";
32-
import { ISetToken } from "../../interfaces/ISetToken.sol";
33-
import { ModuleBase } from "../lib/ModuleBase.sol";
26+
import { Compound } from "../../integration/lib/Compound.sol";
27+
import { ICErc20 } from "../../../interfaces/external/ICErc20.sol";
28+
import { IComptroller } from "../../../interfaces/external/IComptroller.sol";
29+
import { IController } from "../../../interfaces/IController.sol";
30+
import { IDebtIssuanceModule } from "../../../interfaces/IDebtIssuanceModule.sol";
31+
import { IExchangeAdapter } from "../../../interfaces/IExchangeAdapter.sol";
32+
import { ISetToken } from "../../../interfaces/ISetToken.sol";
33+
import { ModuleBase } from "../../lib/ModuleBase.sol";
3434

3535
/**
3636
* @title CompoundLeverageModule

0 commit comments

Comments
 (0)