Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing the exclusive resolver type on usion quote responses #90

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions sdk-clients/fusion/fusion_types_extended.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (

type GetQuoteOutputFixed struct {
// FeeToken Destination token address
FeeToken string `json:"feeToken"`
FromTokenAmount string `json:"fromTokenAmount"`
Presets QuotePresetsClass `json:"presets"`
Prices TokenPairValue `json:"prices"`
FeeToken string `json:"feeToken"`
FromTokenAmount string `json:"fromTokenAmount"`
Presets QuotePresetsClassFixed `json:"presets"`
Prices TokenPairValue `json:"prices"`

// QuoteId Current generated quote id, should be passed with order
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
Expand Down Expand Up @@ -263,3 +263,28 @@ type OrderResponse struct {
Status string `json:"status"`
ToTokenToUsdPrice string `json:"toTokenToUsdPrice"`
}

// PresetClassFixed defines model for PresetClass.
type PresetClassFixed struct {
AllowMultipleFills bool `json:"allowMultipleFills"`
AllowPartialFills bool `json:"allowPartialFills"`
AuctionDuration float32 `json:"auctionDuration"`
AuctionEndAmount string `json:"auctionEndAmount"`
AuctionStartAmount string `json:"auctionStartAmount"`
BankFee string `json:"bankFee"`
EstP float32 `json:"estP"`
ExclusiveResolver string `json:"exclusiveResolver"` // This was changed to a string from a map[string]interface{}
GasCost GasCostConfigClass `json:"gasCost"`
InitialRateBump float32 `json:"initialRateBump"`
Points []AuctionPointClass `json:"points"`
StartAuctionIn float32 `json:"startAuctionIn"`
TokenFee string `json:"tokenFee"`
}

// QuotePresetsClassFixed defines model for QuotePresetsClass.
type QuotePresetsClassFixed struct {
Custom *PresetClassFixed `json:"custom,omitempty"`
Fast PresetClassFixed `json:"fast"`
Medium PresetClassFixed `json:"medium"`
Slow PresetClassFixed `json:"slow"`
}
4 changes: 2 additions & 2 deletions sdk-clients/fusion/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func BigIntFromString(s string) (*big.Int, error) {
return bigInt, nil
}

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

func CreateAuctionDetails(preset *PresetClass, additionalWaitPeriod float32) (*AuctionDetails, error) {
func CreateAuctionDetails(preset *PresetClassFixed, additionalWaitPeriod float32) (*AuctionDetails, error) {
pointsFixed := make([]AuctionPointClassFixed, 0)
for _, point := range preset.Points {
pointsFixed = append(pointsFixed, AuctionPointClassFixed{
Expand Down
30 changes: 15 additions & 15 deletions sdk-clients/fusion/order_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ func TestCreateFusionOrderData(t *testing.T) {
}

func TestGetPreset(t *testing.T) {
customPreset := &PresetClass{
customPreset := &PresetClassFixed{
AllowMultipleFills: true,
AllowPartialFills: true,
AuctionDuration: 10.0,
AuctionEndAmount: "1000",
AuctionStartAmount: "500",
BankFee: "5",
EstP: 0.1,
ExclusiveResolver: map[string]interface{}{"resolver": "value"},
ExclusiveResolver: "resolver",
GasCost: GasCostConfigClass{
GasBumpEstimate: 1.0,
GasPriceEstimate: "100",
Expand All @@ -150,15 +150,15 @@ func TestGetPreset(t *testing.T) {
TokenFee: "1",
}

fastPreset := PresetClass{
fastPreset := PresetClassFixed{
AllowMultipleFills: false,
AllowPartialFills: false,
AuctionDuration: 20.0,
AuctionEndAmount: "2000",
AuctionStartAmount: "1000",
BankFee: "10",
EstP: 0.2,
ExclusiveResolver: map[string]interface{}{"resolver": "value"},
ExclusiveResolver: "resolver",
GasCost: GasCostConfigClass{
GasBumpEstimate: 2.0,
GasPriceEstimate: "200",
Expand All @@ -171,15 +171,15 @@ func TestGetPreset(t *testing.T) {
TokenFee: "2",
}

mediumPreset := PresetClass{
mediumPreset := PresetClassFixed{
AllowMultipleFills: true,
AllowPartialFills: false,
AuctionDuration: 30.0,
AuctionEndAmount: "3000",
AuctionStartAmount: "1500",
BankFee: "15",
EstP: 0.3,
ExclusiveResolver: map[string]interface{}{"resolver": "value"},
ExclusiveResolver: "resolver",
GasCost: GasCostConfigClass{
GasBumpEstimate: 3.0,
GasPriceEstimate: "300",
Expand All @@ -192,15 +192,15 @@ func TestGetPreset(t *testing.T) {
TokenFee: "3",
}

slowPreset := PresetClass{
slowPreset := PresetClassFixed{
AllowMultipleFills: false,
AllowPartialFills: true,
AuctionDuration: 40.0,
AuctionEndAmount: "4000",
AuctionStartAmount: "2000",
BankFee: "20",
EstP: 0.4,
ExclusiveResolver: map[string]interface{}{"resolver": "value"},
ExclusiveResolver: "resolver",
GasCost: GasCostConfigClass{
GasBumpEstimate: 4.0,
GasPriceEstimate: "400",
Expand All @@ -213,7 +213,7 @@ func TestGetPreset(t *testing.T) {
TokenFee: "4",
}

presets := QuotePresetsClass{
presets := QuotePresetsClassFixed{
Custom: customPreset,
Fast: fastPreset,
Medium: mediumPreset,
Expand All @@ -223,7 +223,7 @@ func TestGetPreset(t *testing.T) {
tests := []struct {
name string
presetType GetQuoteOutputRecommendedPreset
expected *PresetClass
expected *PresetClassFixed
expectErr bool
}{
{
Expand Down Expand Up @@ -274,22 +274,22 @@ func TestGetPreset(t *testing.T) {
func TestCreateAuctionDetails(t *testing.T) {
tests := []struct {
name string
preset *PresetClass
preset *PresetClassFixed
additionalWaitPeriod float32
expected *AuctionDetails
expectErr bool
}{
{
name: "Valid Preset",
preset: &PresetClass{
preset: &PresetClassFixed{
AllowMultipleFills: true,
AllowPartialFills: true,
AuctionDuration: 60.0,
AuctionEndAmount: "1000",
AuctionStartAmount: "500",
BankFee: "5",
EstP: 0.1,
ExclusiveResolver: map[string]interface{}{"resolver": "value"},
ExclusiveResolver: "resolver",
GasCost: GasCostConfigClass{
GasBumpEstimate: 1.0,
GasPriceEstimate: "100",
Expand Down Expand Up @@ -318,15 +318,15 @@ func TestCreateAuctionDetails(t *testing.T) {
},
{
name: "Invalid Gas Price Estimate",
preset: &PresetClass{
preset: &PresetClassFixed{
AllowMultipleFills: true,
AllowPartialFills: true,
AuctionDuration: 60.0,
AuctionEndAmount: "1000",
AuctionStartAmount: "500",
BankFee: "5",
EstP: 0.1,
ExclusiveResolver: map[string]interface{}{"resolver": "value"},
ExclusiveResolver: "resolver",
GasCost: GasCostConfigClass{
GasBumpEstimate: 1.0,
GasPriceEstimate: "invalid",
Expand Down
Loading