Skip to content

Commit

Permalink
Merge branch 'prod' into feat/stakingv3-stakerstakeamount
Browse files Browse the repository at this point in the history
  • Loading branch information
gluneau authored Jan 23, 2024
2 parents 79e7f38 + e10593b commit be20e76
Show file tree
Hide file tree
Showing 4 changed files with 361 additions and 2 deletions.
128 changes: 128 additions & 0 deletions public/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,40 @@
}
}
},
"/api/v3/{network}/dapps-staking/stakerslist/{contractAddress}": {
"get": {
"tags": [
"Dapps Staking"
],
"description": "Retrieves dapps staking stakers list for a given network and period.",
"parameters": [
{
"name": "network",
"in": "path",
"required": true,
"type": "string",
"description": "The network name. Supported networks: astar",
"enum": [
"astar",
"shiden",
"shibuya"
]
},
{
"name": "contractAddress",
"in": "path",
"required": true,
"type": "string",
"description": "Contract address to get stats for"
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/api/v3/{network}/dapps-staking/chaindapps": {
"get": {
"tags": [
Expand Down Expand Up @@ -876,6 +910,100 @@
}
}
},
"/api/v3/{network}/dapps-staking/rewards/{period}": {
"get": {
"tags": [
"Dapps Staking"
],
"description": "Retrieves dapps staking rewards for a given network and period.",
"parameters": [
{
"name": "network",
"in": "path",
"required": true,
"type": "string",
"description": "The network name. Supported networks: astar",
"enum": [
"astar",
"shiden",
"shibuya"
]
},
{
"name": "period",
"in": "path",
"required": true,
"type": "string",
"description": "The period type. Supported values: 1 day, 7 days, 30 days, 90 days, 1 year",
"enum": [
"1 day",
"7 days",
"30 days",
"90 days",
"1 year"
]
},
{
"name": "transaction",
"in": "query",
"type": "string"
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/api/v3/{network}/dapps-staking/rewards-aggregated/{address}/{period}": {
"get": {
"tags": [
"Dapps Staking"
],
"description": "Retrieves dapps staking rewards for a given network and period.",
"parameters": [
{
"name": "network",
"in": "path",
"required": true,
"type": "string",
"description": "The network name. Supported networks: astar",
"enum": [
"astar",
"shiden",
"shibuya"
]
},
{
"name": "address",
"in": "path",
"required": true,
"type": "string",
"description": "User address or contract address who received rewards"
},
{
"name": "period",
"in": "path",
"required": true,
"type": "string",
"description": "The period type. Supported values: 1 day, 7 days, 30 days, 90 days, 1 year",
"enum": [
"1 day",
"7 days",
"30 days",
"90 days",
"1 year"
]
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/api/v1/{network}/node/tx-perblock/total": {
"get": {
"tags": [
Expand Down
94 changes: 93 additions & 1 deletion src/controllers/DappsStakingV3Controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { NetworkType } from '../networks';
import { PeriodType } from '../services/ServiceBase';
import { ControllerBase } from './ControllerBase';
import { IControllerBase } from './IControllerBase';
import { IDappsStakingEvents } from '../services/DappsStakingEvents';
import { IDappsStakingEvents, RewardEventType } from '../services/DappsStakingEvents';

@injectable()
export class DappsStakingV3Controller extends ControllerBase implements IControllerBase {
Expand Down Expand Up @@ -75,6 +75,32 @@ export class DappsStakingV3Controller extends ControllerBase implements IControl
},
);

app.route('/api/v3/:network/dapps-staking/stakerslist/:contractAddress').get(
async (req: Request, res: Response) => {
/*
#swagger.description = 'Retrieves dapps staking stakers list for a given network and period.'
#swagger.tags = ['Dapps Staking']
#swagger.parameters['network'] = {
in: 'path',
description: 'The network name. Supported networks: astar',
required: true,
enum: ['astar', 'shiden', 'shibuya']
}
#swagger.parameters['contractAddress'] = {
in: 'path',
description: 'Contract address to get stats for',
required: true
}
*/
res.json(
await this._dappsStakingEvents.getDappStakingStakersList(
req.params.network as NetworkType,
req.params.contractAddress as string,
),
);
},
);

app.route('/api/v3/:network/dapps-staking/chaindapps').get(async (req: Request, res: Response) => {
/*
#swagger.description = 'Retrieves list of dapps (basic info) registered for dapps staking'
Expand Down Expand Up @@ -212,5 +238,71 @@ export class DappsStakingV3Controller extends ControllerBase implements IControl
}
},
);

app.route('/api/v3/:network/dapps-staking/rewards/:period').get(async (req: Request, res: Response) => {
/*
#swagger.description = 'Retrieves dapps staking rewards for a given network and period.'
#swagger.tags = ['Dapps Staking']
#swagger.parameters['network'] = {
in: 'path',
description: 'The network name. Supported networks: astar',
required: true,
enum: ['astar', 'shiden', 'shibuya']
}
#swagger.parameters['period'] = {
in: 'path',
description: 'The period type. Supported values: 1 day, 7 days, 30 days, 90 days, 1 year',
required: true,
enum: ['1 day', '7 days', '30 days', '90 days', '1 year']
}
#swagger.parameters['transaction'] = {
in: 'query',
description: 'The Reward Event transaction type. Supported values: Reward', 'BonusReward', 'DAppReward',
required: false,
type: 'string',
enum: ['Reward', 'BonusReward', 'DAppReward']
}
*/
res.json(
await this._dappsStakingEvents.getDappStakingRewards(
req.params.network as NetworkType,
req.params.period as PeriodType,
req.query.transaction as RewardEventType,
),
);
});

app.route('/api/v3/:network/dapps-staking/rewards-aggregated/:address/:period').get(
async (req: Request, res: Response) => {
/*
#swagger.description = 'Retrieves dapps staking rewards for a given network and period.'
#swagger.tags = ['Dapps Staking']
#swagger.parameters['network'] = {
in: 'path',
description: 'The network name. Supported networks: astar',
required: true,
enum: ['astar', 'shiden', 'shibuya']
}
#swagger.parameters['address'] = {
in: 'path',
description: 'User address or contract address who received rewards',
required: true
}
#swagger.parameters['period'] = {
in: 'path',
description: 'The period type. Supported values: 1 day, 7 days, 30 days, 90 days, 1 year',
required: true,
enum: ['1 day', '7 days', '30 days', '90 days', '1 year']
}
*/
res.json(
await this._dappsStakingEvents.getDappStakingRewardsAggregated(
req.params.network as NetworkType,
req.params.address as string,
req.params.period as PeriodType,
),
);
},
);
}
}
Loading

0 comments on commit be20e76

Please sign in to comment.