Chapter 2

Salesforce Formula:

IF(
  RecordType.Name = 'Sales' && ISPICKVAL(StageName, 'Closed Won'),
   ARR__c,
  IF(
    RecordType.Name = 'Renewal' && ISPICKVAL(StageName, 'Closed Lost'),
    -ARR_Up_For_Renewal__c,
    IF(
      RecordType.Name = 'Renewal' && ISPICKVAL(StageName, 'Closed Won'),
      IF(
        ARR__c - ARR_Up_For_Renewal__c> 0,
        ARR__c - ARR_Up_For_Renewal__c,
        IF(
          ARR__c - ARR_Up_For_Renewal__c < 0,
          ARR__c - ARR_Up_For_Renewal__c,
          0
        )
      ),
      NULL
    )
  )
)

Explanation:

Chapter 3

Salesforce Formula:

IF(
  RecordType.Name = 'Sales' && ISPICKVAL(StageName, 'Closed Won'),
   ARR__c ,
  IF(
    RecordType.Name = 'Upsell' && ISPICKVAL(StageName, 'Closed Won'),
    ARR__c ,
    IF(
      RecordType.Name = 'Renewal' && ISPICKVAL(StageName, 'Closed Lost'),
      -ARR_Up_For_Renewal__c,
      IF(
        RecordType.Name = 'Renewal' && ISPICKVAL(StageName, 'Closed Won'),
        IF(
          ARR__c - ARR_Up_For_Renewal__c > 0,
          ARR__c - ARR_Up_For_Renewal__c,
          IF(
            ARR__c - ARR_Up_For_Renewal__c < 0,
            ARR__c - ARR_Up_For_Renewal__c,
            0
          )
        ),
        NULL
      )
    )
  )
)

Explanation: