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

[THORChainSwap]: Add support for Streaming Swaps #3385

Merged
merged 2 commits into from
Aug 21, 2023
Merged

Conversation

satoshiotomakan
Copy link
Collaborator

@satoshiotomakan satoshiotomakan commented Aug 21, 2023

Description

THORSwap recently implement streaming swaps. Streamers execute at 99.5% and better, it's recommended to use streaming at 1-block intervals, with the protocol determining the count.

Docs: https://dev.thorchain.org/thorchain-dev/concepts/streaming-swaps

How to test

Types of changes

  • Make to_amount_limit optional with the 0 default value
  • Add the interval and quantity optional streaming parameters with the 1 and 0 default values correspondingly.

Next

The next and final step is to set the stream_params value in SwapInput on the end-user app side:

        val input = THORChainSwap.SwapInput.newBuilder()
        input.apply {
            fromAsset = THORChainSwap.Asset.newBuilder().apply {
                chain = THORChainSwap.Chain.ETH
            }.build()
            fromAddress = "0xb9f5771c27664bf2282d98e09d7f50cec7cb01a7"
            toAsset = THORChainSwap.Asset.newBuilder().apply {
                chain = THORChainSwap.Chain.BNB
                symbol = "BNB"
                tokenId = ""
            }.build()
            toAddress = "bnb1us47wdhfx08ch97zdueh3x3u5murfrx30jecrx"
            vaultAddress = "0x1091c4De6a3cF09CdA00AbDAeD42c7c3B69C83EC"
            routerAddress = "0x42A5Ed456650a09Dc10EBc6361A7480fDd61f27B"
            fromAmount = "50000000000000000"
            toAmountLimit = "600003" // Now optional
            streamParams = THORChainSwap.StreamParams.newBuilder().apply {
                interval = "1"
                quantity = "0"
            }.build()
            affiliateFeeAddress = "tthor1ql2tcqyrqsgnql2tcqyj2n8kfdmt9lh0yzql2tcqy"
            affiliateFeeRateBp = "10"
        }

Checklist

  • Create pull request as draft initially, unless its complete.
  • Add tests to cover changes as needed.
  • Update documentation as needed.
  • If there is a related Issue, mention it in the description.

If you're adding a new blockchain

  • I have read the guidelines for adding a new blockchain.

@Milerius Milerius merged commit 6dc5acb into master Aug 21, 2023
12 checks passed
@Milerius Milerius deleted the s/swap-stream branch August 21, 2023 15:54
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