mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-14 06:02:36 +03:00
Merge pull request #264 from orionprotocol/indexer-update
indexer update
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@orionprotocol/sdk",
|
||||
"version": "0.22.9",
|
||||
"version": "0.22.10-rc3",
|
||||
"description": "Orion Protocol SDK",
|
||||
"main": "./lib/index.cjs",
|
||||
"module": "./lib/index.js",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
environmentResponseSchema,
|
||||
getPointsAtResponseSchema,
|
||||
getPoolResponseSchema,
|
||||
listAmountResponseSchema,
|
||||
listNFTOrderResponseSchema,
|
||||
@@ -51,6 +52,12 @@ type VeORNInfoPayload = BasePayload & {
|
||||
params: [string]
|
||||
};
|
||||
|
||||
type GetPointsAtPayload = BasePayload & {
|
||||
model: 'veORN'
|
||||
method: 'pointsInfo'
|
||||
params: [number, number]
|
||||
};
|
||||
|
||||
type ListAmountPayload = BasePayload & {
|
||||
model: string
|
||||
method: 'listAmount'
|
||||
@@ -68,6 +75,7 @@ type Payload =
|
||||
| GetPoolInfoPayload
|
||||
| ListPoolPayload
|
||||
| VeORNInfoPayload
|
||||
| GetPointsAtPayload
|
||||
| ListAmountPayload
|
||||
| GetAmountByORNPayload;
|
||||
|
||||
@@ -92,6 +100,7 @@ class IndexerService {
|
||||
this.poolV2Info = this.poolV2Info.bind(this);
|
||||
this.listPoolV3 = this.listPoolV3.bind(this);
|
||||
this.veORNInfo = this.veORNInfo.bind(this);
|
||||
this.getPointsAt = this.getPointsAt.bind(this);
|
||||
this.listAmount = this.listAmount.bind(this);
|
||||
this.getAmountByORN = this.getAmountByORN.bind(this);
|
||||
this.getAmountAt = this.getAmountAt.bind(this);
|
||||
@@ -118,6 +127,21 @@ class IndexerService {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} page - current page
|
||||
* @param {number} [pageSize] - amount of items on one page
|
||||
*/
|
||||
readonly getPointsAt = (page = 1, pageSize = 1000) => {
|
||||
return fetchWithValidation(this.apiUrl, getPointsAtResponseSchema, {
|
||||
method: 'POST',
|
||||
body: this.makeRPCPayload({
|
||||
model: 'veORN',
|
||||
method: 'pointsAt',
|
||||
params: [page, pageSize],
|
||||
}),
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} amount - amount
|
||||
* @param {number} [timestamp = Date.now()] - timestamp, defaults to current time
|
||||
|
||||
15
src/services/Indexer/schemas/get-points-at-schema.ts
Normal file
15
src/services/Indexer/schemas/get-points-at-schema.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { z } from 'zod';
|
||||
import infoSchema from './info-schema.js';
|
||||
|
||||
const getPointsAtResultSchema = z.object({
|
||||
pointsObject: z.record(z.string(), z.number()),
|
||||
currentPage: z.number(),
|
||||
totalElements: z.number(),
|
||||
});
|
||||
|
||||
const getPointsAtSchema = z.object({
|
||||
result: getPointsAtResultSchema,
|
||||
info: infoSchema,
|
||||
}).nullable();
|
||||
|
||||
export default getPointsAtSchema;
|
||||
@@ -9,3 +9,4 @@ export { default as veORNInfoResponseSchema } from './veORN-info-schema';
|
||||
export { default as listAmountResponseSchema } from './list-amount-schema';
|
||||
export { default as votingInfoResponseSchema } from './voting-info-schema';
|
||||
export { default as testIncrementorSchema } from './test-incrementor-schema';
|
||||
export { default as getPointsAtResponseSchema } from './get-points-at-schema';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { z } from 'zod';
|
||||
import { evmAddressSchema } from './util-schemas.js';
|
||||
import infoSchema from './info-schema.js';
|
||||
import { z } from "zod";
|
||||
import { evmAddressSchema } from "./util-schemas.js";
|
||||
import infoSchema from "./info-schema.js";
|
||||
|
||||
const veORNResultSchema = z.object({
|
||||
avgAPR: z.number(),
|
||||
@@ -17,6 +17,8 @@ const veORNResultSchema = z.object({
|
||||
userReward: z.number(),
|
||||
userWeeklyReward: z.number(),
|
||||
userMinLockPeriod: z.number(),
|
||||
dropLock: z.boolean(),
|
||||
pointsReward: z.number(),
|
||||
});
|
||||
|
||||
const veORNInfoSchema = z.object({
|
||||
|
||||
Reference in New Issue
Block a user