add getCrossChainAssetsByNetwork method

This commit is contained in:
TheJuze
2024-01-10 15:29:06 +03:00
parent e2729cf5a1
commit c654778129
3 changed files with 33 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@orionprotocol/sdk",
"version": "0.20.41",
"version": "0.20.42-rc0",
"description": "Orion Protocol SDK",
"main": "./lib/index.cjs",
"module": "./lib/index.js",

View File

@@ -6,9 +6,9 @@ import cancelOrderSchema from './schemas/cancelOrderSchema.js';
import orderBenefitsSchema from './schemas/orderBenefitsSchema.js';
import errorSchema from './schemas/errorSchema.js';
import placeAtomicSwapSchema from './schemas/placeAtomicSwapSchema.js';
import { AggregatorWS } from './ws/index.js';
import { AggregatorWS } from './ws';
import { atomicSwapHistorySchema } from './schemas/atomicSwapHistorySchema.js';
import type { BasicAuthCredentials, SignedCancelOrderRequest, SignedOrder } from '../../types.js';
import type { BasicAuthCredentials, SignedCancelOrderRequest, SignedOrder, SupportedChainShortNames } from '../../types.js';
import {
pairConfigSchema, aggregatedOrderbookSchema,
exchangeOrderbookSchema, poolReservesSchema,
@@ -51,6 +51,7 @@ class Aggregator {
this.getPairConfigs = this.getPairConfigs.bind(this);
this.getPairsList = this.getPairsList.bind(this);
this.getSwapInfo = this.getSwapInfo.bind(this);
this.getCrossChainAssetsByNetwork = this.getCrossChainAssetsByNetwork.bind(this);
this.getTradeProfits = this.getTradeProfits.bind(this);
this.placeAtomicSwap = this.placeAtomicSwap.bind(this);
this.placeOrder = this.placeOrder.bind(this);
@@ -290,6 +291,18 @@ class Aggregator {
);
};
getCrossChainAssetsByNetwork = (sourceChain: SupportedChainShortNames) => {
const url = new URL(`${this.apiUrl}/api/v1/cross-chain/assets`);
url.searchParams.append('sourceChain', sourceChain);
return fetchWithValidation(
url.toString(),
z.array(z.number()),
{ headers: this.basicAuthHeaders },
errorSchema,
)
}
getPrices = (assetPair: string, includePools: boolean) => {
const url = new URL(`${this.apiUrl}/api/v1/prices/`);
url.searchParams.append('assetPair', assetPair);

View File

@@ -99,6 +99,23 @@ export enum SupportedChainId {
// BROKEN = '0',
}
export enum SupportedChainShortNames {
MAINNET = 'ETH',
ROPSTEN = 'ETH-Ropsten',
GOERLI = 'ETH-Goerli',
ARBITRUM_GOERLI = 'Arbitrum Goerli',
FANTOM_OPERA = 'FTM',
POLYGON = 'Polygon',
OKC = 'OKC',
POLYGON_TESTNET = 'Polygon Mumbai',
FANTOM_TESTNET = 'FTM-Testnet',
BSC = 'BSC',
BSC_TESTNET = 'BSC-Testnet',
OKC_TESTNET = 'OKC-Testnet',
DRIP_TESTNET = 'DRIP Chain',
}
const balanceTypes = ['exchange', 'wallet'] as const;
export type Source = typeof balanceTypes[number];