Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IND-503]: Add historical trading reward block and aggregation endpoints #954

Merged
merged 1 commit into from
Jan 11, 2024

Conversation

Christopher-Li
Copy link
Contributor

Changelist

Add historical trading reward block and aggregation endpoints

Test Plan

Unit tests

Author/Reviewer Checklist

  • If this PR has changes that result in a different app state given the same prior state and transaction list, manually add the state-breaking label.
  • If the PR has breaking postgres changes to the indexer add the indexer-postgres-breaking label.
  • If this PR isn't state-breaking but has changes that modify behavior in PrepareProposal or ProcessProposal, manually add the label proposal-breaking.
  • If this PR is one of many that implement a specific feature, manually label them all feature:[feature-name].
  • If you wish to for mergify-bot to automatically create a PR to backport your change to a release branch, manually add the label backport/[branch-name].
  • Manually add any of the following labels: refactor, chore, bug.

Copy link

linear bot commented Jan 10, 2024

Copy link
Contributor

coderabbitai bot commented Jan 10, 2024

Walkthrough

The recent updates to the codebase focus on enhancing the functionality of trading rewards and their historical data retrieval. Two new query parameters have been introduced to refine searches by date and block height. The API version 4 now includes endpoints for fetching historical block trading rewards and aggregations with these additional parameters. Changes include the introduction of new enums, schema modifications for request validation, controller updates, and the transformation of database entities to response objects for the updated API endpoints.

Changes

File Path Change Summary
.../postgres/src/stores/trading-reward-aggregation-table.ts
.../postgres/src/stores/trading-reward-table.ts
Updated findAll functions to accept new time and height parameters; added conditional query logic.
.../postgres/src/types/query-types.ts Added new enum values and fields to query config interfaces.
.../comlink/__tests__/controllers/api/v4/...-block-trading-reward-controller.test.ts
.../comlink/__tests__/controllers/api/v4/...-trading-reward-aggregations-controller.test.ts
Added tests for new historical trading reward functionality in API v4.
.../comlink/public/api-documentation.md Documented new API operations GetTradingRewards and GetAggregations with examples and responses.
.../comlink/src/controllers/api/index-v4.ts Added new controllers for historical trading data and updated routing.
.../comlink/src/controllers/api/v4/addresses-controller.ts Replaced checkSchema import and usage with CheckAddressSchema.
.../comlink/src/controllers/api/v4/...-block-trading-rewards-controller.ts
.../comlink/src/controllers/api/v4/...-trading-reward-aggregations-controller.ts
Introduced controllers for new historical trading reward and aggregation endpoints.
.../comlink/src/lib/validation/schemas.ts Added new schemas and updated existing ones for additional validation rules.
.../comlink/src/request-helpers/request-transformer.ts Added functions to transform database entities to API response objects.
.../comlink/src/types.ts Introduced new types and interfaces for historical trading reward data.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 4

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 2bfcb31 and 01b79bd.
Files ignored due to filter (1)
  • indexer/services/comlink/public/swagger.json
Files selected for processing (13)
  • indexer/packages/postgres/src/stores/trading-reward-aggregation-table.ts (3 hunks)
  • indexer/packages/postgres/src/stores/trading-reward-table.ts (3 hunks)
  • indexer/packages/postgres/src/types/query-types.ts (3 hunks)
  • indexer/services/comlink/tests/controllers/api/v4/historical-block-trading-reward-controller.test.ts (1 hunks)
  • indexer/services/comlink/tests/controllers/api/v4/historical-trading-reward-aggregations-controller.test.ts (1 hunks)
  • indexer/services/comlink/public/api-documentation.md (4 hunks)
  • indexer/services/comlink/src/controllers/api/index-v4.ts (2 hunks)
  • indexer/services/comlink/src/controllers/api/v4/addresses-controller.ts (3 hunks)
  • indexer/services/comlink/src/controllers/api/v4/historical-block-trading-rewards-controller.ts (1 hunks)
  • indexer/services/comlink/src/controllers/api/v4/historical-trading-reward-aggregations-controller.ts (1 hunks)
  • indexer/services/comlink/src/lib/validation/schemas.ts (2 hunks)
  • indexer/services/comlink/src/request-helpers/request-transformer.ts (3 hunks)
  • indexer/services/comlink/src/types.ts (2 hunks)
