Match previous results in $lookup

Given is the working code below.
What’s missing:
In the $lookup I only want the results when the to field of the transfers collection matches the _id field of one group result one step ahead. Meaning I want to match the to field against the set of all group results.
Let me give you an example:

transfers (called T)

  1. from: 0x1, to: 0x2, address: 0xFF
  2. from: 0x1, to: 0x3, address: 0xFF
  3. from: 0x1, to: 0x5, address: 0xFF
  4. from: 0x1, to: 0x6, address: 0xFF
  5. from: 0x2, to: 0x6, address: 0xFF
  6. from: 0x2, to: 0x4, address: 0xFF

swaps group results (called G)

  1. _id: 0x1, token: 0xFF, …
  2. _id: 0x2, token: 0xFF, …
  3. _id: 0x3, token: 0xFF, …
  4. _id: 0x4, token: 0xFF, …

After $lookup G would look like (called R):

  1. _id: 0x1, token: 0xFF, confluence: [ {to: 0x2}, {to: 0x3} ] …
  2. _id: 0x2, token: 0xFF, confluence: [ {to: 0x4}], …
  3. _id: 0x3, token: 0xFF, confluence: , …
  4. _id: 0x4, token: 0xFF, confluence: , …

0x5 and 0x6 are not part of the confluence field in result 1 as missing in G.
Feedback is highly appreciated.

db.swaps.aggregate([
   {
      $match: {
         'tokenOut.address': '0x24d73bca2bd9c3a61e99dfc7cb86d3c379ebded7',
      },
   },
   {
      $project: {
         _id: 0,
         wallet: '$taker',
         amountSpent: '$amountWETH',
         amountBought: '$amountOut',
         token: '$tokenOut'
      },
   },
   {
      $unionWith: {
         coll: 'swaps',
         pipeline: [
            {
               $match: {
                  'tokenIn.address': '0x24d73bca2bd9c3a61e99dfc7cb86d3c379ebded7',
               },
            },
            {
               $project: {
                  _id: 0,
                  wallet: '$maker',
                  amountEarned: '$amountWETH',
                  amountSold: '$amountIn',
                  token: '$tokenIn'
               },
            },
         ],
      },
   },
	{
     	$group: {
            _id: '$wallet',
            amountSpent: { $sum: '$amountSpent' }, // WETH
            amountEarned: { $sum: '$amountEarned' }, // WETH
            amountBought: { $sum: '$amountBought' }, // Token
            amountSold: { $sum: '$amountSold' }, // Token
            token: { $first: '$token' },
            chain: { $first: '$chain' }
      }
   },
	{
		$lookup: {
			from: 'transfers',
			let: { wallet: '$_id', token: '$token.address' },
			pipeline: [
				{
					$match: {
						$expr: {
                     $and: [
                        { $eq: [ '$from', '$$wallet' ] },
                        { $ne: [ '$address', '$$token' ] }
                     ]
						}
					}
				},
				{
					$project: { _id: 0, to: 1 }
				}
			],
			as: 'confluence'
		}
	},
   {
      $addFields: {
         wallet: '$_id',
      // ROI: (100 / amountSpent) * (amountEarned - amountSpent)
      realizedPnL: {
         $multiply: [
         { $divide: [ 100, '$amountSpent' ] },
         { $subtract: [ '$amountEarned', '$amountSpent' ] }
         ]
         }
      }
   },
   {
      // sort documents by PnL
      $sort: {
         realizedPnL: -1,
      },
   }
])

What does this mean? What determines the ordering of the group results?