Skip to content

Implement invoice auto-currency conversion #88

@Kingsman-99

Description

@Kingsman-99

Label: complexity: high
Points: 200

Description

Payers holding XLM or other Stellar assets cannot pay USDC invoices directly. This issue adds an auto_convert: bool flag to pay() — when true, the contract calls the Stellar DEX to swap the payer's asset to the invoice token before crediting the payment.

Technical Context

Involves lib.rs pay(). Add auto_convert: bool parameter. When true, invoke a DEX swap contract (mock interface in tests) to convert payer's source asset to invoice.token before the standard token_client.transfer(). The swapped amount is what gets credited to invoice.funded.

Acceptance Criteria

  • pay() accepts auto_convert: bool parameter
  • auto_convert = false produces identical behaviour to current implementation
  • When auto_convert = true, DEX swap is invoked before crediting payment
  • Swapped amount correctly credited to invoice.funded
  • Test mocks DEX swap and verifies invoice funded with converted amount
  • All existing cargo tests pass
  • cargo clippy passes with zero warnings

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programcomplexity: highComplex feature requiring deep knowledge - 200 pts

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions