user1369: I'm doing some analysis on Db-sync and I came across a situation where it appeared the full EUTXO at an address was not being spent so wanted to see what I was misunderstanding.
Here is the first transaction:
https://cardanoscan.io/transaction/23141e4c6fed6114dc77f5e7d1bd6e115d983e5704dd2206b0af3a41fe924c2b
Notice there are 2 amounts going to the address ending in 3d for 6.4 Ada and 118k Ada.
Now look at what I believe to be the only transaction that consumes the EUTXO at this address.
https://cardanoscan.io/transaction/10beefe48f417f3fdb9d164da95adf78e9efaf22f24c0a24893b68fe8e322f68
I can see the 6.4 Ada being spent but not the 118k. They do have different 'index' fields in db-Sync so is that why? i.e. it's not all the Ada at one address that gets sent, but only enough indexes as needed?
-- Edit --
Just to add clarity:
a) The first transaction has two amounts going back to the same user. This I presume means it's getting back two separate EUTXOs - one containing additional tokens, and the other just Ada.
b) When I look for these transaction outputs in DbSync (tx_out table) the only way I can identify them as separate EUTXOs is if I treat Address + Transaction ID + Index as the unique ID
c) Therefore is it fair to say that when making a transaction the wallet treats everything with a unique Address + Transaction ID + Index as a separate EUTXO, and this is why the wallet did not need to consume the 118k EUTXO from the first transaction?

user4302: 
In the first transaction (starting with 23141), there is a single input UTXO with three outputs - the first output (4.5 ADA) going to a non-staking address, the second and third outputs are going back to the sender's address, likely as change.

The second transaction (starting with 10beef) has three inputs and three outputs. The first two inputs are from the sender, and the third input is from a different address, likely a script address. The first output is to the same non-staking address as the first output in the first (above) TX, and the last two outputs are again going back to the sender.


UTXOs are always consumed in whole when used as inputs. The confusion may have been in the fact that the majority of the contents in both transactions go back to the same address, but they do so in the form of new UTXOs. In this case, a lot of ADA and other tokens were all sitting in a single UTXO, so when the user ordered the swap, the entire UTXO was consumed and most of its contents were returned back as change in a new UTXO. Whatever assets were required for the swap were output as separate UTXOs.

user4627: I think there might be a misunderstanding in the fact that a transaction has several "outputs" - and those outputs are called "UTXO"'s (as long as they are unspent; hence "unspent transaction outputs") - and those can be spent separately.
So one of the UTXOs created by your first transaction holds only Ada (~118k). That output is not used in the second transaction your linking to, though.
Regarding the edit, you can identify any tx output or utxo by "transaction id" + "output index".
The ~118k Ada UTXO for example is still sitting at output index 2 of the transaction 23141e4c6fed6114dc77f5e7d1bd6e115d983e5704dd2206b0af3a41fe924c2b - ready to be spent.

1369: <p>I'm doing some analysis on Db-sync and I came across a situation where it appeared the full EUTXO at an address was not being spent so wanted to see what I was misunderstanding.</p>
<p>Here is the first transaction:
<a href="https://cardanoscan.io/transaction/23141e4c6fed6114dc77f5e7d1bd6e115d983e5704dd2206b0af3a41fe924c2b" rel="nofollow noreferrer">https://cardanoscan.io/transaction/23141e4c6fed6114dc77f5e7d1bd6e115d983e5704dd2206b0af3a41fe924c2b</a></p>
<p>Notice there are 2 amounts going to the address ending in 3d for 6.4 Ada and 118k Ada.</p>
<p>Now look at what I believe to be the only transaction that consumes the EUTXO at this address.
<a href="https://cardanoscan.io/transaction/10beefe48f417f3fdb9d164da95adf78e9efaf22f24c0a24893b68fe8e322f68" rel="nofollow noreferrer">https://cardanoscan.io/transaction/10beefe48f417f3fdb9d164da95adf78e9efaf22f24c0a24893b68fe8e322f68</a></p>
<p>I can see the 6.4 Ada being spent but not the 118k. They do have different 'index' fields in db-Sync so is that why? i.e. it's not all the Ada at one address that gets sent, but only enough indexes as needed?</p>
<p>-- Edit --</p>
<p>Just to add clarity:</p>
<p>a) The first transaction has two amounts going back to the same user. This I presume means it's getting back two separate EUTXOs - one containing additional tokens, and the other just Ada.</p>
<p>b) When I look for these transaction outputs in DbSync (<a href="https://github.com/input-output-hk/cardano-db-sync/blob/master/doc/schema.md#tx_out" rel="nofollow noreferrer">tx_out table</a>) the only way I can identify them as separate EUTXOs is if I treat Address + Transaction ID + Index as the unique ID</p>
<p>c) Therefore is it fair to say that when making a transaction the wallet treats everything with a unique Address + Transaction ID + Index as a separate EUTXO, and this is why the wallet did not need to consume the 118k EUTXO from the first transaction?</p>
 4302: <ol>
<li><p>In the first transaction (starting with 23141), there is a single input UTXO with three outputs - the first output (4.5 ADA) going to a non-staking address, the second <em>and</em> third outputs are going <strong>back</strong> to the sender's address, likely as change.</p>
</li>
<li><p>The second transaction (starting with 10beef) has three inputs and three outputs. The first two inputs are from the sender, and the third input is from a different address, likely a script address. The first output is to the same non-staking address as the first output in the first (above) TX, and the last two outputs are again going back to the sender.</p>
</li>
</ol>
<p>UTXOs are <em><strong>always</strong></em> consumed in whole when used as inputs. The confusion may have been in the fact that the majority of the contents in both transactions go back to the same address, but they do so in the form of <strong>new UTXOs</strong>. In this case, a lot of ADA and other tokens were all sitting in a single UTXO, so when the user ordered the swap, the entire UTXO was consumed and most of its contents were returned back as change in a new UTXO. Whatever assets were required for the swap were output as separate UTXOs.</p>
 4627: <p>I think there might be a misunderstanding in the fact that a transaction has several &quot;outputs&quot; - and those outputs are called &quot;UTXO&quot;'s <em>(as long as they are unspent; hence &quot;unspent transaction outputs&quot;)</em> - and those can be spent separately.</p>
<p>So one of the UTXOs created by your first transaction holds only Ada (~118k). That output is not used in the second transaction your linking to, though.</p>
<p>Regarding the edit, you can identify any tx output or utxo by &quot;transaction id&quot; + &quot;output index&quot;.</p>
<p>The ~118k Ada UTXO for example is still sitting at output index <em>2</em> of the transaction <em>23141e4c6fed6114dc77f5e7d1bd6e115d983e5704dd2206b0af3a41fe924c2b</em> - ready to be spent.</p>
