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

Adding member_zrx_staked to epoch pool rewards query #56

Merged
merged 9 commits into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ lib
.env.kovan
package-lock.json
yarn-error.log
.DS_Store
7 changes: 6 additions & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"nohoist": ["**types**"],
"nohoist": [
"**types**"
],
"scripts": {
"build": "yarn tsc -b",
"clean": "rm -rf lib",
"dev": "nodemon -r dotenv/config src/index.ts | pino-pretty",
Copy link
Contributor

Choose a reason for hiding this comment

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

yay, thanks!

"lint": "tslint --project . --format stylish && yarn prettier:ci",
"prettier": "prettier --write '**/*.{ts,tsx,json,md}' --config ../.prettierrc --ignore-path ../../.prettierignore",
"prettier:ci": "prettier --list-different '**/*.{ts,tsx,json,md}' --config ../.prettierrc --ignore-path ../../.prettierignore",
Expand All @@ -29,6 +32,8 @@
"mocha": "^6.2.2",
"prettier": "^1.18.2",
"source-map-support": "^0.5.19",
"nodemon": "^1.19.4",
"pino-pretty": "^3.2.2",
"supertest": "^4.0.2",
"tslint": "^6.1.3"
},
Expand Down
9 changes: 6 additions & 3 deletions packages/api/src/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,18 +328,21 @@ export const poolEpochRewardsQuery = `
, e.ending_timestamp
, e.ending_block_number
, e.ending_transaction_hash
, esps.member_zrx_delegated AS member_zrx_staked
Copy link
Contributor

Choose a reason for hiding this comment

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

COALESCE(esps.member_zrx_delegated, 0.00)

, COALESCE(rpe.operator_reward / 1e18,0) AS operator_reward
, COALESCE(rpe.members_reward / 1e18,0) AS members_reward
, COALESCE((rpe.operator_reward + rpe.members_reward) / 1e18,0) AS total_reward
FROM events.rewards_paid_events rpe
FULL JOIN staking.epochs e ON e.epoch_id = (rpe.epoch_id - 1)
LEFT JOIN staking.epoch_start_pool_status esps ON (esps.epoch_id = e.epoch_id AND esps.pool_id = rpe.pool_id)
LEFT JOIN staking.current_epoch ce ON ce.epoch_id = e.epoch_id
WHERE
(
pool_id = $1
OR pool_id IS NULL
rpe.pool_id = $1
OR rpe.pool_id IS NULL
)
AND ce.epoch_id IS NULL;
AND ce.epoch_id IS NULL
ORDER BY epoch_id ASC;
`;

export const currentEpochPoolsStatsQuery = `
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/query_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ export const stakingUtils = {
epochEndTimestamp: epochReward.ending_timestamp,
operatorRewardsPaidInEth: Number(epochReward.operator_reward || 0),
membersRewardsPaidInEth: Number(epochReward.members_reward || 0),
memberZrxStaked: Number(epochReward.member_zrx_staked || 0),
totalRewardsPaidInEth: Number(epochReward.total_reward || 0),
}));
},
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface RawPoolEpochRewards {
operator_reward: string;
members_reward: string;
total_reward: string;
member_zrx_staked: string;
// Fields below are available but not used in response
starting_block_timestamp: string;
starting_block_number: string;
Expand Down
11 changes: 8 additions & 3 deletions packages/api/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@
"noImplicitReturns": true,
"pretty": true,
"skipLibCheck": true,
"typeRoots": ["../../node_modules/@0x/typescript-typings/types", "node_modules/@types", "../../node_modules/@types", "node_modules/@0x/typescript-typings/types"],
"typeRoots": [
"../../node_modules/@0x/typescript-typings/types",
"node_modules/@types",
"../../node_modules/@types",
"node_modules/@0x/typescript-typings/types"
],
"strict": true,
"declaration": true,
"declarationMap": true,
// "declaration": true,
// "declarationMap": true,
"sourceMap": true
},
"include": ["./src/**/*", "./test/**/*", "./migrations/**/*"]
Expand Down
Loading