Additional comments: 26
indexer/services/comlink/src/controllers/api/index-v4.ts (2)
  • 9-12: The import statements for HistoricalBlockTradingRewardController and HistoricalTradingRewardController have been added correctly, ensuring that the new controllers are available for use in the router setup.

  • 30-33: The router has been updated to use the new controllers for the routes /historicalBlockTradingRewards and /historicalTradingRewardAggregations. This correctly exposes the new endpoints as part of the application's API.

indexer/packages/postgres/src/stores/trading-reward-table.ts (2)
  • 31-31: The findAll function now accepts a new parameter blockHeightBeforeOrAt. This parameter should be used to filter the results to only include trading rewards at or before the specified block height.

  • 76-77: The query logic has been correctly updated to include a condition that filters the results based on the blockHeightBeforeOrAt parameter if it is provided.

indexer/services/comlink/src/controllers/api/v4/historical-block-trading-rewards-controller.ts (2)
  • 30-38: The HistoricalBlockTradingRewardsController class has been defined with a getTradingRewards method that correctly retrieves trading rewards based on the provided query parameters.

  • 56-62: The router setup for the /historicalBlockTradingRewards/:address endpoint includes middleware for country restrictions, rate limiting, validation, and response code statistics. This is a comprehensive setup that ensures proper request handling and response.

indexer/services/comlink/src/lib/validation/schemas.ts (2)
  • 21-25: The checkAddressSchemaRecord has been added to define validation rules for the address parameter. This is a good practice to ensure that the address provided in requests is validated against expected criteria.

  • 140-155: The CheckHistoricalBlockTradingRewardsSchema has been modified to include additional validation rules for startingBeforeOrAt and startingBeforeOrAtHeight. This ensures that the query parameters are validated correctly before being processed by the controller.

indexer/services/comlink/src/controllers/api/v4/historical-trading-reward-aggregations-controller.ts (2)
  • 31-40: The HistoricalTradingRewardAggregationsController class has been defined with a getAggregations method that correctly retrieves trading reward aggregations based on the provided query parameters.

  • 58-62: The router setup for the /historicalTradingRewardAggregations/:address endpoint includes middleware for country restrictions, rate limiting, and validation. This is a comprehensive setup that ensures proper request handling and response.

indexer/packages/postgres/src/stores/trading-reward-aggregation-table.ts (2)
  • 37-38: The findAll function now accepts two new parameters startedAtBeforeOrAt and startedAtHeightBeforeOrAt. These parameters should be used to filter the results to only include trading reward aggregations at or before the specified times and block heights.

  • 79-87: The query logic has been correctly updated to include conditions that filter the results based on the startedAtBeforeOrAt and startedAtHeightBeforeOrAt parameters if they are provided.

indexer/services/comlink/__tests__/controllers/api/v4/historical-block-trading-reward-controller.test.ts (1)
  • 65-138: The test cases for the historical-block-trading-reward-controller cover various scenarios, including fetching all rewards, fetching with a limit, fetching with no rewards, and fetching with time and height filters. These tests are well-structured and should validate the functionality of the controller effectively.
indexer/services/comlink/__tests__/controllers/api/v4/historical-trading-reward-aggregations-controller.test.ts (1)
  • 71-151: The test cases for the historical-trading-reward-aggregations-controller cover various scenarios, including fetching all aggregations, fetching with a limit, fetching with no aggregations, and fetching with time and height filters. These tests are well-structured and should validate the functionality of the controller effectively.
