-
Notifications
You must be signed in to change notification settings - Fork 18
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
Conversation
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.
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.
There was a problem hiding this 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
if deposit.status == 1 && // 1 = success | ||
deposit.coin == binance_coin_name && | ||
deposit.network == binance_network_info.network && | ||
deposit_amount == amount_to_transfer |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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(), |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
tee-worker/omni-executor/intent/executors/cross-chain/src/lib.rs
Outdated
Show resolved
Hide resolved
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.
There was a problem hiding this 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
I agree, the sooner we start testing the better |
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