Merge pull request #23 from Instadapp/aave-rewards

Add Aave rewards connector
This commit is contained in:
Samyak Jain 2021-04-13 22:09:32 +10:00 committed by GitHub
commit e85a489b10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,11 @@
pragma solidity ^0.7.0;
contract Events {
event LogClaimed(
address[] assets,
uint256 amt,
bool stake,
uint256 getId,
uint256 setId
);
}

View File

@ -0,0 +1,12 @@
pragma solidity ^0.7.0;
import { DSMath } from "../../common/math.sol";
import { Basic } from "../../common/basic.sol";
import { AaveIncentivesInterface } from "./interface.sol";
abstract contract Helpers is DSMath, Basic {
/**
* @dev Aave Incentives
*/
AaveIncentivesInterface internal constant incentives = AaveIncentivesInterface(0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B);
}

View File

@ -0,0 +1,10 @@
pragma solidity ^0.7.0;
interface AaveIncentivesInterface {
function claimRewards(
address[] calldata assets,
uint256 amount,
address to,
bool stake
) external returns (uint256);
}

View File

@ -0,0 +1,28 @@
pragma solidity ^0.7.0;
import { TokenInterface } from "../../common/interfaces.sol";
import { Stores } from "../../common/stores.sol";
import { Helpers } from "./helpers.sol";
import { Events } from "./events.sol";
abstract contract IncentivesResolver is Helpers, Events {
function claim(
address[] calldata assets,
uint256 amt,
bool stake,
uint256 getId,
uint256 setId
) external payable returns (string memory _eventName, bytes memory _eventParam) {
uint _amt = getUint(getId, amt);
require(assets.length > 0, "invalid-assets");
_amt = incentives.claimRewards(assets, _amt, address(this), stake);
setUint(setId, _amt);
_eventName = "LogClaimed(address[],uint256,bool,uint256,uint256)";
_eventParam = abi.encode(assets, _amt, stake, getId, setId);
}
}