Skip to content

Commit 9db362b

Browse files
committed
Add gross rewards
1 parent 0ece00a commit 9db362b

File tree

14 files changed

+1217
-446
lines changed

14 files changed

+1217
-446
lines changed

docs/openapi/orchestration.swagger.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
},
109109
"/v1/viewStakingContext:view": {
110110
"get": {
111-
"summary": "Returns point-in-time context of staking data for an address",
111+
"summary": "View point-in-time staking context",
112112
"description": "Returns point-in-time context of staking data for an address",
113113
"operationId": "ViewStakingContext",
114114
"responses": {
@@ -414,7 +414,7 @@
414414
},
415415
"/v1/{name}/step": {
416416
"post": {
417-
"summary": "Perform the next step in a workflow",
417+
"summary": "Perform next workflow step",
418418
"description": "Perform the next step in a workflow",
419419
"operationId": "updateWorkflow",
420420
"responses": {

docs/openapi/rewards.swagger.json

+160-7
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,113 @@
3030
"application/json"
3131
],
3232
"paths": {
33+
"/v1/portfolioRewards": {
34+
"get": {
35+
"summary": "List a portfolio's rewards",
36+
"description": "Lists rewards of addresses that have been staked via the Staking API.",
37+
"operationId": "RewardService_ListPortfolioRewards",
38+
"responses": {
39+
"200": {
40+
"description": "OK",
41+
"schema": {
42+
"example": {
43+
"rewards": [
44+
{
45+
"address": "beefKGBWeSpHzYBHZXwp5So7wdQGX6mu4ZHCsH3uTar",
46+
"epoch": "533",
47+
"aggregationUnit": "epoch",
48+
"periodStartTime": null,
49+
"periodEndTime": "2023-11-16T00:13:44Z",
50+
"totalEarnedNativeUnit": {
51+
"amount": "224.7098145",
52+
"exp": "9",
53+
"ticker": "SOL",
54+
"rawNumeric": "224709814509"
55+
},
56+
"totalEarnedUsd": null,
57+
"endingBalance": null,
58+
"protocol": "solana"
59+
},
60+
{
61+
"address": "beefKGBWeSpHzYBHZXwp5So7wdQGX6mu4ZHCsH3uTar",
62+
"epoch": "532",
63+
"aggregationUnit": "epoch",
64+
"periodStartTime": null,
65+
"periodEndTime": "2023-11-13T19:38:36Z",
66+
"totalEarnedNativeUnit": {
67+
"amount": "225.0794241",
68+
"exp": "9",
69+
"ticker": "SOL",
70+
"rawNumeric": "225079424094"
71+
},
72+
"totalEarnedUsd": null,
73+
"endingBalance": null,
74+
"protocol": "solana"
75+
}
76+
],
77+
"nextPageToken": "VAql-wtdiJWkWII9bJBDnE9oEc-8IlgU0DtKbxSDtBg=:1:1700241277"
78+
}
79+
}
80+
},
81+
"400": {
82+
"description": "The request attempted has invalid parameters",
83+
"schema": {
84+
"example": {
85+
"code": 3,
86+
"message": "Filter validation failed. \u003cRemediation assistance here\u003e.",
87+
"details": []
88+
}
89+
}
90+
},
91+
"401": {
92+
"description": "Returned if authentication information is invalid",
93+
"schema": {
94+
"example": "Unauthorized"
95+
}
96+
},
97+
"500": {
98+
"description": "Returned when an internal server error happens.",
99+
"schema": {
100+
"example": {
101+
"code": 3,
102+
"message": "Internal server error.",
103+
"details": []
104+
}
105+
}
106+
},
107+
"default": {
108+
"description": "An unexpected error response.",
109+
"schema": {
110+
"$ref": "#/definitions/rpcStatus"
111+
}
112+
}
113+
},
114+
"parameters": [
115+
{
116+
"name": "pageSize",
117+
"description": "The maximum number of items to return.",
118+
"in": "query",
119+
"required": false,
120+
"type": "integer",
121+
"format": "int32"
122+
},
123+
{
124+
"name": "pageToken",
125+
"description": "A page token as part of the response of a previous call.\nProvide this to retrieve the next page.\n\nWhen paginating, all other parameters must match the previous\nrequest to list resources.",
126+
"in": "query",
127+
"required": false,
128+
"type": "string"
129+
}
130+
],
131+
"tags": [
132+
"Reward"
133+
]
134+
}
135+
},
33136
"/v1/portfolios": {
34137
"get": {
35-
"summary": "List all portfolios available to you.",
138+
"summary": "List portfolios",
139+
"description": "List portfolios in a CDP organization. Portfolios represent a collection of addresses, grouped together for easier management.",
36140
"operationId": "RewardService_ListPortfolios",
37141
"responses": {
38142
"200": {
@@ -98,7 +202,8 @@
98202
},
99203
"/v1/{name}": {
100204
"get": {
101-
"summary": "Get a portfolio based on the name.",
205+
"summary": "Get portfolio by name",
206+
"description": "Get portfolios in a CDP organization. Portfolios represent a collection of addresses, grouped together for easier management.",
102207
"operationId": "RewardService_GetPortfolio",
103208
"responses": {
104209
"200": {
@@ -157,7 +262,7 @@
157262
},
158263
"/v1/{parent}/rewards": {
159264
"get": {
160-
"summary": "List rewards",
265+
"summary": "List staking rewards",
161266
"description": "Lists onchain rewards of an address for a specific protocol, with optional filters for time range, aggregation period, and more.",
162267
"operationId": "RewardService_ListRewards",
163268
"responses": {
@@ -266,6 +371,13 @@
266371
"in": "query",
267372
"required": false,
268373
"type": "string"
374+
},
375+
{
376+
"name": "orderBy",
377+
"description": "The order in which to sort the results.\n[AIP-132](https://google.aip.dev/132) compliant order_by field.\nThe default behavior, if not supplied, is 'period_end_time desc'.\nExample(s):\n* 'period_end_time desc', which returns Rewards starting with the most recent.\n* 'period_end_time asc', which returns Rewards starting with the oldest available.\n* 'period_end_time', which returns Rewards starting with the oldest available.",
378+
"in": "query",
379+
"required": false,
380+
"type": "string"
269381
}
270382
],
271383
"tags": [
@@ -275,7 +387,7 @@
275387
},
276388
"/v1/{parent}/stakes": {
277389
"get": {
278-
"summary": "List and filter staking balances",
390+
"summary": "List staking balances",
279391
"description": "Lists staking balance of a protocol, with optional filters for time range and address.",
280392
"operationId": "RewardService_ListStakes",
281393
"responses": {
@@ -448,6 +560,11 @@
448560
"type": "string",
449561
"title": "The onchain address",
450562
"readOnly": true
563+
},
564+
"protocol": {
565+
"$ref": "#/definitions/v1ProtocolName",
566+
"title": "The protocol of this particular address",
567+
"readOnly": true
451568
}
452569
},
453570
"description": "Represents an address on any protocol."
@@ -489,6 +606,26 @@
489606
},
490607
"description": "Amount encapsulation for a given asset."
491608
},
609+
"v1ListPortfolioRewardsResponse": {
610+
"type": "object",
611+
"properties": {
612+
"portfolioRewards": {
613+
"type": "array",
614+
"items": {
615+
"type": "object",
616+
"$ref": "#/definitions/v1Reward"
617+
},
618+
"description": "The rewards returned in this response.",
619+
"readOnly": true
620+
},
621+
"nextPageToken": {
622+
"type": "string",
623+
"description": "The page token the user must use in the next request if the next page is desired.",
624+
"readOnly": true
625+
}
626+
},
627+
"description": "The response to a ListPortfolioRewardRequest.\nContains a list of rewards associated with the addresses in a portfolio."
628+
},
492629
"v1ListPortfoliosResponse": {
493630
"type": "object",
494631
"properties": {
@@ -579,6 +716,17 @@
579716
},
580717
"description": "A portfolio represents an arbitrary collection of addresses. A portfolio doesn't necessarily\nimply that the underlying addresses are linked onchain in any manner.\nA portfolio is a convenient way for users to group addresses together for reporting purposes.\nFor now, project and portfolio are synonymous, 1-to-1."
581718
},
719+
"v1ProtocolName": {
720+
"type": "string",
721+
"enum": [
722+
"PROTOCOL_NAME_UNSPECIFIED",
723+
"SOLANA",
724+
"COSMOS",
725+
"ETHEREUM"
726+
],
727+
"default": "PROTOCOL_NAME_UNSPECIFIED",
728+
"description": "The complete list of supported protocols.\n\n - PROTOCOL_NAME_UNSPECIFIED: The protocol isn't defined\n - SOLANA: The Solana protocol\n - COSMOS: The Cosmos protocol\n - ETHEREUM: The Ethereum protocol"
729+
},
582730
"v1Reward": {
583731
"type": "object",
584732
"properties": {
@@ -617,7 +765,12 @@
617765
},
618766
"totalEarnedNativeUnit": {
619767
"$ref": "#/definitions/v1AssetAmount",
620-
"description": "The amount earned in this time period in the native unit of the protocol.",
768+
"description": "The amount earned in this time period in the native unit of the protocol.\nThis is the net amount earned, meaning the amount that was actually paid out to the address.\nIf the rewards had a commission or fee taken out before it landed on this address, that commission amount is not included here.",
769+
"readOnly": true
770+
},
771+
"totalEarnedNativeUnitGross": {
772+
"$ref": "#/definitions/v1AssetAmount",
773+
"description": "This is the gross amount earned, meaning the total amount of rewards that is attributable to the staking activity of this address.\nThis amount includes any commission or fee taken out before it landed on this address.",
621774
"readOnly": true
622775
},
623776
"totalEarnedUsd": {
@@ -626,7 +779,7 @@
626779
"type": "object",
627780
"$ref": "#/definitions/v1USDValue"
628781
},
629-
"description": "The amount earned in this time period in USD. Calculated by getting each individual reward of this\ntime period and summing the USD value of each individual component. USD value is calculate at\nthe time each component was earned.",
782+
"description": "The amount earned in this time period in USD.\nIf multiple different price sources are used, then multiple USD values will be returned.\nTotal USD value is calculated by getting each individual reward components in this time period and summing the USD value of each individual component.\nUSD value is calculates at the time each component was earned.",
630783
"readOnly": true
631784
},
632785
"endingBalance": {
@@ -690,7 +843,7 @@
690843
},
691844
"totalDelegationReceived": {
692845
"$ref": "#/definitions/v1AssetAmount",
693-
"description": "The amount of stake that this address receives from other addresses.\nFor most delegators, this will be 0.",
846+
"description": "The amount of stake that this address receives from other addresses.\nFor most delegators, this will be 0. For validators, this will be the total amount of stake delegated to them.",
694847
"readOnly": true
695848
},
696849
"delegationsReceived": {

examples/ethereum/create-workflow/main.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ import (
88
"context"
99
"log"
1010

11-
"google.golang.org/protobuf/encoding/protojson"
12-
1311
"github.com/coinbase/staking-client-library-go/auth"
1412
"github.com/coinbase/staking-client-library-go/client"
1513
"github.com/coinbase/staking-client-library-go/client/options"
1614
api "github.com/coinbase/staking-client-library-go/gen/go/coinbase/staking/orchestration/v1"
15+
"google.golang.org/protobuf/encoding/protojson"
1716
)
1817

1918
var (

examples/ethereum/list-rewards/partial-eth/main.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ import (
1111
"log"
1212
"time"
1313

14-
"google.golang.org/api/iterator"
15-
"google.golang.org/protobuf/encoding/protojson"
16-
1714
"github.com/coinbase/staking-client-library-go/auth"
1815
"github.com/coinbase/staking-client-library-go/client"
1916
"github.com/coinbase/staking-client-library-go/client/options"
2017
"github.com/coinbase/staking-client-library-go/client/rewards"
2118
filter "github.com/coinbase/staking-client-library-go/client/rewards/rewardsfilter"
2219
api "github.com/coinbase/staking-client-library-go/gen/go/coinbase/staking/rewards/v1"
20+
"google.golang.org/api/iterator"
21+
"google.golang.org/protobuf/encoding/protojson"
2322
)
2423

2524
const (

examples/ethereum/list-rewards/validator/main.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ import (
1111
"log"
1212
"time"
1313

14-
"google.golang.org/api/iterator"
15-
"google.golang.org/protobuf/encoding/protojson"
16-
1714
"github.com/coinbase/staking-client-library-go/auth"
1815
"github.com/coinbase/staking-client-library-go/client"
1916
"github.com/coinbase/staking-client-library-go/client/options"
2017
"github.com/coinbase/staking-client-library-go/client/rewards"
2118
filter "github.com/coinbase/staking-client-library-go/client/rewards/rewardsfilter"
2219
api "github.com/coinbase/staking-client-library-go/gen/go/coinbase/staking/rewards/v1"
20+
"google.golang.org/api/iterator"
21+
"google.golang.org/protobuf/encoding/protojson"
2322
)
2423

2524
const (
@@ -72,5 +71,4 @@ func main() {
7271

7372
fmt.Println(string(marshaled))
7473
}
75-
7674
}

0 commit comments

Comments
 (0)