Sep38Quote Request
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 timeExample - 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 flowSee also:
Sep38QuoteResponse for the response structure
Sep38PriceResponse for indicative (non-binding) prices
Constructors
Properties
Optional delivery method name from GET /info response (for off-chain buy assets)
Optional ISO 3166-1 alpha-2 or ISO 3166-2 country code
Optional desired expiration time in ISO 8601 format (UTC)
Optional amount of sellAsset to exchange (provide either this or buyAmount)
Optional delivery method name from GET /info response (for off-chain sell assets)