Skip to content
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
3 changes: 3 additions & 0 deletions client/intents.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ type CreateIntentRequest struct {
UserSourceAddress string `json:"user_source_address"`
UserDestinationAddress string `json:"user_destination_address"`
RefundAddress string `json:"refund_address"`

// ReferrerID is an optional identifier for further filtration.
ReferrerID string `json:"referrer_id,omitempty"`
}

// CreateIntentResponse represents the response payload of creating new intent.
Expand Down
6 changes: 6 additions & 0 deletions client/swaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ type ListSwapHistoryParams struct {
Statuses []types.CombinedStatus
// RetailID specifies the retail ID filter.
RetailID string
// ReferrerID is an optional referrer id (setup during intent creation) to request history for.
ReferrerID string
}

func (params *ListSwapHistoryParams) toQueryParams() string {
Expand Down Expand Up @@ -79,6 +81,10 @@ func (params *ListSwapHistoryParams) toQueryParams() string {
q.Set("retail_id", params.RetailID)
}

if params.ReferrerID != "" {
q.Set("referrer_id", params.ReferrerID)
}

for _, status := range params.Statuses {
q.Add("status", status.String())
}
Expand Down
30 changes: 30 additions & 0 deletions types/intents.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package types

import (
"github.com/google/uuid"
)

// CombinedStatus combines intent statuses with swaps statuses to provide a general overview on swap flow progress.
type CombinedStatus string

Expand Down Expand Up @@ -29,3 +33,29 @@ const (
func (s CombinedStatus) String() string {
return string(s)
}

// Fee represents an affiliate fee that will be collected and stored for a specific intent.
type Fee struct {
IntentID uuid.UUID `json:"intent_id"`
SubAffiliateID string `json:"sub_affiliate_id"`
FeeBps *Int `json:"fee_bps"`
NetworkID int64 `json:"network_id"`
Token string `json:"token"`
FeeAmountLots *Int `json:"fee_amount_lots"`
FeeAmountDecimals int64 `json:"fee_amount_decimals"`
Status FeeStatus `json:"status"`
}

// FeeStatus represents settlement status for an affiliate fee.
type FeeStatus string

const (
// FeeStatusCreated defines that fee is in the Created status until the swap is finished for the user (swap_status < Fulfilled).
FeeStatusCreated FeeStatus = "Created"
// FeeStatusToSettle defines that fee moves to ToSettle when the swap is confirmed and completed for the user (swap_status = Fulfilled).
FeeStatusToSettle FeeStatus = "ToSettle"
// FeeStatusCancelled defines that fee is set to Cancelled when the swap fails and transitions to Refunding or Refunded.
FeeStatusCancelled FeeStatus = "Cancelled"
// FeeStatusSettled defines that fee is set to Settled when the swap is completed and the fee has been settled to the affiliate.
FeeStatusSettled FeeStatus = "Settled"
)
10 changes: 6 additions & 4 deletions types/swaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import (

// Swap represents the swap entity data.
type Swap struct {
IntentID uuid.UUID `json:"intent_id"`
Status CombinedStatus `json:"status"`
Metadata *SwapMetadata `json:"swap_metadata,omitempty"`
AdditionalInfo SwapAdditionalInfo `json:"additional_info"`
SwapAdditionalInfo

IntentID uuid.UUID `json:"intent_id"`
Status CombinedStatus `json:"status"`
Metadata *SwapMetadata `json:"swap_metadata,omitempty"`
Fees []Fee `json:"fees"`
}

// SwapMetadata holds swap extra data.
Expand Down
Loading