Sep38PricesResponse

@Serializable
data class Sep38PricesResponse(val buyAssets: List<Sep38BuyAsset>? = null, val sellAssets: List<Sep38SellAsset>? = null)

Response containing indicative prices for multiple assets.

Returns a list of available buy assets OR sell assets with their indicative prices. Used to display multiple exchange options to users before they select a specific asset pair for a firm quote.

The response contains either buyAssets (when selling a specific asset) or sellAssets (when buying a specific asset), but never both in the same response.

Indicative prices are non-binding estimates and may change. For binding commitments, use the POST /quote endpoint to request a firm quote.

Example - Getting buy options (selling USDC):

val pricesResponse = sep38Service.prices(
sellAsset = "stellar:USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
sellAmount = "100"
)

// Response contains buyAssets (what you can buy with 100 USDC)
pricesResponse.buyAssets?.forEach { buyAsset ->
println("Buy ${buyAsset.asset} at price ${buyAsset.price} (${buyAsset.decimals} decimals)")
}
// Output:
// Buy iso4217:BRL at price 0.18 (2 decimals)
// Buy iso4217:USD at price 1.00 (2 decimals)

Example - Getting sell options (buying USDC):

val pricesResponse = sep38Service.prices(
buyAsset = "stellar:USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
buyAmount = "100"
)

// Response contains sellAssets (what you need to sell to get 100 USDC)
pricesResponse.sellAssets?.forEach { sellAsset ->
println("Sell ${sellAsset.asset} at price ${sellAsset.price} (${sellAsset.decimals} decimals)")
}
// Output:
// Sell iso4217:BRL at price 5.42 (2 decimals)
// Sell iso4217:USD at price 1.00 (2 decimals)

Example - Building asset selection UI:

val pricesResponse = sep38Service.prices(
sellAsset = "stellar:USDC:G...",
sellAmount = "100",
countryCode = "BR"
)

pricesResponse.buyAssets?.forEach { buyAsset ->
val assetName = extractAssetName(buyAsset.asset)
val formattedPrice = "%.${buyAsset.decimals}f".format(buyAsset.price.toDouble())

displayAssetOption(
name = assetName,
price = formattedPrice,
onClick = { proceedToQuote(buyAsset) }
)
}

Example - Filtering and sorting prices:

val pricesResponse = sep38Service.prices(
sellAsset = "stellar:USDC:G...",
sellAmount = "1000"
)

// Find best rate (highest price when selling)
val bestRate = pricesResponse.buyAssets
?.maxByOrNull { it.price.toDouble() }

println("Best rate: ${bestRate?.asset} at ${bestRate?.price}")

See also:

Constructors

Link copied to clipboard
constructor(buyAssets: List<Sep38BuyAsset>? = null, sellAssets: List<Sep38SellAsset>? = null)

Properties

Link copied to clipboard
@SerialName(value = "buy_assets")
val buyAssets: List<Sep38BuyAsset>?

List of available buy assets with prices (present when selling a specific asset)

Link copied to clipboard
@SerialName(value = "sell_assets")
val sellAssets: List<Sep38SellAsset>?

List of available sell assets with prices (present when buying a specific asset)