mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-14 06:02:36 +03:00
cfdContractsSchema rename
Add getCFDHistory method package.json update
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@orionprotocol/sdk",
|
||||
"version": "0.16.0-rc.3",
|
||||
"version": "0.16.0-rc.4",
|
||||
"description": "Orion Protocol SDK",
|
||||
"main": "./lib/esm/index.js",
|
||||
"module": "./lib/esm/index.js",
|
||||
|
||||
@@ -10,7 +10,8 @@ import {
|
||||
userEarnedSchema,
|
||||
PairStatusEnum,
|
||||
pairStatusSchema,
|
||||
CFDContractsSchema,
|
||||
cfdContractsSchema,
|
||||
cfdHistorySchema,
|
||||
} from './schemas';
|
||||
import redeemOrderSchema from '../OrionAggregator/schemas/redeemOrderSchema';
|
||||
import { sourceAtomicHistorySchema, targetAtomicHistorySchema } from './schemas/atomicHistorySchema';
|
||||
@@ -53,6 +54,12 @@ type AtomicSwapHistoryTargetQuery = AtomicSwapHistoryBaseQuery & {
|
||||
expiredRedeem?: 0 | 1,
|
||||
state?: 'REDEEMED' | 'BEFORE-REDEEM',
|
||||
}
|
||||
|
||||
type CfdHistoryQuery = {
|
||||
instrument?: string,
|
||||
page?: number,
|
||||
limit?: number,
|
||||
}
|
||||
class OrionBlockchain {
|
||||
private readonly apiUrl: string;
|
||||
|
||||
@@ -92,6 +99,7 @@ class OrionBlockchain {
|
||||
this.getRedeemOrderBySecretHash = this.getRedeemOrderBySecretHash.bind(this);
|
||||
this.claimOrder = this.claimOrder.bind(this);
|
||||
this.getCFDContracts = this.getCFDContracts.bind(this);
|
||||
this.getCFDHistory = this.getCFDHistory.bind(this);
|
||||
}
|
||||
|
||||
get orionBlockchainWsUrl() {
|
||||
@@ -382,8 +390,17 @@ class OrionBlockchain {
|
||||
|
||||
getCFDContracts = () => fetchWithValidation(
|
||||
`${this.apiUrl}/api/cfd/contracts`,
|
||||
CFDContractsSchema,
|
||||
cfdContractsSchema,
|
||||
);
|
||||
|
||||
getCFDHistory = (address: string, query: CfdHistoryQuery) => {
|
||||
const url = new URL(`${this.apiUrl}/api/cfd/deposit-withdraw/${address}`);
|
||||
|
||||
Object.entries(query)
|
||||
.forEach(([key, value]) => url.searchParams.append(key, value.toString()));
|
||||
|
||||
return fetchWithValidation(url.toString(), cfdHistorySchema);
|
||||
};
|
||||
}
|
||||
|
||||
export * as schemas from './schemas';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
const CFDContractsSchema = z.array(z.object({
|
||||
const cfdContractsSchema = z.array(z.object({
|
||||
name: z.string(),
|
||||
alias: z.string(),
|
||||
address: z.string(),
|
||||
@@ -14,4 +14,4 @@ const CFDContractsSchema = z.array(z.object({
|
||||
priceIndex: z.number(),
|
||||
}));
|
||||
|
||||
export default CFDContractsSchema;
|
||||
export default cfdContractsSchema;
|
||||
15
src/services/OrionBlockchain/schemas/cfdHistorySchema.ts
Normal file
15
src/services/OrionBlockchain/schemas/cfdHistorySchema.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
const cfdHistorySchema = z.array(z.object({
|
||||
address: z.string(),
|
||||
instrument: z.string(),
|
||||
balance: z.string(),
|
||||
position: z.string(),
|
||||
reason: z.string(),
|
||||
positionPrice: z.string(),
|
||||
fundingRate: z.string(),
|
||||
transactionHash: z.string(),
|
||||
blockNumber: z.number(),
|
||||
}));
|
||||
|
||||
export default cfdHistorySchema;
|
||||
@@ -12,4 +12,5 @@ export { default as atomicSummarySchema } from './atomicSummarySchema';
|
||||
export { default as poolsLpAndStakedSchema } from './poolsLpAndStakedSchema';
|
||||
export { default as userVotesSchema } from './userVotesSchema';
|
||||
export { default as userEarnedSchema } from './userEarnedSchema';
|
||||
export { default as CFDContractsSchema } from './CFDContractsSchema';
|
||||
export { default as cfdContractsSchema } from './cfdContractsSchema';
|
||||
export { default as cfdHistorySchema } from './cfdHistorySchema';
|
||||
|
||||
Reference in New Issue
Block a user