Skip to content

Add rate field to GetQuoteResponse#157

Merged
PurpleTheBest merged 1 commit into
devfrom
add-rate-to-quote-response
Apr 22, 2026
Merged

Add rate field to GetQuoteResponse#157
PurpleTheBest merged 1 commit into
devfrom
add-rate-to-quote-response

Conversation

@PurpleTheBest
Copy link
Copy Markdown
Contributor

Summary

  • Adds a rate field to GetQuoteResponse (proto + C# DTO) carrying the dest/source conversion ratio as an invariant-culture decimal string, truncated to 6 decimals.
  • Populated in QuoteService.GetQuoteAsync from the route's IRateProvider and mapped through SolverProtoMapper.ToGetQuoteResponse. Single-leg paths make Layerswap's multiplicative path aggregate reduce to the provider's rate directly.
  • Intentionally not part of the signing payload — it's informational and derivable from the already-signed amount / receive-amount pair.

Files

  • protos/solver.protostring rate = 14; on GetQuoteResponse
  • csharp/src/Shared.Models/Models/QuoteDto.cspublic decimal Rate { get; set; }
  • csharp/src/Infrastructure/Quote/QuoteService.csRate = swapRate.Truncate(6) on the QuoteWithSolverDto initializer
  • csharp/src/Shared.Proto/SolverProtoMapper.cs — maps quote.Rate.ToString(InvariantCulture) into the gRPC response

Test plan

  • dotnet build csharp/src/Shared.Proto/Proto.csproj succeeds (regenerates gRPC stubs with new field)
  • dotnet build csharp/src/Infrastructure/Infrastructure.csproj succeeds
  • dotnet test csharp/tests/Util.Tests/Util.Tests.csproj — existing QuoteServiceTests stay green
  • Manual gateway call: GetQuote response includes a non-empty rate field and is consistent with receive_amount / amount after fee subtraction
  • StationAPI aggregator passes the new field through unchanged to downstream clients

🤖 Generated with Claude Code

Exposes the dest/source conversion rate on the quote response so clients can
surface it alongside the receive amount, matching the existing Layerswap
quote payload shape.

Rate comes from the route's IRateProvider and is truncated to 6 decimals
(matching Layerswap's Constants.UsdPrecision). Single-leg paths reduce the
Layerswap multiplicative path aggregate to the provider's rate directly.
Intentionally not part of the signing payload — it's informational and
derivable from the already-signed amount/receive-amount pair.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@PurpleTheBest PurpleTheBest merged commit 954cd29 into dev Apr 22, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant