mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
commit
9a764a517c
|
@ -0,0 +1,13 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.0;
|
||||
|
||||
contract Events {
|
||||
event LogClaimed(
|
||||
address[] assets,
|
||||
uint256 amt,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
);
|
||||
|
||||
event LogAllClaimed(address[] assets, address[] rewards, uint256[] amts);
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
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 v3 Incentives
|
||||
*/
|
||||
AaveIncentivesInterface internal constant incentives =
|
||||
AaveIncentivesInterface(0x929EC64c34a17401F460460D4B9390518E5B473e);
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.0;
|
||||
|
||||
interface AaveIncentivesInterface {
|
||||
function claimRewards(
|
||||
address[] calldata assets,
|
||||
uint256 amount,
|
||||
address to,
|
||||
address reward
|
||||
) external returns (uint256);
|
||||
|
||||
function claimAllRewards(address[] calldata assets, address to)
|
||||
external
|
||||
returns (address[] memory rewardsList, uint256[] memory claimedAmounts);
|
||||
}
|
78
contracts/arbitrum/connectors/aave/aave-v3-rewards/main.sol
Normal file
78
contracts/arbitrum/connectors/aave/aave-v3-rewards/main.sol
Normal file
|
@ -0,0 +1,78 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.0;
|
||||
|
||||
/**
|
||||
* @title Aave v3 Rewards.
|
||||
* @dev Claim Aave v3 rewards.
|
||||
*/
|
||||
|
||||
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 {
|
||||
/**
|
||||
* @dev Claim Pending Rewards.
|
||||
* @notice Claim Pending Rewards from Aave v3 incentives contract.
|
||||
* @param assets The list of assets supplied and borrowed.
|
||||
* @param amt The amount of reward to claim. (uint(-1) for max)
|
||||
* @param reward The address of reward token to claim.
|
||||
* @param getId ID to retrieve amt.
|
||||
* @param setId ID stores the amount of rewards claimed.
|
||||
*/
|
||||
function claim(
|
||||
address[] calldata assets,
|
||||
uint256 amt,
|
||||
address reward,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
)
|
||||
external
|
||||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
uint256 _amt = getUint(getId, amt);
|
||||
|
||||
require(assets.length > 0, "invalid-assets");
|
||||
|
||||
_amt = incentives.claimRewards(assets, _amt, address(this), reward);
|
||||
|
||||
TokenInterface weth = TokenInterface(wethAddr);
|
||||
uint256 wethAmount = weth.balanceOf(address(this));
|
||||
convertWethToEth(wethAmount > 0, weth, wethAmount);
|
||||
|
||||
setUint(setId, _amt);
|
||||
|
||||
_eventName = "LogClaimed(address[],uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(assets, _amt, getId, setId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Claim All Pending Rewards.
|
||||
* @notice Claim All Pending Rewards from Aave v3 incentives contract.
|
||||
* @param assets The list of assets supplied and borrowed.
|
||||
*/
|
||||
function claimAll(address[] calldata assets)
|
||||
external
|
||||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
require(assets.length > 0, "invalid-assets");
|
||||
uint256[] memory _amts = new uint256[](assets.length);
|
||||
address[] memory _rewards = new address[](assets.length);
|
||||
|
||||
(_rewards, _amts) = incentives.claimAllRewards(assets, address(this));
|
||||
|
||||
TokenInterface weth = TokenInterface(wethAddr);
|
||||
uint256 wethAmount = weth.balanceOf(address(this));
|
||||
convertWethToEth(wethAmount > 0, weth, wethAmount);
|
||||
|
||||
_eventName = "LogAllClaimed(address[],address[],uint256[])";
|
||||
_eventParam = abi.encode(assets, _rewards, _amts);
|
||||
}
|
||||
}
|
||||
|
||||
contract ConnectV3AaveIncentivesArbitrum is IncentivesResolver {
|
||||
string public constant name = "Aave-V3-Incentives-v1";
|
||||
}
|
13
contracts/mainnet/connectors/aave/aave-v3-rewards/events.sol
Normal file
13
contracts/mainnet/connectors/aave/aave-v3-rewards/events.sol
Normal file
|
@ -0,0 +1,13 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.0;
|
||||
|
||||
contract Events {
|
||||
event LogClaimed(
|
||||
address[] assets,
|
||||
uint256 amt,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
);
|
||||
|
||||
event LogAllClaimed(address[] assets, address[] rewards, uint256[] amts);
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
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 v3 Incentives
|
||||
*/
|
||||
AaveIncentivesInterface internal constant incentives =
|
||||
AaveIncentivesInterface(0x8164Cc65827dcFe994AB23944CBC90e0aa80bFcb);
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.0;
|
||||
|
||||
interface AaveIncentivesInterface {
|
||||
function claimRewards(
|
||||
address[] calldata assets,
|
||||
uint256 amount,
|
||||
address to,
|
||||
address reward
|
||||
) external returns (uint256);
|
||||
|
||||
function claimAllRewards(address[] calldata assets, address to)
|
||||
external
|
||||
returns (address[] memory rewardsList, uint256[] memory claimedAmounts);
|
||||
}
|
78
contracts/mainnet/connectors/aave/aave-v3-rewards/main.sol
Normal file
78
contracts/mainnet/connectors/aave/aave-v3-rewards/main.sol
Normal file
|
@ -0,0 +1,78 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.0;
|
||||
|
||||
/**
|
||||
* @title Aave v3 Rewards.
|
||||
* @dev Claim Aave v3 rewards.
|
||||
*/
|
||||
|
||||
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 {
|
||||
/**
|
||||
* @dev Claim Pending Rewards.
|
||||
* @notice Claim Pending Rewards from Aave v3 incentives contract.
|
||||
* @param assets The list of assets supplied and borrowed.
|
||||
* @param amt The amount of reward to claim. (uint(-1) for max)
|
||||
* @param reward The address of reward token to claim.
|
||||
* @param getId ID to retrieve amt.
|
||||
* @param setId ID stores the amount of rewards claimed.
|
||||
*/
|
||||
function claim(
|
||||
address[] calldata assets,
|
||||
uint256 amt,
|
||||
address reward,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
)
|
||||
external
|
||||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
uint256 _amt = getUint(getId, amt);
|
||||
|
||||
require(assets.length > 0, "invalid-assets");
|
||||
|
||||
_amt = incentives.claimRewards(assets, _amt, address(this), reward);
|
||||
|
||||
TokenInterface weth = TokenInterface(wethAddr);
|
||||
uint256 wethAmount = weth.balanceOf(address(this));
|
||||
convertWethToEth(wethAmount > 0, weth, wethAmount);
|
||||
|
||||
setUint(setId, _amt);
|
||||
|
||||
_eventName = "LogClaimed(address[],uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(assets, _amt, getId, setId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Claim All Pending Rewards.
|
||||
* @notice Claim All Pending Rewards from Aave v3 incentives contract.
|
||||
* @param assets The list of assets supplied and borrowed.
|
||||
*/
|
||||
function claimAll(address[] calldata assets)
|
||||
external
|
||||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
require(assets.length > 0, "invalid-assets");
|
||||
uint256[] memory _amts = new uint256[](assets.length);
|
||||
address[] memory _rewards = new address[](assets.length);
|
||||
|
||||
(_rewards, _amts) = incentives.claimAllRewards(assets, address(this));
|
||||
|
||||
TokenInterface weth = TokenInterface(wethAddr);
|
||||
uint256 wethAmount = weth.balanceOf(address(this));
|
||||
convertWethToEth(wethAmount > 0, weth, wethAmount);
|
||||
|
||||
_eventName = "LogAllClaimed(address[],address[],uint256[])";
|
||||
_eventParam = abi.encode(assets, _rewards, _amts);
|
||||
}
|
||||
}
|
||||
|
||||
contract ConnectV3AaveIncentives is IncentivesResolver {
|
||||
string public constant name = "Aave-V3-Incentives-v1";
|
||||
}
|
13
contracts/polygon/connectors/aave/aave-v3-rewards/events.sol
Normal file
13
contracts/polygon/connectors/aave/aave-v3-rewards/events.sol
Normal file
|
@ -0,0 +1,13 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.0;
|
||||
|
||||
contract Events {
|
||||
event LogClaimed(
|
||||
address[] assets,
|
||||
uint256 amt,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
);
|
||||
|
||||
event LogAllClaimed(address[] assets, address[] rewards, uint256[] amts);
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
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 v3 Incentives
|
||||
*/
|
||||
AaveIncentivesInterface internal constant incentives =
|
||||
AaveIncentivesInterface(0x929EC64c34a17401F460460D4B9390518E5B473e);
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.0;
|
||||
|
||||
interface AaveIncentivesInterface {
|
||||
function claimRewards(
|
||||
address[] calldata assets,
|
||||
uint256 amount,
|
||||
address to,
|
||||
address reward
|
||||
) external returns (uint256);
|
||||
|
||||
function claimAllRewards(address[] calldata assets, address to)
|
||||
external
|
||||
returns (address[] memory rewardsList, uint256[] memory claimedAmounts);
|
||||
}
|
78
contracts/polygon/connectors/aave/aave-v3-rewards/main.sol
Normal file
78
contracts/polygon/connectors/aave/aave-v3-rewards/main.sol
Normal file
|
@ -0,0 +1,78 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.0;
|
||||
|
||||
/**
|
||||
* @title Aave v3 Rewards.
|
||||
* @dev Claim Aave v3 rewards.
|
||||
*/
|
||||
|
||||
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 {
|
||||
/**
|
||||
* @dev Claim Pending Rewards.
|
||||
* @notice Claim Pending Rewards from Aave v3 incentives contract.
|
||||
* @param assets The list of assets supplied and borrowed.
|
||||
* @param amt The amount of reward to claim. (uint(-1) for max)
|
||||
* @param reward The address of reward token to claim.
|
||||
* @param getId ID to retrieve amt.
|
||||
* @param setId ID stores the amount of rewards claimed.
|
||||
*/
|
||||
function claim(
|
||||
address[] calldata assets,
|
||||
uint256 amt,
|
||||
address reward,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
)
|
||||
external
|
||||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
uint256 _amt = getUint(getId, amt);
|
||||
|
||||
require(assets.length > 0, "invalid-assets");
|
||||
|
||||
_amt = incentives.claimRewards(assets, _amt, address(this), reward);
|
||||
|
||||
TokenInterface wmatic = TokenInterface(wmaticAddr);
|
||||
uint256 wmaticAmount = wmatic.balanceOf(address(this));
|
||||
convertWmaticToMatic(wmaticAmount > 0, wmatic, wmaticAmount);
|
||||
|
||||
setUint(setId, _amt);
|
||||
|
||||
_eventName = "LogClaimed(address[],uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(assets, _amt, getId, setId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Claim All Pending Rewards.
|
||||
* @notice Claim All Pending Rewards from Aave v3 incentives contract.
|
||||
* @param assets The list of assets supplied and borrowed.
|
||||
*/
|
||||
function claimAll(address[] calldata assets)
|
||||
external
|
||||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
require(assets.length > 0, "invalid-assets");
|
||||
uint256[] memory _amts = new uint256[](assets.length);
|
||||
address[] memory _rewards = new address[](assets.length);
|
||||
|
||||
(_rewards, _amts) = incentives.claimAllRewards(assets, address(this));
|
||||
|
||||
TokenInterface wmatic = TokenInterface(wmaticAddr);
|
||||
uint256 wmaticAmount = wmatic.balanceOf(address(this));
|
||||
convertWmaticToMatic(wmaticAmount > 0, wmatic, wmaticAmount);
|
||||
|
||||
_eventName = "LogAllClaimed(address[],address[],uint256[])";
|
||||
_eventParam = abi.encode(assets, _rewards, _amts);
|
||||
}
|
||||
}
|
||||
|
||||
contract ConnectV3AaveIncentivesPolygon is IncentivesResolver {
|
||||
string public constant name = "Aave-V3-Incentives-v1";
|
||||
}
|
Loading…
Reference in New Issue
Block a user