@myx-trade/sdk 0.1.2 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -4,7 +4,7 @@ export { formatUnits, parseUnits } from 'ethers';
4
4
  import { Options, Event } from 'reconnecting-websocket';
5
5
  import { WalletClient } from 'viem';
6
6
 
7
- type Address$1 = `0x${string}` | typeof ZeroAddress;
7
+ type Address$2 = `0x${string}` | typeof ZeroAddress;
8
8
  declare enum ChainId {
9
9
  LINEA_SEPOLIA = 59141,
10
10
  LINEA_MAINNET = 59144,
@@ -55,7 +55,7 @@ interface CancelTpSLParams {
55
55
 
56
56
  declare const createPool: ({ chainId, baseToken }: CreatePoolRequest) => Promise<string | undefined>;
57
57
 
58
- declare const getMarketPoolId: ({ chainId, baseToken }: CreatePoolRequest) => Promise<string | undefined>;
58
+ declare const getMarketPoolId: ({ chainId, baseToken, }: CreatePoolRequest) => Promise<string | undefined>;
59
59
  declare const getMarketPools: (chainId: ChainId) => Promise<string[]>;
60
60
  declare const getPoolInfo$1: (chainId: ChainId, poolId: string, marketPrice?: bigint) => Promise<{
61
61
  quotePool: {
@@ -81,6 +81,12 @@ declare const getPoolInfo$1: (chainId: ChainId, poolId: string, marketPrice?: bi
81
81
  lastFundingFeeTracker: bigint;
82
82
  nextEpochTime: bigint;
83
83
  };
84
+ ioTracker: {
85
+ tracker: bigint;
86
+ longSize: bigint;
87
+ shortSize: bigint;
88
+ poolEntryPrice: bigint;
89
+ };
84
90
  }>;
85
91
 
86
92
  declare const getUserGenesisShare: (chainId: ChainId, tokenAddress: string, account: string) => Promise<bigint>;
@@ -220,7 +226,7 @@ interface UpdateOrderTpSlParams {
220
226
  interface ObjectType<T> {
221
227
  [key: string]: T;
222
228
  }
223
- type Address = `0x${string}`;
229
+ type Address$1 = `0x${string}`;
224
230
  type NetWorkFee = {
225
231
  paymentType: number;
226
232
  volScale: number;
@@ -377,7 +383,259 @@ interface TickerDataItem {
377
383
  volume: string;
378
384
  turnover: string;
379
385
  }
386
+ declare enum MarketType {
387
+ Contract = 1,
388
+ Cook = 2,
389
+ Earn = 3
390
+ }
391
+ declare enum SearchTypeEnum {
392
+ All = 0,
393
+ Contract = 1,
394
+ Cook = 2,
395
+ Earn = 3
396
+ }
397
+ declare enum MarketCapType {
398
+ BlueChips = 1,
399
+ Alpha = 2
400
+ }
401
+ declare enum SearchSecondTypeEnum {
402
+ BlueChips = 1,
403
+ Alpha = 2,
404
+ Favorite = 3
405
+ }
406
+ interface ChainIdRequest {
407
+ chainId: ChainId;
408
+ }
409
+ type FavoritesType = -1 | 1;
410
+ interface SearchResultContractItem {
411
+ chainId: ChainId;
412
+ poolId: string;
413
+ baseQuoteSymbol: string;
414
+ symbolName: string;
415
+ baseToken: Address$1;
416
+ tokenIcon: string;
417
+ type: MarketType;
418
+ capType: MarketCapType;
419
+ favorites: FavoritesType;
420
+ volume: string;
421
+ liquidity: string;
422
+ basePrice: string;
423
+ priceChange: string;
424
+ }
425
+ interface SearchResultCookItem {
426
+ chainId: ChainId;
427
+ poolId: string;
428
+ mBaseQuoteSymbol: string;
429
+ symbolName: string;
430
+ baseToken: Address$1;
431
+ tokenIcon: string;
432
+ type: MarketType;
433
+ state: MarketPoolState;
434
+ tvl: string;
435
+ marketCap: string;
436
+ lpPrice: string;
437
+ lpPriceChange: string;
438
+ }
439
+ interface SearchResultEarnItem {
440
+ chainId: ChainId;
441
+ poolId: string;
442
+ mQuoteBaseSymbol: string;
443
+ symbolName: string;
444
+ baseToken: Address$1;
445
+ tokenIcon: string;
446
+ type: MarketType;
447
+ state: MarketPoolState;
448
+ rating: string;
449
+ tvl: string;
450
+ marketCap: string;
451
+ apr: string;
452
+ }
453
+ interface SearchResultResponse {
454
+ earnInfo: {
455
+ list: SearchResultEarnItem[];
456
+ total: number;
457
+ };
458
+ cookInfo: {
459
+ list: SearchResultCookItem[];
460
+ total: number;
461
+ };
462
+ contractInfo: {
463
+ list: SearchResultContractItem[];
464
+ total: number;
465
+ };
466
+ }
467
+ interface FavoritesListItem {
468
+ ChainId: ChainId;
469
+ poolId: string;
470
+ symbolName: string;
471
+ tokenIcon: string;
472
+ capType: MarketCapType;
473
+ baseToken: Address$1;
474
+ basePrice: string;
475
+ priceChange: string;
476
+ volume: string;
477
+ marketCap: string;
478
+ baseQuoteSymbol: string;
479
+ favorites: FavoritesType;
480
+ }
481
+ interface BaseDetailResponse {
482
+ totalSupply: string;
483
+ circulation: string;
484
+ marketCap: string;
485
+ fdv: string;
486
+ holders: number;
487
+ traders: number;
488
+ liquidity: string;
489
+ volume: string;
490
+ longPosition: number;
491
+ shortPosition: number;
492
+ fundingRate: string;
493
+ tokenIcon: string;
494
+ poolId: string;
495
+ mSymbol: string;
496
+ symbolName: string;
497
+ lpPriceChange: string;
498
+ chainId: number;
499
+ tokenCreateTime: number;
500
+ baseToken: Address$1;
501
+ marketId: string;
502
+ basePrice: string;
503
+ tvl: string;
504
+ apr: string;
505
+ }
506
+ interface MarketDetailResponse {
507
+ chainId: number;
508
+ marketId: string;
509
+ poolId: string;
510
+ oracleId: number;
511
+ globalId: number;
512
+ state: MarketPoolState;
513
+ baseSymbol: string;
514
+ quoteSymbol: string;
515
+ baseDecimals: number;
516
+ quoteDecimals: number;
517
+ baseToken: Address$1;
518
+ quoteToken: Address$1;
519
+ basePoolToken: Address$1;
520
+ quotePoolToken: Address$1;
521
+ oracleType: OracleType;
522
+ feedId: string;
523
+ activeTime: number;
524
+ capType: MarketCapType;
525
+ }
380
526
 
527
+ declare class Address {
528
+ private _addr;
529
+ static ZERO_ADDRESS: Address;
530
+ constructor(addr?: string);
531
+ toString(): string;
532
+ format(): string;
533
+ unmaskFormat(): string;
534
+ static from(addr?: string): Address;
535
+ isEqualTo(otherAddress?: string | Address): boolean;
536
+ }
537
+
538
+ interface GetHistoryOrdersParams {
539
+ limit?: number;
540
+ chainId?: number;
541
+ }
542
+ declare enum OrderTypeEnum {
543
+ Market = 0,
544
+ Limit = 1,
545
+ Stop = 2,
546
+ Conditional = 3
547
+ }
548
+ declare enum OperationEnum {
549
+ Increase = 0,
550
+ Decrease = 1
551
+ }
552
+ declare enum TriggerTypeEnum {
553
+ Unknown = 0,
554
+ GTE = 1,
555
+ LTE = 2
556
+ }
557
+ declare enum DirectionEnum {
558
+ Long = 0,
559
+ Short = 1
560
+ }
561
+ declare enum OrderStatusEnum {
562
+ Cancelled = 1,
563
+ Expired = 2,
564
+ Successful = 9
565
+ }
566
+ declare enum ExecTypeEnum {
567
+ UserEntrust = 0,
568
+ Liquidation = 1,
569
+ Adl = 2,
570
+ AdlTrigger = 3
571
+ }
572
+ interface HistoryOrderItem {
573
+ chainId: number;
574
+ poolId: string;
575
+ orderId: number;
576
+ txTime: number;
577
+ txHash: number;
578
+ orderType: OrderTypeEnum;
579
+ operation: OperationEnum;
580
+ triggerType: TriggerTypeEnum;
581
+ direction: DirectionEnum;
582
+ size: string;
583
+ filledSize: string;
584
+ filledAmount: string;
585
+ price: string;
586
+ lastPrice: string;
587
+ orderStatus: OrderStatusEnum;
588
+ execType: ExecTypeEnum;
589
+ slippagePct: number;
590
+ executionFeeToken: Address;
591
+ executionFeeAmount: string;
592
+ tradingFee: string;
593
+ fundingFee: string;
594
+ realizedPnl: string;
595
+ }
596
+ /**
597
+ * Get history orders
598
+ */
599
+ declare const getHistoryOrders: ({ accessToken, ...params }: GetHistoryOrdersParams & AccessTokenRequest) => Promise<ApiResponse<HistoryOrderItem[]>>;
600
+ /**
601
+ * Get position history
602
+ */
603
+ interface PositionHistoryItem {
604
+ chainId: number;
605
+ poolId: string;
606
+ positionId: number;
607
+ direction: DirectionEnum;
608
+ entryPrice: string;
609
+ fundingRateIndex: string;
610
+ size: string;
611
+ filledSize: string;
612
+ riskTier: number;
613
+ collateralAmount: string;
614
+ openTime: number;
615
+ closeTime: number;
616
+ realizedPnl: string;
617
+ }
618
+ declare const getPositionHistory: ({ accessToken, ...params }: GetHistoryOrdersParams & AccessTokenRequest) => Promise<ApiResponse<PositionHistoryItem[]>>;
619
+ /**
620
+ * Get Trade Flow
621
+ */
622
+ interface TradeFlowItem {
623
+ chainId: number;
624
+ orderId: number;
625
+ user: Address;
626
+ poolId: string;
627
+ realizedPnl: string;
628
+ fundingFee: string;
629
+ tradingFee: string;
630
+ charge: string;
631
+ beforeCollateralAmount: string;
632
+ afterCollateralAmount: string;
633
+ txHash: string;
634
+ txTime: number;
635
+ }
636
+ declare const getTradeFlow: ({ accessToken, ...params }: GetHistoryOrdersParams & AccessTokenRequest) => Promise<ApiResponse<TradeFlowItem[]>>;
637
+
638
+ declare const baseUrl = "https://api-test.myx.cash";
381
639
  /**
382
640
  * Get pools
383
641
  */
@@ -435,6 +693,53 @@ interface GetTickerDataParams {
435
693
  }
436
694
  declare const getTickerData: ({ chainId, poolIds, }: GetTickerDataParams) => Promise<ApiResponse<TickerDataItem[]>>;
437
695
  declare const getAllTickers: () => Promise<ApiResponse<TickerDataItem[]>>;
696
+ /**
697
+ * search
698
+ */
699
+ interface SearchMarketParams {
700
+ chainId: ChainId | 0;
701
+ searchType?: SearchTypeEnum;
702
+ type?: SearchSecondTypeEnum;
703
+ searchKey?: string;
704
+ }
705
+ declare const searchMarketAuth: ({ accessToken, ...params }: SearchMarketParams & AccessTokenRequest) => Promise<ApiResponse<SearchResultResponse>>;
706
+ declare const searchMarket: ({ ...params }: SearchMarketParams) => Promise<ApiResponse<SearchResultResponse>>;
707
+ /**
708
+ * favorite
709
+ */
710
+ interface AddFavoriteParams {
711
+ poolId: string;
712
+ chainId: ChainId;
713
+ }
714
+ declare const addFavorite: ({ accessToken, ...params }: AddFavoriteParams & AccessTokenRequest) => Promise<ApiResponse<null>>;
715
+ interface RemoveFavoriteParams {
716
+ poolId: string;
717
+ chainId: ChainId;
718
+ }
719
+ declare const removeFavorite: ({ accessToken, ...params }: RemoveFavoriteParams & AccessTokenRequest) => Promise<ApiResponse<null>>;
720
+ /**
721
+ * Favorites List
722
+ */
723
+ type FavoritesTimeInterval = "10m" | "1h" | "4h" | "12h" | "24h";
724
+ interface FavoritesListParams {
725
+ poolId?: string;
726
+ before?: number;
727
+ after?: number;
728
+ limit?: number;
729
+ timeInterval?: FavoritesTimeInterval;
730
+ chainId: ChainId | 0;
731
+ }
732
+ declare const getFavoritesList: ({ accessToken, ...params }: FavoritesListParams & AccessTokenRequest) => Promise<ApiResponse<FavoritesListItem[]>>;
733
+ interface GetBaseDetailParams {
734
+ chainId: ChainId;
735
+ poolId: string;
736
+ }
737
+ declare const getBaseDetail: (params: GetBaseDetailParams) => Promise<ApiResponse<BaseDetailResponse>>;
738
+ interface GetMarketDetailParams {
739
+ chainId: number;
740
+ poolId: string;
741
+ }
742
+ declare const getMarketDetail: (params: GetMarketDetailParams) => Promise<ApiResponse<MarketDetailResponse>>;
438
743
 
439
744
  declare const getPoolInfo: (chainId: ChainId, poolId: string) => Promise<MarketPool | undefined>;
440
745
 
@@ -581,7 +886,7 @@ declare const COMMON_LP_AMOUNT_DECIMALS = 18;
581
886
 
582
887
  interface MarketInfo {
583
888
  readonly marketId: string;
584
- readonly quoteToken: Address$1;
889
+ readonly quoteToken: Address$2;
585
890
  readonly oracleFeeUsd: bigint;
586
891
  readonly oracleRefundFeeUsd: bigint;
587
892
  readonly baseReserveRatio: number;
@@ -608,6 +913,16 @@ declare const bigintTradingGasPriceWithRatio: (chainId: ChainId) => Promise<{
608
913
  }>;
609
914
  declare const bigintAmountSlipperCalculator: (amount: bigint, slipper?: Number) => bigint;
610
915
 
916
+ declare const getTokenInfo: (chainId: number, tokenAddress: string, account?: string) => Promise<{
917
+ balance?: number | undefined;
918
+ address: string;
919
+ name: string;
920
+ symbol: string;
921
+ decimals: bigint;
922
+ icon: string;
923
+ totalSupply: number;
924
+ }>;
925
+
611
926
  interface WebSocketConfig extends Omit<Options, "maxReconnectionDelay" | "minReconnectionDelay"> {
612
927
  url: string;
613
928
  protocols?: string | string[];
@@ -971,6 +1286,37 @@ declare class Markets {
971
1286
  * ticker start
972
1287
  */
973
1288
  getTickerList(params: Omit<GetTickerDataParams, "chainId">): Promise<TickerDataItem[]>;
1289
+ /**
1290
+ * ticker end
1291
+ */
1292
+ /**
1293
+ * search by access token
1294
+ * (only for authenticated users)
1295
+ *
1296
+ */
1297
+ searchMarketAuth(params: SearchMarketParams): Promise<SearchResultResponse>;
1298
+ /**
1299
+ * search by unauthenticated users
1300
+ */
1301
+ searchMarket(params: SearchMarketParams): Promise<SearchResultResponse>;
1302
+ /**
1303
+ * get favorites list
1304
+ * (only for authenticated users)
1305
+ */
1306
+ getFavoritesList(params: FavoritesListParams): Promise<FavoritesListItem[]>;
1307
+ /**
1308
+ * favorite
1309
+ */
1310
+ addFavorite(params: AddFavoriteParams): Promise<null>;
1311
+ removeFavorite(params: RemoveFavoriteParams): Promise<null>;
1312
+ /**
1313
+ * base detail
1314
+ */
1315
+ getBaseDetail(params: GetBaseDetailParams): Promise<BaseDetailResponse>;
1316
+ /**
1317
+ * get market detail
1318
+ */
1319
+ getMarketDetail(params: GetMarketDetailParams): Promise<MarketDetailResponse>;
974
1320
  }
975
1321
 
976
1322
  declare class Position {
@@ -987,6 +1333,10 @@ declare class Position {
987
1333
  data: PositionType[];
988
1334
  message?: undefined;
989
1335
  }>;
1336
+ getPositionHistory(params: GetHistoryOrdersParams): Promise<{
1337
+ code: number;
1338
+ data: PositionHistoryItem[];
1339
+ }>;
990
1340
  /**
991
1341
  * @desc temp skip eip7702
992
1342
  * @todo adjustCollateral 调整保证金
@@ -1108,6 +1458,10 @@ declare class Order {
1108
1458
  data: PositionType[];
1109
1459
  message?: undefined;
1110
1460
  }>;
1461
+ getOrderHistory(params: GetHistoryOrdersParams): Promise<{
1462
+ code: number;
1463
+ data: HistoryOrderItem[];
1464
+ }>;
1111
1465
  }
1112
1466
 
1113
1467
  declare class Account {
@@ -1115,16 +1469,16 @@ declare class Account {
1115
1469
  private logger;
1116
1470
  private utils;
1117
1471
  constructor(configManager: ConfigManager, logger: Logger, utils: Utils);
1118
- /**
1119
- * get locked assets
1120
- */
1121
- getUserAssets(): Promise<any>;
1122
1472
  /**
1123
1473
  * get tradable amount
1124
1474
  */
1125
1475
  getTradableAmount({ poolId }: {
1126
1476
  poolId: string;
1127
1477
  }): Promise<any>;
1478
+ getTradeFlow(params: GetHistoryOrdersParams): Promise<{
1479
+ code: number;
1480
+ data: TradeFlowItem[];
1481
+ }>;
1128
1482
  }
1129
1483
 
1130
1484
  declare class MyxClient {
@@ -1149,4 +1503,4 @@ declare class MyxClient {
1149
1503
  constructor(options: MyxClientConfig);
1150
1504
  }
1151
1505
 
1152
- export { type AccessTokenRequest, type AccessTokenResponse$1 as AccessTokenResponse, type AccessTokenType, type Address, type ApiResponse, type BaseResponse, COMMON_LP_AMOUNT_DECIMALS, COMMON_PRICE_DECIMALS, type DashboardType, Direction, ErrorCode, type GetKlineDataParams, type GetPoolLevelConfigParams, type GetTickerDataParams, HttpKlineIntervalEnum, type KlineDataItemType, type KlineDataResponse, type KlineResolution, type LevelConfig, Market, type MarketInfoMap, type MarketPool, type MarketPoolResponse, MarketPoolState, MyxClient, type MyxClientConfig, type MyxSubscriptionOptions, type NetWorkFee, type ObjectType, type OnKlineCallback, type OnOrderCallback, type OnPositionCallback, type OnTickersAllCallback, type OnTickersCallback, OperationType, OracleType, type Order$1 as Order, OrderStatus, OrderType, type PlaceOrderParams, type PoolLevelConfig, type PoolOpenOrder, type PoolOpenOrdersResponse, type PoolResponse, type Position$1 as Position, type PositionResponse, type PositionTpSlOrderParams, type PositionType, type PriceResponse, type PriceType, type StatDashBoardResponse, type TickerDataItem, type TickersDataResponse, TimeInForce, type TradingResult, TriggerType, type UpdateOrderTpSlParams, approve, index$2 as base, bigintAmountSlipperCalculator, bigintTradingGasPriceWithRatio, bigintTradingGasToRatioCalculator, getAllTickers, getAllowanceApproved, getBalanceOf, getKlineData, getKlineLatestBar, getOraclePrice, getOrders, getPoolDetail, getPoolLevelConfig, getPoolOpenOrders, getPools, getPositions, getPriceData, getPricesData, getTickerData, index as market, index$3 as pool, index$1 as quote };
1506
+ export { type AccessTokenRequest, type AccessTokenResponse$1 as AccessTokenResponse, type AccessTokenType, type AddFavoriteParams, type Address$1 as Address, type ApiResponse, type BaseDetailResponse, type BaseResponse, COMMON_LP_AMOUNT_DECIMALS, COMMON_PRICE_DECIMALS, ChainId, type ChainIdRequest, type DashboardType, Direction, DirectionEnum, ErrorCode, ExecTypeEnum, type FavoritesListItem, type FavoritesListParams, type FavoritesTimeInterval, type FavoritesType, type GetBaseDetailParams, type GetHistoryOrdersParams, type GetKlineDataParams, type GetMarketDetailParams, type GetPoolLevelConfigParams, type GetTickerDataParams, type HistoryOrderItem, HttpKlineIntervalEnum, type KlineDataItemType, type KlineDataResponse, type KlineResolution, type LevelConfig, Market, MarketCapType, type MarketDetailResponse, type MarketInfo, type MarketInfoMap, type MarketPool, type MarketPoolResponse, MarketPoolState, MarketType, MyxClient, type MyxClientConfig, type MyxSubscriptionOptions, type NetWorkFee, type ObjectType, type OnKlineCallback, type OnOrderCallback, type OnPositionCallback, type OnTickersAllCallback, type OnTickersCallback, OperationEnum, OperationType, OracleType, type Order$1 as Order, OrderStatus, OrderStatusEnum, OrderType, OrderTypeEnum, type PlaceOrderParams, type PoolLevelConfig, type PoolOpenOrder, type PoolOpenOrdersResponse, type PoolResponse, type Position$1 as Position, type PositionHistoryItem, type PositionResponse, type PositionTpSlOrderParams, type PositionType, type PriceResponse, type PriceType, type RemoveFavoriteParams, type SearchMarketParams, type SearchResultContractItem, type SearchResultCookItem, type SearchResultEarnItem, type SearchResultResponse, SearchSecondTypeEnum, SearchTypeEnum, type StatDashBoardResponse, type TickerDataItem, type TickersDataResponse, TimeInForce, type TradeFlowItem, type TradingResult, TriggerType, TriggerTypeEnum, type UpdateOrderTpSlParams, addFavorite, approve, index$2 as base, baseUrl, bigintAmountSlipperCalculator, bigintTradingGasPriceWithRatio, bigintTradingGasToRatioCalculator, getAllTickers, getAllowanceApproved, getBalanceOf, getBaseDetail, getFavoritesList, getHistoryOrders, getKlineData, getKlineLatestBar, getMarketDetail, getOraclePrice, getOrders, getPoolDetail, getPoolLevelConfig, getPoolOpenOrders, getPools, getPositionHistory, getPositions, getPriceData, getPricesData, getTickerData, getTokenInfo, getTradeFlow, index as market, index$3 as pool, index$1 as quote, removeFavorite, searchMarket, searchMarketAuth };