indexer/packages/postgres/src/types/query-types.ts (3)
  • 82-84: The addition of new enum values BLOCK_HEIGHT_BEFORE_OR_AT, STARTED_AT_BEFORE_OR_AT, and STARTED_AT_HEIGHT_BEFORE_OR_AT to QueryableField is consistent with the PR objectives to allow filtering based on specific block heights and timestamps.

  • 286-286: The new field [QueryableField.BLOCK_HEIGHT_BEFORE_OR_AT]?: IsoString; has been correctly added to the TradingRewardQueryConfig interface to support the new query parameter for block height filtering.

  • 295-296: The new fields [QueryableField.STARTED_AT_BEFORE_OR_AT]?: IsoString; and [QueryableField.STARTED_AT_HEIGHT_BEFORE_OR_AT]?: string; have been correctly added to the TradingRewardAggregationQueryConfig interface to support the new query parameters for timestamp and block height filtering.

indexer/services/comlink/src/types.ts (4)
  • 21-21: The addition of TradingRewardAggregationPeriod enum is consistent with the PR objectives to support aggregation periods for historical trading rewards.

  • 409-413: The new interface HistoricalTradingRewardAggregationRequest correctly defines the structure for requests related to historical trading reward aggregations, including the period and starting timestamps.

  • 415-429: The new interface HistoricalTradingRewardAggregationsResponse and HistoricalTradingRewardAggregation are well-defined and align with the PR objectives to provide responses for historical trading reward aggregations.

  • 432-448: The new interfaces HistoricalBlockTradingRewardRequest, HistoricalBlockTradingRewardsResponse, and HistoricalBlockTradingReward are correctly added to handle requests and responses for historical block trading rewards.

indexer/services/comlink/src/controllers/api/v4/addresses-controller.ts (2)
  • 55-55: The import of CheckAddressSchema from the validation schemas is consistent with the PR objectives to refactor schema validation logic.

  • 260-260: The replacement of ...checkSchema({...}) with ...CheckAddressSchema in the router.get method is a correct implementation of the new schema validation logic.

indexer/services/comlink/src/request-helpers/request-transformer.ts (3)
  • 25-26: The addition of TradingRewardAggregationFromDatabase and TradingRewardFromDatabase imports aligns with the PR's objective to handle historical trading reward data. These imports are necessary for the new transformation functions added later in the file.

  • 458-468: The function tradingRewardAggregationToResponse correctly transforms a TradingRewardAggregationFromDatabase object into a HistoricalTradingRewardAggregation response object. The fields are appropriately mapped, and the function is concise and follows best practices.

  • 471-478: The function tradingRewardToResponse correctly transforms a TradingRewardFromDatabase object into a HistoricalBlockTradingReward response object. The mapping of fields is consistent with the expected response structure. This function is also concise and follows best practices.

Comment on lines +662 to +738
## GetTradingRewards

<a id="opIdGetTradingRewards"></a>

> Code samples

```python
import requests
headers = {
'Accept': 'application/json'
}

r = requests.get('https://dydx-testnet.imperator.co/v4/historicalBlockTradingRewards/{address}', params={
'limit': '0'
}, headers = headers)

print(r.json())

```

```javascript

const headers = {
'Accept':'application/json'
};

fetch('https://dydx-testnet.imperator.co/v4/historicalBlockTradingRewards/{address}?limit=0',
{
method: 'GET',

headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});

```

`GET /historicalBlockTradingRewards/{address}`

### Parameters

