Refund excess value if sent in fx transfer using anchor FX server.#176
Refund excess value if sent in fx transfer using anchor FX server.#176
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements a refund mechanism for excess value sent in FX transfers through the anchor FX server. When users send more tokens than required for a conversion (either in the source token or the cost token), the excess amount is automatically refunded back to the user.
Changes:
- Added refund calculation logic to detect and track excess tokens sent by users
- Modified the FX server to process refunds by sending excess tokens back to users
- Added comprehensive integration tests covering various refund scenarios
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/services/fx/util.ts | Added RefundValue type and refund calculation logic to assertExchangeBlockParameters function; changed return type from void to object containing refunds array |
| src/services/fx/server.ts | Imported RefundValue type; captured and applied refunds from assertExchangeBlockParameters when processing estimate-based exchanges |
| src/services/fx/client.test.ts | Added comprehensive integration tests for refund functionality covering multiple scenarios including different affinity types, cost tokens, and excess amounts |
|
|
||
| await waitForExchangeToComplete(serverDoesNotRequireQuote, exchange); | ||
|
|
||
| const costTokenBalancePost = await client.balance(testCase.quote.cost.token) |
There was a problem hiding this comment.
Missing semicolon at the end of the statement. While JavaScript allows this due to automatic semicolon insertion, adding it would maintain consistency with the rest of the codebase (e.g., line 1286).
| throw(new Error('No block computed')); | ||
| } | ||
|
|
||
| const costTokenBalancePre = await client.balance(testCase.quote.cost.token) |
There was a problem hiding this comment.
Missing semicolon at the end of the statement. While JavaScript allows this due to automatic semicolon insertion, adding it would maintain consistency with the rest of the codebase (e.g., line 1278).
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|



No description provided.