Skip to content

feat: execute swaps#698

Open
bufo24 wants to merge 9 commits intotrade-magmafrom
trade-execute
Open

feat: execute swaps#698
bufo24 wants to merge 9 commits intotrade-magmafrom
trade-execute

Conversation

@bufo24
Copy link
Copy Markdown
Collaborator

@bufo24 bufo24 commented Apr 9, 2026

No description provided.

input: TradeQuoteInput
): Promise<TradeQuoteResult> {
const [invoice, error] = await toWithError(
this.tapdNodeService.addAssetInvoice({
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why do you use addAssetSellOrder when getting a sell quote but not addAssetBuyOrder?

// 2. Send assets via tapd — it handles RFQ negotiation with the peer,
// routes assets out and sats back to our invoice (circular self-payment)
const [payResult, payError] = await toWithError(
this.tapdNodeService.sendAssetPayment({
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You need to send the original rfqid that you got from addAssetSellOrder into this function and then on to tapd.channels.sendPayment.

Otherwise, the swap node is not bound to the RFQ quote that was returned earlier and a new rate is calculated.

For asset sales, this can mean that you don't actually sell the right amount of asset you intended, because you're specifying your invoice in sats and with a new exchange rate that might be more or less than what you originally specified.

So we want that original quote to be binding.

Also, the quote has a timeout and we should show a timer in the UI that counts down and when it expires, a new quote needs to be fetched.

We should be doing the same with buy orders as well.

Comment on lines +377 to +392
export type ExecuteTradeInput = {
assetAmount: Scalars['String']['input'];
peerPubkey: Scalars['String']['input'];
satsAmount: Scalars['String']['input'];
tapdAssetId: Scalars['String']['input'];
tapdGroupKey?: InputMaybe<Scalars['String']['input']>;
transactionType: TapTransactionType;
};

export type ExecuteTradeResult = {
__typename?: 'ExecuteTradeResult';
amountSats?: Maybe<Scalars['String']['output']>;
feeSats?: Maybe<Scalars['String']['output']>;
paymentPreimage?: Maybe<Scalars['String']['output']>;
success: Scalars['Boolean']['output'];
};
Copy link
Copy Markdown
Collaborator

@wthrajat wthrajat Apr 10, 2026

Choose a reason for hiding this comment

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

I can see these types also from line 1207 to 1220. They're duplicated

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.

3 participants