@myx-trade/sdk 0.1.158 → 0.1.161

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
@@ -1,4 +1,5 @@
1
- import { AddressLike, Signer, ethers } from 'ethers';
1
+ import * as ethers from 'ethers';
2
+ import { AddressLike, Signer, ethers as ethers$1 } from 'ethers';
2
3
  export { formatUnits, parseUnits } from 'ethers';
3
4
  import { Options, Event } from 'reconnecting-websocket';
4
5
  import { WalletClient } from 'viem';
@@ -48,49 +49,49 @@ interface CancelTpSLParams {
48
49
  orderId: string;
49
50
  }
50
51
 
51
- declare const createPool: ({ chainId, baseToken, marketId }: CreatePoolRequest) => Promise<any>;
52
+ declare const createPool: ({ chainId, baseToken, marketId }: CreatePoolRequest) => Promise<string | undefined>;
52
53
 
53
- declare const getMarketPoolId: ({ chainId, baseToken, marketId, }: CreatePoolRequest) => Promise<any>;
54
- declare const getMarketPools: (chainId: ChainId) => Promise<any>;
54
+ declare const getMarketPoolId: ({ chainId, baseToken, marketId, }: CreatePoolRequest) => Promise<string | undefined>;
55
+ declare const getMarketPools: (chainId: ChainId) => Promise<string[]>;
55
56
  declare const getPoolInfo$1: (chainId: ChainId, poolId: string, marketPrice?: bigint) => Promise<{
56
57
  quotePool: {
57
- poolToken: any;
58
- exchangeRate: any;
59
- poolTokenPrice: any;
60
- poolTokenSupply: any;
58
+ poolToken: string;
59
+ exchangeRate: bigint;
60
+ poolTokenPrice: bigint;
61
+ poolTokenSupply: bigint;
61
62
  };
62
63
  basePool: {
63
- poolToken: any;
64
- exchangeRate: any;
65
- poolTokenPrice: any;
66
- poolTokenSupply: any;
64
+ poolToken: string;
65
+ exchangeRate: bigint;
66
+ poolTokenPrice: bigint;
67
+ poolTokenSupply: bigint;
67
68
  };
68
69
  reserveInfo: {
69
- baseTotalAmount: any;
70
- baseReservedAmount: any;
71
- quoteTotalAmount: any;
72
- quoteReservedAmount: any;
70
+ baseTotalAmount: bigint;
71
+ baseReservedAmount: bigint;
72
+ quoteTotalAmount: bigint;
73
+ quoteReservedAmount: bigint;
73
74
  };
74
75
  fundingInfo: {
75
- nextFundingRate: any;
76
- lastFundingFeeTracker: any;
77
- nextEpochTime: any;
76
+ nextFundingRate: bigint;
77
+ lastFundingFeeTracker: bigint;
78
+ nextEpochTime: bigint;
78
79
  };
79
80
  ioTracker: {
80
- tracker: any;
81
- longSize: any;
82
- shortSize: any;
83
- poolEntryPrice: any;
81
+ tracker: bigint;
82
+ longSize: bigint;
83
+ shortSize: bigint;
84
+ poolEntryPrice: bigint;
84
85
  };
85
86
  }>;
86
87
 
87
- declare const getUserGenesisShare: (chainId: ChainId, tokenAddress: string, account: string) => Promise<any>;
88
+ declare const getUserGenesisShare: (chainId: ChainId, tokenAddress: string, account: string) => Promise<bigint>;
88
89
 
89
- declare const addTpSl: (params: AddTpSLParams) => Promise<any>;
90
+ declare const addTpSl: (params: AddTpSLParams) => Promise<ethers.ContractTransactionReceipt | null>;
90
91
 
91
- declare const cancelTpSl: (params: CancelTpSLParams) => Promise<any>;
92
+ declare const cancelTpSl: (params: CancelTpSLParams) => Promise<ethers.ContractTransactionReceipt | null>;
92
93
 
93
- declare const reprime: (chainId: ChainId, poolId: string, marketId: string) => Promise<any>;
94
+ declare const reprime: (chainId: ChainId, poolId: string, marketId: string) => Promise<ethers.ContractTransactionReceipt | null>;
94
95
 
