@@ -25,22 +25,22 @@ import { SafeCast } from "@openzeppelin/contracts/utils/SafeCast.sol";
25
25
import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol " ;
26
26
import { SignedSafeMath } from "@openzeppelin/contracts/math/SignedSafeMath.sol " ;
27
27
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 " ;
36
36
37
37
38
38
/**
39
39
* @title AmmModule
40
40
* @author Set Protocol
41
41
*
42
42
* 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.
44
44
*/
45
45
contract AmmModule is ModuleBase , ReentrancyGuard {
46
46
using SafeCast for int256 ;
@@ -61,7 +61,7 @@ contract AmmModule is ModuleBase, ReentrancyGuard {
61
61
address [] _components ,
62
62
int256 [] _componentBalancesDelta // Change in SetToken component token balances
63
63
);
64
-
64
+
65
65
event LiquidityRemoved (
66
66
ISetToken indexed _setToken ,
67
67
address indexed _ammPool ,
@@ -80,11 +80,11 @@ contract AmmModule is ModuleBase, ReentrancyGuard {
80
80
address liquidityToken; // Address of the AMM pool token
81
81
uint256 preActionLiquidityTokenBalance; // Balance of liquidity token before add/remove liquidity action
82
82
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.
84
84
// When removing liquidity, quantity to dispose of
85
85
uint256 [] totalNotionalComponents; // When adding liquidity, maximum components provided
86
86
// 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
88
88
address [] components; // List of component addresses for providing/removing liquidity
89
89
}
90
90
@@ -138,11 +138,11 @@ contract AmmModule is ModuleBase, ReentrancyGuard {
138
138
139
139
emit LiquidityAdded (_setToken, _ammPool, liquidityTokenDelta, _components, componentsDelta);
140
140
}
141
-
141
+
142
142
/**
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.
144
144
* 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
146
146
* liquidity pool tokens to receive.
147
147
*
148
148
* @param _setToken Address of SetToken
@@ -193,7 +193,7 @@ contract AmmModule is ModuleBase, ReentrancyGuard {
193
193
}
194
194
195
195
/**
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
197
197
* liquidity pool tokens to provide and the components and minimum quantity of component units to receive
198
198
*
199
199
* @param _setToken Address of SetToken
@@ -240,7 +240,7 @@ contract AmmModule is ModuleBase, ReentrancyGuard {
240
240
liquidityTokenDelta,
241
241
_components,
242
242
componentsDelta
243
- );
243
+ );
244
244
}
245
245
246
246
/**
@@ -262,7 +262,7 @@ contract AmmModule is ModuleBase, ReentrancyGuard {
262
262
uint256 _poolTokenPositionUnits ,
263
263
address _component ,
264
264
uint256 _minComponentUnitsReceived
265
- )
265
+ )
266
266
external
267
267
nonReentrant
268
268
onlyManagerAndValidSet (_setToken)
@@ -339,14 +339,14 @@ contract AmmModule is ModuleBase, ReentrancyGuard {
339
339
actionInfo.preActionComponentBalances = _getTokenBalances (address (_setToken), _components);
340
340
341
341
actionInfo.liquidityQuantity = actionInfo.totalSupply.getDefaultTotalNotional (_poolTokenInPositionUnit);
342
-
342
+
343
343
actionInfo.totalNotionalComponents = _getTotalNotionalComponents (_setToken, _componentUnits);
344
344
345
345
actionInfo.componentUnits = _componentUnits;
346
-
347
- actionInfo.components = _components;
348
346
349
- return actionInfo;
347
+ actionInfo.components = _components;
348
+
349
+ return actionInfo;
350
350
}
351
351
352
352
function _getActionInfoSingleAsset (
@@ -426,7 +426,7 @@ contract AmmModule is ModuleBase, ReentrancyGuard {
426
426
);
427
427
}
428
428
}
429
-
429
+
430
430
function _executeAddLiquidity (ActionInfo memory _actionInfo ) internal {
431
431
(
432
432
address targetAmm , uint256 callValue , bytes memory methodData
@@ -456,9 +456,9 @@ contract AmmModule is ModuleBase, ReentrancyGuard {
456
456
457
457
_executeComponentApprovals (_actionInfo);
458
458
459
- _actionInfo.setToken.invoke (targetAmm, callValue, methodData);
459
+ _actionInfo.setToken.invoke (targetAmm, callValue, methodData);
460
460
}
461
-
461
+
462
462
function _executeRemoveLiquidity (ActionInfo memory _actionInfo ) internal {
463
463
(
464
464
address targetAmm , uint256 callValue , bytes memory methodData
@@ -476,7 +476,7 @@ contract AmmModule is ModuleBase, ReentrancyGuard {
476
476
_actionInfo.liquidityQuantity
477
477
);
478
478
479
- _actionInfo.setToken.invoke (targetAmm, callValue, methodData);
479
+ _actionInfo.setToken.invoke (targetAmm, callValue, methodData);
480
480
}
481
481
482
482
function _executeRemoveLiquiditySingleAsset (ActionInfo memory _actionInfo ) internal {
@@ -496,9 +496,9 @@ contract AmmModule is ModuleBase, ReentrancyGuard {
496
496
_actionInfo.liquidityQuantity
497
497
);
498
498
499
- _actionInfo.setToken.invoke (targetAmm, callValue, methodData);
499
+ _actionInfo.setToken.invoke (targetAmm, callValue, methodData);
500
500
}
501
-
501
+
502
502
function _validateMinimumLiquidityReceived (ActionInfo memory _actionInfo ) internal view {
503
503
uint256 liquidityTokenBalance = IERC20 (_actionInfo.liquidityToken).balanceOf (address (_actionInfo.setToken));
504
504
0 commit comments