Skip to content
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

Automatic swap refund bot #15

Merged
merged 12 commits into from
Jun 18, 2020
Merged

Automatic swap refund bot #15

merged 12 commits into from
Jun 18, 2020

Conversation

denalimarsh
Copy link
Contributor

@denalimarsh denalimarsh commented Jun 15, 2020

Introduces RefundBot, a swap refund process that scans Kava and Binance Chain for refundable swaps and automatically processes them. Works on testnet. Once approved, I'll launch a server for RefundBot and put it live on mainnet. Edit: RefundBot is live on mainnet.

Example testnet refund cron routine output:

[2020-06-15T08:51:32.754Z] Kava refundable swap count: 1
[2020-06-15T08:51:32.757Z]      Refunding swap 251165847a4f65efe47174339b76cf65f817e5fd700018d51a8dad89e4b2ec1f
[2020-06-15T08:51:32.790Z]      Tx hash: D3F38B67C2E0BF073E1BC1111CAEF09F81141B1DA568C2C462AE3E909B4F2D6E
[2020-06-15T08:51:39.458Z] Binance Chain refundable swap count: 8
[2020-06-15T08:51:39.458Z]      Refunding swap 5a044d1e9fe39f1065a61bfa2dc66b3ead80ddf84b960f8fbbfc7d39609bad10
[2020-06-15T08:51:40.789Z]      Tx hash: 541F78A34A4BDCE69F8ECE61E362681C47D17746AC43C2F5D3ED7F6602615FBA
[2020-06-15T08:51:43.793Z]      Refunding swap 130cd8ec49960989343f7988c7d728959ad8e8fbca363350d32bb7ff418d1252
[2020-06-15T08:51:45.239Z]      Tx hash: 4EB31E241535EEAA3095CB96EEC7446CB0E28441A570856078ADB071F015FCEC
[2020-06-15T08:51:48.243Z]      Refunding swap eb69463cc2063d230ec9079b91495c309c68ccdf7d8811db1aa488ee72a64dbd
[2020-06-15T08:51:48.879Z]      Tx hash: 68982CEC5F3EC870CC9018CA99C89E289E6854C135573850082C70474128361D
...

The RefundBot waits 3 seconds between posting refund txs to Binance Chain, otherwise, an account sequence error is thrown. I've created #14 for upstreaming this to the binance-chain/javascript-sdk.

Every hour the query offsets are printed. Binance Chain uses a different swap querying strategy and this monitoring allows for debugging and future optimization:

[2020-06-15T08:54:12.153Z] Current Binance Chain offsets:
[2020-06-15T08:54:12.154Z]      Offset incoming: 0
[2020-06-15T08:54:12.154Z]      Offset outgoing: 0

@denalimarsh denalimarsh added the R4R Request for review label Jun 15, 2020
@denalimarsh denalimarsh requested review from nddeluca and karzak June 15, 2020 12:25
@denalimarsh
Copy link
Contributor Author

NOTE: This PR updates @kava-labs/javascript-sdk to ^2.0.0-beta.6, which includes significant client changes. Before this PR is merged all other kava-tools should be run on this branch to confirm everything works fine.

Copy link
Member

@nddeluca nddeluca left a comment

Choose a reason for hiding this comment

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

I think there is just that one missing return statement is all that needs to be changed.

Rest of feedback is just comments and code style stuff.

scripts/refund.js Show resolved Hide resolved
refund/refund.js Show resolved Hide resolved
refund/refund.js Outdated Show resolved Hide resolved
refund/refund.js Show resolved Hide resolved
refund/refund.js Outdated Show resolved Hide resolved
refund/refund.js Outdated Show resolved Hide resolved
@denalimarsh denalimarsh requested a review from nddeluca June 18, 2020 12:26
Copy link
Member

@nddeluca nddeluca left a comment

Choose a reason for hiding this comment

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

💯

@denalimarsh denalimarsh merged commit 5c89e4e into master Jun 18, 2020
@denalimarsh denalimarsh deleted the dm-refund-bot branch June 18, 2020 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R4R Request for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants