Skip to content

Refund excess value if sent in fx transfer using anchor FX server.#176

Open
ezraripps wants to merge 2 commits intomainfrom
feature/refund-excess-fx
Open

Refund excess value if sent in fx transfer using anchor FX server.#176
ezraripps wants to merge 2 commits intomainfrom
feature/refund-excess-fx

Conversation

@ezraripps
Copy link
Member

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
throw(new Error('No block computed'));
}

const costTokenBalancePre = await client.balance(testCase.quote.cost.token)
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 5, 2026

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