Skip to content

Commit 4ab55f7

Browse files
authored
Fixing the exclusive resolver type on usion quote responses (#90)
1 parent 3b39461 commit 4ab55f7

File tree

3 files changed

+46
-21
lines changed

3 files changed

+46
-21
lines changed

sdk-clients/fusion/fusion_types_extended.go

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import (
1010

1111
type GetQuoteOutputFixed struct {
1212
// FeeToken Destination token address
13-
FeeToken string `json:"feeToken"`
14-
FromTokenAmount string `json:"fromTokenAmount"`
15-
Presets QuotePresetsClass `json:"presets"`
16-
Prices TokenPairValue `json:"prices"`
13+
FeeToken string `json:"feeToken"`
14+
FromTokenAmount string `json:"fromTokenAmount"`
15+
Presets QuotePresetsClassFixed `json:"presets"`
16+
Prices TokenPairValue `json:"prices"`
1717

1818
// QuoteId Current generated quote id, should be passed with order
1919
QuoteId string `json:"quoteId"` // TODO This field is marked as "object" instead of "string" in the swagger file. This is an easy fix from the Fusion team
@@ -263,3 +263,28 @@ type OrderResponse struct {
263263
Status string `json:"status"`
264264
ToTokenToUsdPrice string `json:"toTokenToUsdPrice"`
265265
}
266+
267+
// PresetClassFixed defines model for PresetClass.
268+
type PresetClassFixed struct {
269+
AllowMultipleFills bool `json:"allowMultipleFills"`
270+
AllowPartialFills bool `json:"allowPartialFills"`
271+
AuctionDuration float32 `json:"auctionDuration"`
272+
AuctionEndAmount string `json:"auctionEndAmount"`
273+
AuctionStartAmount string `json:"auctionStartAmount"`
274+
BankFee string `json:"bankFee"`
275+
EstP float32 `json:"estP"`
276+
ExclusiveResolver string `json:"exclusiveResolver"` // This was changed to a string from a map[string]interface{}
277+
GasCost GasCostConfigClass `json:"gasCost"`
278+
InitialRateBump float32 `json:"initialRateBump"`
279+
Points []AuctionPointClass `json:"points"`
280+
StartAuctionIn float32 `json:"startAuctionIn"`
281+
TokenFee string `json:"tokenFee"`
282+
}
283+
284+
// QuotePresetsClassFixed defines model for QuotePresetsClass.
285+
type QuotePresetsClassFixed struct {
286+
Custom *PresetClassFixed `json:"custom,omitempty"`
287+
Fast PresetClassFixed `json:"fast"`
288+
Medium PresetClassFixed `json:"medium"`
289+
Slow PresetClassFixed `json:"slow"`
290+
}

sdk-clients/fusion/order.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func BigIntFromString(s string) (*big.Int, error) {
160160
return bigInt, nil
161161
}
162162

163-
func getPreset(presets QuotePresetsClass, presetType GetQuoteOutputRecommendedPreset) (*PresetClass, error) {
163+
func getPreset(presets QuotePresetsClassFixed, presetType GetQuoteOutputRecommendedPreset) (*PresetClassFixed, error) {
164164
switch presetType {
165165
case Custom:
166166
if presets.Custom == nil {
@@ -184,7 +184,7 @@ func CalcAuctionStartTime(startAuctionIn uint32, additionalWaitPeriod uint32) ui
184184
return uint32(currentTime) + additionalWaitPeriod + startAuctionIn
185185
}
186186

187-
func CreateAuctionDetails(preset *PresetClass, additionalWaitPeriod float32) (*AuctionDetails, error) {
187+
func CreateAuctionDetails(preset *PresetClassFixed, additionalWaitPeriod float32) (*AuctionDetails, error) {
188188
pointsFixed := make([]AuctionPointClassFixed, 0)
189189
for _, point := range preset.Points {
190190
pointsFixed = append(pointsFixed, AuctionPointClassFixed{

sdk-clients/fusion/order_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,15 @@ func TestCreateFusionOrderData(t *testing.T) {
129129
}
130130

131131
func TestGetPreset(t *testing.T) {
132-
customPreset := &PresetClass{
132+
customPreset := &PresetClassFixed{
133133
AllowMultipleFills: true,
134134
AllowPartialFills: true,
135135
AuctionDuration: 10.0,
136136
AuctionEndAmount: "1000",
137137
AuctionStartAmount: "500",
138138
BankFee: "5",
139139
EstP: 0.1,
140-
ExclusiveResolver: map[string]interface{}{"resolver": "value"},
140+
ExclusiveResolver: "resolver",
141141
GasCost: GasCostConfigClass{
142142
GasBumpEstimate: 1.0,
143143
GasPriceEstimate: "100",
@@ -150,15 +150,15 @@ func TestGetPreset(t *testing.T) {
150150
TokenFee: "1",
151151
}
152152

153-
fastPreset := PresetClass{
153+
fastPreset := PresetClassFixed{
154154
AllowMultipleFills: false,
155155
AllowPartialFills: false,
156156
AuctionDuration: 20.0,
157157
AuctionEndAmount: "2000",
158158
AuctionStartAmount: "1000",
159159
BankFee: "10",
160160
EstP: 0.2,
161-
ExclusiveResolver: map[string]interface{}{"resolver": "value"},
161+
ExclusiveResolver: "resolver",
162162
GasCost: GasCostConfigClass{
163163
GasBumpEstimate: 2.0,
164164
GasPriceEstimate: "200",
@@ -171,15 +171,15 @@ func TestGetPreset(t *testing.T) {
171171
TokenFee: "2",
172172
}
173173

174-
mediumPreset := PresetClass{
174+
mediumPreset := PresetClassFixed{
175175
AllowMultipleFills: true,
176176
AllowPartialFills: false,
177177
AuctionDuration: 30.0,
178178
AuctionEndAmount: "3000",
179179
AuctionStartAmount: "1500",
180180
BankFee: "15",
181181
EstP: 0.3,
182-
ExclusiveResolver: map[string]interface{}{"resolver": "value"},
182+
ExclusiveResolver: "resolver",
183183
GasCost: GasCostConfigClass{
184184
GasBumpEstimate: 3.0,
185185
GasPriceEstimate: "300",
@@ -192,15 +192,15 @@ func TestGetPreset(t *testing.T) {
192192
TokenFee: "3",
193193
}
194194

195-
slowPreset := PresetClass{
195+
slowPreset := PresetClassFixed{
196196
AllowMultipleFills: false,
197197
AllowPartialFills: true,
198198
AuctionDuration: 40.0,
199199
AuctionEndAmount: "4000",
200200
AuctionStartAmount: "2000",
201201
BankFee: "20",
202202
EstP: 0.4,
203-
ExclusiveResolver: map[string]interface{}{"resolver": "value"},
203+
ExclusiveResolver: "resolver",
204204
GasCost: GasCostConfigClass{
205205
GasBumpEstimate: 4.0,
206206
GasPriceEstimate: "400",
@@ -213,7 +213,7 @@ func TestGetPreset(t *testing.T) {
213213
TokenFee: "4",
214214
}
215215

216-
presets := QuotePresetsClass{
216+
presets := QuotePresetsClassFixed{
217217
Custom: customPreset,
218218
Fast: fastPreset,
219219
Medium: mediumPreset,
@@ -223,7 +223,7 @@ func TestGetPreset(t *testing.T) {
223223
tests := []struct {
224224
name string
225225
presetType GetQuoteOutputRecommendedPreset
226-
expected *PresetClass
226+
expected *PresetClassFixed
227227
expectErr bool
228228
}{
229229
{
@@ -274,22 +274,22 @@ func TestGetPreset(t *testing.T) {
274274
func TestCreateAuctionDetails(t *testing.T) {
275275
tests := []struct {
276276
name string
277-
preset *PresetClass
277+
preset *PresetClassFixed
278278
additionalWaitPeriod float32
279279
expected *AuctionDetails
280280
expectErr bool
281281
}{
282282
{
283283
name: "Valid Preset",
284-
preset: &PresetClass{
284+
preset: &PresetClassFixed{
285285
AllowMultipleFills: true,
286286
AllowPartialFills: true,
287287
AuctionDuration: 60.0,
288288
AuctionEndAmount: "1000",
289289
AuctionStartAmount: "500",
290290
BankFee: "5",
291291
EstP: 0.1,
292-
ExclusiveResolver: map[string]interface{}{"resolver": "value"},
292+
ExclusiveResolver: "resolver",
293293
GasCost: GasCostConfigClass{
294294
GasBumpEstimate: 1.0,
295295
GasPriceEstimate: "100",
@@ -318,15 +318,15 @@ func TestCreateAuctionDetails(t *testing.T) {
318318
},
319319
{
320320
name: "Invalid Gas Price Estimate",
321-
preset: &PresetClass{
321+
preset: &PresetClassFixed{
322322
AllowMultipleFills: true,
323323
AllowPartialFills: true,
324324
AuctionDuration: 60.0,
325325
AuctionEndAmount: "1000",
326326
AuctionStartAmount: "500",
327327
BankFee: "5",
328328
EstP: 0.1,
329-
ExclusiveResolver: map[string]interface{}{"resolver": "value"},
329+
ExclusiveResolver: "resolver",
330330
GasCost: GasCostConfigClass{
331331
GasBumpEstimate: 1.0,
332332
GasPriceEstimate: "invalid",

0 commit comments

Comments
 (0)