-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #177 from fei-protocol/feat/fip-22
Aave Liquidity and Incentives
- Loading branch information
Showing
14 changed files
with
1,151 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// SPDX-License-Identifier: agpl-3.0 | ||
pragma solidity ^0.8.0; | ||
|
||
library DataTypes { | ||
// refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties. | ||
struct ReserveData { | ||
//stores the reserve configuration | ||
ReserveConfigurationMap configuration; | ||
//the liquidity index. Expressed in ray | ||
uint128 liquidityIndex; | ||
//variable borrow index. Expressed in ray | ||
uint128 variableBorrowIndex; | ||
//the current supply rate. Expressed in ray | ||
uint128 currentLiquidityRate; | ||
//the current variable borrow rate. Expressed in ray | ||
uint128 currentVariableBorrowRate; | ||
//the current stable borrow rate. Expressed in ray | ||
uint128 currentStableBorrowRate; | ||
uint40 lastUpdateTimestamp; | ||
//tokens addresses | ||
address aTokenAddress; | ||
address stableDebtTokenAddress; | ||
address variableDebtTokenAddress; | ||
//address of the interest rate strategy | ||
address interestRateStrategyAddress; | ||
//the id of the reserve. Represents the position in the list of the active reserves | ||
uint8 id; | ||
} | ||
|
||
struct ReserveConfigurationMap { | ||
//bit 0-15: LTV | ||
//bit 16-31: Liq. threshold | ||
//bit 32-47: Liq. bonus | ||
//bit 48-55: Decimals | ||
//bit 56: Reserve is active | ||
//bit 57: reserve is frozen | ||
//bit 58: borrowing is enabled | ||
//bit 59: stable rate borrowing enabled | ||
//bit 60-63: reserved | ||
//bit 64-79: reserve factor | ||
uint256 data; | ||
} | ||
|
||
struct UserConfigurationMap { | ||
uint256 data; | ||
} | ||
|
||
enum InterestRateMode {NONE, STABLE, VARIABLE} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// SPDX-License-Identifier: agpl-3.0 | ||
pragma solidity ^0.8.0; | ||
pragma experimental ABIEncoderV2; | ||
|
||
interface IAaveDistributionManager { | ||
|
||
event AssetConfigUpdated(address indexed asset, uint256 emission); | ||
event AssetIndexUpdated(address indexed asset, uint256 index); | ||
event UserIndexUpdated(address indexed user, address indexed asset, uint256 index); | ||
event DistributionEndUpdated(uint256 newDistributionEnd); | ||
|
||
/** | ||
* @dev Sets the end date for the distribution | ||
* @param distributionEnd The end date timestamp | ||
**/ | ||
function setDistributionEnd(uint256 distributionEnd) external; | ||
|
||
/** | ||
* @dev Gets the end date for the distribution | ||
* @return The end of the distribution | ||
**/ | ||
function getDistributionEnd() external view returns (uint256); | ||
|
||
/** | ||
* @dev for backwards compatibility with the previous DistributionManager used | ||
* @return The end of the distribution | ||
**/ | ||
function DISTRIBUTION_END() external view returns(uint256); | ||
|
||
/** | ||
* @dev Returns the data of an user on a distribution | ||
* @param user Address of the user | ||
* @param asset The address of the reference asset of the distribution | ||
* @return The new index | ||
**/ | ||
function getUserAssetData(address user, address asset) external view returns (uint256); | ||
|
||
/** | ||
* @dev Returns the configuration of the distribution for a certain asset | ||
* @param asset The address of the reference asset of the distribution | ||
* @return The asset index, the emission per second and the last updated timestamp | ||
**/ | ||
function getAssetData(address asset) external view returns (uint256, uint256, uint256); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,272 @@ | ||
// SPDX-License-Identifier: agpl-3.0 | ||
pragma solidity ^0.8.0; | ||
|
||
// Copied from https://github.com/aave/governance-v2 | ||
// with updated solidity version and changed import to interface | ||
|
||
interface IExecutorWithTimelock {} | ||
|
||
interface IAaveGovernanceV2 { | ||
enum ProposalState {Pending, Canceled, Active, Failed, Succeeded, Queued, Expired, Executed} | ||
|
||
struct Vote { | ||
bool support; | ||
uint248 votingPower; | ||
} | ||
|
||
struct Proposal { | ||
uint256 id; | ||
address creator; | ||
IExecutorWithTimelock executor; | ||
address[] targets; | ||
uint256[] values; | ||
string[] signatures; | ||
bytes[] calldatas; | ||
bool[] withDelegatecalls; | ||
uint256 startBlock; | ||
uint256 endBlock; | ||
uint256 executionTime; | ||
uint256 forVotes; | ||
uint256 againstVotes; | ||
bool executed; | ||
bool canceled; | ||
address strategy; | ||
bytes32 ipfsHash; | ||
mapping(address => Vote) votes; | ||
} | ||
|
||
struct ProposalWithoutVotes { | ||
uint256 id; | ||
address creator; | ||
IExecutorWithTimelock executor; | ||
address[] targets; | ||
uint256[] values; | ||
string[] signatures; | ||
bytes[] calldatas; | ||
bool[] withDelegatecalls; | ||
uint256 startBlock; | ||
uint256 endBlock; | ||
uint256 executionTime; | ||
uint256 forVotes; | ||
uint256 againstVotes; | ||
bool executed; | ||
bool canceled; | ||
address strategy; | ||
bytes32 ipfsHash; | ||
} | ||
|
||
/** | ||
* @dev emitted when a new proposal is created | ||
* @param id Id of the proposal | ||
* @param creator address of the creator | ||
* @param executor The ExecutorWithTimelock contract that will execute the proposal | ||
* @param targets list of contracts called by proposal's associated transactions | ||
* @param values list of value in wei for each propoposal's associated transaction | ||
* @param signatures list of function signatures (can be empty) to be used when created the callData | ||
* @param calldatas list of calldatas: if associated signature empty, calldata ready, else calldata is arguments | ||
* @param withDelegatecalls boolean, true = transaction delegatecalls the taget, else calls the target | ||
* @param startBlock block number when vote starts | ||
* @param endBlock block number when vote ends | ||
* @param strategy address of the governanceStrategy contract | ||
* @param ipfsHash IPFS hash of the proposal | ||
**/ | ||
event ProposalCreated( | ||
uint256 id, | ||
address indexed creator, | ||
IExecutorWithTimelock indexed executor, | ||
address[] targets, | ||
uint256[] values, | ||
string[] signatures, | ||
bytes[] calldatas, | ||
bool[] withDelegatecalls, | ||
uint256 startBlock, | ||
uint256 endBlock, | ||
address strategy, | ||
bytes32 ipfsHash | ||
); | ||
|
||
/** | ||
* @dev emitted when a proposal is canceled | ||
* @param id Id of the proposal | ||
**/ | ||
event ProposalCanceled(uint256 id); | ||
|
||
/** | ||
* @dev emitted when a proposal is queued | ||
* @param id Id of the proposal | ||
* @param executionTime time when proposal underlying transactions can be executed | ||
* @param initiatorQueueing address of the initiator of the queuing transaction | ||
**/ | ||
event ProposalQueued(uint256 id, uint256 executionTime, address indexed initiatorQueueing); | ||
/** | ||
* @dev emitted when a proposal is executed | ||
* @param id Id of the proposal | ||
* @param initiatorExecution address of the initiator of the execution transaction | ||
**/ | ||
event ProposalExecuted(uint256 id, address indexed initiatorExecution); | ||
/** | ||
* @dev emitted when a vote is registered | ||
* @param id Id of the proposal | ||
* @param voter address of the voter | ||
* @param support boolean, true = vote for, false = vote against | ||
* @param votingPower Power of the voter/vote | ||
**/ | ||
event VoteEmitted(uint256 id, address indexed voter, bool support, uint256 votingPower); | ||
|
||
event GovernanceStrategyChanged(address indexed newStrategy, address indexed initiatorChange); | ||
|
||
event VotingDelayChanged(uint256 newVotingDelay, address indexed initiatorChange); | ||
|
||
event ExecutorAuthorized(address executor); | ||
|
||
event ExecutorUnauthorized(address executor); | ||
|
||
/** | ||
* @dev Creates a Proposal (needs Proposition Power of creator > Threshold) | ||
* @param executor The ExecutorWithTimelock contract that will execute the proposal | ||
* @param targets list of contracts called by proposal's associated transactions | ||
* @param values list of value in wei for each propoposal's associated transaction | ||
* @param signatures list of function signatures (can be empty) to be used when created the callData | ||
* @param calldatas list of calldatas: if associated signature empty, calldata ready, else calldata is arguments | ||
* @param withDelegatecalls if true, transaction delegatecalls the taget, else calls the target | ||
* @param ipfsHash IPFS hash of the proposal | ||
**/ | ||
function create( | ||
IExecutorWithTimelock executor, | ||
address[] memory targets, | ||
uint256[] memory values, | ||
string[] memory signatures, | ||
bytes[] memory calldatas, | ||
bool[] memory withDelegatecalls, | ||
bytes32 ipfsHash | ||
) external returns (uint256); | ||
|
||
/** | ||
* @dev Cancels a Proposal, | ||
* either at anytime by guardian | ||
* or when proposal is Pending/Active and threshold no longer reached | ||
* @param proposalId id of the proposal | ||
**/ | ||
function cancel(uint256 proposalId) external; | ||
|
||
/** | ||
* @dev Queue the proposal (If Proposal Succeeded) | ||
* @param proposalId id of the proposal to queue | ||
**/ | ||
function queue(uint256 proposalId) external; | ||
|
||
/** | ||
* @dev Execute the proposal (If Proposal Queued) | ||
* @param proposalId id of the proposal to execute | ||
**/ | ||
function execute(uint256 proposalId) external payable; | ||
|
||
/** | ||
* @dev Function allowing msg.sender to vote for/against a proposal | ||
* @param proposalId id of the proposal | ||
* @param support boolean, true = vote for, false = vote against | ||
**/ | ||
function submitVote(uint256 proposalId, bool support) external; | ||
|
||
/** | ||
* @dev Function to register the vote of user that has voted offchain via signature | ||
* @param proposalId id of the proposal | ||
* @param support boolean, true = vote for, false = vote against | ||
* @param v v part of the voter signature | ||
* @param r r part of the voter signature | ||
* @param s s part of the voter signature | ||
**/ | ||
function submitVoteBySignature( | ||
uint256 proposalId, | ||
bool support, | ||
uint8 v, | ||
bytes32 r, | ||
bytes32 s | ||
) external; | ||
|
||
/** | ||
* @dev Set new GovernanceStrategy | ||
* Note: owner should be a timelocked executor, so needs to make a proposal | ||
* @param governanceStrategy new Address of the GovernanceStrategy contract | ||
**/ | ||
function setGovernanceStrategy(address governanceStrategy) external; | ||
|
||
/** | ||
* @dev Set new Voting Delay (delay before a newly created proposal can be voted on) | ||
* Note: owner should be a timelocked executor, so needs to make a proposal | ||
* @param votingDelay new voting delay in seconds | ||
**/ | ||
function setVotingDelay(uint256 votingDelay) external; | ||
|
||
/** | ||
* @dev Add new addresses to the list of authorized executors | ||
* @param executors list of new addresses to be authorized executors | ||
**/ | ||
function authorizeExecutors(address[] memory executors) external; | ||
|
||
/** | ||
* @dev Remove addresses to the list of authorized executors | ||
* @param executors list of addresses to be removed as authorized executors | ||
**/ | ||
function unauthorizeExecutors(address[] memory executors) external; | ||
|
||
/** | ||
* @dev Let the guardian abdicate from its priviledged rights | ||
**/ | ||
function __abdicate() external; | ||
|
||
/** | ||
* @dev Getter of the current GovernanceStrategy address | ||
* @return The address of the current GovernanceStrategy contracts | ||
**/ | ||
function getGovernanceStrategy() external view returns (address); | ||
|
||
/** | ||
* @dev Getter of the current Voting Delay (delay before a created proposal can be voted on) | ||
* Different from the voting duration | ||
* @return The voting delay in seconds | ||
**/ | ||
function getVotingDelay() external view returns (uint256); | ||
|
||
/** | ||
* @dev Returns whether an address is an authorized executor | ||
* @param executor address to evaluate as authorized executor | ||
* @return true if authorized | ||
**/ | ||
function isExecutorAuthorized(address executor) external view returns (bool); | ||
|
||
/** | ||
* @dev Getter the address of the guardian, that can mainly cancel proposals | ||
* @return The address of the guardian | ||
**/ | ||
function getGuardian() external view returns (address); | ||
|
||
/** | ||
* @dev Getter of the proposal count (the current number of proposals ever created) | ||
* @return the proposal count | ||
**/ | ||
function getProposalsCount() external view returns (uint256); | ||
|
||
/** | ||
* @dev Getter of a proposal by id | ||
* @param proposalId id of the proposal to get | ||
* @return the proposal as ProposalWithoutVotes memory object | ||
**/ | ||
function getProposalById(uint256 proposalId) external view returns (ProposalWithoutVotes memory); | ||
|
||
/** | ||
* @dev Getter of the Vote of a voter about a proposal | ||
* Note: Vote is a struct: ({bool support, uint248 votingPower}) | ||
* @param proposalId id of the proposal | ||
* @param voter address of the voter | ||
* @return The associated Vote memory object | ||
**/ | ||
function getVoteOnProposal(uint256 proposalId, address voter) external view returns (Vote memory); | ||
|
||
/** | ||
* @dev Get the current state of a proposal | ||
* @param proposalId id of the proposal | ||
* @return The current state if the proposal | ||
**/ | ||
function getProposalState(uint256 proposalId) external view returns (ProposalState); | ||
} |
Oops, something went wrong.