Skip to content

Commit

Permalink
README updates for Partial ETH rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin-cb committed May 16, 2024
1 parent 10d6054 commit 711350f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 70 deletions.
100 changes: 38 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ client.Solana.stake('devnet', '8rMGARtkJY5QygP1mgvBFLsE9JrvXByARJiyNfcSE5Z', '10

</details>

### View Ethereum Rewards :moneybag:
### View Partial ETH Rewards :moneybag:

This code sample helps view rewards for an Ethereum validator address. View the full source [here](examples/ethereum/list-rewards.ts).
This code sample helps view rewards for an Ethereum address. View the full source [here](examples/ethereum/list-rewards.ts).

<details open>

Expand All @@ -188,15 +188,18 @@ const client = new StakingClient(apiKeyName, apiPrivateKey);

// Defines which address and rewards we want to see
const address: string =
'0xac53512c39d0081ca4437c285305eb423f474e6153693c12fbba4a3df78bcaa3422b31d800c5bea71c1b017168a60474';
const filter: string = `address='${address}' AND period_end_time > '2024-02-25T00:00:00Z' AND period_end_time < '2024-02-27T00:00:00Z'`;
'0x60c7e246344ae3856cf9abe3a2e258d495fc39e0';
const filter: string = `address='${address}' AND period_end_time > '2024-05-01T00:00:00Z' AND period_end_time < '2024-05-02T00:00:00Z'`;

// Loops through rewards array and prints each reward
client.Ethereum.listRewards(filter).then((resp) => {
var list = async function () {
const resp = await client.Ethereum.listRewards(filter)
resp.rewards!.forEach((reward) => {
console.log(JSON.stringify(reward, null, 2));
});
});
}

list();
```

</details>
Expand All @@ -205,62 +208,35 @@ client.Ethereum.listRewards(filter).then((resp) => {
<summary>Output</summary>

```json
{
"address": "0xac53512c39d0081ca4437c285305eb423f474e6153693c12fbba4a3df78bcaa3422b31d800c5bea71c1b017168a60474",
"date": "2024-02-25",
"aggregationUnit": "DAY",
"periodStartTime": "2024-02-25T00:00:00Z",
"periodEndTime": "2024-02-25T23:59:59Z",
"totalEarnedNativeUnit": {
"amount": "0.002183619",
"exp": "18",
"ticker": "ETH",
"rawNumeric": "2183619000000000"
},
"totalEarnedUsd": [
{
"source": "COINBASE_EXCHANGE",
"conversionTime": "2024-02-26T00:09:00Z",
"amount": {
"amount": "6.79",
"exp": "2",
"ticker": "USD",
"rawNumeric": "679"
},
"conversionPrice": "3105.780029"
}
],
"endingBalance": null,
"protocol": "ethereum"
}
{
"address": "0xac53512c39d0081ca4437c285305eb423f474e6153693c12fbba4a3df78bcaa3422b31d800c5bea71c1b017168a60474",
"date": "2024-02-26",
"aggregationUnit": "DAY",
"periodStartTime": "2024-02-26T00:00:00Z",
"periodEndTime": "2024-02-26T23:59:59Z",
"totalEarnedNativeUnit": {
"amount": "0.002182946",
"exp": "18",
"ticker": "ETH",
"rawNumeric": "2182946000000000"
},
"totalEarnedUsd": [
{
"source": "COINBASE_EXCHANGE",
"conversionTime": "2024-02-27T00:09:00Z",
"amount": {
"amount": "6.94",
"exp": "2",
"ticker": "USD",
"rawNumeric": "694"
},
"conversionPrice": "3178.889893"
}
],
"endingBalance": null,
"protocol": "ethereum"
}
{
"address": "0x60c7e246344ae3856cf9abe3a2e258d495fc39e0",
"date": "2024-05-01",
"aggregationUnit": "DAY",
"periodStartTime": "2024-05-01T00:00:00Z",
"periodEndTime": "2024-05-01T23:59:59Z",
"totalEarnedNativeUnit": {
"amount": "0.001212525541415161",
"exp": "18",
"ticker": "ETH",
"rawNumeric": "1212525541415161"
},
"totalEarnedUsd": [
{
"source": "COINBASE_EXCHANGE",
"conversionTime": "2024-05-02T00:09:00Z",
"amount": {
"amount": "3.61",
"exp": "2",
"ticker": "USD",
"rawNumeric": "361"
},
"conversionPrice": "2971.419922"
}
],
"endingBalance": null,
"protocol": "ethereum",
"rewardState": "PENDING_CLAIMABLE"
}
```

</details>
Expand Down
18 changes: 10 additions & 8 deletions examples/ethereum/list-rewards.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { StakingClient } from '../../src/client/staking-client';

// Address can be substituted with any Ethereum validator.
const address: string =
'0xac53512c39d0081ca4437c285305eb423f474e6153693c12fbba4a3df78bcaa3422b31d800c5bea71c1b017168a60474';

const filter: string = `address='${address}' AND period_end_time > '2024-02-25T00:00:00Z' AND period_end_time < '2024-02-27T00:00:00Z'`;

// Set your api key name and private key here. Get your keys from here: https://portal.cdp.coinbase.com/access/api
const apiKeyName: string = 'your-api-key-name';
const apiPrivateKey: string = 'your-api-private-key';

const client = new StakingClient(apiKeyName, apiPrivateKey);

// Defines which address and rewards we want to see
const address: string =

Check failure on line 10 in examples/ethereum/list-rewards.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎·`
'0x60c7e246344ae3856cf9abe3a2e258d495fc39e0';
const filter: string = `address='${address}' AND period_end_time > '2024-05-01T00:00:00Z' AND period_end_time < '2024-05-02T00:00:00Z'`;

// Loops through rewards array and prints each reward
client.Ethereum.listRewards(filter).then((resp) => {
var list = async function () {

Check failure on line 15 in examples/ethereum/list-rewards.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected var, use let or const instead

Check failure on line 15 in examples/ethereum/list-rewards.ts

View workflow job for this annotation

GitHub Actions / lint

Missing return type on function
const resp = await client.Ethereum.listRewards(filter)

Check failure on line 16 in examples/ethereum/list-rewards.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `;`
resp.rewards!.forEach((reward) => {

Check failure on line 17 in examples/ethereum/list-rewards.ts

View workflow job for this annotation

GitHub Actions / lint

Expected blank line before this statement
console.log(JSON.stringify(reward, null, 2));
});
});
}

Check failure on line 20 in examples/ethereum/list-rewards.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `;`

list();

Check failure on line 22 in examples/ethereum/list-rewards.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `⏎`

0 comments on commit 711350f

Please sign in to comment.