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,6 +1,6 @@
{
"name": "@orionprotocol/sdk",
"version": "0.23.0-rc7",
"version": "0.23.0-rc8",
"description": "Orion Protocol SDK",
"main": "./lib/index.cjs",
"module": "./lib/index.js",

View File

@@ -64,6 +64,19 @@
"curveRegistry": ""
}
},
"123420000034": {
"chainId": "123420000034",
"explorer": "https://blockscout-123420000034.raas-testnet.gelato.digital/",
"label": "Event Horizon Testnet",
"shortName": "EH-Testnet",
"code": "eth",
"rpc": "https://rpc-123420000034.raas-testnet.gelato.digital/",
"baseCurrencyName": "ETH",
"contracts": {
"WETH": "0x4200000000000000000000000000000000000006",
"curveRegistry": ""
}
},
"42161": {
"chainId": "42161",
"explorer": "https://arbiscan.io/",

View File

@@ -244,6 +244,24 @@
"http": "/orion-indexer/"
}
}
},
"123420000034": {
"api": "https://testing.orion.xyz/event-horizon-testnet",
"services": {
"aggregator": {
"http": "/backend",
"ws": "/v1"
},
"blockchain": {
"http": ""
},
"priceFeed": {
"all": "/price-feed"
},
"indexer": {
"http": "/orion-indexer/"
}
}
}
}
},

View File

@@ -3,6 +3,7 @@ import { SupportedChainId } from '../types.js';
export const developmentChains = [
SupportedChainId.BSC_TESTNET,
SupportedChainId.SEPOLIA,
SupportedChainId.EVENT_HORIZON_TESTNET,
];
export const productionChains = [
SupportedChainId.MAINNET,

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,

View File

@@ -121,6 +121,7 @@ export enum SupportedChainId {
BSC_TESTNET = '97',
SEPOLIA = '11155111',
EVENT_HORIZON_TESTNET = '123420000034',
// For testing and debug purpose
// BROKEN = '0',