@longdotxyz/shared 0.0.101 → 0.0.102
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.
|
@@ -5679,19 +5679,44 @@ export declare const rootContract: {
|
|
|
5679
5679
|
}, {
|
|
5680
5680
|
tokenInAddress: string;
|
|
5681
5681
|
}>;
|
|
5682
|
+
query: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
5683
|
+
amount: import("zod").ZodOptional<import("zod").ZodString>;
|
|
5684
|
+
tokenOut: import("zod").ZodOptional<import("zod").ZodString>;
|
|
5685
|
+
slippage: import("zod").ZodOptional<import("zod").ZodString>;
|
|
5686
|
+
sender: import("zod").ZodOptional<import("zod").ZodString>;
|
|
5687
|
+
recipient: import("zod").ZodOptional<import("zod").ZodString>;
|
|
5688
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
5689
|
+
amount?: string | undefined;
|
|
5690
|
+
tokenOut?: string | undefined;
|
|
5691
|
+
slippage?: string | undefined;
|
|
5692
|
+
sender?: string | undefined;
|
|
5693
|
+
recipient?: string | undefined;
|
|
5694
|
+
}, {
|
|
5695
|
+
amount?: string | undefined;
|
|
5696
|
+
tokenOut?: string | undefined;
|
|
5697
|
+
slippage?: string | undefined;
|
|
5698
|
+
sender?: string | undefined;
|
|
5699
|
+
recipient?: string | undefined;
|
|
5700
|
+
}>>;
|
|
5682
5701
|
method: "GET";
|
|
5683
5702
|
path: "/paths/:tokenInAddress";
|
|
5684
5703
|
responses: {
|
|
5685
|
-
200: import("zod").ZodObject<{
|
|
5704
|
+
200: import("zod").ZodUnion<[import("zod").ZodObject<{
|
|
5686
5705
|
token_address: import("zod").ZodString;
|
|
5687
5706
|
paths_count: import("zod").ZodNumber;
|
|
5688
5707
|
paths: import("zod").ZodArray<import("zod").ZodObject<{
|
|
5708
|
+
source: import("zod").ZodEnum<["codex", "kyber"]>;
|
|
5689
5709
|
start_token_address: import("zod").ZodString;
|
|
5690
5710
|
end_token_address: import("zod").ZodString;
|
|
5691
5711
|
score: import("zod").ZodNumber;
|
|
5692
|
-
total_liquidity_usd: import("zod").ZodNumber
|
|
5693
|
-
total_volume_usd: import("zod").ZodNumber
|
|
5694
|
-
bottleneck_liquidity_usd: import("zod").ZodNumber
|
|
5712
|
+
total_liquidity_usd: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
5713
|
+
total_volume_usd: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
5714
|
+
bottleneck_liquidity_usd: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
5715
|
+
encoded_calldata: import("zod").ZodOptional<import("zod").ZodString>;
|
|
5716
|
+
router_address: import("zod").ZodOptional<import("zod").ZodString>;
|
|
5717
|
+
amount_in: import("zod").ZodOptional<import("zod").ZodString>;
|
|
5718
|
+
amount_out: import("zod").ZodOptional<import("zod").ZodString>;
|
|
5719
|
+
gas_estimate: import("zod").ZodOptional<import("zod").ZodString>;
|
|
5695
5720
|
hops: import("zod").ZodArray<import("zod").ZodObject<{
|
|
5696
5721
|
pool_address: import("zod").ZodString;
|
|
5697
5722
|
token_in_address: import("zod").ZodString;
|
|
@@ -5724,12 +5749,10 @@ export declare const rootContract: {
|
|
|
5724
5749
|
liquidity_usd: number | null;
|
|
5725
5750
|
}>, "many">;
|
|
5726
5751
|
}, "strip", import("zod").ZodTypeAny, {
|
|
5752
|
+
source: "codex" | "kyber";
|
|
5727
5753
|
start_token_address: string;
|
|
5728
5754
|
end_token_address: string;
|
|
5729
5755
|
score: number;
|
|
5730
|
-
total_liquidity_usd: number;
|
|
5731
|
-
total_volume_usd: number;
|
|
5732
|
-
bottleneck_liquidity_usd: number;
|
|
5733
5756
|
hops: {
|
|
5734
5757
|
fee: number | null;
|
|
5735
5758
|
hooks: string | null;
|
|
@@ -5741,13 +5764,19 @@ export declare const rootContract: {
|
|
|
5741
5764
|
tick_spacing: number | null;
|
|
5742
5765
|
liquidity_usd: number | null;
|
|
5743
5766
|
}[];
|
|
5767
|
+
total_liquidity_usd?: number | undefined;
|
|
5768
|
+
total_volume_usd?: number | undefined;
|
|
5769
|
+
bottleneck_liquidity_usd?: number | undefined;
|
|
5770
|
+
encoded_calldata?: string | undefined;
|
|
5771
|
+
router_address?: string | undefined;
|
|
5772
|
+
amount_in?: string | undefined;
|
|
5773
|
+
amount_out?: string | undefined;
|
|
5774
|
+
gas_estimate?: string | undefined;
|
|
5744
5775
|
}, {
|
|
5776
|
+
source: "codex" | "kyber";
|
|
5745
5777
|
start_token_address: string;
|
|
5746
5778
|
end_token_address: string;
|
|
5747
5779
|
score: number;
|
|
5748
|
-
total_liquidity_usd: number;
|
|
5749
|
-
total_volume_usd: number;
|
|
5750
|
-
bottleneck_liquidity_usd: number;
|
|
5751
5780
|
hops: {
|
|
5752
5781
|
fee: number | null;
|
|
5753
5782
|
hooks: string | null;
|
|
@@ -5759,17 +5788,23 @@ export declare const rootContract: {
|
|
|
5759
5788
|
tick_spacing: number | null;
|
|
5760
5789
|
liquidity_usd: number | null;
|
|
5761
5790
|
}[];
|
|
5791
|
+
total_liquidity_usd?: number | undefined;
|
|
5792
|
+
total_volume_usd?: number | undefined;
|
|
5793
|
+
bottleneck_liquidity_usd?: number | undefined;
|
|
5794
|
+
encoded_calldata?: string | undefined;
|
|
5795
|
+
router_address?: string | undefined;
|
|
5796
|
+
amount_in?: string | undefined;
|
|
5797
|
+
amount_out?: string | undefined;
|
|
5798
|
+
gas_estimate?: string | undefined;
|
|
5762
5799
|
}>, "many">;
|
|
5763
5800
|
}, "strip", import("zod").ZodTypeAny, {
|
|
5764
5801
|
token_address: string;
|
|
5765
5802
|
paths_count: number;
|
|
5766
5803
|
paths: {
|
|
5804
|
+
source: "codex" | "kyber";
|
|
5767
5805
|
start_token_address: string;
|
|
5768
5806
|
end_token_address: string;
|
|
5769
5807
|
score: number;
|
|
5770
|
-
total_liquidity_usd: number;
|
|
5771
|
-
total_volume_usd: number;
|
|
5772
|
-
bottleneck_liquidity_usd: number;
|
|
5773
5808
|
hops: {
|
|
5774
5809
|
fee: number | null;
|
|
5775
5810
|
hooks: string | null;
|
|
@@ -5781,17 +5816,23 @@ export declare const rootContract: {
|
|
|
5781
5816
|
tick_spacing: number | null;
|
|
5782
5817
|
liquidity_usd: number | null;
|
|
5783
5818
|
}[];
|
|
5819
|
+
total_liquidity_usd?: number | undefined;
|
|
5820
|
+
total_volume_usd?: number | undefined;
|
|
5821
|
+
bottleneck_liquidity_usd?: number | undefined;
|
|
5822
|
+
encoded_calldata?: string | undefined;
|
|
5823
|
+
router_address?: string | undefined;
|
|
5824
|
+
amount_in?: string | undefined;
|
|
5825
|
+
amount_out?: string | undefined;
|
|
5826
|
+
gas_estimate?: string | undefined;
|
|
5784
5827
|
}[];
|
|
5785
5828
|
}, {
|
|
5786
5829
|
token_address: string;
|
|
5787
5830
|
paths_count: number;
|
|
5788
5831
|
paths: {
|
|
5832
|
+
source: "codex" | "kyber";
|
|
5789
5833
|
start_token_address: string;
|
|
5790
5834
|
end_token_address: string;
|
|
5791
5835
|
score: number;
|
|
5792
|
-
total_liquidity_usd: number;
|
|
5793
|
-
total_volume_usd: number;
|
|
5794
|
-
bottleneck_liquidity_usd: number;
|
|
5795
5836
|
hops: {
|
|
5796
5837
|
fee: number | null;
|
|
5797
5838
|
hooks: string | null;
|
|
@@ -5803,8 +5844,31 @@ export declare const rootContract: {
|
|
|
5803
5844
|
tick_spacing: number | null;
|
|
5804
5845
|
liquidity_usd: number | null;
|
|
5805
5846
|
}[];
|
|
5847
|
+
total_liquidity_usd?: number | undefined;
|
|
5848
|
+
total_volume_usd?: number | undefined;
|
|
5849
|
+
bottleneck_liquidity_usd?: number | undefined;
|
|
5850
|
+
encoded_calldata?: string | undefined;
|
|
5851
|
+
router_address?: string | undefined;
|
|
5852
|
+
amount_in?: string | undefined;
|
|
5853
|
+
amount_out?: string | undefined;
|
|
5854
|
+
gas_estimate?: string | undefined;
|
|
5806
5855
|
}[];
|
|
5807
|
-
}
|
|
5856
|
+
}>, import("zod").ZodObject<{
|
|
5857
|
+
amountOut: import("zod").ZodString;
|
|
5858
|
+
data: import("zod").ZodString;
|
|
5859
|
+
routerAddress: import("zod").ZodString;
|
|
5860
|
+
transactionValue: import("zod").ZodString;
|
|
5861
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
5862
|
+
amountOut: string;
|
|
5863
|
+
data: string;
|
|
5864
|
+
routerAddress: string;
|
|
5865
|
+
transactionValue: string;
|
|
5866
|
+
}, {
|
|
5867
|
+
amountOut: string;
|
|
5868
|
+
data: string;
|
|
5869
|
+
routerAddress: string;
|
|
5870
|
+
transactionValue: string;
|
|
5871
|
+
}>]>;
|
|
5808
5872
|
};
|
|
5809
5873
|
};
|
|
5810
5874
|
};
|
|
@@ -3,12 +3,18 @@ declare const FetchTokensPathsResponseSchema: z.ZodObject<{
|
|
|
3
3
|
token_address: z.ZodString;
|
|
4
4
|
paths_count: z.ZodNumber;
|
|
5
5
|
paths: z.ZodArray<z.ZodObject<{
|
|
6
|
+
source: z.ZodEnum<["codex", "kyber"]>;
|
|
6
7
|
start_token_address: z.ZodString;
|
|
7
8
|
end_token_address: z.ZodString;
|
|
8
9
|
score: z.ZodNumber;
|
|
9
|
-
total_liquidity_usd: z.ZodNumber
|
|
10
|
-
total_volume_usd: z.ZodNumber
|
|
11
|
-
bottleneck_liquidity_usd: z.ZodNumber
|
|
10
|
+
total_liquidity_usd: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
total_volume_usd: z.ZodOptional<z.ZodNumber>;
|
|
12
|
+
bottleneck_liquidity_usd: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
encoded_calldata: z.ZodOptional<z.ZodString>;
|
|
14
|
+
router_address: z.ZodOptional<z.ZodString>;
|
|
15
|
+
amount_in: z.ZodOptional<z.ZodString>;
|
|
16
|
+
amount_out: z.ZodOptional<z.ZodString>;
|
|
17
|
+
gas_estimate: z.ZodOptional<z.ZodString>;
|
|
12
18
|
hops: z.ZodArray<z.ZodObject<{
|
|
13
19
|
pool_address: z.ZodString;
|
|
14
20
|
token_in_address: z.ZodString;
|
|
@@ -41,12 +47,10 @@ declare const FetchTokensPathsResponseSchema: z.ZodObject<{
|
|
|
41
47
|
liquidity_usd: number | null;
|
|
42
48
|
}>, "many">;
|
|
43
49
|
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
source: "codex" | "kyber";
|
|
44
51
|
start_token_address: string;
|
|
45
52
|
end_token_address: string;
|
|
46
53
|
score: number;
|
|
47
|
-
total_liquidity_usd: number;
|
|
48
|
-
total_volume_usd: number;
|
|
49
|
-
bottleneck_liquidity_usd: number;
|
|
50
54
|
hops: {
|
|
51
55
|
fee: number | null;
|
|
52
56
|
hooks: string | null;
|
|
@@ -58,13 +62,19 @@ declare const FetchTokensPathsResponseSchema: z.ZodObject<{
|
|
|
58
62
|
tick_spacing: number | null;
|
|
59
63
|
liquidity_usd: number | null;
|
|
60
64
|
}[];
|
|
65
|
+
total_liquidity_usd?: number | undefined;
|
|
66
|
+
total_volume_usd?: number | undefined;
|
|
67
|
+
bottleneck_liquidity_usd?: number | undefined;
|
|
68
|
+
encoded_calldata?: string | undefined;
|
|
69
|
+
router_address?: string | undefined;
|
|
70
|
+
amount_in?: string | undefined;
|
|
71
|
+
amount_out?: string | undefined;
|
|
72
|
+
gas_estimate?: string | undefined;
|
|
61
73
|
}, {
|
|
74
|
+
source: "codex" | "kyber";
|
|
62
75
|
start_token_address: string;
|
|
63
76
|
end_token_address: string;
|
|
64
77
|
score: number;
|
|
65
|
-
total_liquidity_usd: number;
|
|
66
|
-
total_volume_usd: number;
|
|
67
|
-
bottleneck_liquidity_usd: number;
|
|
68
78
|
hops: {
|
|
69
79
|
fee: number | null;
|
|
70
80
|
hooks: string | null;
|
|
@@ -76,17 +86,23 @@ declare const FetchTokensPathsResponseSchema: z.ZodObject<{
|
|
|
76
86
|
tick_spacing: number | null;
|
|
77
87
|
liquidity_usd: number | null;
|
|
78
88
|
}[];
|
|
89
|
+
total_liquidity_usd?: number | undefined;
|
|
90
|
+
total_volume_usd?: number | undefined;
|
|
91
|
+
bottleneck_liquidity_usd?: number | undefined;
|
|
92
|
+
encoded_calldata?: string | undefined;
|
|
93
|
+
router_address?: string | undefined;
|
|
94
|
+
amount_in?: string | undefined;
|
|
95
|
+
amount_out?: string | undefined;
|
|
96
|
+
gas_estimate?: string | undefined;
|
|
79
97
|
}>, "many">;
|
|
80
98
|
}, "strip", z.ZodTypeAny, {
|
|
81
99
|
token_address: string;
|
|
82
100
|
paths_count: number;
|
|
83
101
|
paths: {
|
|
102
|
+
source: "codex" | "kyber";
|
|
84
103
|
start_token_address: string;
|
|
85
104
|
end_token_address: string;
|
|
86
105
|
score: number;
|
|
87
|
-
total_liquidity_usd: number;
|
|
88
|
-
total_volume_usd: number;
|
|
89
|
-
bottleneck_liquidity_usd: number;
|
|
90
106
|
hops: {
|
|
91
107
|
fee: number | null;
|
|
92
108
|
hooks: string | null;
|
|
@@ -98,17 +114,23 @@ declare const FetchTokensPathsResponseSchema: z.ZodObject<{
|
|
|
98
114
|
tick_spacing: number | null;
|
|
99
115
|
liquidity_usd: number | null;
|
|
100
116
|
}[];
|
|
117
|
+
total_liquidity_usd?: number | undefined;
|
|
118
|
+
total_volume_usd?: number | undefined;
|
|
119
|
+
bottleneck_liquidity_usd?: number | undefined;
|
|
120
|
+
encoded_calldata?: string | undefined;
|
|
121
|
+
router_address?: string | undefined;
|
|
122
|
+
amount_in?: string | undefined;
|
|
123
|
+
amount_out?: string | undefined;
|
|
124
|
+
gas_estimate?: string | undefined;
|
|
101
125
|
}[];
|
|
102
126
|
}, {
|
|
103
127
|
token_address: string;
|
|
104
128
|
paths_count: number;
|
|
105
129
|
paths: {
|
|
130
|
+
source: "codex" | "kyber";
|
|
106
131
|
start_token_address: string;
|
|
107
132
|
end_token_address: string;
|
|
108
133
|
score: number;
|
|
109
|
-
total_liquidity_usd: number;
|
|
110
|
-
total_volume_usd: number;
|
|
111
|
-
bottleneck_liquidity_usd: number;
|
|
112
134
|
hops: {
|
|
113
135
|
fee: number | null;
|
|
114
136
|
hooks: string | null;
|
|
@@ -120,8 +142,32 @@ declare const FetchTokensPathsResponseSchema: z.ZodObject<{
|
|
|
120
142
|
tick_spacing: number | null;
|
|
121
143
|
liquidity_usd: number | null;
|
|
122
144
|
}[];
|
|
145
|
+
total_liquidity_usd?: number | undefined;
|
|
146
|
+
total_volume_usd?: number | undefined;
|
|
147
|
+
bottleneck_liquidity_usd?: number | undefined;
|
|
148
|
+
encoded_calldata?: string | undefined;
|
|
149
|
+
router_address?: string | undefined;
|
|
150
|
+
amount_in?: string | undefined;
|
|
151
|
+
amount_out?: string | undefined;
|
|
152
|
+
gas_estimate?: string | undefined;
|
|
123
153
|
}[];
|
|
124
154
|
}>;
|
|
155
|
+
declare const KyberSwapResponseSchema: z.ZodObject<{
|
|
156
|
+
amountOut: z.ZodString;
|
|
157
|
+
data: z.ZodString;
|
|
158
|
+
routerAddress: z.ZodString;
|
|
159
|
+
transactionValue: z.ZodString;
|
|
160
|
+
}, "strip", z.ZodTypeAny, {
|
|
161
|
+
amountOut: string;
|
|
162
|
+
data: string;
|
|
163
|
+
routerAddress: string;
|
|
164
|
+
transactionValue: string;
|
|
165
|
+
}, {
|
|
166
|
+
amountOut: string;
|
|
167
|
+
data: string;
|
|
168
|
+
routerAddress: string;
|
|
169
|
+
transactionValue: string;
|
|
170
|
+
}>;
|
|
125
171
|
declare const pathfindingContract: {
|
|
126
172
|
fetchTokenPaths: {
|
|
127
173
|
pathParams: z.ZodObject<{
|
|
@@ -131,19 +177,44 @@ declare const pathfindingContract: {
|
|
|
131
177
|
}, {
|
|
132
178
|
tokenInAddress: string;
|
|
133
179
|
}>;
|
|
180
|
+
query: z.ZodOptional<z.ZodObject<{
|
|
181
|
+
amount: z.ZodOptional<z.ZodString>;
|
|
182
|
+
tokenOut: z.ZodOptional<z.ZodString>;
|
|
183
|
+
slippage: z.ZodOptional<z.ZodString>;
|
|
184
|
+
sender: z.ZodOptional<z.ZodString>;
|
|
185
|
+
recipient: z.ZodOptional<z.ZodString>;
|
|
186
|
+
}, "strip", z.ZodTypeAny, {
|
|
187
|
+
amount?: string | undefined;
|
|
188
|
+
tokenOut?: string | undefined;
|
|
189
|
+
slippage?: string | undefined;
|
|
190
|
+
sender?: string | undefined;
|
|
191
|
+
recipient?: string | undefined;
|
|
192
|
+
}, {
|
|
193
|
+
amount?: string | undefined;
|
|
194
|
+
tokenOut?: string | undefined;
|
|
195
|
+
slippage?: string | undefined;
|
|
196
|
+
sender?: string | undefined;
|
|
197
|
+
recipient?: string | undefined;
|
|
198
|
+
}>>;
|
|
134
199
|
method: "GET";
|
|
135
200
|
path: "/paths/:tokenInAddress";
|
|
136
201
|
responses: {
|
|
137
|
-
200: z.ZodObject<{
|
|
202
|
+
200: z.ZodUnion<[z.ZodObject<{
|
|
138
203
|
token_address: z.ZodString;
|
|
139
204
|
paths_count: z.ZodNumber;
|
|
140
205
|
paths: z.ZodArray<z.ZodObject<{
|
|
206
|
+
source: z.ZodEnum<["codex", "kyber"]>;
|
|
141
207
|
start_token_address: z.ZodString;
|
|
142
208
|
end_token_address: z.ZodString;
|
|
143
209
|
score: z.ZodNumber;
|
|
144
|
-
total_liquidity_usd: z.ZodNumber
|
|
145
|
-
total_volume_usd: z.ZodNumber
|
|
146
|
-
bottleneck_liquidity_usd: z.ZodNumber
|
|
210
|
+
total_liquidity_usd: z.ZodOptional<z.ZodNumber>;
|
|
211
|
+
total_volume_usd: z.ZodOptional<z.ZodNumber>;
|
|
212
|
+
bottleneck_liquidity_usd: z.ZodOptional<z.ZodNumber>;
|
|
213
|
+
encoded_calldata: z.ZodOptional<z.ZodString>;
|
|
214
|
+
router_address: z.ZodOptional<z.ZodString>;
|
|
215
|
+
amount_in: z.ZodOptional<z.ZodString>;
|
|
216
|
+
amount_out: z.ZodOptional<z.ZodString>;
|
|
217
|
+
gas_estimate: z.ZodOptional<z.ZodString>;
|
|
147
218
|
hops: z.ZodArray<z.ZodObject<{
|
|
148
219
|
pool_address: z.ZodString;
|
|
149
220
|
token_in_address: z.ZodString;
|
|
@@ -176,12 +247,10 @@ declare const pathfindingContract: {
|
|
|
176
247
|
liquidity_usd: number | null;
|
|
177
248
|
}>, "many">;
|
|
178
249
|
}, "strip", z.ZodTypeAny, {
|
|
250
|
+
source: "codex" | "kyber";
|
|
179
251
|
start_token_address: string;
|
|
180
252
|
end_token_address: string;
|
|
181
253
|
score: number;
|
|
182
|
-
total_liquidity_usd: number;
|
|
183
|
-
total_volume_usd: number;
|
|
184
|
-
bottleneck_liquidity_usd: number;
|
|
185
254
|
hops: {
|
|
186
255
|
fee: number | null;
|
|
187
256
|
hooks: string | null;
|
|
@@ -193,13 +262,19 @@ declare const pathfindingContract: {
|
|
|
193
262
|
tick_spacing: number | null;
|
|
194
263
|
liquidity_usd: number | null;
|
|
195
264
|
}[];
|
|
265
|
+
total_liquidity_usd?: number | undefined;
|
|
266
|
+
total_volume_usd?: number | undefined;
|
|
267
|
+
bottleneck_liquidity_usd?: number | undefined;
|
|
268
|
+
encoded_calldata?: string | undefined;
|
|
269
|
+
router_address?: string | undefined;
|
|
270
|
+
amount_in?: string | undefined;
|
|
271
|
+
amount_out?: string | undefined;
|
|
272
|
+
gas_estimate?: string | undefined;
|
|
196
273
|
}, {
|
|
274
|
+
source: "codex" | "kyber";
|
|
197
275
|
start_token_address: string;
|
|
198
276
|
end_token_address: string;
|
|
199
277
|
score: number;
|
|
200
|
-
total_liquidity_usd: number;
|
|
201
|
-
total_volume_usd: number;
|
|
202
|
-
bottleneck_liquidity_usd: number;
|
|
203
278
|
hops: {
|
|
204
279
|
fee: number | null;
|
|
205
280
|
hooks: string | null;
|
|
@@ -211,17 +286,23 @@ declare const pathfindingContract: {
|
|
|
211
286
|
tick_spacing: number | null;
|
|
212
287
|
liquidity_usd: number | null;
|
|
213
288
|
}[];
|
|
289
|
+
total_liquidity_usd?: number | undefined;
|
|
290
|
+
total_volume_usd?: number | undefined;
|
|
291
|
+
bottleneck_liquidity_usd?: number | undefined;
|
|
292
|
+
encoded_calldata?: string | undefined;
|
|
293
|
+
router_address?: string | undefined;
|
|
294
|
+
amount_in?: string | undefined;
|
|
295
|
+
amount_out?: string | undefined;
|
|
296
|
+
gas_estimate?: string | undefined;
|
|
214
297
|
}>, "many">;
|
|
215
298
|
}, "strip", z.ZodTypeAny, {
|
|
216
299
|
token_address: string;
|
|
217
300
|
paths_count: number;
|
|
218
301
|
paths: {
|
|
302
|
+
source: "codex" | "kyber";
|
|
219
303
|
start_token_address: string;
|
|
220
304
|
end_token_address: string;
|
|
221
305
|
score: number;
|
|
222
|
-
total_liquidity_usd: number;
|
|
223
|
-
total_volume_usd: number;
|
|
224
|
-
bottleneck_liquidity_usd: number;
|
|
225
306
|
hops: {
|
|
226
307
|
fee: number | null;
|
|
227
308
|
hooks: string | null;
|
|
@@ -233,17 +314,23 @@ declare const pathfindingContract: {
|
|
|
233
314
|
tick_spacing: number | null;
|
|
234
315
|
liquidity_usd: number | null;
|
|
235
316
|
}[];
|
|
317
|
+
total_liquidity_usd?: number | undefined;
|
|
318
|
+
total_volume_usd?: number | undefined;
|
|
319
|
+
bottleneck_liquidity_usd?: number | undefined;
|
|
320
|
+
encoded_calldata?: string | undefined;
|
|
321
|
+
router_address?: string | undefined;
|
|
322
|
+
amount_in?: string | undefined;
|
|
323
|
+
amount_out?: string | undefined;
|
|
324
|
+
gas_estimate?: string | undefined;
|
|
236
325
|
}[];
|
|
237
326
|
}, {
|
|
238
327
|
token_address: string;
|
|
239
328
|
paths_count: number;
|
|
240
329
|
paths: {
|
|
330
|
+
source: "codex" | "kyber";
|
|
241
331
|
start_token_address: string;
|
|
242
332
|
end_token_address: string;
|
|
243
333
|
score: number;
|
|
244
|
-
total_liquidity_usd: number;
|
|
245
|
-
total_volume_usd: number;
|
|
246
|
-
bottleneck_liquidity_usd: number;
|
|
247
334
|
hops: {
|
|
248
335
|
fee: number | null;
|
|
249
336
|
hooks: string | null;
|
|
@@ -255,9 +342,32 @@ declare const pathfindingContract: {
|
|
|
255
342
|
tick_spacing: number | null;
|
|
256
343
|
liquidity_usd: number | null;
|
|
257
344
|
}[];
|
|
345
|
+
total_liquidity_usd?: number | undefined;
|
|
346
|
+
total_volume_usd?: number | undefined;
|
|
347
|
+
bottleneck_liquidity_usd?: number | undefined;
|
|
348
|
+
encoded_calldata?: string | undefined;
|
|
349
|
+
router_address?: string | undefined;
|
|
350
|
+
amount_in?: string | undefined;
|
|
351
|
+
amount_out?: string | undefined;
|
|
352
|
+
gas_estimate?: string | undefined;
|
|
258
353
|
}[];
|
|
259
|
-
}
|
|
354
|
+
}>, z.ZodObject<{
|
|
355
|
+
amountOut: z.ZodString;
|
|
356
|
+
data: z.ZodString;
|
|
357
|
+
routerAddress: z.ZodString;
|
|
358
|
+
transactionValue: z.ZodString;
|
|
359
|
+
}, "strip", z.ZodTypeAny, {
|
|
360
|
+
amountOut: string;
|
|
361
|
+
data: string;
|
|
362
|
+
routerAddress: string;
|
|
363
|
+
transactionValue: string;
|
|
364
|
+
}, {
|
|
365
|
+
amountOut: string;
|
|
366
|
+
data: string;
|
|
367
|
+
routerAddress: string;
|
|
368
|
+
transactionValue: string;
|
|
369
|
+
}>]>;
|
|
260
370
|
};
|
|
261
371
|
};
|
|
262
372
|
};
|
|
263
|
-
export { pathfindingContract, FetchTokensPathsResponseSchema };
|
|
373
|
+
export { pathfindingContract, FetchTokensPathsResponseSchema, KyberSwapResponseSchema };
|
|
@@ -3,35 +3,50 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.FetchTokensPathsResponseSchema = exports.pathfindingContract = void 0;
|
|
6
|
+
exports.KyberSwapResponseSchema = exports.FetchTokensPathsResponseSchema = exports.pathfindingContract = void 0;
|
|
7
7
|
const core_1 = require("@ts-rest/core");
|
|
8
8
|
const zod_1 = __importDefault(require("zod"));
|
|
9
9
|
const types_1 = require("../types");
|
|
10
10
|
const contract = (0, core_1.initContract)();
|
|
11
|
+
const PathHopSchema = zod_1.default.object({
|
|
12
|
+
pool_address: zod_1.default.string(),
|
|
13
|
+
token_in_address: zod_1.default.string(),
|
|
14
|
+
token_out_address: zod_1.default.string(),
|
|
15
|
+
protocol: zod_1.default.string(),
|
|
16
|
+
fee: zod_1.default.number().nullable(),
|
|
17
|
+
tick_spacing: zod_1.default.number().nullable(),
|
|
18
|
+
hooks: zod_1.default.string().nullable(),
|
|
19
|
+
liquidity_usd: zod_1.default.number().nullable(),
|
|
20
|
+
volume_usd: zod_1.default.number().nullable(),
|
|
21
|
+
});
|
|
22
|
+
const PathSchema = zod_1.default.object({
|
|
23
|
+
source: zod_1.default.enum(["codex", "kyber"]),
|
|
24
|
+
start_token_address: zod_1.default.string(),
|
|
25
|
+
end_token_address: zod_1.default.string(),
|
|
26
|
+
score: zod_1.default.number().describe("Path score (sum of liquidity × volume for each hop)"),
|
|
27
|
+
total_liquidity_usd: zod_1.default.number().optional().describe("Total liquidity in USD"),
|
|
28
|
+
total_volume_usd: zod_1.default.number().optional().describe("Total volume in USD for the past 24 hours"),
|
|
29
|
+
bottleneck_liquidity_usd: zod_1.default.number().optional().describe("Liquidity of the bottleneck token in USD"),
|
|
30
|
+
encoded_calldata: zod_1.default.string().optional(),
|
|
31
|
+
router_address: zod_1.default.string().optional(),
|
|
32
|
+
amount_in: zod_1.default.string().optional(),
|
|
33
|
+
amount_out: zod_1.default.string().optional(),
|
|
34
|
+
gas_estimate: zod_1.default.string().optional(),
|
|
35
|
+
hops: zod_1.default.array(PathHopSchema),
|
|
36
|
+
});
|
|
11
37
|
const FetchTokensPathsResponseSchema = zod_1.default.object({
|
|
12
38
|
token_address: zod_1.default.string(),
|
|
13
39
|
paths_count: zod_1.default.number(),
|
|
14
|
-
paths: zod_1.default.array(
|
|
15
|
-
start_token_address: zod_1.default.string(),
|
|
16
|
-
end_token_address: zod_1.default.string(),
|
|
17
|
-
score: zod_1.default.number().describe("Path score (sum of liquidity × volume for each hop)"),
|
|
18
|
-
total_liquidity_usd: zod_1.default.number().describe("Total liquidity in USD"),
|
|
19
|
-
total_volume_usd: zod_1.default.number().describe("Total volume in USD for the past 24 hours"),
|
|
20
|
-
bottleneck_liquidity_usd: zod_1.default.number().describe("Liquidity of the bottleneck token in USD"),
|
|
21
|
-
hops: zod_1.default.array(zod_1.default.object({
|
|
22
|
-
pool_address: zod_1.default.string(),
|
|
23
|
-
token_in_address: zod_1.default.string(),
|
|
24
|
-
token_out_address: zod_1.default.string(),
|
|
25
|
-
protocol: zod_1.default.string(),
|
|
26
|
-
fee: zod_1.default.number().nullable(),
|
|
27
|
-
tick_spacing: zod_1.default.number().nullable(),
|
|
28
|
-
hooks: zod_1.default.string().nullable(),
|
|
29
|
-
liquidity_usd: zod_1.default.number().nullable(),
|
|
30
|
-
volume_usd: zod_1.default.number().nullable(),
|
|
31
|
-
})),
|
|
32
|
-
})),
|
|
40
|
+
paths: zod_1.default.array(PathSchema),
|
|
33
41
|
});
|
|
34
42
|
exports.FetchTokensPathsResponseSchema = FetchTokensPathsResponseSchema;
|
|
43
|
+
const KyberSwapResponseSchema = zod_1.default.object({
|
|
44
|
+
amountOut: zod_1.default.string(),
|
|
45
|
+
data: zod_1.default.string(),
|
|
46
|
+
routerAddress: zod_1.default.string(),
|
|
47
|
+
transactionValue: zod_1.default.string(),
|
|
48
|
+
});
|
|
49
|
+
exports.KyberSwapResponseSchema = KyberSwapResponseSchema;
|
|
35
50
|
const pathfindingContract = contract.router({
|
|
36
51
|
fetchTokenPaths: {
|
|
37
52
|
method: "GET",
|
|
@@ -39,8 +54,17 @@ const pathfindingContract = contract.router({
|
|
|
39
54
|
pathParams: zod_1.default.object({
|
|
40
55
|
tokenInAddress: types_1.hex,
|
|
41
56
|
}),
|
|
57
|
+
query: zod_1.default
|
|
58
|
+
.object({
|
|
59
|
+
amount: zod_1.default.string().optional(),
|
|
60
|
+
tokenOut: zod_1.default.string().optional(),
|
|
61
|
+
slippage: zod_1.default.string().optional(),
|
|
62
|
+
sender: zod_1.default.string().optional(),
|
|
63
|
+
recipient: zod_1.default.string().optional(),
|
|
64
|
+
})
|
|
65
|
+
.optional(),
|
|
42
66
|
responses: {
|
|
43
|
-
200: FetchTokensPathsResponseSchema,
|
|
67
|
+
200: zod_1.default.union([FetchTokensPathsResponseSchema, KyberSwapResponseSchema]),
|
|
44
68
|
},
|
|
45
69
|
},
|
|
46
70
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathfinding.contract.js","sourceRoot":"","sources":["../../src/contracts/pathfinding.contract.ts"],"names":[],"mappings":";;;;;;AAAA,wCAA6C;AAC7C,8CAAoB;AAEpB,oCAA+B;AAE/B,MAAM,QAAQ,GAAG,IAAA,mBAAY,GAAE,CAAC;AAEhC,MAAM,
|
|
1
|
+
{"version":3,"file":"pathfinding.contract.js","sourceRoot":"","sources":["../../src/contracts/pathfinding.contract.ts"],"names":[],"mappings":";;;;;;AAAA,wCAA6C;AAC7C,8CAAoB;AAEpB,oCAA+B;AAE/B,MAAM,QAAQ,GAAG,IAAA,mBAAY,GAAE,CAAC;AAEhC,MAAM,aAAa,GAAG,aAAC,CAAC,MAAM,CAAC;IAC3B,YAAY,EAAE,aAAC,CAAC,MAAM,EAAE;IACxB,gBAAgB,EAAE,aAAC,CAAC,MAAM,EAAE;IAC5B,iBAAiB,EAAE,aAAC,CAAC,MAAM,EAAE;IAC7B,QAAQ,EAAE,aAAC,CAAC,MAAM,EAAE;IACpB,GAAG,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC1B,YAAY,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACnC,KAAK,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,aAAa,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACpC,UAAU,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACpC,CAAC,CAAC;AAEH,MAAM,UAAU,GAAG,aAAC,CAAC,MAAM,CAAC;IACxB,MAAM,EAAE,aAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAClC,mBAAmB,EAAE,aAAC,CAAC,MAAM,EAAE;IAC/B,iBAAiB,EAAE,aAAC,CAAC,MAAM,EAAE;IAC7B,KAAK,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qDAAqD,CAAC;IACjF,mBAAmB,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wBAAwB,CAAC;IAC7E,gBAAgB,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,2CAA2C,CAAC;IAC7F,wBAAwB,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,0CAA0C,CAAC;IAEpG,gBAAgB,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACvC,cAAc,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACrC,SAAS,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,UAAU,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACjC,YAAY,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACnC,IAAI,EAAE,aAAC,CAAC,KAAK,CAAC,aAAa,CAAC;CAC/B,CAAC,CAAC;AAEH,MAAM,8BAA8B,GAAG,aAAC,CAAC,MAAM,CAAC;IAC5C,aAAa,EAAE,aAAC,CAAC,MAAM,EAAE;IACzB,WAAW,EAAE,aAAC,CAAC,MAAM,EAAE;IACvB,KAAK,EAAE,aAAC,CAAC,KAAK,CAAC,UAAU,CAAC;CAC7B,CAAC,CAAC;AA+B2B,wEAA8B;AA7B5D,MAAM,uBAAuB,GAAG,aAAC,CAAC,MAAM,CAAC;IACrC,SAAS,EAAE,aAAC,CAAC,MAAM,EAAE;IACrB,IAAI,EAAE,aAAC,CAAC,MAAM,EAAE;IAChB,aAAa,EAAE,aAAC,CAAC,MAAM,EAAE;IACzB,gBAAgB,EAAE,aAAC,CAAC,MAAM,EAAE;CAC/B,CAAC,CAAC;AAwB2D,0DAAuB;AAtBrF,MAAM,mBAAmB,GAAG,QAAQ,CAAC,MAAM,CAAC;IACxC,eAAe,EAAE;QACb,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,wBAAwB;QAC9B,UAAU,EAAE,aAAC,CAAC,MAAM,CAAC;YACjB,cAAc,EAAE,WAAG;SACtB,CAAC;QACF,KAAK,EAAE,aAAC;aACH,MAAM,CAAC;YACJ,MAAM,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YAC7B,QAAQ,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YAC/B,QAAQ,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YAC/B,MAAM,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YAC7B,SAAS,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;SACnC,CAAC;aACD,QAAQ,EAAE;QACf,SAAS,EAAE;YACP,GAAG,EAAE,aAAC,CAAC,KAAK,CAAC,CAAC,8BAA8B,EAAE,uBAAuB,CAAC,CAAC;SAC1E;KACJ;CACJ,CAAC,CAAC;AAEM,kDAAmB"}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -24,11 +24,12 @@ The library includes auto-generated GraphQL types and a ready-to-use SDK client.
|
|
|
24
24
|
### Basic Setup
|
|
25
25
|
|
|
26
26
|
```typescript
|
|
27
|
-
import { GraphQLClient } from
|
|
28
|
-
|
|
27
|
+
import { GraphQLClient } from "graphql-request";
|
|
28
|
+
|
|
29
|
+
import { getSdk } from "@longdotxyz/shared";
|
|
29
30
|
|
|
30
31
|
// Initialize GraphQL client
|
|
31
|
-
const client = new GraphQLClient(
|
|
32
|
+
const client = new GraphQLClient("https://graphql.long.xyz");
|
|
32
33
|
|
|
33
34
|
// Create SDK instance
|
|
34
35
|
const sdk = getSdk(client);
|
|
@@ -37,36 +38,30 @@ const sdk = getSdk(client);
|
|
|
37
38
|
### Example: Fetch Auction by Address
|
|
38
39
|
|
|
39
40
|
```typescript
|
|
40
|
-
import {
|
|
41
|
+
import { GetAuctionByAddressQuery, getSdk } from "@longdotxyz/shared";
|
|
41
42
|
|
|
42
43
|
// Query an auction
|
|
43
44
|
const { auction_pool } = await sdk.GetAuctionByAddress({
|
|
44
|
-
|
|
45
|
+
address: "0x123...",
|
|
45
46
|
});
|
|
46
47
|
|
|
47
48
|
// Type-safe access to auction data
|
|
48
49
|
if (auction_pool) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
console.log(auction_pool.auction_pool_address);
|
|
51
|
+
console.log(auction_pool.asset_address);
|
|
52
|
+
console.log(auction_pool.numeraire_address);
|
|
52
53
|
}
|
|
53
54
|
```
|
|
54
55
|
|
|
55
56
|
### Available GraphQL Types
|
|
56
57
|
|
|
57
58
|
```typescript
|
|
58
|
-
import type {
|
|
59
|
-
Asset,
|
|
60
|
-
AuctionPool,
|
|
61
|
-
GraduationPool,
|
|
62
|
-
Asset_Bool_Exp,
|
|
63
|
-
Asset_Order_By
|
|
64
|
-
} from '@longdotxyz/shared';
|
|
59
|
+
import type { Asset, Asset_Bool_Exp, Asset_Order_By, AuctionPool, GraduationPool } from "@longdotxyz/shared";
|
|
65
60
|
|
|
66
61
|
// Use types for type-safe queries
|
|
67
62
|
const assetFilter: Asset_Bool_Exp = {
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
chain_id: { _eq: 1 },
|
|
64
|
+
asset_address: { _ilike: "0x%" },
|
|
70
65
|
};
|
|
71
66
|
```
|
|
72
67
|
|
|
@@ -77,15 +72,16 @@ The library provides type-safe REST API contracts using [ts-rest](https://ts-res
|
|
|
77
72
|
### Initialize API Client
|
|
78
73
|
|
|
79
74
|
```typescript
|
|
80
|
-
import { initClient } from
|
|
81
|
-
|
|
75
|
+
import { initClient } from "@ts-rest/core";
|
|
76
|
+
|
|
77
|
+
import { rootContract } from "@longdotxyz/shared";
|
|
82
78
|
|
|
83
79
|
// Create typed API client
|
|
84
80
|
const apiClient = initClient(rootContract, {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
81
|
+
baseUrl: "https://api.long.xyz/v1",
|
|
82
|
+
baseHeaders: {
|
|
83
|
+
"Content-Type": "application/json",
|
|
84
|
+
},
|
|
89
85
|
});
|
|
90
86
|
```
|
|
91
87
|
|
|
@@ -94,37 +90,35 @@ const apiClient = initClient(rootContract, {
|
|
|
94
90
|
```typescript
|
|
95
91
|
// Get dynamic auction details
|
|
96
92
|
const auctionResponse = await apiClient.auctions.getDynamicAuction({
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
93
|
+
params: {
|
|
94
|
+
address: "0x123...",
|
|
95
|
+
},
|
|
100
96
|
});
|
|
101
97
|
|
|
102
98
|
if (auctionResponse.status === 200) {
|
|
103
|
-
|
|
104
|
-
|
|
99
|
+
const { auction_pool_address, auction_base_token_symbol } = auctionResponse.body.result;
|
|
100
|
+
console.log(`Pool: ${auction_pool_address}, Symbol: ${auction_base_token_symbol}`);
|
|
105
101
|
}
|
|
106
102
|
|
|
107
103
|
// Create dynamic auction
|
|
108
104
|
const createResponse = await apiClient.auctions.createDynamicAuction({
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
}
|
|
105
|
+
body: {
|
|
106
|
+
chain_id: 8453, // Base
|
|
107
|
+
template_id: "template_123",
|
|
108
|
+
metadata: {
|
|
109
|
+
token_name: "My Token",
|
|
110
|
+
token_symbol: "MTK",
|
|
111
|
+
token_uri: "ipfs://...",
|
|
112
|
+
migration_duration: 86400,
|
|
113
|
+
migration_beneficiaries: [{ address: "0xabc...", amount: 10000 }],
|
|
114
|
+
user_address: "0xdef...",
|
|
115
|
+
},
|
|
116
|
+
},
|
|
123
117
|
});
|
|
124
118
|
|
|
125
119
|
if (createResponse.status === 200) {
|
|
126
|
-
|
|
127
|
-
|
|
120
|
+
const { governance_factory, pool_initializer, liquidity_migrator } = createResponse.body.result;
|
|
121
|
+
console.log("Auction created with factories:", { governance_factory, pool_initializer });
|
|
128
122
|
}
|
|
129
123
|
```
|
|
130
124
|
|
|
@@ -133,83 +127,83 @@ if (createResponse.status === 200) {
|
|
|
133
127
|
```typescript
|
|
134
128
|
// V4 Exact Input Quote
|
|
135
129
|
const v4InputQuote = await apiClient.quotes.v4ExactInputSingle({
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
130
|
+
body: {
|
|
131
|
+
chain_id: 8453,
|
|
132
|
+
pool_key: {
|
|
133
|
+
currency0: "0x0000000000000000000000000000000000000000", // ETH
|
|
134
|
+
currency1: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC
|
|
135
|
+
fee: 500,
|
|
136
|
+
tick_spacing: 10,
|
|
137
|
+
hooks: "0x0000000000000000000000000000000000000000",
|
|
138
|
+
},
|
|
139
|
+
zero_for_one: true,
|
|
140
|
+
exact_amount: "1000000000000000000", // 1 ETH
|
|
141
|
+
hook_data: "0x", // Optional hook data
|
|
144
142
|
},
|
|
145
|
-
zero_for_one: true,
|
|
146
|
-
exact_amount: '1000000000000000000', // 1 ETH
|
|
147
|
-
hook_data: '0x' // Optional hook data
|
|
148
|
-
}
|
|
149
143
|
});
|
|
150
144
|
|
|
151
145
|
if (v4InputQuote.status === 200) {
|
|
152
|
-
|
|
153
|
-
|
|
146
|
+
console.log(`Output amount: ${v4InputQuote.body.result.amount_out}`);
|
|
147
|
+
console.log(`Gas estimate: ${v4InputQuote.body.result.gas_estimate}`);
|
|
154
148
|
}
|
|
155
149
|
|
|
156
150
|
// V4 Exact Output Quote
|
|
157
151
|
const v4OutputQuote = await apiClient.quotes.v4ExactOutputSingle({
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
152
|
+
body: {
|
|
153
|
+
chain_id: 8453,
|
|
154
|
+
pool_key: {
|
|
155
|
+
currency0: "0x0000000000000000000000000000000000000000", // ETH
|
|
156
|
+
currency1: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC
|
|
157
|
+
fee: 500,
|
|
158
|
+
tick_spacing: 10,
|
|
159
|
+
hooks: "0x0000000000000000000000000000000000000000",
|
|
160
|
+
},
|
|
161
|
+
zero_for_one: true,
|
|
162
|
+
exact_amount: "1000000000", // 1000 USDC output
|
|
163
|
+
hook_data: "0x", // Optional hook data
|
|
166
164
|
},
|
|
167
|
-
zero_for_one: true,
|
|
168
|
-
exact_amount: '1000000000', // 1000 USDC output
|
|
169
|
-
hook_data: '0x' // Optional hook data
|
|
170
|
-
}
|
|
171
165
|
});
|
|
172
166
|
|
|
173
167
|
if (v4OutputQuote.status === 200) {
|
|
174
|
-
|
|
175
|
-
|
|
168
|
+
console.log(`Input required: ${v4OutputQuote.body.result.amount_in}`);
|
|
169
|
+
console.log(`Gas estimate: ${v4OutputQuote.body.result.gas_estimate}`);
|
|
176
170
|
}
|
|
177
171
|
|
|
178
172
|
// V3 Exact Input Quote
|
|
179
173
|
const v3InputQuote = await apiClient.quotes.v3ExactInputSingle({
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
174
|
+
body: {
|
|
175
|
+
chain_id: 1,
|
|
176
|
+
token_in: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
|
|
177
|
+
token_out: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
|
|
178
|
+
amount_in: "1000000000000000000", // 1 WETH
|
|
179
|
+
fee: 500, // 0.05%
|
|
180
|
+
sqrt_price_limit_x96: "0", // Optional price limit
|
|
181
|
+
},
|
|
188
182
|
});
|
|
189
183
|
|
|
190
184
|
if (v3InputQuote.status === 200) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
185
|
+
console.log(`Output amount: ${v3InputQuote.body.result.amount_out}`);
|
|
186
|
+
console.log(`Price after: ${v3InputQuote.body.result.sqrt_price_x96_after}`);
|
|
187
|
+
console.log(`Ticks crossed: ${v3InputQuote.body.result.initialized_ticks_crossed}`);
|
|
188
|
+
console.log(`Gas estimate: ${v3InputQuote.body.result.gas_estimate}`);
|
|
195
189
|
}
|
|
196
190
|
|
|
197
191
|
// V3 Exact Output Quote
|
|
198
192
|
const v3OutputQuote = await apiClient.quotes.v3ExactOutputSingle({
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
193
|
+
body: {
|
|
194
|
+
chain_id: 1,
|
|
195
|
+
token_in: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
|
|
196
|
+
token_out: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
|
|
197
|
+
amount_out: "1000000000", // 1000 USDC
|
|
198
|
+
fee: 500, // 0.05%
|
|
199
|
+
},
|
|
206
200
|
});
|
|
207
201
|
|
|
208
202
|
if (v3OutputQuote.status === 200) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
203
|
+
console.log(`Input required: ${v3OutputQuote.body.result.amount_in}`);
|
|
204
|
+
console.log(`Price after: ${v3OutputQuote.body.result.sqrt_price_x96_after}`);
|
|
205
|
+
console.log(`Ticks crossed: ${v3OutputQuote.body.result.initialized_ticks_crossed}`);
|
|
206
|
+
console.log(`Gas estimate: ${v3OutputQuote.body.result.gas_estimate}`);
|
|
213
207
|
}
|
|
214
208
|
```
|
|
215
209
|
|
|
@@ -220,15 +214,15 @@ if (v3OutputQuote.status === 200) {
|
|
|
220
214
|
const communities = await apiClient.communities.fetchCommunities();
|
|
221
215
|
|
|
222
216
|
if (communities.status === 200) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
217
|
+
communities.body.result.forEach((community) => {
|
|
218
|
+
console.log(`${community.label}: ${community.description}`);
|
|
219
|
+
console.log(`Funding: ${community.funding_amount}`);
|
|
220
|
+
});
|
|
227
221
|
}
|
|
228
222
|
|
|
229
223
|
// Get specific community
|
|
230
224
|
const community = await apiClient.communities.getCommunity({
|
|
231
|
-
|
|
225
|
+
params: { id: 1 },
|
|
232
226
|
});
|
|
233
227
|
```
|
|
234
228
|
|
|
@@ -237,90 +231,144 @@ const community = await apiClient.communities.getCommunity({
|
|
|
237
231
|
```typescript
|
|
238
232
|
// Upload an image to IPFS
|
|
239
233
|
const formData = new FormData();
|
|
240
|
-
formData.append(
|
|
234
|
+
formData.append("image", imageFile); // imageFile is a File object
|
|
241
235
|
|
|
242
236
|
const imageUpload = await apiClient.ipfs.uploadImage({
|
|
243
|
-
|
|
237
|
+
body: formData,
|
|
244
238
|
});
|
|
245
239
|
|
|
246
240
|
if (imageUpload.status === 200) {
|
|
247
|
-
|
|
248
|
-
|
|
241
|
+
const imageHash = imageUpload.body.result;
|
|
242
|
+
console.log(`Image IPFS hash: ${imageHash}`);
|
|
249
243
|
}
|
|
250
244
|
|
|
251
245
|
// Upload metadata to IPFS
|
|
252
246
|
const metadataUpload = await apiClient.ipfs.uploadMetadata({
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
247
|
+
body: {
|
|
248
|
+
name: "My Token",
|
|
249
|
+
description: "Token description",
|
|
250
|
+
image_hash: imageHash, // From previous upload
|
|
251
|
+
social_links: [
|
|
252
|
+
{ label: "Twitter", url: "https://twitter.com/mytoken" },
|
|
253
|
+
{ label: "Discord", url: "https://discord.gg/mytoken" },
|
|
254
|
+
],
|
|
255
|
+
vesting_recipients: [
|
|
256
|
+
{ address: "0xabc...", amount: 5000 },
|
|
257
|
+
{ address: "0xdef...", amount: 5000 },
|
|
258
|
+
],
|
|
259
|
+
fee_receiver: "0x123...",
|
|
260
|
+
},
|
|
267
261
|
});
|
|
268
262
|
|
|
269
263
|
if (metadataUpload.status === 200) {
|
|
270
|
-
|
|
271
|
-
|
|
264
|
+
const metadataHash = metadataUpload.body.result;
|
|
265
|
+
console.log(`Metadata IPFS hash: ${metadataHash}`);
|
|
272
266
|
}
|
|
273
267
|
```
|
|
274
268
|
|
|
269
|
+
### Pathfinding Endpoints
|
|
270
|
+
|
|
271
|
+
#### Get Swap Paths
|
|
272
|
+
|
|
273
|
+
```typescript
|
|
274
|
+
import { apiClient } from "@longdotxyz/shared";
|
|
275
|
+
|
|
276
|
+
// Basic usage (Codex only)
|
|
277
|
+
const paths = await apiClient.pathfinding.fetchTokenPaths({
|
|
278
|
+
params: { tokenInAddress: "0xTokenAddress" },
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
// With Kyber fallback (when amount provided)
|
|
282
|
+
const pathsWithFallback = await apiClient.pathfinding.fetchTokenPaths({
|
|
283
|
+
params: { tokenInAddress: "0xTokenAddress" },
|
|
284
|
+
query: {
|
|
285
|
+
amount: "1000000000000000000", // 1 token in wei
|
|
286
|
+
tokenOut: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913", // Optional: USDC
|
|
287
|
+
},
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
if (pathsWithFallback.status === 200) {
|
|
291
|
+
const { paths, paths_count } = pathsWithFallback.body;
|
|
292
|
+
|
|
293
|
+
paths.forEach((path) => {
|
|
294
|
+
if (path.source === "kyber") {
|
|
295
|
+
// Kyber route includes executable calldata
|
|
296
|
+
console.log("Router:", path.router_address);
|
|
297
|
+
console.log("Calldata:", path.encoded_calldata);
|
|
298
|
+
console.log("Expected output:", path.amount_out);
|
|
299
|
+
} else {
|
|
300
|
+
// Codex route includes liquidity metrics
|
|
301
|
+
console.log("Liquidity:", path.total_liquidity_usd);
|
|
302
|
+
console.log("Volume:", path.total_volume_usd);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
**Query Parameters:**
|
|
309
|
+
|
|
310
|
+
- `amount` (optional): Swap amount in wei. When provided, enables Kyber fallback if Codex returns no paths.
|
|
311
|
+
- `tokenOut` (optional): Target token address. If omitted, queries all exit tokens (WETH, USDC, ETH on Base).
|
|
312
|
+
|
|
313
|
+
**Response Fields:**
|
|
314
|
+
|
|
315
|
+
- `source`: Either `"codex"` or `"kyber"` - indicates which service provided the route
|
|
316
|
+
- `encoded_calldata` (Kyber only): Ready-to-execute swap calldata
|
|
317
|
+
- `router_address` (Kyber only): Kyber router contract address
|
|
318
|
+
- `amount_in` (Kyber only): Input amount in wei
|
|
319
|
+
- `amount_out` (Kyber only): Expected output amount in wei
|
|
320
|
+
- `gas_estimate` (Kyber only): Estimated gas for the swap
|
|
321
|
+
|
|
275
322
|
## Type Utilities
|
|
276
323
|
|
|
277
324
|
### Pool Key Type (Uniswap V4)
|
|
278
325
|
|
|
279
326
|
```typescript
|
|
280
|
-
import { PoolKey } from
|
|
327
|
+
import { PoolKey } from "@longdotxyz/shared";
|
|
281
328
|
|
|
282
329
|
const poolKey: PoolKey = {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
330
|
+
currency0: "0x0000000000000000000000000000000000000000",
|
|
331
|
+
currency1: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
332
|
+
fee: 500,
|
|
333
|
+
tick_spacing: 10,
|
|
334
|
+
hooks: "0x0000000000000000000000000000000000000000",
|
|
288
335
|
};
|
|
289
336
|
```
|
|
290
337
|
|
|
291
338
|
### Hex Address Validation
|
|
292
339
|
|
|
293
340
|
```typescript
|
|
294
|
-
import {
|
|
295
|
-
|
|
341
|
+
import { z } from "zod";
|
|
342
|
+
|
|
343
|
+
import { hex } from "@longdotxyz/shared";
|
|
296
344
|
|
|
297
345
|
// Validate and normalize hex addresses
|
|
298
346
|
const addressSchema = z.string().pipe(hex);
|
|
299
|
-
const validAddress = addressSchema.parse(
|
|
347
|
+
const validAddress = addressSchema.parse("0xabc..."); // Returns lowercase hex
|
|
300
348
|
```
|
|
301
349
|
|
|
302
350
|
### BigInt Coercion
|
|
303
351
|
|
|
304
352
|
```typescript
|
|
305
|
-
import { coerceBigInt } from
|
|
353
|
+
import { coerceBigInt } from "@longdotxyz/shared";
|
|
306
354
|
|
|
307
|
-
const amount = coerceBigInt.parse(
|
|
355
|
+
const amount = coerceBigInt.parse("1000000000000000000"); // Returns bigint
|
|
308
356
|
const amount2 = coerceBigInt.parse(1000n); // Also accepts bigint
|
|
309
357
|
```
|
|
310
358
|
|
|
311
359
|
## Native Token Utilities
|
|
312
360
|
|
|
313
361
|
```typescript
|
|
314
|
-
import { isNativeToken, isNativeTokenAddress } from
|
|
362
|
+
import { isNativeToken, isNativeTokenAddress } from "@longdotxyz/shared";
|
|
315
363
|
|
|
316
364
|
// Check if address is native token (ETH)
|
|
317
|
-
isNativeTokenAddress(
|
|
318
|
-
isNativeTokenAddress(
|
|
365
|
+
isNativeTokenAddress("0x0000000000000000000000000000000000000000"); // true
|
|
366
|
+
isNativeTokenAddress("0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"); // true
|
|
319
367
|
|
|
320
368
|
// Check token object
|
|
321
369
|
isNativeToken({
|
|
322
|
-
|
|
323
|
-
|
|
370
|
+
address: "0x0000000000000000000000000000000000000000",
|
|
371
|
+
symbol: "ETH",
|
|
324
372
|
}); // true
|
|
325
373
|
```
|
|
326
374
|
|
|
@@ -362,4 +410,4 @@ All API contracts are defined using ts-rest and exported from `@longdotxyz/share
|
|
|
362
410
|
|
|
363
411
|
## License
|
|
364
412
|
|
|
365
|
-
UNLICENSED
|
|
413
|
+
UNLICENSED
|