Skip to content

Conversation

@dangeross
Copy link
Collaborator

@dangeross dangeross commented Dec 2, 2025

Preparation PR for token to lightning payments

  • Adds Flashnet client
  • Handles failed conversions by manually checking and performing refunds if necessary

@dangeross dangeross changed the base branch from main to savage-payment-update-persistence December 2, 2025 14:12
@dangeross dangeross force-pushed the savage-token-transfers branch 4 times, most recently from eb80ff5 to 54047cb Compare December 3, 2025 09:00
@dangeross dangeross marked this pull request as ready for review December 3, 2025 12:44
Copy link
Member

@roeierez roeierez left a comment

Choose a reason for hiding this comment

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

Looks really good!

"Amount in {amount_in} is less than minimum required {min_in} for asset {asset_in_address}",
)));
}
return Ok(());
Copy link
Member

Choose a reason for hiding this comment

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

We skip here without checking the min_amount_out ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copied logic from the Flashnet SDK. You think it's worth checking?

Copy link
Member

Choose a reason for hiding this comment

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

To me it looks like the min_amount_out is not validated in this case. It looks like a bug unless it is not used when min_in is set.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I was assuming if there's a min in to check and it's valid, we don't need to check the min out also

@dangeross dangeross changed the title Token transfers Convert tokens Dec 4, 2025
Copy link
Collaborator

@danielgranhao danielgranhao left a comment

Choose a reason for hiding this comment

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

Awesome! A few comments

@dangeross dangeross force-pushed the savage-token-transfers branch 2 times, most recently from bffa205 to c728a88 Compare December 8, 2025 09:42

tokio::join!(sync_wallet, sync_lnurl, sync_deposits);

if sync_type.contains(SyncType::ConversionInfo) {
Copy link
Member

Choose a reason for hiding this comment

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

My concern here is that we always attempting to approach flashnet API while lots of users won't use it. Slowing the sync for most cases for no reason.
Perhaps we can add a config flag (enable_flashnet) to signal we need to sync with it?

Copy link
Member

@roeierez roeierez left a comment

Choose a reason for hiding this comment

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

Looks a lot better. I still plan to do another review.

Comment on lines 1725 to 1747
let pools_response = self
.flashnet_client
.list_pools(ListPoolsRequest {
asset_a_address: Some(asset_in_address.clone()),
asset_b_address: Some(asset_out_address.clone()),
sort: Some(PoolSortOrder::Volume24hDesc),
..Default::default()
})
.await?;
// Get the pool for the conversion
let pool = pools_response.pools.first().ok_or(SdkError::Generic(
"No pool found for the given token identifier".to_string(),
))?;
let response = self
.flashnet_client
.simulate_swap(SimulateSwapRequest {
asset_in_address: asset_in_address.clone(),
asset_out_address: asset_out_address.clone(),
pool_id: pool.lp_public_key,
amount_in: request.amount,
integrator_bps: None,
})
.await?;
Copy link
Member

Choose a reason for hiding this comment

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

Now that we don't need to sync we can treat flashnet as a swapper (swap provider) from the sdk perspective and this code (and some more )could be extracted out to its own swapper trait/service. It it a nice to have for now that will get the flashnet specifics out of the sdk generic code. I wouldn't hold the merge for this feedback.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe it could even be a plugin? Then, even multiple swappers could be used by the same SDK instance

Copy link
Member

Choose a reason for hiding this comment

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

I agree but I would rather wait for another implementation before attempting to generalize as a plugin. This has complexities also around integration with the payment list, sync etc... perhaps it is too soon.

Copy link
Collaborator

@danielgranhao danielgranhao left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@roeierez roeierez left a comment

Choose a reason for hiding this comment

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

LGTM

@dangeross dangeross changed the title Convert tokens Prep for token to lightning payments Dec 17, 2025
Copy link
Collaborator

@JssDWt JssDWt left a comment

Choose a reason for hiding this comment

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

LGTM

@dangeross dangeross force-pushed the savage-payment-update-persistence branch from 0823ef4 to 08dd127 Compare December 22, 2025 13:39
@dangeross dangeross force-pushed the savage-token-transfers branch from 7e63851 to 3316594 Compare December 22, 2025 13:52
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.

5 participants