Euler diff: contracts/modules/Swap.sol

Before: contract 0xf40e8314143B4CF1764CCCd22588a8794a00d8Ca
After: git 1d8c9f1d548570a0235cda39b13a76e658ae37d3
Files changed (5) hide show
  1. contracts/modules/Swap.sol +3 -3
  2. contracts/Interfaces.sol +6 -0
  3. contracts/IRiskManager.sol +5 -5
  4. contracts/Base.sol +7 -0
  5. contracts/Constants.sol +3 -1
contracts/modules/Swap.sol CHANGED
@@ -422,12 +422,12 @@
422
422
  logAssetStatus(assetCache);
423
423
  }
424
424
 
425
425
  function processDeposit(AssetStorage storage assetStorage, AssetCache memory assetCache, address eTokenAddress, address account, uint amount) private {
426
- uint amountInternal;
426
+ uint amountDecoded = decodeExternalAmount(assetCache, amount);
427
+ uint amountInternal = underlyingAmountToBalance(assetCache, amountDecoded);
427
428
 
428
- amountInternal = underlyingAmountToBalance(assetCache, decodeExternalAmount(assetCache, amount));
429
- assetCache.poolSize += amount;
429
+ assetCache.poolSize += amountDecoded;
430
430
 
431
431
  increaseBalance(assetStorage, assetCache, eTokenAddress, account, amountInternal);
432
432
 
433
433
  logAssetStatus(assetCache);
contracts/Interfaces.sol CHANGED
@@ -18,8 +18,14 @@
18
18
  function transfer(address to, uint value) external returns (bool);
19
19
  function transferFrom(address from, address to, uint value) external returns (bool);
20
20
  }
21
21
 
22
+ interface IERC20Permit {
23
+ function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
24
+ function permit(address holder, address spender, uint256 nonce, uint256 expiry, bool allowed, uint8 v, bytes32 r, bytes32 s) external;
25
+ function permit(address owner, address spender, uint value, uint deadline, bytes calldata signature) external;
26
+ }
27
+
22
28
  interface IERC3156FlashBorrower {
23
29
  function onFlashLoan(address initiator, address token, uint256 amount, uint256 fee, bytes calldata data) external returns (bytes32);
24
30
  }
25
31
 
contracts/IRiskManager.sol CHANGED
@@ -27,11 +27,11 @@
27
27
  }
28
28
 
29
29
  function getNewMarketParameters(address underlying) external returns (NewMarketParameters memory);
30
30
 
31
- function requireLiquidity(address account) external;
32
- function computeLiquidity(address account) external returns (LiquidityStatus memory status);
33
- function computeAssetLiquidities(address account) external returns (AssetLiquidity[] memory assets);
31
+ function requireLiquidity(address account) external view;
32
+ function computeLiquidity(address account) external view returns (LiquidityStatus memory status);
33
+ function computeAssetLiquidities(address account) external view returns (AssetLiquidity[] memory assets);
34
34
 
35
- function getPrice(address underlying) external returns (uint twap, uint twapPeriod);
36
- function getPriceFull(address underlying) external returns (uint twap, uint twapPeriod, uint currPrice);
35
+ function getPrice(address underlying) external view returns (uint twap, uint twapPeriod);
36
+ function getPriceFull(address underlying) external view returns (uint twap, uint twapPeriod, uint currPrice);
37
37
  }
contracts/Base.sol CHANGED
@@ -52,8 +52,15 @@
52
52
  modifier reentrantOK() { // documentation only
53
53
  _;
54
54
  }
55
55
 
56
+ // Used to flag functions which do not modify storage, but do perform a delegate call
57
+ // to a view function, which prohibits a standard view modifier. The flag is used to
58
+ // patch state mutability in compiled ABIs and interfaces.
59
+ modifier staticDelegate() {
60
+ _;
61
+ }
62
+
56
63
  // WARNING: Must be very careful with this modifier. It resets the free memory pointer
57
64
  // to the value it was when the function started. This saves gas if more memory will
58
65
  // be allocated in the future. However, if the memory will be later referenced
59
66
  // (for example because the function has returned a pointer to it) then you cannot
contracts/Constants.sol CHANGED
@@ -20,11 +20,12 @@
20
20
  uint internal constant RESERVE_FEE_SCALE = 4_000_000_000; // must fit into a uint32
21
21
  uint32 internal constant DEFAULT_RESERVE_FEE = uint32(0.23 * 4_000_000_000);
22
22
  uint internal constant INITIAL_INTEREST_ACCUMULATOR = 1e27;
23
23
  uint internal constant AVERAGE_LIQUIDITY_PERIOD = 24 * 60 * 60;
24
- uint16 internal constant MIN_UNISWAP3_OBSERVATION_CARDINALITY = 10;
24
+ uint16 internal constant MIN_UNISWAP3_OBSERVATION_CARDINALITY = 144;
25
25
  uint24 internal constant DEFAULT_TWAP_WINDOW_SECONDS = 30 * 60;
26
26
  uint32 internal constant DEFAULT_BORROW_FACTOR = uint32(0.28 * 4_000_000_000);
27
+ uint32 internal constant SELF_COLLATERAL_FACTOR = uint32(0.95 * 4_000_000_000);
27
28
 
28
29
 
29
30
  // Implementation internals
30
31
 
@@ -74,8 +75,9 @@
74
75
  // Classes
75
76
  uint internal constant MODULEID__IRM_CLASS__STABLE = 2_000_500;
76
77
  uint internal constant MODULEID__IRM_CLASS__MAJOR = 2_000_501;
77
78
  uint internal constant MODULEID__IRM_CLASS__MIDCAP = 2_000_502;
79
+ uint internal constant MODULEID__IRM_CLASS__MEGA = 2_000_503;
78
80
 
79
81
  // Swap types
80
82
  uint internal constant SWAP_TYPE__UNI_EXACT_INPUT_SINGLE = 1;
81
83
  uint internal constant SWAP_TYPE__UNI_EXACT_INPUT = 2;