Skip to content

Instantly share code, notes, and snippets.

@ripzery
Last active August 10, 2020 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ripzery/ab05700e60964502c4a3ef0b4601588c to your computer and use it in GitHub Desktop.
Save ripzery/ab05700e60964502c4a3ef0b4601588c to your computer and use it in GitHub Desktop.

UTXOs

Given that:

  • ETH is a token user wants to send
  • OMG is a fee token
ETH OMG
5 5
10 10
15 -
20 -

Strategy

Pick fee tokens first for the stealth inputs (because fee token is often used)

Send Amount (ETH) Fee Amount (OMG) Inputs Stealth Inputs
5 3 5 ETH, 10 OMG 5 OMG, 20 ETH
35 8 20 ETH, 15 ETH, 10 OMG 5 OMG
35 15 20 ETH, 15 ETH, 10 OMG, 5 OMG -
12 15 20 ETH, 10 OMG, 5 OMG 15 ETH
30 10 20 ETH, 15 ETH, 10 OMG 5 OMG
15 10 15 ETH, 10 OMG 5 OMG, 20 ETH
@kalouo
Copy link

kalouo commented Aug 10, 2020

Example 1. Makes sense.
Example 2. Makes sense
Example 3. Makes sense
Example 4. Makes sense

Example 5. This would have no benefit because you will return an output of 5 OMG, which is equivalent to the input you put in. What you could do here is put an extra ETH input.
Example 6. Again, this would have no benefit as you would return the same stealth inputs as outputs. What you could do is add two inputs of the same currency.

I have clarified the logic in what I wrote:

U < 3; input amounts match corresponding currency payables exactly -> Stealth merge if 2 or more UTXOs of the same currency available.
U < 4; input amounts exceed corresponding currency payables -> Stealth merge if 1 or more UTXOs available on a currency where we expect "change"

@kalouo
Copy link

kalouo commented Aug 10, 2020

Thanks! The above would serve as good test cases!

@kalouo
Copy link

kalouo commented Aug 10, 2020

We also need to clarify two things:

  • Do we prioritise larger or smaller inputs for stealth merge? 🤔
  • How do we prioritise currencies for stealth merge? I propose we order currencies by number of UTXOs, given that each currency has an exit queue and this is what we are trying to shorten in the case of a mass exit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment