Skip to content

Improve binance spot trading logic #3392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Apr 15, 2025

Conversation

silva-fj
Copy link
Contributor

@silva-fj silva-fj commented Apr 14, 2025

Improving cross chain swaps by waiting until the deposit has been confirmed before attempt to create a market trade order on Binance. Additionaly, if the trade fails, the assets are transferred back to the OmniAccount

Add deposit confirmation logic to cross-chain executor to ensure funds
have been successfully received by Binance before attempting to create
market orders. Implements a polling mechanism with timeout to verify
deposit status, making the cross-chain swap process more robust and
reliable.
Copy link

linear bot commented Apr 14, 2025

Implement the withdraw API endpoint for the Binance wallet API, allowing
the submission of withdrawal requests.
When a Binance spot trade order fails to be created, the system now
automatically withdraws the assets back to the Omni account instead of
just logging an error.
@silva-fj silva-fj requested review from Kailai-Wang, kziemianek and a team April 15, 2025 01:40
@silva-fj silva-fj marked this pull request as ready for review April 15, 2025 01:40
Copy link
Collaborator

@Kailai-Wang Kailai-Wang left a comment

Choose a reason for hiding this comment

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

Thanks! I left a few comments

Comment on lines 676 to 679
if deposit.status == 1 && // 1 = success
deposit.coin == binance_coin_name &&
deposit.network == binance_network_info.network &&
deposit_amount == amount_to_transfer
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm so if the user somehow makes two consectutive deposit with the same param (coin, network, amount) - can it be differentiated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a txId optional param, let me refactor the solana_client to return the signatures and pass it to the api. But I think we don't need to differentiate them, if the deposit was made the user cannot withdraw the assets. I've also included a filter for the source address to make sure the deposit is from the same user, I will push it soon

.withdraw(
&binance_coin_name,
&from_address,
amount_to_transfer_decimal.to_string(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just to confirm, this is with multiplier, right?

"decimal" here just means the Decimal format, it doesn't mean it's e.g. 0.03 instead of 3 * (10^16) (just example)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is with multiplier but looking at the API docs again, I think this should be the amount we get in pumpx_config, as binance expects a decimal number, so 0.03 in this example

Add transaction ID tracking for cross-chain deposits to improve
reliability when checking deposit status. Modify Solana client to
return transaction signatures and pass them to Binance API to filter
deposit history by specific transactions. Also add handling for
rejected deposits with appropriate error reporting.
Implement withdrawal of assets back to the omni account when a
Binance trade fails.
Copy link
Collaborator

@Kailai-Wang Kailai-Wang left a comment

Choose a reason for hiding this comment

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

@silva-fj I'm happy with it mostly - if there're no major TODOs, I'm inclined to merging it and building a new image cc @BillyWooo

@silva-fj
Copy link
Contributor Author

@silva-fj I'm happy with it mostly - if there're no major TODOs, I'm inclined to merging it and building a new image cc @BillyWooo

I agree, the sooner we start testing the better

@silva-fj silva-fj enabled auto-merge (squash) April 15, 2025 11:33
@silva-fj silva-fj merged commit 994fbb0 into dev Apr 15, 2025
21 checks passed
@silva-fj silva-fj deleted the p-1466-improve-binance-spot-trading-logic branch April 15, 2025 11:58
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