Sep38QuoteRequest

@Serializable
data class Sep38QuoteRequest(val context: String, val sellAsset: String, val buyAsset: String, val sellAmount: String? = null, val buyAmount: String? = null, val expireAfter: String? = null, val sellDeliveryMethod: String? = null, val buyDeliveryMethod: String? = null, val countryCode: String? = null)

Request for creating a firm quote.

Specifies the parameters for a binding quote commitment from the anchor. Either sellAmount or buyAmount must be provided, but not both.

The anchor will reserve liquidity at the quoted rate until the quote expires. The quote can be used with SEP-6, SEP-24, or SEP-31 transactions by referencing the quote ID returned in the response.

Example - Request quote for selling BRL:

val request = Sep38QuoteRequest(
context = "sep6",
sellAsset = "iso4217:BRL",
buyAsset = "stellar:USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
sellAmount = "542",
sellDeliveryMethod = "PIX",
countryCode = "BR"
)

val quote = sep38Service.postQuote(request, jwtToken)

Example - Request quote for buying USDC:

val request = Sep38QuoteRequest(
context = "sep31",
sellAsset = "iso4217:BRL",
buyAsset = "stellar:USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
buyAmount = "100",
sellDeliveryMethod = "PIX",
countryCode = "BR"
)

val quote = sep38Service.postQuote(request, jwtToken)

Example - Request quote with custom expiration:

val request = Sep38QuoteRequest(
context = "sep6",
sellAsset = "stellar:USDC:G...",
buyAsset = "iso4217:USD",
sellAmount = "100",
expireAfter = "2021-04-30T07:42:23Z" // ISO 8601 format
)

val quote = sep38Service.postQuote(request, jwtToken)
// Anchor may provide expires_at on or after the requested expireAfter time

Example - Request quote with both delivery methods:

val request = Sep38QuoteRequest(
context = "sep6",
sellAsset = "iso4217:BRL",
buyAsset = "iso4217:USD",
sellAmount = "500",
sellDeliveryMethod = "PIX",
buyDeliveryMethod = "WIRE",
countryCode = "BR"
)

val quote = sep38Service.postQuote(request, jwtToken)
// Exchange BRL (via PIX) for USD (via wire transfer)

Example - Validation before request:

fun createQuoteRequest(
sellAsset: String,
buyAsset: String,
sellAmount: String? = null,
buyAmount: String? = null
): Sep38QuoteRequest {
// Must provide exactly one amount
require((sellAmount != null) xor (buyAmount != null)) {
"Must provide either sellAmount or buyAmount, but not both"
}

return Sep38QuoteRequest(
context = "sep6",
sellAsset = sellAsset,
buyAsset = buyAsset,
sellAmount = sellAmount,
buyAmount = buyAmount
)
}

Example - SEP-24 interactive flow context:

val request = Sep38QuoteRequest(
context = "sep24", // For interactive deposit/withdrawal
sellAsset = "iso4217:USD",
buyAsset = "stellar:USDC:G...",
sellAmount = "100",
buyDeliveryMethod = "bank_account"
)

val quote = sep38Service.postQuote(request, jwtToken)
// Use quote in SEP-24 interactive flow

See also:

Constructors

Link copied to clipboard
constructor(context: String, sellAsset: String, buyAsset: String, sellAmount: String? = null, buyAmount: String? = null, expireAfter: String? = null, sellDeliveryMethod: String? = null, buyDeliveryMethod: String? = null, countryCode: String? = null)

Properties

Link copied to clipboard
@SerialName(value = "buy_amount")
val buyAmount: String?

Optional amount of buyAsset to receive (provide either this or sellAmount)

Link copied to clipboard
@SerialName(value = "buy_asset")
val buyAsset: String

Asset to buy using Asset Identification Format

Link copied to clipboard
@SerialName(value = "buy_delivery_method")
val buyDeliveryMethod: String?

Optional delivery method name from GET /info response (for off-chain buy assets)

Link copied to clipboard
@SerialName(value = "context")
val context: String

Context for quote usage ("sep6", "sep24", or "sep31")

Link copied to clipboard
@SerialName(value = "country_code")
val countryCode: String?

Optional ISO 3166-1 alpha-2 or ISO 3166-2 country code

Link copied to clipboard
@SerialName(value = "expire_after")
val expireAfter: String?

Optional desired expiration time in ISO 8601 format (UTC)

Link copied to clipboard
@SerialName(value = "sell_amount")
val sellAmount: String?

Optional amount of sellAsset to exchange (provide either this or buyAmount)

Link copied to clipboard
@SerialName(value = "sell_asset")
val sellAsset: String

Asset to sell using Asset Identification Format (e.g., "stellar:USDC:G...", "iso4217:BRL")

Link copied to clipboard
@SerialName(value = "sell_delivery_method")
val sellDeliveryMethod: String?

Optional delivery method name from GET /info response (for off-chain sell assets)