Skip to content

Commit 8fca865

Browse files
authored
feat: add a new endpoint GetRewardDistributionByStake (#67)
2 parents 7d96482 + 36cb7e6 commit 8fca865

File tree

11 files changed

+828
-130
lines changed

11 files changed

+828
-130
lines changed

gen/api-ts/eigenlayer/sidecar/v1/rewards/rewards.pb.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,4 +259,27 @@ type BaseListEarnerHistoricalRewardsResponse = {
259259
}
260260

261261
export type ListEarnerHistoricalRewardsResponse = BaseListEarnerHistoricalRewardsResponse
262-
& OneOf<{ nextPage: EigenlayerSidecarV1CommonTypes.Pagination }>
262+
& OneOf<{ nextPage: EigenlayerSidecarV1CommonTypes.Pagination }>
263+
264+
export type StrategyAndMultiplier = {
265+
strategy?: string
266+
multiplier?: string
267+
}
268+
269+
export type GetRewardDistributionByStakeRequest = {
270+
avs?: string
271+
token?: string
272+
amount?: string
273+
startTimestamp?: string
274+
duration?: string
275+
strategiesAndMultipliers?: StrategyAndMultiplier[]
276+
}
277+
278+
export type OperatorReward = {
279+
operator?: string
280+
amount?: string
281+
}
282+
283+
export type GetRewardDistributionByStakeResponse = {
284+
operatorRewards?: OperatorReward[]
285+
}

gen/api-ts/eigenlayer/sidecar/v1/rewards/rpc.pb.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,7 @@ export class Rewards {
7070
static ListEarnerHistoricalRewards(req: EigenlayerSidecarV1RewardsRewards.ListEarnerHistoricalRewardsRequest, initReq?: fm.InitReq): Promise<EigenlayerSidecarV1RewardsRewards.ListEarnerHistoricalRewardsResponse> {
7171
return fm.fetchReq<EigenlayerSidecarV1RewardsRewards.ListEarnerHistoricalRewardsRequest, EigenlayerSidecarV1RewardsRewards.ListEarnerHistoricalRewardsResponse>(`/rewards/v1/earners/${req["earnerAddress"]}/historical-rewards?${fm.renderURLSearchParams(req, ["earnerAddress"])}`, {...initReq, method: "GET"})
7272
}
73+
static GetRewardDistributionByStake(req: EigenlayerSidecarV1RewardsRewards.GetRewardDistributionByStakeRequest, initReq?: fm.InitReq): Promise<EigenlayerSidecarV1RewardsRewards.GetRewardDistributionByStakeResponse> {
74+
return fm.fetchReq<EigenlayerSidecarV1RewardsRewards.GetRewardDistributionByStakeRequest, EigenlayerSidecarV1RewardsRewards.GetRewardDistributionByStakeResponse>(`/rewards/v1/reward-distribution-by-stake`, {...initReq, method: "POST", body: JSON.stringify(req, fm.replacer)})
75+
}
7376
}

gen/openapi/api.public.swagger.json

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,65 @@
10981098
]
10991099
}
11001100
},
1101+
"/rewards/v1/reward-distribution-by-stake": {
1102+
"post": {
1103+
"summary": "GetRewardDistributionByStake",
1104+
"description": "GetRewardDistributionByStake computes a reward distribution based on stake weight,\nas if submitting a v1 reward. Returns a mapping of each operator to their reward amount,\nproportional to their stake weight over the specified time range.",
1105+
"operationId": "Rewards_GetRewardDistributionByStake",
1106+
"requestBody": {
1107+
"required": true,
1108+
"content": {
1109+
"application/json": {
1110+
"schema": {
1111+
"type": "object",
1112+
"properties": {
1113+
"amount": {
1114+
"type": "string"
1115+
},
1116+
"avs": {
1117+
"type": "string"
1118+
},
1119+
"duration": {
1120+
"type": "integer",
1121+
"format": "uint64"
1122+
},
1123+
"startTimestamp": {
1124+
"type": "integer",
1125+
"format": "uint64"
1126+
},
1127+
"strategiesAndMultipliers": {
1128+
"$ref": "#/components/schemas/StrategyAndMultiplier"
1129+
},
1130+
"token": {
1131+
"type": "string"
1132+
}
1133+
}
1134+
}
1135+
}
1136+
}
1137+
},
1138+
"responses": {
1139+
"200": {
1140+
"description": "Successful response",
1141+
"content": {
1142+
"application/json": {
1143+
"schema": {
1144+
"type": "object",
1145+
"properties": {
1146+
"operatorRewards": {
1147+
"$ref": "#/components/schemas/OperatorReward"
1148+
}
1149+
}
1150+
}
1151+
}
1152+
}
1153+
}
1154+
},
1155+
"tags": [
1156+
"rewards"
1157+
]
1158+
}
1159+
},
11011160
"/rpc/v1/latest-block": {
11021161
"get": {
11031162
"summary": "GetBlockHeight",
@@ -2218,6 +2277,39 @@
22182277
}
22192278
}
22202279
},
2280+
"GetRewardDistributionByStakeRequest": {
2281+
"type": "object",
2282+
"properties": {
2283+
"amount": {
2284+
"type": "string"
2285+
},
2286+
"avs": {
2287+
"type": "string"
2288+
},
2289+
"duration": {
2290+
"type": "integer",
2291+
"format": "uint64"
2292+
},
2293+
"startTimestamp": {
2294+
"type": "integer",
2295+
"format": "uint64"
2296+
},
2297+
"strategiesAndMultipliers": {
2298+
"$ref": "#/components/schemas/StrategyAndMultiplier"
2299+
},
2300+
"token": {
2301+
"type": "string"
2302+
}
2303+
}
2304+
},
2305+
"GetRewardDistributionByStakeResponse": {
2306+
"type": "object",
2307+
"properties": {
2308+
"operatorRewards": {
2309+
"$ref": "#/components/schemas/OperatorReward"
2310+
}
2311+
}
2312+
},
22212313
"GetRewardsByAvsForDistributionRootRequest": {
22222314
"type": "object",
22232315
"properties": {
@@ -3370,6 +3462,17 @@
33703462
"transaction_metadata"
33713463
]
33723464
},
3465+
"OperatorReward": {
3466+
"type": "object",
3467+
"properties": {
3468+
"amount": {
3469+
"type": "string"
3470+
},
3471+
"operator": {
3472+
"type": "string"
3473+
}
3474+
}
3475+
},
33733476
"OperatorSet": {
33743477
"type": "object",
33753478
"properties": {
@@ -4045,6 +4148,17 @@
40454148
}
40464149
}
40474150
},
4151+
"StrategyAndMultiplier": {
4152+
"type": "object",
4153+
"properties": {
4154+
"multiplier": {
4155+
"type": "string"
4156+
},
4157+
"strategy": {
4158+
"type": "string"
4159+
}
4160+
}
4161+
},
40484162
"StreamEigenStateChangesRequest": {
40494163
"type": "object",
40504164
"properties": {

gen/openapi/api.swagger.json

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,6 +1689,65 @@
16891689
]
16901690
}
16911691
},
1692+
"/rewards/v1/reward-distribution-by-stake": {
1693+
"post": {
1694+
"summary": "GetRewardDistributionByStake",
1695+
"description": "GetRewardDistributionByStake computes a reward distribution based on stake weight,\nas if submitting a v1 reward. Returns a mapping of each operator to their reward amount,\nproportional to their stake weight over the specified time range.",
1696+
"operationId": "Rewards_GetRewardDistributionByStake",
1697+
"requestBody": {
1698+
"required": true,
1699+
"content": {
1700+
"application/json": {
1701+
"schema": {
1702+
"type": "object",
1703+
"properties": {
1704+
"amount": {
1705+
"type": "string"
1706+
},
1707+
"avs": {
1708+
"type": "string"
1709+
},
1710+
"duration": {
1711+
"type": "integer",
1712+
"format": "uint64"
1713+
},
1714+
"startTimestamp": {
1715+
"type": "integer",
1716+
"format": "uint64"
1717+
},
1718+
"strategiesAndMultipliers": {
1719+
"$ref": "#/components/schemas/StrategyAndMultiplier"
1720+
},
1721+
"token": {
1722+
"type": "string"
1723+
}
1724+
}
1725+
}
1726+
}
1727+
}
1728+
},
1729+
"responses": {
1730+
"200": {
1731+
"description": "Successful response",
1732+
"content": {
1733+
"application/json": {
1734+
"schema": {
1735+
"type": "object",
1736+
"properties": {
1737+
"operatorRewards": {
1738+
"$ref": "#/components/schemas/OperatorReward"
1739+
}
1740+
}
1741+
}
1742+
}
1743+
}
1744+
}
1745+
},
1746+
"tags": [
1747+
"rewards"
1748+
]
1749+
}
1750+
},
16921751
"/rewards/v1/rewards/{snapshot}": {
16931752
"get": {
16941753
"summary": "GetRewardsForSnapshot",
@@ -3206,6 +3265,39 @@
32063265
}
32073266
}
32083267
},
3268+
"GetRewardDistributionByStakeRequest": {
3269+
"type": "object",
3270+
"properties": {
3271+
"amount": {
3272+
"type": "string"
3273+
},
3274+
"avs": {
3275+
"type": "string"
3276+
},
3277+
"duration": {
3278+
"type": "integer",
3279+
"format": "uint64"
3280+
},
3281+
"startTimestamp": {
3282+
"type": "integer",
3283+
"format": "uint64"
3284+
},
3285+
"strategiesAndMultipliers": {
3286+
"$ref": "#/components/schemas/StrategyAndMultiplier"
3287+
},
3288+
"token": {
3289+
"type": "string"
3290+
}
3291+
}
3292+
},
3293+
"GetRewardDistributionByStakeResponse": {
3294+
"type": "object",
3295+
"properties": {
3296+
"operatorRewards": {
3297+
"$ref": "#/components/schemas/OperatorReward"
3298+
}
3299+
}
3300+
},
32093301
"GetRewardsByAvsForDistributionRootRequest": {
32103302
"type": "object",
32113303
"properties": {
@@ -4358,6 +4450,17 @@
43584450
"transaction_metadata"
43594451
]
43604452
},
4453+
"OperatorReward": {
4454+
"type": "object",
4455+
"properties": {
4456+
"amount": {
4457+
"type": "string"
4458+
},
4459+
"operator": {
4460+
"type": "string"
4461+
}
4462+
}
4463+
},
43614464
"OperatorSet": {
43624465
"type": "object",
43634466
"properties": {
@@ -5033,6 +5136,17 @@
50335136
}
50345137
}
50355138
},
5139+
"StrategyAndMultiplier": {
5140+
"type": "object",
5141+
"properties": {
5142+
"multiplier": {
5143+
"type": "string"
5144+
},
5145+
"strategy": {
5146+
"type": "string"
5147+
}
5148+
}
5149+
},
50365150
"StreamEigenStateChangesRequest": {
50375151
"type": "object",
50385152
"properties": {

0 commit comments

Comments
 (0)