Skip to content

Commit 653284e

Browse files
authored
AaveLeverageStrategy extension (#72)
* add AaveFLIStrategyExtension * remove unused import * set up basic constructor tests * fix engage and update tests * add rebalance and tests * add iterateRebalance tests * add ripcord tests * add disengage tests * add misc tests * fix naming of flexibleLeverage utils functions * fix how decimal units are handled * add integration tests * improve comments * add aave v2 contracts * clean up * fix decimals * update comments * review changes * fix comment * update AaveLeverageModule and AaveV2 external contracts * fix whitespace
1 parent 14f4e89 commit 653284e

File tree

54 files changed

+20639
-12
lines changed

Some content is hidden

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

54 files changed

+20639
-12
lines changed

contracts/adapters/AaveLeverageStrategyExtension.sol

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

contracts/adapters/FlexibleLeverageStrategyExtension.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { ICErc20 } from "../interfaces/ICErc20.sol";
2828
import { IBaseManager } from "../interfaces/IBaseManager.sol";
2929
import { IChainlinkAggregatorV3 } from "../interfaces/IChainlinkAggregatorV3.sol";
3030
import { IComptroller } from "../interfaces/IComptroller.sol";
31-
import { ICompoundLeverageModule } from "../interfaces/ICompoundLeverageModule.sol";
31+
import { ILeverageModule } from "../interfaces/ILeverageModule.sol";
3232
import { ISetToken } from "../interfaces/ISetToken.sol";
3333
import { PreciseUnitMath } from "../lib/PreciseUnitMath.sol";
3434
import { StringArrayUtils } from "../lib/StringArrayUtils.sol";
@@ -104,7 +104,7 @@ contract FlexibleLeverageStrategyExtension is BaseExtension {
104104

105105
struct ContractSettings {
106106
ISetToken setToken; // Instance of leverage token
107-
ICompoundLeverageModule leverageModule; // Instance of Compound leverage module
107+
ILeverageModule leverageModule; // Instance of Compound leverage module
108108
IComptroller comptroller; // Instance of Compound Comptroller
109109
IChainlinkAggregatorV3 collateralPriceOracle; // Chainlink oracle feed that returns prices in 8 decimals for collateral asset
110110
IChainlinkAggregatorV3 borrowPriceOracle; // Chainlink oracle feed that returns prices in 8 decimals for borrow asset

contracts/interfaces/ICompoundLeverageModule.sol renamed to contracts/interfaces/ILeverageModule.sol

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

44
import { ISetToken } from "./ISetToken.sol";
55

6-
interface ICompoundLeverageModule {
6+
interface ILeverageModule {
77
function sync(
88
ISetToken _setToken
99
) external;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// SPDX-License-Identifier: agpl-3.0
2+
pragma solidity 0.6.10;
3+
pragma experimental ABIEncoderV2;
4+
5+
interface IProtocolDataProvider {
6+
struct TokenData {
7+
string symbol;
8+
address tokenAddress;
9+
}
10+
11+
function ADDRESSES_PROVIDER() external view returns (address);
12+
function getAllReservesTokens() external view returns (TokenData[] memory);
13+
function getAllATokens() external view returns (TokenData[] memory);
14+
function getReserveConfigurationData(address asset) external view returns (uint256 decimals, uint256 ltv, uint256 liquidationThreshold, uint256 liquidationBonus, uint256 reserveFactor, bool usageAsCollateralEnabled, bool borrowingEnabled, bool stableBorrowRateEnabled, bool isActive, bool isFrozen);
15+
function getReserveData(address asset) external view returns (uint256 availableLiquidity, uint256 totalStableDebt, uint256 totalVariableDebt, uint256 liquidityRate, uint256 variableBorrowRate, uint256 stableBorrowRate, uint256 averageStableBorrowRate, uint256 liquidityIndex, uint256 variableBorrowIndex, uint40 lastUpdateTimestamp);
16+
function getUserReserveData(address asset, address user) external view returns (uint256 currentATokenBalance, uint256 currentStableDebt, uint256 currentVariableDebt, uint256 principalStableDebt, uint256 scaledVariableDebt, uint256 stableBorrowRate, uint256 liquidityRate, uint40 stableRateLastUpdated, bool usageAsCollateralEnabled);
17+
function getReserveTokensAddresses(address asset) external view returns (address aTokenAddress, address stableDebtTokenAddress, address variableDebtTokenAddress);
18+
}

external/abi/aaveV2/AaveGovernanceV2.json

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

external/abi/aaveV2/AaveTokenV2Mintable.json

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

0 commit comments

Comments
 (0)