|Name|In|Type|Required|Description|
|---|---|---|---|---|
|address|path|string|true|none|
|limit|query|number(double)|true|none|
|startingBeforeOrAt|query|[IsoString](#schemaisostring)|false|none|
|startingBeforeOrAtHeight|query|string|false|none|

> Example responses

> 200 Response

```json
{
"rewards": [
{
"tradingReward": "string",
"createdAt": "string",
"createdAtHeight": "string"
}
]
}
```

### Responses

|Status|Meaning|Description|Schema|
|---|---|---|---|
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Ok|[HistoricalBlockTradingRewardsResponse](#schemahistoricalblocktradingrewardsresponse)|

<aside class="success">
This operation does not require authentication
</aside>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation for the GetTradingRewards operation appears to be complete and well-structured, including parameters, code samples, and example responses. However, the limit parameter in the code samples is set to '0', which might be an error since it usually indicates no data would be returned. This should be clarified or corrected if it's a mistake.

-  'limit': '0'
+  'limit': '10'  # Assuming '10' is a reasonable default for demonstration purposes

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
## GetTradingRewards
<a id="opIdGetTradingRewards"></a>
> Code samples
```python
import requests
headers = {
'Accept': 'application/json'
}
r = requests.get('https://dydx-testnet.imperator.co/v4/historicalBlockTradingRewards/{address}', params={
'limit': '0'
}, headers = headers)
print(r.json())
```
```javascript
const headers = {
'Accept':'application/json'
};
fetch('https://dydx-testnet.imperator.co/v4/historicalBlockTradingRewards/{address}?limit=0',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
```
`GET /historicalBlockTradingRewards/{address}`
### Parameters
|Name|In|Type|Required|Description|
|---|---|---|---|---|
|address|path|string|true|none|
|limit|query|number(double)|true|none|
|startingBeforeOrAt|query|[IsoString](#schemaisostring)|false|none|
|startingBeforeOrAtHeight|query|string|false|none|
> Example responses
> 200 Response
```json
{
"rewards": [
{
"tradingReward": "string",
"createdAt": "string",
"createdAtHeight": "string"
}
]
}
```
### Responses
|Status|Meaning|Description|Schema|
|---|---|---|---|
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Ok|[HistoricalBlockTradingRewardsResponse](#schemahistoricalblocktradingrewardsresponse)|
<aside class="success">
This operation does not require authentication
</aside>
## GetTradingRewards
<a id="opIdGetTradingRewards"></a>
> Code samples
```python
import requests
headers = {
'Accept': 'application/json'
}
r = requests.get('https://dydx-testnet.imperator.co/v4/historicalBlockTradingRewards/{address}', params={
'limit': '10' # Assuming '10' is a reasonable default for demonstration purposes
}, headers = headers)
print(r.json())
const headers = {
  'Accept':'application/json'
};

fetch('https://dydx-testnet.imperator.co/v4/historicalBlockTradingRewards/{address}?limit=10',
{
  method: 'GET',

  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

GET /historicalBlockTradingRewards/{address}

Parameters

Name In Type Required Description
address path string true none
limit query number(double) true none
startingBeforeOrAt query IsoString false none
startingBeforeOrAtHeight query string false none

Example responses

200 Response

{
  "rewards": [
    {
      "tradingReward": "string",
      "createdAt": "string",
      "createdAtHeight": "string"
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK Ok HistoricalBlockTradingRewardsResponse
This operation does not require authentication


</details>
<!-- suggestion_end -->

<!-- This is an auto-generated comment by CodeRabbit -->

Comment on lines +903 to +991
## GetAggregations

<a id="opIdGetAggregations"></a>

> Code samples

```python
import requests
headers = {
'Accept': 'application/json'
}

r = requests.get('https://dydx-testnet.imperator.co/v4/historicalTradingRewardAggregations/{address}', params={
'period': 'DAILY', 'limit': '0'
}, headers = headers)

print(r.json())

```

```javascript

const headers = {
'Accept':'application/json'
};

fetch('https://dydx-testnet.imperator.co/v4/historicalTradingRewardAggregations/{address}?period=DAILY&limit=0',
{
method: 'GET',

headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});

```

`GET /historicalTradingRewardAggregations/{address}`

### Parameters

|Name|In|Type|Required|Description|
|---|---|---|---|---|
|address|path|string|true|none|
|period|query|[TradingRewardAggregationPeriod](#schematradingrewardaggregationperiod)|true|none|
|limit|query|number(double)|true|none|
|startingBeforeOrAt|query|[IsoString](#schemaisostring)|false|none|
|startingBeforeOrAtHeight|query|string|false|none|

#### Enumerated Values

|Parameter|Value|
|---|---|
|period|DAILY|
|period|WEEKLY|
|period|MONTHLY|

> Example responses

> 200 Response

```json
{
"rewards": [
{
"tradingReward": "string",
"startedAt": "string",
"startedAtHeight": "string",
"endedAt": "string",
"endedAtHeight": "string",
"period": "DAILY"
}
]
}
```

### Responses

|Status|Meaning|Description|Schema|
|---|---|---|---|
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Ok|[HistoricalTradingRewardAggregationsResponse](#schemahistoricaltradingrewardaggregationsresponse)|

<aside class="success">
This operation does not require authentication
</aside>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the previous comment, the GetAggregations operation documentation is well-structured. However, the limit parameter in the code samples is also set to '0'. This should be verified and corrected if necessary.

-  'limit': '0'
+  'limit': '10'  # Assuming '10' is a reasonable default for demonstration purposes

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
## GetAggregations
<a id="opIdGetAggregations"></a>
> Code samples
```python
import requests
headers = {
'Accept': 'application/json'
}
r = requests.get('https://dydx-testnet.imperator.co/v4/historicalTradingRewardAggregations/{address}', params={
'period': 'DAILY', 'limit': '0'
}, headers = headers)
print(r.json())
```
```javascript
const headers = {
'Accept':'application/json'
};
fetch('https://dydx-testnet.imperator.co/v4/historicalTradingRewardAggregations/{address}?period=DAILY&limit=0',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
```
`GET /historicalTradingRewardAggregations/{address}`
### Parameters
|Name|In|Type|Required|Description|
|---|---|---|---|---|
|address|path|string|true|none|
|period|query|[TradingRewardAggregationPeriod](#schematradingrewardaggregationperiod)|true|none|
|limit|query|number(double)|true|none|
|startingBeforeOrAt|query|[IsoString](#schemaisostring)|false|none|
|startingBeforeOrAtHeight|query|string|false|none|
#### Enumerated Values
|Parameter|Value|
|---|---|
|period|DAILY|
|period|WEEKLY|
|period|MONTHLY|
> Example responses
> 200 Response
```json
{
"rewards": [
{
"tradingReward": "string",
"startedAt": "string",
"startedAtHeight": "string",
"endedAt": "string",
"endedAtHeight": "string",
"period": "DAILY"
}
]
}
```
### Responses
|Status|Meaning|Description|Schema|
|---|---|---|---|
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Ok|[HistoricalTradingRewardAggregationsResponse](#schemahistoricaltradingrewardaggregationsresponse)|
<aside class="success">
This operation does not require authentication
</aside>
## GetAggregations
<a id="opIdGetAggregations"></a>
> Code samples
```python
import requests
headers = {
'Accept': 'application/json'
}
r = requests.get('https://dydx-testnet.imperator.co/v4/historicalTradingRewardAggregations/{address}', params={
'period': 'DAILY', 'limit': '10' # Assuming '10' is a reasonable default for demonstration purposes
}, headers = headers)
print(r.json())
const headers = {
  'Accept':'application/json'
};

fetch('https://dydx-testnet.imperator.co/v4/historicalTradingRewardAggregations/{address}?period=DAILY&limit=10',
{
  method: 'GET',

  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

GET /historicalTradingRewardAggregations/{address}

Parameters

Name In Type Required Description
address path string true none
period query TradingRewardAggregationPeriod true none
limit query number(double) true none
startingBeforeOrAt query IsoString false none
startingBeforeOrAtHeight query string false none

Enumerated Values

Parameter Value
period DAILY
period WEEKLY
period MONTHLY

Example responses

200 Response

{
  "rewards": [
    {
      "tradingReward": "string",
      "startedAt": "string",
      "startedAtHeight": "string",
      "endedAt": "string",
      "endedAtHeight": "string",
      "period": "DAILY"
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK Ok HistoricalTradingRewardAggregationsResponse
This operation does not require authentication


</details>
<!-- suggestion_end -->

<!-- This is an auto-generated comment by CodeRabbit -->

Comment on lines +2619 to +2668
## HistoricalBlockTradingReward

<a id="schemahistoricalblocktradingreward"></a>
<a id="schema_HistoricalBlockTradingReward"></a>
<a id="tocShistoricalblocktradingreward"></a>
<a id="tocshistoricalblocktradingreward"></a>

```json
{
"tradingReward": "string",
"createdAt": "string",
"createdAtHeight": "string"
}

```

### Properties

|Name|Type|Required|Restrictions|Description|
|---|---|---|---|---|
|tradingReward|string|true|none|none|
|createdAt|[IsoString](#schemaisostring)|true|none|none|
|createdAtHeight|string|true|none|none|

## HistoricalBlockTradingRewardsResponse

<a id="schemahistoricalblocktradingrewardsresponse"></a>
<a id="schema_HistoricalBlockTradingRewardsResponse"></a>
<a id="tocShistoricalblocktradingrewardsresponse"></a>
<a id="tocshistoricalblocktradingrewardsresponse"></a>

```json
{
"rewards": [
{
"tradingReward": "string",
"createdAt": "string",
"createdAtHeight": "string"
}
]
}

```

### Properties

|Name|Type|Required|Restrictions|Description|
|---|---|---|---|---|
|rewards|[[HistoricalBlockTradingReward](#schemahistoricalblocktradingreward)]|true|none|none|

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The HistoricalBlockTradingReward and HistoricalBlockTradingRewardsResponse data structures are documented with JSON examples and a table of properties. The properties are marked as required, but there are no restrictions or descriptions provided. It would be beneficial to add descriptions to each property to ensure clarity for the API consumers.

Comment on lines +2790 to +2874
## TradingRewardAggregationPeriod

<a id="schematradingrewardaggregationperiod"></a>
<a id="schema_TradingRewardAggregationPeriod"></a>
<a id="tocStradingrewardaggregationperiod"></a>
<a id="tocstradingrewardaggregationperiod"></a>

```json
"DAILY"

```

### Properties

|Name|Type|Required|Restrictions|Description|
|---|---|---|---|---|
|*anonymous*|string|false|none|none|

#### Enumerated Values

|Property|Value|
|---|---|
|*anonymous*|DAILY|
|*anonymous*|WEEKLY|
|*anonymous*|MONTHLY|

## HistoricalTradingRewardAggregation

<a id="schemahistoricaltradingrewardaggregation"></a>
<a id="schema_HistoricalTradingRewardAggregation"></a>
<a id="tocShistoricaltradingrewardaggregation"></a>
<a id="tocshistoricaltradingrewardaggregation"></a>

```json
{
"tradingReward": "string",
"startedAt": "string",
"startedAtHeight": "string",
"endedAt": "string",
"endedAtHeight": "string",
"period": "DAILY"
}

```

### Properties

|Name|Type|Required|Restrictions|Description|
|---|---|---|---|---|
|tradingReward|string|true|none|none|
|startedAt|[IsoString](#schemaisostring)|true|none|none|
|startedAtHeight|string|true|none|none|
|endedAt|[IsoString](#schemaisostring)|false|none|none|
|endedAtHeight|string|false|none|none|
|period|[TradingRewardAggregationPeriod](#schematradingrewardaggregationperiod)|true|none|none|

## HistoricalTradingRewardAggregationsResponse

<a id="schemahistoricaltradingrewardaggregationsresponse"></a>
<a id="schema_HistoricalTradingRewardAggregationsResponse"></a>
<a id="tocShistoricaltradingrewardaggregationsresponse"></a>
<a id="tocshistoricaltradingrewardaggregationsresponse"></a>

```json
{
"rewards": [
{
"tradingReward": "string",
"startedAt": "string",
"startedAtHeight": "string",
"endedAt": "string",
"endedAtHeight": "string",
"period": "DAILY"
}
]
}

```

### Properties

|Name|Type|Required|Restrictions|Description|
|---|---|---|---|---|
|rewards|[[HistoricalTradingRewardAggregation](#schemahistoricaltradingrewardaggregation)]|true|none|none|

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TradingRewardAggregationPeriod enum and the HistoricalTradingRewardAggregation and HistoricalTradingRewardAggregationsResponse data structures are well-documented. The JSON examples and properties tables are clear. However, the period property in the HistoricalTradingRewardAggregation structure is documented as required, but the example JSON marks it as "DAILY". It should be clarified whether this is a default value or if other values are also acceptable.

@Christopher-Li Christopher-Li merged commit 6385473 into main Jan 11, 2024
11 checks passed
@Christopher-Li Christopher-Li deleted the cl_historical_trading_rewards branch January 11, 2024 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants