@@ -12,7 +12,7 @@ import (
1212
1313// CreateOrder creates an order in the Limit Order Protocol
1414func (api * api ) CreateOrder (ctx context.Context , params CreateOrderParams ) (* CreateOrderResponse , error ) {
15- u := fmt .Sprintf ("/orderbook/v4.0 /%d" , api .chainId )
15+ u := fmt .Sprintf ("/orderbook/v4.1 /%d" , api .chainId )
1616
1717 err := params .Validate ()
1818 if err != nil {
@@ -49,8 +49,6 @@ func (api *api) CreateOrder(ctx context.Context, params CreateOrderParams) (*Cre
4949 return & createOrderResponse , nil
5050}
5151
52- // TODO Reusing the same request/response objects until the openapi spec is updated to include the correct object definitions
53-
5452// GetOrdersByCreatorAddress returns all orders created by a given address in the Limit Order Protocol
5553func (api * api ) GetOrdersByCreatorAddress (ctx context.Context , params GetOrdersByCreatorAddressParams ) ([]* OrderResponse , error ) {
5654 u := fmt .Sprintf ("/orderbook/v4.0/%d/address/%s" , api .chainId , params .CreatorAddress )
@@ -77,7 +75,7 @@ func (api *api) GetOrdersByCreatorAddress(ctx context.Context, params GetOrdersB
7775
7876// GetOrder returns an order from Limit Order Protocol that matches a specific hash
7977func (api * api ) GetOrder (ctx context.Context , params GetOrderParams ) (* GetOrderByHashResponseExtended , error ) {
80- u := fmt .Sprintf ("/orderbook/v4.0 /%d/order/%s" , api .chainId , params .OrderHash )
78+ u := fmt .Sprintf ("/orderbook/v4.1 /%d/order/%s" , api .chainId , params .OrderHash )
8179
8280 err := params .Validate ()
8381 if err != nil {
@@ -99,6 +97,30 @@ func (api *api) GetOrder(ctx context.Context, params GetOrderParams) (*GetOrderB
9997 return NormalizeGetOrderByHashResponse (getOrderByHashResponse )
10098}
10199
100+ // GetOrderCount returns the number of orders for a given trading pair with a specific status
101+ func (api * api ) GetOrderCount (ctx context.Context , params GetOrderCountParams ) (* GetOrderCountResponse , error ) {
102+ u := fmt .Sprintf ("/orderbook/v4.1/%d/count" , api .chainId )
103+
104+ err := params .Validate ()
105+ if err != nil {
106+ return nil , err
107+ }
108+
109+ payload := common.RequestPayload {
110+ Method : "GET" ,
111+ Params : params ,
112+ U : u ,
113+ }
114+
115+ var response GetOrderCountResponse
116+ err = api .httpExecutor .ExecuteRequest (ctx , payload , & response )
117+ if err != nil {
118+ return nil , err
119+ }
120+
121+ return & response , nil
122+ }
123+
102124// GetOrderWithSignature first looks up an order by hash, then does a second request to get the signature data
103125func (api * api ) GetOrderWithSignature (ctx context.Context , params GetOrderParams ) (* OrderExtendedWithSignature , error ) {
104126
@@ -115,7 +137,7 @@ func (api *api) GetOrderWithSignature(ctx context.Context, params GetOrderParams
115137
116138 // Second, lookup all orders by that creator (these orders will contain the signature data)
117139 allOrdersByCreator , err := api .GetOrdersByCreatorAddress (ctx , GetOrdersByCreatorAddressParams {
118- CreatorAddress : order .OrderMaker ,
140+ CreatorAddress : order .Data . Maker ,
119141 })
120142 if err != nil {
121143 return nil , err
@@ -136,8 +158,8 @@ func (api *api) GetOrderWithSignature(ctx context.Context, params GetOrderParams
136158}
137159
138160// GetAllOrders returns all orders in the Limit Order Protocol
139- func (api * api ) GetAllOrders (ctx context.Context , params GetAllOrdersParams ) ([] OrderResponse , error ) {
140- u := fmt .Sprintf ("/orderbook/v3.0 /%d/all" , api .chainId )
161+ func (api * api ) GetAllOrders (ctx context.Context , params GetAllOrdersParams ) (* Orders , error ) {
162+ u := fmt .Sprintf ("/orderbook/v4.1 /%d/all" , api .chainId )
141163
142164 err := params .Validate ()
143165 if err != nil {
@@ -150,92 +172,17 @@ func (api *api) GetAllOrders(ctx context.Context, params GetAllOrdersParams) ([]
150172 U : u ,
151173 }
152174
153- var allOrdersResponse [] OrderResponse
175+ var allOrdersResponse Orders
154176 err = api .httpExecutor .ExecuteRequest (ctx , payload , & allOrdersResponse )
155177 if err != nil {
156178 return nil , err
157179 }
158180
159- return allOrdersResponse , nil
160- }
161-
162- // GetCount returns the number of orders in the Limit Order Protocol
163- func (api * api ) GetCount (ctx context.Context , params GetCountParams ) (* CountResponse , error ) {
164- u := fmt .Sprintf ("/orderbook/v3.0/%d/count" , api .chainId )
165-
166- err := params .Validate ()
167- if err != nil {
168- return nil , err
169- }
170-
171- payload := common.RequestPayload {
172- Method : "GET" ,
173- Params : params ,
174- U : u ,
175- }
176-
177- var count CountResponse
178- err = api .httpExecutor .ExecuteRequest (ctx , payload , & count )
179- if err != nil {
180- return nil , err
181- }
182-
183- return & count , nil
181+ return & allOrdersResponse , nil
184182}
185183
186- // GetEvent returns an event in the Limit Order Protocol by order hash
187- func (api * api ) GetEvent (ctx context.Context , params GetEventParams ) (* EventResponse , error ) {
188- u := fmt .Sprintf ("/orderbook/v3.0/%d/events/%s" , api .chainId , params .OrderHash )
189-
190- err := params .Validate ()
191- if err != nil {
192- return nil , err
193- }
194-
195- payload := common.RequestPayload {
196- Method : "GET" ,
197- Params : params ,
198- U : u ,
199- }
200-
201- var event EventResponse
202- err = api .httpExecutor .ExecuteRequest (ctx , payload , & event )
203- if err != nil {
204- return nil , err
205- }
206-
207- return & event , nil
208- }
209-
210- // GetEvents returns all events in the Limit Order Protocol
211- func (api * api ) GetEvents (ctx context.Context , params GetEventsParams ) ([]EventResponse , error ) {
212- u := fmt .Sprintf ("/orderbook/v3.0/%d/events" , api .chainId )
213-
214- err := params .Validate ()
215- if err != nil {
216- return nil , err
217- }
218-
219- payload := common.RequestPayload {
220- Method : "GET" ,
221- Params : params ,
222- U : u ,
223- }
224-
225- var events []EventResponse
226- err = api .httpExecutor .ExecuteRequest (ctx , payload , & events )
227- if err != nil {
228- return nil , err
229- }
230-
231- return events , nil
232- }
233-
234- // TODO untested endpoint
235-
236- // GetActiveOrdersWithPermit returns all orders in the Limit Order Protocol that are active and have a valid permit
237- func (api * api ) GetActiveOrdersWithPermit (ctx context.Context , params GetActiveOrdersWithPermitParams ) ([]OrderResponse , error ) {
238- u := fmt .Sprintf ("/orderbook/v3.0/%d/has-active-orders-with-permit/%s/%s" , api .chainId , params .Token , params .Wallet )
184+ func (api * api ) GetFeeInfo (ctx context.Context , params GetFeeInfoParams ) (* FeeInfoResponse , error ) {
185+ u := fmt .Sprintf ("/orderbook/v4.0/%d/fee-info" , api .chainId )
239186
240187 err := params .Validate ()
241188 if err != nil {
@@ -248,11 +195,11 @@ func (api *api) GetActiveOrdersWithPermit(ctx context.Context, params GetActiveO
248195 U : u ,
249196 }
250197
251- var orders [] OrderResponse
252- err = api .httpExecutor .ExecuteRequest (ctx , payload , & orders )
198+ var feeInfo * FeeInfoResponse
199+ err = api .httpExecutor .ExecuteRequest (ctx , payload , & feeInfo )
253200 if err != nil {
254201 return nil , err
255202 }
256203
257- return orders , nil
204+ return feeInfo , nil
258205}
0 commit comments