mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
Merge pull request #247 from Instadapp/Euler-Rewards-Connector
Euler rewards connector
This commit is contained in:
commit
c6a6193c2a
11
contracts/mainnet/connectors/euler/euler-rewards/events.sol
Normal file
11
contracts/mainnet/connectors/euler/euler-rewards/events.sol
Normal file
|
@ -0,0 +1,11 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.0;
|
||||
|
||||
contract Events {
|
||||
event LogClaimed(
|
||||
address user,
|
||||
address token,
|
||||
uint256 amt,
|
||||
uint256 setId
|
||||
);
|
||||
}
|
13
contracts/mainnet/connectors/euler/euler-rewards/helpers.sol
Normal file
13
contracts/mainnet/connectors/euler/euler-rewards/helpers.sol
Normal file
|
@ -0,0 +1,13 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.0;
|
||||
import "./interface.sol";
|
||||
import { Basic } from "../../../common/basic.sol";
|
||||
|
||||
contract Helpers is Basic {
|
||||
|
||||
/**
|
||||
* @dev Euler Incentives Distributor
|
||||
*/
|
||||
IEulerDistributor internal constant eulerDistribute = IEulerDistributor(0xd524E29E3BAF5BB085403Ca5665301E94387A7e2);
|
||||
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.0;
|
||||
|
||||
interface IEulerDistributor {
|
||||
function claim(address account, address token, uint claimable, bytes32[] calldata proof, address stake) external;
|
||||
}
|
42
contracts/mainnet/connectors/euler/euler-rewards/main.sol
Normal file
42
contracts/mainnet/connectors/euler/euler-rewards/main.sol
Normal file
|
@ -0,0 +1,42 @@
|
|||
//SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.7.0;
|
||||
import "./helpers.sol";
|
||||
import "./events.sol";
|
||||
|
||||
/**
|
||||
* @title Euler Rewards.
|
||||
* @dev Claim Euler rewards.
|
||||
*/
|
||||
|
||||
contract EulerIncentives is Helpers, Events {
|
||||
|
||||
/**
|
||||
* @dev Claim Pending Rewards.
|
||||
* @notice Claim Pending Rewards from Euler incentives contract.
|
||||
* @param user Address that should receive tokens.
|
||||
* @param token Address of token being claimed (ie EUL)
|
||||
* @param amt The amount of reward to claim.
|
||||
* @param proof Merkle proof that validates this claim.
|
||||
* @param setId ID stores the amount of rewards claimed.
|
||||
*/
|
||||
function claim(
|
||||
address user,
|
||||
address token,
|
||||
uint256 amt,
|
||||
bytes32[] memory proof,
|
||||
uint256 setId
|
||||
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||
require(proof.length > 0, "proofs-empty");
|
||||
|
||||
eulerDistribute.claim(user, token, amt, proof, address(0));
|
||||
|
||||
setUint(setId, amt);
|
||||
|
||||
_eventName = "LogClaimed(address,address,uint256,uint256)";
|
||||
_eventParam = abi.encode(user, token, amt, setId);
|
||||
}
|
||||
}
|
||||
|
||||
contract ConnectV2EulerIncentives is EulerIncentives {
|
||||
string public constant name = "Euler-Incentives-v1";
|
||||
}
|
72
test/mainnet/euler-rewards/euler-rewards.test.ts
Normal file
72
test/mainnet/euler-rewards/euler-rewards.test.ts
Normal file
|
@ -0,0 +1,72 @@
|
|||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||
import { ethers } from "hardhat";
|
||||
import { ConnectV2EulerIncentives, ConnectV2EulerIncentives__factory } from "../../../typechain";
|
||||
import hre from "hardhat";
|
||||
|
||||
describe("Euler Rewards Claim Test", () => {
|
||||
let signer: SignerWithAddress;
|
||||
let signer_user: any;
|
||||
const user = "0x9F60699cE23f1Ab86Ec3e095b477Ff79d4f409AD";
|
||||
const EUL = "0xd9Fcd98c322942075A5C3860693e9f4f03AAE07b";
|
||||
|
||||
before(async () => {
|
||||
[signer] = await ethers.getSigners();
|
||||
});
|
||||
|
||||
describe("Euler Functions", () => {
|
||||
let contract: ConnectV2EulerIncentives;
|
||||
|
||||
before(async () => {
|
||||
await hre.network.provider.request({
|
||||
method: "hardhat_reset",
|
||||
params: [
|
||||
{
|
||||
forking: {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
jsonRpcUrl: hre.config.networks.hardhat.forking.url,
|
||||
blockNumber: 15247044,
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const deployer = new ConnectV2EulerIncentives__factory(signer);
|
||||
contract = await deployer.deploy();
|
||||
await contract.deployed();
|
||||
console.log("Contract deployed at: ", contract.address);
|
||||
|
||||
await hre.network.provider.request({
|
||||
method: 'hardhat_impersonateAccount',
|
||||
params: [user],
|
||||
})
|
||||
|
||||
signer_user = await ethers.getSigner(user)
|
||||
});
|
||||
|
||||
it("Returns the positions on Euler", async () => {
|
||||
let response = await contract
|
||||
.connect(signer_user)
|
||||
.claim(
|
||||
user,
|
||||
EUL,
|
||||
"459635735326895",
|
||||
["0x7289f1c53c25e201538b91f7f6582388677bd6ff2fca03082267dbb1d96258ac",
|
||||
'0xc85ccc67cd68d38b0da6eec50c3c897757832450e22ca103543589fb610b79ee',
|
||||
'0x7e57faa32389a498f27187bc1c8ebb993a2065f019e3840cf36d599866ea5504',
|
||||
'0x38aae0a5be3e76eef383cc55c48d029acb1c6c4ed91c8385a501c1cc8c2031ca',
|
||||
'0x8bfd0363720bf2e5671b2689adbf667b74e47be7a5e91d36c3bdb24e4abad4f4',
|
||||
'0xc23081eb1f3001535376d454a070abd67a27de6f3db68089568cf981adeb480f',
|
||||
'0x8356b1a7033ff341b75749de37aab0d3a6a9420f20c03b9e07d0f7d3d1840753',
|
||||
'0x4300ab0ed87f84baa140f31113e2eee8d20dea7d7ff7848cf6806ecd8067b1c9',
|
||||
'0x83248015245f51e6d42021617415097cde157288d1c1de17f4de5fcbbd97b70e',
|
||||
'0x785649546b18cad99c2aea8d889689b5b2d4fabc15e6a9ea1ff2b9310beebc44',
|
||||
'0x310fdf199874bf9f992c02125278b4592bec5cd5ad1ee30fac130fa2b9ffc0ae',
|
||||
'0x6d0a8568a994d5b8a356cf1a933ff8f5c195ea72f0f213f38a08ff3d87b3c4da'
|
||||
],
|
||||
"0"
|
||||
)
|
||||
console.log(response);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user