95
96
  /**
96
97
  * Trading related types and enums
@@ -887,21 +888,21 @@ interface PreviewWithdrawDataParams {
887
888
  amount: string | number;
888
889
  }
889
890
 
890
- declare const claimBasePoolRebate: (params: ClaimParams) => Promise<any>;
891
- declare const claimBasePoolRebates: (params: ClaimRebatesParams) => Promise<any>;
891
+ declare const claimBasePoolRebate: (params: ClaimParams) => Promise<ethers.ContractTransactionResponse | undefined>;
892
+ declare const claimBasePoolRebates: (params: ClaimRebatesParams) => Promise<ethers.ContractTransactionResponse | undefined>;
892
893
 
893
- declare const deposit$1: (params: Deposit) => Promise<any>;
894
+ declare const deposit$1: (params: Deposit) => Promise<ethers.ContractTransactionResponse | undefined>;
894
895
 
895
- declare const withdraw$1: (params: WithdrawParams) => Promise<any>;
896
+ declare const withdraw$1: (params: WithdrawParams) => Promise<ethers.ContractTransactionReceipt | null | undefined>;
896
897
 
897
- declare const getRewards$1: (params: RewardsParams) => Promise<any>;
898
+ declare const getRewards$1: (params: RewardsParams) => Promise<bigint | undefined>;
898
899
 
899
900
  declare const previewUserWithdrawData: ({ chainId, account, poolId, amount }: PreviewWithdrawDataParams) => Promise<{
900
- baseAmountOut: any;
901
- rebateAmount: any;
901
+ baseAmountOut: bigint;
902
+ rebateAmount: bigint;
902
903
  } | undefined>;
903
904
 
904
- declare const getLpPrice$1: (chainId: ChainId, poolId: string) => Promise<any>;
905
+ declare const getLpPrice$1: (chainId: ChainId, poolId: string) => Promise<bigint | undefined>;
905
906
 
906
907
  declare const index$2_claimBasePoolRebate: typeof claimBasePoolRebate;
907
908
  declare const index$2_claimBasePoolRebates: typeof claimBasePoolRebates;
@@ -910,18 +911,18 @@ declare namespace index$2 {
910
911
  export { index$2_claimBasePoolRebate as claimBasePoolRebate, index$2_claimBasePoolRebates as claimBasePoolRebates, deposit$1 as deposit, getLpPrice$1 as getLpPrice, getRewards$1 as getRewards, index$2_previewUserWithdrawData as previewUserWithdrawData, withdraw$1 as withdraw };
911
912
  }
912
913
 
913
- declare const deposit: (params: Deposit) => Promise<any>;
914
+ declare const deposit: (params: Deposit) => Promise<ethers.ContractTransactionResponse | undefined>;
914
915
 
915
- declare const withdraw: (params: WithdrawParams) => Promise<any>;
916
+ declare const withdraw: (params: WithdrawParams) => Promise<ethers.ContractTransactionReceipt | null | undefined>;
916
917
 
917
- declare const transfer: (chainId: ChainId, fromPoolId: string, toPoolId: string, amount: number) => Promise<any>;
918
+ declare const transfer: (chainId: ChainId, fromPoolId: string, toPoolId: string, amount: number) => Promise<ethers.ContractTransactionResponse | null>;
918
919
 
919
- declare const getRewards: (params: RewardsParams) => Promise<any>;
920
+ declare const getRewards: (params: RewardsParams) => Promise<bigint | undefined>;
920
921
 
921
- declare const claimQuotePoolRebate: (params: ClaimParams) => Promise<any>;
922
- declare const claimQuotePoolRebates: (params: ClaimRebatesParams) => Promise<any>;
922
+ declare const claimQuotePoolRebate: (params: ClaimParams) => Promise<ethers.ContractTransactionResponse | undefined>;
923
+ declare const claimQuotePoolRebates: (params: ClaimRebatesParams) => Promise<ethers.ContractTransactionResponse | undefined>;
923
924
 
924
- declare const getLpPrice: (chainId: ChainId, poolId: string) => Promise<any>;
925
+ declare const getLpPrice: (chainId: ChainId, poolId: string) => Promise<bigint | undefined>;
925
926
 
926
927
  declare const index$1_claimQuotePoolRebate: typeof claimQuotePoolRebate;
927
928
  declare const index$1_claimQuotePoolRebates: typeof claimQuotePoolRebates;
@@ -934,9 +935,16 @@ declare namespace index$1 {
934
935
  export { index$1_claimQuotePoolRebate as claimQuotePoolRebate, index$1_claimQuotePoolRebates as claimQuotePoolRebates, index$1_deposit as deposit, index$1_getLpPrice as getLpPrice, index$1_getRewards as getRewards, index$1_transfer as transfer, index$1_withdraw as withdraw };
935
936
  }
936
937
 
937
- declare const getMarket: (chainId: ChainId, marketId: string) => Promise<any>;
938
+ declare const getMarket: (chainId: ChainId, marketId: string) => Promise<([string, bigint, bigint, bigint, bigint, bigint] & {
939
+ quoteToken: string;
940
+ baseReserveRatio: bigint;
941
+ quoteReserveRatio: bigint;
942
+ oracleFeeUsd: bigint;
943
+ oracleRefundFeeUsd: bigint;
944
+ poolPrimeThreshold: bigint;
945
+ }) | undefined>;
938
946
 
939
- declare const getOracleFee: (chainId: ChainId, marketId: string) => Promise<any>;
947
+ declare const getOracleFee: (chainId: ChainId, marketId: string) => Promise<bigint | undefined>;
940
948
 
941
949
  declare const index_getMarket: typeof getMarket;
942
950
  declare const index_getOracleFee: typeof getOracleFee;
@@ -979,9 +987,9 @@ declare const bigintAmountSlipperCalculator: (amount: bigint, slipper?: Number)
979
987
  declare const getTokenInfo: (chainId: number, tokenAddress: string, account?: string) => Promise<{
980
988
  balance?: number | undefined;
981
989
  address: string;
982
- name: any;
983
- symbol: any;
984
- decimals: any;
990
+ name: string;
991
+ symbol: string;
992
+ decimals: bigint;
985
993
  icon: string;
986
994
  totalSupply: number;
987
995
  }>;
@@ -1195,7 +1203,7 @@ interface MyxClientConfig {
1195
1203
  signer?: Signer;
1196
1204
  seamlessAccount?: {
1197
1205
  masterAddress: string;
1198
- wallet: ethers.Wallet | null;
1206
+ wallet: ethers$1.Wallet | null;
1199
1207
  authorized: boolean;
1200
1208
  };
1201
1209
  walletClient?: WalletClient;
@@ -1215,7 +1223,7 @@ declare class ConfigManager {
1215
1223
  clear(): void;
1216
1224
  startSeamlessMode(open: boolean): MyxClientConfig;
1217
1225
  updateSeamlessWallet({ wallet, authorized, masterAddress }: {
1218
- wallet?: ethers.Wallet;
1226
+ wallet?: ethers$1.Wallet;
1219
1227
  authorized?: boolean;
1220
1228
  masterAddress?: string;
1221
1229
  }): void;
@@ -1323,7 +1331,7 @@ declare class Utils {
1323
1331
  quoteAddress: string;
1324
1332
  amount?: string;
1325
1333
  spenderAddress?: string;
1326
- signer?: ethers.Signer;
1334
+ signer?: ethers$1.Signer;
1327
1335
  }): Promise<{
1328
1336
  code: number;
1329
1337
  message: any;
@@ -1366,7 +1374,68 @@ declare class Utils {
1366
1374
  marketPrice: string;
1367
1375
  }): Promise<{
1368
1376
  code: number;
1369
- data: any;
1377
+ data: [[string, bigint, bigint, bigint] & {
1378
+ poolToken: string;
1379
+ exchangeRate: bigint;
1380
+ poolTokenPrice: bigint;
1381
+ poolTokenSupply: bigint;
1382
+ }, [string, bigint, bigint, bigint] & {
1383
+ poolToken: string;
1384
+ exchangeRate: bigint;
1385
+ poolTokenPrice: bigint;
1386
+ poolTokenSupply: bigint;
1387
+ }, [bigint, bigint, bigint, bigint] & {
1388
+ baseTotalAmount: bigint;
1389
+ baseReservedAmount: bigint;
1390
+ quoteTotalAmount: bigint;
1391
+ quoteReservedAmount: bigint;
1392
+ }, [bigint, bigint, bigint] & {
1393
+ nextFundingRate: bigint;
1394
+ lastFundingFeeTracker: bigint;
1395
+ nextEpochTime: bigint;
1396
+ }, [bigint, bigint, bigint, bigint] & {
1397
+ tracker: bigint;
1398
+ longSize: bigint;
1399
+ shortSize: bigint;
1400
+ poolEntryPrice: bigint;
1401
+ }, [bigint, bigint] & {
1402
+ windowCaps: bigint;
1403
+ openInterest: bigint;
1404
+ }] & {
1405
+ basePool: [string, bigint, bigint, bigint] & {
1406
+ poolToken: string;
1407
+ exchangeRate: bigint;
1408
+ poolTokenPrice: bigint;
1409
+ poolTokenSupply: bigint;
1410
+ };
1411
+ quotePool: [string, bigint, bigint, bigint] & {
1412
+ poolToken: string;
1413
+ exchangeRate: bigint;
1414
+ poolTokenPrice: bigint;
1415
+ poolTokenSupply: bigint;
1416
+ };
1417
+ reserveInfo: [bigint, bigint, bigint, bigint] & {
1418
+ baseTotalAmount: bigint;
1419
+ baseReservedAmount: bigint;
1420
+ quoteTotalAmount: bigint;
1421
+ quoteReservedAmount: bigint;
1422
+ };
1423
+ fundingInfo: [bigint, bigint, bigint] & {
1424
+ nextFundingRate: bigint;
1425
+ lastFundingFeeTracker: bigint;
1426
+ nextEpochTime: bigint;
1427
+ };
1428
+ oi: [bigint, bigint, bigint, bigint] & {
1429
+ tracker: bigint;
1430
+ longSize: bigint;
1431
+ shortSize: bigint;
1432
+ poolEntryPrice: bigint;
1433
+ };
1434
+ liquidityInfo: [bigint, bigint] & {
1435
+ windowCaps: bigint;
1436
+ openInterest: bigint;
1437
+ };
1438
+ };
1370
1439
  message?: undefined;
1371
1440
  } | {
1372
1441
  code: number;
@@ -1520,9 +1589,9 @@ declare class Seamless {
1520
1589
  private utils;
1521
1590
  private account;
1522
1591
  constructor(configManager: ConfigManager, logger: Logger, utils: Utils, account: Account);
1523
- onCheckRelayer(account: string, relayer: string, chainId: number): Promise<any>;
1592
+ onCheckRelayer(account: string, relayer: string, chainId: number): Promise<boolean>;
1524
1593
  getUSDPermitParams(deadline: number, chainId: number): Promise<{
1525
- token: string | ethers.Addressable;
1594
+ token: string | ethers$1.Addressable;
1526
1595
  owner: string;
1527
1596
  spender: string;
1528
1597
  value: bigint;
@@ -1539,7 +1608,7 @@ declare class Seamless {
1539
1608
  deadline: number;
1540
1609
  data: string;
1541
1610
  nonce: string;
1542
- }, chainId: number, provider?: ethers.Signer): Promise<ApiResponse<any>>;
1611
+ }, chainId: number, provider?: ethers$1.Signer): Promise<ApiResponse<any>>;
1543
1612
  authorizeSeamlessAccount({ approve, seamlessAddress, chainId }: {
1544
1613
  approve: boolean;
1545
1614
  seamlessAddress: string;
@@ -1561,7 +1630,7 @@ declare class Seamless {
1561
1630
  data: {
1562
1631
  masterAddress: string;
1563
1632
  seamlessAccount: string;
1564
- authorized: any;
1633
+ authorized: boolean;
1565
1634
  };
1566
1635
  }>;
1567
1636
  exportSeamlessPrivateKey({ password, apiKey }: {
@@ -1580,9 +1649,9 @@ declare class Seamless {
1580
1649
  }): Promise<{
1581
1650
  code: number;
1582
1651
  data: {
1583
- masterAddress: any;
1652
+ masterAddress: string;
1584
1653
  seamlessAccount: string;
1585
- authorized: any;
1654
+ authorized: boolean;
1586
1655
  apiKey: string;
1587
1656
  };
1588
1657
  }>;
@@ -1602,7 +1671,7 @@ declare class Seamless {
1602
1671
  data: {
1603
1672
  masterAddress: string;
1604
1673
  seamlessAccount: string;
1605
- authorized: any;
1674
+ authorized: boolean;
1606
1675
  apiKey: string;
1607
1676
  };
1608
1677
  message?: undefined;
@@ -1689,13 +1758,13 @@ declare class Order {
1689
1758
  data: {
1690
1759
  success: boolean;
1691
1760
  orderId: string | null;
1692
- transactionHash: any;
1693
- blockNumber: any;
1694
- gasUsed: any;
1761
+ transactionHash: string;
1762
+ blockNumber: number | undefined;
1763
+ gasUsed: string | undefined;
1695
1764
  status: string;
1696
1765
  confirmations: number;
1697
1766
  timestamp: number;
1698
- receipt: any;
1767
+ receipt: ethers$1.ContractTransactionReceipt | null;
1699
1768
  };
1700
1769
  } | {
1701
1770
  code: number;
@@ -1717,13 +1786,13 @@ declare class Order {
1717
1786
  code: number;
1718
1787
  message: string;
1719
1788
  data: string | null;
1720
- transactionHash: any;
1721
- blockNumber: any;
1722
- gasUsed: any;
1789
+ transactionHash: string;
1790
+ blockNumber: number | undefined;
1791
+ gasUsed: string | undefined;
1723
1792
  status: string;
1724
1793
  confirmations: number;
1725
1794
  timestamp: number;
1726
- receipt: any;
1795
+ receipt: ethers$1.ContractTransactionReceipt | null;
1727
1796
  } | {
1728
1797
  code: number;
1729
1798
  message: any;
@@ -1746,13 +1815,13 @@ declare class Order {
1746
1815
  data: {
1747
1816
  success: boolean;
1748
1817
  orderId: string | null;
1749
- transactionHash: any;
1750
- blockNumber: any;
1751
- gasUsed: any;
1818
+ transactionHash: string;
1819
+ blockNumber: number | undefined;
1820
+ gasUsed: string | undefined;
1752
1821
  status: string;
1753
1822
  confirmations: number;
1754
1823
  timestamp: number;
1755
- receipt: any;
1824
+ receipt: ethers$1.ContractTransactionReceipt | null;
1756
1825
  };
1757
1826
  } | {
1758
1827
  code: number;
@@ -1769,13 +1838,13 @@ declare class Order {
1769
1838
  data: {
1770
1839
  success: boolean;
1771
1840
  orderId: string | null;
1772
- transactionHash: any;
1773
- blockNumber: any;
1774
- gasUsed: any;
1841
+ transactionHash: string;
1842
+ blockNumber: number | undefined;
1843
+ gasUsed: string | undefined;
1775
1844
  status: string;
1776
1845
  confirmations: number;
1777
1846
  timestamp: number;
1778
- receipt: any;
1847
+ receipt: ethers$1.ContractTransactionReceipt | null;
1779
1848
  };
1780
1849
  } | {
1781
1850
  code: number;
@@ -1801,7 +1870,7 @@ declare class Order {
1801
1870
  }>;
1802
1871
  updateOrderTpSl(params: UpdateOrderParams, quoteAddress: string, chainId: number): Promise<{
1803
1872
  code: number;
1804
- data: any;
1873
+ data: ethers$1.ContractTransactionReceipt | null;
1805
1874
  message: string;
1806
1875
  } | {
1807
1876
  code: number;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { AddressLike, Signer, ethers } from 'ethers';
1
+ import * as ethers from 'ethers';
2
+ import { AddressLike, Signer, ethers as ethers$1 } from 'ethers';
2
3
  export { formatUnits, parseUnits } from 'ethers';
3
4
  import { Options, Event } from 'reconnecting-websocket';
4
5
  import { WalletClient } from 'viem';
@@ -48,49 +49,49 @@ interface CancelTpSLParams {
48
49
  orderId: string;
49
50
  }
50
51
 
51
- declare const createPool: ({ chainId, baseToken, marketId }: CreatePoolRequest) => Promise<any>;
52
+ declare const createPool: ({ chainId, baseToken, marketId }: CreatePoolRequest) => Promise<string | undefined>;
52
53
 
53
- declare const getMarketPoolId: ({ chainId, baseToken, marketId, }: CreatePoolRequest) => Promise<any>;
54
- declare const getMarketPools: (chainId: ChainId) => Promise<any>;
54
+ declare const getMarketPoolId: ({ chainId, baseToken, marketId, }: CreatePoolRequest) => Promise<string | undefined>;
55
+ declare const getMarketPools: (chainId: ChainId) => Promise<string[]>;
55
56
  declare const getPoolInfo$1: (chainId: ChainId, poolId: string, marketPrice?: bigint) => Promise<{
56
57
  quotePool: {
57
- poolToken: any;
58
- exchangeRate: any;
59
- poolTokenPrice: any;
60
- poolTokenSupply: any;
58
+ poolToken: string;
59
+ exchangeRate: bigint;
60
+ poolTokenPrice: bigint;
61
+ poolTokenSupply: bigint;
61
62
  };
62
63
  basePool: {
63
- poolToken: any;
64
- exchangeRate: any;
65
- poolTokenPrice: any;
66
- poolTokenSupply: any;
64
+ poolToken: string;
65
+ exchangeRate: bigint;
66
+ poolTokenPrice: bigint;
67
+ poolTokenSupply: bigint;
67
68
  };
68
69
  reserveInfo: {
69
- baseTotalAmount: any;
70
- baseReservedAmount: any;
71
- quoteTotalAmount: any;
72
- quoteReservedAmount: any;
70
+ baseTotalAmount: bigint;
71
+ baseReservedAmount: bigint;
72
+ quoteTotalAmount: bigint;
73
+ quoteReservedAmount: bigint;
73
74
  };
74
75
  fundingInfo: {
75
- nextFundingRate: any;
76
- lastFundingFeeTracker: any;
77
- nextEpochTime: any;
76
+ nextFundingRate: bigint;
77
+ lastFundingFeeTracker: bigint;
78
+ nextEpochTime: bigint;
78
79
  };
79
80
  ioTracker: {
80
- tracker: any;
81
- longSize: any;
82
- shortSize: any;
83
- poolEntryPrice: any;
81
+ tracker: bigint;
82
+ longSize: bigint;
83
+ shortSize: bigint;
84
+ poolEntryPrice: bigint;
84
85
  };
85
86
  }>;
86
87
 
87
- declare const getUserGenesisShare: (chainId: ChainId, tokenAddress: string, account: string) => Promise<any>;
88
+ declare const getUserGenesisShare: (chainId: ChainId, tokenAddress: string, account: string) => Promise<bigint>;
88
89
 
89
- declare const addTpSl: (params: AddTpSLParams) => Promise<any>;
90
+ declare const addTpSl: (params: AddTpSLParams) => Promise<ethers.ContractTransactionReceipt | null>;
90
91
 
91
- declare const cancelTpSl: (params: CancelTpSLParams) => Promise<any>;
92
+ declare const cancelTpSl: (params: CancelTpSLParams) => Promise<ethers.ContractTransactionReceipt | null>;
92
93
 
93
- declare const reprime: (chainId: ChainId, poolId: string, marketId: string) => Promise<any>;
94
+ declare const reprime: (chainId: ChainId, poolId: string, marketId: string) => Promise<ethers.ContractTransactionReceipt | null>;
94
95
 
95
96
  /**
96
97
  * Trading related types and enums
@@ -887,21 +888,21 @@ interface PreviewWithdrawDataParams {
887
888
  amount: string | number;
888
889
  }
889
890
 
890
- declare const claimBasePoolRebate: (params: ClaimParams) => Promise<any>;
891
- declare const claimBasePoolRebates: (params: ClaimRebatesParams) => Promise<any>;
891
+ declare const claimBasePoolRebate: (params: ClaimParams) => Promise<ethers.ContractTransactionResponse | undefined>;
892
+ declare const claimBasePoolRebates: (params: ClaimRebatesParams) => Promise<ethers.ContractTransactionResponse | undefined>;
892
893
 
893
- declare const deposit$1: (params: Deposit) => Promise<any>;
894
+ declare const deposit$1: (params: Deposit) => Promise<ethers.ContractTransactionResponse | undefined>;
894
895
 
895
- declare const withdraw$1: (params: WithdrawParams) => Promise<any>;
896
+ declare const withdraw$1: (params: WithdrawParams) => Promise<ethers.ContractTransactionReceipt | null | undefined>;
896
897
 
897
- declare const getRewards$1: (params: RewardsParams) => Promise<any>;
898
+ declare const getRewards$1: (params: RewardsParams) => Promise<bigint | undefined>;
898
899
 
899
900
  declare const previewUserWithdrawData: ({ chainId, account, poolId, amount }: PreviewWithdrawDataParams) => Promise<{
900
- baseAmountOut: any;
901
- rebateAmount: any;
901
+ baseAmountOut: bigint;
902
+ rebateAmount: bigint;
902
903
  } | undefined>;
903
904
 
904
- declare const getLpPrice$1: (chainId: ChainId, poolId: string) => Promise<any>;
905
+ declare const getLpPrice$1: (chainId: ChainId, poolId: string) => Promise<bigint | undefined>;
905
906
 
906
907
  declare const index$2_claimBasePoolRebate: typeof claimBasePoolRebate;
907
908
  declare const index$2_claimBasePoolRebates: typeof claimBasePoolRebates;
@@ -910,18 +911,18 @@ declare namespace index$2 {
910
911
  export { index$2_claimBasePoolRebate as claimBasePoolRebate, index$2_claimBasePoolRebates as claimBasePoolRebates, deposit$1 as deposit, getLpPrice$1 as getLpPrice, getRewards$1 as getRewards, index$2_previewUserWithdrawData as previewUserWithdrawData, withdraw$1 as withdraw };
911
912
  }
912
913
 
913
- declare const deposit: (params: Deposit) => Promise<any>;
914
+ declare const deposit: (params: Deposit) => Promise<ethers.ContractTransactionResponse | undefined>;
914
915
 
915
- declare const withdraw: (params: WithdrawParams) => Promise<any>;
916
+ declare const withdraw: (params: WithdrawParams) => Promise<ethers.ContractTransactionReceipt | null | undefined>;
916
917
 
917
- declare const transfer: (chainId: ChainId, fromPoolId: string, toPoolId: string, amount: number) => Promise<any>;
918
+ declare const transfer: (chainId: ChainId, fromPoolId: string, toPoolId: string, amount: number) => Promise<ethers.ContractTransactionResponse | null>;
918
919
 
919
- declare const getRewards: (params: RewardsParams) => Promise<any>;
920
+ declare const getRewards: (params: RewardsParams) => Promise<bigint | undefined>;
920
921
 
921
- declare const claimQuotePoolRebate: (params: ClaimParams) => Promise<any>;
922
- declare const claimQuotePoolRebates: (params: ClaimRebatesParams) => Promise<any>;
922
+ declare const claimQuotePoolRebate: (params: ClaimParams) => Promise<ethers.ContractTransactionResponse | undefined>;
923
+ declare const claimQuotePoolRebates: (params: ClaimRebatesParams) => Promise<ethers.ContractTransactionResponse | undefined>;
923
924
 
924
- declare const getLpPrice: (chainId: ChainId, poolId: string) => Promise<any>;
925
+ declare const getLpPrice: (chainId: ChainId, poolId: string) => Promise<bigint | undefined>;
925
926
 
926
927
  declare const index$1_claimQuotePoolRebate: typeof claimQuotePoolRebate;
927
928
  declare const index$1_claimQuotePoolRebates: typeof claimQuotePoolRebates;
@@ -934,9 +935,16 @@ declare namespace index$1 {
934
935
  export { index$1_claimQuotePoolRebate as claimQuotePoolRebate, index$1_claimQuotePoolRebates as claimQuotePoolRebates, index$1_deposit as deposit, index$1_getLpPrice as getLpPrice, index$1_getRewards as getRewards, index$1_transfer as transfer, index$1_withdraw as withdraw };
935
936
  }
936
937
 
937
- declare const getMarket: (chainId: ChainId, marketId: string) => Promise<any>;
938
+ declare const getMarket: (chainId: ChainId, marketId: string) => Promise<([string, bigint, bigint, bigint, bigint, bigint] & {
939
+ quoteToken: string;
940
+ baseReserveRatio: bigint;
941
+ quoteReserveRatio: bigint;
942
+ oracleFeeUsd: bigint;
943
+ oracleRefundFeeUsd: bigint;
944
+ poolPrimeThreshold: bigint;
945
+ }) | undefined>;
938
946
 
939
- declare const getOracleFee: (chainId: ChainId, marketId: string) => Promise<any>;
947
+ declare const getOracleFee: (chainId: ChainId, marketId: string) => Promise<bigint | undefined>;
940
948
 
941
949
  declare const index_getMarket: typeof getMarket;
942
950
  declare const index_getOracleFee: typeof getOracleFee;
@@ -979,9 +987,9 @@ declare const bigintAmountSlipperCalculator: (amount: bigint, slipper?: Number)
979
987
  declare const getTokenInfo: (chainId: number, tokenAddress: string, account?: string) => Promise<{
980
988
  balance?: number | undefined;
981
989
  address: string;
982
- name: any;
983
- symbol: any;
984
- decimals: any;
990
+ name: string;
991
+ symbol: string;
992
+ decimals: bigint;
985
993
  icon: string;
986
994
  totalSupply: number;
987
995
  }>;
@@ -1195,7 +1203,7 @@ interface MyxClientConfig {
1195
1203
  signer?: Signer;
1196
1204
  seamlessAccount?: {
1197
1205
  masterAddress: string;
1198
- wallet: ethers.Wallet | null;
1206
+ wallet: ethers$1.Wallet | null;
1199
1207
  authorized: boolean;
1200
1208
  };
1201
1209
  walletClient?: WalletClient;
@@ -1215,7 +1223,7 @@ declare class ConfigManager {
1215
1223
  clear(): void;
1216
1224
  startSeamlessMode(open: boolean): MyxClientConfig;
1217
1225
  updateSeamlessWallet({ wallet, authorized, masterAddress }: {
1218
- wallet?: ethers.Wallet;
1226
+ wallet?: ethers$1.Wallet;
1219
1227
  authorized?: boolean;
1220
1228
  masterAddress?: string;
1221
1229
  }): void;
@@ -1323,7 +1331,7 @@ declare class Utils {
1323
1331
  quoteAddress: string;
1324
1332
  amount?: string;
1325
1333
  spenderAddress?: string;
1326
- signer?: ethers.Signer;
1334
+ signer?: ethers$1.Signer;
1327
1335
  }): Promise<{
1328
1336
  code: number;
1329
1337
  message: any;
@@ -1366,7 +1374,68 @@ declare class Utils {
1366
1374
  marketPrice: string;
1367
1375
  }): Promise<{
1368
1376
  code: number;
1369
- data: any;
1377
+ data: [[string, bigint, bigint, bigint] & {
1378
+ poolToken: string;
1379
+ exchangeRate: bigint;
1380
+ poolTokenPrice: bigint;
1381
+ poolTokenSupply: bigint;
1382
+ }, [string, bigint, bigint, bigint] & {
1383
+ poolToken: string;
1384
+ exchangeRate: bigint;
1385
+ poolTokenPrice: bigint;
1386
+ poolTokenSupply: bigint;
1387
+ }, [bigint, bigint, bigint, bigint] & {
1388
+ baseTotalAmount: bigint;
1389
+ baseReservedAmount: bigint;
1390
+ quoteTotalAmount: bigint;
1391
+ quoteReservedAmount: bigint;
1392
+ }, [bigint, bigint, bigint] & {
1393
+ nextFundingRate: bigint;
1394
+ lastFundingFeeTracker: bigint;
1395
+ nextEpochTime: bigint;
1396
+ }, [bigint, bigint, bigint, bigint] & {
1397
+ tracker: bigint;
1398
+ longSize: bigint;
1399
+ shortSize: bigint;
1400
+ poolEntryPrice: bigint;
1401
+ }, [bigint, bigint] & {
1402
+ windowCaps: bigint;
1403
+ openInterest: bigint;
1404
+ }] & {
1405
+ basePool: [string, bigint, bigint, bigint] & {
1406
+ poolToken: string;
1407
+ exchangeRate: bigint;
1408
+ poolTokenPrice: bigint;
1409
+ poolTokenSupply: bigint;
1410
+ };
1411
+ quotePool: [string, bigint, bigint, bigint] & {
1412
+ poolToken: string;
1413
+ exchangeRate: bigint;
1414
+ poolTokenPrice: bigint;
1415
+ poolTokenSupply: bigint;
1416
+ };
1417
+ reserveInfo: [bigint, bigint, bigint, bigint] & {
1418
+ baseTotalAmount: bigint;
1419
+ baseReservedAmount: bigint;
1420
+ quoteTotalAmount: bigint;
1421
+ quoteReservedAmount: bigint;
1422
+ };
1423
+ fundingInfo: [bigint, bigint, bigint] & {
1424
+ nextFundingRate: bigint;
1425
+ lastFundingFeeTracker: bigint;
1426
+ nextEpochTime: bigint;
1427
+ };
1428
+ oi: [bigint, bigint, bigint, bigint] & {
1429
+ tracker: bigint;
1430
+ longSize: bigint;
1431
+ shortSize: bigint;
1432
+ poolEntryPrice: bigint;
1433
+ };
1434
+ liquidityInfo: [bigint, bigint] & {
1435
+ windowCaps: bigint;
1436
+ openInterest: bigint;
1437
+ };
1438
+ };
1370
1439
  message?: undefined;
1371
1440
  } | {
1372
1441
  code: number;
@@ -1520,9 +1589,9 @@ declare class Seamless {
1520
1589
  private utils;
1521
1590
  private account;
1522
1591
  constructor(configManager: ConfigManager, logger: Logger, utils: Utils, account: Account);
1523
- onCheckRelayer(account: string, relayer: string, chainId: number): Promise<any>;
1592
+ onCheckRelayer(account: string, relayer: string, chainId: number): Promise<boolean>;
1524
1593
  getUSDPermitParams(deadline: number, chainId: number): Promise<{
1525
- token: string | ethers.Addressable;
1594
+ token: string | ethers$1.Addressable;
1526
1595
  owner: string;
1527
1596
  spender: string;
1528
1597
  value: bigint;
@@ -1539,7 +1608,7 @@ declare class Seamless {
1539
1608
  deadline: number;
1540
1609
  data: string;
1541
1610
  nonce: string;
1542
- }, chainId: number, provider?: ethers.Signer): Promise<ApiResponse<any>>;
1611
+ }, chainId: number, provider?: ethers$1.Signer): Promise<ApiResponse<any>>;
1543
1612
  authorizeSeamlessAccount({ approve, seamlessAddress, chainId }: {
1544
1613
  approve: boolean;
1545
1614
  seamlessAddress: string;
@@ -1561,7 +1630,7 @@ declare class Seamless {
1561
1630
  data: {
1562
1631
  masterAddress: string;
1563
1632
  seamlessAccount: string;
1564
- authorized: any;
1633
+ authorized: boolean;
1565
1634
  };
1566
1635
  }>;
1567
1636
  exportSeamlessPrivateKey({ password, apiKey }: {
@@ -1580,9 +1649,9 @@ declare class Seamless {
1580
1649
  }): Promise<{
1581
1650
  code: number;
1582
1651
  data: {
1583
- masterAddress: any;
1652
+ masterAddress: string;
1584
1653
  seamlessAccount: string;
1585
- authorized: any;
1654
+ authorized: boolean;
1586
1655
  apiKey: string;
1587
1656
  };
1588
1657
  }>;
@@ -1602,7 +1671,7 @@ declare class Seamless {
1602
1671
  data: {
1603
1672
  masterAddress: string;
1604
1673
  seamlessAccount: string;
1605
- authorized: any;
1674
+ authorized: boolean;
1606
1675
  apiKey: string;
1607
1676
  };
1608
1677
  message?: undefined;
@@ -1689,13 +1758,13 @@ declare class Order {
1689
1758
  data: {
1690
1759
  success: boolean;
1691
1760
  orderId: string | null;
1692
- transactionHash: any;
1693
- blockNumber: any;
1694
- gasUsed: any;
1761
+ transactionHash: string;
1762
+ blockNumber: number | undefined;
1763
+ gasUsed: string | undefined;
1695
1764
  status: string;
1696
1765
  confirmations: number;
1697
1766
  timestamp: number;
1698
- receipt: any;
1767
+ receipt: ethers$1.ContractTransactionReceipt | null;
1699
1768
  };
1700
1769
  } | {
1701
1770
  code: number;
@@ -1717,13 +1786,13 @@ declare class Order {
1717
1786
  code: number;
1718
1787
  message: string;
1719
1788
  data: string | null;
1720
- transactionHash: any;
1721
- blockNumber: any;
1722
- gasUsed: any;
1789
+ transactionHash: string;
1790
+ blockNumber: number | undefined;
1791
+ gasUsed: string | undefined;
1723
1792
  status: string;
1724
1793
  confirmations: number;
1725
1794
  timestamp: number;
1726
- receipt: any;
1795
+ receipt: ethers$1.ContractTransactionReceipt | null;
1727
1796
  } | {
1728
1797
  code: number;
1729
1798
  message: any;
@@ -1746,13 +1815,13 @@ declare class Order {
1746
1815
  data: {
1747
1816
  success: boolean;
1748
1817
  orderId: string | null;
1749
- transactionHash: any;
1750
- blockNumber: any;
1751
- gasUsed: any;
1818
+ transactionHash: string;
1819
+ blockNumber: number | undefined;
1820
+ gasUsed: string | undefined;
1752
1821
  status: string;
1753
1822
  confirmations: number;
1754
1823
  timestamp: number;
1755
- receipt: any;
1824
+ receipt: ethers$1.ContractTransactionReceipt | null;
1756
1825
  };
1757
1826
  } | {
1758
1827
  code: number;
@@ -1769,13 +1838,13 @@ declare class Order {
1769
1838
  data: {
1770
1839
  success: boolean;
1771
1840
  orderId: string | null;
1772
- transactionHash: any;
1773
- blockNumber: any;
1774
- gasUsed: any;
1841
+ transactionHash: string;
1842
+ blockNumber: number | undefined;
1843
+ gasUsed: string | undefined;
1775
1844
  status: string;
1776
1845
  confirmations: number;
1777
1846
  timestamp: number;
1778
- receipt: any;
1847
+ receipt: ethers$1.ContractTransactionReceipt | null;
1779
1848
  };
1780
1849
  } | {
1781
1850
  code: number;
@@ -1801,7 +1870,7 @@ declare class Order {
1801
1870
  }>;
1802
1871
  updateOrderTpSl(params: UpdateOrderParams, quoteAddress: string, chainId: number): Promise<{
1803
1872
  code: number;
1804
- data: any;
1873
+ data: ethers$1.ContractTransactionReceipt | null;
1805
1874
  message: string;
1806
1875
  } | {
1807
1876
  code: number;
package/dist/index.js CHANGED
@@ -1821,7 +1821,7 @@ var RotationProvider = class extends import_providers.BaseProvider {
1821
1821
  // package.json
1822
1822
  var package_default = {
1823
1823
  name: "@myx-trade/sdk",
1824
- version: "0.1.158",
1824
+ version: "0.1.161",
1825
1825
  private: false,
1826
1826
  publishConfig: {
1827
1827
  access: "public"
@@ -21026,6 +21026,13 @@ var Account_default = [
21026
21026
 
21027
21027
  // src/manager/account/index.ts
21028
21028
  var import_dayjs3 = __toESM(require("dayjs"));
21029
+
21030
+ // src/api/pool/index.ts
21031
+ var getPoolList = async () => {
21032
+ return http.get(`${baseUrl}/openapi/gateway/scan/market/list`);
21033
+ };
21034
+
21035
+ // src/manager/account/index.ts
21029
21036
  var Account = class {
21030
21037
  constructor(configManager, logger, utils, client2) {
21031
21038
  this.configManager = configManager;
@@ -21083,16 +21090,54 @@ var Account = class {
21083
21090
  }
21084
21091
  }
21085
21092
  async getAvailableMarginBalance({ poolId, chainId, address }) {
21086
- const marginAccountBalanceRes = await this.getTradableAmount({ poolId, chainId, address });
21087
- const marginAccountBalance = marginAccountBalanceRes?.data;
21088
- if (marginAccountBalanceRes.code !== 0) {
21093
+ try {
21094
+ const poolListRes = await getPoolList();
21095
+ if (poolListRes.code !== 0) {
21096
+ throw new MyxSDKError(
21097
+ "REQUEST_FAILED" /* RequestFailed */,
21098
+ "Failed to get pool list"
21099
+ );
21100
+ }
21101
+ const poolList = poolListRes.data;
21102
+ const pool = poolList?.find((pool2) => pool2.poolId === poolId);
21103
+ const orderRes = await this.client.order.getOrders();
21104
+ this.logger.info("orderRes-->", orderRes);
21105
+ if (orderRes.code !== 0) {
21106
+ throw new MyxSDKError(
21107
+ "REQUEST_FAILED" /* RequestFailed */,
21108
+ "Failed to get orders"
21109
+ );
21110
+ }
21111
+ const orders = orderRes.data;
21112
+ const openOrders = orders?.filter((order) => order.poolId === poolId);
21113
+ const used = openOrders?.reduce((acc, order) => {
21114
+ const prev = BigInt(acc);
21115
+ const curr = BigInt(order.collateralAmount ?? 0) + prev;
21116
+ return curr.toString();
21117
+ }, "0");
21118
+ const marginAccountBalanceRes = await this.getAccountInfo(chainId, address, poolId);
21119
+ if (marginAccountBalanceRes.code !== 0) {
21120
+ throw new MyxSDKError(
21121
+ "REQUEST_FAILED" /* RequestFailed */,
21122
+ "Failed to get account info"
21123
+ );
21124
+ }
21125
+ const marginAccountBalance = marginAccountBalanceRes.data;
21126
+ const usedMargin = import_ethers26.ethers.parseUnits(used ?? "0", pool?.quoteDecimals ?? 6);
21127
+ const quoteProfit = BigInt(marginAccountBalance.quoteProfit ?? 0);
21128
+ const freeAmount = BigInt(marginAccountBalance?.freeAmount.toString() ?? 0);
21129
+ const accountMargin = freeAmount + quoteProfit;
21130
+ if (accountMargin < usedMargin) {
21131
+ return BigInt(0);
21132
+ }
21133
+ const availableAccountMarginBalance = accountMargin - usedMargin;
21134
+ return availableAccountMarginBalance;
21135
+ } catch (error) {
21089
21136
  throw new MyxSDKError(
21090
- "INSUFFICIENT_MARGIN_BALANCE" /* InsufficientMarginBalance */,
21091
- "Insufficient margin balance"
21137
+ "REQUEST_FAILED" /* RequestFailed */,
21138
+ "Failed to get orders"
21092
21139
  );
21093
21140
  }
