129.    /// @notice Get the associated risk partner of the leg index (generally another leg index in the position).
130.--> /// @notice that returning the riskPartner for any leg is 0 by default, this does not necessarily imply that token 1 (index 0) //@audit if there is no risk partner this value is set to 0.
131.    /// @notice is the risk partner of that leg. We are assuming here that the position has been validated before this and that
132.    /// @notice the risk partner of any leg always makes sense in this way. A leg btw. does not need to have a risk partner.
133.    /// @notice the point here is that this function is very low level and must be used with utmost care because it comes down
134.--> /// @notice to the caller to interpret whether 00 means "no risk partner" or "risk partner leg index 0".
135.    /// @notice But in general we can return 00, 01, 10, and 11 meaning the partner is leg 0, 1, 2, or 3.
136.    /// @param self the tokenId in the SFPM representing an option position
137.    /// @param legIndex the leg index of this position (in {0,1,2,3})
138.    /// @return the leg index of `legIndex`'s risk partner.
139.    function riskPartner(uint256 self, uint256 legIndex) internal pure returns (uint256) {
140.        unchecked {
141.            return uint256((self >> (64 + legIndex * 48 + 10)) % 4);
142.        }
143.    }
file: TokenId.sol
// function validate()
        // ...

                // In the following, we check whether the risk partner of this leg is itself
                // or another leg in this position.
                // Handles case where riskPartner(i) != i ==> leg i has a risk partner that is another leg
                uint256 riskPartnerIndex = self.riskPartner(i);
-->             if (riskPartnerIndex != i) { //@audit default is 0 not i. If there is no risk partner it is 0. However, this function expects riskPartnerIndex to be equal to i, not zero.
                    // Ensures that risk partners are mutual
                    if (self.riskPartner(riskPartnerIndex) != i)
                        revert Errors.InvalidTokenIdParameter(3);

       // ...
    /// @notice Add the associated risk partner of the leg index (generally another leg in the overall position).
    /// @param self the tokenId in the SFPM representing an option position
    /// @param legIndex the leg index of this position (in {0,1,2,3})
    /// @return the tokenId with riskPartner added to its relevant leg.
    function addRiskPartner(
       ...
function test_Revert_MultiLegged_TokenId_With_DefaultRiskPartner() public {
        _initPool(1);

        uint256 tokenId = uint256(0).addUniv3pool(poolId).addLeg(
            0, //leg index
            1, // option ratio
            0, // asset
            0, // isLong
            0, // tokenType
            0, // riskPartner
            1000, // strike
            10 // width
        );

        // add second leg with riskPartner default 0 (No risk partner);
        tokenId = tokenId.addLeg(
            1, // leg index 
            1, // option ratio
            0, // asset
            0, // isLong
            0, // tokenType
            0, // riskPartner -> It is default 0 (No risk partner)
            1000, // strike
            10 // width
        );

        // Try to mint this token Id.
        // It will revert with InvalidTokenIdParameter(3) error
        vm.expectRevert(abi.encodeWithSelector(Errors.InvalidTokenIdParameter.selector, 3));
        sfpm.mintTokenizedPosition(
            tokenId,
            1e18,
            TickMath.MIN_TICK,
            TickMath.MAX_TICK
        );
    }
Running 1 test for test/foundry/core/SemiFungiblePositionManager.t.sol:SemiFungiblePositionManagerTest
[PASS] test_Revert_MultiLegged_TokenId_With_DefaultRiskPartner() (gas: 1359556)
Logs:
  Bound Result 1

Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 8.29s
 
Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests)
