removed cfd

This commit is contained in:
Kirill Litvinov
2023-07-06 14:22:26 +03:00
parent abdd849eeb
commit 0c02ff821a
21 changed files with 5 additions and 521 deletions

View File

@@ -9,8 +9,6 @@ import {
userEarnedSchema,
type PairStatusEnum,
pairStatusSchema,
cfdContractsSchema,
cfdHistorySchema,
governanceContractsSchema,
governancePoolsSchema,
governancePoolSchema,
@@ -59,12 +57,6 @@ type AtomicSwapHistoryTargetQuery = AtomicSwapHistoryBaseQuery & {
expiredRedeem?: 0 | 1
state?: 'REDEEMED' | 'BEFORE-REDEEM'
}
type CfdHistoryQuery = {
instrument?: string
page?: number
limit?: number
} & Partial<Record<string, string | number>>
class BlockchainService {
private readonly apiUrl: string;
@@ -110,8 +102,6 @@ class BlockchainService {
this.getBlockNumber = this.getBlockNumber.bind(this);
this.getRedeemOrderBySecretHash = this.getRedeemOrderBySecretHash.bind(this);
this.claimOrder = this.claimOrder.bind(this);
this.getCFDContracts = this.getCFDContracts.bind(this);
this.getCFDHistory = this.getCFDHistory.bind(this);
this.getGovernanceContracts = this.getGovernanceContracts.bind(this);
this.getGovernancePools = this.getGovernancePools.bind(this);
this.getGovernancePool = this.getGovernancePool.bind(this);
@@ -222,12 +212,6 @@ class BlockchainService {
{ headers: this.basicAuthHeaders }
);
getCFDPrices = () => fetchWithValidation(
`${this.apiUrl}/api/cfd/prices`,
z.record(z.string()).transform(makePartial),
{ headers: this.basicAuthHeaders }
);
getTokensFee = () => fetchWithValidation(
`${this.apiUrl}/api/tokensFee`,
z.record(z.string()).transform(makePartial),
@@ -454,24 +438,6 @@ class BlockchainService {
},
);
getCFDContracts = () => fetchWithValidation(
`${this.apiUrl}/api/cfd/contracts`,
cfdContractsSchema,
{ headers: this.basicAuthHeaders },
);
getCFDHistory = (address: string, query: CfdHistoryQuery = {}) => {
const url = new URL(`${this.apiUrl}/api/cfd/deposit-withdraw/${address}`);
Object.entries(query)
.forEach(([key, value]) => {
if (value === undefined) throw new Error('Value must be defined');
url.searchParams.append(key, value.toString());
});
return fetchWithValidation(url.toString(), cfdHistorySchema, { headers: this.basicAuthHeaders });
};
getGovernanceContracts = () => fetchWithValidation(
`${this.apiUrl}/api/governance/info`,
governanceContractsSchema,

View File

@@ -1,20 +0,0 @@
import { z } from 'zod';
const cfdContractsSchema = z.array(z.object({
name: z.string(),
alias: z.string(),
address: z.string(),
leverage: z.number(),
soLevel: z.number(),
shortFR: z.number(),
longFR: z.number(),
shortFRStored: z.number(),
longFRStored: z.number(),
lastFRPriceUpdateTime: z.number(),
priceIndex: z.number(),
feePercent: z.number(),
withdrawMarginLevel: z.number(),
delegateContractAddress: z.string(),
}));
export default cfdContractsSchema;

View File

@@ -1,52 +0,0 @@
import { z } from 'zod';
import { HistoryTransactionStatus } from '../../../types.js';
export enum historyTransactionType {
WITHDRAW = 'withdrawal',
DEPOSIT = 'deposit',
}
const cfdHistoryItem = z.object({
_id: z.string(),
__v: z.number(),
address: z.string(),
instrument: z.string(),
instrumentAddress: z.string(),
balance: z.string(),
amount: z.string(),
amountNumber: z.string(),
position: z.string(),
reason: z.enum(['WITHDRAW', 'DEPOSIT']),
positionPrice: z.string(),
fundingRate: z.string(),
transactionHash: z.string(),
blockNumber: z.number(),
createdAt: z.number(),
});
const cfdHistorySchema = z.object({
success: z.boolean(),
count: z.number(),
total: z.number(),
pagination: z.object({}),
data: z.array(cfdHistoryItem),
}).transform((response) => {
return response.data.map((item) => {
const {
createdAt, reason, transactionHash, amountNumber,
} = item;
const type = historyTransactionType[reason];
return {
type,
date: createdAt,
token: 'USDT',
amount: amountNumber,
status: HistoryTransactionStatus.DONE,
transactionHash,
user: item.address,
};
});
});
export default cfdHistorySchema;

View File

@@ -12,8 +12,6 @@ export { default as atomicSummarySchema } from './atomicSummarySchema.js';
export { default as poolsLpAndStakedSchema } from './poolsLpAndStakedSchema.js';
export { default as userVotesSchema } from './userVotesSchema.js';
export { default as userEarnedSchema } from './userEarnedSchema.js';
export { default as cfdContractsSchema } from './cfdContractsSchema.js';
export { default as cfdHistorySchema } from './cfdHistorySchema.js';
export { default as governanceContractsSchema } from './governanceContractsSchema.js';
export { default as governancePoolsSchema } from './governancePoolsSchema.js';
export { default as governancePoolSchema } from './governancePoolSchema.js';