21094
- const availableAccountMarginBalance = BigInt(marginAccountBalance?.freeAmount.toString() ?? 0) + (!marginAccountBalance?.tradeableProfit ? BigInt(marginAccountBalance?.tradeableProfit) : BigInt(0));
21095
- return availableAccountMarginBalance;
21096
21141
  }
21097
21142
  async getTradeFlow(params) {
21098
21143
  const accessToken = await this.configManager.getAccessToken();
package/dist/index.mjs CHANGED
@@ -1731,7 +1731,7 @@ var RotationProvider = class extends BaseProvider {
1731
1731
  // package.json
1732
1732
  var package_default = {
1733
1733
  name: "@myx-trade/sdk",
1734
- version: "0.1.158",
1734
+ version: "0.1.161",
1735
1735
  private: false,
1736
1736
  publishConfig: {
1737
1737
  access: "public"
@@ -20936,6 +20936,13 @@ var Account_default = [
20936
20936
 
20937
20937
  // src/manager/account/index.ts
20938
20938
  import dayjs3 from "dayjs";
20939
+
20940
+ // src/api/pool/index.ts
20941
+ var getPoolList = async () => {
20942
+ return http.get(`${baseUrl}/openapi/gateway/scan/market/list`);
20943
+ };
20944
+
20945
+ // src/manager/account/index.ts
20939
20946
  var Account = class {
20940
20947
  constructor(configManager, logger, utils, client2) {
20941
20948
  this.configManager = configManager;
@@ -20993,16 +21000,54 @@ var Account = class {
20993
21000
  }
20994
21001
  }
20995
21002
  async getAvailableMarginBalance({ poolId, chainId, address }) {
20996
- const marginAccountBalanceRes = await this.getTradableAmount({ poolId, chainId, address });
20997
- const marginAccountBalance = marginAccountBalanceRes?.data;
20998
- if (marginAccountBalanceRes.code !== 0) {
21003
+ try {
21004
+ const poolListRes = await getPoolList();
21005
+ if (poolListRes.code !== 0) {
21006
+ throw new MyxSDKError(
21007
+ "REQUEST_FAILED" /* RequestFailed */,
21008
+ "Failed to get pool list"
21009
+ );
21010
+ }
21011
+ const poolList = poolListRes.data;
21012
+ const pool = poolList?.find((pool2) => pool2.poolId === poolId);
21013
+ const orderRes = await this.client.order.getOrders();
21014
+ this.logger.info("orderRes-->", orderRes);
21015
+ if (orderRes.code !== 0) {
21016
+ throw new MyxSDKError(
21017
+ "REQUEST_FAILED" /* RequestFailed */,
21018
+ "Failed to get orders"
21019
+ );
21020
+ }
21021
+ const orders = orderRes.data;
21022
+ const openOrders = orders?.filter((order) => order.poolId === poolId);
21023
+ const used = openOrders?.reduce((acc, order) => {
21024
+ const prev = BigInt(acc);
21025
+ const curr = BigInt(order.collateralAmount ?? 0) + prev;
21026
+ return curr.toString();
21027
+ }, "0");
21028
+ const marginAccountBalanceRes = await this.getAccountInfo(chainId, address, poolId);
21029
+ if (marginAccountBalanceRes.code !== 0) {
21030
+ throw new MyxSDKError(
21031
+ "REQUEST_FAILED" /* RequestFailed */,
21032
+ "Failed to get account info"
21033
+ );
21034
+ }
21035
+ const marginAccountBalance = marginAccountBalanceRes.data;
21036
+ const usedMargin = ethers8.parseUnits(used ?? "0", pool?.quoteDecimals ?? 6);
21037
+ const quoteProfit = BigInt(marginAccountBalance.quoteProfit ?? 0);
21038
+ const freeAmount = BigInt(marginAccountBalance?.freeAmount.toString() ?? 0);
21039
+ const accountMargin = freeAmount + quoteProfit;
21040
+ if (accountMargin < usedMargin) {
21041
+ return BigInt(0);
21042
+ }
21043
+ const availableAccountMarginBalance = accountMargin - usedMargin;
21044
+ return availableAccountMarginBalance;
21045
+ } catch (error) {
20999
21046
  throw new MyxSDKError(
21000
- "INSUFFICIENT_MARGIN_BALANCE" /* InsufficientMarginBalance */,
21001
- "Insufficient margin balance"
21047
+ "REQUEST_FAILED" /* RequestFailed */,
21048
+ "Failed to get orders"
21002
21049
  );
21003
21050
  }
21004
- const availableAccountMarginBalance = BigInt(marginAccountBalance?.freeAmount.toString() ?? 0) + (!marginAccountBalance?.tradeableProfit ? BigInt(marginAccountBalance?.tradeableProfit) : BigInt(0));
21005
- return availableAccountMarginBalance;
21006
21051
  }
21007
21052
  async getTradeFlow(params) {
21008
21053
  const accessToken = await this.configManager.getAccessToken();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myx-trade/sdk",
3
- "version": "0.1.158",
3
+ "version": "0.1.161",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"