Skip to content

Commit 2d242d6

Browse files
authored
add IRewardClaim interface (#3610)
* add IRewardClaim interface This is taken from PR #3491 Would like to review and merge it into main first before we finish the contract so that it's easy to share with external parties. * rename event for consistency * add IRewardClaim ABI Json
1 parent 7dee60e commit 2d242d6

File tree

3 files changed

+124
-1
lines changed

3 files changed

+124
-1
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
[
2+
{
3+
"type": "function",
4+
"name": "claimRewards",
5+
"inputs": [
6+
{
7+
"name": "lifetimeRewards",
8+
"type": "uint256",
9+
"internalType": "uint256"
10+
},
11+
{
12+
"name": "proof",
13+
"type": "tuple",
14+
"internalType": "struct IRewardClaim.LifetimeRewardsProof",
15+
"components": [
16+
{
17+
"name": "siblings",
18+
"type": "bytes32[]",
19+
"internalType": "bytes32[]"
20+
}
21+
]
22+
},
23+
{
24+
"name": "authRootInputs",
25+
"type": "bytes32[7]",
26+
"internalType": "bytes32[7]"
27+
}
28+
],
29+
"outputs": [],
30+
"stateMutability": "nonpayable"
31+
},
32+
{
33+
"type": "function",
34+
"name": "claimedRewards",
35+
"inputs": [
36+
{
37+
"name": "claimer",
38+
"type": "address",
39+
"internalType": "address"
40+
}
41+
],
42+
"outputs": [
43+
{
44+
"name": "",
45+
"type": "uint256",
46+
"internalType": "uint256"
47+
}
48+
],
49+
"stateMutability": "view"
50+
},
51+
{
52+
"type": "event",
53+
"name": "RewardsClaimed",
54+
"inputs": [
55+
{
56+
"name": "user",
57+
"type": "address",
58+
"indexed": true,
59+
"internalType": "address"
60+
},
61+
{
62+
"name": "amount",
63+
"type": "uint256",
64+
"indexed": false,
65+
"internalType": "uint256"
66+
}
67+
],
68+
"anonymous": false
69+
},
70+
{
71+
"type": "error",
72+
"name": "AlreadyClaimed",
73+
"inputs": []
74+
},
75+
{
76+
"type": "error",
77+
"name": "InvalidAuthRoot",
78+
"inputs": []
79+
},
80+
{
81+
"type": "error",
82+
"name": "InvalidRewardAmount",
83+
"inputs": []
84+
}
85+
]
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.28;
3+
4+
interface IRewardClaim {
5+
/// @notice Proof for rewards merkle tree. Obtained from Espresso query service API.
6+
struct LifetimeRewardsProof {
7+
bytes32[] siblings;
8+
}
9+
10+
/// @notice User claimed rewards
11+
event RewardsClaimed(address indexed user, uint256 amount);
12+
13+
/// @notice Unable to authenticate rewards against Light Client contract
14+
error InvalidAuthRoot();
15+
16+
/// @notice All available rewards already claimed
17+
error AlreadyClaimed();
18+
19+
/// @notice Reward amount must be greater than zero
20+
error InvalidRewardAmount();
21+
22+
/// @notice Claim staking rewards
23+
///
24+
/// @param lifetimeRewards Total earned lifetime rewards for the user
25+
/// @param proof Merkle proof attesting to lifetime rewards for the user
26+
/// @param authRootInputs The authRootInputs must all be zero at the moment,
27+
/// this may change in the future with Espresso protocol upgrades.
28+
///
29+
/// @notice Obtain rewards and proof from the Espresso query service API.
30+
function claimRewards(
31+
uint256 lifetimeRewards,
32+
LifetimeRewardsProof calldata proof,
33+
bytes32[7] calldata authRootInputs
34+
) external;
35+
36+
/// @notice Check amount of rewards claimed by a user
37+
function claimedRewards(address claimer) external view returns (uint256);
38+
}

justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ gen-bindings:
170170
export-contract-abis:
171171
rm -rv contracts/artifacts/abi
172172
mkdir -p contracts/artifacts/abi
173-
for contract in LightClient{,Mock,V2{,Mock}} StakeTable EspToken; do \
173+
for contract in LightClient{,Mock,V2{,Mock}} StakeTable EspToken IRewardClaim; do \
174174
cat "contracts/out/${contract}.sol/${contract}.json" | jq .abi > "contracts/artifacts/abi/${contract}.json"; \
175175
done
176176

0 commit comments

Comments
 (0)