@limitless-exchange/sdk 0.0.1 → 0.0.3
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/README.md +71 -6
- package/dist/index.d.mts +835 -200
- package/dist/index.d.ts +835 -200
- package/dist/index.js +301 -210
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +301 -209
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -30,26 +30,138 @@ interface SignatureHeaders {
|
|
|
30
30
|
'x-signature': string;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
* User
|
|
33
|
+
* User rank information.
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
interface UserRank {
|
|
37
|
+
/**
|
|
38
|
+
* Rank ID
|
|
39
|
+
*/
|
|
40
|
+
id: number;
|
|
41
|
+
/**
|
|
42
|
+
* Rank name
|
|
43
|
+
*/
|
|
44
|
+
name: string;
|
|
45
|
+
/**
|
|
46
|
+
* Fee rate in basis points
|
|
47
|
+
*/
|
|
48
|
+
feeRateBps: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Referral data for a user.
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
interface ReferralData {
|
|
55
|
+
/**
|
|
56
|
+
* Referral creation timestamp
|
|
57
|
+
*/
|
|
58
|
+
createdAt: string;
|
|
59
|
+
/**
|
|
60
|
+
* Referral ID
|
|
61
|
+
*/
|
|
62
|
+
id: number;
|
|
63
|
+
/**
|
|
64
|
+
* Referred user's profile ID
|
|
65
|
+
*/
|
|
66
|
+
referredProfileId: number;
|
|
67
|
+
/**
|
|
68
|
+
* Profile picture URL
|
|
69
|
+
*/
|
|
70
|
+
pfpUrl: string | null;
|
|
71
|
+
/**
|
|
72
|
+
* Display name
|
|
73
|
+
*/
|
|
74
|
+
displayName: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* User profile information returned after authentication (1:1 with API response).
|
|
34
78
|
* @public
|
|
35
79
|
*/
|
|
36
80
|
interface UserProfile {
|
|
81
|
+
/**
|
|
82
|
+
* User ID (used as ownerId for orders)
|
|
83
|
+
*/
|
|
84
|
+
id: number;
|
|
37
85
|
/**
|
|
38
86
|
* User's Ethereum address (EOA)
|
|
39
87
|
*/
|
|
40
88
|
account: string;
|
|
89
|
+
/**
|
|
90
|
+
* Client type used for authentication
|
|
91
|
+
*/
|
|
92
|
+
client: ClientType;
|
|
93
|
+
/**
|
|
94
|
+
* User rank information containing feeRateBps
|
|
95
|
+
*/
|
|
96
|
+
rank?: UserRank;
|
|
97
|
+
/**
|
|
98
|
+
* Account creation timestamp
|
|
99
|
+
*/
|
|
100
|
+
createdAt?: string;
|
|
101
|
+
/**
|
|
102
|
+
* Username
|
|
103
|
+
*/
|
|
104
|
+
username?: string;
|
|
41
105
|
/**
|
|
42
106
|
* Display name for the user
|
|
43
107
|
*/
|
|
44
|
-
displayName
|
|
108
|
+
displayName?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Profile picture URL
|
|
111
|
+
*/
|
|
112
|
+
pfpUrl?: string;
|
|
113
|
+
/**
|
|
114
|
+
* User bio
|
|
115
|
+
*/
|
|
116
|
+
bio?: string;
|
|
117
|
+
/**
|
|
118
|
+
* Social media URL
|
|
119
|
+
*/
|
|
120
|
+
socialUrl?: string;
|
|
45
121
|
/**
|
|
46
122
|
* Smart wallet address (optional, required for ETHERSPOT client)
|
|
47
123
|
*/
|
|
48
124
|
smartWallet?: string;
|
|
49
125
|
/**
|
|
50
|
-
*
|
|
126
|
+
* Trade wallet option
|
|
51
127
|
*/
|
|
52
|
-
|
|
128
|
+
tradeWalletOption?: string;
|
|
129
|
+
/**
|
|
130
|
+
* Embedded account address
|
|
131
|
+
*/
|
|
132
|
+
embeddedAccount?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Total points
|
|
135
|
+
*/
|
|
136
|
+
points?: number;
|
|
137
|
+
/**
|
|
138
|
+
* Accumulative points
|
|
139
|
+
*/
|
|
140
|
+
accumulativePoints?: number;
|
|
141
|
+
/**
|
|
142
|
+
* Whether enrolled in points program
|
|
143
|
+
*/
|
|
144
|
+
enrolledInPointsProgram?: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Position on leaderboard
|
|
147
|
+
*/
|
|
148
|
+
leaderboardPosition?: number;
|
|
149
|
+
/**
|
|
150
|
+
* Whether user is in top 100
|
|
151
|
+
*/
|
|
152
|
+
isTop100?: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Whether user is a captain
|
|
155
|
+
*/
|
|
156
|
+
isCaptain?: boolean;
|
|
157
|
+
/**
|
|
158
|
+
* List of referral information
|
|
159
|
+
*/
|
|
160
|
+
referralData?: ReferralData[];
|
|
161
|
+
/**
|
|
162
|
+
* Count of referred users
|
|
163
|
+
*/
|
|
164
|
+
referredUsersCount?: number;
|
|
53
165
|
}
|
|
54
166
|
/**
|
|
55
167
|
* Mode information from authentication response.
|
|
@@ -197,14 +309,6 @@ declare enum OrderType {
|
|
|
197
309
|
/** Good-Til-Cancelled: Remain on orderbook until filled or cancelled */
|
|
198
310
|
GTC = "GTC"
|
|
199
311
|
}
|
|
200
|
-
/**
|
|
201
|
-
* Market type enum.
|
|
202
|
-
* @public
|
|
203
|
-
*/
|
|
204
|
-
declare enum MarketType {
|
|
205
|
-
CLOB = "CLOB",
|
|
206
|
-
NEGRISK = "NEGRISK"
|
|
207
|
-
}
|
|
208
312
|
/**
|
|
209
313
|
* Signature type enum.
|
|
210
314
|
* @public
|
|
@@ -230,11 +334,6 @@ interface BaseOrderArgs {
|
|
|
230
334
|
* Order side (BUY or SELL)
|
|
231
335
|
*/
|
|
232
336
|
side: Side;
|
|
233
|
-
/**
|
|
234
|
-
* Market type (CLOB or NEGRISK)
|
|
235
|
-
* @defaultValue 'CLOB'
|
|
236
|
-
*/
|
|
237
|
-
marketType?: MarketType;
|
|
238
337
|
/**
|
|
239
338
|
* Expiration timestamp (0 for no expiration)
|
|
240
339
|
* @defaultValue '0'
|
|
@@ -572,48 +671,186 @@ interface OrderSigningConfig {
|
|
|
572
671
|
*/
|
|
573
672
|
chainId: number;
|
|
574
673
|
/**
|
|
575
|
-
* Contract address for verification
|
|
674
|
+
* Contract address for verification (from venue.exchange)
|
|
576
675
|
*/
|
|
577
676
|
contractAddress: string;
|
|
578
|
-
/**
|
|
579
|
-
* Market type (CLOB or NEGRISK)
|
|
580
|
-
*/
|
|
581
|
-
marketType: MarketType;
|
|
582
677
|
}
|
|
583
678
|
|
|
584
679
|
/**
|
|
585
680
|
* Market-related types for Limitless Exchange.
|
|
586
681
|
* @module types/markets
|
|
587
682
|
*/
|
|
683
|
+
/**
|
|
684
|
+
* Collateral token information.
|
|
685
|
+
* @public
|
|
686
|
+
*/
|
|
687
|
+
interface CollateralToken {
|
|
688
|
+
/**
|
|
689
|
+
* Token contract address
|
|
690
|
+
*/
|
|
691
|
+
address: string;
|
|
692
|
+
/**
|
|
693
|
+
* Token decimals
|
|
694
|
+
*/
|
|
695
|
+
decimals: number;
|
|
696
|
+
/**
|
|
697
|
+
* Token symbol (e.g., "USDC")
|
|
698
|
+
*/
|
|
699
|
+
symbol: string;
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Market creator information.
|
|
703
|
+
* @public
|
|
704
|
+
*/
|
|
705
|
+
interface MarketCreator {
|
|
706
|
+
/**
|
|
707
|
+
* Creator name
|
|
708
|
+
*/
|
|
709
|
+
name: string;
|
|
710
|
+
/**
|
|
711
|
+
* Creator image URL
|
|
712
|
+
*/
|
|
713
|
+
imageURI?: string;
|
|
714
|
+
/**
|
|
715
|
+
* Creator link URL
|
|
716
|
+
*/
|
|
717
|
+
link?: string;
|
|
718
|
+
}
|
|
719
|
+
/**
|
|
720
|
+
* Market metadata.
|
|
721
|
+
* @public
|
|
722
|
+
*/
|
|
723
|
+
interface MarketMetadata {
|
|
724
|
+
/**
|
|
725
|
+
* Fee enabled flag
|
|
726
|
+
*/
|
|
727
|
+
fee: boolean;
|
|
728
|
+
/**
|
|
729
|
+
* Banner flag
|
|
730
|
+
*/
|
|
731
|
+
isBannered?: boolean;
|
|
732
|
+
/**
|
|
733
|
+
* Polymarket arbitrage flag
|
|
734
|
+
*/
|
|
735
|
+
isPolyArbitrage?: boolean;
|
|
736
|
+
/**
|
|
737
|
+
* Market making flag
|
|
738
|
+
*/
|
|
739
|
+
shouldMarketMake?: boolean;
|
|
740
|
+
/**
|
|
741
|
+
* Opening price for oracle markets
|
|
742
|
+
*/
|
|
743
|
+
openPrice?: string;
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* Market settings for CLOB markets.
|
|
747
|
+
* @public
|
|
748
|
+
*/
|
|
749
|
+
interface MarketSettings {
|
|
750
|
+
/**
|
|
751
|
+
* Minimum order size
|
|
752
|
+
*/
|
|
753
|
+
minSize: string;
|
|
754
|
+
/**
|
|
755
|
+
* Maximum spread allowed
|
|
756
|
+
*/
|
|
757
|
+
maxSpread: number;
|
|
758
|
+
/**
|
|
759
|
+
* Daily reward amount
|
|
760
|
+
*/
|
|
761
|
+
dailyReward: string;
|
|
762
|
+
/**
|
|
763
|
+
* Rewards epoch duration
|
|
764
|
+
*/
|
|
765
|
+
rewardsEpoch: string;
|
|
766
|
+
/**
|
|
767
|
+
* Constant parameter
|
|
768
|
+
*/
|
|
769
|
+
c: string;
|
|
770
|
+
}
|
|
771
|
+
/**
|
|
772
|
+
* Trade prices for different order types.
|
|
773
|
+
* @public
|
|
774
|
+
*/
|
|
775
|
+
interface TradePrices {
|
|
776
|
+
/**
|
|
777
|
+
* Buy prices (market and limit) for yes/no tokens
|
|
778
|
+
*/
|
|
779
|
+
buy: {
|
|
780
|
+
market: [number, number];
|
|
781
|
+
limit: [number, number];
|
|
782
|
+
};
|
|
783
|
+
/**
|
|
784
|
+
* Sell prices (market and limit) for yes/no tokens
|
|
785
|
+
*/
|
|
786
|
+
sell: {
|
|
787
|
+
market: [number, number];
|
|
788
|
+
limit: [number, number];
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* Price oracle metadata for oracle-based markets.
|
|
793
|
+
* @public
|
|
794
|
+
*/
|
|
795
|
+
interface PriceOracleMetadata {
|
|
796
|
+
/**
|
|
797
|
+
* Asset ticker symbol
|
|
798
|
+
*/
|
|
799
|
+
ticker: string;
|
|
800
|
+
/**
|
|
801
|
+
* Asset type (e.g., "CRYPTO")
|
|
802
|
+
*/
|
|
803
|
+
assetType: string;
|
|
804
|
+
/**
|
|
805
|
+
* Pyth Network price feed address
|
|
806
|
+
*/
|
|
807
|
+
pythAddress: string;
|
|
808
|
+
/**
|
|
809
|
+
* Price feed symbol
|
|
810
|
+
*/
|
|
811
|
+
symbol: string;
|
|
812
|
+
/**
|
|
813
|
+
* Asset name
|
|
814
|
+
*/
|
|
815
|
+
name: string;
|
|
816
|
+
/**
|
|
817
|
+
* Logo URL
|
|
818
|
+
*/
|
|
819
|
+
logo: string;
|
|
820
|
+
}
|
|
588
821
|
/**
|
|
589
822
|
* Orderbook entry (bid or ask).
|
|
823
|
+
* Matches API response format exactly (1:1 parity).
|
|
824
|
+
*
|
|
590
825
|
* @public
|
|
591
826
|
*/
|
|
592
827
|
interface OrderbookEntry {
|
|
593
828
|
/**
|
|
594
|
-
* Price per share
|
|
829
|
+
* Price per share (0-1 range)
|
|
595
830
|
*/
|
|
596
831
|
price: number;
|
|
597
832
|
/**
|
|
598
|
-
* Size in shares
|
|
833
|
+
* Size in shares
|
|
599
834
|
*/
|
|
600
835
|
size: number;
|
|
601
836
|
/**
|
|
602
|
-
* Order side (BUY or SELL)
|
|
837
|
+
* Order side ("BUY" or "SELL")
|
|
603
838
|
*/
|
|
604
839
|
side: string;
|
|
605
840
|
}
|
|
606
841
|
/**
|
|
607
842
|
* Complete orderbook for a market.
|
|
843
|
+
* Matches API response format exactly (1:1 parity).
|
|
844
|
+
*
|
|
608
845
|
* @public
|
|
609
846
|
*/
|
|
610
847
|
interface OrderBook {
|
|
611
848
|
/**
|
|
612
|
-
* Bid orders (buy orders)
|
|
849
|
+
* Bid orders (buy orders) sorted by price descending
|
|
613
850
|
*/
|
|
614
851
|
bids: OrderbookEntry[];
|
|
615
852
|
/**
|
|
616
|
-
* Ask orders (sell orders)
|
|
853
|
+
* Ask orders (sell orders) sorted by price ascending
|
|
617
854
|
*/
|
|
618
855
|
asks: OrderbookEntry[];
|
|
619
856
|
/**
|
|
@@ -621,13 +858,21 @@ interface OrderBook {
|
|
|
621
858
|
*/
|
|
622
859
|
tokenId: string;
|
|
623
860
|
/**
|
|
624
|
-
*
|
|
861
|
+
* Adjusted midpoint price between best bid and ask
|
|
862
|
+
*/
|
|
863
|
+
adjustedMidpoint: number;
|
|
864
|
+
/**
|
|
865
|
+
* Maximum allowed spread for the market
|
|
866
|
+
*/
|
|
867
|
+
maxSpread: string;
|
|
868
|
+
/**
|
|
869
|
+
* Minimum order size allowed
|
|
625
870
|
*/
|
|
626
871
|
minSize: string;
|
|
627
872
|
/**
|
|
628
|
-
* Last trade price
|
|
873
|
+
* Last trade price for the market
|
|
629
874
|
*/
|
|
630
|
-
lastTradePrice
|
|
875
|
+
lastTradePrice: number;
|
|
631
876
|
}
|
|
632
877
|
/**
|
|
633
878
|
* Market price information.
|
|
@@ -670,7 +915,46 @@ interface MarketOutcome {
|
|
|
670
915
|
price?: number;
|
|
671
916
|
}
|
|
672
917
|
/**
|
|
673
|
-
*
|
|
918
|
+
* Venue information for CLOB markets.
|
|
919
|
+
*
|
|
920
|
+
* @remarks
|
|
921
|
+
* Contains contract addresses required for trading:
|
|
922
|
+
* - exchange: Used as verifyingContract for EIP-712 order signing
|
|
923
|
+
* - adapter: Required for NegRisk/Grouped market SELL approvals
|
|
924
|
+
*
|
|
925
|
+
* @public
|
|
926
|
+
*/
|
|
927
|
+
interface Venue {
|
|
928
|
+
/**
|
|
929
|
+
* Exchange contract address.
|
|
930
|
+
*
|
|
931
|
+
* @remarks
|
|
932
|
+
* This address is used as the verifyingContract in EIP-712 order signing.
|
|
933
|
+
* All BUY orders require USDC approval to this address.
|
|
934
|
+
* Simple CLOB SELL orders require CT approval to this address.
|
|
935
|
+
*/
|
|
936
|
+
exchange: string;
|
|
937
|
+
/**
|
|
938
|
+
* Adapter contract address.
|
|
939
|
+
*
|
|
940
|
+
* @remarks
|
|
941
|
+
* Required for NegRisk/Grouped markets only.
|
|
942
|
+
* SELL orders on NegRisk markets require CT approval to both exchange AND adapter.
|
|
943
|
+
*/
|
|
944
|
+
adapter: string;
|
|
945
|
+
}
|
|
946
|
+
/**
|
|
947
|
+
* Market token IDs for CLOB markets.
|
|
948
|
+
* @public
|
|
949
|
+
*/
|
|
950
|
+
interface MarketTokens {
|
|
951
|
+
yes: string;
|
|
952
|
+
no: string;
|
|
953
|
+
}
|
|
954
|
+
/**
|
|
955
|
+
* Complete market information (1:1 with API response).
|
|
956
|
+
* Handles both CLOB single markets and NegRisk group markets.
|
|
957
|
+
*
|
|
674
958
|
* @public
|
|
675
959
|
*/
|
|
676
960
|
interface Market {
|
|
@@ -679,9 +963,9 @@ interface Market {
|
|
|
679
963
|
*/
|
|
680
964
|
id: number;
|
|
681
965
|
/**
|
|
682
|
-
* Market
|
|
966
|
+
* Market slug identifier
|
|
683
967
|
*/
|
|
684
|
-
|
|
968
|
+
slug: string;
|
|
685
969
|
/**
|
|
686
970
|
* Market title
|
|
687
971
|
*/
|
|
@@ -693,19 +977,23 @@ interface Market {
|
|
|
693
977
|
/**
|
|
694
978
|
* Market description
|
|
695
979
|
*/
|
|
696
|
-
description
|
|
980
|
+
description?: string;
|
|
697
981
|
/**
|
|
698
|
-
*
|
|
982
|
+
* Collateral token information
|
|
699
983
|
*/
|
|
700
|
-
|
|
984
|
+
collateralToken: CollateralToken;
|
|
701
985
|
/**
|
|
702
|
-
*
|
|
986
|
+
* Human-readable expiration date
|
|
703
987
|
*/
|
|
704
|
-
|
|
988
|
+
expirationDate: string;
|
|
705
989
|
/**
|
|
706
|
-
*
|
|
990
|
+
* Expiration timestamp in milliseconds
|
|
707
991
|
*/
|
|
708
|
-
|
|
992
|
+
expirationTimestamp: number;
|
|
993
|
+
/**
|
|
994
|
+
* Whether market is expired
|
|
995
|
+
*/
|
|
996
|
+
expired?: boolean;
|
|
709
997
|
/**
|
|
710
998
|
* Creation timestamp
|
|
711
999
|
*/
|
|
@@ -714,12 +1002,144 @@ interface Market {
|
|
|
714
1002
|
* Last update timestamp
|
|
715
1003
|
*/
|
|
716
1004
|
updatedAt: string;
|
|
1005
|
+
/**
|
|
1006
|
+
* Market categories
|
|
1007
|
+
*/
|
|
1008
|
+
categories: string[];
|
|
717
1009
|
/**
|
|
718
1010
|
* Market status
|
|
719
1011
|
*/
|
|
720
|
-
status
|
|
1012
|
+
status: string;
|
|
1013
|
+
/**
|
|
1014
|
+
* Creator information
|
|
1015
|
+
*/
|
|
1016
|
+
creator: MarketCreator;
|
|
1017
|
+
/**
|
|
1018
|
+
* Market tags
|
|
1019
|
+
*/
|
|
1020
|
+
tags: string[];
|
|
1021
|
+
/**
|
|
1022
|
+
* Trade type (clob or amm)
|
|
1023
|
+
*/
|
|
1024
|
+
tradeType: string;
|
|
1025
|
+
/**
|
|
1026
|
+
* Market type (single or group)
|
|
1027
|
+
*/
|
|
1028
|
+
marketType: string;
|
|
1029
|
+
/**
|
|
1030
|
+
* Priority index for sorting
|
|
1031
|
+
*/
|
|
1032
|
+
priorityIndex: number;
|
|
1033
|
+
/**
|
|
1034
|
+
* Market metadata
|
|
1035
|
+
*/
|
|
1036
|
+
metadata: MarketMetadata;
|
|
1037
|
+
/**
|
|
1038
|
+
* Trading volume
|
|
1039
|
+
*/
|
|
1040
|
+
volume?: string;
|
|
1041
|
+
/**
|
|
1042
|
+
* Formatted trading volume
|
|
1043
|
+
*/
|
|
1044
|
+
volumeFormatted?: string;
|
|
1045
|
+
/**
|
|
1046
|
+
* Condition ID (CLOB only)
|
|
1047
|
+
*/
|
|
1048
|
+
conditionId?: string;
|
|
1049
|
+
/**
|
|
1050
|
+
* NegRisk request ID (CLOB only)
|
|
1051
|
+
*/
|
|
1052
|
+
negRiskRequestId?: string | null;
|
|
1053
|
+
/**
|
|
1054
|
+
* Token IDs for yes/no outcomes (CLOB only)
|
|
1055
|
+
* @example
|
|
1056
|
+
* {
|
|
1057
|
+
* yes: "27687694610130623013351012526567944730242898906227824547270172934678693687246",
|
|
1058
|
+
* no: "9288900480010863316984252765488448624297561656655547117581633191173128271467"
|
|
1059
|
+
* }
|
|
1060
|
+
*/
|
|
1061
|
+
tokens?: MarketTokens;
|
|
1062
|
+
/**
|
|
1063
|
+
* Current prices [yes, no] (CLOB only)
|
|
1064
|
+
*/
|
|
1065
|
+
prices?: number[];
|
|
1066
|
+
/**
|
|
1067
|
+
* Trade prices for buy/sell market/limit orders (CLOB only)
|
|
1068
|
+
*/
|
|
1069
|
+
tradePrices?: TradePrices;
|
|
1070
|
+
/**
|
|
1071
|
+
* Whether market is rewardable (CLOB only)
|
|
1072
|
+
*/
|
|
1073
|
+
isRewardable?: boolean;
|
|
1074
|
+
/**
|
|
1075
|
+
* Market settings (CLOB only)
|
|
1076
|
+
*/
|
|
1077
|
+
settings?: MarketSettings;
|
|
1078
|
+
/**
|
|
1079
|
+
* Venue information for CLOB markets.
|
|
1080
|
+
*
|
|
1081
|
+
* @remarks
|
|
1082
|
+
* Contains exchange and adapter contract addresses for order signing and approvals.
|
|
1083
|
+
* The exchange address is used as verifyingContract in EIP-712 signatures.
|
|
1084
|
+
*
|
|
1085
|
+
* Performance tip: Call getMarket() before createOrder() to cache venue data
|
|
1086
|
+
* and avoid additional API requests during order creation.
|
|
1087
|
+
*/
|
|
1088
|
+
venue?: Venue;
|
|
1089
|
+
/**
|
|
1090
|
+
* Market logo URL
|
|
1091
|
+
*/
|
|
1092
|
+
logo?: string | null;
|
|
1093
|
+
/**
|
|
1094
|
+
* Price oracle metadata (oracle markets only)
|
|
1095
|
+
*/
|
|
1096
|
+
priceOracleMetadata?: PriceOracleMetadata;
|
|
1097
|
+
/**
|
|
1098
|
+
* Order within group (group markets only)
|
|
1099
|
+
*/
|
|
1100
|
+
orderInGroup?: number;
|
|
1101
|
+
/**
|
|
1102
|
+
* Winning outcome index
|
|
1103
|
+
*/
|
|
1104
|
+
winningOutcomeIndex?: number | null;
|
|
1105
|
+
/**
|
|
1106
|
+
* Outcome token names (group only)
|
|
1107
|
+
*/
|
|
1108
|
+
outcomeTokens?: string[];
|
|
1109
|
+
/**
|
|
1110
|
+
* OG image URI (group only)
|
|
1111
|
+
*/
|
|
1112
|
+
ogImageURI?: string;
|
|
1113
|
+
/**
|
|
1114
|
+
* NegRisk market ID (group only)
|
|
1115
|
+
*/
|
|
1116
|
+
negRiskMarketId?: string;
|
|
1117
|
+
/**
|
|
1118
|
+
* Child markets in group (group only)
|
|
1119
|
+
*/
|
|
1120
|
+
markets?: Market[];
|
|
1121
|
+
/**
|
|
1122
|
+
* Daily reward for group (group only)
|
|
1123
|
+
*/
|
|
1124
|
+
dailyReward?: string;
|
|
1125
|
+
/**
|
|
1126
|
+
* Market contract address
|
|
1127
|
+
* @deprecated Use conditionId instead
|
|
1128
|
+
*/
|
|
1129
|
+
address?: string | null;
|
|
1130
|
+
/**
|
|
1131
|
+
* Market type (CLOB or AMM)
|
|
1132
|
+
* @deprecated Use tradeType instead
|
|
1133
|
+
*/
|
|
1134
|
+
type?: string;
|
|
1135
|
+
/**
|
|
1136
|
+
* Market outcomes
|
|
1137
|
+
* @deprecated Use tokens for CLOB markets
|
|
1138
|
+
*/
|
|
1139
|
+
outcomes?: MarketOutcome[];
|
|
721
1140
|
/**
|
|
722
1141
|
* Resolution timestamp
|
|
1142
|
+
* @deprecated Use expirationTimestamp instead
|
|
723
1143
|
*/
|
|
724
1144
|
resolutionDate?: string;
|
|
725
1145
|
}
|
|
@@ -749,7 +1169,7 @@ interface MarketsResponse {
|
|
|
749
1169
|
* Sort options for active markets.
|
|
750
1170
|
* @public
|
|
751
1171
|
*/
|
|
752
|
-
type ActiveMarketsSortBy = 'lp_rewards' | 'ending_soon' | 'newest' | 'high_value';
|
|
1172
|
+
type ActiveMarketsSortBy = 'lp_rewards' | 'ending_soon' | 'newest' | 'high_value' | 'liquidity';
|
|
753
1173
|
/**
|
|
754
1174
|
* Query parameters for active markets endpoint.
|
|
755
1175
|
* @public
|
|
@@ -1132,6 +1552,7 @@ interface PortfolioSummary {
|
|
|
1132
1552
|
* WebSocket types for real-time data streaming.
|
|
1133
1553
|
* @module types/websocket
|
|
1134
1554
|
*/
|
|
1555
|
+
|
|
1135
1556
|
/**
|
|
1136
1557
|
* WebSocket connection configuration.
|
|
1137
1558
|
* @public
|
|
@@ -1177,22 +1598,36 @@ declare enum WebSocketState {
|
|
|
1177
1598
|
* Subscription channels for WebSocket events.
|
|
1178
1599
|
* @public
|
|
1179
1600
|
*/
|
|
1180
|
-
type SubscriptionChannel = 'orderbook' | 'trades' | 'orders' | 'fills' | 'markets' | 'prices';
|
|
1601
|
+
type SubscriptionChannel = 'orderbook' | 'trades' | 'orders' | 'fills' | 'markets' | 'prices' | 'subscribe_market_prices' | 'subscribe_positions' | 'subscribe_transactions';
|
|
1602
|
+
/**
|
|
1603
|
+
* Orderbook data structure (nested object in OrderbookUpdate).
|
|
1604
|
+
* @public
|
|
1605
|
+
*/
|
|
1606
|
+
interface OrderbookData {
|
|
1607
|
+
/** List of bid orders sorted by price descending */
|
|
1608
|
+
bids: OrderbookEntry[];
|
|
1609
|
+
/** List of ask orders sorted by price ascending */
|
|
1610
|
+
asks: OrderbookEntry[];
|
|
1611
|
+
/** Token ID for the orderbook */
|
|
1612
|
+
tokenId: string;
|
|
1613
|
+
/** Adjusted midpoint price */
|
|
1614
|
+
adjustedMidpoint: number;
|
|
1615
|
+
/** Maximum spread allowed */
|
|
1616
|
+
maxSpread: number;
|
|
1617
|
+
/** Minimum order size */
|
|
1618
|
+
minSize: number;
|
|
1619
|
+
}
|
|
1181
1620
|
/**
|
|
1182
|
-
* Orderbook update event.
|
|
1621
|
+
* Orderbook update event - matches API format exactly.
|
|
1183
1622
|
* @public
|
|
1184
1623
|
*/
|
|
1185
1624
|
interface OrderbookUpdate {
|
|
1625
|
+
/** Market slug identifier (camelCase to match API) */
|
|
1186
1626
|
marketSlug: string;
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
asks: Array<{
|
|
1192
|
-
price: number;
|
|
1193
|
-
size: number;
|
|
1194
|
-
}>;
|
|
1195
|
-
timestamp: number;
|
|
1627
|
+
/** Nested orderbook data object */
|
|
1628
|
+
orderbook: OrderbookData;
|
|
1629
|
+
/** Timestamp as Date or number after serialization */
|
|
1630
|
+
timestamp: Date | number | string;
|
|
1196
1631
|
}
|
|
1197
1632
|
/**
|
|
1198
1633
|
* Trade event.
|
|
@@ -1245,14 +1680,79 @@ interface MarketUpdate {
|
|
|
1245
1680
|
timestamp: number;
|
|
1246
1681
|
}
|
|
1247
1682
|
/**
|
|
1248
|
-
* Price update event.
|
|
1683
|
+
* Price update event (deprecated - use NewPriceData for AMM prices).
|
|
1684
|
+
*
|
|
1685
|
+
* Note: This type does not match the actual API response.
|
|
1686
|
+
* Use NewPriceData for the correct AMM price update format.
|
|
1687
|
+
*
|
|
1249
1688
|
* @public
|
|
1689
|
+
* @deprecated
|
|
1250
1690
|
*/
|
|
1251
1691
|
interface PriceUpdate {
|
|
1252
1692
|
marketSlug: string;
|
|
1253
1693
|
price: number;
|
|
1254
1694
|
timestamp: number;
|
|
1255
1695
|
}
|
|
1696
|
+
/**
|
|
1697
|
+
* Single AMM price entry in updatedPrices array.
|
|
1698
|
+
* @public
|
|
1699
|
+
*/
|
|
1700
|
+
interface AmmPriceEntry {
|
|
1701
|
+
/** Market ID */
|
|
1702
|
+
marketId: number;
|
|
1703
|
+
/** Market contract address */
|
|
1704
|
+
marketAddress: string;
|
|
1705
|
+
/** YES token price (0-1 range) */
|
|
1706
|
+
yesPrice: number;
|
|
1707
|
+
/** NO token price (0-1 range) */
|
|
1708
|
+
noPrice: number;
|
|
1709
|
+
}
|
|
1710
|
+
/**
|
|
1711
|
+
* AMM price update event (newPriceData) - matches API format exactly.
|
|
1712
|
+
* @public
|
|
1713
|
+
*/
|
|
1714
|
+
interface NewPriceData {
|
|
1715
|
+
/** Market contract address (camelCase to match API) */
|
|
1716
|
+
marketAddress: string;
|
|
1717
|
+
/** Array of price updates for this market */
|
|
1718
|
+
updatedPrices: AmmPriceEntry[];
|
|
1719
|
+
/** Blockchain block number */
|
|
1720
|
+
blockNumber: number;
|
|
1721
|
+
/** Timestamp as Date or number after serialization */
|
|
1722
|
+
timestamp: Date | number | string;
|
|
1723
|
+
}
|
|
1724
|
+
/**
|
|
1725
|
+
* Transaction event (blockchain transaction status).
|
|
1726
|
+
* @public
|
|
1727
|
+
*/
|
|
1728
|
+
interface TransactionEvent {
|
|
1729
|
+
/** User ID (optional) */
|
|
1730
|
+
userId?: number;
|
|
1731
|
+
/** Transaction hash (optional) */
|
|
1732
|
+
txHash?: string;
|
|
1733
|
+
/** Transaction status */
|
|
1734
|
+
status: 'CONFIRMED' | 'FAILED';
|
|
1735
|
+
/** Transaction source */
|
|
1736
|
+
source: string;
|
|
1737
|
+
/** Transaction timestamp */
|
|
1738
|
+
timestamp: Date | string;
|
|
1739
|
+
/** Market address (optional) */
|
|
1740
|
+
marketAddress?: string;
|
|
1741
|
+
/** Market slug identifier (optional) */
|
|
1742
|
+
marketSlug?: string;
|
|
1743
|
+
/** Token ID (optional) */
|
|
1744
|
+
tokenId?: string;
|
|
1745
|
+
/** Condition ID (optional) */
|
|
1746
|
+
conditionId?: string;
|
|
1747
|
+
/** Amount of contracts (optional, in string format) */
|
|
1748
|
+
amountContracts?: string;
|
|
1749
|
+
/** Amount of collateral (optional, in string format) */
|
|
1750
|
+
amountCollateral?: string;
|
|
1751
|
+
/** Price (optional, in string format) */
|
|
1752
|
+
price?: string;
|
|
1753
|
+
/** Trade side (optional) */
|
|
1754
|
+
side?: 'BUY' | 'SELL';
|
|
1755
|
+
}
|
|
1256
1756
|
/**
|
|
1257
1757
|
* WebSocket event types.
|
|
1258
1758
|
* @public
|
|
@@ -1275,9 +1775,13 @@ interface WebSocketEvents {
|
|
|
1275
1775
|
*/
|
|
1276
1776
|
reconnecting: (attempt: number) => void;
|
|
1277
1777
|
/**
|
|
1278
|
-
* Orderbook updates
|
|
1778
|
+
* Orderbook updates (CLOB markets) - API event name: orderbookUpdate
|
|
1779
|
+
*/
|
|
1780
|
+
orderbookUpdate: (data: OrderbookUpdate) => void;
|
|
1781
|
+
/**
|
|
1782
|
+
* AMM price updates - API event name: newPriceData
|
|
1279
1783
|
*/
|
|
1280
|
-
|
|
1784
|
+
newPriceData: (data: NewPriceData) => void;
|
|
1281
1785
|
/**
|
|
1282
1786
|
* Trade events
|
|
1283
1787
|
*/
|
|
@@ -1295,7 +1799,16 @@ interface WebSocketEvents {
|
|
|
1295
1799
|
*/
|
|
1296
1800
|
market: (data: MarketUpdate) => void;
|
|
1297
1801
|
/**
|
|
1298
|
-
*
|
|
1802
|
+
* Position updates
|
|
1803
|
+
*/
|
|
1804
|
+
positions: (data: any) => void;
|
|
1805
|
+
/**
|
|
1806
|
+
* Transaction events (blockchain confirmations)
|
|
1807
|
+
*/
|
|
1808
|
+
tx: (data: TransactionEvent) => void;
|
|
1809
|
+
/**
|
|
1810
|
+
* Price updates (deprecated - use newPriceData)
|
|
1811
|
+
* @deprecated
|
|
1299
1812
|
*/
|
|
1300
1813
|
price: (data: PriceUpdate) => void;
|
|
1301
1814
|
}
|
|
@@ -1392,16 +1905,64 @@ interface HttpClientConfig {
|
|
|
1392
1905
|
* Request timeout in milliseconds
|
|
1393
1906
|
* @defaultValue 30000
|
|
1394
1907
|
*/
|
|
1395
|
-
timeout?: number;
|
|
1908
|
+
timeout?: number;
|
|
1909
|
+
/**
|
|
1910
|
+
* Session cookie for authenticated requests
|
|
1911
|
+
*/
|
|
1912
|
+
sessionCookie?: string;
|
|
1913
|
+
/**
|
|
1914
|
+
* Optional logger for debugging
|
|
1915
|
+
* @defaultValue NoOpLogger (no logging)
|
|
1916
|
+
*/
|
|
1917
|
+
logger?: ILogger;
|
|
1918
|
+
/**
|
|
1919
|
+
* Enable HTTP connection pooling with keepAlive
|
|
1920
|
+
* @defaultValue true
|
|
1921
|
+
* @remarks
|
|
1922
|
+
* When enabled, HTTP connections are reused across requests, reducing latency by 30-50%.
|
|
1923
|
+
* Recommended for production environments with high request volume.
|
|
1924
|
+
*/
|
|
1925
|
+
keepAlive?: boolean;
|
|
1926
|
+
/**
|
|
1927
|
+
* Maximum number of sockets to allow per host
|
|
1928
|
+
* @defaultValue 50
|
|
1929
|
+
* @remarks
|
|
1930
|
+
* Controls the connection pool size. Higher values allow more concurrent requests
|
|
1931
|
+
* but consume more system resources.
|
|
1932
|
+
*/
|
|
1933
|
+
maxSockets?: number;
|
|
1934
|
+
/**
|
|
1935
|
+
* Maximum number of free sockets to keep open per host
|
|
1936
|
+
* @defaultValue 10
|
|
1937
|
+
* @remarks
|
|
1938
|
+
* Determines how many idle connections to maintain in the pool.
|
|
1939
|
+
* Keeping connections open reduces latency for subsequent requests.
|
|
1940
|
+
*/
|
|
1941
|
+
maxFreeSockets?: number;
|
|
1396
1942
|
/**
|
|
1397
|
-
*
|
|
1943
|
+
* Socket timeout in milliseconds
|
|
1944
|
+
* @defaultValue 60000
|
|
1945
|
+
* @remarks
|
|
1946
|
+
* Time to wait before closing an idle socket connection.
|
|
1398
1947
|
*/
|
|
1399
|
-
|
|
1948
|
+
socketTimeout?: number;
|
|
1400
1949
|
/**
|
|
1401
|
-
*
|
|
1402
|
-
* @
|
|
1950
|
+
* Additional headers to include in all requests
|
|
1951
|
+
* @remarks
|
|
1952
|
+
* These headers will be merged with default headers and sent with every request.
|
|
1953
|
+
* Can be overridden by per-request headers.
|
|
1954
|
+
*
|
|
1955
|
+
* @example
|
|
1956
|
+
* ```typescript
|
|
1957
|
+
* const client = new HttpClient({
|
|
1958
|
+
* additionalHeaders: {
|
|
1959
|
+
* 'X-Custom-Header': 'value',
|
|
1960
|
+
* 'X-API-Version': 'v1'
|
|
1961
|
+
* }
|
|
1962
|
+
* });
|
|
1963
|
+
* ```
|
|
1403
1964
|
*/
|
|
1404
|
-
|
|
1965
|
+
additionalHeaders?: Record<string, string>;
|
|
1405
1966
|
}
|
|
1406
1967
|
/**
|
|
1407
1968
|
* HTTP client wrapper for Limitless Exchange API.
|
|
@@ -2014,22 +2575,34 @@ declare const SIGNING_MESSAGE_TEMPLATE = "Welcome to Limitless.exchange! Please
|
|
|
2014
2575
|
declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
2015
2576
|
/**
|
|
2016
2577
|
* Contract addresses by network
|
|
2578
|
+
*
|
|
2579
|
+
* @remarks
|
|
2580
|
+
* Note: CLOB and NegRisk exchange addresses are provided dynamically via the venue system
|
|
2581
|
+
* (market.venue.exchange and market.venue.adapter). These addresses vary per market and
|
|
2582
|
+
* should be fetched from the API rather than hardcoded.
|
|
2583
|
+
*
|
|
2017
2584
|
* @public
|
|
2018
2585
|
*/
|
|
2019
2586
|
declare const CONTRACT_ADDRESSES: {
|
|
2020
2587
|
readonly 8453: {
|
|
2021
|
-
readonly
|
|
2022
|
-
readonly
|
|
2588
|
+
readonly USDC: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
2589
|
+
readonly CTF: "0xC9c98965297Bc527861c898329Ee280632B76e18";
|
|
2023
2590
|
};
|
|
2024
2591
|
readonly 84532: {
|
|
2025
|
-
readonly
|
|
2026
|
-
readonly
|
|
2592
|
+
readonly USDC: "0x...";
|
|
2593
|
+
readonly CTF: "0x...";
|
|
2027
2594
|
};
|
|
2028
2595
|
};
|
|
2029
2596
|
/**
|
|
2030
|
-
* Get contract address for
|
|
2597
|
+
* Get contract address for tokens (USDC or CTF)
|
|
2598
|
+
*
|
|
2599
|
+
* @remarks
|
|
2600
|
+
* For CLOB and NegRisk exchange addresses, use the venue system instead:
|
|
2601
|
+
* - Fetch market via `marketFetcher.getMarket(slug)`
|
|
2602
|
+
* - Use `market.venue.exchange` for signing and approvals
|
|
2603
|
+
* - Use `market.venue.adapter` for NegRisk adapter approvals
|
|
2031
2604
|
*
|
|
2032
|
-
* @param
|
|
2605
|
+
* @param contractType - Contract type (USDC or CTF)
|
|
2033
2606
|
* @param chainId - Chain ID (default: 8453 for Base mainnet)
|
|
2034
2607
|
* @returns Contract address
|
|
2035
2608
|
*
|
|
@@ -2037,7 +2610,7 @@ declare const CONTRACT_ADDRESSES: {
|
|
|
2037
2610
|
*
|
|
2038
2611
|
* @public
|
|
2039
2612
|
*/
|
|
2040
|
-
declare function getContractAddress(
|
|
2613
|
+
declare function getContractAddress(contractType: 'USDC' | 'CTF', chainId?: number): string;
|
|
2041
2614
|
|
|
2042
2615
|
/**
|
|
2043
2616
|
* Order builder for constructing unsigned order payloads.
|
|
@@ -2101,8 +2674,7 @@ declare class OrderBuilder {
|
|
|
2101
2674
|
* const fokOrder = builder.buildOrder({
|
|
2102
2675
|
* tokenId: '123456',
|
|
2103
2676
|
* makerAmount: 50, // 50 USDC to spend
|
|
2104
|
-
* side: Side.BUY
|
|
2105
|
-
* marketType: MarketType.CLOB
|
|
2677
|
+
* side: Side.BUY
|
|
2106
2678
|
* });
|
|
2107
2679
|
*
|
|
2108
2680
|
* // GTC order (price + size)
|
|
@@ -2110,8 +2682,7 @@ declare class OrderBuilder {
|
|
|
2110
2682
|
* tokenId: '123456',
|
|
2111
2683
|
* price: 0.38,
|
|
2112
2684
|
* size: 22.123, // Will be rounded to tick-aligned: 22.123 shares
|
|
2113
|
-
* side: Side.BUY
|
|
2114
|
-
* marketType: MarketType.CLOB
|
|
2685
|
+
* side: Side.BUY
|
|
2115
2686
|
* });
|
|
2116
2687
|
* ```
|
|
2117
2688
|
*/
|
|
@@ -2265,8 +2836,7 @@ declare class OrderSigner {
|
|
|
2265
2836
|
* ```typescript
|
|
2266
2837
|
* const signature = await signer.signOrder(unsignedOrder, {
|
|
2267
2838
|
* chainId: 8453,
|
|
2268
|
-
* contractAddress: '0x...'
|
|
2269
|
-
* marketType: MarketType.CLOB
|
|
2839
|
+
* contractAddress: '0x...'
|
|
2270
2840
|
* });
|
|
2271
2841
|
* ```
|
|
2272
2842
|
*/
|
|
@@ -2353,6 +2923,139 @@ declare function validateUnsignedOrder(order: UnsignedOrder): void;
|
|
|
2353
2923
|
*/
|
|
2354
2924
|
declare function validateSignedOrder(order: SignedOrder): void;
|
|
2355
2925
|
|
|
2926
|
+
/**
|
|
2927
|
+
* Market data fetcher for Limitless Exchange.
|
|
2928
|
+
* @module markets/fetcher
|
|
2929
|
+
*/
|
|
2930
|
+
|
|
2931
|
+
/**
|
|
2932
|
+
* Market data fetcher for retrieving market information and orderbooks.
|
|
2933
|
+
*
|
|
2934
|
+
* @remarks
|
|
2935
|
+
* This class provides methods to fetch market data, orderbooks, and prices
|
|
2936
|
+
* from the Limitless Exchange API.
|
|
2937
|
+
*
|
|
2938
|
+
* Venue caching: When fetching market data, venue information is automatically
|
|
2939
|
+
* cached for efficient order signing. This eliminates redundant API calls when
|
|
2940
|
+
* creating orders for the same market.
|
|
2941
|
+
*
|
|
2942
|
+
* @public
|
|
2943
|
+
*/
|
|
2944
|
+
declare class MarketFetcher {
|
|
2945
|
+
private httpClient;
|
|
2946
|
+
private logger;
|
|
2947
|
+
private venueCache;
|
|
2948
|
+
/**
|
|
2949
|
+
* Creates a new market fetcher instance.
|
|
2950
|
+
*
|
|
2951
|
+
* @param httpClient - HTTP client for API requests
|
|
2952
|
+
* @param logger - Optional logger for debugging (default: no logging)
|
|
2953
|
+
*
|
|
2954
|
+
* @example
|
|
2955
|
+
* ```typescript
|
|
2956
|
+
* const fetcher = new MarketFetcher(httpClient);
|
|
2957
|
+
* ```
|
|
2958
|
+
*/
|
|
2959
|
+
constructor(httpClient: HttpClient, logger?: ILogger);
|
|
2960
|
+
/**
|
|
2961
|
+
* Gets active markets with query parameters and pagination support.
|
|
2962
|
+
*
|
|
2963
|
+
* @param params - Query parameters for filtering and pagination
|
|
2964
|
+
* @returns Promise resolving to active markets response
|
|
2965
|
+
* @throws Error if API request fails
|
|
2966
|
+
*
|
|
2967
|
+
* @example
|
|
2968
|
+
* ```typescript
|
|
2969
|
+
* // Get 8 markets sorted by LP rewards
|
|
2970
|
+
* const response = await fetcher.getActiveMarkets({
|
|
2971
|
+
* limit: 8,
|
|
2972
|
+
* sortBy: 'lp_rewards'
|
|
2973
|
+
* });
|
|
2974
|
+
* console.log(`Found ${response.data.length} of ${response.totalMarketsCount} markets`);
|
|
2975
|
+
*
|
|
2976
|
+
* // Get page 2
|
|
2977
|
+
* const page2 = await fetcher.getActiveMarkets({
|
|
2978
|
+
* limit: 8,
|
|
2979
|
+
* page: 2,
|
|
2980
|
+
* sortBy: 'ending_soon'
|
|
2981
|
+
* });
|
|
2982
|
+
* ```
|
|
2983
|
+
*/
|
|
2984
|
+
getActiveMarkets(params?: ActiveMarketsParams): Promise<ActiveMarketsResponse>;
|
|
2985
|
+
/**
|
|
2986
|
+
* Gets a single market by slug.
|
|
2987
|
+
*
|
|
2988
|
+
* @remarks
|
|
2989
|
+
* Automatically caches venue information for efficient order signing.
|
|
2990
|
+
* Always call this method before creating orders to ensure venue data
|
|
2991
|
+
* is available and avoid additional API requests.
|
|
2992
|
+
*
|
|
2993
|
+
* @param slug - Market slug identifier
|
|
2994
|
+
* @returns Promise resolving to market details
|
|
2995
|
+
* @throws Error if API request fails or market not found
|
|
2996
|
+
*
|
|
2997
|
+
* @example
|
|
2998
|
+
* ```typescript
|
|
2999
|
+
* const market = await fetcher.getMarket('bitcoin-price-2024');
|
|
3000
|
+
* console.log(`Market: ${market.title}`);
|
|
3001
|
+
*
|
|
3002
|
+
* // Venue is now cached for order signing
|
|
3003
|
+
* await orderClient.createOrder({
|
|
3004
|
+
* marketSlug: 'bitcoin-price-2024',
|
|
3005
|
+
* ...
|
|
3006
|
+
* });
|
|
3007
|
+
* ```
|
|
3008
|
+
*/
|
|
3009
|
+
getMarket(slug: string): Promise<Market>;
|
|
3010
|
+
/**
|
|
3011
|
+
* Gets cached venue information for a market.
|
|
3012
|
+
*
|
|
3013
|
+
* @remarks
|
|
3014
|
+
* Returns venue data previously cached by getMarket() call.
|
|
3015
|
+
* Used internally by OrderClient for efficient order signing.
|
|
3016
|
+
*
|
|
3017
|
+
* @param slug - Market slug identifier
|
|
3018
|
+
* @returns Cached venue information, or undefined if not in cache
|
|
3019
|
+
*
|
|
3020
|
+
* @example
|
|
3021
|
+
* ```typescript
|
|
3022
|
+
* const venue = fetcher.getVenue('bitcoin-price-2024');
|
|
3023
|
+
* if (venue) {
|
|
3024
|
+
* console.log(`Exchange: ${venue.exchange}`);
|
|
3025
|
+
* }
|
|
3026
|
+
* ```
|
|
3027
|
+
*/
|
|
3028
|
+
getVenue(slug: string): Venue | undefined;
|
|
3029
|
+
/**
|
|
3030
|
+
* Gets the orderbook for a CLOB market.
|
|
3031
|
+
*
|
|
3032
|
+
* @param slug - Market slug identifier
|
|
3033
|
+
* @returns Promise resolving to orderbook data
|
|
3034
|
+
* @throws Error if API request fails
|
|
3035
|
+
*
|
|
3036
|
+
* @example
|
|
3037
|
+
* ```typescript
|
|
3038
|
+
* const orderbook = await fetcher.getOrderBook('bitcoin-price-2024');
|
|
3039
|
+
* console.log(`Bids: ${orderbook.bids.length}, Asks: ${orderbook.asks.length}`);
|
|
3040
|
+
* ```
|
|
3041
|
+
*/
|
|
3042
|
+
getOrderBook(slug: string): Promise<OrderBook>;
|
|
3043
|
+
/**
|
|
3044
|
+
* Gets the current price for a token.
|
|
3045
|
+
*
|
|
3046
|
+
* @param tokenId - Token ID
|
|
3047
|
+
* @returns Promise resolving to price information
|
|
3048
|
+
* @throws Error if API request fails
|
|
3049
|
+
*
|
|
3050
|
+
* @example
|
|
3051
|
+
* ```typescript
|
|
3052
|
+
* const price = await fetcher.getPrice('123456');
|
|
3053
|
+
* console.log(`Current price: ${price.price}`);
|
|
3054
|
+
* ```
|
|
3055
|
+
*/
|
|
3056
|
+
getPrice(tokenId: string): Promise<MarketPrice>;
|
|
3057
|
+
}
|
|
3058
|
+
|
|
2356
3059
|
/**
|
|
2357
3060
|
* Order client for managing orders on Limitless Exchange.
|
|
2358
3061
|
* @module orders/client
|
|
@@ -2362,9 +3065,11 @@ declare function validateSignedOrder(order: SignedOrder): void;
|
|
|
2362
3065
|
* Configuration for the order client.
|
|
2363
3066
|
*
|
|
2364
3067
|
* @remarks
|
|
2365
|
-
* The order client
|
|
2366
|
-
*
|
|
2367
|
-
*
|
|
3068
|
+
* The order client auto-configures signing based on venue data from the API.
|
|
3069
|
+
* Custom signingConfig is optional for advanced use cases.
|
|
3070
|
+
*
|
|
3071
|
+
* Performance tip: Provide a shared marketFetcher instance to enable venue caching
|
|
3072
|
+
* across market fetches and order creation, avoiding redundant API calls.
|
|
2368
3073
|
*
|
|
2369
3074
|
* @public
|
|
2370
3075
|
*/
|
|
@@ -2390,23 +3095,41 @@ interface OrderClientConfig {
|
|
|
2390
3095
|
*/
|
|
2391
3096
|
userData: UserData;
|
|
2392
3097
|
/**
|
|
2393
|
-
*
|
|
3098
|
+
* Custom signing configuration (optional)
|
|
2394
3099
|
*
|
|
2395
3100
|
* @remarks
|
|
2396
|
-
*
|
|
2397
|
-
*
|
|
2398
|
-
*
|
|
2399
|
-
* @defaultValue MarketType.CLOB
|
|
3101
|
+
* If not provided, SDK will auto-configure from venue data.
|
|
3102
|
+
* Useful for custom deployments or testing.
|
|
2400
3103
|
*/
|
|
2401
|
-
|
|
3104
|
+
signingConfig?: OrderSigningConfig;
|
|
2402
3105
|
/**
|
|
2403
|
-
*
|
|
3106
|
+
* Shared MarketFetcher instance for venue caching (optional)
|
|
2404
3107
|
*
|
|
2405
3108
|
* @remarks
|
|
2406
|
-
*
|
|
2407
|
-
*
|
|
3109
|
+
* When provided, enables efficient venue caching across market fetches and order creation.
|
|
3110
|
+
* If not provided, OrderClient creates its own internal MarketFetcher instance.
|
|
3111
|
+
*
|
|
3112
|
+
* Best practice: Share the same MarketFetcher instance between market operations
|
|
3113
|
+
* and order creation for optimal performance.
|
|
3114
|
+
*
|
|
3115
|
+
* @example
|
|
3116
|
+
* ```typescript
|
|
3117
|
+
* const marketFetcher = new MarketFetcher(httpClient);
|
|
3118
|
+
* const orderClient = new OrderClient({
|
|
3119
|
+
* httpClient,
|
|
3120
|
+
* wallet,
|
|
3121
|
+
* userData,
|
|
3122
|
+
* marketFetcher // Shared instance
|
|
3123
|
+
* });
|
|
3124
|
+
*
|
|
3125
|
+
* // Venue is cached
|
|
3126
|
+
* await marketFetcher.getMarket('bitcoin-2024');
|
|
3127
|
+
*
|
|
3128
|
+
* // Uses cached venue, no extra API call
|
|
3129
|
+
* await orderClient.createOrder({ marketSlug: 'bitcoin-2024', ... });
|
|
3130
|
+
* ```
|
|
2408
3131
|
*/
|
|
2409
|
-
|
|
3132
|
+
marketFetcher?: MarketFetcher;
|
|
2410
3133
|
/**
|
|
2411
3134
|
* Optional logger
|
|
2412
3135
|
*/
|
|
@@ -2419,17 +3142,21 @@ interface OrderClientConfig {
|
|
|
2419
3142
|
* This class provides high-level methods for order operations,
|
|
2420
3143
|
* abstracting away HTTP details and order signing complexity.
|
|
2421
3144
|
*
|
|
3145
|
+
* Uses dynamic venue addressing for EIP-712 order signing. For best performance,
|
|
3146
|
+
* always call marketFetcher.getMarket() before creating orders to cache venue data.
|
|
3147
|
+
*
|
|
2422
3148
|
* @example
|
|
2423
3149
|
* ```typescript
|
|
2424
3150
|
* const orderClient = new OrderClient({
|
|
2425
3151
|
* httpClient,
|
|
2426
3152
|
* wallet,
|
|
2427
|
-
*
|
|
2428
|
-
*
|
|
3153
|
+
* userData: {
|
|
3154
|
+
* userId: 123,
|
|
3155
|
+
* feeRateBps: 100
|
|
3156
|
+
* },
|
|
2429
3157
|
* signingConfig: {
|
|
2430
3158
|
* chainId: 8453,
|
|
2431
|
-
* contractAddress: '0x...'
|
|
2432
|
-
* marketType: MarketType.CLOB
|
|
3159
|
+
* contractAddress: '0x...'
|
|
2433
3160
|
* }
|
|
2434
3161
|
* });
|
|
2435
3162
|
*
|
|
@@ -2449,6 +3176,7 @@ declare class OrderClient {
|
|
|
2449
3176
|
private httpClient;
|
|
2450
3177
|
private orderBuilder;
|
|
2451
3178
|
private orderSigner;
|
|
3179
|
+
private marketFetcher;
|
|
2452
3180
|
private ownerId;
|
|
2453
3181
|
private signingConfig;
|
|
2454
3182
|
private logger;
|
|
@@ -2456,8 +3184,6 @@ declare class OrderClient {
|
|
|
2456
3184
|
* Creates a new order client instance.
|
|
2457
3185
|
*
|
|
2458
3186
|
* @param config - Order client configuration
|
|
2459
|
-
*
|
|
2460
|
-
* @throws Error if neither marketType nor signingConfig is provided
|
|
2461
3187
|
*/
|
|
2462
3188
|
constructor(config: OrderClientConfig);
|
|
2463
3189
|
/**
|
|
@@ -2465,24 +3191,31 @@ declare class OrderClient {
|
|
|
2465
3191
|
*
|
|
2466
3192
|
* @remarks
|
|
2467
3193
|
* This method handles the complete order creation flow:
|
|
2468
|
-
* 1.
|
|
2469
|
-
* 2.
|
|
2470
|
-
* 3.
|
|
3194
|
+
* 1. Resolve venue address (from cache or API)
|
|
3195
|
+
* 2. Build unsigned order
|
|
3196
|
+
* 3. Sign with EIP-712 using venue.exchange as verifyingContract
|
|
3197
|
+
* 4. Submit to API
|
|
3198
|
+
*
|
|
3199
|
+
* Performance best practice: Always call marketFetcher.getMarket(marketSlug)
|
|
3200
|
+
* before createOrder() to cache venue data and avoid additional API requests.
|
|
2471
3201
|
*
|
|
2472
3202
|
* @param params - Order parameters
|
|
2473
3203
|
* @returns Promise resolving to order response
|
|
2474
3204
|
*
|
|
2475
|
-
* @throws Error if order creation fails
|
|
3205
|
+
* @throws Error if order creation fails or venue not found
|
|
2476
3206
|
*
|
|
2477
3207
|
* @example
|
|
2478
3208
|
* ```typescript
|
|
3209
|
+
* // Best practice: fetch market first to cache venue
|
|
3210
|
+
* const market = await marketFetcher.getMarket('bitcoin-2024');
|
|
3211
|
+
*
|
|
2479
3212
|
* const order = await orderClient.createOrder({
|
|
2480
|
-
* tokenId:
|
|
3213
|
+
* tokenId: market.tokens.yes,
|
|
2481
3214
|
* price: 0.65,
|
|
2482
3215
|
* size: 100,
|
|
2483
3216
|
* side: Side.BUY,
|
|
2484
3217
|
* orderType: OrderType.GTC,
|
|
2485
|
-
* marketSlug: '
|
|
3218
|
+
* marketSlug: 'bitcoin-2024'
|
|
2486
3219
|
* });
|
|
2487
3220
|
*
|
|
2488
3221
|
* console.log(`Order created: ${order.order.id}`);
|
|
@@ -2593,104 +3326,6 @@ declare class OrderClient {
|
|
|
2593
3326
|
signOrder(order: UnsignedOrder): Promise<string>;
|
|
2594
3327
|
}
|
|
2595
3328
|
|
|
2596
|
-
/**
|
|
2597
|
-
* Market data fetcher for Limitless Exchange.
|
|
2598
|
-
* @module markets/fetcher
|
|
2599
|
-
*/
|
|
2600
|
-
|
|
2601
|
-
/**
|
|
2602
|
-
* Market data fetcher for retrieving market information and orderbooks.
|
|
2603
|
-
*
|
|
2604
|
-
* @remarks
|
|
2605
|
-
* This class provides methods to fetch market data, orderbooks, and prices
|
|
2606
|
-
* from the Limitless Exchange API.
|
|
2607
|
-
*
|
|
2608
|
-
* @public
|
|
2609
|
-
*/
|
|
2610
|
-
declare class MarketFetcher {
|
|
2611
|
-
private httpClient;
|
|
2612
|
-
private logger;
|
|
2613
|
-
/**
|
|
2614
|
-
* Creates a new market fetcher instance.
|
|
2615
|
-
*
|
|
2616
|
-
* @param httpClient - HTTP client for API requests
|
|
2617
|
-
* @param logger - Optional logger for debugging (default: no logging)
|
|
2618
|
-
*
|
|
2619
|
-
* @example
|
|
2620
|
-
* ```typescript
|
|
2621
|
-
* const fetcher = new MarketFetcher(httpClient);
|
|
2622
|
-
* ```
|
|
2623
|
-
*/
|
|
2624
|
-
constructor(httpClient: HttpClient, logger?: ILogger);
|
|
2625
|
-
/**
|
|
2626
|
-
* Gets active markets with query parameters and pagination support.
|
|
2627
|
-
*
|
|
2628
|
-
* @param params - Query parameters for filtering and pagination
|
|
2629
|
-
* @returns Promise resolving to active markets response
|
|
2630
|
-
* @throws Error if API request fails
|
|
2631
|
-
*
|
|
2632
|
-
* @example
|
|
2633
|
-
* ```typescript
|
|
2634
|
-
* // Get 8 markets sorted by LP rewards
|
|
2635
|
-
* const response = await fetcher.getActiveMarkets({
|
|
2636
|
-
* limit: 8,
|
|
2637
|
-
* sortBy: 'lp_rewards'
|
|
2638
|
-
* });
|
|
2639
|
-
* console.log(`Found ${response.data.length} of ${response.totalMarketsCount} markets`);
|
|
2640
|
-
*
|
|
2641
|
-
* // Get page 2
|
|
2642
|
-
* const page2 = await fetcher.getActiveMarkets({
|
|
2643
|
-
* limit: 8,
|
|
2644
|
-
* page: 2,
|
|
2645
|
-
* sortBy: 'ending_soon'
|
|
2646
|
-
* });
|
|
2647
|
-
* ```
|
|
2648
|
-
*/
|
|
2649
|
-
getActiveMarkets(params?: ActiveMarketsParams): Promise<ActiveMarketsResponse>;
|
|
2650
|
-
/**
|
|
2651
|
-
* Gets a single market by slug.
|
|
2652
|
-
*
|
|
2653
|
-
* @param slug - Market slug identifier
|
|
2654
|
-
* @returns Promise resolving to market details
|
|
2655
|
-
* @throws Error if API request fails or market not found
|
|
2656
|
-
*
|
|
2657
|
-
* @example
|
|
2658
|
-
* ```typescript
|
|
2659
|
-
* const market = await fetcher.getMarket('bitcoin-price-2024');
|
|
2660
|
-
* console.log(`Market: ${market.title}`);
|
|
2661
|
-
* ```
|
|
2662
|
-
*/
|
|
2663
|
-
getMarket(slug: string): Promise<Market>;
|
|
2664
|
-
/**
|
|
2665
|
-
* Gets the orderbook for a CLOB market.
|
|
2666
|
-
*
|
|
2667
|
-
* @param slug - Market slug identifier
|
|
2668
|
-
* @returns Promise resolving to orderbook data
|
|
2669
|
-
* @throws Error if API request fails
|
|
2670
|
-
*
|
|
2671
|
-
* @example
|
|
2672
|
-
* ```typescript
|
|
2673
|
-
* const orderbook = await fetcher.getOrderBook('bitcoin-price-2024');
|
|
2674
|
-
* console.log(`Bids: ${orderbook.bids.length}, Asks: ${orderbook.asks.length}`);
|
|
2675
|
-
* ```
|
|
2676
|
-
*/
|
|
2677
|
-
getOrderBook(slug: string): Promise<OrderBook>;
|
|
2678
|
-
/**
|
|
2679
|
-
* Gets the current price for a token.
|
|
2680
|
-
*
|
|
2681
|
-
* @param tokenId - Token ID
|
|
2682
|
-
* @returns Promise resolving to price information
|
|
2683
|
-
* @throws Error if API request fails
|
|
2684
|
-
*
|
|
2685
|
-
* @example
|
|
2686
|
-
* ```typescript
|
|
2687
|
-
* const price = await fetcher.getPrice('123456');
|
|
2688
|
-
* console.log(`Current price: ${price.price}`);
|
|
2689
|
-
* ```
|
|
2690
|
-
*/
|
|
2691
|
-
getPrice(tokenId: string): Promise<MarketPrice>;
|
|
2692
|
-
}
|
|
2693
|
-
|
|
2694
3329
|
/**
|
|
2695
3330
|
* Portfolio data fetcher for Limitless Exchange.
|
|
2696
3331
|
* @module portfolio/fetcher
|
|
@@ -3012,4 +3647,4 @@ declare class WebSocketClient {
|
|
|
3012
3647
|
private getChannelFromKey;
|
|
3013
3648
|
}
|
|
3014
3649
|
|
|
3015
|
-
export { type AMMPosition, APIError, type ActiveMarketsParams, type ActiveMarketsResponse, type ActiveMarketsSortBy, type AuthResult, AuthenticatedClient, type AuthenticatedClientConfig, Authenticator, BASE_SEPOLIA_CHAIN_ID, type BaseOrderArgs, type CLOBPosition, CONTRACT_ADDRESSES, type ClientType, ConsoleLogger, type CreatedOrder, DEFAULT_API_URL, DEFAULT_CHAIN_ID, DEFAULT_WS_URL, type FOKOrderArgs, type FillEvent, type GTCOrderArgs, HttpClient, type HttpClientConfig, type ILogger, type LatestTrade, type LoginOptions, type Market, MarketFetcher, type MarketOutcome, type MarketPrice,
|
|
3650
|
+
export { type AMMPosition, APIError, type ActiveMarketsParams, type ActiveMarketsResponse, type ActiveMarketsSortBy, type AmmPriceEntry, type AuthResult, AuthenticatedClient, type AuthenticatedClientConfig, Authenticator, BASE_SEPOLIA_CHAIN_ID, type BaseOrderArgs, type CLOBPosition, CONTRACT_ADDRESSES, type ClientType, type CollateralToken, ConsoleLogger, type CreatedOrder, DEFAULT_API_URL, DEFAULT_CHAIN_ID, DEFAULT_WS_URL, type FOKOrderArgs, type FillEvent, type GTCOrderArgs, HttpClient, type HttpClientConfig, type ILogger, type LatestTrade, type LoginOptions, type Market, type MarketCreator, MarketFetcher, type MarketMetadata, type MarketOutcome, type MarketPrice, type MarketSettings, type MarketTokens, type MarketUpdate, type MarketsResponse, MessageSigner, type ModeInfo, type NewOrderPayload, type NewPriceData, NoOpLogger, type OrderArgs, type OrderBook, OrderBuilder, OrderClient, type OrderClientConfig, type OrderMatch, type OrderResponse, OrderSigner, type OrderSigningConfig, OrderType, type OrderUpdate, type OrderbookData, type OrderbookEntry, type OrderbookUpdate, PortfolioFetcher, type PortfolioPositionsResponse, type PortfolioSummary, type Position, type PositionMarket, type PositionSide, type PriceOracleMetadata, type PriceUpdate, type ReferralData, RetryConfig, type RetryConfigOptions, RetryableClient, SIGNING_MESSAGE_TEMPLATE, Side, type SignatureHeaders, SignatureType, type SignedOrder, type SubscriptionChannel, type SubscriptionOptions, type TokenBalance, type TradeEvent, type TradePrices, type TradingMode, type TransactionEvent, type UnsignedOrder, type UserData, type UserProfile, type UserRank, ValidationError, type Venue, WebSocketClient, type WebSocketConfig, type WebSocketEvents, WebSocketState, ZERO_ADDRESS, getContractAddress, retryOnErrors, validateOrderArgs, validateSignedOrder, validateUnsignedOrder, withRetry };
|