Merge branch 'refs/heads/main' into feat/OP-4308-cross-chain-swap

# Conflicts:
#	package.json
This commit is contained in:
Mikhail Gladchenko
2024-07-10 10:57:29 +01:00
10 changed files with 81 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
import { z } from 'zod';
import { makePartial } from '../../../utils/index.js';
import { makePartial } from '../../../utils';
const internalFeeAssetSchema = z.object({
type: z.enum(['percent', 'plain']),
@@ -10,8 +10,9 @@ const internalFeeAssetSchema = z.object({
const infoSchema = z.object({
chainId: z.number(),
chainName: z.string(),
exchangeContractAddress: z.string(),
swapExecutorContractAddress: z.string(),
libValidatorContractAddress: z.string().optional(),
exchangeContractAddress: z.string(),
oracleContractAddress: z.string(),
matcherAddress: z.string(),
orderFeePercent: z.number(),

View File

@@ -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

View 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;

View File

@@ -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';

View File

@@ -12,12 +12,15 @@ const veORNResultSchema = z.object({
weeklyReward: z.number(),
userAPR: z.number(),
userVeORN: z.number(),
userVeORNBalance: z.number(),
userORNLocked: z.number(),
userLockEndDate: z.number(),
userReward: z.number(),
userWeeklyReward: z.number(),
userMinLockPeriod: z.number(),
});
dropLock: z.boolean().optional(),
pointsReward: z.number().optional(),
}).passthrough();
const veORNInfoSchema = z.object({
result: veORNResultSchema,